Skip to content

vscode: don't force-create a second editor group when spawning builder terminals — attach if exists, else use the default group #804

@amrmelsayed

Description

@amrmelsayed

Problem

Spawning a builder terminal unconditionally targets vscode.ViewColumn.Two (packages/vscode/src/terminal-manager.ts:336). If the user only has one editor group open, VS Code creates a new second group to host the terminal. That's intrusive — the user's existing layout gets reshaped every time a builder spawns, even if they were happily working in a single column.

Desired behavior:

  • Second group exists → spawn in it (current behavior, preserved).
  • No second group exists → spawn in the first / default group instead of forcing a new one into existence.

This keeps the "builders live in the right pane" affordance for users who already work in a split, while staying out of the way for users who don't.

Current state

terminal-manager.ts:330–337:

let location: vscode.TerminalLocation | vscode.TerminalEditorLocationOptions;
if (type === 'dev' || position !== 'editor') {
  location = vscode.TerminalLocation.Panel;
} else if (type === 'architect') {
  location = { viewColumn: vscode.ViewColumn.One };
} else {
  location = { viewColumn: vscode.ViewColumn.Two };   // ← always Two, even if it doesn't exist
}

ViewColumn.Two is fixed by ordinal — VS Code creates the group on demand if it isn't there.

Proposed behavior

For terminals that today resolve to ViewColumn.Two (the else branch — builder and shell types), conditionally pick the target column:

const groupCount = vscode.window.tabGroups.all.length;
location = { viewColumn: groupCount >= 2 ? vscode.ViewColumn.Two : vscode.ViewColumn.One };

Architect terminals (ViewColumn.One) and dev/panel terminals stay exactly as they are.

Acceptance criteria

  • When at least two editor groups exist at spawn time, a new builder terminal attaches to the second group (unchanged from today).
  • When only one editor group exists at spawn time, the new builder terminal attaches to the first/default group without creating a new group.
  • Same rule applies to shell-type terminals (they share the ViewColumn.Two branch today).
  • Architect terminals (ViewColumn.One) and dev / panel terminals are untouched.
  • No new configuration setting — the behavior is unconditional.
  • Existing focus / show(!focus) semantics preserved (cursor doesn't jump unexpectedly).

Out of scope

  • A user-facing setting to choose between "force second group" (old) and "attach if exists" (new).
  • Re-positioning existing builder terminals when the user later splits / unsplits groups.
  • Cross-builder grouping (e.g. all builders in one group, dev terminals elsewhere).

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions