feat(web): extract the viewer SDK from the cockpit - #3565
Conversation
- New web/sdk package (@dimos/sdk): the read-only viewer library. Reconnecting WebTransport, session state, stores, decoders, refcounted subscriptions. - Code moves from web/cockpit/src/session with the wire behavior unchanged. React hooks live on the @dimos/sdk/react subpath, the root entry is React-free. - The cockpit is rebuilt on the SDK. The SDK subscribes to nothing by itself, so the panel subscription policy moves to cockpit/src/subscriptions.ts. - sdk/src/testing/fakeRelay.ts gives SDK unit tests a scripted fake relay. - sdk/fixture/ is a minimal non-cockpit consumer for manual demos. - CI runs the SDK checks and tests. setup.py and MANIFEST.in ship the SDK sources in the sdist.
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Greptile SummaryThis PR extracts Cockpit viewer and session functionality into the SDK and updates Cockpit to consume it. A browser hosted on a different origin from its relay cannot complete relay discovery through Merge safety: address cross-origin discovery before merging for deployments that host the viewer and relay on separate origins. Confidence Score: 4/5The change is not safe for cross-origin viewer-to-relay deployments until relay discovery is made accessible to supported browser origins. A real headless-browser request reproduced the failed discovery request, and the same request succeeded when the relay response included a matching CORS header. Files Needing Attention: web/sdk/src/session.ts initiates the absolute discovery request; web/relay/server.ts needs an explicit
What T-Rex did
|
| transportDeps, | ||
| { | ||
| ...deps, | ||
| fetchInfo: deps.fetchInfo ?? ((signal) => fetchRelayInfo(infoUrl, signal)), |
There was a problem hiding this comment.
Cross-origin relay discovery lacks CORS support
connect({ url }) resolves an absolute relay URL and fetches its /api/info endpoint directly. The relay returns this endpoint without Access-Control-Allow-Origin, so a browser consumer hosted on another origin cannot read the discovery response. The transport treats that rejected fetch as retryable and remains in its reconnect loop instead of establishing WebTransport. Add an explicit CORS policy for supported /api/info consumers, including Vary: Origin when reflecting allowed origins, or route discovery through a same-origin proxy.
Artifacts
Focused cross-origin browser test source
- The executable Node harness serves separate application and relay origins and toggles the relay CORS header, takeaway: it reproduces the browser CORS boundary directly.
Captured focused browser test source
- Captured command output records the exact source of the executed focused test, takeaway: the tested browser flow is fully traceable.
Browser fetch without relay CORS permission
- Headless Chrome requested relay `/api/info` across origins, the relay logged an Origin and no ACAO header, and Fetch rejected with `TypeError: Failed to fetch`, takeaway: the claimed browser failure occurs.
Browser fetch with relay CORS permission
- The identical headless Chrome request fulfilled with HTTP 200 after the relay supplied matching ACAO, takeaway: missing CORS permission is the causal difference.
SDK transport and relay source excerpts
- Captured source excerpts show the absolute SDK fetch, the no-CORS relay response, and the reconnect-on-fetch-failure loop, takeaway: the observed failure maps directly to the reported code locations.
No description provided.