Skip to content

[codex] Fix initial offline websocket UI state#1748

Open
sabraman wants to merge 2 commits intopingdotgg:mainfrom
sabraman:codex/ws-offline-initial-state
Open

[codex] Fix initial offline websocket UI state#1748
sabraman wants to merge 2 commits intopingdotgg:mainfrom
sabraman:codex/ws-offline-initial-state

Conversation

@sabraman
Copy link
Copy Markdown
Contributor

@sabraman sabraman commented Apr 5, 2026

Summary

  • report the websocket UI state as offline whenever the browser starts offline
  • add a regression test for the cold-start offline case

Why

The new websocket connection surface already has dedicated offline UI copy, but the state helper only returned offline after a disconnect had already occurred. On a cold launch with the browser offline, the app could show a misleading connecting state instead of the offline surface.

Impact

Users who open the web client while already offline now see the correct offline state immediately instead of a connecting message.

Validation

  • bun run test src/rpc/wsConnectionState.test.ts
  • bun fmt
  • bun lint
  • bun typecheck

Note

Fix WebSocket blocking UI to show offline state when browser starts offline

  • Replaces buildBlockingCopy with getBlockingStateDescriptor in WebSocketConnectionSurface.tsx, adding a tone and connectionLabel field to the returned descriptor.
  • Adds a specific branch for the connecting UI state when the browser is offline, returning tone: 'offline' and 'Waiting for network' labels instead of the generic connecting state.
  • Updates icon selection and spinner animation to derive from copy.tone rather than uiState directly.
  • Adds test coverage for the offline-at-startup case in both the UI descriptor logic and the underlying wsConnectionState state machine.

Macroscope summarized e24ac5b.


Note

Low Risk
Low risk UI/logic refactor limited to the WebSocket connection surface plus added tests; behavior changes only affect what blocking copy/icon is shown when the browser is offline during initial connect.

Overview
Updates the WebSocket blocking surface to use a new exported getBlockingStateDescriptor that centralizes the UI copy, connection label, and tone used to select icons/spinner.

When uiState is connecting but the browser is offline, the surface now shows a dedicated “Waiting for network” offline message instead of the standard “Opening WebSocket” copy. Adds regression tests for the new descriptor behavior and expands wsConnectionState tests around initial offline vs first failed attempt handling.

Reviewed by Cursor Bugbot for commit e24ac5b. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f77ffc93-c1df-45f9-b688-7491278eec36

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 5, 2026
@sabraman sabraman marked this pull request as ready for review April 5, 2026 00:25
@juliusmarminge
Copy link
Copy Markdown
Member

you don't need to be online to have a connection to the backend though?

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 5, 2026

Approvability

Verdict: Approved

Straightforward bug fix for WebSocket connection UI state when the browser starts offline. Changes are limited to UI presentation logic (text labels and icons), include comprehensive tests, and have no runtime behavior implications beyond the intended fix.

You can customize Macroscope's approvability policy. Learn more.

macroscopeapp[bot]
macroscopeapp bot previously approved these changes Apr 5, 2026
@macroscopeapp macroscopeapp bot dismissed their stale review April 5, 2026 01:01

Dismissing prior approval to re-evaluate e24ac5b

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Apr 5, 2026
@sabraman
Copy link
Copy Markdown
Contributor Author

sabraman commented Apr 5, 2026

you don't need to be online to have a connection to the backend though?

yeah, updated this to keep the existing state semantics and instead make the initial blocking UI network-aware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants