Skip to content

feat(offline): impl client chat store, service worker, UX #2377

Open
LoneRifle wants to merge 2 commits into
huggingface:mainfrom
LoneRifle:feat/offline-mode
Open

feat(offline): impl client chat store, service worker, UX #2377
LoneRifle wants to merge 2 commits into
huggingface:mainfrom
LoneRifle:feat/offline-mode

Conversation

@LoneRifle

@LoneRifle LoneRifle commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
image

This pull request introduces robust offline support to the chat UI by implementing a new IndexedDB-backed caching layer for conversations and a reliable online/offline detection mechanism. The UI is now aware of connectivity status, disabling actions that require a network connection and providing clear feedback to users. The most significant changes are grouped below.

Offline detection and UI adaptation:

  • Introduced a new isOnline store (useIsOnline) that reliably detects real connectivity by probing a healthcheck endpoint, improving on the limitations of navigator.onLine. UI components now reactively use this store to enable or disable actions depending on online status, and provide tooltips explaining why actions are unavailable when offline.

  • Updated UI elements—including chat input, file uploads, attachments, new chat button, conversation rename/delete, and voice recording—to be disabled when offline, with appropriate visual cues and accessibility titles.

Closes #2344

@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: 4a4e58b0bc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/service-worker.ts Outdated
Comment thread src/routes/conversation/[id]/+page.ts Outdated
Comment thread src/service-worker.ts Outdated
@gary149

gary149 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

that's a lot of changes I'll try to take a look when I've time but can't guarantee it will be soon

@LoneRifle LoneRifle force-pushed the feat/offline-mode branch 5 times, most recently from a9f2aed to ccbf82d Compare June 26, 2026 02:15
@LoneRifle LoneRifle force-pushed the feat/offline-mode branch from ccbf82d to 3b98f22 Compare June 28, 2026 13:38
@LoneRifle LoneRifle force-pushed the feat/offline-mode branch 3 times, most recently from de8d2e3 to 97685d4 Compare June 30, 2026 15:20
cto-new Bot added 2 commits July 1, 2026 18:09
Implements offline-mode support, with service worker, connectivity store, and comprehensive UX guards.

**1. Service Worker (`src/service-worker.ts`)**
- Precaches app shell using SvelteKit's `$service-worker` module
- Runtime caching for attachment blobs (GET `/output/[sha256]` - cache-first)
- Cache-first for assets, Network-first for API calls
- `message` listener for `SKIP_WAITING` support
- Old cache cleanup on activation

**2. Connectivity Store (`src/lib/stores/isOnline.svelte.ts`)**
- Svelte 5 runes store tracking `navigator.onLine`
- Listens to `online`/`offline` events

**3. Frontend Update Handling (`src/routes/+layout.svelte`)**
- New SW waiting detection with "Update Now" notification bar
- Posts `SKIP_WAITING` to activate new version
- Listens for `controllerchange` to reload

**4. Offline UX Enhancements**
- Offline banner in layout
- ChatInput disabled (textarea, uploads, MCP) with tooltips
- Voice recording and send button disabled in ChatWindow
- NavMenu "New Chat" visually disabled
- NavConversationItem Rename/Delete disabled
- UploadedFile triggers fetch for SW caching
@LoneRifle LoneRifle force-pushed the feat/offline-mode branch from 97685d4 to 59b070f Compare July 1, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants