Visitar URL original
Made `-w 0` target the window of the calling terminal. by NathanSweet · Pull Request #20733 · microsoft/terminal · GitHub
Skip to content

Made -w 0 target the window of the calling terminal. - #20733

Open
Nathan Sweet (NathanSweet) wants to merge 1 commit into
microsoft:mainfrom
NathanSweet:wt-window-for-caller-session
Open

Nathan Sweet (NathanSweet) wants to merge 1 commit into
microsoft:mainfrom
NathanSweet:wt-window-for-caller-session

Conversation

@NathanSweet

Copy link
Copy Markdown

wt -w 0 now runs the commandline in the window that wt was run from, instead of the most recently used window. The calling terminal session is identified by WT_SESSION in the caller's environment, as proposed in the Session Management spec. If wt wasn't run from a Terminal session (for example from Explorer or the Run dialog), or the session no longer exists, it falls back to the most recently used window as before.

References

Details

  • WindowEmperor::_dispatchCommandline first looks for the window hosting the caller's session, then falls back to the existing logic (_dispatchCommandlineCurrentDesktop / _mostRecentWindow).
  • The environment block forwarded by wt.exe is parsed with til::env. TerminalPage::HostsSession walks the panes of all tabs and compares its connection's SessionId(). The lookup happens at dispatch time, follows panes that were moved to another window.
  • This applies to WindowingMode::UseExisting (-w 0, -w last, and "windowingBehavior": "useExisting") and to UseAnyExisting. In both cases the calling window is what "an existing window" should mean.
  • A spoofed WT_SESSION can only target an existing window, which -w <id> already allows.
  • Built from main with VS 2022 17.14 (v143) and SDK 10.0.26100.9169.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Remoting Communication layer between windows. Often for windowing behavior, quake mode, etc. Product-Terminal The new Windows Terminal. labels Sep 28, 2026
@NathanSweet

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@DHowett

Dustin L. Howett (DHowett) commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Of (EDIT to fix typo) the 7 PRs we got over the weekend, this is maybe the only one I don't viscerally hate. Thank you! We'll have a look.

@NathanSweet

Copy link
Copy Markdown
Author

Haha... wait, I opened 2 so that means you hate my other one! 😉

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

Labels

Area-Remoting Communication layer between windows. Often for windowing behavior, quake mode, etc. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spawn new tab in quake window with wt -w 0

2 participants