Skip to content

vscode: focusing a builder PTY tab silently reveals/expands the matching builder row in the tree #790

@amrmelsayed

Description

@amrmelsayed

Problem

Today the click-row → focus-terminal direction is wired (see views/builders.ts:127), but the inverse isn't: activating a builder PTY tab (via Cmd+` cycle, terminal tab click, or any other path) does not update the Builders tree. The user is looking at a terminal and can't tell at a glance which row in the sidebar it corresponds to — especially with 3+ builders running, similar names, or after the accordion auto-collapsed something.

Current state

  • terminalManager.terminals (terminal-manager.ts:342) keys PTYs by a label/key that can be reversed to a builder id.
  • terminalManager.isCodevTerminalActive() already exists (extension.ts:127) — knows whether the active terminal is one of ours.
  • BuildersProvider exposes TreeView.reveal(...) (views/builders.ts:62–63); the accordion path uses it. The infrastructure is in place.
  • No window.onDidChangeActiveTerminal subscription currently drives the tree.

Proposed behavior

On extension activation, subscribe to vscode.window.onDidChangeActiveTerminal. Each fire:

  1. If terminal is null → no-op.
  2. Resolve the terminal to a builderId via terminalManager.terminals (matching by terminal reference; only entries with type === 'builder' count).
  3. If no builder match → no-op. Dev/architect/shell terminals do not move the tree.
  4. Find the corresponding builder TreeItem in BuildersProvider.
  5. Call buildersView.reveal(item, { select: true, focus: false, expand: true }). Silent select — selection and expansion update, but focus stays where it is (so swapping to a builder terminal doesn't yank you out of the terminal pane).

Acceptance criteria

  • Activating a builder PTY tab updates the Builders tree selection to the matching row and expands it.
  • Focus is NOT stolen from the terminal pane (or wherever it was).
  • Architect, shell, and dev terminals do not move the tree.
  • Activating a non-Codev terminal does not change tree selection.
  • Works alongside the existing accordion mode without fighting it (the reveal call should cooperate, not double-collapse).
  • Disposed cleanly on extension deactivate.

Out of scope

  • Architect / shell / dev terminal scoping (intentionally — builder only).
  • Focus-stealing variant (intentionally rejected).
  • Changing the existing click-row → focus-terminal direction.

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