Skip to content

perf(app): reduce box connection latency and background work - #42

Merged
frahlg merged 1 commit into
mainfrom
agent/web-connection-performance
Aug 11, 2026
Merged

perf(app): reduce box connection latency and background work#42
frahlg merged 1 commit into
mainfrom
agent/web-connection-performance

Conversation

@frahlg

@frahlg frahlg commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • send the first telemetry subscription with hello when the box supports it, with a legacy fallback
  • request 1 Hz while visible and 0.2 Hz while hidden
  • drop expected Noise authentication and replay failures from other app sessions without throwing or logging a stack
  • pause hidden History and Energy work, keep shown Energy data, and catch up when visible
  • combine history chunk renders with requestAnimationFrame
  • materialize stored snapshots only when their 15-second write is due
  • skip unchanged Power Now diagram updates
  • add local relay, Noise, handshake, and snapshot marks and counters; no data leaves the device

Measured impact

The paired box PR provides the wire and box-side changes.

  • hidden lane-0 traffic falls by 80%, from 1 Hz to 0.2 Hz
  • at the fixed 512-byte frame plus 24-byte Noise overhead, that avoids about 35.3 MiB per hidden client per day before WebSocket and TLS overhead
  • an updated app and box save one post-Noise round trip before the first snapshot
  • hidden History and Energy views stop requesting or assembling history until visible
  • repeated history chunks cause at most one render per animation frame
  • foreign relay frames no longer create one exception and stack log per frame on each unrelated app session

Compatibility

  • hello.sub and hello_ok.subscribed are optional
  • when the box omits the acknowledgement, the app sends the old separate sub message
  • old apps still work with the updated box
  • the simulator supports both paths
  • visibility changes update cadence on the existing encrypted session

Checks

  • npm run verify
  • Svelte check: 0 errors and 0 warnings
  • Vitest: 853 passed, 1 skipped across 90 files
  • production Vite build
  • two real Noise sessions against one relay/box test
  • protocol contract copies match byte for byte
  • shared UI token check passes with no drift
  • local simulator browser check on desktop and 390 x 844 mobile views; no console errors
  • independent code review found no remaining P0, P1, or P2 issue

Proof limits and follow-ups

  • Chrome DevTools tracing was unavailable in this environment, so this PR makes no Core Web Vitals, phone CPU, or live relay latency claim
  • the relay still broadcasts encrypted box frames to every app stream; this PR removes the client exception and logging cost, not that bandwidth
  • directed relay routing needs a separate wire change that does not expose session identity
  • a LAN or WebRTC carrier needs a separate threat model, discovery design, and measured fallback

Companion box and on-box dashboard PR: srcfl/ftw#894

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
ftw-webapp 4fb9f53 Aug 11 2026, 06:42 AM

@frahlg
frahlg marked this pull request as ready for review August 11, 2026 06:57
@frahlg
frahlg merged commit 80da912 into main Aug 11, 2026
4 of 5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fb9f539d3

ℹ️ 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".

Comment thread src/views/History.svelte
Comment on lines +73 to +75
() =>
active && site.documentVisible
? `${history.range} ${Math.floor(nowMs / 300_000)}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Clear paused history when switching homes

When a user accepts an invitation to a different box while viewing another tab after History has already mounted, App.svelte's onPaired() reuses the existing SiteStore, HistoryStore, and nested EnergyStore. This guard prevents either store from refreshing or invalidating its old data while inactive, so opening History initially displays the previous household's chart and totals; if the new box is unreachable, that cross-home data remains indefinitely. Invalidate the retained History/Energy state when siteId changes even while the panel is inactive.

Useful? React with 👍 / 👎.

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.

1 participant