Skip to content

fix(sessions): web-resume of a resident chat session no longer replays the trigger message or gets reaped (v0.266.1)#467

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/resume-reinject-fix
Jul 25, 2026
Merged

fix(sessions): web-resume of a resident chat session no longer replays the trigger message or gets reaped (v0.266.1)#467
vikasprogrammer merged 1 commit into
mainfrom
feat/resume-reinject-fix

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

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) carries RESIDENT=1 + TASK_FILE=<the original trigger message>. When the browser reattaches, attach.sh resurrects it via RESUME=1 ENV_FILE=… claude-launch.sh, which sources that env.

  1. Re-pastes the trigger message. The unattended/resident resume branch ran 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).
  2. Killed shortly after. markResumed set status='running' but left last_activity stale (from the original run). The next 60 s idle sweep (reapIdleSessions case 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 $TASK on the primary claude --resume when 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_ENV unset → its genuinely-new message is still seeded, so thread continuity is unaffected.
  • src/terminal.ts markResumed — also refresh last_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.sh change 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

…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
@vikasprogrammer
vikasprogrammer merged commit e7d7f17 into main Jul 25, 2026
1 check passed
@vikasprogrammer
vikasprogrammer deleted the feat/resume-reinject-fix branch July 25, 2026 13:26
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