inspector/clients/web/src/utils
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cliffhall 104b3c0775 chore(web): collapse App.tsx's six session refs into useSessionRef (#2129)
Step 1 of phase 2 of the App.tsx decomposition, landed first and alone
because it is the seam the remaining clusters are extracted onto.

App.tsx kept six "latest value" refs so long-lived callbacks could read a
current value without listing it as a dependency and being re-created on
every change: `activeServerNameRef`, `activeServerIdRef`, `serversRef`,
`inspectorClientRef`, `pendingStepUpRef` and `pendingReauthRef`, plus the
three passive effects that synced them. `useSessionRef` replaces all nine
with one hook returning one stable ref onto a `SessionSnapshot`.

This is not a store: nothing renders off it, nothing subscribes to it, and
mutating it never schedules a render. It is not the prop-to-state sync
AGENTS.md forbids either — that rule is about `setState` in an effect, and
a ref write produces no render at all. It is exactly the pattern the file
already used, written once instead of six times.

What it buys the later steps is a *stable* dependency: a hook taking
`sessionRef` does not drag the other clusters into its argument list, so
`useOAuthRecovery`, `useConnectionLifecycle` and `useServerCommands` can
be extracted one PR at a time.

Behavior is unchanged:

- The snapshot is seeded from the first render's values, matching what
  each `useRef(value)` seeded.
- `activeServerName` keeps its one non-uniform rule — it holds the last
  server that *was* active and is never cleared, because a transport
  crash clears `activeServerId` before the failure toast is raised. It is
  derived from `servers`/`activeServerId` rather than taking the
  `activeServer` memo, which is the same value by definition and is what
  lets the hook be called ahead of that memo.
- The two pending-* syncs already ran ahead of the only effect that reads
  them, so merging them changes no effect's view. The other four synced
  below every effect that reads them, so hoisting that sync changes none
  either.
- The sync effect is deliberately un-gated rather than carrying a
  dependency list: re-assigning unchanged values costs nothing and
  removes a place for a newly-added field to be forgotten.

`sessionRef` is declared ahead of its first reader because a hook return
is not provably stable to `react-hooks/exhaustive-deps` — consumers must
list it, and a later declaration would put every one of them in the
temporal dead zone. Listing a ref that never changes identity re-runs
nothing.

