Skip to content

Implementation/72687 new connection error restore banner v2#22591

Merged
akabiru merged 6 commits intorefinements/72665-collaboration-improvementsfrom
implementation/72687-new-connection-error-restore-banner-v2
Mar 31, 2026
Merged

Implementation/72687 new connection error restore banner v2#22591
akabiru merged 6 commits intorefinements/72665-collaboration-improvementsfrom
implementation/72687-new-connection-error-restore-banner-v2

Conversation

@ihordubas99
Copy link
Copy Markdown
Collaborator

Ticket

https://community.openproject.org/projects/communicator-stream/work_packages/72687

What are you trying to accomplish?

Replace server-rendered connection error/recovery flash banners with a
lightweight inline status indicator in the document page header.

Previously, when the collaboration WebSocket disconnected or reconnected,
the app made HTTP requests to Rails endpoints (render_connection_error,
render_connection_recovery) to fetch and inject server-rendered HTML
into an errorContainer outside the React tree.

Now the connection state is handled entirely on the frontend — a small
ConnectionStatusComponent in the info line shows "Currently offline"
or "Connection reestablished" by toggling visibility via a Stimulus
controller that listens to custom DOM events dispatched by
OpBlockNoteContainer

Screenshots

image image image

What approach did you choose and why?

Chosen approach: pure frontend state management via custom DOM events + Stimulus

OpBlockNoteContainer dispatches documents:connection-error and
documents:connection-recovery events on window based on the
offlineMode state from useCollaboration. ConnectionStatusController
(Stimulus) listens for these events and toggles style.display on the
appropriate elements.

The "normal" state elements (LiveUsers + LiveSavedAt) are found via
querySelectorAll('[data-normal]') rather than Stimulus targets, because
LiveUsersComponent renders as a <turbo-frame> that gets replaced on
Turbo updates — which would cause Stimulus to lose track of cached targets.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@ihordubas99 ihordubas99 requested a review from akabiru March 30, 2026 14:12
@ihordubas99 ihordubas99 self-assigned this Mar 30, 2026
ihordubas99 and others added 5 commits March 30, 2026 17:27
As this is already a dynamically loaded controller, there is no need to
pre-register it.

Ref: docs/development/concepts/stimulus/README.md
…or connection status

Replace inline style.display manipulation with the semantic hidden HTML
attribute for better accessibility. Consolidate repetitive show/hide
logic into a single activateState method driven by a ConnectionState
type union, and align Stimulus target names (live/offline/recovered)
between controller and template.
…ver-side template

Replace the empty shadow DOM error container with a server-rendered
ConnectionErrorNoticeComponent that is hidden by default and revealed
via a Stimulus controller when the collaboration connection fails.

This approach caches the fully-localized Primer Banner in the DOM at
page load, avoiding the need to fetch templates from the server during
network failures. The header info line continues to show brief
"Currently offline" / "Connection reestablished" status independently.

- Simplify ConnectionErrorNoticeComponent to always show the
  server-unavailable message (all offline is blocking without IDB)
- Add EditorConnectionController to toggle error/editor visibility
- Remove shadow DOM error container and FlashController from
  block-note-element
- Delete unused connection-template-fetcher.ts
- Remove unused translation keys
@akabiru akabiru force-pushed the implementation/72687-new-connection-error-restore-banner-v2 branch from 1961f20 to ac52634 Compare March 30, 2026 16:57
@akabiru akabiru force-pushed the implementation/72687-new-connection-error-restore-banner-v2 branch from ac52634 to 68c140b Compare March 31, 2026 08:57
Copy link
Copy Markdown
Member

@akabiru akabiru left a comment

Choose a reason for hiding this comment

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

:shipit:

@akabiru akabiru merged commit 1e09c24 into refinements/72665-collaboration-improvements Mar 31, 2026
12 checks passed
@akabiru akabiru deleted the implementation/72687-new-connection-error-restore-banner-v2 branch March 31, 2026 13:25
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants