Skip to content

feat: --session-id flag + SubagentStop/PostCompact hooks - #69

Merged
aterrylu merged 1 commit into
mainfrom
terry/session-id-hooks
Mar 26, 2026
Merged

feat: --session-id flag + SubagentStop/PostCompact hooks#69
aterrylu merged 1 commit into
mainfrom
terry/session-id-hooks

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

--session-id: Pre-generate Claude session ID before spawning. Eliminates PTY regex parsing race condition. Sessions persist immediately.

SubagentStop + PostCompact: Fix agent status getting stuck in "orchestrating" or "compacting" after the operation completes.

Changes

File What
sessions.ts Generate claudeSessionId at spawn, pass --session-id, remove PTY regex block, persist immediately
hooks.ts Remove SessionStart ID detection (obsolete), add SubagentStop/PostCompact status handlers

Test plan

  • Create new session → claudeSessionId is set immediately (no 2-5s delay)
  • Resume session → uses existing session ID, no --session-id flag
  • Session persists on server restart (immediate persistence, no race)
  • Subagent spawned → status shows "orchestrating" → subagent finishes → status returns to "working"
  • Context compaction → status shows "compacting" → completes → status returns to "working"

🤖 Generated with Claude Code

Session ID:
- Pre-generate claudeSessionId via crypto.randomUUID() before spawn
- Pass --session-id to Claude Code for fresh sessions
- Eliminates PTY regex parsing of "Session: <uuid>" output
- Sessions are persisted immediately at creation (no race window)
- Removed SessionStart hook ID detection (no longer needed)

Hook events:
- Added SubagentStop → transitions status from "orchestrating" to "working"
- Added PostCompact → transitions status from "compacting" to "working"
- Fixes agent status getting stuck after subagent completion or compaction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu merged commit f526ddf into main Mar 26, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/session-id-hooks branch March 26, 2026 03:53
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