Skip to content

feat(host): guard codex resume against an active session - #219

Merged
tanlethanh merged 1 commit into
mainfrom
feat/codex-resume-guard
Aug 26, 2026
Merged

tanlethanh merged 1 commit into
mainfrom
feat/codex-resume-guard

Conversation

@tanlethanh

Copy link
Copy Markdown
Member

Summary

  • Resuming a codex session that is open in another terminal failed with already has an active writer and exited immediately; codex holds an exclusive writer lock per thread for the session's whole life and has no force flag.
  • zedra <slug> <args> now dispatches to an agent's own CLI wrapper via AgentActor::run_wrapped (default None); codex is the only implementation, since "already running" means something different per agent.
  • zedra codex resume probes the lock first and offers kill / fork / cancel, then execs the real CLI. Everything else forwards unchanged.
  • resume_launch_command routes through the wrapper, so the app shows the prompt instead of a dead terminal.

Notes

  • y (default) sends SIGTERM, polls the lock for 3s, escalates to SIGKILL. f rewrites resume to fork, dropping --include-non-interactive, which ForkCommand does not accept.
  • Prompt is laid out for a phone-width terminal: longest line is 35 chars at 40 columns.
  • A custom agents.overrides.codex.resume_cmd keeps the guard by keeping the zedra codex prefix.
  • Verified end to end against real codex processes: cancel leaves the holder alive, fork creates a new session and leaves the holder alive, kill terminates it and resumes, a free lock skips the prompt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQXVaJtBFwALs97XDrh53W

Codex locks a thread for a session's whole life, so resuming one that is
open in another terminal fails with "already has an active writer" and
exits at once.

`zedra <slug> <args>` runs an agent's own CLI wrapper through
`AgentActor::run_wrapped`; codex is the only implementation. It probes
the lock, offers kill / fork / cancel, then execs the real CLI.
`resume_launch_command` routes through the wrapper, so the app hits the
prompt instead of a dead terminal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQXVaJtBFwALs97XDrh53W
@tanlethanh
tanlethanh force-pushed the feat/codex-resume-guard branch from 05d3b19 to a78518c Compare August 26, 2026 17:43
@tanlethanh
tanlethanh merged commit c9207b4 into main Aug 26, 2026
0 of 3 checks passed
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