Skip to content

Enable PWA mode for the assistant#150

Open
ericboucher wants to merge 18 commits intosuitenumerique:mainfrom
ericboucher:enable-pwa
Open

Enable PWA mode for the assistant#150
ericboucher wants to merge 18 commits intosuitenumerique:mainfrom
ericboucher:enable-pwa

Conversation

@ericboucher
Copy link

@ericboucher ericboucher commented Nov 7, 2025

Purpose

Enable PWA mode to allow users to add an augmented shortcut of the app, just like the one availble for Tchap.
Let me know if you find this relevant and its worth fixing the CI / coderabbit @qbey @elvoisin

Screenshot 2025-11-07 at 4 03 11 PM Screenshot 2025-11-07 at 4 03 00 PM Screenshot 2025-11-07 at 4 01 59 PM Screenshot 2025-11-07 at 4 01 52 PM

Proposal

  • item 1...
  • item 2...

External contributions

Thank you for your contribution! 🎉

Please ensure the following items are checked before submitting your pull request:

  • I have read and followed the contributing guidelines
  • I have read and agreed to the Code of Conduct
  • I have signed off my commits with git commit --signoff (DCO compliance)
  • I have signed my commits with my SSH or GPG key (git commit -S)
  • My commit messages follow the required format: <gitmoji>(type) title description
  • I have added a changelog entry under ## [Unreleased] section (if noticeable change)
  • I have added corresponding tests for new features or bug fixes (if applicable)

Summary by CodeRabbit

  • New Features

    • PWA support: web app manifest, theme/icons and related metadata, app-shell routing, and offline-first caching for assets, APIs, and fonts.
    • Service worker added and automatically registered on app start, with update prompt and immediate activation flow.
  • Chores

    • Updated Workbox packages for improved build-time service worker integration.
  • Documentation

    • Added PWA assets guidance to the README.

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds PWA support to the conversations frontend: Workbox-based service worker source and registration, InjectManifest wired into Next.js webpack for production client builds, a web app manifest and PWA meta tags, and Workbox dependency updates.

Changes

Cohort / File(s) Summary
Build config & deps
src/frontend/apps/conversations/next.config.js, src/frontend/apps/conversations/package.json
Next.js webpack callback signature expanded to ({ isServer, dev, webpack }); conditionally injects Workbox InjectManifest for production client builds. Workbox packages updated/added in devDependencies (moved to modular workbox packages and bumped to 7.4.0).
PWA manifest & HTML head
src/frontend/apps/conversations/public/manifest.json, src/frontend/apps/conversations/src/pages/_document.tsx
Added web app manifest and inserted PWA meta tags/links (manifest, theme-color, Apple/Microsoft tags, touch icon) into the document head.
Service worker source
src/frontend/apps/conversations/public/sw.src.js
New Workbox-based service worker source: precaching via __WB_MANIFEST, app-shell routing, CacheFirst for static assets/fonts, NetworkFirst for same-origin /api/ responses, expiration limits, and SKIP_WAITING handling.
Registration utility & usage
src/frontend/apps/conversations/src/utils/registerServiceWorker.ts, src/frontend/apps/conversations/src/pages/_app.tsx
Added TypeScript registerServiceWorker utility (registers /sw.js in production, handles updatefound/installed workflow, prompts for refresh, listens for controllerchange) and wired it into _app.tsx via useEffect.
Docs / assets guidance
src/frontend/apps/conversations/README.md, src/frontend/apps/conversations/public/assets/*
Added README PWA-assets guidance and referenced required icon assets used by the manifest.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant App as _app.tsx
    participant RegUtil as registerServiceWorker()
    participant SWReg as ServiceWorkerRegistration
    participant NewSW as Installing Worker
    participant ActiveSW as Active Service Worker
    participant API as /api/

    Browser->>App: page load
    App->>RegUtil: call registerServiceWorker()
    Note right of RegUtil: runs only in browser, production, and if SW supported
    RegUtil->>SWReg: navigator.serviceWorker.register('/sw.js')
    SWReg-->>RegUtil: registration resolved
    RegUtil->>SWReg: schedule registration.update() (hourly)
    SWReg->>NewSW: updatefound -> installing
    NewSW-->>SWReg: state -> installed
    SWReg->>RegUtil: installed detected && controller exists
    RegUtil->>Browser: prompt user to refresh
    alt user accepts
        RegUtil->>NewSW: postMessage {type: 'SKIP_WAITING'}
        NewSW->>ActiveSW: skipWaiting -> activate
        ActiveSW->>Browser: controllerchange
        Browser->>App: reload -> fetch assets, API calls to API
        Browser->>API: request -> API responds (NetworkFirst)
    else user declines
        Note right of Browser: continue using current SW until next activation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • qbey
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enabling Progressive Web App (PWA) mode for the assistant application, which is the primary objective across all modified files.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5bc974 and dbce7a2.

📒 Files selected for processing (7)
  • src/frontend/apps/conversations/next.config.js (1 hunks)
  • src/frontend/apps/conversations/package.json (1 hunks)
  • src/frontend/apps/conversations/public/manifest.json (1 hunks)
  • src/frontend/apps/conversations/public/sw.src.js (1 hunks)
  • src/frontend/apps/conversations/src/pages/_app.tsx (2 hunks)
  • src/frontend/apps/conversations/src/pages/_document.tsx (1 hunks)
  • src/frontend/apps/conversations/src/utils/registerServiceWorker.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/frontend/apps/conversations/src/pages/_app.tsx (1)
src/frontend/apps/conversations/src/utils/registerServiceWorker.ts (1)
  • registerServiceWorker (6-66)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@qbey
Copy link
Member

qbey commented Dec 12, 2025

@ericboucher if you suggest it, we guess there is a need. We think we could merge this when ready, we are only a bit afraid for the support/maintenance it might generate (and the fact the application has no offline mode at all).

For sure, if you want to finish the PR, we will accept it. Don't hesitate to reach out @elvoisin to work with her :) 🥔 🔥

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/frontend/apps/conversations/package.json`:
- Around line 88-93: Update all Workbox package versions from 7.1.0 to 7.4.0 in
package.json by replacing the version strings for the dependencies
"workbox-cacheable-response", "workbox-core", "workbox-expiration",
"workbox-precaching", "workbox-routing", and "workbox-strategies" with "7.4.0",
then run your package manager (npm/yarn/pnpm) to install and update lockfile
accordingly.

@ericboucher
Copy link
Author

Dans une prochaine itération on pourra imaginer autoriser les utilisateurs à accéder aux conversations hors ligne pendant quelques temps, avec une strategy CacheFirst ou StaleWhileRevalidate.

@socket-security
Copy link

socket-security bot commented Feb 16, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@ericboucher
Copy link
Author

Bonsoir @elvoisin dites moi comment je peux vous aider à débloquer cette PR. Je serais bien heureux de pouvoir avoir un petit icon assistant à côté de Tchap dans le dock :)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants