Fix empty OSC 2 sequence not clearing terminal title#315317
Open
wpfleger96 wants to merge 5 commits into
Open
Conversation
`_updateTitleProperties` guarded with `if (!title)`, treating empty string as falsy and early-returning before the Sequence case could set `this._sequence = ""`. Change to `if (title == null)` so empty OSC 2 sequences flow through and clear the title variable, letting the tab revert to the process name.
Author
|
@microsoft-github-policy-service agree |
…itle * main: Fixes tests Escapes model id in chatEditHunk event Strip codicons from terminal quickpick filter matching (microsoft#313197) Approval telemetry (microsoft#315215)
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes handling of empty OSC 2 title sequences so ${sequence} can be cleared (and tab titles can fall back to the process name) by allowing empty strings to flow through the terminal title update logic.
Changes:
- Update
TerminalInstance._updateTitlePropertiesto guard onlynull/undefined(not""), enabling empty OSC 2 to clear the stored sequence. - Add a
TerminalLabelComputertest asserting${sequence}${separator}${process}resolves to the process name whensequence: "".
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | Adjusts title update guard to allow empty strings through, enabling sequence clearing. |
| src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts | Adds a label-template test for the empty-sequence fallback behavior. |
`rename("")` is reachable from the rename input box (validateTerminalName
shows an info message but doesn't block). With the `title == null` guard
change, empty string now flows into the Api case and sets `_staticTitle`
/ `_titleSource`, blocking future process-name updates. Normalize empty
to `undefined` so it hits the null guard and resets as intended.
…2-not-clearing-terminal-title * upstream/main: chat: hide plugin actions for synced customization items (microsoft#315320) fixes microsoft#291188 (microsoft#314713) sessions: restore last active session on reload (microsoft#315312) Replace "Agents app" with "Agents window" in user-facing strings (microsoft#315302) chat: remove 'Bridged' badge from MCP servers in AI Customizations UI (microsoft#315319) Add proposal for custom editor diff/merge priority agentHost: revert undefined-field omission, update tests instead sessions: fix Customizations single-entry width overflow (microsoft#315125) agentHost: rewrite Resource attachments and omit undefined fields agentHost: support image and blob user-message attachments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a shell sends an empty OSC 2 sequence (
\033]2;\007), the${sequence}terminal title variable should reset to""and the tab should revert to the process name. Instead,_sequenceretained its last non-empty value permanently.The guard in
_updateTitlePropertiesusedif (!title), which treats empty string as falsy and returns before theTitleEventSource.Sequencecase can assignthis._sequence = "". xterm.js correctly firesonTitleChange("")for empty OSC 2 — the bug was entirely in VS Code's handler. Changed toif (title == null)so empty strings flow through to the switch while still guardingundefined/null.Since the broader guard also lets empty strings through the Api path,
rename("")(reachable from the rename input box) would now set_staticTitle = ""and_titleSource = Api, blocking future process-name updates. Added a normalization inrename()that converts empty/whitespace-only titles toundefined, so the existing null guard handles it as a reset — matchingvalidateTerminalName's stated intent.terminalInstance.ts: change guard from!titletotitle == nullterminalInstance.ts: normalize emptyrename()input toundefinedterminalInstance.test.ts: add test for empty sequence falling back to process nameFixes #312403