Repository navigation
Fix session-switcher applying unmatched completions - #21
Conversation
Gate apply_completion on pending == Some(request) like directory-list and worktree paths, move activate/create realm updates behind that gate, and cover stale/overlapping completions with unit tests.
ElSargo
left a comment
There was a problem hiding this comment.
Brood QA review — session-switcher pending-gate
Verdict: approve (posted as comment — gh as ElSargo cannot formally APPROVE own PRs)
What looks good
apply_completionnow early-returns unlesspending == Some(completion.request), then clears pending and mutates UI — same gate as directory-list / worktree.- Activate/create
backend_id/session_idupdates moved inside that gate soCommandCompletedcannot bypass it. - Regression coverage is on-point: unmatched preserve, matched apply, overlapping create→activate does not clobber newer pending.
- Friction doc remittance matches the code.
Local verification
cd plugins/session-switcher && RUSTFLAGS='-C linker=cc' cargo test --lib → 47 passed (including the three new tests).
CI
Red checks are not regressions from this PR:
- SC2148 on
tools/test-themes-live.sh/tools/test-theme-switcher-live.sh— pre-existing onmain(identical blobs; this PR does not touch those files). Sourced fragments need# shellcheck shell=bash(or equivalent) in a separate chore. - Build disk full while unpacking rustc — runner infra.
Nits (non-blocking)
- Optional: unit-test unmatched failure completion as well.
- Optional:
assert_eq!forEditModein the new tests.
Desktop
Manual overlapping activate/create while the first is in flight would be nice belt-and-suspenders; not required for merge of this reducer-level fix given the unit tests.
No code changes requested on this PR.
ElSargo
left a comment
There was a problem hiding this comment.
Brood QA review
Checked: diff/view; CI 35145838495; audit C2; friction doc update in-PR.
Code: Correct C2 fix. apply_completion early-returns unless pending == Some(completion.request); activate/create backend_id/session_id updates moved behind that gate (cannot bypass via CommandCompleted). Tests cover unmatched preserve, matched apply, overlapping older-create vs newer-activate.
CI: FAILURE — same runner ENOSPC during Nix/rustc unpack. Not attributable to this change. Author: 47 lib tests passed locally.
Race-doc: Session-completion friction remitted; aligns with directory-list / worktree gates.
Desktop verify: Blocked (no nix / client build on QA box).
Residual / merge: Conflicts likely with #29/#32 (same session-switcher + shared friction doc). Merge only after green CI + resolve stacking order.
— Brood QA
Summary
apply_completiononpending == Some(completion.request)(same pattern as directory-list /apply_worktree_completion) so late/stale session completions no longer rewrite error, status, selection, query, or edit mode for a newer in-flight action.backend_id/session_idupdates into that gated path so theCommandCompletedcall site cannot bypass the check.docs/frictions/ui-concurrency.md.Test plan
cd plugins/session-switcher && RUSTFLAGS='-C linker=cc' cargo test --lib— 47 passed (includes 3 new regression tests for unmatched / matched / overlapping completions)