openai / openai/codex

Windows Desktop Quit stops app-server without dispatching SessionEnd

Open
#43,377 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app app-server bug hooks windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the Codex App are you using (From “About Codex” dialog)?

Windows MSIX package 26.901.6511.0 (also reproduced on 26.901.5280.0); Codex CLI 0.153.4

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Quitting Codex Desktop on native Windows does not dispatch the configured and trusted SessionEnd hook for the currently open root thread. This reproduces both when the main window is closed with the title-bar X and the app is then quit from the Windows notification area, and when Quit is used from the notification area.

No new SessionEnd entry marker is written and no hook start, completion, timeout, or failure is recorded. Relaunching dispatches a new SessionStart. The previous Desktop-process log ends with:

Stopping app-server transport connectionId=1 transport=stdio
app_server_connection.state_changed cause=stop_process ... next=disconnected

There is no intervening SessionEnd, graceful shutdown request, hook-start, or hook-completion record.

What steps can reproduce the bug?
  1. Open a trusted local project in Codex Desktop.
  2. Configure one project-local SessionEnd command hook with an absolute path and a 3-second timeout. The test hook writes an entry marker immediately, then starts its real work asynchronously.
  3. Confirm in /hooks that it is installed, active, and trusted.
  4. Send a prompt and wait for the turn to complete.
  5. Close the main window with X.
  6. From the Windows notification area, choose Quit for Codex.
  7. Wait at least 30 seconds.
  8. Relaunch Codex Desktop and reopen the same thread.
  9. Observe that SessionStart runs but no new SessionEnd marker exists.

Controls using the same project and hook command:

  • Archiving the open thread in Codex Desktop dispatches SessionEnd successfully.
  • Codex CLI /exit dispatches SessionEnd successfully.
  • Natural Desktop PreCompact succeeds.
  • Desktop SessionStart and UserPromptSubmit succeed.

The failure reproduced on two Desktop package versions. Hook count, absolute command path, trust, timeout, PowerShell availability, and script execution were verified between runs.

What is the expected behavior?

Codex Desktop should gracefully shut down the app-server before terminating its process. The app-server should dispatch SessionEnd once for every open root thread, wait within the documented bounded shutdown budget, and then exit. This should produce the same hook lifecycle as Codex CLI /exit.

Additional information

The open-source Codex core already invokes run_session_end_hooks() from the session shutdown handler, and the SessionEnd timeout is capped to leave room inside app-server teardown. The Windows Desktop Quit path appears to stop the stdio app-server process without first invoking that graceful shutdown path.

Requested acceptance criteria:

  1. Title-bar close followed by application Quit and notification-area Quit initiate graceful app-server shutdown.
  2. Every open root thread receives exactly one SessionEnd dispatch before termination.
  3. The app observes the existing bounded shutdown timeout.
  4. Archive, delete, idle-unload, and CLI behavior remain unchanged.
  5. Add a Windows Desktop integration test using a marker-only SessionEnd hook.

References:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with codex-rs/core/src/session/handlers.rs and codex-rs/hooks/src/events/session_end.rs, then trace the Windows Desktop Quit path that stops the stdio app-server. Compare it with CLI /exit and the existing shutdown behavior. Done means the listed Quit paths dispatch exactly one SessionEnd per open root thread, respect the bounded timeout, preserve other behavior, and include a marker-only Windows Desktop integration test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend, desktop, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.