codex icon indicating copy to clipboard operation
codex copied to clipboard

Expose an active-thread-changed hook before a TUI prompt is sent

Open p31d3ng opened this issue 4 days ago • 1 comments

Use case

A terminal supervisor restores an exact saved Codex session after its container restarts. Several terminals can share one working directory, so choosing the newest session by cwd is unsafe. The supervisor must reopen a UUID without supplying a prompt or starting work.

Observed with Codex CLI 0.172.0 (Linux amd64)

Using an isolated home and a synthetic loopback Responses provider:

  1. Start a TUI conversation, submit one synthetic initialization turn, and record the exact session UUID from a working hook.
  2. Run /new, select the current worktree, and leave the new empty composer untouched.
  3. Before another prompt is sent, the existing SessionStart-based mapping still points to the previous conversation. A CLI invocation of codex resume <UUID> can be mapped from its explicit argument, but that does not identify a later in-TUI selection.

The request is for a reliable selection signal, rather than inferring identity from cwd, title, modification time or an open file. I have not established that SessionEnd supplies a reliable guard for this case, and am not claiming that it never fires.

Requested interface

An ActiveThreadChanged hook (or an equivalent documented client event) emitted when the TUI selects a different conversation, before a user prompt/model request. Suggested fields: exact thread/session UUID, cwd, optional transcript path, selection source, and a client/terminal correlation identifier. For a new empty conversation without a persisted UUID, an explicit null/unbound event would let a supervisor invalidate the old mapping safely.

It should also cover choosing an existing conversation through the TUI resume picker and should not itself create a turn, send a prompt, or invoke a provider. This would let recovery reopen the selected session accurately while leaving the agent idle.

No real credentials, conversation contents or private session identifiers are included.

p31d3ng avatar Nov 30 '26 23:11 p31d3ng

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #64665
  • #64667

Powered by Codex Action

github-actions[bot] avatar Nov 30 '26 23:11 github-actions[bot]