Skip to content

Don't show the termination info bar for closeOnExit "always" - #21023

Draft
Kevin Wiblin (KevinWiblin) wants to merge 1 commit into
microsoft:mainfrom
KevinWiblin:fix/11608-closeonexit-infobar
Draft

Kevin Wiblin (KevinWiblin) wants to merge 1 commit into
microsoft:mainfrom
KevinWiblin:fix/11608-closeonexit-infobar

Conversation

@KevinWiblin

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

When a profile has closeOnExit set to always and its command exits with a nonzero exit code, Terminal still displays the "Termination behavior can be configured in advanced profile settings" info bar.

The pane closes as expected, but the info bar remains visible despite the user having already configured the termination behaviour.

This change prevents the info bar from being displayed for profiles with closeOnExit set to always.

References and Relevant Issues

Closes #11608

Related to #11607, which concerns the info bar remaining visible after the pane that triggered it has been closed. That issue is outside the scope of this PR.

Detailed Description of the Pull Request / Additional comments

The change is limited to TerminalPage::_ConnectionStateChangedHandler in src/cascadia/TerminalApp/TerminalPage.cpp.

The handler now uses the TermControl that raised the connection state event to locate the corresponding pane by walking the pane trees across all tabs.

If the originating pane's profile has CloseOnExit() set to CloseOnExitMode::Always, the handler returns without displaying the info bar.

The control is obtained from sender before the co_await, as sender is passed by reference and may no longer be valid when the coroutine resumes.

The lookup returns a Pane rather than a Profile, since WalkTree returns R{} when no match is found. Returning a Profile would construct a default profile rather than return null.

The automatic mode behaviour for default terminal sessions introduced in #13325 is deliberately left unchanged. This PR is limited to the always case described in #11608.

Validation Steps Performed

Built and deployed CascadiaPackage (Debug x64) using unmodified main and the patched branch.

Created test profiles using cmd.exe /c exit 1, with closeOnExit set to always and graceful.

  • Before the fix, confirmed that the failing always tab closed but the termination info bar remained visible.
  • After the fix, opened the failing always profile in a second tab. The tab closed without displaying the info bar, confirming that the lookup correctly skipped the unrelated first tab.
  • Repeated the test using a split pane. The failing pane closed without displaying the info bar.
  • Tested the graceful profile and confirmed that the info bar still appeared as expected.
  • Checked the Windows Application event log and found no crashes during testing.

No automated regression tests have been added.

PR Checklist

When a profile with "closeOnExit": "always" exited with a nonzero
code, the pane closed but the "Termination behavior can be configured
in advanced profile settings" info bar still appeared. Skip it when
the failed pane's profile already closes on exit.

Closes microsoft#11608
@microsoft-github-policy-service microsoft-github-policy-service Bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Dec 4, 2026
@DHowett

Copy link
Copy Markdown
Member

Honestly, we could skip showing the termination message for any profile which has configured CloseOnExit at all (in the user layers) because that suggests the user is at least passively aware of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The info bar shows up on nonzero exit codes even with "closeOnExit": "always"

2 participants