Skip to content

🤖 tests: two-mode reconnect harness, useLiveAPI for stores and deferred writes, stream inventory - #6295

Merged
ThomasK33 merged 6 commits into
mainfrom
stable-api/2-harness
Oct 13, 2026
Merged

ThomasK33 merged 6 commits into
mainfrom
stable-api/2-harness

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR is layer 2 of the reconnect stack (base: #6293). It adds a test harness that simulates both reconnect behaviours of the API provider, and useLiveAPI(), which returns the client only while the connection is live. It moves the stores and the side-chat discard queue to useLiveAPI(). It also adds a test that fails when a new file opens a server stream without a restart rule. Nothing a user sees changes yet.

Background

The last PR of the stack makes useAPI().api keep the last client while Xum reconnects, instead of null, so panes do not blank. After that, api != null no longer means "online". The code that must see "offline" now reads useLiveAPI():

  • The 10 stores. They drop their client while offline and resubscribe when it comes back (AppLoader.tsx, and AppConfigStore through API.tsx).
  • The side-chat discard queue (useDiscardSideChatOnLeave). Otherwise it would send its discard into the gap, the call would fail, and the side chat would stay.

Today useLiveAPI() equals useAPI().api in every render. A provider test checks that over three drops and reconnects.

Implementation

  • connection.testHarness.tsx runs the same test in two gap modes:

    • null-gap (today): api goes to null in the gap.
    • kept-gap (after the switch): api stays the old client, and its calls reject with ConnectionLostError.

    Each connect builds a real oRPC client over the ConnectionLink from 🤖 feat: ConnectionLink and ConnectionLostError (not used yet) #6293, as the provider will. A drop keeps each mode's real order. Today React renders the drop first, because it treats a socket close event as a discrete event. After the switch, the link rejects calls first.

  • ArtifactsReconnect.test.tsx now runs all 11 cases in both modes (describe.each).

  • subscriptionInventory.test.ts reads every eventIterator procedure from schemas/api.ts (26 today) and finds the renderer files that read them. Each file must state how its stream restarts after a reconnect (effect deps, store feed, router, backoff, one-off operation). A new holder fails the test until it is listed.

  • APIState now types reconnecting and error with api: APIClient | null. The provider still passes null. Four closures in WorkflowRunToolCall.tsx relied on the old narrowing, so they now capture the client in a local.

Validation

  • The harness catches the bug that 🤖 fix: artifacts stay rendered across a dropped connection #6253 fixed. With the old !api early return put back in useArtifactInteractions, three null-gap cases fail.
  • The discard test fails in kept-gap mode if the hook gets useAPI().api instead of the live client.
  • These suites pass: src/browser/contexts, ArtifactsTab, AppLoader, WorkflowRunToolCall and the new tests (526 + 68). make static-check also passes.

Risks

Low. The only runtime change is that the stores and the discard queue read a value that equals the old one in every render (tested).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $23.83

@ThomasK33
ThomasK33 added this pull request to stack #6296 October 13, 2026 07:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:22:01.461447Z c2e5350 New commits
🔒 Security Review ✅ Completed 2026-10-13T08:21:20.600369Z c2e5350 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33 ThomasK33 changed the title test+refactor: two-mode reconnect harness, useLiveAPI for stores and deferred writes, stream inventory 🤖 tests: two-mode reconnect harness, useLiveAPI for stores and deferred writes, stream inventory Oct 13, 2026
@ThomasK33
ThomasK33 force-pushed the stable-api/2-harness branch from 5d11111 to fb60c16 Compare October 13, 2026 07:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb60c16f6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/contexts/subscriptionInventory.test.ts
Comment thread src/browser/contexts/connection.testHarness.tsx Outdated
@ThomasK33
ThomasK33 force-pushed the stable-api/2-harness branch from 02f2668 to c2e5350 Compare October 13, 2026 08:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2e5350f7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

},
"operation-stream": {
describe: "one operation's stream (no restart by design)",
matches: () => true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the operation-stream classification

When a new long-lived stream holder is mistakenly labeled operation-stream, this unconditional matcher lets the inventory pass even though the stream will remain dead after reconnect. Fresh evidence after the earlier review is that the added rule-shape validation explicitly returns true for this classification, so the original bypass still exists for at least one rule; check that the stream is actually scoped to a one-off operation or restrict this exemption to verified holders.

AGENTS.md reference: AGENTS.md:L233-L235

Useful? React with 👍 / 👎.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 00b933e Oct 13, 2026
35 of 53 checks passed
Base automatically changed from stable-api/1-connection-link to main October 13, 2026 10:05
@ThomasK33
ThomasK33 deleted the stable-api/2-harness branch October 13, 2026 10:05
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.

1 participant