You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let integrations know which thread is active when it is opened, resumed, or reconnected, without waiting for a prompt #52907
CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesenhancementNew feature or requesthooksIssues related to event hooksmcpIssues related to the use of model context protocol (MCP) servers
An integration (a hook or an MCP server) should learn which thread a user has open as soon as that thread is started or resumed in a client. It should also learn this again after the app-server restarts (for example on auto-update) or after an MCP server is reloaded. The user should not have to send a prompt first.
Why it matters
Integrations that route messages to a conversation, or show its state, must bind to the thread the user is actually working in. Today they cannot do that until the user types:
After an app-server restart, the daemon also restores threads the user had already closed. Neither thread/loaded/list nor rollout activity can tell those apart from threads that are still open in a client.
So after a restart or an auto-update, an integration has no reliable way to reconnect to the conversations that are still open.
Any of these would solve it
Fire SessionStart when a thread is started or resumed in the client, not at the first prompt.
Give each MCP server instance the thread it serves.
Expose which threads currently have a live client subscribed.
A terminal session manager needs to restore the exact Codex conversation the user was interacting with when the user confirms a terminal-service restart, and then confirm the outcome. The integration keeps the native interactive TUI, without controlling model work, sending an extra chat message, or taking over the app-server transport. This matches this issue's current-thread/before-prompt requirement; the evidence below adds an embedded-client case and concrete lifecycle ambiguities.
An opt-in observation interface dedicated to TUI lifecycle could provide three outcomes:
The current input target as a structured fact. Identify the exact thread on initialization, selection changes and exit; distinguish the root/session tree from the current input target, and writable interaction from read-only viewing. Document ordering, client/lifecycle correlation and invalidation so a delayed event cannot restore a previously selected thread.
A resume result independent of model turns. Report success or the applicable failure once determined, distinguishing cancellation and read-only fallback. No extra prompt should be necessary, and the result should not depend on whether a restored goal or queue starts a turn. Consumers need to separate requesting a resume from observing its outcome.
Verifiable association with the interactive client. Start with embedded --no-daemon: a TUI-spawned observer helper, or another supported mechanism whose association can be checked through the operating system, could work. A PID asserted in a payload is not itself OS-verified process provenance. Solving every shared-daemon attribution case is outside this narrower request.
Event names and transport are suggestions, not requirements. Simply moving existing SessionStart hooks earlier could affect hooks that inject context or influence turns; a separate observation surface would avoid assuming that change is compatible.
Additional information
Executed experiments (2026-10-17). Interactive 0.163.0 TUIs used isolated HOME/CODEX_HOME, --no-daemon, no real authentication, and individually trusted hooks. Control turns used a loopback stub provider, not a real model service.
No SessionStart was observed in 15 resume windows without additional prompts: three 30-second windows and twelve 20-second windows. Subsequent minimal test turns produced source=resume. These are bounded observations, not proof across all configurations.
A switch/exit reproduction was: start a TUI, use /new, then /quit. One TUI process emitted SessionEnd for two different root sessions, both with reason=other; the old session could arrive last. Neither one received event nor the last event establishes the current input target.
Source findings, checked separately from runtime observations. The experiment revision was 83086188ae0614bd882818ff1aa23f3194962012; main was also inspected at fixed commit 3b8f43a06bb3105e81406b35ff69f94977d18ae4. These identify the October 17 investigation, not a claim about the latest release at publication. Relevant behavior was present in both:
An active goal can start a turn while idle. The queue extension likewise dispatches persisted input on idle after resume. Thus the gap is a turn-independent resume notification, not a claim that SessionStart can never occur without user input.
Source also shows active-writer conflicts falling back to read-only viewing, and archived-session cancellation exiting normally. Process survival or exit code zero therefore cannot distinguish writable success, read-only fallback and cancellation. These paths and goal/queue continuation were source-reviewed, not newly runtime-tested; no Codex tests were run for this analysis.
Related: #51360 covers delayed hooks; #44902 and #48500 discuss client attribution. The client-side preference and multi-client concerns in #44774 are consistent with starting here at TUI observation.
This asks only for observation: no automatic continuation prompts, tool approvals, goal/queue changes, headless orchestration, or guarantee that resumed work stays paused. Terminal text, private databases and writer-lock files are not requested substitutes; even demonstrated writer ownership would not establish the current TUI input target.
I reproduced this on macOS with the Codex Desktop bundled engine 0.169.0-alpha.11.1.
Enable a trusted plugin that records when its SessionStart hook runs. Use a saved chat that previously ran the hook, and let the chat unload.
Reopen that chat in Desktop. Leave the input empty.
Compare the chat status, last completed turn, and plugin registration before and after reopening.
Desktop changed the chat from notLoaded to idle. Its last completed turn stayed the same. An independent client still could not see it in the plugin’s directory. Starting one ordinary turn in a separate reproduction restored registration.
I also tested the bundled engine with a disposable local app server and a plugin with a stdio MCP server. Two cold resumes of the same saved thread returned idle with zero new turns. MCP started in the correct working directory, but neither its environment nor its initialize request identified the thread. Two chats in one checkout would therefore be ambiguous. A client attached to the owning app server could observe the thread-specific status change.
In this build, the engine queues the resume event and dispatches it in the turn path. A trusted, thread-scoped callback on interactive reopen would let a plugin register the correct chat before the first prompt. A useful regression test would open two chats in the same checkout and verify the callback identifies only the one actually reopened.
CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesenhancementNew feature or requesthooksIssues related to event hooksmcpIssues related to the use of model context protocol (MCP) servers
Activity
github-actions commentedon Oct 10, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
gpgkd906 commentedon Oct 17, 2026
Additional evidence: TUI lifecycle and resume results (
--no-daemon)What variant of Codex are you using?
CLI / interactive TUI (
--no-daemon), macOS; tested Codex 0.163.0.What feature would you like to see?
A terminal session manager needs to restore the exact Codex conversation the user was interacting with when the user confirms a terminal-service restart, and then confirm the outcome. The integration keeps the native interactive TUI, without controlling model work, sending an extra chat message, or taking over the app-server transport. This matches this issue's current-thread/before-prompt requirement; the evidence below adds an embedded-client case and concrete lifecycle ambiguities.
An opt-in observation interface dedicated to TUI lifecycle could provide three outcomes:
--no-daemon: a TUI-spawned observer helper, or another supported mechanism whose association can be checked through the operating system, could work. A PID asserted in a payload is not itself OS-verified process provenance. Solving every shared-daemon attribution case is outside this narrower request.Event names and transport are suggestions, not requirements. Simply moving existing
SessionStarthooks earlier could affect hooks that inject context or influence turns; a separate observation surface would avoid assuming that change is compatible.Additional information
Executed experiments (2026-10-17). Interactive 0.163.0 TUIs used isolated
HOME/CODEX_HOME,--no-daemon, no real authentication, and individually trusted hooks. Control turns used a loopback stub provider, not a real model service.SessionStartwas observed in 15 resume windows without additional prompts: three 30-second windows and twelve 20-second windows. Subsequent minimal test turns producedsource=resume. These are bounded observations, not proof across all configurations./new, then/quit. One TUI process emittedSessionEndfor two different root sessions, both withreason=other; the old session could arrive last. Neither one received event nor the last event establishes the current input target.Source findings, checked separately from runtime observations. The experiment revision was
83086188ae0614bd882818ff1aa23f3194962012; main was also inspected at fixed commit3b8f43a06bb3105e81406b35ff69f94977d18ae4. These identify the October 17 investigation, not a claim about the latest release at publication. Relevant behavior was present in both:SessionStart; execution is inside a turn.SessionEndevents do not identify the selected target.SessionStartcan never occur without user input.Source also shows active-writer conflicts falling back to read-only viewing, and archived-session cancellation exiting normally. Process survival or exit code zero therefore cannot distinguish writable success, read-only fallback and cancellation. These paths and goal/queue continuation were source-reviewed, not newly runtime-tested; no Codex tests were run for this analysis.
Related: #51360 covers delayed hooks; #44902 and #48500 discuss client attribution. The client-side preference and multi-client concerns in #44774 are consistent with starting here at TUI observation.
This asks only for observation: no automatic continuation prompts, tool approvals, goal/queue changes, headless orchestration, or guarantee that resumed work stays paused. Terminal text, private databases and writer-lock files are not requested substitutes; even demonstrated writer ownership would not establish the current TUI input target.
flyryan commentedon Nov 21, 2026
I reproduced this on macOS with the Codex Desktop bundled engine
0.169.0-alpha.11.1.SessionStarthook runs. Use a saved chat that previously ran the hook, and let the chat unload.Desktop changed the chat from
notLoadedtoidle. Its last completed turn stayed the same. An independent client still could not see it in the plugin’s directory. Starting one ordinary turn in a separate reproduction restored registration.I also tested the bundled engine with a disposable local app server and a plugin with a stdio MCP server. Two cold resumes of the same saved thread returned
idlewith zero new turns. MCP started in the correct working directory, but neither its environment nor its initialize request identified the thread. Two chats in one checkout would therefore be ambiguous. A client attached to the owning app server could observe the thread-specific status change.In this build, the engine queues the resume event and dispatches it in the turn path. A trusted, thread-scoped callback on interactive reopen would let a plugin register the correct chat before the first prompt. A useful regression test would open two chats in the same checkout and verify the callback identifies only the one actually reopened.