The inline `pendingStepUp` state shape is named `PendingStepUp` and moved
beside `StepUpSource` in `utils/stepUp.ts`, so the snapshot can name it
without importing from the component that owns the state.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MZdpUwhHf943FoprcLVzEm
Signed-off-by: cliffhall <cliff@futurescale.com>
2026-08-26 20:43:29 -04:00
..
toasts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
correlateTransportErrors.test.ts Network: modern Mcp-* headers, new error codes, cancellation-as-abort (#1628) (#1722) 2026-07-18 17:32:05 -04:00
correlateTransportErrors.ts Network: modern Mcp-* headers, new error codes, cancellation-as-abort (#1628) (#1722) 2026-07-18 17:32:05 -04:00
customHeaders.test.ts refactor(web): sharpen the src/lib vs src/utils rule and move misfiled modules (#1784) 2026-07-25 22:24:30 -04:00
customHeaders.ts refactor(web): sharpen the src/lib vs src/utils rule and move misfiled modules (#1784) 2026-07-25 22:24:30 -04:00
deepLink.test.ts web: deep-link auto-connect + machine-readable connection status (#1576) 2026-07-11 22:48:28 -04:00
deepLink.ts web: deep-link auto-connect + machine-readable connection status (#1576) 2026-07-11 22:48:28 -04:00
errorFormat.test.ts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
errorFormat.ts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
inspectorTabs.test.ts refactor(web): rename "History" tab/feature to "Protocol" (#1623) 2026-07-09 19:04:54 -04:00
inspectorTabs.ts refactor(web): rename "History" tab/feature to "Protocol" (#1623) 2026-07-09 19:04:54 -04:00
jsonObjectDraft.test.ts fix: reject non-finite numbers before they reach _meta 2026-08-23 19:43:39 -04:00
jsonObjectDraft.ts fix: reject non-finite numbers before they reach _meta 2026-08-23 19:43:39 -04:00
jsonUtils.test.ts fix: address Copilot review round 41 — const does not demand a property, required-only branches 2026-08-26 16:08:24 -04:00
jsonUtils.ts fix: address Copilot review round 41 — const does not demand a property, required-only branches 2026-08-26 16:08:24 -04:00
malformedListReport.test.ts fix: return the era-parsed tool, and hide aggregate reports in paginated mode (#1909) 2026-08-15 20:08:03 -04:00
malformedListReport.ts fix: return the era-parsed tool, and hide aggregate reports in paginated mode (#1909) 2026-08-15 20:08:03 -04:00
maskSecrets.test.ts feat(network): show auth response bodies with masked secrets + reveal toggle (#1386) (#1387) 2026-05-31 08:52:13 -04:00
maskSecrets.ts feat(network): show auth response bodies with masked secrets + reveal toggle (#1386) (#1387) 2026-05-31 08:52:13 -04:00
mcpNetworkHeaders.test.ts Network: modern Mcp-* headers, new error codes, cancellation-as-abort (#1628) (#1722) 2026-07-18 17:32:05 -04:00
mcpNetworkHeaders.ts Network: modern Mcp-* headers, new error codes, cancellation-as-abort (#1628) (#1722) 2026-07-18 17:32:05 -04:00
oauthFlow.test.ts Auth hardening CI gaps + SDK consolidation: EMA leg 2 / scopes (#1527) (#1725) 2026-07-19 22:36:21 -04:00
oauthFlow.ts Guided-auth removal, OAuth smoke testing, and TUI/CLI support (#1531) 2026-06-29 15:35:51 -04:00
oauthNetworkPhase.test.ts OAuth: re-key store to (server, issuer) + SEP-837/2350/2352 auth UX (#1694) 2026-07-16 16:52:53 -04:00
oauthNetworkPhase.ts OAuth: re-key store to (server, issuer) + SEP-837/2350/2352 auth UX (#1694) 2026-07-16 16:52:53 -04:00
oauthUx.test.ts All of the mid-session and step-up auth work 2026-07-02 16:35:31 -07:00
oauthUx.ts fix(auth): explicit re-authorize when the OAuth callback state was lost (#1808) (#1810) 2026-07-27 18:08:31 -04:00
pendingReauth.test.ts All of the mid-session and step-up auth work 2026-07-02 16:35:31 -07:00
pendingReauth.ts refactor(web): sharpen the src/lib vs src/utils rule and move misfiled modules (#1784) 2026-07-25 22:24:30 -04:00
replayableProtocolMethods.test.ts chore(web): address Copilot review on #2127 2026-08-26 18:24:09 -04:00
replayableProtocolMethods.ts chore(web): address Copilot review on #2127 2026-08-26 18:24:09 -04:00
sandbox-csp.test.ts fix(web): state the expected shape when dropping a CSP source (#2064) 2026-08-24 01:02:02 -04:00
sandbox-csp.ts docs(web): describe the accepted subset, not "parses as a source expression" 2026-08-24 01:20:18 -04:00
schemaUtils.test.ts fix: centralize the nullable-union collapse in core and apply it in the TUI 2026-08-15 16:59:37 -04:00
schemaUtils.ts fix: centralize the nullable-union collapse in core and apply it in the TUI 2026-08-15 16:59:37 -04:00
serverSettingsDefaults.test.ts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
serverSettingsDefaults.ts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
stepUp.test.ts chore(web): move App.tsx's module-level block into files (#2127) 2026-08-26 18:07:40 -04:00
stepUp.ts chore(web): collapse App.tsx's six session refs into useSessionRef (#2129) 2026-08-26 20:43:29 -04:00
toolUtils.test.ts fix: address Copilot review round 40 — a required name counts as a field 2026-08-26 15:49:54 -04:00
toolUtils.ts fix: address Copilot review round 3 — conjunctive keywords, unflattenable allOf, branch inference 2026-08-26 02:01:44 -04:00
uriTemplate.test.ts fix: scope the value ceiling to the names a template references 2026-08-17 01:54:37 -04:00
uriTemplate.ts fix: scope the value ceiling to the names a template references 2026-08-17 01:54:37 -04:00