Skip to content

terminal: preserve parent location for background terminal children - #346704

Merged
Dmitriy Vasyura (dmitrivMS) merged 6 commits into
mainfrom
agents/address-copilot-feedback-draft-pr
Nov 9, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 6 commits into
mainfrom
agents/address-copilot-feedback-draft-pr

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related to #205254.

Follow-up to #342420, addressing Copilot's original feedback, the hidden-editor-parent finding, and the previously missed panel-location finding.

Prevent API child-terminal creation from trying to split a hidden or backgrounded panel parent that has no terminal group, while preserving the parent's location as promised by TerminalSplitLocationOptions.

  • For a resolved background panel parent, pass TerminalLocation.Panel instead of a split parent. The child stays in the panel even when terminal.integrated.defaultLocation is editor; the parent remains hidden.
  • Preserve editor-targeted parents, including hidden/backgrounded editor parents. Editor splits do not require a parent terminal group.
  • Preserve normal foreground splits, including previously hidden parents after they are shown, and support both creation identifiers and numeric instance IDs.
  • Keep the existing default-location fallback for an unresolved parent only.

The explicit panel location also preserves hidden-child creation, which already bypasses splitting. The earlier implementation's fallback to the configured default was incorrect for resolved background panel parents.

Add regression coverage for hidden/backgrounded panel and editor parents, both identifier types, shown parents, and visible/hidden children with an editor default.

Follow up on #342420 and preserve the parentTerminal fix for #205254 while falling back to the default location for hidden or backgrounded parents.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 7, 2026 00:39
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added bug Issue identified by VS Code Team member as probable bug terminal-tabs labels Nov 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change restricting API split parents to foreground terminals.

No open issues 🎉

What changed in this PR

This PR follows up on the parentTerminal fix for #205254 by excluding background terminals as API split parents. Children fall back to the configured default location, while previously hidden parents remain valid after being shown.

Changes:

  • Require foreground membership when resolving split parents, preserving support for creation identifiers and numeric instance IDs.
  • Add five regression tests covering hidden parents, shown parents, and visible parents moved to the background.

No actionable findings remain.

File Description
src/​vs/​workbench/​api/​test/​browser/​mainThreadTerminalService.test.ts Adds regression coverage for split-parent visibility and identifier handling.
src/​vs/​workbench/​api/​browser/​mainThreadTerminalService.ts Restricts API split parents to foreground terminal instances.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Splitting from a hidden or backgrounded editor parent can send the child terminal to the default location instead of preserving the parent’s editor location, regressing the API contract.

1 open issue

Review effort: Max

Keep editor-targeted API split parents even when hidden or backgrounded, while retaining foreground validation for panel parents. Cover both terminal identifier types with regression tests.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

With an editor default, children of hidden or backgrounded panel terminals can be placed in the editor, violating the promised preservation of the parent’s panel location.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Hidden panel parents should retain the panel terminal location

src/​vs/​workbench/​api/​browser/​mainThreadTerminalService.ts:193

When terminal.integrated.defaultLocation is editor, a hidden/backgrounded panel parent now sends its child to the editor instead of preserving the panel location promised by TerminalSplitLocationOptions (src/vscode-dts/vscode.d.ts:7785). This also changes hidden-child creation, which previously kept the parent's location without attempting a split. Return TerminalLocation.Panel for a resolved background panel parent, and add a regression test with an editor default.

1 resolved since last review

Review effort: Max

Use an explicit panel location when a resolved background panel parent cannot be split. Preserve the parent location for visible and hidden children even with an editor default, with regression coverage for both terminal identifier types.

Co-authored-by: Copilot <[email protected]>
@dmitrivMS Dmitriy Vasyura (dmitrivMS) changed the title terminal: ignore background instances as API split parents terminal: preserve parent location for background terminal children Nov 9, 2026
@dmitrivMS

Copy link
Copy Markdown
Collaborator Author

Addressed the "previously missed issue" in #346704 (review) with commit b0b1662. Resolved hidden/backgrounded panel parents now pass an explicit TerminalLocation.Panel rather than falling back to the configured default. This preserves the location for both visible and hidden children, while keeping editor-targeted parents and ordinary foreground splits intact.

All eight new panel-parent/editor-default cases failed before the correction and now pass (hidden/backgrounded parent, creation/numeric identifier, visible/hidden child). The full terminal API suite passes all 34 tests; client compilation/type checking and staged-file hygiene also pass.

I corrected the PR description and manual steps, including the earlier UI expectation: a hidden panel parent must keep its child in the panel even with an editor default. The older recording is not validation of this final correction; a fresh end-to-end UI run has not been performed. This finding was embedded in the review summary, so there is no separate inline thread to resolve.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Hidden child terminals without an explicit cwd lose a hidden or backgrounded parent’s working directory when splitCwd is initial or inherited, launching in the default directory instead.

1 open issue

Review effort: Max

Retain the resolved split parent for hidden-child requests so initial and inherited cwd settings keep working. Preserve explicit cwd overrides and keep the panel fallback for visible children of background parents.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify the hidden-child cwd path, explicitly type captured test results, and locate the child terminal by its extension identifier.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) marked this pull request as ready for review November 9, 2026 09:52
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 8ac2763 into main Nov 9, 2026
94 of 96 checks passed
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) deleted the agents/address-copilot-feedback-draft-pr branch November 9, 2026 09:55
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 9, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Nov 9, 2026
@vs-code-engineering vs-code-engineering Bot added the release-cherry-pick Automated cherry-pick between release and main branches label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches terminal-tabs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants