Skip to content

fix(desktop): prevent terminal realtime session resurrection - #9791

Merged
kodjima33 merged 3 commits into
mainfrom
fix/realtimehub-close-send-race
Jul 15, 2026
Merged

kodjima33 merged 3 commits into
mainfrom
fix/realtimehub-close-send-race

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #9666.

A terminal RealtimeHub transport error previously posted to the main-actor controller before the physical session was made non-sendable. Queued audio or commit work could therefore attempt a WebSocket send during the close-to-controller-teardown window.

This change clears transport readiness and detaches the task on the session queue before delivering the controller callback.

Product invariants affected

  • INV-CHAT-1

Durable guard

RealtimeHubSessionInputLifecycleTests.testOpenAITransportCloseImmediatelyMakesSessionNonSendableBeforeControllerTeardown failed before the repair and passes after it.

Verification

  • focused lifecycle regression test — passed
  • xcrun swift test --package-path Desktop --filter Realtime — 117 passed
  • make preflight — pending this PR metadata

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor follow-up for PR #9791:

  • No code changes were needed in this run. The context-listed cancelled Repo Checks were superseded by passing/skipped current checks on the same head commit.
  • Re-scanned trusted review threads: none unresolved.
  • Verification passed locally:
    • git diff --check origin/main...HEAD
    • python3 .github/scripts/check-desktop-changelog.py --base origin/main --head HEAD
    • xcrun swift test -c debug --package-path Desktop --filter RealtimeHubSessionInputLifecycleTests/testOpenAITransportCloseImmediatelyMakesSessionNonSendableBeforeControllerTeardown (1 test passed)
  • Current GitHub checks show Desktop Swift Build & Tests, Desktop Swift Release Compile, Detect Changes, and Hygiene passing; non-applicable checks are skipped.

Synchronously clear transport readiness and detach the task on the session queue before delivering a terminal error to the controller, preventing close-to-send races.

Tests:
- xcrun swift test --package-path Desktop --filter RealtimeHubSessionInputLifecycleTests/testOpenAITransportCloseImmediatelyMakesSessionNonSendableBeforeControllerTeardown
- xcrun swift test --package-path Desktop --filter RealtimeHub
Guard terminal sessions at start, transport-open, and provider-readiness boundaries so queued setup acknowledgements cannot re-open a closed session or flush its buffers.\n\nTests:\n- xcrun swift test --package-path Desktop --filter RealtimeHubSessionInputLifecycleTests/testTerminalOpenAISessionDoesNotResurrectFromLateReadiness\n- xcrun swift test --package-path Desktop --filter Realtime
@Git-on-my-level
Git-on-my-level force-pushed the fix/realtimehub-close-send-race branch from a896d05 to 2ae9c45 Compare July 15, 2026 12:09
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Rebased PR #9791 onto latest origin/main (was 2 commits behind) and force-pushed.

What changed: No code changes — only a clean rebase of the existing 3 commits onto the current upstream main. The PR's fix (clear transport readiness and detach the task before delivering the controller error callback) is unchanged.

Verification:

  • scripts/pr-preflight — 14/14 checks passed (with PR body providing INV-CHAT-1)
  • Desktop Swift Build & Tests — passed (9m20s)
  • Desktop Swift Release Compile — passed
  • Hygiene — passed
  • All Detect Changes — passed
  • No new bot review comments (Codex/Cubic) after the push

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor pass complete for PR #9791.

  • No code changes were needed: the trusted review-thread re-scan found no unresolved review threads (zero reviews, zero inline comments from Codex or Cubic).
  • The worktree was rebased onto latest upstream/main (was 2 commits behind); the rebased head 2ae9c45 is already pushed and current on the PR branch.
  • All CI checks pass on the current head: Desktop Swift Build & Tests (9m20s), Desktop Swift Release Compile, Hygiene, and all Detect Changes checks pass; all other component checks skipped.
  • PR status: MERGEABLE, merge state BLOCKED only for review requirement.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualifying bug fix (root cause stated, scoped, tested, CI green).

@kodjima33
kodjima33 merged commit 5d40755 into main Jul 15, 2026
19 checks passed
@kodjima33
kodjima33 deleted the fix/realtimehub-close-send-race branch July 15, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS RealtimeHub: rotate/reconnect OpenAI sessions at the 60-minute limit without surfacing an error

2 participants