Skip to content

Fix session-switcher applying unmatched completions - #21

Merged
ElSargo merged 1 commit into
mainfrom
fix/session-switcher-completion-pending-gate
Sep 16, 2026
Merged

ElSargo merged 1 commit into
mainfrom
fix/session-switcher-completion-pending-gate

Conversation

@ElSargo

@ElSargo ElSargo commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Gate apply_completion on pending == 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.
  • Move activate/create backend_id / session_id updates into that gated path so the CommandCompleted call site cannot bypass the check.
  • Mark the session-completion race remitted in 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)
  • Manual: start a session action, then another before the first completes; confirm a late first reply does not change UI while the newer request is still pending

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 ElSargo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Brood QA review — session-switcher pending-gate

Verdict: approve (posted as comment — gh as ElSargo cannot formally APPROVE own PRs)

What looks good

  • apply_completion now early-returns unless pending == Some(completion.request), then clears pending and mutates UI — same gate as directory-list / worktree.
  • Activate/create backend_id / session_id updates moved inside that gate so CommandCompleted cannot 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 on main (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! for EditMode in 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 ElSargo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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

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