Skip to content

fix(pi): clear watcher shutdown latch on session_start (/new)#976

Open
moj02090 wants to merge 3 commits into
kunchenguid:mainfrom
moj02090:fm/firstmate-watcher-fix-upstream-pr
Open

fix(pi): clear watcher shutdown latch on session_start (/new)#976
moj02090 wants to merge 3 commits into
kunchenguid:mainfrom
moj02090:fm/firstmate-watcher-fix-upstream-pr

Conversation

@moj02090

@moj02090 moj02090 commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Fixes Pi /new leaving the primary watcher stuck on watcher: not armed - Pi session is shutting down.

Root cause

.pi/extensions/fm-primary-pi-watch.ts sets a module-scope stopping latch in stopArm() on session_shutdown / process exit. /new keeps the same Pi process and loaded extension module, so the old session_start path (only markLoaded()) never cleared that latch. Every later arm refused with the shutdown message.

Fix

On session_start:

  1. Clear stopping = false
  2. Reset retryFailures / retryTimer
  3. Re-attach the process-exit cleanup listener
  4. markLoaded() as before
  5. Quiet startArm() when this session already owns the lock and nothing is armed

Review follow-ups on the same branch also:

  • Cancel / generation-scope pending restoreAfterActionableClose work across session boundaries before reopening the latch
  • Tag arm children with sessionGeneration and ignore delayed close events from a pre-/new child

Scope

Pure upstream fix only (extension + docs note + tests). No ADO forge-adaptation commits.

Test plan

  • tests/fm-pi-watch-extension.test.sh — session_start clears shutdown latch and quiet-rearms
  • Restoration-cancellation and stale-child-close regressions added by review fixes
  • no-mistakes local pipeline: intent/rebase/review/test/document/lint/push passed

Pipeline

Updates from git push no-mistakes

Firstmate jail user added 3 commits July 24, 2026 13:39
/new keeps the same Pi process and loaded extension module. session_shutdown
sets the process-local stopping latch, and the old session_start path never
cleared it, so later arms stuck on "Pi session is shutting down".

Clear the latch on session_start, restore the process-exit fallback, and
quietly re-arm when this session already owns the lock.
@moj02090

Copy link
Copy Markdown
Author

hmm I used no mistakes?

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