Skip to content

🤖 refactor: handlers that return an offline result use the live client - #6317

Open
ThomasK33 wants to merge 5 commits into
mainfrom
stable-api/4a-result-gates
Open

ThomasK33 wants to merge 5 commits into
mainfrom
stable-api/4a-result-gates

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR is layer 4a of the reconnect stack (base: #6304). Handlers that answer "offline" with a result now check the live client (useLiveAPI()). Nothing changes today: the live client equals useAPI().api until PR 6. After PR 6, useAPI().api keeps the last client while Xum reconnects. A gate on it would then let the call through, and the call would fail with ConnectionLostError instead of the handler's own offline result ({ success: false, error: "API not connected" }, an empty list, or a thrown "not connected" error).

Implementation

Each gated handler uses liveApi (from useLiveAPI()) in its gate, its calls and its useCallback deps. Effects and subscriptions in the same components keep api: PR 5 changes those.

Site Handlers
ProjectContext removeProject, getBranchesForProject, getSecrets, updateSecrets, updateDisplayName, updateColor, updateCustomInstructions, assignWorkspaceToSubProject, getRemovalBlockers, updateCodeWorkspaceSyncPath
WorkspaceContext createWorkspace, workspace removal, updateWorkspaceTitle, setWorkspacePinned, reorderPinnedWorkspaces, preflightArchiveWorkspace, archiveWorkspace, unarchiveWorkspace, getWorkspaceInfo, and the side-chat discard queue (it already used useLiveAPI())
App.tsx fast-mode toggle, multi-project creation, archive merged, branch list. The command palette sources and confirmAndRemoveSubagent now get the live client, which covers their own !p.api gates.
Components and hooks ProjectSidebar and AgentListItem title regeneration, ChatPane queued dispatch mode, UILayoutsContext.saveAll, useComposerAttachments staging, useCreationWorkspace trust prompt, RightSidebar goal actions, useExperiment, useOpenInEditor, DelegatedCreationInterruptedBanner

Handlers with their own offline message (WorkspaceMenuBar, ProjectCreateModal, ChatInput, settings sections) follow in PR 4b.

Validation

  • WorkspaceContext.test.tsx, new both-mode test (null-gap today, kept-gap after the switch): after a drop, the project and workspace handlers return their offline result and call no server method. The kept-gap case fails without this PR.
  • offlineResultGates.test.ts scans src/browser with the TypeScript compiler. It fails on an if (!api) or api == null gate that returns { success: false } or throws, so a new handler cannot gate on useAPI().api. It lists App.tsx and useExperiments.ts when I revert them.
  • make static-check, make crap-check, and bun test on the touched folders pass.

Risks

Low. Before PR 6 the live client and useAPI().api are the same object in every render (PR 2 pins this), so every changed handler behaves as before.


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

@ThomasK33
ThomasK33 added this pull request to stack #6296 October 13, 2026 08:47
@ThomasK33 ThomasK33 changed the title stable api/4a result gates 🤖 refactor: handlers that return an offline result use the live client Oct 13, 2026
@ThomasK33
ThomasK33 force-pushed the stable-api/4a-result-gates branch 2 times, most recently from 46f9334 to b66797e Compare October 13, 2026 10:05
@ThomasK33
ThomasK33 marked this pull request as ready for review October 13, 2026 10:29
@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-13T13:11:12.661696Z ced336d New commits
🔒 Security Review ✅ Completed 2026-10-13T13:09:05.800781Z ced336d 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.

Base automatically changed from stable-api/3-terminal-router to main October 13, 2026 10:41
@ThomasK33
ThomasK33 force-pushed the stable-api/4a-result-gates branch from b66797e to 54a5f43 Compare October 13, 2026 10:41

@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: 54a5f4383c

ℹ️ 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/offlineResultGates.test.ts Outdated
@ThomasK33
ThomasK33 force-pushed the stable-api/4a-result-gates branch from 54a5f43 to 7212c9f Compare October 13, 2026 11:05

@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: 7212c9fa5c

ℹ️ 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/offlineResultGates.test.ts
Comment thread src/browser/App.tsx Outdated
Comment thread src/browser/contexts/UILayoutsContext.tsx

@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: f7ba755584

ℹ️ 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/utils/subagentRemoval.ts
@ThomasK33
ThomasK33 force-pushed the stable-api/4a-result-gates branch from f7ba755 to c07e65f Compare October 13, 2026 12:13

@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: c07e65fa0a

ℹ️ 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/offlineResultGates.test.ts
Comment thread src/browser/contexts/WorkspaceContext.tsx

@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: ced336df50

ℹ️ 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/App.tsx
Comment thread src/browser/contexts/offlineResultGates.test.ts

This branch has not been deployed

No deployments
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