Repository navigation
fix(ui): keep settings drafts and data through reconnects - #174045
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dbe9c9279d
ℹ️ 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".
| onIdentityChange: () => { | ||
| setView((state) => { | ||
| state.editor = null; | ||
| state.draft = createCloudWorkerDraft(); | ||
| }); |
There was a problem hiding this comment.
Clear cloud-worker drafts when admin access is lost
When a connected snapshot on the same GatewayBrowserClient drops operator.admin, onIdentityChange does not run because GatewayPageBinding defines identity changes only as source/client replacement. The editor therefore remains open with its unsaved setup/setupEnv draft visible after the current account no longer has permission; unlike the adjacent cloud-worker owners, this page has no onSnapshot access-loss reset. Clear the editor and draft when a fresh connected snapshot fails the config.patch admin check.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3b9145f: Confirmed admin revocation now clears the machine profile editor and private setup drafts and retires pending catalog work.
|
Codex review: needs real behavior proof before merge. What this changesThis PR preserves Settings drafts and loaded data across same-client reconnects and conditionally resumes unsent configuration autosaves. Example: Enter an unsaved device execution policy with security set to allowlist, then briefly disconnect the Gateway.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 7 items remain Keep this PR open: it addresses draft loss still present on main, but retaining the Models sign-in wizard introduces an enabled submission button that silently does nothing while disconnected. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherSettings pages consume Gateway snapshots and configuration projections, retain local presentation state, and submit authorized mutations through existing Gateway RPC owners. flowchart LR
A[Settings input] --> B[Page draft owner]
C[Gateway connection snapshots] --> B
C --> D[Request and authorization guards]
B --> D
D --> E[Gateway RPC]
E --> F[Authoritative configuration and accounts]
Technical reviewBest possible solution: Preserve drafts at their existing owners while keeping submission availability, current authorization, request retirement, and configuration revision checks explicit. Do we have a high-confidence way to reproduce the issue? Source shows both main's reconnect resets and the introduced enabled-but-inert wizard submission path; no runtime reproduction was executed. Is this the best way to solve the issue? Separating presentation retention from request lifetimes is the right approach and reuses the existing page, configuration, and Gateway owners. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 330ce7f06f38. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: unit tests only. SecurityNeeds attention: Retained mutation intent needs final-effect authorization evidence; no concrete authorization bypass or supply-chain regression was established. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +476, Tests +952, Docs +15. Total +1443 across 77 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 5:11 AM ET / 09:11 UTC. |
Keep same-client Settings drafts and loaded views through transient disconnects while fencing old requests and requiring live authority for submissions. Retire defaults and profile-order intent only after acknowledged success, and resume unsent config autosave only after an unchanged-base refresh.
dbe9c92 to
f6c1702
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6c170296a
ℹ️ 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".
| if (change.snapshot.phase === "connected") { | ||
| const auth = change.snapshot.hello?.auth; | ||
| const allowed = auth?.scopes !== undefined && hasOperatorAdminAccess(auth); | ||
| if (profilesVisible && !allowed) { | ||
| resetConnectionState(); | ||
| } | ||
| profilesVisible = allowed; |
There was a problem hiding this comment.
Reload model providers when admin access returns
When an already-connected client regains operator.admin after previously losing it, this sets profilesVisible back to true but does not restart the core provider load that resetConnectionState() cleared on access loss. Because GatewayPageBinding only invokes ensureInitialData for connection or identity changes, the page remains indefinitely in its empty loading state until another unrelated refresh occurs. Trigger the replacement refresh when allowed transitions from false to true.
AGENTS.md reference: ui/AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: Model Providers reloads through the existing route loader on navigation or the page Refresh action, so an additional grant change reload is outside this retention fix.
| if (!nextAccess[0]) { | ||
| resetLoadedSkillState(); | ||
| } else { | ||
| if (!nextAccess[1]) { | ||
| library.reset(); | ||
| } | ||
| if (!nextAccess[2]) { | ||
| data.skillEdits = {}; |
There was a problem hiding this comment.
Reload Skills data when read access returns
When a connected snapshot regains operator.read, this branch invalidates requests but never calls ensureInitialData, loadSkills, or library.load. The preceding access-loss transition cleared the report and library, and GatewayPageBinding does not run its initial-data callback for a same-client permission-only update, so the Skills page stays empty until navigation or another unrelated event causes a load. Start the reads when nextAccess[0] transitions back to true.
AGENTS.md reference: ui/AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: Skills already reloads its report and library through Refresh or the next navigation, so immediate permission return reload is unnecessary.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0511efeea
ℹ️ 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".
| if ((canRead && !nextRead) || (canAdmin && !nextAdmin) || (canManagePairing && !nextPairing)) { | ||
| gatewayBinding.invalidate(); | ||
| invalidateRequests(); | ||
| } |
There was a problem hiding this comment.
Reload Devices data when privileges return
When a connected same-client snapshot restores operator.read, pairing, or admin privileges, this only updates the access booleans. The corresponding loss path has already cleared nodes/presence, devicesList, and execution approvals, while neither GatewayPageBinding nor handleGatewaySnapshot calls ensureInitialData for an auth-only update. Pairing and node data therefore remain absent until polling, and execution approvals remain empty until manually loaded. Trigger the appropriate refreshes on false-to-true access transitions.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: Devices reloads inventory through polling or navigation and exposes Load for execution approvals, so an additional permission return reload is unnecessary.
| if (becameConnected || (identityChanged && !mutationOwnsIdentityChange)) { | ||
| queueVerification(); |
There was a problem hiding this comment.
Reverify GitHub identities when access returns
When a connected account regains read/admin access without reconnecting, the preceding loss transition has cleared status, personal, and system, but this condition does not call queueVerification() because becameConnected and identityChanged are both false. Although the capability and client revision changed, the GitHub connection UI remains unloaded until another reconnect or identity change; include the access-restored transition in the verification condition.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: Profile connections reverify on access snapshots and the agent Tools panel rechecks on its next navigation or refresh, so hidden panel reloads are unnecessary.
| const allowed = hasOperatorAdminAccess(snapshot.hello?.auth ?? null); | ||
| if (this.adminAccess && !allowed) { | ||
| this.invalidateRequests(false); | ||
| } | ||
| this.adminAccess = allowed; |
There was a problem hiding this comment.
Restore selected plugin details when admin access returns
On a same-client admin-access loss, this branch calls invalidateRequests(false), which retires state.detail; when admin access later changes from false to true, the branch only records the boolean. Because access changes are absent from shouldRefreshAfterChange, ensureInitialData() does not call showDetails(), and unchanged route data is not reapplied, so a deep-linked plugin page falls back to the inventory and stays there until navigation or manual retry. Reload the active detail on access restoration.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: The selected plugin detail reloads through route navigation and catalog refresh completion, so an additional grant change reload is unnecessary.
| onSnapshot: ({ snapshot }) => { | ||
| if ( | ||
| snapshot.phase === "connected" && | ||
| !canCallGatewayMethod(snapshot, "environments.list", "operator.admin") | ||
| ) { | ||
| clearPresentation(); | ||
| } |
There was a problem hiding this comment.
Reload cloud-worker environments when admin access returns
When the Gateway advertises environments.list but not the optional crabbox.images.list method, losing admin access clears the environment inventory here, but regaining access on the same connected client does not call load(). GatewayPageBinding does not rerun initial loading for an auth-only update, and the nearby effect continues to see canCall("crabbox.images.list") === false on both sides, so the page remains empty until focus or another unrelated refresh. Detect the false-to-true environment access transition directly.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: Environments reloads through the existing page activation handler even without the optional images method, and the regression now proves recovery through that path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28a4a5f238
ℹ️ 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".
| onSnapshot: ({ snapshot }) => { | ||
| if ( | ||
| snapshot.phase === "connected" && | ||
| !canCallGatewayMethod(snapshot, "environments.list", "operator.admin") | ||
| ) { | ||
| clearPresentation(); | ||
| } |
There was a problem hiding this comment.
Invalidate environment loads when admin access is lost
When operator.admin is revoked while environments.list is in flight on the same client, this branch clears the displayed data but does not invalidate the GatewayPageBinding scope or cancel activeLoad. An authorization-only snapshot leaves the connection epoch unchanged, so the response still passes gateway.isCurrent(scope) and republishes the restricted inventory after it was cleared. Invalidate or cancel the request as part of this access-loss path so an older authorized response cannot restore the data.
AGENTS.md reference: ui/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3b9145f: Confirmed admin revocation now invalidates the existing Gateway request scope and retires the active environment load before clearing inventory, preventing late environment and image responses from restoring restricted data.
What Problem This Solves
Fixes: unsaved Settings edits disappear when the Gateway connection blips.
Several Settings pages treated an ordinary reconnect of the same client as an identity change and reset their state: Model Providers dropped default-model drafts, key editors, entered keys and login flows; Plugins closed credential editors and cleared details; Devices discarded unsaved execution-approval policy edits; Skills reset library editor content; Profile reset the display-name draft and account-linking flow; GitHub identity, Session Storage, Channels (Nostr drafts) and Cloud Worker pool/policy drafts reset too, and Channels claimed nothing was connected. Model default drafts and profile-order intent were also cleared after a failed or never-dispatched save. Config autosave paused after any disconnect until an explicit Save, even when nothing was in flight.
User Impact
User impact: you can keep editing Settings through a spotty connection; your drafts and the last loaded data stay put, saves are disabled only while disconnected, and autosave resumes on its own after a clean reconnect.
Why This Change Was Made
Request-generation fencing is unchanged (old-epoch results are still discarded); only drafts and presented data now outlive a same-identity transport edge. A different client, Gateway or account still resets everything, and typed secrets stay in memory only. Model default drafts and profile-order intent clear only on acknowledged success. The config write coordinator resumes autosave after reconnect only when no submission was in flight and the base revision is unchanged; uncertain submissions and changed bases keep the existing pause and explicit recovery.
Part of the offline-first series.
Evidence
operator.admin/read access was revoked can no longer republish restricted data (Cloud Workers environments/images/editor, Models, Plugins, Channels plugin presentation, config writes, Profile, GitHub identity before identity readiness).Landing validation
The current head merges main through
45c6db39b27. The Skills conflict keeps main's sharedcreatePageRequestowner while retaining drafts and loaded results and canceling pending reads on reconnect or access loss. Six focused files passed all 51 tests; formatting and whitespace checks passed; independent Codex autoreview was scoped-clean. The offline guide no longer promises memory-search retention, which remains the plugin-host follow-up described above.CI run 39062011444 has one inherited failure:
check-lint-core-2reportstypescript(await-thenable)atsrc/infra/sqlite-readonly-location.worker.ts:381. Main commitf15018960a1removed the async state-snapshot operation from the read-only registry but retained the worker's await on its now-synchronous dispatch. The exact tested merge10611c2417375c451c05e53e5a54d95b321ec082has main parentd91ee6e97b7d42fe80c42d16f98c60788824e4c2; the failing source, registry, operation contracts, lint configuration, and dependencies are byte-identical to that parent. This PR changes only UI/docs. The CI classification used an older main run from before that removal. Scheduled main CI run 39062485709 independently reproduces the identical diagnostic incheck-lint-core-4; main and this PR assignsrc/infrato different lint stripe numbers. Every other job in the PR run completed successfully or was normally skipped, including successfulsecurity-fast. This failure is recorded for the native inherited-failure landing path; CI remains failed. No checks were rerun or assertions weakened.