fix(sessions): web-resume of a resident chat session no longer replays the trigger message or gets reaped (v0.266.1)#467
Merged
Conversation
…r replays the trigger message or gets reaped seconds later (v0.266.1) A resident chat session (Slack/Discord/`/agent`) resumed from the web console hit two bugs on the attach.sh resurrect path: 1. Re-pasted the original trigger message. attach.sh resurrects a stopped resident session via `RESUME=1 ENV_FILE=… claude-launch.sh`, sourcing the persisted env — which carries the ORIGINAL launch TASK (the Discord/Slack message that started it). The unattended/resident resume branch re-seeded `$TASK` on `claude --resume`, replaying the first prompt. Fixed: mark an env-file resurrect (RESUMED_FROM_ENV) and skip re-seeding the original task on the primary resume; the fallback still seeds so a lost transcript gets a prompt. A genuine server-driven follow-up (reviveResident/chatSend) spawns a fresh pane with no ENV_FILE, so its new message is still seeded. 2. Killed shortly after resumption. markResumed refreshed only updated_at, leaving last_activity stale, so the resurrected resident session tripped the 30-min resident idle reaper on the very next 60s sweep. It now refreshes last_activity too, giving a deliberately re-opened session a fresh idle window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JVfxDWBcQLbAqJPshB4Ha2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Resuming a Discord-triggered (resident chat) session from the web console: it (1) re-pasted the original Discord message on resume, and (2) got killed within ~a minute of resuming.
Root cause
The session is a resident chat session (
resident=1,spawned_by=chat:<agent>). Its persisted launch env (session-<id>.env) carriesRESIDENT=1+TASK_FILE=<the original trigger message>. When the browser reattaches,attach.shresurrects it viaRESUME=1 ENV_FILE=… claude-launch.sh, which sources that env.claude --resume "$CLAUDE_SESSION_ID" … ${TASK:+"$TASK"}— re-seeding the original task (already in the transcript) as a fresh prompt. The interactive lane never had this bug (it passes no task on the primary resume).markResumedsetstatus='running'but leftlast_activitystale (from the original run). The next 60 s idle sweep (reapIdleSessionscase 1, 30-min resident timeout) saw it as long-idle and reaped it →stopped+blockResume.Fix
terminal/claude-launch.sh— mark an env-file resurrect (RESUMED_FROM_ENV); in the resident/unattended resume branch, skip re-seeding$TASKon the primaryclaude --resumewhen resurrected from a sourced env (the fallback still seeds so a lost transcript gets a prompt). A server-driven follow-up (reviveResident/chatSend) spawns a fresh pane with no env file →RESUMED_FROM_ENVunset → its genuinely-new message is still seeded, so thread continuity is unaffected.src/terminal.tsmarkResumed— also refreshlast_activity, giving a deliberately re-opened session a fresh idle window instead of tripping the reaper on the next sweep.Validation
npm run typecheck✓ ·bash -n terminal/claude-launch.sh✓ ·cd web && npm run build✓npm run test:governance→ 102/102 ✓Note: a
claude-launch.shchange only affects new session launches — an already-stopped session picks it up on its next reattach after deploy.🤖 Generated with Claude Code
https://claude.ai/code/session_01JVfxDWBcQLbAqJPshB4Ha2