Skip to content

fix(web): add connection status banner to thread view #1270#1369

Open
JaskiratAnand wants to merge 3 commits intopingdotgg:mainfrom
JaskiratAnand:fix/show-no-connection-state
Open

fix(web): add connection status banner to thread view #1270#1369
JaskiratAnand wants to merge 3 commits intopingdotgg:mainfrom
JaskiratAnand:fix/show-no-connection-state

Conversation

@JaskiratAnand
Copy link

@JaskiratAnand JaskiratAnand commented Mar 24, 2026

FIX: #1270

What Changed

Adds a ConnectionStatusBanner component that surfaces offline and disconnected states to the user in the chat interface.

  • ConnectionStatusBanner — new component rendered in the ChatView top header to display offline/disconnected states
  • WsTransport — now tracks and emits transport state changes internally
  • Native API — exposes onTransportStateChange so the UI layer can react to connection changes
  • Tests — unit tests added for ConnectionStatusBanner logic
  • Vitest config — fixes alias resolution for web app packages

Why

Users had no visibility into connection issues during a chat session — the app would silently fail or behave unexpectedly when the WebSocket dropped or the device went offline. This PR wires up transport state through to the UI so users get clear, timely feedback about their connection status, reducing confusion and support load.

The banner approach keeps the signal non-blocking and contextually placed (top of chat), which is a common, well-understood pattern for connectivity feedback.

UI Changes

Screenshot:
no-internet-warning

Video:
https://github.com/user-attachments/assets/78df905c-fd43-4831-834d-909eb4944f28

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Touches the core WebSocket transport state machine and adds new state-listener callbacks, which could affect reconnect/dispose behavior if notifications are incorrect. UI changes are straightforward but depend on accurate transport state transitions.

Overview
Adds a new ConnectionStatusBanner to ChatView to warn users when the browser is offline or when the WebSocket transport is closed/reconnecting.

Plumbs transport connectivity to the UI by exporting TransportState, adding WsTransport.onStateChange() + centralized setState() notifications, and exposing onTransportStateChange() from wsNativeApi (forcing instance creation if needed). Includes unit tests covering banner render behavior across online/offline and transport states.

Written by Cursor Bugbot for commit 3aa07e1. This will update automatically on new commits. Configure here.

Note

Add connection status banner to thread view for offline and WebSocket disconnect states

  • Adds ConnectionStatusBanner, a memoized React component that shows a warning alert when the browser is offline or the WebSocket transport is closed/reconnecting.
  • Subscribes to navigator online/offline events and WebSocket transport state via a new onTransportStateChange function added to wsNativeApi.ts.
  • Extends WsTransport with a listener set and onStateChange method; all state transitions now go through a single setState notifier that invokes registered listeners.
  • Renders the banner in ChatView above the existing ProviderHealthBanner.
  • Behavioral Change: WsTransport now calls registered listeners on every state transition, including immediately upon subscription with the current state.

Macroscope summarized 3aa07e1.

- Implement ConnectionStatusBanner component to show offline/disconnected states
- Update WsTransport to track and emit transport state changes
- Expose onTransportStateChange in native API for UI consumption
- Integrate banner into ChatView top header section
- Add unit tests for ConnectionStatusBanner logic
- Fix vitest alias configuration for web app packages
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 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: f98893df-2429-442b-8c67-a69ce8a52f10

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:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 24, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

window.removeEventListener("offline", handleOffline);
unsub();
};
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

Online state not re-synced inside useEffect

Low Severity

The transport state is properly synchronized inside the useEffect because onTransportStateChange immediately invokes the listener with the current state (line 27–29). However, isOnline is only read once in the useState initializer (line 13–14) and is never re-synced inside the effect. If an offline event fires between the initial render and the effect setup, the event is missed and isOnline remains stale — the banner stays hidden until the next online/offline event. Adding a setIsOnline(navigator.onLine) call inside the effect after registering the event listeners would close this gap, consistent with how transport state is already handled.

Fix in Cursor Fix in Web

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

Labels

size:L 100-499 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.

[Bug]: no clear offline / no-connection state when internet drops

1 participant