Skip to content

fix(xr): live reload survives a dropped connection and refreshes data sources safely - #69

Merged
aMonteSl merged 2 commits into
v1.2.1from
claude/project-thread-kvvyg6-sse
Nov 25, 2026
Merged

aMonteSl merged 2 commits into
v1.2.1from
claude/project-thread-kvvyg6-sse

Conversation

@aMonteSl

Copy link
Copy Markdown
Collaborator

Requested by Adrián · project thread

Summary

Story S2 of the XR review epic: audit findings CHARTS-10 (blocker), CHARTS-11, LIFECYCLE-7 and LIFECYCLE-10 (docs/xr-audit/, PR #67).

  • Reconnect with handlers. After any EventSource error, live_sse_fileXR.js used to close the connection that had the handlers and open a bare new EventSource('/events') with none. From then on the scene ignored every dataRefresh / analysis-updated and kept showing stale metrics until a page reload. Now one connectLiveReload() binds every handler. The browser's own retry (readyState CONNECTING) is left alone, and a source the browser gave up on (CLOSED, e.g. a 404) is reopened with back-off from 1 s doubling to 30 s. Events from a replaced source are ignored. The state is published as the codexr-live-reload-status event; the visible indicator is left for S7.
  • Safe cache busting. It reads both babia-queryjson forms (object, raw declaration), keeps existing query parameters such as a comparison's ?revision=, and skips the row-budgeted chart slices and inline-data sources. Those slices used to be pointed at ?t=…, which fetched the page itself as JSON. A leaked url: prefix is stripped.
  • url: url: ./data.json. refreshNormalDataSources in the analysis-mode runtime read the raw declaration string as the URL before A-Frame initialised the component. Once that corruption happened, no later refresh could repair it. It is now parsed and healed.
  • DOM client. It no longer reloads the page 3 s after every error (that loop never ends while /events answers 404). It reconnects with back-off and reloads once when the connection comes back.
  • CHANGELOG [1.2.1] → Fixed.

Test plan

  • npm test: 1072/1072.
  • New test/analysis/liveReloadClient.test.cjs (fake EventSource and timers): reconnect keeps handlers, browser retry untouched, back-off 1→30 s and reset on open, stale source ignored, cache-bust over six URL shapes, offline export never connects, DOM client has no reload loop and reloads once on recovery.
  • dependencyGraph.test.cjs: normal refresh from the raw declaration and from an already-corrupted URL.
  • The four Playwright harnesses are green.
  • Headless Chromium with a scene from the real generator: after the server drops the SSE client, a 12-row re-analysis reaches the chart and the slice URL stays empty. Before this change the chart stayed on 20 rows and the slice was set to ?t=….
  • Maintainer: open an XR analysis, stop and restart the network (or toggle Wi-Fi on the headset), edit the file and check that the scene updates.

Generated by Claude Code

… sources safely

- live_sse_fileXR.js: one connectLiveReload() binds every handler; the old
  reconnect opened a bare EventSource with no handlers, so after one network
  error the scene stopped following re-analyses (audit CHARTS-10 /
  LIFECYCLE-10). The browser's own retry is left alone; a source it gave up
  on is reopened with back-off (1 s doubling to 30 s). Connection state is
  published as codexr-live-reload-status.
- Cache busting reads both babia-queryjson forms, keeps existing query
  parameters (?revision=), skips chart slices and inline-data sources (they
  were pointed at '?t=…', i.e. the page itself), and strips a leaked 'url:'
  prefix (CHARTS-11).
- analysisModeRuntime refreshNormalDataSources reads the raw declaration
  form, which used to turn the url into 'url: url: ./data.json' (LIFECYCLE-7).
- live_sse_fileDOM.js: no reload loop on errors; reconnect with back-off and
  reload once when the connection is back.

Tests: liveReloadClient.test.cjs (fake EventSource: reconnect, back-off,
stale-source, cache-bust shapes, offline export, DOM client) and a
raw-declaration refresh test. Headless check with a generated scene: after
the server drops the SSE client, a 12-row re-analysis now reaches the chart
(before: it stayed on the previous 20 rows).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FkKtAtQus8TVjhG9bhytC
@aMonteSl aMonteSl self-assigned this Nov 25, 2026
…nto claude/project-thread-kvvyg6-sse

# Conflicts:
#	apps/vscode-extension/CHANGELOG.md
@aMonteSl
aMonteSl merged commit 69e26f3 into v1.2.1 Nov 25, 2026
7 checks passed
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.

2 participants