Skip to content

fix(daemon): admit history shutdowns before connection preparation - #33504

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-daemon-history-shutdown-admission
Oct 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-daemon-history-shutdown-admission

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

A keep-history shutdown could yield while preparing its connection before registering itself with the disconnect drain. If disconnectOnly() started during that gap, it could close the connection before shutdown finished saving history and retiring the PTY.

Register the complete keep-history operation synchronously before connection preparation starts. Preserve the existing spawn-lock order, absolute deadlines, checkpoint/recovery checks, and kill/cleanup sequence. Calls admitted after disconnect starts still reject.

Validation:

  • A deterministic regression blocks connection preparation, starts disconnect, and verifies the admitted shutdown finishes with saved history. It fails on the original implementation at the admission assertion and passes with this fix.
  • All 18 history/admission cases and 87 adoption, deadline, WSL, upgrade, and idle-shutdown cases pass.
  • Two independent native Codex source reviews approve the committed files, including concurrency, rejection handling, cleanup, and platform boundaries.
  • pnpm check:changed --maxWorkers=2 --base=048bc0f30984602492c735a5d5dbf55b0abd60aa: all 20 checks passed.
  • The original refactor-audit merge validator passes against fresh main; only the two approved paths change, and the original history suite is untouched.

This is a separate behavior fix discovered during module-organization CI investigation. The exact interleaving behind that earlier CI failure has not been reproduced.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e6d91e4-6675-4512-9f85-e199ea5bd4ee
Commits

Reviewing files that changed from the base of the PR and between 346e2ac and f4e609d.

Files selected for processing: 2
  • src/main/daemon/daemon-pty-adapter-history-shutdown-admission.test.ts
  • src/main/daemon/daemon-pty-session-control.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

Non-history-preserving shutdowns now run under the history/spawn lock. History-preserving shutdowns start connection and session adoption before acquiring the lock, and the operation is tracked while it runs. A new test checks admission before connection preparation completes, rejection of a later shutdown, and the resulting session and checkpoint state.

Priority: Normal

Merge Risk: Minimal · up to f4e60

The admitted history-preserving shutdown is allowed to finish before disconnect closes the connection. No actionable merge-blocking issue remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the race, the fix, the preserved behavior, and the validation performed. However, it omits the required template sections and information, including an actual Linked Issue ref… Use the repository template headings. Add an actual issue link after “Fixes #”. Add an ELI5 explanation, mark Visual Proof as N/A with a reason if applicable, complete the Testing and Checklist items, and state the impact or N/A status for …
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: admitting history-preserving daemon shutdowns before connection preparation.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Full details: Description check

Explanation

The description explains the race, the fix, the preserved behavior, and the validation performed. However, it omits the required template sections and information, including an actual Linked Issue reference, ELI5, Visual Proof with an N/A explanation, checklist confirmations, and explicit notes on the required compatibility areas.

Resolution

Use the repository template headings. Add an actual issue link after “Fixes #”. Add an ELI5 explanation, mark Visual Proof as N/A with a reason if applicable, complete the Testing and Checklist items, and state the impact or N/A status for security, cross-platform support, SSH/remote, mobile, backwards compatibility, and performance.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 48d8b35 into main Oct 25, 2026
51 checks passed
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