Summary
The web app currently makes three independent GET /api/config fetches on load — useSandboxUrl, useServerListWritable, and useInspectorVersion (added in #1641) each fetch the same static payload and read one field from it. Consolidate them into a single useInitialConfig hook that fetches once and exposes version / sandboxUrl / writable (+ loading).
Background
GET /api/config returns one InitialConfigPayload (core/mcp/remote/node/server.ts) with sandboxUrl, writable, version, and the default-transport fields. Three hooks (core/react/useSandboxUrl.ts, useServerListWritable.ts, useInspectorVersion.ts) each fetch it separately and extract one field. They're intentionally near-identical (each documents that it mirrors the others), so this is an established-pattern cleanup, not a regression — but it's 3 requests for one static payload.
Scope
- Add
core/react/useInitialConfig.ts: fetch GET /api/config once, expose { version, sandboxUrl, writable, loading } with the same tolerant parsing/defaults the three hooks use today (writable defaults true; sandboxUrl/version undefined when absent; unmount-safe).
- Update
App.tsx to use it instead of the three separate hooks.
- Deprecate/remove
useSandboxUrl / useServerListWritable / useInspectorVersion (or reimplement them as thin selectors over the shared hook) once nothing else uses them.
- Keep full test coverage (the fetch-branch matrix the three hooks currently cover).
Acceptance
- One
GET /api/config fetch on load (verify in the network panel / a test).
version / sandboxUrl / writable behave exactly as before, including legacy-backend tolerance.
- Per-file ≥90 coverage maintained.
Follow-up raised in review of #1641.
Summary
The web app currently makes three independent
GET /api/configfetches on load —useSandboxUrl,useServerListWritable, anduseInspectorVersion(added in #1641) each fetch the same static payload and read one field from it. Consolidate them into a singleuseInitialConfighook that fetches once and exposesversion/sandboxUrl/writable(+loading).Background
GET /api/configreturns oneInitialConfigPayload(core/mcp/remote/node/server.ts) withsandboxUrl,writable,version, and the default-transport fields. Three hooks (core/react/useSandboxUrl.ts,useServerListWritable.ts,useInspectorVersion.ts) each fetch it separately and extract one field. They're intentionally near-identical (each documents that it mirrors the others), so this is an established-pattern cleanup, not a regression — but it's 3 requests for one static payload.Scope
core/react/useInitialConfig.ts: fetchGET /api/configonce, expose{ version, sandboxUrl, writable, loading }with the same tolerant parsing/defaults the three hooks use today (writable defaults true; sandboxUrl/version undefined when absent; unmount-safe).App.tsxto use it instead of the three separate hooks.useSandboxUrl/useServerListWritable/useInspectorVersion(or reimplement them as thin selectors over the shared hook) once nothing else uses them.Acceptance
GET /api/configfetch on load (verify in the network panel / a test).version/sandboxUrl/writablebehave exactly as before, including legacy-backend tolerance.Follow-up raised in review of #1641.