fix: guard autoresearch shutdown context - #57
Conversation
Commit-Queue-Session: cq_20260426235232_ecf71f8eb10a211a19af3f6b Coding-Agent: pi Coding-Agent-Session: pi-019dcbcc-b152-70a0-b167-aeaaaf7a9b32
|
Small human note from me because the original PR description was written by my coding agent and reads like a robot filed a ticket. What I ran into with autoresearch: fresh Pi print mode printed the expected answer, That makes scripting around Pi weird. The useful work finished, but the process still looks failed. This PR is just trying to make that shutdown path boring. If Pi is already tearing down a session, autoresearch should cancel pending resume work first, avoid using stale UI/context, and treat stale context during teardown as a no-op instead of an extension error. No feature change intended. Just making print-mode startup/shutdown less noisy and less surprising. |
|
thanks I'll give it a review, feels a lot of changes for what it does, so might be worth seeing if there's a simpler way to achieve it. |
Why
Autoresearch stores delayed auto-resume work and updates UI state from lifecycle handlers. In fresh Pi print-mode shutdown, those handlers can observe a stale Pi extension context if another extension still has async teardown work in flight.
What changed
Verification
node --test tests/*.mjs→ 8/8 passPATH=/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin bash tests/finalize_test.sh→ 18/18 passexit=0,stderr_lines=0,stdout=okexit=0,stderr_lines=0,stdout=ok