Skip to content

fix(sidebar): preserve focus while docking background worktrees - #121

Open
dclausen wants to merge 1 commit into
alexarthurs:mainfrom
dclausen:fix/background-worktree-sidebar-focus
Open

dclausen wants to merge 1 commit into
alexarthurs:mainfrom
dclausen:fix/background-worktree-sidebar-focus

Conversation

@dclausen

Copy link
Copy Markdown

Problem

A background worktree open --no-focus can still switch the user into the new workspace when the automatic sidebar hook docks: pane.swap focuses the new sidebar. The prior repair picked the pane displaced by the swap, which belongs to the background workspace, instead of the globally focused pane.

Fix

Capture the focused pane immediately before pane.swap, then restore it only if the newly docked sidebar remains focused. Fall back to the entry snapshot when the fresh read fails, or to the displaced pane when there is no recorded focus. Explicit user focus changes after docking still win. Extend the existing focus regression for a background workspace, same-tab docking, and missing prior focus; document the host behavior in AGENTS.md.

Validation

  • Regression failed before fix: got w2:p1 instead of w1:p1; passes after fix.
  • cargo test -- --test-threads=1: 390 passed, 3 ignored.
  • cargo clippy --all-targets -- -D warnings, cargo fmt --check, git diff --check: passed.
  • Ripwire quality delta: gating=0; six minor findings (including two verbosity findings).
  • No live client end-to-end focus reproduction was run.

Capture global focus immediately before a sidebar swap and restore it only when the new sidebar remains focused. Prefer that pane over the background workspace pane displaced by the swap, while preserving intentional later focus changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant