Skip to content

fix(server): suppress teardown-only Codex session closures#1946

Open
ashvinnihalani wants to merge 1 commit intopingdotgg:mainfrom
ashvinnihalani:t3code/silent-shutdown-recovery
Open

fix(server): suppress teardown-only Codex session closures#1946
ashvinnihalani wants to merge 1 commit intopingdotgg:mainfrom
ashvinnihalani:t3code/silent-shutdown-recovery

Conversation

@ashvinnihalani
Copy link
Copy Markdown
Contributor

@ashvinnihalani ashvinnihalani commented Apr 12, 2026

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 / stopAll so teardown-only cleanup can skip session/closed lifecycle emission, and updates CodexAdapter.stopAll plus 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 real session.exited runtime 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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk
Low risk: adds an optional flag to suppress session/closed emission 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/stopAll now accept an emitLifecycleEvent option (defaulting to true) and skip emitting session/closed when disabled; CodexAdapter.stopAll and the adapter finalizer now call stopAll({ 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/closed lifecycle events during Codex adapter teardown

  • Adds an optional emitLifecycleEvent flag to CodexAppServerManager.stopSession and stopAll, defaulting to true for existing behavior.
  • Updates makeCodexAdapter in CodexAdapter.ts to pass { emitLifecycleEvent: false } when stopping sessions during adapter teardown or scope finalization.
  • Sessions are still stopped and updateSession is still called; only the session/closed lifecycle event is suppressed.

Macroscope summarized a7b3524.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 60d436a1-16de-460b-9b89-bf26448b6350

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Apr 12, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 12, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant