fix(server): suppress teardown-only Codex session closures#1946
fix(server): suppress teardown-only Codex session closures#1946ashvinnihalani wants to merge 1 commit intopingdotgg:mainfrom
Conversation
Allow CodexAppServerManager stopAll/stopSession to suppress session/closed lifecycle emission, and use that path from CodexAdapter stopAll and adapter finalization. Add manager and adapter coverage for silent teardown behavior.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved This is a small, backward-compatible bug fix that adds an optional flag to suppress lifecycle event emission during teardown. The default behavior is preserved, the change is well-tested, and the scope is limited to cleanup scenarios where emitting events would be noise. You can customize Macroscope's approvability policy. Learn more. |
Allow CodexAppServerManager stopAll/stopSession to suppress session/closed lifecycle emission, and use that path from CodexAdapter stopAll and adapter finalization.
Add manager and adapter coverage for silent teardown behavior.
What Changed
Closing or reloading T3 Code no longer emits spurious Codex session-exited events during teardown.
Technically, this adds a silent shutdown path to
CodexAppServerManager.stopSession/stopAllso teardown-only cleanup can skipsession/closedlifecycle emission, and updatesCodexAdapter.stopAllplus adapter finalization to use that path. I also added manager- and adapter-level tests to verify teardown still clears sessions without reporting a real session exit.Why
Today, when the Codex adapter shuts down, it tears down all tracked sessions through the same path used for an intentional session stop. That causes teardown to emit
session/closed, which is then projected as a realsession.exitedruntime event even though the app is just shutting down.For users, that can surface as threads being treated like they explicitly exited when they only closed or restarted the app. This change keeps intentional session stops observable, but makes teardown-only cleanup quiet so shutdown does not create misleading lifecycle events or leave session state looking more final than it really is.
UI Changes
Checklist
Note
Low Risk
Low risk: adds an optional flag to suppress
session/closedemission during teardown and updates adapter shutdown paths; behavior for explicit session stops remains unchanged by default.Overview
Prevents shutdown/reload of the Codex adapter from producing misleading “session exited” runtime events by adding a silent teardown option.
CodexAppServerManager.stopSession/stopAllnow accept anemitLifecycleEventoption (defaulting totrue) and skip emittingsession/closedwhen disabled;CodexAdapter.stopAlland the adapter finalizer now callstopAll({ emitLifecycleEvent: false }). Tests were added/updated to verify sessions are still cleared and lifecycle events are suppressed during teardown.Reviewed by Cursor Bugbot for commit a7b3524. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Suppress
session/closedlifecycle events during Codex adapter teardownemitLifecycleEventflag toCodexAppServerManager.stopSessionandstopAll, defaulting totruefor existing behavior.makeCodexAdapterin CodexAdapter.ts to pass{ emitLifecycleEvent: false }when stopping sessions during adapter teardown or scope finalization.updateSessionis still called; only thesession/closedlifecycle event is suppressed.Macroscope summarized a7b3524.