Skip to content

fix: supersede active sessions when resuming in the same pane - #57

Merged
boxp merged 1 commit into
mainfrom
fix/resume-duplicate-session
Mar 11, 2026
Merged

fix: supersede active sessions when resuming in the same pane#57
boxp merged 1 commit into
mainfrom
fix/resume-duplicate-session

Conversation

@boxp

@boxp boxp commented Mar 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Root cause: maybe-supersede only fired for brand-new session IDs. When Claude Code resumes a past session (--resume), hooks reuse the same session-id that already exists in the store, so supersede was skipped. The previously-active session in the same pane remained un-superseded, causing duplicate sessions in ceeker.
  • Fix: Extend maybe-supersede to also fire when an existing session reactivates from a terminal state (:completed, :closed, :error), while excluding already-superseded sessions to prevent stale delayed hooks from evicting the current active session.
  • Def ordering: Move terminal-statuses definition before maybe-supersede to fix forward-reference lint error.

Test plan

  • test-resume-supersedes-active-session-in-same-pane — core resume-dup scenario
  • test-resume-with-different-cwd-supersedes — different CWD same pane
  • test-resume-does-not-affect-different-pane — parallel pane safety
  • test-resume-closed-session-supersedes — closed (non-superseded) session resume
  • test-ongoing-running-update-no-supersede — normal hook updates unaffected
  • test-delayed-hook-on-superseded-session-no-eviction — stale hook safety (Codex review P1 fix)

Residual risk

  • The fix relies on terminal-statuses to detect resume. If a new terminal status is added without updating the set, resume-supersede would not fire for that status.
  • close-dup-pane-sessions! remains as a safety net for edge cases where supersede timing is insufficient.
  • Superseded sessions remain permanently blocked from :running reactivation via merge-session-data.

Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 173e40290a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +195 to +198
(or (nil? existing)
(and (contains? terminal-statuses
(:agent-status existing))
(not (:superseded existing)))))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict reactivation supersede to true resume events

This condition now supersedes other active sessions whenever an existing session is terminal and receives any :running update, but handle-hook! emits :running for many non-resume events (including default/unknown events), and the repo docs note asynchronous hook delivery (InstructionsLoaded), so a delayed event for an old completed session can incorrectly close the current active session in the same pane and revive stale state. Before this commit, that delayed update would not evict peers because supersede only ran for brand-new session IDs.

Useful? React with 👍 / 👎.

@boxp
boxp merged commit 9bf1392 into main Mar 11, 2026
6 checks passed
@boxp
boxp deleted the fix/resume-duplicate-session branch March 11, 2026 07:17
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