Pin Claude, Codex, and OpenCode conversations from lifecycle events - #41
Merged
Conversation
lvwerra
marked this pull request as ready for review
August 6, 2026 16:58
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.
Summary
Replace newest-file/newest-row guessing with exact lifecycle events for the three harnesses that expose an integration point:
SessionStarthook, but bind every breadcrumb to a fresh per-launch nonce and the top-level pane process.SessionStarthook forstartup,resume, andclear; persist the exactsession_idand validatedtranscript_pathit reports.session.createdevents and the exact session selected on the nextchat.message; validate that id, cwd, process, and root status against SQLite before pinning it.Every PTY launch now gets an
AM_RUN_IDand anAM_PANE_PID. The server accepts a breadcrumb only when its pane id, launch nonce, harness, cwd, id shape, process identity, and ownership all agree. Delayed events from an old process and lifecycle events from nested agents therefore cannot re-pin the top-level pane, and same-folder panes do not pick each other conversations.The existing transcript/rollout/database discovery remains as a fallback when an adapter is unavailable. Gemini, Hermes, OpenClaw, shell, files, and trace behavior is unchanged.
Clear/new-session behavior
/clearemitsSessionStart(source=clear)./clearemitsSessionStart(source=clear)./new(/clear) emits a rootsession.createdevent.The exact breadcrumb is polled from local disk every 250 ms and once more on PTY exit, while expensive storage discovery keeps its existing sparse cadence. Transient Codex rollout/OpenCode database visibility failures retain the exact event briefly and retry rather than discarding it.
Reliability and safety details
/clearfollowed immediately by quit cannot lose it at the firstawait./etc/codex/requirements.tomland a root-owned managed hook, so no user/hookstrust prompt or global hook-trust bypass is required.$CODEX_HOME/sessions, accept lexical or canonical paths for symlinked storage, and encode the reported UUID. The nullabletranscript_pathcase resolves only an exact-ID rollout.Tests
npm test --prefix servergit diff --checkThe full server suite passes, including 54 conversation re-pin checks, 32 OpenCode resume/plugin checks, and the Ghostty terminal migration/scrollback/resize integration suites.
Relationship to existing work
This is the deterministic follow-up to #36 and is based on current
main, including the watcher lifecycle fixes merged from #35.