Compare commits

...
Author SHA1 Message Date
Lotus CIandClaude Opus 5.5 70206d6033 chore(deps): matrix-js-sdk 41.7 -> 44.0 (#201)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m24s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 16m50s
Picks up three releases of MatrixRTC / delayed-event fixes and
matrix-sdk-crypto-wasm 18.3.1 -> 18.9.0.

SDK 43 moved OAuth (MSC3861) into the SDK and dropped oidc-client-ts, so
the native-OAuth sign-in is ported:
- login discovers the auth server via /auth_metadata, registers with
  OAuth2.registerClient, and keeps the PKCE verifier + device in its own
  sessionStorage entry keyed by `state` (single use; CSRF check);
- refresh is done by the SDK (oauthClientId + onTokenRefresh); the #16
  cross-tab protection is kept by a narrow guard on refresh-token grants
  (the SDK calls the global fetch for OAuth, not fetchFn), which
  serialises them with a Web Lock and adopts a sibling tab's tokens;
- logout and forced logout revoke via mx.logout() (the SDK revokes at
  the auth server for OAuth sessions);
- the callback page parsed its params on every render, re-running the
  single-use code exchange in a loop; parsed once now.

Also: notification_type is deprecated in MSC4075 (ring in DMs, notify
elsewhere when omitted), _onRTCSessionMemberUpdate ->
ensureRecalculateSessionMembers, precache limit 6 -> 10 MB for the
7.8 MB crypto wasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-24 00:32:13 -04:00
jared bfed37bf50 Merge pull request 'feat(e2ee): tell the user when their device's key uploads are stuck (#201 KE-1)' (#446) from feat/key-upload-recovery into lotus
CI / Build & Quality Checks (push) Successful in 3m33s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 8s
CI / Trigger Desktop Build (push) Successful in 6s
CI / Playwright smoke (e2e) (push) Successful in 16m32s
2026-10-24 00:11:28 -04:00
Lotus CIandClaude Opus 5.5 c2c43eda99 feat(e2ee): tell the user when their device's key uploads are stuck (#201 KE-1)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m41s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 8s
CI / Playwright smoke (e2e) (pull_request) Successful in 15m54s
When the server keeps rejecting this device's /keys/upload with 400 "One
time key ... already exists", the device's encryption store has diverged
and the SDK retries forever (matrix-rust-sdk#5200, still open). Synapse
saw 474k of these from May 30 to Jul 8 2026. The fix is a fresh login, so:

- keyUploadWatch observes /keys/upload responses through the client's
  fetchFn (the response the SDK gets is untouched; a clone is read).
  Three conflicts within 15 min = stuck; any successful upload clears it.
- KeyUploadBanner (critical strip, same slot as the sync/clock banners):
  "Encryption on this device is out of sync" with Details and
  "Fix: sign out…", which opens the normal logout dialog (it already
  warns when the device isn't verified / backed up).

Server side, Grafana now alerts on the same signal (E2EE Key Upload
Conflicts) and on delayed-event 5xx (Call Delayed-Event Errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-23 23:51:15 -04:00
jared 45c3b16694 Merge pull request 'feat(desktop): keep the login tokens only in the OS keychain (#105 step 2)' (#445) from feat/keychain-session into lotus
CI / Build & Quality Checks (push) Successful in 3m13s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 8s
CI / Trigger Desktop Build (push) Successful in 2s
CI / Playwright smoke (e2e) (push) Successful in 16m28s
2026-10-23 20:59:25 -04:00
Lotus CIandClaude Opus 5.5 5f3c5d370a feat(desktop): keep the login tokens only in the OS keychain (#105 step 2)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m50s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 12s
CI / Playwright smoke (e2e) (pull_request) Successful in 20m30s
On the desktop app with a working keychain (Windows Credential Manager),
the tokens leave localStorage: it keeps a token-less shell blob
(tokensIn: keychain) and the full session lives in memory, read from the
keychain at boot before anything reads the session, so getFallbackSession
stays synchronous. Web, Linux and older desktop builds are unchanged.

- A new session (login, token refresh) is written to localStorage in full
  first; the mirror verifies the keychain copy and only then strips the
  tokens, so one durable store always holds the newest tokens.
- Existing installs migrate on first boot the same way; a failing keychain
  write keeps the tokens in localStorage.
- If a shell is there but the keychain entry is missing or unreadable, the
  app shows Retry / Sign in again instead of logging out, and the mirror
  is not started (it would clear the entry).

Fixes #105

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-23 20:02:35 -04:00
jared 4120ccdbcc Merge pull request 'feat(embeds): Vimeo live events play inline (#200)' (#444) from feat/vimeo-events into lotus
CI / Build & Quality Checks (push) Successful in 4m7s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 13s
CI / Trigger Desktop Build (push) Successful in 16s
CI / Playwright smoke (e2e) (push) Successful in 21m22s
2026-10-21 00:14:21 -04:00
Lotus CIandClaude Opus 5.5 ed5bf997b4 feat(embeds): Vimeo live events play inline (#200)
CI / Build & Quality Checks (pull_request) Successful in 4m38s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 17s
CI / Playwright smoke (e2e) (pull_request) Successful in 24m27s
vimeo.com/event/{id} (and /event/{id}/{hash} for unlisted events) now get
the same click-to-play card as Vimeo videos, embedding Vimeo's live-event
player (vimeo.com/event/{id}/embed[/{hash}], dnt=1). The issue assumed
this needed vimeo.com in the CSP, but frame-src is already https: on web
and desktop.

Refs #200

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 23:31:13 -04:00
jared 878a34712a Merge pull request 'feat(widgets): keep a widget on screen while you navigate away (#205)' (#443) from feat/widget-always-on-screen into lotus
CI / Build & Quality Checks (push) Successful in 3m39s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 42s
CI / Trigger Desktop Build (push) Successful in 18s
CI / Playwright smoke (e2e) (push) Successful in 19m38s
2026-10-20 22:21:48 -04:00
jared 62672787a0 Merge pull request 'feat(call): Details card after a call, with who/why/numbers/activity (#253)' (#442) from feat/call-summary-details into lotus
CI / Build & Quality Checks (push) Canceled after 18s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-20 21:37:26 -04:00
Lotus CIandClaude Opus 5.5 0746e80941 feat(widgets): keep a widget on screen while you navigate away (#205)
CI / Build & Quality Checks (pull_request) Successful in 3m36s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 18s
CI / Playwright smoke (e2e) (pull_request) Successful in 16m40s
MSC2931: a widget with m.always_on_screen (auto-granted) can send
set_always_on_screen; the host now answers it, and a widget that asked
keeps running in a small floating window (title, Back to room, close)
when the Widgets panel closes or you switch rooms. Back to room returns
to it with the panel open on that widget, without reloading it.

Moving an iframe reloads it, so widget frames now live in an app-level
layer from the start (widgetSessions.ts) and are positioned over the
panel's placeholder while docked. A widget that did not ask is torn
down as before. One floating widget at a time; it also goes when the
widget withdraws, is removed from the room, or on logout. A permission
request while floating grants nothing extra.

Refs #205

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 21:05:31 -04:00
jared 6300e4170e Merge pull request 'feat(widgets): open a widget in its own window (#205)' (#441) from feat/widget-popout into lotus
CI / Build & Quality Checks (push) Successful in 4m5s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 14s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-20 21:05:12 -04:00
jared 7250322977 Merge pull request 'fix(touch): harden long-press for iOS (#199)' (#440) from fix/ios-long-press into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-20 20:47:19 -04:00
Lotus CIandClaude Opus 5.5 ac1a1c9a48 chore(deps): pin @lotusguild/element-call-embedded 0.25.0-lotus.29 (#253)
CI / Build & Quality Checks (pull_request) Successful in 3m22s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 20m13s
lotus.29 adds the call summary `details` (element-call#60).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 20:33:13 -04:00
Lotus CIandClaude Opus 5.5 8645a55769 feat(call): Details card for the call-ended toast (#253)
The call-ended toast gets a Details button (and stays 10 s) that opens a
card with who was in the call and the peak, connection verdict and
reconnects, how long your / each person's / everyone's connection was
poor (likely the server when everyone), RTT, packet loss and jitter, and
your talk, mute, deafen and screenshare time, in technical wording.
Deafened time is tracked by CallEmbed; the rest comes from the fork's new
io.lotus.call_summary `details` (lotus.29). Settings → Calls gets
"Summary After Calls" (on by default).

Fixes #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 20:33:07 -04:00
Lotus CIandClaude Opus 5.5 c3f897b6d1 feat(widgets): open a widget in its own window (#205)
CI / Build & Quality Checks (pull_request) Successful in 3m34s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 7s
CI / Playwright smoke (e2e) (pull_request) Successful in 17m37s
Each widget in the Widgets panel (and the open widget's header) gets an
"Open in a new window" button, so a pad or board can sit beside the chat.
It opens the same filled-in URL the frame uses (widgetCompleteUrl, now
shared) with noopener,noreferrer, standalone as in Element. Only
cross-origin https URLs get the button: room state can carry anything,
e.g. a script URL from another client.

Refs #205

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 20:17:52 -04:00
jared 8784a8158c Merge pull request 'chore(types): fewer any casts; eslint ratchet 36 → 29 (#210)' (#439) from chore/any-cleanup into lotus
CI / Build & Quality Checks (push) Successful in 3m13s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 8s
CI / Playwright smoke (e2e) (push) Canceled after 14s
2026-10-20 20:17:01 -04:00
Lotus CIandClaude Opus 5.5 f920fd82fb fix(touch): harden long-press for iOS (#199)
CI / Build & Quality Checks (pull_request) Successful in 2m57s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 8s
CI / Playwright smoke (e2e) (pull_request) Successful in 18m1s
Long-press opens the message action sheet (#166), but on iOS the system
takes a long-press for itself: the link/image callout or the text-selection
loupe races the 450 ms press. Message rows on touch screens now carry
data-touch-actions (no -webkit-touch-callout), and the pressed row carries
data-pressing from touch-down until the finger lifts, which turns text
selection off for that moment only. Copy Text stays in the sheet.

Refs #199

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 20:13:04 -04:00
Lotus CIandClaude Opus 5.5 42040b6412 chore(types): fewer any casts; eslint warning ratchet 36 -> 29 (#210)
CI / Build & Quality Checks (pull_request) Successful in 3m23s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 17s
CI / Playwright smoke (e2e) (pull_request) Successful in 18m6s
- Developer tools (send event, state event editor, room account data) and
  setMarkedUnread go through the typed helpers in utils/room and
  utils/accountData (new setRoomAccountData) instead of casting at the
  call site; sendStateEvent accepts a developer-chosen type string.
- SecretStorage passes the key description as the SDK's
  SecretStorageKeyDescription, CallEmbed replies with an IWidgetApiRequest,
  and fillMissingPowers writes through a Record instead of `as any`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 19:49:15 -04:00
jared ccbafdb147 Merge pull request 'chore(deps): element-call lotus.28, soundboard in voice channels with a call policy (EC #47)' (#438) from chore/soundboard-mic-mix into lotus
CI / Build & Quality Checks (push) Successful in 4m12s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 4s
CI / Playwright smoke (e2e) (push) Successful in 24m18s
CI / Build & Quality Checks (pull_request) Canceled after 0s
CI / Trigger Desktop Build (pull_request) Canceled after 0s
CI / Secret scan (gitleaks) (pull_request) Canceled after 0s
CI / Docker image build & smoke test (pull_request) Canceled after 0s
CI / Playwright smoke (e2e) (pull_request) Canceled after 0s
2026-10-20 00:04:51 -04:00
Lotus CIandClaude Opus 5.5 60c0b9ad30 chore(deps): pin @lotusguild/element-call-embedded 0.25.0-lotus.28 (element-call#47)
CI / Build & Quality Checks (pull_request) Successful in 1m47s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 10s
CI / Playwright smoke (e2e) (pull_request) Successful in 19m10s
lotus.28 plays soundboard clips in voice channels with a call policy by
mixing them into the published microphone (element-call#59), instead of
answering not_permitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 23:43:25 -04:00
jared 1873285371 Merge pull request 'fix(call): one-row phone call bar with self-view; screenshare-audio mute only when useful (#265, #277)' (#437) from fix/phone-call-controls into lotus
CI / Build & Quality Checks (push) Successful in 1m43s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 7s
CI / Trigger Desktop Build (push) Successful in 6s
CI / Playwright smoke (e2e) (push) Successful in 14m46s
2026-10-19 18:11:32 -04:00
Lotus CIandClaude Opus 5.5 78dcf9ee9d chore(deps): pin @lotusguild/element-call-embedded 0.25.0-lotus.27 (#265, #277)
CI / Build & Quality Checks (pull_request) Successful in 2m2s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 7s
CI / Playwright smoke (e2e) (pull_request) Successful in 16m19s
lotus.27 reports remote screenshare audio (element-call#57) and keeps
your own tile on phones with the camera off (element-call#58).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 17:24:42 -04:00
Lotus CIandClaude Opus 5.5 3418a8865d fix(call): one-row call bar on phones; screenshare-audio mute only when useful (#265, #277)
#265: in the compact layout (phones, narrow windows) the control bar
stacked into four rows (~330px, 40% of a portrait phone). It is now one
row: mic, deafen, camera, chat, soundboard, More and an icon-only End.
Screenshare, its audio mute and fullscreen move into More; Share Screen
is only offered where getDisplayMedia exists. (The self-view comes from
the fork, lotus.27.)

#277: "Mute Screenshare Audio" showed whenever screensharing was allowed,
as a speaker icon that did nothing. It now shows while the fork reports
remote screenshare audio (io.lotus.screenshare_audio_state), or while it
is muted, so a hidden mute cannot silence the next share.

Fixes #265
Fixes #277

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 17:24:38 -04:00
jared 5d2d7ca63c Merge pull request 'fix(a11y): dialog names, aria-pressed, labels, avatar alt, placeholder contrast (#278)' (#436) from fix/a11y-axe-findings into lotus
CI / Build & Quality Checks (push) Successful in 2m29s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 10s
CI / Trigger Desktop Build (push) Successful in 10s
CI / Playwright smoke (e2e) (push) Successful in 16m49s
2026-10-19 17:06:37 -04:00
jared 1a0e581f21 Merge pull request 'fix(copy): soundboard wording, deafen hint, pin typo; keep Reddit context= (#279, #280)' (#435) from fix/copy-and-reddit-context into lotus
CI / Build & Quality Checks (push) Canceled after 12s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 16:54:30 -04:00
jared 2fff7a5388 Merge pull request 'feat(about): show the desktop version and the web build's commit and date (#276)' (#434) from feat/about-build-info into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 16:42:07 -04:00
jared 8ea03ab9b6 Merge pull request 'fix(schedule): limit to 24 hours ahead with a clear message (#275)' (#433) from fix/schedule-24h into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 16:28:34 -04:00
jared a1223ba5cf Merge pull request 'fix(sync): "Connecting…" only while catching up, not for 30 s after load (#274)' (#432) from fix/connecting-strip into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 16:15:39 -04:00
jared 400545c79a Merge pull request 'fix(ui): receipt pill, insights counts, settings dividers, decoration preview (#269-#273)' (#431) from fix/ui-polish-batch into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 15:59:47 -04:00
Lotus CIandClaude Opus 5.5 885ec7c82e fix(a11y): axe findings: dialog names, aria-pressed, labels, avatar alt, placeholder contrast (#278)
CI / Build & Quality Checks (pull_request) Successful in 1m47s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 7s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m18s
- Modal500 takes a label: Room/Space Settings ("<name> settings") and
  Settings dialogs have accessible names.
- aria-selected on plain buttons (inbox filter chips, date/time picker
  chips, verification/usage/notification menu items) -> aria-pressed; the
  Permissions power chips open a menu -> aria-haspopup + aria-expanded.
- Labels tied to the room pack name input and the Export From/To dates.
- UserAvatar defaults to alt="" (decorative next to a name / in a
  labelled button) unless a caller passes one.
- Composer placeholder: Slate's inline opacity 0.333 overrode the #222
  AA-contrast class (2.66:1); it is dropped so the class (0.75) applies.
- e2e/a11y.spec.ts also audits Room Settings → Permissions, Emojis &
  Stickers and Export, checks the dialog name, and audits the inbox.

Fixes #278

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 15:35:59 -04:00
jared 997df415dd Merge pull request 'fix(outbox): two tabs no longer overwrite each other's queue (#268)' (#430) from fix/outbox-multi-tab into lotus
CI / Build & Quality Checks (push) Successful in 1m57s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 7s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 15:31:01 -04:00
Lotus CIandClaude Opus 5.5 8bfb8737d6 fix(copy): soundboard room/space wording, deafen Escape hint, pin typo; keep Reddit context= (#279, #280)
CI / Build & Quality Checks (pull_request) Successful in 1m50s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m29s
#279: Room Settings → Soundboard said clips are "inherited by every room
under this space" for plain rooms too; the wording now follows
room.isSpaceRoom(). The Push to Deafen description only mentions Escape
while rebinding. "can pin a messages" → "can pin a message".

#280: the tracking stripper removed Reddit's context=, which is what
makes a comment permalink show its parent comments. Only share_id and
rdt are stripped now.

Fixes #279
Fixes #280

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 15:26:21 -04:00
Lotus CIandClaude Opus 5.5 72277399f0 feat(about): show the desktop version and the web build's commit and date (#276)
CI / Build & Quality Checks (pull_request) Successful in 1m46s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m27s
Settings → About only showed cinny's package version, the same on web
and desktop and unchanged across many deploys a day. vite.config.js now
stamps the short commit (git, or LOTUS_BUILD_COMMIT; "unknown" without
git) and build time into the bundle, and About shows "Web build <commit>
· built <date>", linking the commit. On desktop it also shows "Desktop
<version>" from Tauri's built-in plugin:app|version (allowed by
core:default).

Fixes #276

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 15:24:37 -04:00
Lotus CIandClaude Opus 5.5 d223f847c6 fix(schedule): limit to 24 hours ahead with a clear message (#275)
CI / Build & Quality Checks (pull_request) Successful in 1m43s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 7s
CI / Playwright smoke (e2e) (pull_request) Successful in 13m4s
Production Synapse caps delayed events at 24h, but the dialog let any
later time be picked and then showed the raw server error. The date
input now has min/max (today .. now+24h), a too-late time shows "You can
schedule up to 24 hours ahead." as soon as it is picked (and blocks
Schedule), and ORG.MATRIX.MSC4140_DELAY_TOO_LARGE maps to the same text.

Fixes #275

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 15:20:08 -04:00
jared 7ad2a94e2e Merge pull request 'fix(security): widget consents and shared files cleared on logout; forged shares refused (#266, #267)' (#429) from fix/widget-share-hardening into lotus
CI / Build & Quality Checks (push) Canceled after 0s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Secret scan (gitleaks) (push) Canceled after 0s
CI / Docker image build & smoke test (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 15:18:57 -04:00
Lotus CIandClaude Opus 5.5 c6aac574ee fix(sync): "Connecting…" only while catching up, not for 30 s after load (#274)
CI / Build & Quality Checks (pull_request) Successful in 1m55s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 13s
CI / Playwright smoke (e2e) (pull_request) Successful in 13m48s
The strip showed for PREPARED and for the first SYNCING after it (or after
RECONNECTING), i.e. until the next /sync returned: ~30 s of long-poll on a
quiet account while the app already worked. A SYNCING means a sync just
succeeded, so the strip now shows only during CATCHUP; failures still show
as Reconnecting / Connection lost.

Fixes #274

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 15:14:38 -04:00
jared e1168f47bb Merge pull request 'fix(room): one width for every right-hand panel (#263)' (#428) from fix/side-panel-width into lotus
CI / Build & Quality Checks (push) Successful in 1m48s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 6s
CI / Trigger Desktop Build (push) Canceled after 0s
CI / Playwright smoke (e2e) (push) Canceled after 0s
2026-10-19 14:54:18 -04:00
Lotus CIandClaude Opus 5.5 97d2d195c3 fix(outbox): two tabs no longer overwrite each other's queue (#268)
CI / Build & Quality Checks (pull_request) Successful in 1m40s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 6s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m4s
OutboxFeature loaded lotus_outbox_v1 once and then saved its own
in-memory list over the key on every change, so a second tab's save
dropped the first tab's unsent messages. persist() now re-reads the
stored list and applies the change (add/remove by txnId) to it.

Fixes #268

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 14:49:40 -04:00
Lotus CIandClaude Opus 5.5 14f05a3d5c fix(security): widget consents and shared files cleared on logout; forged shares refused (#266, #267)
CI / Build & Quality Checks (pull_request) Successful in 1m53s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 7s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m51s
#266: remembered widget approvals (lotus.widgetConsent.*) survived logout,
so they applied silently to the next account on the device and listed the
previous account's rooms; clearPlaintextCaches now sweeps them. Space
structure, call membership and Lotus room-policy state join
PROTECTED_STATE_TYPES, so no widget can be granted them.

#267: any website could auto-submit a form to /share-target and land the
user in the share picker with attacker-chosen text and files. The worker
now refuses a share whose Origin is another site. (Sec-Fetch-Site, as the
issue suggested, never reaches a service worker: checked in Chromium.)
Origin null/absent, as the OS share sheet sends, stays accepted, and
/share now says the content came from another app or website. Both logout
paths await clearSharedPayload(); the server-forced one also clears the
soundboard clip cache, as #57 intended.

Fixes #266
Fixes #267

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 14:47:11 -04:00
Lotus CIandClaude Opus 5.5 ed494d2ae5 fix(room): one width for every right-hand panel (#263)
CI / Build & Quality Checks (pull_request) Successful in 1m43s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 8s
CI / Playwright smoke (e2e) (pull_request) Successful in 13m12s
Members and bookmarks were 266px, the gallery 320, the threads list 340,
a thread and widgets 360. Swapping panels resized the room view, so the
header icons slid sideways (74px for members -> threads) and a second
click on the same spot opened Widgets instead of closing the panel. All
six now use SIDE_PANEL_WIDTH (340px, styles/sidePanel.ts).

Fixes #263

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-19 14:14:26 -04:00
104 changed files with 3350 additions and 710 deletions
+19 -1
View File
@@ -118,8 +118,26 @@ test.describe('accessibility', () => {
test('room settings', async ({ page }) => {
await page.getByRole('button', { name: 'More Options' }).first().click();
await page.getByText('Room Settings', { exact: true }).click();
await expect(page.getByRole('dialog').first()).toBeVisible();
// [Gitea #278] The dialog has an accessible name.
await expect(page.getByRole('dialog', { name: 'A11y Room settings' })).toBeVisible();
await auditPage(page, 'room settings');
// [Gitea #278] aria-selected on the power chips, unlabelled pack name and
// export date inputs were only on these pages.
// One page at a time, in order.
for (const name of ['Permissions', 'Emojis & Stickers', 'Export']) {
// eslint-disable-next-line no-await-in-loop
await page.getByRole('dialog').getByText(name, { exact: true }).first().click();
// eslint-disable-next-line no-await-in-loop
await page.waitForTimeout(1000);
// eslint-disable-next-line no-await-in-loop
await auditPage(page, `room settings: ${name}`);
}
});
test('inbox invites', async ({ page }) => {
await page.goto('/inbox/invites/');
await expect(page.getByRole('button', { name: /Known|Unknown|Spam/ }).first()).toBeVisible();
await auditPage(page, 'inbox invites');
});
});
});
+49
View File
@@ -0,0 +1,49 @@
import { test, expect } from '@playwright/test';
import { ensureUser, hsReachable, loginUI, uniq } from './localHs';
// [Gitea #201 KE-1] When the server keeps rejecting this device's key uploads
// with "One time key … already exists", the app says so and offers the fix.
const CONFLICT = {
errcode: 'M_UNKNOWN',
error: 'One time key signed_curve25519:AAAAAAAAAA0 already exists. Old key: {}; new key: {}',
};
test.describe('key upload recovery (#201)', () => {
test.beforeAll(async () => {
test.skip(!(await hsReachable()), 'local homeserver not running');
});
test('a diverged device sees the banner, and Fix opens the logout dialog', async ({ page }) => {
test.setTimeout(240_000);
const user = await ensureUser(uniq('kup'));
let rejected = 0;
await page.route(/\/_matrix\/client\/v3\/keys\/upload/, async (route) => {
rejected += 1;
await route.fulfill({ status: 400, json: CONFLICT });
});
await loginUI(page, user);
const banner = page
.getByRole('alert')
.filter({ hasText: /Encryption on this device is out of sync/ });
await expect(banner).toBeVisible({ timeout: 200_000 });
console.log(`key uploads rejected: ${rejected}`);
expect(rejected).toBeGreaterThanOrEqual(3);
await banner.getByRole('button', { name: 'Details' }).click();
await expect(banner).toContainText('Settings → Devices');
await expect(banner).toContainText('already exists');
await banner.getByRole('button', { name: /Fix: sign out/ }).click();
await expect(page.getByRole('dialog').getByText('Logout').first()).toBeVisible();
});
test('a healthy device never sees it', async ({ page }) => {
test.setTimeout(120_000);
const user = await ensureUser(uniq('kok'));
await loginUI(page, user);
await page.getByText('Connecting...').first().waitFor({ state: 'detached', timeout: 90_000 });
await page.waitForTimeout(5000);
await expect(page.getByText(/Encryption on this device is out of sync/)).toHaveCount(0);
});
});
+234
View File
@@ -0,0 +1,234 @@
import { createHash } from 'node:crypto';
import { test, expect, Page, Route, BrowserContext } from '@playwright/test';
import { HS, PASSWORD, api, enc, ensureUser, hsReachable, uniq } from './localHs';
// Native OAuth sign-in on matrix-js-sdk 44 (Gitea #201 SDK upgrade): login,
// refresh on an expired token, the #16 two-tab refresh race, and logout
// revocation. The homeserver is the real local Synapse; the auth server is
// faked here and hands out REAL Synapse tokens for the device the client asked
// for, so sync works after every step. "Expiry" is simulated by answering
// M_UNKNOWN_TOKEN for a token we mark expired.
const AUTH = 'https://auth.fake.test';
type Fake = {
registered: number;
tokenCalls: { grant: string; refresh?: string }[];
revoked: string[];
expired: Set<string>;
issuedAccess: string[];
};
const b64url = (buf: Buffer) =>
buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
async function synapseToken(localpart: string, deviceId: string): Promise<string> {
const res = await api<{ access_token: string }>('POST', '/_matrix/client/v3/login', undefined, {
type: 'm.login.password',
identifier: { type: 'm.id.user', user: localpart },
password: PASSWORD,
device_id: deviceId,
});
return res.access_token;
}
async function fakeOAuth(context: BrowserContext, localpart: string): Promise<Fake> {
const fake: Fake = {
registered: 0,
tokenCalls: [],
revoked: [],
expired: new Set(),
issuedAccess: [],
};
const codes = new Map<string, { challenge: string; deviceId: string }>();
const refreshes = new Map<string, string>(); // live refresh token -> deviceId (rotating)
let n = 0;
const cors = { 'access-control-allow-origin': '*', 'access-control-allow-headers': '*' };
const issue = async (deviceId: string) => {
n += 1;
const access = await synapseToken(localpart, deviceId);
const refresh = `r${n}`;
refreshes.set(refresh, deviceId);
fake.issuedAccess.push(access);
return { token_type: 'Bearer', access_token: access, refresh_token: refresh, expires_in: 300 };
};
// Homeserver: advertise the issuer, serve auth metadata, and "expire" tokens.
await context.route(`${HS}/.well-known/matrix/client`, (route) =>
route.fulfill({
headers: cors,
json: { 'm.homeserver': { base_url: HS }, 'm.authentication': { issuer: `${AUTH}/` } },
}),
);
await context.route(`${HS}/_matrix/client/v1/auth_metadata`, (route) =>
route.fulfill({
headers: cors,
json: {
issuer: `${AUTH}/`,
authorization_endpoint: `${AUTH}/authorize`,
token_endpoint: `${AUTH}/token`,
registration_endpoint: `${AUTH}/register`,
revocation_endpoint: `${AUTH}/revoke`,
response_types_supported: ['code'],
response_modes_supported: ['query', 'fragment'],
grant_types_supported: ['authorization_code', 'refresh_token'],
code_challenge_methods_supported: ['S256'],
},
}),
);
await context.route(`${HS}/_matrix/**`, async (route: Route) => {
const auth = route.request().headers().authorization ?? '';
const token = auth.replace(/^Bearer /, '');
if (token && fake.expired.has(token)) {
await route.fulfill({
status: 401,
headers: cors,
json: { errcode: 'M_UNKNOWN_TOKEN', error: 'Token expired', soft_logout: true },
});
return;
}
await route.fallback();
});
// Auth server.
await context.route(`${AUTH}/**`, async (route: Route) => {
const req = route.request();
const url = new URL(req.url());
if (req.method() === 'OPTIONS') {
await route.fulfill({ status: 204, headers: cors });
return;
}
if (url.pathname === '/register') {
fake.registered += 1;
await route.fulfill({ headers: cors, json: { client_id: 'fake-client' } });
return;
}
if (url.pathname === '/authorize') {
const deviceId = /urn:matrix:client:device:(\S+)/.exec(
url.searchParams.get('scope') ?? '',
)?.[1];
expect(url.searchParams.get('response_mode')).toBe('query');
expect(url.searchParams.get('code_challenge_method')).toBe('S256');
const code = `code-${Date.now()}`;
codes.set(code, { challenge: url.searchParams.get('code_challenge')!, deviceId: deviceId! });
const back = new URL(url.searchParams.get('redirect_uri')!);
back.searchParams.set('code', code);
back.searchParams.set('state', url.searchParams.get('state')!);
await route.fulfill({ status: 302, headers: { location: back.href } });
return;
}
const form = new URLSearchParams(req.postData() ?? '');
if (url.pathname === '/token') {
const grant = form.get('grant_type') ?? '';
fake.tokenCalls.push({ grant, refresh: form.get('refresh_token') ?? undefined });
if (grant === 'authorization_code') {
const pending = codes.get(form.get('code') ?? '');
const verifier = form.get('code_verifier') ?? '';
if (
!pending ||
b64url(createHash('sha256').update(verifier).digest()) !== pending.challenge
) {
await route.fulfill({ status: 400, headers: cors, json: { error: 'invalid_grant' } });
return;
}
codes.delete(form.get('code')!);
await route.fulfill({ headers: cors, json: await issue(pending.deviceId) });
return;
}
if (grant === 'refresh_token') {
const deviceId = refreshes.get(form.get('refresh_token') ?? '');
if (!deviceId) {
// rotating refresh tokens: a used one is dead
await route.fulfill({ status: 400, headers: cors, json: { error: 'invalid_grant' } });
return;
}
refreshes.delete(form.get('refresh_token')!);
await route.fulfill({ headers: cors, json: await issue(deviceId) });
return;
}
}
if (url.pathname === '/revoke') {
fake.revoked.push(form.get('token') ?? '');
await route.fulfill({ status: 200, headers: cors, body: '' });
return;
}
await route.fulfill({ status: 404, headers: cors, body: '' });
});
return fake;
}
const storedSession = (page: Page) =>
page.evaluate(() => JSON.parse(localStorage.getItem('cinny_session_v1') ?? 'null'));
async function oauthLogin(page: Page) {
await page.goto(`/login/${enc(HS)}/`);
await page.getByRole('button', { name: /Continue with/ }).click();
await page.waitForURL(/\/home/, { timeout: 60_000 });
await page.getByText('Connecting...').first().waitFor({ state: 'detached', timeout: 90_000 });
}
test.describe('OAuth sign-in on SDK 44', () => {
test.beforeAll(async () => {
test.skip(!(await hsReachable()), 'local homeserver not running');
});
test('login, refresh on expiry, two-tab race, logout revokes', async ({ context }) => {
test.setTimeout(240_000);
const user = await ensureUser(uniq('oa'));
const fake = await fakeOAuth(context, user.localpart);
const page = await context.newPage();
// 1. Login: registration, PKCE-checked code exchange, session persisted.
await oauthLogin(page);
expect(fake.registered).toBe(1);
expect(fake.tokenCalls.map((c) => c.grant)).toEqual(['authorization_code']);
let s = await storedSession(page);
expect(s.userId).toBe(user.userId);
expect(s.refreshToken).toBe('r1');
expect(s.oidc.clientId).toBe('fake-client');
const t1 = s.accessToken;
// 2. Second tab on the same session.
const page2 = await context.newPage();
await page2.goto('/home/');
await page2.getByText('Connecting...').first().waitFor({ state: 'detached', timeout: 90_000 });
// 3. Token "expires": both tabs get M_UNKNOWN_TOKEN on their next request
// and refresh at once. Exactly one refresh may reach the auth server
// (r1 is single-use); the other tab must adopt its tokens.
// Sync long-polls continuously, so both tabs hit it within ~30 s.
fake.expired.add(t1);
await expect
.poll(async () => (await storedSession(page)).accessToken, { timeout: 90_000 })
.not.toBe(t1);
await page.waitForTimeout(5000);
const refreshCalls = fake.tokenCalls.filter((c) => c.grant === 'refresh_token');
expect(refreshCalls.map((c) => c.refresh)).toEqual(['r1']);
s = await storedSession(page);
expect(s.refreshToken).toBe('r2');
await Promise.all(
[page, page2].map((p) =>
expect(p.getByText(/Username or email|Sign-in failed|logged out/i)).toHaveCount(0),
),
);
// 4. Logout through the UI revokes both tokens at the auth server
// (the SDK does it for OAuth sessions instead of calling /logout).
await page2.close();
const latest = await storedSession(page);
await page.getByRole('button', { name: 'User Settings' }).click();
await page.getByRole('dialog').getByRole('button', { name: 'Logout' }).first().click();
await page
.getByRole('dialog')
.getByRole('button', { name: 'Logout', exact: true })
.last()
.click();
await expect(
page.getByLabel('Username or email').or(page.getByRole('button', { name: /Continue with/ })),
).toBeVisible({
timeout: 60_000,
});
expect(fake.revoked.sort()).toEqual([latest.accessToken, latest.refreshToken].sort());
expect(await storedSession(page)).toBeNull();
});
});
+35 -42
View File
@@ -53,7 +53,7 @@
"katex": "0.18.11",
"linkify-react": "4.3.3",
"linkifyjs": "4.3.3",
"matrix-js-sdk": "41.7.0",
"matrix-js-sdk": "44.0.0",
"matrix-widget-api": "1.18.0",
"millify": "6.1.0",
"pdfjs-dist": "6.3.289",
@@ -81,7 +81,7 @@
},
"devDependencies": {
"@axe-core/playwright": "4.13.0",
"@lotusguild/element-call-embedded": "0.25.0-lotus.26",
"@lotusguild/element-call-embedded": "0.25.0-lotus.29",
"@playwright/test": "1.63.0",
"@rollup/plugin-inject": "5.0.5",
"@rollup/plugin-wasm": "6.2.2",
@@ -2695,15 +2695,15 @@
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
},
"node_modules/@lotusguild/element-call-embedded": {
"version": "0.25.0-lotus.26",
"resolved": "https://code.lotusguild.org/api/packages/LotusGuild/npm/%40lotusguild%2Felement-call-embedded/-/0.25.0-lotus.26/element-call-embedded-0.25.0-lotus.26.tgz",
"integrity": "sha512-u0gFV/ne61MHVkl2JFY6TjC0C/vY2oYTz6dFaDtAmdLUBH6gU+6ar0QOr5xs9bhr4+HT8CSBibU8mLTR+ByjKA==",
"version": "0.25.0-lotus.29",
"resolved": "https://code.lotusguild.org/api/packages/LotusGuild/npm/%40lotusguild%2Felement-call-embedded/-/0.25.0-lotus.29/element-call-embedded-0.25.0-lotus.29.tgz",
"integrity": "sha512-IAIEyiOFfkfb1k2JfBNOkX4LOVaGF8LzeKVQYCqKoyKDVao6rYEYA71LON8ntTaxkredXOK4CeLFsnkCiJHuGg==",
"dev": true
},
"node_modules/@matrix-org/matrix-sdk-crypto-wasm": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-18.3.1.tgz",
"integrity": "sha512-VRjWhE1UgHnPpJ3b9B5+8z71ZC/HICFngPPFIN6ktzmUBKI5RusPujzbAQUoB3CgZ0yU58L99AfSQS4YTztSWw==",
"version": "18.9.0",
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-18.9.0.tgz",
"integrity": "sha512-NtLzNDTEfNASBjNCTGZHuk7N0jrQhS6Zx2CM857rCHZYYh/rpbKGQNrJ7azktm4S1P5Jy3WU3nwJTGohGw26qQ==",
"license": "Apache-2.0",
"engines": {
"node": ">= 18"
@@ -5580,12 +5580,12 @@
"dev": true
},
"node_modules/content-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-3.1.1.tgz",
"integrity": "sha512-GW4qUsfFo59d0HbUibDlWv5wPz+vAAcaTWbKIuKCf0JkC7wWkSyf8f13IpXn5JkeMlB2P8iTSSIjwXljorg2vA==",
"license": "MIT",
"engines": {
"node": ">=18"
"node": ">=22"
},
"funding": {
"type": "opencollective",
@@ -9152,15 +9152,6 @@
"node": ">=4.0"
}
},
"node_modules/jwt-decode": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/katex": {
"version": "0.18.11",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.18.11.tgz",
@@ -10037,21 +10028,19 @@
"license": "Apache-2.0"
},
"node_modules/matrix-js-sdk": {
"version": "41.7.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-41.7.0.tgz",
"integrity": "sha512-MP0xNv/VVRbshq00TE6EVo77IIXsQk0KjiVtgKV0t9j/V77a6Klt00QrrO0XykkTUsNC0+mQeBMxnx75rZO86Q==",
"version": "44.0.0",
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-44.0.0.tgz",
"integrity": "sha512-5wjcYMIX1aqhJC9hSUGjfSW+7SWEaLC8NUaek0xH5KGXqAO11M4Z5Mk7Voodsk+16Jm9PYB8/wMtyqIKFm0VAQ==",
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@matrix-org/matrix-sdk-crypto-wasm": "^18.3.1",
"@babel/runtime": "^8.0.0",
"@matrix-org/matrix-sdk-crypto-wasm": "^18.9.0",
"another-json": "^0.2.0",
"bs58": "^6.0.0",
"content-type": "^2.0.0",
"jwt-decode": "^4.0.0",
"content-type": "^3.0.0",
"loglevel": "^1.9.2",
"matrix-events-sdk": "0.0.1",
"matrix-widget-api": "^1.16.1",
"oidc-client-ts": "^3.0.1",
"matrix-widget-api": "^1.19.0",
"p-retry": "8",
"sdp-transform": "^3.0.0",
"unhomoglyph": "^1.0.6"
@@ -10060,6 +10049,22 @@
"node": ">=22.0.0"
}
},
"node_modules/matrix-js-sdk/node_modules/@babel/runtime": {
"version": "8.0.8",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-8.0.8.tgz",
"integrity": "sha512-dEu8nGlRqjsJsvviUUoSMfcRHpwomCiRlXsc2mPfJ79+ffTpDm+JtfUtTMzUrqCApHQnCsVPD3gT1ZT8RgBRCQ==",
"license": "MIT"
},
"node_modules/matrix-js-sdk/node_modules/matrix-widget-api": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/matrix-widget-api/-/matrix-widget-api-1.20.0.tgz",
"integrity": "sha512-qwFP37rgns7mPesM5/vvZgknzb+kvyRB5BISv5sCuBxsGMceMr+Kogf7OkjRxBXdMCPBFuf6gIuYRe5S+lpzQw==",
"license": "Apache-2.0",
"dependencies": {
"@types/events": "^3.0.0",
"events": "^3.2.0"
}
},
"node_modules/matrix-widget-api": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/matrix-widget-api/-/matrix-widget-api-1.18.0.tgz",
@@ -10405,18 +10410,6 @@
],
"license": "MIT"
},
"node_modules/oidc-client-ts": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/oidc-client-ts/-/oidc-client-ts-3.2.1.tgz",
"integrity": "sha512-hS5AJ5s/x4bXhHvNJT1v+GGvzHUwdRWqNQQbSrp10L1IRmzfRGKQ3VWN3dstJb+oF3WtAyKezwD2+dTEIyBiAA==",
"license": "Apache-2.0",
"dependencies": {
"jwt-decode": "^4.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+3 -3
View File
@@ -12,7 +12,7 @@
"build": "vite build",
"preview": "vite preview",
"lint": "npm run check:eslint && npm run check:prettier",
"check:eslint": "eslint src/* --max-warnings 36",
"check:eslint": "eslint src/* --max-warnings 29",
"check:prettier": "prettier --check .",
"fix:prettier": "prettier --write .",
"typecheck": "tsc --noEmit",
@@ -80,7 +80,7 @@
"katex": "0.18.11",
"linkify-react": "4.3.3",
"linkifyjs": "4.3.3",
"matrix-js-sdk": "41.7.0",
"matrix-js-sdk": "44.0.0",
"matrix-widget-api": "1.18.0",
"millify": "6.1.0",
"pdfjs-dist": "6.3.289",
@@ -108,7 +108,7 @@
},
"devDependencies": {
"@axe-core/playwright": "4.13.0",
"@lotusguild/element-call-embedded": "0.25.0-lotus.26",
"@lotusguild/element-call-embedded": "0.25.0-lotus.29",
"@playwright/test": "1.63.0",
"@rollup/plugin-inject": "5.0.5",
"@rollup/plugin-wasm": "6.2.2",
+6 -2
View File
@@ -571,7 +571,11 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
? content.sender_ts
: event.getTs();
const lifetime = Math.min(content.lifetime, 120000);
const notificationType = content.notification_type;
// `notification_type` is deprecated in MSC4075 (matrix-js-sdk 43+): newer
// senders may omit it and leave the presentation to us. Then ring in a
// direct chat and notify quietly elsewhere, like Element Web.
const notificationType =
content.notification_type ?? (directs.has(room.roomId) ? 'ring' : 'notification');
const relation =
event.getRelation()?.rel_type === RelationType.Reference ? event.getRelation() : undefined;
const refEventId = relation?.event_id;
@@ -653,7 +657,7 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
mx.getRooms().forEach((r) => {
mx.matrixRTC
.getActiveRoomSession(r)
?._onRTCSessionMemberUpdate()
?.ensureRecalculateSessionMembers()
.catch(() => undefined);
});
};
+2 -2
View File
@@ -82,7 +82,7 @@ export function ManualVerificationMethodSwitcher({
<MenuItem
size="300"
variant="Surface"
aria-selected={value === ManualVerificationMethod.RecoveryPassphrase}
aria-pressed={value === ManualVerificationMethod.RecoveryPassphrase}
radii="300"
onClick={() => handleSelect(ManualVerificationMethod.RecoveryPassphrase)}
>
@@ -93,7 +93,7 @@ export function ManualVerificationMethodSwitcher({
<MenuItem
size="300"
variant="Surface"
aria-selected={value === ManualVerificationMethod.RecoveryKey}
aria-pressed={value === ManualVerificationMethod.RecoveryKey}
radii="300"
onClick={() => handleSelect(ManualVerificationMethod.RecoveryKey)}
>
+4 -1
View File
@@ -7,8 +7,10 @@ import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
type Modal500Props = {
requestClose: () => void;
children: ReactNode;
/** [Gitea #278] The dialog's accessible name (role="dialog" needs one). */
label: string;
};
export function Modal500({ requestClose, children }: Modal500Props) {
export function Modal500({ requestClose, children, label }: Modal500Props) {
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
return (
<Overlay open backdrop={<OverlayBackdrop />}>
@@ -26,6 +28,7 @@ export function Modal500({ requestClose, children }: Modal500Props) {
variant="Background"
role="dialog"
aria-modal="true"
aria-label={label}
// On mobile expand to fill the viewport. On desktop fall back to the
// folds `size="500"` width (~50rem) — overriding maxWidth here would
// squish the two-pane settings layout.
+9 -2
View File
@@ -1,6 +1,7 @@
import React, { FormEventHandler, useCallback } from 'react';
import { Box, Text, Button, Spinner, color } from 'folds';
import { decodeRecoveryKey, deriveRecoveryKeyFromPassphrase } from 'matrix-js-sdk/lib/crypto-api';
import type { SecretStorageKeyDescription } from 'matrix-js-sdk/lib/secret-storage';
import { PasswordInput } from './password-input';
import {
SecretStorageKeyContent,
@@ -39,7 +40,10 @@ export function SecretStorageRecoveryPassphrase({
bits,
);
const match = await mx.secretStorage.checkKey(decodedRecoveryKey, keyContent as any);
const match = await mx.secretStorage.checkKey(
decodedRecoveryKey,
keyContent as SecretStorageKeyDescription,
);
if (!match) {
throw new Error('Invalid recovery passphrase.');
@@ -132,7 +136,10 @@ export function SecretStorageRecoveryKey({
async (recoveryKey) => {
const decodedRecoveryKey = decodeRecoveryKey(recoveryKey);
const match = await mx.secretStorage.checkKey(decodedRecoveryKey, keyContent as any);
const match = await mx.secretStorage.checkKey(
decodedRecoveryKey,
keyContent as SecretStorageKeyDescription,
);
if (!match) {
throw new Error('Invalid recovery key.');
+4 -13
View File
@@ -1,5 +1,5 @@
import { ReactNode, useCallback, useMemo } from 'react';
import { Capabilities, validateAuthMetadata, ValidatedAuthMetadata } from 'matrix-js-sdk';
import { Capabilities, ValidatedAuthMetadata } from 'matrix-js-sdk';
import { AsyncStatus, useAsyncCallbackValue } from '../hooks/useAsyncCallback';
import { useMatrixClient } from '../hooks/useMatrixClient';
import { MediaConfig } from '../hooks/useMediaConfig';
@@ -28,23 +28,14 @@ export function ServerConfigsLoader({ children }: ServerConfigsLoaderProps) {
const capabilities = promiseFulfilledResult(result[0]);
const mediaConfig = promiseFulfilledResult(result[1]);
// getAuthMetadata validates (and rejects when the server has no native
// OAuth, which is normal for servers using traditional SSO).
const authMetadata = promiseFulfilledResult(result[2]);
let validatedAuthMetadata: ValidatedAuthMetadata | undefined;
// Only validate if the server returned metadata — a rejected promise means no native
// Matrix OIDC (MSC3861/MAS), which is normal for servers using traditional SSO.
if (authMetadata !== undefined) {
try {
validatedAuthMetadata = validateAuthMetadata(authMetadata);
} catch (e) {
console.error(e);
}
}
return {
capabilities,
mediaConfig,
authMetadata: validatedAuthMetadata,
authMetadata,
};
}, [mx]),
);
+8 -1
View File
@@ -117,7 +117,14 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
const renderPlaceholder = useCallback(
({ attributes, children }: RenderPlaceholderProps) => (
<span {...attributes} className={css.EditorPlaceholderContainer}>
<span
{...attributes}
// [Gitea #278] Slate puts an inline `opacity: 0.333` on the placeholder,
// which beat EditorPlaceholderContainer's AA-contrast opacity (#222):
// measured 2.66:1. Drop it so the class decides.
style={{ ...attributes.style, opacity: undefined }}
className={css.EditorPlaceholderContainer}
>
{/* Inner component to style the actual text position and appearance */}
<Text as="span" className={css.EditorPlaceholderTextVisual} truncate>
{children}
@@ -39,7 +39,7 @@ export function UsageSelector({ selected, onChange }: UsageSelectorProps) {
key={getUsageStr(usage)}
size="300"
variant={isSelected(usage) ? 'SurfaceVariant' : 'Surface'}
aria-selected={isSelected(usage)}
aria-pressed={isSelected(usage)}
radii="300"
onClick={() => onChange(usage)}
>
+3 -3
View File
@@ -69,7 +69,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
variant={selectedDay === day ? 'Primary' : 'SurfaceVariant'}
fill="None"
radii="300"
aria-selected={selectedDay === day}
aria-pressed={selectedDay === day}
onClick={() => handleDay(day)}
disabled={
(selectedYear === minYear && selectedMonth === minMonth && day < minDay) ||
@@ -90,7 +90,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
variant={selectedMonth === month ? 'Primary' : 'SurfaceVariant'}
fill="None"
radii="300"
aria-selected={selectedMonth === month}
aria-pressed={selectedMonth === month}
onClick={() => handleMonth(month)}
disabled={
(selectedYear === minYear && month < minMonth) ||
@@ -115,7 +115,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
variant={selectedYear === year ? 'Primary' : 'SurfaceVariant'}
fill="None"
radii="300"
aria-selected={selectedYear === year}
aria-pressed={selectedYear === year}
onClick={() => handleYear(year)}
>
<Text size="T300">{year}</Text>
+5 -5
View File
@@ -71,7 +71,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
variant={hour === selectedHour ? 'Primary' : 'Background'}
fill="None"
radii="300"
aria-selected={hour === selectedHour}
aria-pressed={hour === selectedHour}
onClick={() => handleHour(hour)}
disabled={(minDay && hour < minHour24) || (maxDay && hour > maxHour24)}
>
@@ -90,7 +90,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
variant={hour === selectedHour ? 'Primary' : 'Background'}
fill="None"
radii="300"
aria-selected={hour === selectedHour}
aria-pressed={hour === selectedHour}
onClick={() => handleHour(hour)}
disabled={
(minDay && hour12to24(hour, selectedPM) < minHour24) ||
@@ -109,7 +109,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
variant={minute === selectedMinute ? 'Primary' : 'Background'}
fill="None"
radii="300"
aria-selected={minute === selectedMinute}
aria-pressed={minute === selectedMinute}
onClick={() => handleMinute(minute)}
disabled={
(minDay && hour24 === minHour24 && minute < minMinute) ||
@@ -127,7 +127,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
variant={!selectedPM ? 'Primary' : 'SurfaceVariant'}
fill="None"
radii="300"
aria-selected={!selectedPM}
aria-pressed={!selectedPM}
onClick={() => handlePeriod(false)}
disabled={minDay && minPM}
>
@@ -138,7 +138,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
variant={selectedPM ? 'Primary' : 'SurfaceVariant'}
fill="None"
radii="300"
aria-selected={selectedPM}
aria-pressed={selectedPM}
onClick={() => handlePeriod(true)}
disabled={maxDay && !maxPM}
>
@@ -33,7 +33,9 @@ export function UserAvatar({ className, userId, src, alt, renderFallback }: User
<AvatarImage
className={classNames(css.UserAvatar, className)}
src={src}
alt={alt}
// [Gitea #278] An avatar sits next to the person's name or inside a
// labelled button, so without an explicit alt it is decorative.
alt={alt ?? ''}
onError={() => setError(true)}
onLoad={handleLoad}
draggable={false}
@@ -1,10 +1,11 @@
import { style } from '@vanilla-extract/css';
import { config, toRem } from 'folds';
import { config } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../styles/sidePanel';
// Mirrors MembersDrawer: a 266px side panel on desktop that becomes a
// Mirrors MembersDrawer: a side panel (shared width) on desktop that becomes a
// full-screen fixed panel on narrow viewports — the app's canonical drawer.
export const BookmarksPanel = style({
width: toRem(266),
width: SIDE_PANEL_WIDTH,
'@media': {
'(max-width: 750px)': {
position: 'fixed',
@@ -0,0 +1,84 @@
import React from 'react';
import FocusTrap from 'focus-trap-react';
import {
Box,
config,
Dialog,
Header,
Icon,
IconButton,
Icons,
Overlay,
OverlayBackdrop,
OverlayCenter,
Text,
} from 'folds';
import { useAtom } from 'jotai';
import { callSummaryViewAtom } from '../../state/callSummary';
import { useModalStyle } from '../../hooks/useModalStyle';
import { stopPropagation } from '../../utils/keyboard';
/**
* [Gitea #253] The post-call "Details" card: opened from the call-ended toast,
* shows who was in the call, connection quality and whose side it was on,
* network numbers and your own activity (technical wording).
*/
export function CallSummaryDialog() {
const [view, setView] = useAtom(callSummaryViewAtom);
const modalStyle = useModalStyle(400);
if (!view) return null;
const close = () => setView(undefined);
return (
<Overlay open backdrop={<OverlayBackdrop />}>
<OverlayCenter>
<FocusTrap
focusTrapOptions={{
initialFocus: false,
onDeactivate: close,
clickOutsideDeactivates: true,
escapeDeactivates: stopPropagation,
}}
>
<Dialog
variant="Surface"
role="dialog"
aria-modal="true"
aria-labelledby="call-summary-title"
style={modalStyle}
>
<Header
variant="Surface"
size="500"
style={{
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
borderBottomWidth: config.borderWidth.B300,
}}
>
<Box grow="Yes" alignItems="Center" gap="200">
<Icon src={Icons.Phone} size="100" />
<Text id="call-summary-title" size="H4" truncate>
Call summary · {view.roomName}
</Text>
</Box>
<IconButton size="300" radii="300" onClick={close} aria-label="Close">
<Icon src={Icons.Cross} />
</IconButton>
</Header>
<Box direction="Column" gap="400" style={{ padding: config.space.S400 }}>
{view.sections.map((section) => (
<Box key={section.title} direction="Column" gap="100">
<Text size="L400">{section.title}</Text>
{section.lines.map((line) => (
<Text key={line} size="T300" style={{ fontVariantNumeric: 'tabular-nums' }}>
{line}
</Text>
))}
</Box>
))}
</Box>
</Dialog>
</FocusTrap>
</OverlayCenter>
</Overlay>
);
}
+227 -134
View File
@@ -44,6 +44,7 @@ import { stopPropagation } from '../../utils/keyboard';
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
import { useCallEmbedRef } from '../../hooks/useCallEmbed';
import { pttActiveAtom } from '../../hooks/useCallHotkeys';
import { SCREENSHARE_AUDIO_STATE } from '../../plugins/call/CallControl';
import { CallSoundboard } from './CallSoundboard';
import { useRoomCallPolicy } from '../../hooks/useRoomCallPolicy';
import { ScreenshareConfirm } from './ScreenshareConfirm';
@@ -90,6 +91,21 @@ export function CallControls({ callEmbed }: CallControlsProps) {
const { microphone, video, sound, screenshare, spotlight, screenshareAudioMuted } =
useCallControlState(callEmbed.control);
// [Gitea #277] Only offer "Mute Screenshare Audio" while a remote share's
// audio is playing, or while it is muted (so a hidden mute can't silently
// swallow the next share).
const [remoteScreenshareAudio, setRemoteScreenshareAudio] = useState(
callEmbed.control.remoteScreenshareAudio,
);
useEffect(() => {
const onState = () => setRemoteScreenshareAudio(callEmbed.control.remoteScreenshareAudio);
onState();
callEmbed.control.on(SCREENSHARE_AUDIO_STATE, onState);
return () => {
callEmbed.control.off(SCREENSHARE_AUDIO_STATE, onState);
};
}, [callEmbed]);
const showScreenshareAudio = remoteScreenshareAudio || screenshareAudioMuted;
const micLevel = useCallMicLevel(callEmbed);
const [cords, setCords] = useState<RectCords>();
@@ -122,6 +138,8 @@ export function CallControls({ callEmbed }: CallControlsProps) {
};
const showScreenshare = allowScreenshare || screenshare;
const showVideoGroup = showCamera || showScreenshare || !!document.fullscreenEnabled;
// [Gitea #265] Phones can't share their screen from a browser; don't offer it.
const canShareScreen = typeof navigator.mediaDevices?.getDisplayMedia === 'function';
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
setCords(evt.currentTarget.getBoundingClientRect());
};
@@ -166,6 +184,111 @@ export function CallControls({ callEmbed }: CallControlsProps) {
return () => clearTimeout(id);
}, [hangupState.status, callEmbed, setCallEmbed]);
const moreMenu = (
<PopOut
anchor={cords}
position="Top"
align="Center"
content={
<FocusTrap
focusTrapOptions={{
initialFocus: false,
onDeactivate: () => setCords(undefined),
clickOutsideDeactivates: true,
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
escapeDeactivates: stopPropagation,
}}
>
<Menu>
<Box direction="Column" style={{ padding: config.space.S100 }}>
{compact && showScreenshare && screenshareMode !== 'hidden' && canShareScreen && (
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={() => {
setCords(undefined);
handleScreenshareToggle();
}}
>
<Text size="B300" truncate>
{screenshare ? 'Stop Screenshare' : 'Share Screen'}
</Text>
</MenuItem>
)}
{compact && showScreenshareAudio && (
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={() => {
setCords(undefined);
callEmbed.control.toggleScreenshareAudio();
}}
>
<Text size="B300" truncate>
{screenshareAudioMuted ? 'Unmute Screenshare Audio' : 'Mute Screenshare Audio'}
</Text>
</MenuItem>
)}
{compact && !!document.fullscreenEnabled && (
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={() => {
setCords(undefined);
handleFullscreen();
}}
>
<Text size="B300" truncate>
{isFullscreen ? 'Exit Fullscreen' : 'Fullscreen'}
</Text>
</MenuItem>
)}
<MenuItem size="300" variant="Surface" radii="300" onClick={handleSpotlightClick}>
<Text size="B300" truncate>
{spotlight ? 'Grid View' : 'Spotlight View'}
</Text>
</MenuItem>
<MenuItem size="300" variant="Surface" radii="300" onClick={handleReactionsClick}>
<Text size="B300" truncate>
Reactions
</Text>
</MenuItem>
<MenuItem size="300" variant="Surface" radii="300" onClick={handleSettingsClick}>
<Text size="B300" truncate>
Settings
</Text>
</MenuItem>
</Box>
</Menu>
</FocusTrap>
}
>
<IconButton
variant="Surface"
fill="Soft"
radii="400"
size="400"
onClick={handleOpenMenu}
outlined
aria-label="More options"
aria-expanded={!!cords}
aria-haspopup="menu"
>
<Icon size="400" src={Icons.VerticalDots} />
</IconButton>
</PopOut>
);
const hangupIcon = exiting ? (
<Spinner variant="Critical" fill="Solid" size="200" />
) : (
<Icon src={Icons.PhoneDown} size="200" filled />
);
const pttKeyLabel = pttKey === 'Space' ? 'SPACE' : pttKey.replace('Key', '').replace('Digit', '');
return (
@@ -204,144 +327,114 @@ export function CallControls({ callEmbed }: CallControlsProps) {
}}
onCancel={() => setShareConfirm(false)}
/>
<SequenceCard
className={css.ControlCard}
variant="SurfaceVariant"
gap="400"
radii="500"
alignItems="Center"
justifyContent="SpaceBetween"
wrap="Wrap"
>
<Box alignItems="Center" gap="Inherit" grow="Yes" direction={compact ? 'Column' : 'Row'}>
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
<MicrophoneButton
enabled={microphone}
onToggle={handleMicrophoneToggle}
level={micLevel}
/>
<SoundButton enabled={sound} onToggle={() => callEmbed.control.toggleSound()} />
</Box>
{!compact && showVideoGroup && <ControlDivider />}
{showVideoGroup && (
{compact ? (
// [Gitea #265] Phones / narrow windows: ONE row. Screenshare, its audio
// mute and fullscreen live in More (they rarely matter on a phone), and
// End is icon-only. The old stacked layout took four rows (~40% of a
// portrait phone).
<SequenceCard
className={css.ControlCard}
variant="SurfaceVariant"
gap="200"
radii="500"
alignItems="Center"
justifyContent="SpaceBetween"
wrap="NoWrap"
>
<MicrophoneButton
enabled={microphone}
onToggle={handleMicrophoneToggle}
level={micLevel}
/>
<SoundButton enabled={sound} onToggle={() => callEmbed.control.toggleSound()} />
{showCamera && <VideoButton enabled={video} onToggle={handleVideoToggle} />}
<ChatButton />
{soundboardEnabled && <CallSoundboard callEmbed={callEmbed} />}
{moreMenu}
<Button
variant="Critical"
fill="Solid"
radii="400"
size="400"
onClick={hangup}
disabled={exiting}
aria-label="End Call"
style={{ paddingInline: config.space.S300 }}
>
{hangupIcon}
</Button>
</SequenceCard>
) : (
<SequenceCard
className={css.ControlCard}
variant="SurfaceVariant"
gap="400"
radii="500"
alignItems="Center"
justifyContent="SpaceBetween"
wrap="Wrap"
>
<Box alignItems="Center" gap="Inherit" grow="Yes">
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
{/* Show a forbidden control while its track is still live so the
user can stop it; once stopped it hides and can't be restarted. */}
{showCamera && <VideoButton enabled={video} onToggle={handleVideoToggle} />}
{showScreenshare && (
<>
{screenshareMode !== 'hidden' && (
<ScreenShareButton
enabled={screenshare}
onToggle={() => handleScreenshareToggle()}
/>
)}
{/* Mute-screenshare-audio sits directly next to the screenshare
control since they're the same concern. */}
<ScreenshareAudioButton
muted={screenshareAudioMuted}
onToggle={() => callEmbed.control.toggleScreenshareAudio()}
/>
</>
)}
{!!document.fullscreenEnabled && (
<FullscreenButton isFullscreen={isFullscreen} onToggle={handleFullscreen} />
)}
<MicrophoneButton
enabled={microphone}
onToggle={handleMicrophoneToggle}
level={micLevel}
/>
<SoundButton enabled={sound} onToggle={() => callEmbed.control.toggleSound()} />
</Box>
)}
</Box>
{!compact && <ControlDivider />}
<Box alignItems="Center" gap="Inherit" grow="Yes" direction={compact ? 'Column' : 'Row'}>
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
<ChatButton />
{soundboardEnabled && <CallSoundboard callEmbed={callEmbed} />}
<PopOut
anchor={cords}
position="Top"
align="Center"
content={
<FocusTrap
focusTrapOptions={{
initialFocus: false,
onDeactivate: () => setCords(undefined),
clickOutsideDeactivates: true,
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
escapeDeactivates: stopPropagation,
}}
>
<Menu>
<Box direction="Column" style={{ padding: config.space.S100 }}>
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={handleSpotlightClick}
>
<Text size="B300" truncate>
{spotlight ? 'Grid View' : 'Spotlight View'}
</Text>
</MenuItem>
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={handleReactionsClick}
>
<Text size="B300" truncate>
Reactions
</Text>
</MenuItem>
<MenuItem
size="300"
variant="Surface"
radii="300"
onClick={handleSettingsClick}
>
<Text size="B300" truncate>
Settings
</Text>
</MenuItem>
</Box>
</Menu>
</FocusTrap>
}
>
<IconButton
variant="Surface"
fill="Soft"
radii="400"
size="400"
onClick={handleOpenMenu}
outlined
aria-label="More options"
aria-expanded={!!cords}
aria-haspopup="menu"
{showVideoGroup && <ControlDivider />}
{showVideoGroup && (
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
{/* Show a forbidden control while its track is still live so the
user can stop it; once stopped it hides and can't be restarted. */}
{showCamera && <VideoButton enabled={video} onToggle={handleVideoToggle} />}
{showScreenshare && (
<>
{screenshareMode !== 'hidden' && (
<ScreenShareButton
enabled={screenshare}
onToggle={() => handleScreenshareToggle()}
/>
)}
{/* Mute-screenshare-audio sits directly next to the screenshare
control since they're the same concern. */}
{showScreenshareAudio && (
<ScreenshareAudioButton
muted={screenshareAudioMuted}
onToggle={() => callEmbed.control.toggleScreenshareAudio()}
/>
)}
</>
)}
{!!document.fullscreenEnabled && (
<FullscreenButton isFullscreen={isFullscreen} onToggle={handleFullscreen} />
)}
</Box>
)}
</Box>
<ControlDivider />
<Box alignItems="Center" gap="Inherit" grow="Yes">
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
<ChatButton />
{soundboardEnabled && <CallSoundboard callEmbed={callEmbed} />}
{moreMenu}
</Box>
<Box shrink="No" direction="Column">
<Button
style={{ minWidth: toRem(88) }}
variant="Critical"
fill="Solid"
onClick={hangup}
before={hangupIcon}
disabled={exiting}
>
<Icon size="400" src={Icons.VerticalDots} />
</IconButton>
</PopOut>
<Text size="B400">End</Text>
</Button>
</Box>
</Box>
<Box shrink="No" direction="Column">
<Button
style={{ minWidth: toRem(88) }}
variant="Critical"
fill="Solid"
onClick={hangup}
before={
exiting ? (
<Spinner variant="Critical" fill="Solid" size="200" />
) : (
<Icon src={Icons.PhoneDown} size="200" filled />
)
}
disabled={exiting}
>
<Text size="B400">End</Text>
</Button>
</Box>
</Box>
</SequenceCard>
</SequenceCard>
)}
</Box>
);
}
@@ -30,6 +30,7 @@ import {
AccountDataSubmitCallback,
} from '../../../components/AccountDataEditor';
import { useMatrixClient } from '../../../hooks/useMatrixClient';
import { setRoomAccountData } from '../../../utils/accountData';
type DeveloperToolsProps = {
requestClose: () => void;
@@ -58,8 +59,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
const submitAccountData: AccountDataSubmitCallback = useCallback(
async (type, content) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await mx.setRoomAccountData(room.roomId, type as any, content);
await setRoomAccountData(mx, room.roomId, type, content);
},
[mx, room.roomId],
);
@@ -1,5 +1,5 @@
import React, { useCallback, useRef, useState, FormEventHandler, useEffect } from 'react';
import { MatrixError } from 'matrix-js-sdk';
import { IContent, MatrixError } from 'matrix-js-sdk';
import {
Box,
Chip,
@@ -22,6 +22,7 @@ import { useTextAreaCodeEditor } from '../../../hooks/useTextAreaCodeEditor';
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
import { syntaxErrorPosition } from '../../../utils/dom';
import { Cursor } from '../../../plugins/text-area';
import { sendRoomEvent, sendStateEvent } from '../../../utils/room';
const EDITOR_INTENT_SPACE_COUNT = 2;
@@ -51,9 +52,9 @@ export function SendRoomEvent({ type, stateKey, requestClose }: SendRoomEventPro
useCallback(
(evtType, evtStateKey, evtContent) => {
if (typeof evtStateKey === 'string') {
return mx.sendStateEvent(room.roomId, evtType as any, evtContent, evtStateKey);
return sendStateEvent(mx, room.roomId, evtType, evtContent, evtStateKey);
}
return mx.sendEvent(room.roomId, evtType as any, evtContent);
return sendRoomEvent(mx, room.roomId, null, evtType, evtContent as IContent);
},
[mx, room],
),
@@ -31,6 +31,7 @@ import { usePowerLevels } from '../../../hooks/usePowerLevels';
import { useTextAreaCodeEditor } from '../../../hooks/useTextAreaCodeEditor';
import { useRoomCreators } from '../../../hooks/useRoomCreators';
import { useRoomPermissions } from '../../../hooks/useRoomPermissions';
import { sendStateEvent } from '../../../utils/room';
const EDITOR_INTENT_SPACE_COUNT = 2;
@@ -59,7 +60,7 @@ function StateEventEdit({ type, stateKey, content, requestClose }: StateEventEdi
const [submitState, submit] = useAsyncCallback<object, MatrixError, [object]>(
useCallback(
(c) => mx.sendStateEvent(room.roomId, type as any, c, stateKey),
(c) => sendStateEvent(mx, room.roomId, type, c, stateKey),
[mx, room, type, stateKey],
),
);
@@ -109,8 +109,11 @@ function CreatePackTile({ packs, roomId }: CreatePackTileProps) {
alignItems="End"
>
<Box direction="Column" gap="100" grow="Yes">
<Text size="L400">Name</Text>
<Text as="label" htmlFor="room-pack-name" size="L400">
Name
</Text>
<Input
id="room-pack-name"
name="nameInput"
required
size="400"
@@ -136,7 +136,8 @@ export function PermissionGroups({
outlined={powerChanges}
fill="Soft"
radii="Pill"
aria-selected={opened}
aria-haspopup="menu"
aria-expanded={opened}
disabled={!canEdit || applyingChanges}
after={
powerChanges && (
@@ -200,7 +201,8 @@ export function PermissionGroups({
outlined={powerChanges}
fill="Soft"
radii="Pill"
aria-selected={opened}
aria-haspopup="menu"
aria-expanded={opened}
disabled={!canEdit || applyingChanges}
after={
powerChanges && (
@@ -38,10 +38,14 @@ export function Soundboard({ requestClose }: SoundboardProps) {
<PageContent>
<Box direction="Column" gap="700">
<Box direction="Column" gap="200">
<Text size="L400">This room / space (shared)</Text>
<Text size="L400">
{room?.isSpaceRoom() ? 'This space (shared)' : 'This room (shared)'}
</Text>
<Text size="T200" priority="300">
Clips here are shared with everyone, and inherited by every room under this space
— just like emoji/sticker packs. Only members with permission can edit.
{/* [Gitea #279] Only a space's clips are inherited by rooms under it. */}
{room?.isSpaceRoom()
? 'Clips here are shared with everyone, and inherited by every room under this space — just like emoji/sticker packs. Only members with permission can edit.'
: 'Clips here are shared with everyone in this room — just like emoji/sticker packs. Only members with permission can edit.'}
</Text>
{room && <RoomSoundboardPack room={room} stateKey="" />}
</Box>
+12 -7
View File
@@ -94,10 +94,15 @@ export function OutboxFeature() {
OFFLINE.has(mx.getSyncState()) ||
(typeof navigator !== 'undefined' && navigator.onLine === false);
const persist = (next: OutboxEntry[]) => {
if (next === entries) return;
// [Gitea #268] Read-modify-write: another tab may have queued or cleared
// entries since we last looked, and saving our own copy over the key
// would drop theirs. Entries are added/removed by txnId, so applying our
// change to the stored list merges cleanly.
const persist = (update: (list: OutboxEntry[]) => OutboxEntry[]) => {
const stored = loadOutbox(userId);
const next = update(stored);
entries = next;
saveOutbox(userId, entries);
if (next !== stored) saveOutbox(userId, next);
};
/**
@@ -123,8 +128,8 @@ export function OutboxFeature() {
if (!shouldKeepInOutbox(event.getType(), event.getContent())) return;
live.set(txnId, { event, room });
if (event.status === EventStatus.NOT_SENT) scheduleBlipRetry(event);
persist(
withEntry(entries, {
persist((list) =>
withEntry(list, {
txnId,
roomId: room.roomId,
threadId: event.threadRootId ?? null,
@@ -138,7 +143,7 @@ export function OutboxFeature() {
// SENT, CANCELLED, or the remote echo replaced it (status null).
live.delete(txnId);
autoRetries.delete(txnId);
persist(withoutEntry(entries, txnId));
persist((list) => withoutEntry(list, txnId));
};
/** Re-send network failures, oldest first; a room stops at its first failure. */
@@ -191,7 +196,7 @@ export function OutboxFeature() {
return !!room && isDelivered(room, entry.txnId);
},
);
plan.drop.forEach((entry) => persist(withoutEntry(entries, entry.txnId)));
plan.drop.forEach((entry) => persist((list) => withoutEntry(list, entry.txnId)));
plan.restore.forEach((entry) => {
const room = mx.getRoom(entry.roomId);
if (!room || live.has(entry.txnId)) return;
@@ -353,8 +353,11 @@ ${msgRows}
>
<Box gap="400" wrap="Wrap">
<Box direction="Column" gap="100" style={{ flex: 1, minWidth: 160 }}>
<Text size="T300">From</Text>
<Text as="label" htmlFor="export-from-date" size="T300">
From
</Text>
<Input
id="export-from-date"
type="date"
variant="Secondary"
size="400"
@@ -364,8 +367,11 @@ ${msgRows}
/>
</Box>
<Box direction="Column" gap="100" style={{ flex: 1, minWidth: 160 }}>
<Text size="T300">To</Text>
<Text as="label" htmlFor="export-to-date" size="T300">
To
</Text>
<Input
id="export-to-date"
type="date"
variant="Secondary"
size="400"
@@ -21,7 +21,7 @@ function RenderSettings({ state }: RenderSettingsProps) {
if (!room) return null;
return (
<Modal500 requestClose={closeSettings}>
<Modal500 requestClose={closeSettings} label={`${room.name} settings`}>
<SpaceProvider value={space ?? null}>
<RoomProvider value={room}>
<RoomSettings initialPage={page} requestClose={closeSettings} />
+5 -5
View File
@@ -1,13 +1,13 @@
import { style } from '@vanilla-extract/css';
import { color, config, toRem } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../styles/sidePanel';
// Right-side drawer DOCKED into the room layout row (a flex sibling of the
// timeline), exactly like MembersDrawer — not a floating overlay. 320px is a
// little wider than the 266px member/bookmark drawers because it hosts a media
// grid. On narrow viewports it becomes a full-screen fixed panel, matching the
// app's other drawers.
// timeline), exactly like MembersDrawer — not a floating overlay. Same width as
// every other right-hand panel (styles/sidePanel.ts, #263). On narrow viewports
// it becomes a full-screen fixed panel, matching the app's other drawers.
export const MediaGalleryDrawer = style({
width: toRem(320),
width: SIDE_PANEL_WIDTH,
overflow: 'hidden',
'@media': {
'(max-width: 750px)': {
+3 -2
View File
@@ -1,8 +1,9 @@
import { keyframes, style } from '@vanilla-extract/css';
import { config, toRem } from 'folds';
import { config } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../styles/sidePanel';
export const MembersDrawer = style({
width: toRem(266),
width: SIDE_PANEL_WIDTH,
'@media': {
'(max-width: 750px)': {
position: 'fixed',
+22 -4
View File
@@ -20,7 +20,12 @@ import { IContent } from 'matrix-js-sdk';
import { useTimestampFormatter } from '../../hooks/useTimestampFormatter';
import { useMatrixClient } from '../../hooks/useMatrixClient';
import { stopPropagation } from '../../utils/keyboard';
import { scheduleMessage } from '../../utils/scheduledMessages';
import {
describeScheduleError,
MAX_SCHEDULE_AHEAD_MS,
scheduleMessage,
SCHEDULE_TOO_FAR_TEXT,
} from '../../utils/scheduledMessages';
import { useModalStyle } from '../../hooks/useModalStyle';
import {
toLocalDate,
@@ -121,7 +126,13 @@ export function ScheduleMessageModal({
return;
}
const diffMs = sendAt.getTime() - Date.now();
if (diffMs < 60_000) {
// [Gitea #275] Say so as soon as a too-late time is picked, not on submit.
const tooFar = diffMs > MAX_SCHEDULE_AHEAD_MS;
setError((e) => {
if (tooFar) return SCHEDULE_TOO_FAR_TEXT;
return e === SCHEDULE_TOO_FAR_TEXT ? null : e;
});
if (diffMs < 60_000 || tooFar) {
setPreview(null);
return;
}
@@ -149,6 +160,10 @@ export function ScheduleMessageModal({
setError('Scheduled time must be at least 1 minute in the future.');
return;
}
if (diffMs > MAX_SCHEDULE_AHEAD_MS) {
setError(SCHEDULE_TOO_FAR_TEXT);
return;
}
if (!messageText.trim()) {
setError('Please enter a message to schedule.');
return;
@@ -162,7 +177,7 @@ export function ScheduleMessageModal({
onScheduled(delayId, sendAt.getTime(), content);
onClose();
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to schedule message.');
setError(describeScheduleError(err));
setSubmitting(false);
}
};
@@ -247,6 +262,8 @@ export function ScheduleMessageModal({
<input
id="schedule-date"
type="date"
min={toLocalDate(new Date())}
max={toLocalDate(new Date(Date.now() + MAX_SCHEDULE_AHEAD_MS))}
value={dateValue}
onChange={(e) => setDateValue(e.target.value)}
style={pickerInputStyle(color, config)}
@@ -294,7 +311,8 @@ export function ScheduleMessageModal({
</Box>
</Box>
) : (
(dateValue || timeValue) && (
(dateValue || timeValue) &&
error !== SCHEDULE_TOO_FAR_TEXT && (
<Text size="T200" style={{ color: color.Critical.Main }}>
Must be at least 1 minute in the future
</Text>
+12 -1
View File
@@ -1,4 +1,4 @@
import { style } from '@vanilla-extract/css';
import { globalStyle, style } from '@vanilla-extract/css';
import { DefaultReset, FocusOutline, color, config, toRem } from 'folds';
export const MessageBase = style({
@@ -77,3 +77,14 @@ export const ReactionsMore = style([
export const ReactionsTooltipText = style({
wordBreak: 'break-word',
});
// [Gitea #199] Long-press opens the message action sheet on touch screens. On
// iOS a long-press otherwise belongs to the system: a link/image callout, or
// the text-selection loupe, both of which race (and win against) the 450 ms
// press. No callout on message rows, and no selection while a finger is
// down; copying text is in the sheet.
globalStyle('[data-touch-actions]', { WebkitTouchCallout: 'none' });
globalStyle('[data-touch-actions][data-pressing], [data-touch-actions][data-pressing] *', {
userSelect: 'none',
WebkitUserSelect: 'none',
});
@@ -531,7 +531,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
No Pinned Messages
</Text>
<Text size="T400" align="Center">
Users with sufficient power level can pin a messages from its context menu.
Users with sufficient power level can pin a message from its context menu.
</Text>
</Box>
</Box>
@@ -1,8 +1,9 @@
import { style } from '@vanilla-extract/css';
import { config, toRem } from 'folds';
import { config } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../../styles/sidePanel';
export const ThreadPanel = style({
width: toRem(360),
width: SIDE_PANEL_WIDTH,
'@media': {
'(max-width: 750px)': {
position: 'fixed',
@@ -1,8 +1,9 @@
import { style } from '@vanilla-extract/css';
import { color, config, toRem } from 'folds';
import { color, config } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../../styles/sidePanel';
export const ThreadsListPanel = style({
width: toRem(340),
width: SIDE_PANEL_WIDTH,
'@media': {
'(max-width: 750px)': {
position: 'fixed',
@@ -0,0 +1,76 @@
import React, { useEffect, useSyncExternalStore } from 'react';
import { Box, color, config, Icon, IconButton, Icons, Text } from 'folds';
import { useSetAtom } from 'jotai';
import {
destroyAllWidgetSessions,
destroyWidgetSession,
FLOATING_WIDGET,
floatingWidgetSessions,
subscribeWidgetSessions,
widgetSessionsVersion,
} from './widgetSessions';
import { useRoomNavigate } from '../../../hooks/useRoomNavigate';
import { widgetViewingAtom, widgetsPanelAtom } from '../../../state/widgetsPanel';
import { zIndices } from '../../../styles/zIndex';
/**
* [Gitea #205] Title bar for a widget kept on screen (MSC2931) after its room
* or the Widgets panel was left. The widget's own frame is positioned by
* widgetSessions.ts right below this bar. Mounted once for the signed-in
* client; unmounting (logout) stops every widget.
*/
export function FloatingWidget() {
useSyncExternalStore(subscribeWidgetSessions, widgetSessionsVersion);
const { navigateRoom } = useRoomNavigate();
const setPanel = useSetAtom(widgetsPanelAtom);
const setViewing = useSetAtom(widgetViewingAtom);
useEffect(() => () => destroyAllWidgetSessions(), []);
const session = floatingWidgetSessions()[0];
if (!session) return null;
const f = FLOATING_WIDGET;
const back = () => {
setViewing((prev) => ({ ...prev, [session.roomId]: session.widgetId }));
setPanel(true);
navigateRoom(session.roomId);
};
return (
<Box
role="region"
aria-label={`${session.name} (kept on screen)`}
alignItems="Center"
gap="100"
style={{
position: 'fixed',
right: f.right,
bottom: f.bottom + f.height,
width: f.width,
height: f.bar,
zIndex: zIndices.floatingWidget,
padding: `0 ${config.space.S100} 0 ${config.space.S300}`,
background: color.Surface.Container,
color: color.Surface.OnContainer,
borderRadius: '8px 8px 0 0',
boxShadow: '0 8px 24px rgba(0,0,0,0.35)',
}}
>
<Icon size="100" src={Icons.Category} />
<Text size="T300" truncate style={{ flexGrow: 1 }}>
{session.name}
</Text>
<IconButton size="300" radii="300" variant="Surface" aria-label="Back to room" onClick={back}>
<Icon size="100" src={Icons.ArrowGoLeft} />
</IconButton>
<IconButton
size="300"
radii="300"
variant="Surface"
aria-label={`Close ${session.name}`}
onClick={() => destroyWidgetSession(session.key)}
>
<Icon size="100" src={Icons.Cross} />
</IconButton>
</Box>
);
}
+34 -124
View File
@@ -1,138 +1,48 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useSyncExternalStore } from 'react';
import { Box, Icon, Icons, Text, color } from 'folds';
import {
MatrixEvent,
MatrixEventEvent,
Room,
RoomEvent,
RoomEventHandlerMap,
RoomStateEvent,
} from 'matrix-js-sdk';
import { Capability, ClientWidgetApi, IRoomEvent, Widget } from 'matrix-widget-api';
import { Room } from 'matrix-js-sdk';
import { Widget } from 'matrix-widget-api';
import { useMatrixClient } from '../../../hooks/useMatrixClient';
import { GeneralWidgetDriver } from './GeneralWidgetDriver';
import { WidgetPermissionRequest, isWidgetUrlSafe } from './widgetUtils';
import { restrictWidgetMessages } from '../../../plugins/widgetTransport';
import { WidgetPermissionPrompt } from './WidgetPermissionPrompt';
import { isFromFilteredTimelineSet } from '../../../utils/room';
type PendingAsk = {
requests: WidgetPermissionRequest[];
origin: string;
resolve: (allowed: Set<Capability>, remember: boolean) => void;
};
import {
attachWidgetSession,
detachWidgetSession,
getWidgetSession,
subscribeWidgetSessions,
widgetSessionKey,
widgetSessionsVersion,
} from './widgetSessions';
type RoomWidgetViewProps = {
room: Room;
widget: Widget;
};
// Hosts one room widget in a sandboxed iframe via ClientWidgetApi (so widgets
// that wait on the client handshake load). Display-only access is granted
// silently; reading/sending in this room is asked for (WidgetPermissionPrompt)
// and, once granted, the room's live events are fed to the widget.
// Re-mounts only when the widget id or its (template) URL changes — not on every
// unrelated room-state update — so viewing a widget doesn't reload constantly.
// Shows one room widget in the Widgets panel. The widget itself runs in a
// session (widgetSessions.ts) whose sandboxed iframe lives in an app-level
// layer and is positioned over this placeholder, so a widget that asked to
// stay on screen can keep running in a floating window after the panel closes.
// Display-only access is granted silently; reading/sending in this room is
// asked for (WidgetPermissionPrompt) and, once granted, the room's live events
// are fed to the widget. Re-attaches only when the widget id or its (template)
// URL changes, so viewing a widget doesn't reload it on unrelated state updates.
export function RoomWidgetView({ room, widget }: RoomWidgetViewProps) {
const mx = useMatrixClient();
const containerRef = useRef<HTMLDivElement>(null);
const slotRef = useRef<HTMLDivElement>(null);
const widgetRef = useRef(widget);
widgetRef.current = widget;
const [blocked, setBlocked] = useState(false);
const [pendingAsk, setPendingAsk] = useState<PendingAsk>();
const key = widgetSessionKey(room.roomId, widget.id);
useSyncExternalStore(subscribeWidgetSessions, widgetSessionsVersion);
const session = getWidgetSession(key);
useEffect(() => {
const container = containerRef.current;
if (!container) return undefined;
const current = widgetRef.current;
const slot = slotRef.current;
if (!slot) return undefined;
attachWidgetSession(mx, room, widgetRef.current, slot);
return () => detachWidgetSession(key, slot);
}, [mx, room, key, widget.templateUrl]);
const completeUrl = current.getCompleteUrl({
currentUserId: mx.getSafeUserId(),
widgetRoomId: room.roomId,
deviceId: mx.getDeviceId() ?? undefined,
baseUrl: mx.baseUrl,
});
// Security: never render a same-origin widget with allow-same-origin (a
// same-origin frame could break out of the sandbox against our own origin).
if (!isWidgetUrlSafe(completeUrl, window.location.origin)) {
setBlocked(true);
return undefined;
}
setBlocked(false);
const iframe = document.createElement('iframe');
iframe.title = current.name || 'Widget';
iframe.sandbox.value =
'allow-forms allow-scripts allow-same-origin allow-popups allow-downloads';
iframe.allow = 'autoplay; clipboard-write;';
iframe.src = completeUrl;
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
container.append(iframe);
let origin = completeUrl;
try {
origin = new URL(completeUrl).host;
} catch {
// isWidgetUrlSafe already rejected unparsable URLs
}
let cancelAsk: (() => void) | undefined;
const driver = new GeneralWidgetDriver(
mx,
room.roomId,
{ id: current.id, url: current.templateUrl },
(requests) =>
new Promise((resolve) => {
let settled = false;
const done = (allowed: Set<Capability>, remember: boolean) => {
if (settled) return;
settled = true;
cancelAsk = undefined;
setPendingAsk(undefined);
resolve({ allowed, remember });
};
cancelAsk = () => done(new Set(), false);
setPendingAsk({ requests, origin, resolve: done });
}),
);
const clientApi = new ClientWidgetApi(current, iframe, driver);
// Only messages from this widget's own frame and origin are handled, so a
// widget can't impersonate another one (or the call).
restrictWidgetMessages(clientApi, iframe, current.origin);
clientApi.setViewedRoomId(room.roomId);
// Live room events for widgets that were allowed to see them
// (ClientWidgetApi drops anything the widget has no capability for).
const feed = (ev: MatrixEvent) => {
if (ev.getRoomId() !== room.roomId) return;
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
clientApi.feedEvent(ev.getEffectiveEvent() as IRoomEvent).catch(() => undefined);
};
const onTimeline: RoomEventHandlerMap[RoomEvent.Timeline] = (ev, r, toStart, removed, data) => {
if (toStart || removed || !data?.liveEvent) return;
if (isFromFilteredTimelineSet(data)) return; // [Gitea #259] don't feed widgets each event twice
if (ev.isBeingDecrypted()) ev.once(MatrixEventEvent.Decrypted, feed);
else feed(ev);
};
const onState = (ev: MatrixEvent) => {
if (ev.getRoomId() !== room.roomId) return;
clientApi.feedStateUpdate(ev.getEffectiveEvent() as IRoomEvent).catch(() => undefined);
};
mx.on(RoomEvent.Timeline, onTimeline);
mx.on(RoomStateEvent.Events, onState);
return () => {
mx.off(RoomEvent.Timeline, onTimeline);
mx.off(RoomStateEvent.Events, onState);
cancelAsk?.();
clientApi.stop();
iframe.remove();
};
}, [mx, room.roomId, widget.id, widget.templateUrl]);
if (blocked) {
if (session?.blocked) {
return (
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="200">
<Icon size="400" src={Icons.Warning} style={{ color: color.Warning.Main }} />
@@ -149,14 +59,14 @@ export function RoomWidgetView({ room, widget }: RoomWidgetViewProps) {
return (
<>
<Box ref={containerRef} grow="Yes" style={{ height: '100%', minHeight: 0 }} />
{pendingAsk && (
<Box ref={slotRef} grow="Yes" style={{ height: '100%', minHeight: 0 }} />
{session?.pendingAsk && (
<WidgetPermissionPrompt
widgetName={widget.name || 'Widget'}
origin={pendingAsk.origin}
origin={session.pendingAsk.origin}
addedBy={addedBy}
requests={pendingAsk.requests}
onDone={pendingAsk.resolve}
requests={session.pendingAsk.requests}
onDone={session.pendingAsk.resolve}
/>
)}
</>
@@ -1,8 +1,9 @@
import { style } from '@vanilla-extract/css';
import { config, toRem } from 'folds';
import { config } from 'folds';
import { SIDE_PANEL_WIDTH } from '../../../styles/sidePanel';
export const WidgetsPanel = style({
width: toRem(360),
width: SIDE_PANEL_WIDTH,
'@media': {
'(max-width: 750px)': {
position: 'fixed',
+50 -3
View File
@@ -16,7 +16,9 @@ import {
config,
} from 'folds';
import { Room } from 'matrix-js-sdk';
import { useAtom } from 'jotai';
import classNames from 'classnames';
import { widgetViewingAtom } from '../../../state/widgetsPanel';
import * as css from './WidgetsPanel.css';
import { ContainerColor } from '../../../styles/ContainerColor.css';
import { RoomWidgetView } from './RoomWidgetView';
@@ -27,7 +29,13 @@ import { useRoomCreators } from '../../../hooks/useRoomCreators';
import { useRoomPermissions } from '../../../hooks/useRoomPermissions';
import { StateEvent } from '../../../../types/matrix/room';
import { sendStateEvent } from '../../../utils/room';
import { generateWidgetId, validateWidgetUrl, WidgetUrlError } from './widgetUtils';
import {
generateWidgetId,
validateWidgetUrl,
widgetCompleteUrl,
widgetPopoutUrl,
WidgetUrlError,
} from './widgetUtils';
const urlErrorMessage = (err: WidgetUrlError): string => {
switch (err) {
@@ -54,12 +62,23 @@ export function WidgetsPanel({ room, requestClose }: WidgetsPanelProps) {
const permissions = useRoomPermissions(creators, powerLevels);
const canModify = permissions.stateEvent(StateEvent.Widget, mx.getSafeUserId());
const [viewingId, setViewingId] = useState<string | null>(null);
const [viewingByRoom, setViewingByRoom] = useAtom(widgetViewingAtom);
const viewingId = viewingByRoom[room.roomId] ?? null;
const setViewingId = (id: string | null) =>
setViewingByRoom((prev) => ({ ...prev, [room.roomId]: id }));
const [adding, setAdding] = useState(false);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string>();
const viewing = widgets.find((w) => w.id === viewingId) ?? null;
// [Gitea #205] Open a widget in its own window, beside the chat. It runs
// standalone there (no widget API), as in Element's popout.
const popoutUrl = (widget: (typeof widgets)[number]) =>
widgetPopoutUrl(widgetCompleteUrl(widget, mx, room.roomId), window.location.origin);
const popout = (widget: (typeof widgets)[number]) => {
const url = popoutUrl(widget);
if (url) window.open(url, '_blank', 'noopener,noreferrer');
};
const handleAdd: FormEventHandler<HTMLFormElement> = async (evt) => {
evt.preventDefault();
@@ -144,7 +163,13 @@ export function WidgetsPanel({ room, requestClose }: WidgetsPanelProps) {
<Box grow="Yes" className={css.WidgetsPanelContent}>
{viewing ? (
<Box grow="Yes" direction="Column">
<Box shrink="No" style={{ padding: config.space.S200 }}>
<Box
shrink="No"
alignItems="Center"
justifyContent="SpaceBetween"
gap="200"
style={{ padding: config.space.S200 }}
>
<Button
variant="Secondary"
fill="Soft"
@@ -157,6 +182,17 @@ export function WidgetsPanel({ room, requestClose }: WidgetsPanelProps) {
{viewing.name || 'Widget'}
</Text>
</Button>
{popoutUrl(viewing) && (
<IconButton
size="300"
radii="300"
variant="Background"
aria-label={`Open ${viewing.name || 'widget'} in a new window`}
onClick={() => popout(viewing)}
>
<Icon size="100" src={Icons.External} />
</IconButton>
)}
</Box>
<RoomWidgetView room={room} widget={viewing} />
</Box>
@@ -184,6 +220,17 @@ export function WidgetsPanel({ room, requestClose }: WidgetsPanelProps) {
{widget.name || widget.templateUrl}
</Text>
</Box>
{popoutUrl(widget) && (
<IconButton
size="300"
radii="300"
variant="Background"
aria-label={`Open ${widget.name || 'widget'} in a new window`}
onClick={() => popout(widget)}
>
<Icon size="100" src={Icons.External} />
</IconButton>
)}
{canModify && (
<IconButton
size="300"
@@ -0,0 +1,341 @@
import {
MatrixClient,
MatrixEvent,
MatrixEventEvent,
Room,
RoomEvent,
RoomEventHandlerMap,
RoomStateEvent,
} from 'matrix-js-sdk';
import {
Capability,
ClientWidgetApi,
IRoomEvent,
IWidgetApiRequest,
MatrixCapabilities,
Widget,
WidgetApiFromWidgetAction,
} from 'matrix-widget-api';
import { GeneralWidgetDriver } from './GeneralWidgetDriver';
import { WidgetPermissionRequest, isWidgetUrlSafe, widgetCompleteUrl } from './widgetUtils';
import { restrictWidgetMessages } from '../../../plugins/widgetTransport';
import { isFromFilteredTimelineSet } from '../../../utils/room';
import { zIndices } from '../../../styles/zIndex';
/**
* [Gitea #205] Running room widgets, kept outside React so a widget that asked
* to stay on screen (MSC2931 `set_always_on_screen`) survives closing the
* Widgets panel or switching rooms.
*
* Moving an iframe in the DOM reloads it, so every widget frame lives from the
* start in one app-level fixed layer. While the panel shows the widget, the
* frame is positioned over the panel's placeholder (`attach`), so it looks and
* behaves as before. When the placeholder goes away (`detach`) the widget is
* torn down, unless it is always-on-screen: then the same live frame moves to
* a small floating window (see FloatingWidget) until it is closed, the widget
* says it no longer needs to be on screen, or it is removed from the room.
*/
export type PendingAsk = {
requests: WidgetPermissionRequest[];
origin: string;
resolve: (allowed: Set<Capability>, remember: boolean) => void;
};
export type WidgetSession = {
readonly key: string;
readonly roomId: string;
readonly widgetId: string;
readonly name: string;
readonly templateUrl: string;
/** The URL is on this app's own origin: never rendered. */
readonly blocked: boolean;
alwaysOnScreen: boolean;
floating: boolean;
pendingAsk?: PendingAsk;
};
type Internal = WidgetSession & {
frame: HTMLDivElement;
slot: HTMLElement | null;
raf: number | undefined;
stop: () => void;
};
/** The floating window's geometry (FloatingWidget draws its title bar above). */
export const FLOATING_WIDGET = { right: 16, bottom: 96, width: 360, height: 240, bar: 36 };
const DOCKED_Z = 600; // just above the side panel (500 on phones), below popovers/modals
const sessions = new Map<string, Internal>();
const listeners = new Set<() => void>();
let version = 0;
const notify = () => {
version += 1;
listeners.forEach((l) => l());
};
export const subscribeWidgetSessions = (l: () => void): (() => void) => {
listeners.add(l);
return () => listeners.delete(l);
};
export const widgetSessionsVersion = (): number => version;
export const widgetSessionKey = (roomId: string, widgetId: string): string =>
`${roomId}|${widgetId}`;
export const getWidgetSession = (key: string): WidgetSession | undefined => sessions.get(key);
export const floatingWidgetSessions = (): WidgetSession[] =>
[...sessions.values()].filter((s) => s.floating);
let layerEl: HTMLDivElement | undefined;
const layer = (): HTMLDivElement => {
if (!layerEl || !layerEl.isConnected) {
layerEl = document.createElement('div');
layerEl.id = 'lotus-widget-layer';
// The layer itself is click-through; only the frames inside take input.
Object.assign(layerEl.style, { position: 'fixed', inset: '0', pointerEvents: 'none' });
document.body.append(layerEl);
}
return layerEl;
};
const hideFrame = (s: Internal) => {
s.frame.style.visibility = 'hidden';
};
const placeDocked = (s: Internal) => {
const slot = s.slot;
if (!slot) return;
const r = slot.getBoundingClientRect();
if (r.width === 0 || r.height === 0) {
hideFrame(s);
} else {
Object.assign(s.frame.style, {
visibility: 'visible',
left: `${r.left}px`,
top: `${r.top}px`,
width: `${r.width}px`,
height: `${r.height}px`,
right: '',
bottom: '',
borderRadius: '0',
boxShadow: 'none',
zIndex: String(DOCKED_Z),
});
}
s.raf = requestAnimationFrame(() => placeDocked(s));
};
const placeFloating = (s: Internal) => {
const f = FLOATING_WIDGET;
Object.assign(s.frame.style, {
visibility: 'visible',
left: '',
top: '',
right: `${f.right}px`,
bottom: `${f.bottom}px`,
width: `${f.width}px`,
height: `${f.height}px`,
borderRadius: '0 0 8px 8px',
boxShadow: '0 8px 24px rgba(0,0,0,0.35)',
zIndex: String(zIndices.floatingWidget),
});
};
const stopPlacing = (s: Internal) => {
if (s.raf !== undefined) cancelAnimationFrame(s.raf);
s.raf = undefined;
};
export const destroyWidgetSession = (key: string): void => {
const s = sessions.get(key);
if (!s) return;
sessions.delete(key);
stopPlacing(s);
s.stop();
s.frame.remove();
notify();
};
export const destroyAllWidgetSessions = (): void => {
[...sessions.keys()].forEach(destroyWidgetSession);
};
/** Start (or reuse) the widget's session and dock its frame over `slot`. */
export function attachWidgetSession(
mx: MatrixClient,
room: Room,
widget: Widget,
slot: HTMLElement,
): WidgetSession {
const key = widgetSessionKey(room.roomId, widget.id);
let s = sessions.get(key);
if (s && s.templateUrl !== widget.templateUrl) {
destroyWidgetSession(key);
s = undefined;
}
if (!s) s = startSession(mx, room, widget, key);
stopPlacing(s);
s.slot = slot;
s.floating = false;
if (!s.blocked) placeDocked(s);
notify();
return s;
}
/** The panel stopped showing the widget: float it, or tear it down. */
export function detachWidgetSession(key: string, slot: HTMLElement): void {
const s = sessions.get(key);
if (!s || s.slot !== slot) return;
s.slot = null;
stopPlacing(s);
if (!s.alwaysOnScreen || s.blocked) {
destroyWidgetSession(key);
return;
}
// One floating widget at a time: a newer one replaces an older one.
floatingWidgetSessions()
.filter((o) => o.key !== key)
.forEach((o) => destroyWidgetSession(o.key));
// Nobody is there to answer a permission prompt any more.
s.pendingAsk?.resolve(new Set(), false);
s.floating = true;
placeFloating(s);
notify();
}
function startSession(mx: MatrixClient, room: Room, widget: Widget, key: string): Internal {
const frame = document.createElement('div');
Object.assign(frame.style, {
position: 'fixed',
pointerEvents: 'auto',
overflow: 'hidden',
visibility: 'hidden',
});
const completeUrl = widgetCompleteUrl(widget, mx, room.roomId);
const blocked = !isWidgetUrlSafe(completeUrl, window.location.origin);
const s: Internal = {
key,
roomId: room.roomId,
widgetId: widget.id,
name: widget.name || 'Widget',
templateUrl: widget.templateUrl,
blocked,
alwaysOnScreen: false,
floating: false,
frame,
slot: null,
raf: undefined,
stop: () => undefined,
};
sessions.set(key, s);
if (blocked) return s;
// Security: never render a same-origin widget with allow-same-origin (a
// same-origin frame could break out of the sandbox against our own origin).
const iframe = document.createElement('iframe');
iframe.title = widget.name || 'Widget';
iframe.sandbox.value = 'allow-forms allow-scripts allow-same-origin allow-popups allow-downloads';
iframe.allow = 'autoplay; clipboard-write;';
iframe.src = completeUrl;
Object.assign(iframe.style, { width: '100%', height: '100%', border: 'none' });
frame.append(iframe);
layer().append(frame);
let origin = completeUrl;
try {
origin = new URL(completeUrl).host;
} catch {
// isWidgetUrlSafe already rejected unparsable URLs
}
let cancelAsk: (() => void) | undefined;
const driver = new GeneralWidgetDriver(
mx,
room.roomId,
{ id: widget.id, url: widget.templateUrl },
(requests) =>
new Promise((resolve) => {
let settled = false;
const done = (allowed: Set<Capability>, remember: boolean) => {
if (settled) return;
settled = true;
cancelAsk = undefined;
s.pendingAsk = undefined;
notify();
resolve({ allowed, remember });
};
cancelAsk = () => done(new Set(), false);
// A floating widget has nobody to ask: grant nothing extra.
if (s.floating) {
done(new Set(), false);
return;
}
s.pendingAsk = { requests, origin, resolve: done };
notify();
}),
);
const clientApi = new ClientWidgetApi(widget, iframe, driver);
// Only messages from this widget's own frame and origin are handled, so a
// widget can't impersonate another one (or the call).
restrictWidgetMessages(clientApi, iframe, widget.origin);
clientApi.setViewedRoomId(room.roomId);
// MSC2931: the widget asks to stay visible when the user navigates away.
const onAlwaysOnScreen = (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();
if (!clientApi.hasCapability(MatrixCapabilities.AlwaysOnScreen)) {
clientApi.transport.reply(ev.detail, {
error: { message: 'Missing capability' },
});
return;
}
const value = (ev.detail.data as { value?: unknown } | undefined)?.value === true;
s.alwaysOnScreen = value;
clientApi.transport.reply(ev.detail, {});
// Floating only because it asked: once it no longer needs to be, go.
if (!value && s.floating) destroyWidgetSession(key);
else notify();
};
clientApi.on(`action:${WidgetApiFromWidgetAction.UpdateAlwaysOnScreen}`, onAlwaysOnScreen);
// Live room events for widgets that were allowed to see them
// (ClientWidgetApi drops anything the widget has no capability for).
const feed = (ev: MatrixEvent) => {
if (ev.getRoomId() !== room.roomId) return;
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
clientApi.feedEvent(ev.getEffectiveEvent() as IRoomEvent).catch(() => undefined);
};
const onTimeline: RoomEventHandlerMap[RoomEvent.Timeline] = (ev, r, toStart, removed, data) => {
if (toStart || removed || !data?.liveEvent) return;
if (isFromFilteredTimelineSet(data)) return; // [Gitea #259] don't feed widgets each event twice
if (ev.isBeingDecrypted()) ev.once(MatrixEventEvent.Decrypted, feed);
else feed(ev);
};
const onState = (ev: MatrixEvent) => {
if (ev.getRoomId() !== room.roomId) return;
// The widget was removed from the room while it was floating.
if (
s.floating &&
(ev.getType() === 'im.vector.modular.widgets' || ev.getType() === 'm.widget') &&
ev.getStateKey() === widget.id &&
!ev.getContent()?.url
) {
destroyWidgetSession(key);
return;
}
clientApi.feedStateUpdate(ev.getEffectiveEvent() as IRoomEvent).catch(() => undefined);
};
mx.on(RoomEvent.Timeline, onTimeline);
mx.on(RoomStateEvent.Events, onState);
s.stop = () => {
mx.off(RoomEvent.Timeline, onTimeline);
mx.off(RoomStateEvent.Events, onState);
clientApi.off(`action:${WidgetApiFromWidgetAction.UpdateAlwaysOnScreen}`, onAlwaysOnScreen);
cancelAsk?.();
clientApi.stop();
};
return s;
}
@@ -8,6 +8,7 @@ import {
generateWidgetId,
classifyWidgetCapabilities,
loadWidgetConsent,
widgetPopoutUrl,
} from './widgetUtils';
const APP = 'https://chat.lotusguild.org';
@@ -106,3 +107,33 @@ test('classifyWidgetCapabilities: reading protected state is fine, changing unpr
test('loadWidgetConsent tolerates missing storage', () => {
assert.equal(loadWidgetConsent('!r:x', 'w', 'https://w.example'), undefined);
});
test('[#266] space structure, call membership and Lotus room policy can never be granted', () => {
const { auto, ask } = classifyWidgetCapabilities(
[
'm.space.child',
'm.space.parent',
'org.matrix.msc3401.call',
'org.matrix.msc3401.call.member',
'm.call.member',
'io.lotus.voice_limit',
'io.lotus.room_quality',
].map((t) => `org.matrix.msc2762.send.state_event:${t}`),
);
assert.equal(auto.size, 0);
assert.deepEqual(ask, []);
});
test('[#205] widgetPopoutUrl: only cross-origin https opens in a new window', () => {
// Built at runtime so the no-script-url lint rule doesn't flag the test data.
const scriptUrl = ['javascript', 'alert(1)'].join(':');
assert.equal(
widgetPopoutUrl('https://pad.example.org/p/room', APP),
'https://pad.example.org/p/room',
);
assert.equal(widgetPopoutUrl('https://chat.lotusguild.org/evil', APP), null, 'same origin');
assert.equal(widgetPopoutUrl('http://pad.example.org/', APP), null, 'not https');
assert.equal(widgetPopoutUrl(scriptUrl, APP), null, 'script URL');
assert.equal(widgetPopoutUrl('data:text/html,<b>x</b>', APP), null, 'data:');
assert.equal(widgetPopoutUrl('not a url', APP), null);
});
+39 -1
View File
@@ -1,8 +1,10 @@
import type { MatrixClient } from 'matrix-js-sdk';
import {
Capability,
EventDirection,
EventKind,
MatrixCapabilities,
type Widget,
WidgetEventCapability,
} from 'matrix-widget-api';
@@ -48,6 +50,29 @@ export const isWidgetUrlSafe = (completeUrl: string, appOrigin: string): boolean
}
};
/** The widget's URL with its template variables filled in for this viewer. */
export const widgetCompleteUrl = (widget: Widget, mx: MatrixClient, roomId: string): string =>
widget.getCompleteUrl({
currentUserId: mx.getSafeUserId(),
widgetRoomId: roomId,
deviceId: mx.getDeviceId() ?? undefined,
baseUrl: mx.baseUrl,
});
/**
* [Gitea #205] The URL to open a widget in its own window, or null when it
* mustn't be opened: only cross-origin https (room state can carry anything,
* e.g. a `javascript:` URL from another client, whose origin is "null").
*/
export const widgetPopoutUrl = (completeUrl: string, appOrigin: string): string | null => {
try {
const u = new URL(completeUrl);
return u.protocol === 'https:' && u.origin !== appOrigin ? u.href : null;
} catch {
return null;
}
};
export const generateWidgetId = (): string =>
`lotus_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
@@ -67,6 +92,16 @@ export const PROTECTED_STATE_TYPES: ReadonlySet<string> = new Set([
'm.room.third_party_invite',
'im.vector.modular.widgets',
'm.widget',
// [Gitea #266] Space structure, call membership and Lotus room policy: a
// widget could restructure a space, fake call membership or lift the
// voice-channel limit, so these can't be granted even with consent.
'm.space.child',
'm.space.parent',
'org.matrix.msc3401.call',
'org.matrix.msc3401.call.member',
'm.call.member',
'io.lotus.voice_limit',
'io.lotus.room_quality',
]);
export type WidgetPermissionRequest = {
@@ -137,8 +172,11 @@ export const classifyWidgetCapabilities = (
*/
export type StoredWidgetConsent = { url: string; allowed: Capability[]; denied: Capability[] };
// [Gitea #266] Swept on logout by clearPlaintextCaches, so one account's
// approvals never apply to the next account on the same device.
export const WIDGET_CONSENT_PREFIX = 'lotus.widgetConsent.';
export const widgetConsentKey = (roomId: string, widgetId: string): string =>
`lotus.widgetConsent.${roomId}.${widgetId}`;
`${WIDGET_CONSENT_PREFIX}${roomId}.${widgetId}`;
export const loadWidgetConsent = (
roomId: string,
+47
View File
@@ -8,6 +8,7 @@ import { getOriginBaseUrl, withOriginBaseUrl } from '../../../pages/pathUtils';
import pkg from '../../../../../package.json';
import { clearCacheAndReload } from '../../../../client/initMatrix';
import { useMatrixClient } from '../../../hooks/useMatrixClient';
import { tauriInvoke } from '../../../hooks/useTauri';
const LotusLogo = withOriginBaseUrl(getOriginBaseUrl(), '/public/res/lotus-logo.png');
@@ -78,6 +79,51 @@ function useServerSupport(): { support: MSC1929Support | null; loading: boolean
type AboutProps = {
requestClose: () => void;
};
/**
* [Gitea #276] Which build someone is on: the web deploy's commit and build
* date (stamped in by vite.config.js), plus the desktop app's own version from
* Tauri, the number a desktop or updater bug report needs.
*/
function BuildInfo() {
const [desktopVersion, setDesktopVersion] = useState<string>();
useEffect(() => {
tauriInvoke()?.('plugin:app|version')
.then((v) => {
if (typeof v === 'string') setDesktopVersion(v);
})
.catch(() => undefined);
}, []);
const commit = __LOTUS_BUILD_COMMIT__;
const built = new Date(__LOTUS_BUILD_DATE__);
const builtText = Number.isNaN(built.getTime())
? undefined
: built.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });
return (
<Box direction="Column" gap="0">
{desktopVersion && (
<Text size="T200" priority="300">
Desktop {desktopVersion}
</Text>
)}
<Text size="T200" priority="300">
Web build{' '}
{commit !== 'unknown' ? (
<a
href={`https://code.lotusguild.org/LotusGuild/cinny/commit/${commit}`}
target="_blank"
rel="noreferrer noopener"
>
{commit}
</a>
) : (
commit
)}
{builtText && ` · built ${builtText}`}
</Text>
</Box>
);
}
export function About({ requestClose }: AboutProps) {
const mx = useMatrixClient();
const { support: serverSupport, loading: supportLoading } = useServerSupport();
@@ -117,6 +163,7 @@ export function About({ requestClose }: AboutProps) {
<Text size="T200">v{pkg.version}</Text>
</Box>
<Text>A Matrix client for Lotus Guild.</Text>
<BuildInfo />
</Box>
<Box gap="200" wrap="Wrap">
+14 -1
View File
@@ -1749,6 +1749,7 @@ function Calls() {
);
const [pttMode, setPttMode] = useSetting(settingsAtom, 'pttMode');
const [callSummaryToast, setCallSummaryToast] = useSetting(settingsAtom, 'callSummaryToast');
const [callRejoin, setCallRejoin] = useSetting(settingsAtom, 'callRejoinAfterRestart');
const [haptics, setHaptics] = useSetting(settingsAtom, 'hapticFeedback');
const [pttKey, setPttKey] = useSetting(settingsAtom, 'pttKey');
@@ -2062,6 +2063,13 @@ function Calls() {
/>
}
/>
<SettingTile
title="Summary After Calls"
description="When a call ends, show how long it was and how the connection held up, with a Details button for who was there, network numbers and your own talk/mute time."
after={
<Switch variant="Primary" value={callSummaryToast} onChange={setCallSummaryToast} />
}
/>
{hapticsSupported() && (
<SettingTile
title="Haptic Feedback"
@@ -2098,7 +2106,12 @@ function Calls() {
description={
deafenBind.error ??
(deafenHotkey
? `Press ${keyLabel(deafenKey)} during a call to mute your speakers. Press Escape to cancel rebind.${
? `${
// [Gitea #279] The Escape hint only applies while rebinding.
deafenBind.listening
? 'Press a key to bind it, or Escape to cancel.'
: `Press ${keyLabel(deafenKey)} during a call to mute your speakers.`
}${
!isSafeGlobalToggleKey(deafenKey)
? ` A letter, digit or Space only works in the call view — on a chat screen typing takes priority${
isTauriEnv() && globalCallHotkeys ? ' and other apps are never watched' : ''
@@ -98,7 +98,7 @@ export function NotificationModeSwitcher({ pushRule, onChange }: NotificationMod
key={mode}
size="300"
variant="Surface"
aria-selected={mode === selectedMode}
aria-pressed={mode === selectedMode}
radii="300"
onClick={() => handleSelect(mode)}
>
@@ -21,7 +21,7 @@ function RenderSettings({ state }: RenderSettingsProps) {
if (!room) return null;
return (
<Modal500 requestClose={closeSettings}>
<Modal500 requestClose={closeSettings} label={`${room.name} space settings`}>
<SpaceProvider value={space ?? null}>
<RoomProvider value={room}>
<SpaceSettings initialPage={page} requestClose={closeSettings} />
+27 -5
View File
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, CSSProperties } from 'react';
import { useAtomValue, useSetAtom } from 'jotai';
import { color, config, Icon, IconButton, Icons } from 'folds';
import { Button, color, config, Icon, IconButton, Icons, Text } from 'folds';
import { ScreenSize, useScreenSize } from '../../hooks/useScreenSize';
import { toastQueueAtom, dismissToastAtom, ToastNotif } from '../../state/toast';
import { useSetting } from '../../state/hooks/settings';
@@ -43,13 +43,17 @@ function ToastCard({ toast }: ToastCardProps) {
useEffect(() => {
if (toast.sticky) return;
timerRef.current = setTimeout(() => {
dismiss(toast.id);
}, 4000);
timerRef.current = setTimeout(
() => {
dismiss(toast.id);
},
// [Gitea #253] A toast with a button stays long enough to use it.
toast.actionLabel ? 10_000 : 4000,
);
return () => {
if (timerRef.current !== null) clearTimeout(timerRef.current);
};
}, [dismiss, toast.id, toast.sticky]);
}, [dismiss, toast.id, toast.sticky, toast.actionLabel]);
const handleCardClick = () => {
if (toast.onClick) {
@@ -212,6 +216,24 @@ function ToastCard({ toast }: ToastCardProps) {
</div>
<div style={bodyStyle}>{toast.body}</div>
{toast.roomName && <div style={roomNameStyle}>{toast.roomName}</div>}
{toast.actionLabel && toast.onAction && (
<div style={{ marginTop: config.space.S200 }}>
<Button
type="button"
size="300"
radii="300"
variant="Secondary"
fill="Soft"
onClick={(e) => {
e.stopPropagation();
toast.onAction?.();
dismiss(toast.id);
}}
>
<Text size="B300">{toast.actionLabel}</Text>
</Button>
</div>
)}
</div>
);
}
+18 -2
View File
@@ -3,7 +3,10 @@ import { useSetAtom } from 'jotai';
import { CallEmbed } from '../plugins/call';
import { useCallHangupEvent } from './useCallEmbed';
import { toastQueueAtom } from '../state/toast';
import { describeCallEnd } from '../utils/callSummary';
import { describeCallDetails, describeCallEnd } from '../utils/callSummary';
import { callSummaryViewAtom } from '../state/callSummary';
import { useSetting } from '../state/hooks/settings';
import { settingsAtom } from '../state/settings';
// The fork sends io.lotus.call_summary on SFU disconnect, which normally lands
// before Element Call's hangup echo; give a late one this long before toasting.
@@ -16,6 +19,8 @@ const SUMMARY_GRACE_MS = 400;
*/
export function useCallEndedToast(embed: CallEmbed): void {
const setToast = useSetAtom(toastQueueAtom);
const setSummaryView = useSetAtom(callSummaryViewAtom);
const [callSummaryToast] = useSetting(settingsAtom, 'callSummaryToast');
const fired = useRef(false);
useEffect(() => {
@@ -25,14 +30,25 @@ export function useCallEndedToast(embed: CallEmbed): void {
useCallHangupEvent(embed, () => {
if (fired.current || !embed.joined || embed.joinedAt === undefined) return;
fired.current = true;
if (!callSummaryToast) return;
const durationMs = Date.now() - embed.joinedAt;
const deafenedMs = embed.deafenedMs();
const roomName = embed.room.name ?? 'Voice call';
const nameOf = (userId: string) => embed.room.getMember(userId)?.name ?? userId;
const toast = () =>
setToast({
id: `call-ended-${Date.now()}`,
displayName: 'Lotus Chat',
body: describeCallEnd(durationMs, embed.lastSummary),
roomName: embed.room.name ?? 'Voice call',
roomName,
roomId: embed.roomId,
// [Gitea #253] The full breakdown, snapshotted at hangup.
actionLabel: 'Details',
onAction: () =>
setSummaryView({
roomName,
sections: describeCallDetails(embed.lastSummary, durationMs, deafenedMs, nameOf),
}),
});
if (embed.lastSummary) toast();
else setTimeout(toast, SUMMARY_GRACE_MS);
+28 -4
View File
@@ -17,22 +17,37 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
const timer = useRef<number | undefined>(undefined);
const start = useRef<{ x: number; y: number } | null>(null);
const fired = useRef(false);
// [Gitea #199] The element being pressed carries `data-pressing` (set on the
// DOM directly, no re-render) so iOS can't start a text selection under
// the finger; see `[data-touch-actions]` in room/message/styles.css.ts.
const pressed = useRef<HTMLElement | null>(null);
const clear = useCallback(() => {
const stopTimer = useCallback(() => {
if (timer.current !== undefined) window.clearTimeout(timer.current);
timer.current = undefined;
start.current = null;
}, []);
// The finger is up (or the gesture was cancelled): only now drop
// `data-pressing`, so the system selection can't start under a finger that
// is still down after the sheet opened.
const clear = useCallback(() => {
stopTimer();
pressed.current?.removeAttribute('data-pressing');
pressed.current = null;
}, [stopTimer]);
const onTouchStart = useCallback(
(evt: React.TouchEvent) => {
if (!coarse || evt.touches.length !== 1) return;
const t = evt.touches[0];
start.current = { x: t.clientX, y: t.clientY };
fired.current = false;
pressed.current = evt.currentTarget as HTMLElement;
pressed.current.setAttribute('data-pressing', '');
timer.current = window.setTimeout(() => {
const s = start.current;
clear();
stopTimer();
if (!s) return;
fired.current = true;
window.setTimeout(() => {
@@ -41,7 +56,7 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
onLongPress(s.x, s.y);
}, LONG_PRESS_MS);
},
[coarse, clear, onLongPress],
[coarse, stopTimer, onLongPress],
);
const onTouchMove = useCallback(
@@ -72,7 +87,16 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
return {
coarse,
handlers: coarse ? { onTouchStart, onTouchMove, onTouchEnd, onTouchCancel: clear } : {},
handlers: coarse
? {
// [Gitea #199] Marks the element for the iOS hardening CSS.
'data-touch-actions': '',
onTouchStart,
onTouchMove,
onTouchEnd,
onTouchCancel: clear,
}
: {},
/** True for ~1 s after a long-press fired (drop the Android contextmenu echo). */
suppressContextMenu: fired,
};
+1 -1
View File
@@ -46,7 +46,7 @@ const fillMissingPowers = (powerLevels: IPowerLevels): IPowerLevels =>
const keys = Object.keys(DEFAULT_POWER_LEVELS) as unknown as (keyof IPowerLevels)[];
keys.forEach((key) => {
if (draftPl[key] === undefined) {
draftPl[key] = DEFAULT_POWER_LEVELS[key] as any;
(draftPl as Record<string, unknown>)[key] = DEFAULT_POWER_LEVELS[key];
}
});
if (draftPl.notifications && typeof draftPl.notifications.room !== 'number') {
+2
View File
@@ -25,6 +25,7 @@ import { useCompositionEndTracking } from '../hooks/useComposingCheck';
import { settingsAtom } from '../state/settings';
import { isWithinTimeWindow } from '../utils/timeWindow';
import { LotusToastContainer } from '../features/toast/LotusToastContainer';
import { CallSummaryDialog } from '../features/call-summary/CallSummaryDialog';
import { useTauriNotificationBadge } from '../hooks/useTauriNotificationBadge';
import { useSessionAppeared } from '../hooks/useSessionAppeared';
import { useTauriWindowChrome } from '../hooks/useTauriWindowChrome';
@@ -248,6 +249,7 @@ function App() {
<SeasonalEffect />
<NightLightOverlay />
<LotusToastContainer />
<CallSummaryDialog />
</JotaiProvider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
+69
View File
@@ -0,0 +1,69 @@
import React, { useState } from 'react';
import { Box, Button, Text, config } from 'folds';
import { removeFallbackSession } from '../state/sessions';
import type { KeychainBootResult } from '../state/keychainSession';
import type { KeychainInvoke } from '../state/keychainMirror';
/**
* [Gitea #105] Shown instead of the app when the desktop app's sign-in is kept
* in the OS keychain but couldn't be read this time. Never a silent logout:
* Retry boots again; signing in again is an explicit choice.
*/
export function KeychainUnavailable({
boot,
invoke,
}: {
boot: KeychainBootResult;
invoke: KeychainInvoke | undefined;
}) {
const [busy, setBusy] = useState(false);
const missing = boot.mode === 'missing';
const signInAgain = async () => {
setBusy(true);
removeFallbackSession();
await invoke?.('secure_session_clear').catch(() => undefined);
window.location.reload();
};
return (
<Box
direction="Column"
alignItems="Center"
justifyContent="Center"
gap="400"
style={{ minHeight: '100vh', padding: config.space.S700, textAlign: 'center' }}
>
<Text size="H3">Couldn&apos;t read your sign-in</Text>
<Text size="T300" style={{ maxWidth: 460 }}>
{missing
? 'Lotus Chat keeps your sign-in in Windows Credential Manager, but the entry is missing. If you removed it, sign in again.'
: 'Lotus Chat keeps your sign-in in Windows Credential Manager and couldn’t read it just now. This is usually temporary.'}
</Text>
{boot.mode === 'error' && (
<Text size="T200" priority="300">
{boot.error}
</Text>
)}
<Box gap="200">
<Button
variant="Primary"
size="400"
radii="300"
disabled={busy}
onClick={() => window.location.reload()}
>
<Text size="B400">Retry</Text>
</Button>
<Button
variant="Secondary"
fill="Soft"
size="400"
radii="300"
disabled={busy}
onClick={signInAgain}
>
<Text size="B400">Sign in again</Text>
</Button>
</Box>
</Box>
);
}
+2
View File
@@ -68,6 +68,7 @@ import { SHARE_PAGE_PATH } from '../../swShare';
import { RouteError } from './RouteError';
import { CallStatusRenderer } from './CallStatusRenderer';
import { CallEmbedProvider } from '../components/CallEmbedProvider';
import { FloatingWidget } from '../features/room/widgets/FloatingWidget';
const Share = React.lazy(() => import('./client/share/Share').then((m) => ({ default: m.Share })));
@@ -197,6 +198,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
<Outlet />
</ClientLayout>
<CallStatusRenderer />
<FloatingWidget />
</CallEmbedProvider>
<React.Suspense fallback={null}>
<SearchModalRenderer />
+1 -5
View File
@@ -68,11 +68,7 @@ export function Login() {
<Text as="h1" size="H2" priority="400">
Login
</Text>
<OidcLogin
issuer={oidc.issuer}
homeserverBaseUrl={discovery['m.homeserver'].base_url}
serverName={server}
/>
<OidcLogin homeserverBaseUrl={discovery['m.homeserver'].base_url} serverName={server} />
<span data-spacing-node />
<Text align="Center">
Do not have an account? <Link to={getRegisterPath(server)}>Register</Link>
+2 -3
View File
@@ -4,7 +4,6 @@ import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
import { startOidcLogin } from '../oidc/oidcLoginUtil';
type OidcLoginProps = {
issuer: string;
homeserverBaseUrl: string;
serverName: string;
};
@@ -13,7 +12,7 @@ type OidcLoginProps = {
* with the homeserver's OIDC provider and redirects to it. Mirrors `SSOLogin`'s
* single-button styling.
*/
export function OidcLogin({ issuer, homeserverBaseUrl, serverName }: OidcLoginProps) {
export function OidcLogin({ homeserverBaseUrl, serverName }: OidcLoginProps) {
const [state, startLogin] = useAsyncCallback<void, unknown, Parameters<typeof startOidcLogin>>(
useCallback(startOidcLogin, []),
);
@@ -35,7 +34,7 @@ export function OidcLogin({ issuer, homeserverBaseUrl, serverName }: OidcLoginPr
variant="Secondary"
fill="Soft"
outlined
onClick={() => startLogin(issuer, homeserverBaseUrl)}
onClick={() => startLogin(homeserverBaseUrl)}
disabled={ongoing}
before={ongoing ? <Spinner size="200" variant="Secondary" /> : undefined}
>
+24 -17
View File
@@ -1,43 +1,45 @@
import { Box, Button, Icon, Icons, Spinner, Text, color, config } from 'folds';
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import { createClient } from 'matrix-js-sdk';
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
import { setFallbackSession } from '../../../state/sessions';
import { completeAuthorizationCodeGrant } from './oidcLoginUtil';
import { getOidcCallbackUrl } from './oidcConfig';
import { completeOidcCodeGrant } from './oidcLoginUtil';
import {
invalidateCachedClient,
isStaleClientError,
parseOidcCallbackParams,
readStoredOidcIssuer,
takePendingOidcLogin,
} from './oidcState';
/**
* Exchange the authorization code for a Matrix session and persist it. The SDK
* (oidc-client-ts) reads the transient PKCE/state it stored in sessionStorage
* before the redirect and validates `state` (CSRF). `redirectUri` is the
* deterministic callback URL, recomputed here.
* Exchange the authorization code for a Matrix session and persist it. The
* pending sign-in saved before the redirect must exist for this `state`
* (CSRF check) and is consumed here.
*/
const completeOidcLogin = async (code: string, state: string): Promise<void> => {
const { tokenResponse, homeserverUrl, oidcClientSettings, idTokenClaims } =
await completeAuthorizationCodeGrant(code, state);
const pending = takePendingOidcLogin(state);
if (!pending) throw new Error('No pending sign-in for this state.');
const tokenResponse = await completeOidcCodeGrant(code, pending);
// Derive Matrix user_id + device_id from the freshly-issued access token (the
// device is owned by the authentication service under MSC3861).
const tmp = createClient({ baseUrl: homeserverUrl, accessToken: tokenResponse.access_token });
const tmp = createClient({
baseUrl: pending.homeserverUrl,
accessToken: tokenResponse.access_token,
});
const { user_id: userId, device_id: deviceId } = await tmp.whoami();
if (!userId || !deviceId) {
throw new Error('Homeserver did not return a user/device for the OIDC session.');
}
setFallbackSession(tokenResponse.access_token, deviceId, userId, homeserverUrl, {
setFallbackSession(tokenResponse.access_token, deviceId, userId, pending.homeserverUrl, {
refreshToken: tokenResponse.refresh_token,
expiresInMs: tokenResponse.expires_in ? tokenResponse.expires_in * 1000 : undefined,
oidc: {
issuer: oidcClientSettings.issuer,
clientId: oidcClientSettings.clientId,
redirectUri: getOidcCallbackUrl(),
idTokenClaims: idTokenClaims as unknown as Record<string, unknown>,
issuer: pending.issuer,
clientId: pending.clientId,
redirectUri: pending.redirectUri,
},
});
};
@@ -71,14 +73,19 @@ function CallbackError({ message }: { message: string }) {
* router, since the redirect_uri must be a real non-hash path).
*/
export function OidcCallback() {
const params = parseOidcCallbackParams(window.location.search);
// Parsed once: a fresh object per render would re-run the effects below on
// every state change, and the code (and its pending sign-in) is single-use.
const params = useMemo(() => parseOidcCallbackParams(window.location.search), []);
const redeemed = useRef(false);
const [state, complete] = useAsyncCallback<void, unknown, [string, string]>(
useCallback(completeOidcLogin, []),
);
useEffect(() => {
if (params.kind === 'success') complete(params.code, params.state);
if (params.kind !== 'success' || redeemed.current) return;
redeemed.current = true;
complete(params.code, params.state);
}, [params, complete]);
useEffect(() => {
+12 -13
View File
@@ -1,4 +1,4 @@
import type { OidcRegistrationClientMetadata } from 'matrix-js-sdk';
import type { OAuthRegistrationRequest } from 'matrix-js-sdk';
import { OIDC_CALLBACK_PATH } from '../../paths';
import { getOriginBaseUrl, withOriginBaseUrl } from '../../pathUtils';
@@ -17,22 +17,21 @@ export const getOidcCallbackUrl = (): string =>
withOriginBaseUrl(getOriginBaseUrl(), OIDC_CALLBACK_PATH);
/**
* Client metadata sent during MSC2966 dynamic client registration.
* Client metadata sent during dynamic client registration.
*
* `registerOidcClient` drops any URI that doesn't share `clientUri` as a common
* base, so every URI here lives under our origin base.
* The SDK drops any URI that doesn't share `client_uri` as a common base, so
* every URI here lives under our origin base.
*/
export const getOidcClientMetadata = (): OidcRegistrationClientMetadata => {
export const getOidcClientMetadata = (): OAuthRegistrationRequest => {
// `${origin}${BASE_URL}` (with trailing slash) — the common base for all URIs.
const clientUri = getOriginBaseUrl();
return {
clientName: 'Lotus Chat',
clientUri,
logoUri: new URL(LotusLogo, window.location.origin).href,
applicationType: 'web',
contacts: ['support@lotusguild.org'],
tosUri: clientUri,
policyUri: clientUri,
redirectUris: [getOidcCallbackUrl()],
client_name: 'Lotus Chat',
client_uri: clientUri,
logo_uri: new URL(LotusLogo, window.location.origin).href,
application_type: 'web',
tos_uri: clientUri,
policy_uri: clientUri,
redirect_uris: [getOidcCallbackUrl()],
};
};
+50 -27
View File
@@ -1,57 +1,80 @@
import {
completeAuthorizationCodeGrant,
discoverAndValidateOIDCIssuerWellKnown,
generateOidcAuthorizationUrl,
OidcClientConfig,
registerOidcClient,
} from 'matrix-js-sdk';
import { createClient, OAuth2, ValidatedAuthMetadata } from 'matrix-js-sdk';
import { getOidcCallbackUrl, getOidcClientMetadata } from './oidcConfig';
import {
cacheClientId,
getCachedClientId,
invalidateCachedClient,
isStaleClientError,
PendingOidcLogin,
savePendingOidcLogin,
} from './oidcState';
export { completeAuthorizationCodeGrant };
/**
* The homeserver's OAuth 2.0 metadata (`GET /_matrix/client/v1/auth_metadata`).
* This is also how the SDK finds the auth server for token refresh and logout,
* so login uses the same source.
*/
export const discoverAuthMetadata = (homeserverBaseUrl: string): Promise<ValidatedAuthMetadata> =>
createClient({ baseUrl: homeserverBaseUrl }).getAuthMetadata();
export const getOrRegisterClientId = async (
config: OidcClientConfig,
issuer: string,
metadata: ValidatedAuthMetadata,
redirectUri: string,
): Promise<string> => {
const cached = getCachedClientId(issuer, redirectUri);
const cached = getCachedClientId(metadata.issuer, redirectUri);
if (cached) return cached;
const clientId = await registerOidcClient(config, getOidcClientMetadata());
cacheClientId(issuer, clientId, redirectUri);
const clientId = await OAuth2.registerClient(metadata, getOidcClientMetadata());
cacheClientId(metadata.issuer, clientId, redirectUri);
return clientId;
};
/**
* Begin the OIDC authorization-code flow: discover + validate the issuer,
* (re)register a client, build the PKCE authorization URL (oidc-client-ts
* persists the transient code_verifier/state/nonce/homeserverUrl into
* sessionStorage for the callback), then redirect.
* Begin the OAuth authorization-code flow: discover the auth server through
* the homeserver, (re)register a client, remember the PKCE verifier + device
* under a fresh `state` (oidcState), then redirect. The callback reads the
* result from the query string (`response_mode=query`).
*/
export const startOidcLogin = async (issuer: string, homeserverBaseUrl: string): Promise<void> => {
export const startOidcLogin = async (homeserverBaseUrl: string): Promise<void> => {
const redirectUri = getOidcCallbackUrl();
let issuer: string | undefined;
try {
const config = await discoverAndValidateOIDCIssuerWellKnown(issuer);
const clientId = await getOrRegisterClientId(config, issuer, redirectUri);
const url = await generateOidcAuthorizationUrl({
metadata: config,
redirectUri,
const metadata = await discoverAuthMetadata(homeserverBaseUrl);
issuer = metadata.issuer;
const clientId = await getOrRegisterClientId(metadata, redirectUri);
const oauth = new OAuth2(metadata, { clientId });
const state = crypto.randomUUID();
const pending: PendingOidcLogin = {
issuer,
clientId,
deviceId: oauth.context.deviceId,
codeVerifier: oauth.context.codeVerifier,
homeserverUrl: homeserverBaseUrl,
nonce: crypto.randomUUID(),
});
window.location.assign(url);
redirectUri,
};
savePendingOidcLogin(state, pending);
window.location.assign(
await oauth.generateAuthorizationCodeGrantUrl(state, redirectUri, 'query'),
);
} catch (e) {
// #67 — drop the cached client so the next attempt re-registers, but ONLY
// when the failure says the client id itself was rejected. Network and
// discovery failures keep the cache, otherwise each retry would register
// yet another throwaway dynamic client at the provider.
if (isStaleClientError(e)) invalidateCachedClient(issuer);
if (issuer && isStaleClientError(e)) invalidateCachedClient(issuer);
throw e;
}
};
/**
* Exchange the authorization code using the pending sign-in saved before the
* redirect. The metadata is fetched again (it isn't stored).
*/
export const completeOidcCodeGrant = async (code: string, pending: PendingOidcLogin) => {
const metadata = await discoverAuthMetadata(pending.homeserverUrl);
const oauth = new OAuth2(metadata, {
clientId: pending.clientId,
deviceId: pending.deviceId,
codeVerifier: pending.codeVerifier,
});
return oauth.completeAuthorizationCodeGrant(code, pending.redirectUri);
};
+21 -11
View File
@@ -7,6 +7,8 @@ import {
parseOidcCallbackParams,
isStaleClientError,
readStoredOidcIssuer,
savePendingOidcLogin,
takePendingOidcLogin,
} from './oidcState';
const installStorage = (): Map<string, string> => {
@@ -131,21 +133,29 @@ test('isStaleClientError: also recognises the OidcCallback error-redirect shape
);
});
test('readStoredOidcIssuer reads the issuer persisted by generateOidcAuthorizationUrl', () => {
const store = installSessionStorage();
const pending = {
issuer: 'https://issuer.example/',
clientId: 'client1',
deviceId: 'DEVICEABCD',
codeVerifier: 'v'.repeat(96),
homeserverUrl: 'https://hs.example',
redirectUri: 'https://app.example/oidc/callback',
};
test('pending sign-in: saved by state, read for the issuer, consumed once', () => {
installSessionStorage();
assert.equal(readStoredOidcIssuer('xyz'), undefined); // nothing stored yet
store.set(
'mx_oidc_xyz',
JSON.stringify({ authority: 'https://issuer.example', client_id: 'abc' }),
);
assert.equal(readStoredOidcIssuer('xyz'), 'https://issuer.example');
savePendingOidcLogin('xyz', pending);
assert.equal(readStoredOidcIssuer('xyz'), 'https://issuer.example/');
assert.equal(readStoredOidcIssuer('other-state'), undefined); // different state = miss
assert.deepEqual(takePendingOidcLogin('xyz'), pending);
assert.equal(takePendingOidcLogin('xyz'), undefined, 'single use');
});
test('readStoredOidcIssuer tolerates corrupt or missing storage', () => {
test('pending sign-in tolerates corrupt or incomplete storage', () => {
const store = installSessionStorage();
store.set('mx_oidc_bad', '{ not json');
store.set('lotus_oidc_pending_bad', '{ not json');
assert.equal(readStoredOidcIssuer('bad'), undefined);
store.set('mx_oidc_noauth', JSON.stringify({ client_id: 'abc' }));
assert.equal(readStoredOidcIssuer('noauth'), undefined);
store.set('lotus_oidc_pending_partial', JSON.stringify({ ...pending, codeVerifier: '' }));
assert.equal(takePendingOidcLogin('partial'), undefined);
});
+50 -13
View File
@@ -97,23 +97,60 @@ export const parseOidcCallbackParams = (search: string): OidcCallbackParams => {
};
/**
* #102 — the issuer for a pending sign-in isn't available on the callback's
* error branch (we bail out before `completeAuthorizationCodeGrant`, which is
* what would otherwise surface it). oidc-client-ts's `generateOidcAuthorizationUrl`
* persists the pending sign-in's `SigninState` (including `authority` and
* `client_id`) into sessionStorage before redirecting, keyed by
* `mx_oidc_<state>` (WebStorageStateStore prefix `mx_oidc_`, keyed by the same
* `state` value the provider echoes back on redirect). Read it directly so a
* genuinely stale cached client id (`invalid_client`) can be evicted even when
* the callback errors before a token exchange is attempted.
* [Gitea #201, SDK 44] The app keeps a pending OAuth sign-in itself (the SDK's
* OAuth2 class no longer persists anything). Saved in sessionStorage right
* before the redirect, keyed by the `state` we send, which the provider echoes
* back: a callback whose state has no entry is rejected (CSRF), and an entry is
* used once. Holds the PKCE code verifier, so it never goes to localStorage.
*/
export const readStoredOidcIssuer = (state: string): string | undefined => {
export type PendingOidcLogin = {
issuer: string;
clientId: string;
deviceId: string;
codeVerifier: string;
homeserverUrl: string;
redirectUri: string;
};
const PENDING_PREFIX = 'lotus_oidc_pending_';
const isPending = (v: unknown): v is PendingOidcLogin => {
if (!v || typeof v !== 'object') return false;
const p = v as Record<string, unknown>;
return ['issuer', 'clientId', 'deviceId', 'codeVerifier', 'homeserverUrl', 'redirectUri'].every(
(k) => typeof p[k] === 'string' && (p[k] as string).length > 0,
);
};
export const savePendingOidcLogin = (state: string, pending: PendingOidcLogin): void => {
sessionStorage.setItem(`${PENDING_PREFIX}${state}`, JSON.stringify(pending));
};
/** Read the pending sign-in for `state` without consuming it. */
export const readPendingOidcLogin = (state: string): PendingOidcLogin | undefined => {
try {
const raw = sessionStorage.getItem(`mx_oidc_${state}`);
const raw = sessionStorage.getItem(`${PENDING_PREFIX}${state}`);
if (!raw) return undefined;
const { authority } = JSON.parse(raw) as { authority?: unknown };
return typeof authority === 'string' ? authority : undefined;
const parsed: unknown = JSON.parse(raw);
return isPending(parsed) ? parsed : undefined;
} catch {
return undefined;
}
};
/** Read and remove: an authorization code can only be redeemed once anyway. */
export const takePendingOidcLogin = (state: string): PendingOidcLogin | undefined => {
const pending = readPendingOidcLogin(state);
try {
sessionStorage.removeItem(`${PENDING_PREFIX}${state}`);
} catch {
// storage unavailable — nothing to clean up
}
return pending;
};
/**
* #102 — on the callback's error branch, the pending sign-in's issuer tells
* us whose cached client id to evict when the provider rejected it.
*/
export const readStoredOidcIssuer = (state: string): string | undefined =>
readPendingOidcLogin(state)?.issuer;
+18 -6
View File
@@ -33,6 +33,8 @@ import {
} from '../../../client/initMatrix';
import { deleteSearchCacheDatabase } from '../../utils/searchCache';
import { clearPlaintextCaches } from '../../state/plaintextCaches';
import { clearSoundboardClipCache } from '../../utils/soundboardClips';
import { clearSharedPayload } from '../../../swShare';
import { SplashScreen } from '../../components/splash-screen';
import { ServerConfigsLoader } from '../../components/ServerConfigsLoader';
import { CapabilitiesProvider } from '../../hooks/useCapabilities';
@@ -44,6 +46,7 @@ import { useSyncState } from '../../hooks/useSyncState';
import { stopPropagation } from '../../utils/keyboard';
import { SyncStatus } from './SyncStatus';
import { ClockSkewBanner } from './ClockSkewBanner';
import { KeyUploadBanner } from './KeyUploadBanner';
import {
ServerStatusBanner,
ServerStatusFeature,
@@ -52,7 +55,6 @@ import { SecurityBanner } from '../../features/security-nudge/SecurityBanner';
import { AuthMetadataProvider } from '../../hooks/useAuthMetadata';
import { getFallbackSession, removeFallbackSession } from '../../state/sessions';
import { pushSessionToSW } from '../../../sw-session';
import { revokeOidcTokens } from '../../../client/oidcLogout';
import { useSessionSync } from '../../hooks/useSessionSync';
import { installCryptoDiagLog } from '../../utils/cryptoDiagLog';
import { AutoDiscovery } from './AutoDiscovery';
@@ -156,11 +158,11 @@ const useLogoutListener = (mx?: MatrixClient) => {
pushSessionToSW();
mx?.stopClient();
// Best-effort issuer revocation for OIDC sessions (the token is already
// server-revoked here, but revoke the refresh token too). Before we drop
// the stored session below.
const loggedOutSession = getFallbackSession();
if (loggedOutSession?.oidc) {
await revokeOidcTokens(loggedOutSession).catch(() => undefined);
// server-revoked here, but revoke the refresh token too). For an OAuth
// session the SDK's logout() only revokes at the auth server (no /logout
// call). Before we drop the stored session below.
if (getFallbackSession()?.oidc) {
await mx?.logout().catch(() => undefined);
}
await mx?.clearStores();
// The opt-in local search index holds DECRYPTED message plaintext. Wipe it
@@ -172,6 +174,10 @@ const useLogoutListener = (mx?: MatrixClient) => {
// (translation, scheduled messages, recent searches/forwards/gifs/
// stickers, nav paths) — wipe them on server-forced logout too.
clearPlaintextCaches(mx?.getUserId() ?? undefined);
// [Gitea #57] As on manual logout: no decrypted clip bytes via blob: URLs.
clearSoundboardClipCache();
// [Gitea #267] As on manual logout: drop files stashed by the share target.
await clearSharedPayload().catch(() => undefined);
// Remove only the session credential keys — NOT settings, drafts, and
// other preferences (N98). The SDK's IndexedDB stores are cleared above;
// window.localStorage.clear() is reserved for the explicit reset path.
@@ -254,6 +260,12 @@ export function ClientRoot({ children }: ClientRootProps) {
{mx && !syncError && <ServerStatusBanner />}
{mx && !syncError && <SyncStatus mx={mx} />}
{mx && !syncError && <ClockSkewBanner />}
{mx && !syncError && (
// The fix opens LogoutDialog, which reads the client from context.
<MatrixClientProvider value={mx}>
<KeyUploadBanner />
</MatrixClientProvider>
)}
{loading && <ClientRootOptions mx={mx} />}
{(loadState.status === AsyncStatus.Error ||
startState.status === AsyncStatus.Error ||
+104
View File
@@ -0,0 +1,104 @@
import React, { useState, useSyncExternalStore } from 'react';
import FocusTrap from 'focus-trap-react';
import { Box, Button, config, Line, Overlay, OverlayBackdrop, OverlayCenter, Text } from 'folds';
import { ContainerColor } from '../../styles/ContainerColor.css';
import { getKeyUploadWatch, subscribeKeyUploadWatch } from '../../utils/keyUploadWatch';
import { LogoutDialog } from '../../components/LogoutDialog';
import { stopPropagation } from '../../utils/keyboard';
/**
* [Gitea #201 KE-1] "Encryption on this device is out of sync." Shown while
* the server keeps rejecting this device's key uploads (keyUploadWatch). The
* fix is a fresh login, so the action opens the normal logout dialog, which
* already warns if the device isn't verified / backed up. Hideable for this
* session only: the problem doesn't go away by itself.
*/
export function KeyUploadBanner() {
const { stuck, lastError } = useSyncExternalStore(subscribeKeyUploadWatch, getKeyUploadWatch);
const [hidden, setHidden] = useState(false);
const [details, setDetails] = useState(false);
const [logout, setLogout] = useState(false);
if (!stuck || hidden) return null;
return (
<Box direction="Column" shrink="No">
<Box
className={ContainerColor({ variant: 'Critical' })}
style={{ padding: `${config.space.S100} ${config.space.S300}` }}
direction="Column"
alignItems="Center"
gap="100"
role="alert"
>
<Box alignItems="Center" gap="300" wrap="Wrap" justifyContent="Center">
<Text size="L400" align="Center">
Encryption on this device is out of sync with the server. New encrypted messages and
calls may fail until you sign out and back in.
</Text>
<Button
size="300"
variant="Critical"
fill="Solid"
radii="300"
onClick={() => setLogout(true)}
>
<Text size="B300">Fix: sign out…</Text>
</Button>
<Button
size="300"
variant="Critical"
fill="Soft"
radii="300"
onClick={() => setDetails((v) => !v)}
aria-expanded={details}
>
<Text size="B300">Details</Text>
</Button>
<Button
size="300"
variant="Critical"
fill="None"
radii="300"
onClick={() => setHidden(true)}
>
<Text size="B300">Hide</Text>
</Button>
</Box>
{details && (
<Box direction="Column" gap="100" style={{ maxWidth: 640 }}>
<Text size="T200" align="Center">
The server already has encryption keys this device thinks it hasn&apos;t sent, so it
rejects every new upload and other people can&apos;t start fresh encrypted sessions
with you. This usually happens after the browser cleared this site&apos;s storage
while you stayed signed in. Before signing out, make sure this device is verified or
key backup is on (Settings → Devices), so your message history comes back when you
sign in again.
</Text>
{lastError && (
<Text size="T200" align="Center" priority="300" style={{ wordBreak: 'break-word' }}>
Server said: {lastError}
</Text>
)}
</Box>
)}
</Box>
<Line variant="Critical" size="300" />
{logout && (
<Overlay open backdrop={<OverlayBackdrop />}>
<OverlayCenter>
<FocusTrap
focusTrapOptions={{
onDeactivate: () => setLogout(false),
clickOutsideDeactivates: true,
escapeDeactivates: stopPropagation,
}}
>
<LogoutDialog handleClose={() => setLogout(false)} />
</FocusTrap>
</OverlayCenter>
</Overlay>
)}
</Box>
);
}
+6 -6
View File
@@ -65,12 +65,12 @@ export function SyncStatus({ mx }: SyncStatusProps) {
);
}
if (
(stateData.current === SyncState.Prepared ||
stateData.current === SyncState.Syncing ||
stateData.current === SyncState.Catchup) &&
stateData.previous !== SyncState.Syncing
) {
// [Gitea #274] Only while catching up after a drop. Upstream also showed it
// for PREPARED and for the first SYNCING after PREPARED/RECONNECTING, i.e.
// until the NEXT /sync returned: on a quiet account that long-polls ~30 s
// while the app already works (a SYNCING means a sync just succeeded).
// A real failure still surfaces as Reconnecting / Connection lost.
if (stateData.current === SyncState.Catchup) {
return (
<Box direction="Column" shrink="No">
<Box
+3 -3
View File
@@ -369,7 +369,7 @@ function InviteFilters({
<Box gap="200">
<Chip
variant={isKnown ? 'Success' : 'Surface'}
aria-selected={isKnown}
aria-pressed={isKnown}
outlined={!isKnown}
onClick={() => onFilter(InviteFilter.Known)}
before={isKnown && <Icon size="100" src={Icons.Check} />}
@@ -385,7 +385,7 @@ function InviteFilters({
</Chip>
<Chip
variant={isUnknown ? 'Warning' : 'Surface'}
aria-selected={isUnknown}
aria-pressed={isUnknown}
outlined={!isUnknown}
onClick={() => onFilter(InviteFilter.Unknown)}
before={isUnknown && <Icon size="100" src={Icons.Check} />}
@@ -401,7 +401,7 @@ function InviteFilters({
</Chip>
<Chip
variant={isSpam ? 'Critical' : 'Surface'}
aria-selected={isSpam}
aria-pressed={isSpam}
outlined={!isSpam}
onClick={() => onFilter(InviteFilter.Spam)}
before={isSpam && <Icon size="100" src={Icons.Check} />}
+5
View File
@@ -145,6 +145,11 @@ export function Share() {
<Box direction="Column" gap="400">
<Box direction="Column" gap="200">
<Text size="L400">Shared</Text>
{/* [Gitea #267] Not everything that arrives here came from the
user's share sheet; say so before they pick a room. */}
<Text size="T200" priority="300">
This came from another app or website. Check it before you send it.
</Text>
{shared.files.map((f) => (
<Box key={f.name} alignItems="Center" gap="200">
<Icon
+1 -1
View File
@@ -217,7 +217,7 @@ export function SettingsTab() {
</SidebarItemTooltip>
<PresencePicker />
{settingsOpen && (
<Modal500 requestClose={() => setSettingsOpen(false)}>
<Modal500 requestClose={() => setSettingsOpen(false)} label="Settings">
<Settings initialPage={initialPage} requestClose={() => setSettingsOpen(false)} />
</Modal500>
)}
@@ -82,7 +82,7 @@ function UnverifiedIndicator() {
</SidebarItem>
)}
{settings && (
<Modal500 requestClose={closeSettings}>
<Modal500 requestClose={closeSettings} label="Settings">
<Settings initialPage={SettingsPages.DevicesPage} requestClose={closeSettings} />
</Modal500>
)}
+25
View File
@@ -57,6 +57,15 @@ export function parseForkHotkeyReport(data: unknown): ForkHotkeyReport | null {
export const CALL_ERROR_CHANGED = 'call_error_changed';
export const SCREENSHARE_AUDIO_STATE = 'screenshare_audio_state';
/** Pure: parse the fork's `io.lotus.screenshare_audio_state` (#277). */
export function parseScreenshareAudioState(data: unknown): boolean | undefined {
if (typeof data !== 'object' || data === null) return undefined;
const { present } = data as { present?: unknown };
return typeof present === 'boolean' ? present : undefined;
}
export type AudioOutputOption = { id: string; label: string };
export const AUDIO_OUTPUT_STATE = 'audio_output_state';
@@ -281,6 +290,22 @@ export class CallControl extends EventEmitter implements CallControlState {
this.emit(AUDIO_OUTPUT_STATE);
}
// [Gitea #277] Whether a remote screenshare's audio is being received (the
// fork's `io.lotus.screenshare_audio_state`), so the call bar only offers
// "Mute Screenshare Audio" when there is something to mute.
private _remoteScreenshareAudio = false;
public get remoteScreenshareAudio(): boolean {
return this._remoteScreenshareAudio;
}
public onScreenshareAudioState(data: unknown) {
const present = parseScreenshareAudioState(data);
if (present === undefined || present === this._remoteScreenshareAudio) return;
this._remoteScreenshareAudio = present;
this.emit(SCREENSHARE_AUDIO_STATE);
}
private sendAudioOutput(deviceId: string): void {
if (!this.joined) return;
this.call.transport.send('io.lotus.set_audio_output', { deviceId }).catch(() => undefined);
+35 -2
View File
@@ -15,6 +15,7 @@ import {
WidgetApiFromWidgetAction,
WidgetApiToWidgetAction,
WidgetDriver,
IWidgetApiRequest,
} from 'matrix-widget-api';
import { CallWidgetDriver } from './CallWidgetDriver';
import { trimTrailingSlash } from '../../utils/common';
@@ -25,13 +26,14 @@ import {
ElementMediaStateDetail,
ElementWidgetActions,
} from './types';
import { CallControl } from './CallControl';
import { CallControl, CallControlEvent } from './CallControl';
import { CallControlState } from './CallControlState';
import { verifyDenoiseAssets } from './denoiseSmokeCheck';
import { canDelegateCapability } from './utils';
import { getCallPageUrl } from './callPageUrl';
import { restrictWidgetMessages } from '../widgetTransport';
import { isRingableRoom } from '../../utils/callRing';
import { parseCallSummaryDetails, type LotusCallSummaryDetails } from '../../utils/callSummary';
// Maximum time to wait for the embedded Element Call iframe to progress from
// initial load to a ready/joined state. If it hasn't by then, we assume the
@@ -58,6 +60,8 @@ export interface LotusCallSummary {
reconnects: number;
poorMs: number;
verdict: 'good' | 'fair' | 'poor' | 'unknown';
/** [Gitea #253] Breakdown for the Details card (fork lotus.29+). */
details?: LotusCallSummaryDetails;
}
export class CallEmbed {
@@ -77,6 +81,25 @@ export class CallEmbed {
/** [Gitea #143] The fork's end-of-call summary, once it arrives. */
public lastSummary: LotusCallSummary | undefined;
// [Gitea #253] Time spent deafened (sound off), for the post-call Details.
private deafenedSince: number | undefined;
private deafenedTotal = 0;
public deafenedMs(now = Date.now()): number {
return this.deafenedTotal + (this.deafenedSince === undefined ? 0 : now - this.deafenedSince);
}
private trackDeafened = (): void => {
if (!this.joined) return;
const deaf = !this.control.sound;
if (deaf && this.deafenedSince === undefined) this.deafenedSince = Date.now();
if (!deaf && this.deafenedSince !== undefined) {
this.deafenedTotal += Date.now() - this.deafenedSince;
this.deafenedSince = undefined;
}
};
// C-M4: set once dispose() has run so the hangup fallback timer can tell
// whether the embed was already torn down by the normal Close/Hangup echo.
public disposed = false;
@@ -338,6 +361,8 @@ export class CallEmbed {
const controlState = initialControlState ?? new CallControlState(true, false, true);
this.control = new CallControl(controlState, call, iframe);
this.initialState = controlState;
this.control.on(CallControlEvent.StateUpdate, this.trackDeafened);
this.disposables.push(() => this.control.off(CallControlEvent.StateUpdate, this.trackDeafened));
// If the iframe document itself fails to load, fail fast.
iframe.onerror = () => {
this.settleLoad('iframe');
@@ -433,6 +458,7 @@ export class CallEmbed {
reconnects: data.reconnects ?? 0,
poorMs: data.poorMs ?? 0,
verdict: data.verdict ?? 'unknown',
details: parseCallSummaryDetails((data as { details?: unknown }).details),
};
}
}),
@@ -465,6 +491,12 @@ export class CallEmbed {
this.control.onAudioOutputState((evt.detail as { data?: unknown } | undefined)?.data);
}),
);
// [Gitea #277] Remote screenshare audio being received, or not.
this.disposables.push(
this.listenAction('io.lotus.screenshare_audio_state', (evt) => {
this.control.onScreenshareAudioState((evt.detail as { data?: unknown } | undefined)?.data);
}),
);
// [Gitea #43] PTT / deafen keys pressed while focus is inside the frame.
this.disposables.push(
this.listenAction('io.lotus.hotkey', (evt) => {
@@ -616,6 +648,7 @@ export class CallEmbed {
}
this.joined = true;
this.joinedAt = Date.now();
this.trackDeafened();
// EC ignores io.element.device_mute before join; re-apply desired state now that EC is live
this.control.forceState(this.initialState);
}
@@ -790,7 +823,7 @@ export class CallEmbed {
const wrapped = (ev: CustomEvent<T>) => {
ev.preventDefault();
// Reply with success so the widget transport doesn't time out waiting for a response
this.call.transport.reply(ev.detail as any, {});
this.call.transport.reply(ev.detail as unknown as IWidgetApiRequest, {});
callback(ev);
};
return this.listenEvent(`action:${type}`, wrapped);
@@ -0,0 +1,12 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { parseScreenshareAudioState } from './CallControl';
test('parseScreenshareAudioState: reads present, ignores anything else (#277)', () => {
assert.equal(parseScreenshareAudioState({ present: true }), true);
assert.equal(parseScreenshareAudioState({ present: false }), false);
assert.equal(parseScreenshareAudioState({ present: 'yes' }), undefined);
assert.equal(parseScreenshareAudioState({}), undefined);
assert.equal(parseScreenshareAudioState(null), undefined);
assert.equal(parseScreenshareAudioState('present'), undefined);
});
+6
View File
@@ -0,0 +1,6 @@
import { atom } from 'jotai';
import type { CallSummarySection } from '../utils/callSummary';
/** [Gitea #253] The post-call Details card currently open (undefined = closed). */
export type CallSummaryView = { roomName: string; sections: CallSummarySection[] };
export const callSummaryViewAtom = atom<CallSummaryView | undefined>(undefined);
+19 -8
View File
@@ -1,14 +1,19 @@
import { useEffect, useState } from 'react';
import { getFallbackSession, onSessionPersisted, Session } from './sessions';
import {
getFallbackSession,
onSessionPersisted,
Session,
stripTokensFromStorage,
} from './sessions';
/**
* [Gitea #105] Desktop, step 1: mirror the login tokens into the OS keychain.
* [Gitea #105] Desktop: keep the login tokens in the OS keychain.
*
* The session is still read from localStorage exactly as before; this only
* keeps a copy in the keychain (Windows Credential Manager) and checks it by
* reading it back, so real installs prove the keychain works before step 2
* switches reads over to it. Nothing here can log anyone out: every failure
* just records a status for Settings.
* Step 1 mirrored them here and verified by reading back. Step 2 (sessions.ts,
* keychainSession.ts) reads them from here at boot; once a write is verified,
* the tokens are dropped from localStorage. Nothing here can log anyone out:
* a failure keeps the tokens in localStorage and records a status for
* Settings.
*
* Writes are serialized (a token rotation right after login must not race
* the login's write) and time out, so a hung credential store can't pile up.
@@ -122,7 +127,13 @@ export const startKeychainMirror = (invoke: KeychainInvoke | undefined): void =>
started = true;
let chain: Promise<unknown> = Promise.resolve();
const enqueue = (session: Session | null) => {
chain = chain.then(async () => setStatus(await syncKeychain(invoke, session)));
chain = chain.then(async () => {
const result = await syncKeychain(invoke, session);
setStatus(result);
// [Gitea #105] step 2: the keychain verifiably holds these tokens, so
// localStorage can drop them (only if they're still the current ones).
if (result.state === 'ok' && session) stripTokensFromStorage(tokensOf(session));
});
};
enqueue(getFallbackSession() ?? null);
onSessionPersisted((session) => enqueue(session));
+183
View File
@@ -0,0 +1,183 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
// localStorage stand-in (these modules read it at call time).
const store = new Map<string, string>();
(globalThis as { localStorage?: unknown }).localStorage = {
getItem: (k: string) => store.get(k) ?? null,
setItem: (k: string, v: string) => {
store.set(k, v);
},
removeItem: (k: string) => {
store.delete(k);
},
};
const sessions = await import('./sessions');
const { bootKeychainSession } = await import('./keychainSession');
const { syncKeychain, tokensOf } = await import('./keychainMirror');
type Invoke = (cmd: string, args?: Record<string, unknown>) => Promise<unknown>;
const keychain = (opts: { getThrows?: boolean; setThrows?: boolean } = {}) => {
let stored: unknown = null;
const invoke: Invoke = async (cmd, args) => {
if (cmd === 'secure_session_supported') return true;
if (cmd === 'secure_session_get') {
if (opts.getThrows) throw new Error('Element not found.');
return stored;
}
if (cmd === 'secure_session_set') {
if (opts.setThrows) throw new Error('Access is denied.');
stored = args?.tokens;
return null;
}
if (cmd === 'secure_session_clear') {
stored = null;
return null;
}
throw new Error(cmd);
};
return {
invoke,
get: () => stored,
set: (v: unknown) => {
stored = v;
},
};
};
const blob = () => JSON.parse(store.get('cinny_session_v1') ?? 'null');
const tokensOnDisk = () =>
[...store.entries()].some(([, v]) => v.includes('syt_') || v.includes('mar_'));
const login = (access: string, refresh?: string) =>
sessions.setFallbackSession(access, 'DEV1', '@alice:example.org', 'https://hs.example', {
refreshToken: refresh,
expiresInMs: 300_000,
});
/** A fresh page load: drop the in-memory state, keep storage and keychain. */
const reload = () => sessions.leaveKeychainMode();
/** What the mirror does after a write: verify in the keychain, then strip. */
const mirror = async (invoke: Invoke) => {
const s = sessions.getFallbackSession() ?? null;
const r = await syncKeychain(invoke, s);
if (r.state === 'ok' && s) sessions.stripTokensFromStorage(tokensOf(s));
return r;
};
test('[#105] web / no keychain: localStorage stays authoritative', async () => {
store.clear();
reload();
login('syt_web', 'mar_web');
assert.deepEqual(await bootKeychainSession(undefined), { mode: 'off' });
assert.equal(sessions.getFallbackSession()?.accessToken, 'syt_web');
assert.equal(blob().accessToken, 'syt_web');
});
test('[#105] migration: existing install moves its tokens to the keychain, then off disk', async () => {
store.clear();
reload();
login('syt_old', 'mar_old'); // a pre-step-2 install
const kc = keychain();
const boot = await bootKeychainSession(kc.invoke);
assert.equal(boot.mode, 'keychain');
assert.equal(sessions.getFallbackSession()?.accessToken, 'syt_old');
assert.equal(tokensOnDisk(), true, 'not stripped before the keychain is verified');
assert.equal((await mirror(kc.invoke)).state, 'ok');
assert.equal(tokensOnDisk(), false, 'tokens gone from localStorage');
assert.equal(blob().tokensIn, 'keychain');
assert.equal(store.get('cinny_access_token'), undefined);
assert.equal(sessions.getFallbackSession()?.accessToken, 'syt_old', 'still signed in');
// Next launch: shell + keychain -> the same session.
reload();
const again = await bootKeychainSession(kc.invoke);
assert.equal(again.mode, 'keychain');
const s = sessions.getFallbackSession();
assert.equal(s?.accessToken, 'syt_old');
assert.equal(s?.refreshToken, 'mar_old');
assert.equal(s?.baseUrl, 'https://hs.example');
assert.ok((s?.expiresInMs ?? 0) > 0, 'expiry kept in the shell');
});
test('[#105] token refresh: written in full first, stripped once the keychain has it', async () => {
// continues from the previous state: keychain mode, shell on disk
const kc = keychain();
kc.set({
userId: '@alice:example.org',
deviceId: 'DEV1',
accessToken: 'syt_old',
refreshToken: 'mar_old',
});
login('syt_new', 'mar_new');
assert.equal(blob().accessToken, 'syt_new', 'durable on disk until the keychain confirms');
assert.equal(sessions.getFallbackSession()?.accessToken, 'syt_new');
await mirror(kc.invoke);
assert.equal(tokensOnDisk(), false);
assert.equal((kc.get() as { accessToken: string }).accessToken, 'syt_new');
});
test('[#105] a failing keychain write keeps the tokens in localStorage', async () => {
store.clear();
reload();
login('syt_keep', 'mar_keep');
const kc = keychain({ setThrows: true });
await bootKeychainSession(kc.invoke);
assert.equal((await mirror(kc.invoke)).state, 'error');
assert.equal(blob().accessToken, 'syt_keep', 'nothing stripped');
reload();
await bootKeychainSession(kc.invoke);
assert.equal(
sessions.getFallbackSession()?.accessToken,
'syt_keep',
'still signed in after a restart',
);
});
test('[#105] shell but no keychain entry: "missing", never a silent logout', async () => {
store.clear();
reload();
login('syt_x');
const kc = keychain();
await bootKeychainSession(kc.invoke);
await mirror(kc.invoke);
kc.set(null); // someone deleted the Credential Manager entry
reload();
const boot = await bootKeychainSession(kc.invoke);
assert.deepEqual(boot, { mode: 'missing', userId: '@alice:example.org' });
assert.equal(blob().tokensIn, 'keychain', 'shell kept for Retry');
});
test('[#105] shell but the keychain read fails: "error", shell kept', async () => {
// continues: shell on disk
reload();
const boot = await bootKeychainSession(keychain({ getThrows: true }).invoke);
assert.equal(boot.mode, 'error');
assert.equal(blob().tokensIn, 'keychain');
});
test('[#105] a shell for another device never pairs with the keychain', async () => {
store.clear();
reload();
login('syt_a');
const kc = keychain();
await bootKeychainSession(kc.invoke);
await mirror(kc.invoke);
kc.set({ userId: '@alice:example.org', deviceId: 'OTHER', accessToken: 'syt_b' });
reload();
assert.equal((await bootKeychainSession(kc.invoke)).mode, 'missing');
});
test('[#105] logout clears memory, disk and (via the mirror) the keychain', async () => {
store.clear();
reload();
login('syt_bye', 'mar_bye');
const kc = keychain();
await bootKeychainSession(kc.invoke);
await mirror(kc.invoke);
sessions.removeFallbackSession();
assert.equal(sessions.getFallbackSession(), undefined);
assert.equal(store.size, 0);
await mirror(kc.invoke);
assert.equal(kc.get(), null);
reload();
assert.deepEqual(await bootKeychainSession(kc.invoke), { mode: 'keychain', session: undefined });
});
+76
View File
@@ -0,0 +1,76 @@
import {
enterKeychainMode,
hasKeychainShell,
KeychainBoot,
KeychainSessionTokens,
} from './sessions';
import { KEYCHAIN_TIMEOUT_MS, KeychainInvoke } from './keychainMirror';
/**
* [Gitea #105] Desktop, step 2: at boot, before the app renders, read the login
* tokens from the OS keychain into memory (see sessions.ts). Returns:
* - `off`: not the desktop app, or no keychain here (Linux, older builds) —
* localStorage stays authoritative, exactly as before;
* - a KeychainBoot from enterKeychainMode: `keychain` (go on), or `missing`
* (localStorage says the tokens are in the keychain but they can't be read;
* the caller shows Retry / Sign in again and must NOT start the mirror,
* which would clear the keychain entry it couldn't read).
*/
export type KeychainBootResult = { mode: 'off' } | KeychainBoot | { mode: 'error'; error: string };
const withTimeout = <T>(p: Promise<T>, ms: number): Promise<T> =>
new Promise<T>((resolve, reject) => {
const timer = setTimeout(() => reject(new Error('keychain timed out')), ms);
p.then(
(v) => {
clearTimeout(timer);
resolve(v);
},
(e) => {
clearTimeout(timer);
reject(e);
},
);
});
const asTokens = (v: unknown): KeychainSessionTokens | null => {
if (!v || typeof v !== 'object') return null;
const t = v as Partial<KeychainSessionTokens>;
if (typeof t.userId !== 'string' || typeof t.deviceId !== 'string') return null;
if (typeof t.accessToken !== 'string') return null;
return {
userId: t.userId,
deviceId: t.deviceId,
accessToken: t.accessToken,
...(typeof t.refreshToken === 'string' ? { refreshToken: t.refreshToken } : {}),
};
};
export async function bootKeychainSession(
invoke: KeychainInvoke | undefined,
timeoutMs = KEYCHAIN_TIMEOUT_MS,
): Promise<KeychainBootResult> {
if (!invoke) return { mode: 'off' };
let supported: unknown;
try {
supported = await withTimeout(invoke('secure_session_supported'), timeoutMs);
} catch {
supported = false;
}
if (supported !== true) {
// A shell without a keychain to read from can only mean the store went
// away (e.g. a downgrade of the desktop build): say so, don't log out.
return hasKeychainShell()
? { mode: 'error', error: 'keychain not available' }
: { mode: 'off' };
}
let stored: unknown;
try {
stored = await withTimeout(invoke('secure_session_get'), timeoutMs);
} catch (e) {
if (hasKeychainShell())
return { mode: 'error', error: (e instanceof Error ? e.message : String(e)).slice(0, 200) };
return { mode: 'off' };
}
return enterKeychainMode(asTokens(stored));
}
+18 -1
View File
@@ -26,7 +26,10 @@ const api = {
: Object.getOwnPropertyDescriptor(target, key),
});
const { clearPlaintextCaches, plaintextCachesWiped } = await import('./plaintextCaches');
const { clearPlaintextCaches, plaintextCachesWiped, WIDGET_CONSENT_KEY_PREFIX } =
await import('./plaintextCaches');
const { WIDGET_CONSENT_PREFIX, widgetConsentKey } =
await import('../features/room/widgets/widgetUtils');
test('clearPlaintextCaches removes every plaintext/PII localStorage key', () => {
store.clear();
@@ -104,3 +107,17 @@ test('clearPlaintextCaches clears the encrypted-search opt-in and flags the wipe
assert.equal(store.has('mxjssdk_memory_filter_FILTER_SYNC_@me:server'), false);
assert.equal(plaintextCachesWiped(), true, 'draft writes stop until the page reloads');
});
test('[#266] clearPlaintextCaches sweeps remembered widget approvals', () => {
assert.equal(WIDGET_CONSENT_KEY_PREFIX, WIDGET_CONSENT_PREFIX, 'prefix kept in sync');
store.clear();
const consent = widgetConsentKey('!room:server', 'widget-1');
store.set(consent, '{"url":"https://pad.example","allowed":[],"denied":[]}');
store.set('lotus.widgetConsentNotAKey', 'kept');
removed.length = 0;
clearPlaintextCaches('@me:server');
assert.ok(removed.includes(consent), 'consent cleared');
assert.ok(store.has('lotus.widgetConsentNotAKey'), 'unrelated key kept');
});
+26
View File
@@ -139,6 +139,31 @@ const clearAccountScopedFlags = (userId?: string): void => {
});
};
/**
* [Gitea #266] Remembered widget approvals (`lotus.widgetConsent.<room>.<widget>`,
* widgetUtils.ts) would otherwise apply silently to the next account on this
* device, and their keys list the previous account's rooms. Kept as a string
* here so logout doesn't pull the widget code into the entry chunk; a test
* checks it matches WIDGET_CONSENT_PREFIX.
*/
export const WIDGET_CONSENT_KEY_PREFIX = 'lotus.widgetConsent.';
const clearWidgetConsents = (): void => {
let keys: string[];
try {
keys = Object.keys(localStorage);
} catch {
return;
}
keys.forEach((key) => {
if (!key.startsWith(WIDGET_CONSENT_KEY_PREFIX)) return;
try {
localStorage.removeItem(key);
} catch {
// best-effort
}
});
};
export const clearPlaintextCaches = (userId?: string): void => {
wiped = true;
clearTranslationCache();
@@ -153,5 +178,6 @@ export const clearPlaintextCaches = (userId?: string): void => {
clearStatusMessage();
clearCallVolumesAndSyncMeta(userId);
clearAccountScopedFlags(userId);
clearWidgetConsents();
if (userId) clearNavToActivePathStore(userId);
};
+3 -4
View File
@@ -2,6 +2,7 @@ import { atom, useSetAtom } from 'jotai';
import { MatrixClient, MatrixEvent, Room, RoomEvent, RoomEventHandlerMap } from 'matrix-js-sdk';
import { useEffect } from 'react';
import { AccountDataEvent } from '../../../types/matrix/accountData';
import { setRoomAccountData } from '../../utils/accountData';
// MSC2867 — "mark a room as unread". A per-room account-data flag `{ unread }`.
// Stable type `m.marked_unread`; servers/clients predating the stabilization use
@@ -25,11 +26,9 @@ export const setMarkedUnread = (
unread: boolean,
): Promise<unknown> =>
Promise.all([
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mx.setRoomAccountData(roomId, AccountDataEvent.MarkedUnread as any, { unread }),
setRoomAccountData(mx, roomId, AccountDataEvent.MarkedUnread, { unread }),
// Best-effort mirror for older servers; never fail the primary write on it.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
mx.setRoomAccountData(roomId, UNSTABLE_MARKED_UNREAD as any, { unread }).catch(() => undefined),
setRoomAccountData(mx, roomId, UNSTABLE_MARKED_UNREAD, { unread }).catch(() => undefined),
]);
export const receiptIsMine = (event: MatrixEvent, userId: string): boolean => {
+142 -3
View File
@@ -5,9 +5,9 @@
// setLocalStorageItem,
// } from './utils/atomWithLocalStorage';
// OIDC/next-gen-auth (MSC3861) metadata needed to refresh + revoke tokens. Kept
// as a generic claims object so this core module stays decoupled from
// oidc-client-ts (the refresher casts idTokenClaims to IdTokenClaims).
// OIDC/next-gen-auth (MSC3861) metadata needed to refresh + revoke tokens. Since
// matrix-js-sdk 43 only `clientId` is used (the SDK finds the auth server via
// /auth_metadata); `idTokenClaims` is kept for sessions saved by older builds.
export type OidcSessionMeta = {
issuer: string;
clientId: string;
@@ -51,6 +51,21 @@ const OIDC_KEYS = {
// `_v1` suffix.
const SESSION_BLOB_KEY = 'cinny_session_v1';
// [Gitea #105] Desktop, step 2: the login tokens live in the OS keychain.
// localStorage then holds a SHELL blob (everything but the tokens, marked
// `tokensIn: 'keychain'`), and the full session is kept in memory, filled at
// boot (bootKeychainSession) before the app renders, so every reader of
// getFallbackSession stays synchronous. A new session is written to
// localStorage in full first; the tokens are stripped only once the keychain
// write was read back (stripTokensFromStorage), so at every instant one durable
// store holds the newest tokens (a token refresh invalidates the old ones).
let keychainMode = false;
let memorySession: PersistedSession | undefined;
type ShellSession = Omit<PersistedSession, 'accessToken' | 'refreshToken'> & {
tokensIn: 'keychain';
};
// The exact shape stored inside SESSION_BLOB_KEY. Note it stores an ABSOLUTE
// `expiresAt` (ms since epoch) rather than a relative lifetime — identical to
// the legacy `cinny_expires_at` semantics — so reads stay drift-free.
@@ -266,6 +281,7 @@ export function setFallbackSession(
extra?: FallbackSessionExtra,
) {
const persisted = buildPersisted(accessToken, deviceId, userId, baseUrl, extra);
if (keychainMode) memorySession = persisted;
// ONE setItem — the blob can never be observed half-written.
localStorage.setItem(SESSION_BLOB_KEY, JSON.stringify(persisted));
// Dual-write the legacy keys (removal of this half is a future release).
@@ -276,6 +292,7 @@ export function setFallbackSession(
// Clear BOTH the atomic blob and every legacy key so no reader (blob-preferring
// or legacy-fallback) can resurrect a logged-out session.
export const removeFallbackSession = () => {
memorySession = undefined;
localStorage.removeItem(SESSION_BLOB_KEY);
Object.values(LEGACY_KEYS).forEach((key) => localStorage.removeItem(key));
Object.values(OIDC_KEYS).forEach((key) => localStorage.removeItem(key));
@@ -286,7 +303,23 @@ export const removeFallbackSession = () => {
// corrupt/partial we transparently assemble from the legacy keys (migration);
// the next setFallbackSession then persists the blob. When both exist the blob
// wins by construction.
// The stored session with its tokens, choosing blob vs legacy as below.
const readStoredPersisted = (): PersistedSession | undefined => {
const blob = readSessionBlob();
const legacy = readLegacyKeys();
if (
blob &&
legacy &&
typeof legacy.expiresAt === 'number' &&
(typeof blob.expiresAt !== 'number' || legacy.expiresAt > blob.expiresAt)
) {
return legacy;
}
return blob ?? legacy;
};
export const getFallbackSession = (): Session | undefined => {
if (keychainMode) return memorySession ? sessionFromPersisted(memorySession) : undefined;
const blob = readSessionBlob();
const legacy = readLegacyKeys();
// Prefer the atomic blob, EXCEPT when the legacy keys carry a later expiry: a
@@ -305,6 +338,112 @@ export const getFallbackSession = (): Session | undefined => {
if (!persisted) return undefined;
return sessionFromPersisted(persisted);
};
// --- [Gitea #105] desktop keychain session -----------------------------------
export type KeychainSessionTokens = {
userId: string;
deviceId: string;
accessToken: string;
refreshToken?: string;
};
/** The shell blob written while the tokens are in the keychain, if any. */
const readShell = (): Omit<ShellSession, 'tokensIn'> | undefined => {
const raw = localStorage.getItem(SESSION_BLOB_KEY);
if (!raw) return undefined;
try {
const p = JSON.parse(raw) as Partial<ShellSession>;
if (
p?.tokensIn !== 'keychain' ||
typeof p.deviceId !== 'string' ||
typeof p.userId !== 'string' ||
typeof p.baseUrl !== 'string'
)
return undefined;
const { tokensIn: _drop, ...rest } = p as ShellSession;
return rest;
} catch {
return undefined;
}
};
/** A session in localStorage that still carries its tokens (blob or legacy). */
export const readStoredSessionWithTokens = (): Session | undefined => {
const persisted = readStoredPersisted();
return persisted ? sessionFromPersisted(persisted) : undefined;
};
/** Whether localStorage holds a token-less shell (tokens are in the keychain). */
export const hasKeychainShell = (): boolean => readShell() !== undefined;
export type KeychainBoot =
/** Use the keychain: memory holds `session` (or none = signed out). */
| { mode: 'keychain'; session: Session | undefined }
/** A shell says the tokens are in the keychain, but they can't be read. */
| { mode: 'missing'; userId: string };
/**
* Decide the boot session from the keychain's tokens and localStorage, and
* switch this tab to keychain mode. `tokens` is what the keychain returned
* (null = no entry). Pure apart from reading localStorage and setting the
* in-memory state.
*/
export const enterKeychainMode = (tokens: KeychainSessionTokens | null): KeychainBoot => {
const withTokens = readStoredPersisted();
const shell = readShell();
keychainMode = true;
if (withTokens) {
// Pre-step-2 install, or a write not yet confirmed: localStorage has the
// full session and stays authoritative until the mirror verifies it.
memorySession = withTokens;
return { mode: 'keychain', session: sessionFromPersisted(withTokens) };
}
if (shell) {
if (tokens && tokens.userId === shell.userId && tokens.deviceId === shell.deviceId) {
memorySession = {
...shell,
accessToken: tokens.accessToken,
...(tokens.refreshToken ? { refreshToken: tokens.refreshToken } : {}),
};
return { mode: 'keychain', session: sessionFromPersisted(memorySession) };
}
// Never treat this as a logout: the shell stays, the caller offers Retry.
memorySession = undefined;
return { mode: 'missing', userId: shell.userId };
}
memorySession = undefined;
return { mode: 'keychain', session: undefined };
};
/** Leave keychain mode (the keychain failed): localStorage is authoritative again. */
export const leaveKeychainMode = (): void => {
keychainMode = false;
memorySession = undefined;
};
/**
* The keychain now verifiably holds `tokens`: if they're still the current
* session's, drop the tokens from localStorage (shell blob, no legacy keys).
*/
export const stripTokensFromStorage = (tokens: KeychainSessionTokens): boolean => {
const m = memorySession;
if (
!keychainMode ||
!m ||
m.userId !== tokens.userId ||
m.deviceId !== tokens.deviceId ||
m.accessToken !== tokens.accessToken ||
(m.refreshToken ?? undefined) !== (tokens.refreshToken ?? undefined)
)
return false;
const { accessToken: _a, refreshToken: _r, ...rest } = m;
const shell: ShellSession = { ...rest, tokensIn: 'keychain' };
localStorage.setItem(SESSION_BLOB_KEY, JSON.stringify(shell));
Object.values(LEGACY_KEYS).forEach((key) => localStorage.removeItem(key));
Object.values(OIDC_KEYS).forEach((key) => localStorage.removeItem(key));
return true;
};
/**
* End of migration code for old session
*/
+3
View File
@@ -310,6 +310,8 @@ export interface Settings {
screenshareFramerate: ScreenshareFramerate;
// [P5-15] In-call soundboard
soundboardEnabled: boolean;
// [Gitea #253] The call-ended toast (with its Details card).
callSummaryToast: boolean;
soundboardVolume: number; // 0–100
seasonalThemeOverride: SeasonalThemeOverride;
@@ -429,6 +431,7 @@ const defaultSettings: Settings = {
screenshareBitrate: 'auto',
screenshareFramerate: 'auto',
soundboardEnabled: true,
callSummaryToast: true,
soundboardVolume: 80,
seasonalThemeOverride: 'auto',
+2
View File
@@ -13,6 +13,8 @@ export type ToastNotif = {
onClick?: () => void; // custom click handler; skips hash navigation when set
sticky?: boolean; // when true, does not auto-dismiss — use for action toasts that require a click
onDismiss?: () => void; // called when the user closes the toast with its X (not on click/eviction)
actionLabel?: string; // [Gitea #253] a small button on the toast, e.g. "Details"
onAction?: () => void;
createdAt?: number; // set by toastQueueAtom when enqueued; used for #80 eviction ordering
};
+4
View File
@@ -2,3 +2,7 @@ import { atom } from 'jotai';
// Whether the room's Widgets side-panel is open (mirrors mediaGalleryAtom).
export const widgetsPanelAtom = atom<boolean>(false);
// [Gitea #205] Which widget the panel is showing, per room, so a floating
// widget's "Back to room" can open the panel on it.
export const widgetViewingAtom = atom<Record<string, string | null>>({});
+9
View File
@@ -0,0 +1,9 @@
import { toRem } from 'folds';
/**
* One width for every right-hand room panel (members, bookmarks, threads, a
* thread, media gallery, widgets). Swapping one panel for another must not
* resize the room view: when the widths differed, the header icons slid
* sideways and a second click on the same spot hit a different button (#263).
*/
export const SIDE_PANEL_WIDTH = toRem(340);
+2
View File
@@ -5,6 +5,8 @@
* z-index values and is intentionally not listed here.
*/
export const zIndices = {
/** [Gitea #205] A room widget kept on screen after leaving its room. */
floatingWidget: 9980,
/** In-call incoming-call banner — below seasonal/night-light/modals. */
inCallBanner: 9990,
/** Seasonal particle effect — below the night-light tint so particles tint. */
+11
View File
@@ -18,6 +18,17 @@ export function getAccountData<T>(
return event?.getContent() as T | undefined;
}
/** Room account data under a custom or developer-chosen type (same cast). */
export function setRoomAccountData<T>(
mx: MatrixClient,
roomId: string,
eventType: string,
content: T,
): Promise<unknown> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (mx as any).setRoomAccountData(roomId, eventType, content);
}
export function setAccountData<T>(
mx: MatrixClient,
eventType: AccountDataEvent | string,
+100 -1
View File
@@ -1,6 +1,11 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { describeCallDuration, describeCallEnd } from './callSummary';
import {
describeCallDuration,
describeCallEnd,
describeCallDetails,
parseCallSummaryDetails,
} from './callSummary';
describe('describeCallDuration', () => {
it('picks the unit', () => {
@@ -65,3 +70,97 @@ describe('describeCallEnd', () => {
);
});
});
it('[#253] parseCallSummaryDetails keeps well-formed fields and drops the rest', () => {
const d = parseCallSummaryDetails({
participants: ['@bob:x', 7, '@carol:x'],
peakParticipants: 3,
quality: {
youPoorMs: 1000,
othersPoorMs: { '@bob:x': 500, evil: 9, '@c:x': -1 },
everyonePoorMs: 0,
},
network: { rttMedianMs: 38, rttP95Ms: 'fast', inboundLossPct: 0.5 },
activity: { speakingMs: 60_000, mutedMs: 'x', screenshareMs: 0 },
});
assert.deepEqual(d, {
participants: ['@bob:x', '@carol:x'],
peakParticipants: 3,
quality: { youPoorMs: 1000, othersPoorMs: { '@bob:x': 500 }, everyonePoorMs: 0 },
network: { rttMedianMs: 38, inboundLossPct: 0.5 },
activity: { speakingMs: 60_000, mutedMs: 0, screenshareMs: 0 },
});
assert.equal(parseCallSummaryDetails(undefined), undefined);
assert.equal(parseCallSummaryDetails('details'), undefined);
});
it('[#253] describeCallDetails: technical sections with names, blame and numbers', () => {
const names: Record<string, string> = { '@bob:x': 'Bob', '@carol:x': 'Carol' };
const sections = describeCallDetails(
{
durationMs: 2_460_000,
reconnects: 2,
poorMs: 120_000,
verdict: 'fair',
details: {
participants: ['@bob:x', '@carol:x'],
peakParticipants: 3,
quality: {
youPoorMs: 120_000,
othersPoorMs: { '@carol:x': 30_000 },
everyonePoorMs: 10_000,
},
network: {
rttMedianMs: 38,
rttP95Ms: 310,
outboundLossPct: 4.1,
inboundLossPct: 0.5,
jitterMs: 6,
},
activity: { speakingMs: 600_000, mutedMs: 1_200_000, screenshareMs: 300_000 },
},
},
2_460_000,
90_000,
(u) => names[u] ?? u,
);
assert.deepEqual(sections, [
{ title: 'Call', lines: ['Duration 41 min · peak 3 in the call', 'With Bob, Carol'] },
{
title: 'Connection',
lines: [
'Verdict: fair · 2 reconnects',
'Your connection poor/lost: 2 min',
'Carol poor/lost: 30 s',
'Everyone poor at once: 10 s (likely server or SFU side)',
],
},
{
title: 'Network',
lines: [
'RTT median 38 ms · p95 310 ms',
'Outbound packet loss 4.1%',
'Inbound packet loss 0.5%',
'Jitter 6 ms',
],
},
{
title: 'You',
lines: ['Talking 10 min · muted 20 min · deafened 2 min', 'Screensharing 5 min'],
},
]);
});
it('[#253] describeCallDetails without fork details (older fork) still says something useful', () => {
const sections = describeCallDetails(
{ durationMs: 60_000, reconnects: 0, poorMs: 0, verdict: 'good' },
60_000,
0,
(u) => u,
);
assert.deepEqual(
sections.map((s) => s.title),
['Call', 'Connection'],
);
assert.deepEqual(sections[0].lines, ['Duration 1 min', 'Participants unknown']);
});
+120
View File
@@ -32,3 +32,123 @@ export function describeCallEnd(durationMs: number, summary?: LotusCallSummary):
}
return parts.join(' · ');
}
/** [Gitea #253] The fork's `details` in io.lotus.call_summary (lotus.29+). */
export type LotusCallSummaryDetails = {
participants: string[];
peakParticipants: number;
quality: { youPoorMs: number; othersPoorMs: Record<string, number>; everyonePoorMs: number };
network: {
rttMedianMs?: number;
rttP95Ms?: number;
outboundLossPct?: number;
inboundLossPct?: number;
jitterMs?: number;
};
activity: { speakingMs: number; mutedMs: number; screenshareMs: number };
};
const num = (v: unknown): number | undefined =>
typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined;
const obj = (v: unknown): Record<string, unknown> =>
typeof v === 'object' && v !== null && !Array.isArray(v) ? (v as Record<string, unknown>) : {};
/** Defensive: the frame is another origin; take only well-formed fields. */
export function parseCallSummaryDetails(raw: unknown): LotusCallSummaryDetails | undefined {
if (typeof raw !== 'object' || raw === null) return undefined;
const r = obj(raw);
const quality = obj(r.quality);
const network = obj(r.network);
const activity = obj(r.activity);
const othersPoorMs: Record<string, number> = {};
Object.entries(obj(quality.othersPoorMs)).forEach(([user, ms]) => {
const n = num(ms);
if (n !== undefined && user.startsWith('@')) othersPoorMs[user] = n;
});
const net: LotusCallSummaryDetails['network'] = {};
(['rttMedianMs', 'rttP95Ms', 'outboundLossPct', 'inboundLossPct', 'jitterMs'] as const).forEach(
(k) => {
const n = num(network[k]);
if (n !== undefined) net[k] = n;
},
);
return {
participants: Array.isArray(r.participants)
? r.participants.filter((p): p is string => typeof p === 'string').slice(0, 200)
: [],
peakParticipants: num(r.peakParticipants) ?? 1,
quality: {
youPoorMs: num(quality.youPoorMs) ?? 0,
othersPoorMs,
everyonePoorMs: num(quality.everyonePoorMs) ?? 0,
},
network: net,
activity: {
speakingMs: num(activity.speakingMs) ?? 0,
mutedMs: num(activity.mutedMs) ?? 0,
screenshareMs: num(activity.screenshareMs) ?? 0,
},
};
}
export type CallSummarySection = { title: string; lines: string[] };
/**
* [Gitea #253] The Details card, in technical wording (the owner's choice):
* who was there, connection quality and whose side it was on, network
* numbers, and your own activity. `nameOf` turns a user id into a display name.
*/
export function describeCallDetails(
summary: LotusCallSummary | undefined,
durationMs: number,
deafenedMs: number,
nameOf: (userId: string) => string,
): CallSummarySection[] {
const sections: CallSummarySection[] = [];
const d = summary?.details;
const dur = describeCallDuration;
const people = d?.participants ?? [];
sections.push({
title: 'Call',
lines: [
`Duration ${dur(durationMs)}${d ? ` · peak ${d.peakParticipants} in the call` : ''}`,
people.length
? `With ${people.map(nameOf).join(', ')}`
: d
? 'Nobody else joined'
: 'Participants unknown',
],
});
if (summary) {
const quality: string[] = [
`Verdict: ${summary.verdict} · ${summary.reconnects} reconnect${summary.reconnects === 1 ? '' : 's'}`,
];
if (d) {
quality.push(`Your connection poor/lost: ${dur(d.quality.youPoorMs)}`);
Object.entries(d.quality.othersPoorMs)
.sort((a, b) => b[1] - a[1])
.forEach(([user, ms]) => quality.push(`${nameOf(user)} poor/lost: ${dur(ms)}`));
if (d.quality.everyonePoorMs > 0)
quality.push(
`Everyone poor at once: ${dur(d.quality.everyonePoorMs)} (likely server or SFU side)`,
);
} else quality.push(`Your connection poor/lost: ${dur(summary.poorMs)}`);
sections.push({ title: 'Connection', lines: quality });
}
if (d) {
const n = d.network;
const net: string[] = [];
if (n.rttMedianMs !== undefined)
net.push(`RTT median ${n.rttMedianMs} ms · p95 ${n.rttP95Ms ?? n.rttMedianMs} ms`);
if (n.outboundLossPct !== undefined) net.push(`Outbound packet loss ${n.outboundLossPct}%`);
if (n.inboundLossPct !== undefined) net.push(`Inbound packet loss ${n.inboundLossPct}%`);
if (n.jitterMs !== undefined) net.push(`Jitter ${n.jitterMs} ms`);
if (net.length) sections.push({ title: 'Network', lines: net });
const act = [
`Talking ${dur(d.activity.speakingMs)} · muted ${dur(d.activity.mutedMs)} · deafened ${dur(deafenedMs)}`,
];
if (d.activity.screenshareMs > 0) act.push(`Screensharing ${dur(d.activity.screenshareMs)}`);
sections.push({ title: 'You', lines: act });
}
return sections;
}
+86
View File
@@ -0,0 +1,86 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import {
getKeyUploadWatch,
isKeyUploadUrl,
isOtkConflict,
recordKeyUpload,
resetKeyUploadWatch,
STUCK_AFTER,
subscribeKeyUploadWatch,
WINDOW_MS,
watchKeyUploads,
} from './keyUploadWatch';
const CONFLICT = JSON.stringify({
errcode: 'M_UNKNOWN',
error:
'One time key signed_curve25519:AAAAAAAAAA0 already exists. Old key: {...}; new key: {...}',
});
test('[#201] recognises the upload endpoint and the conflict body', () => {
assert.equal(isKeyUploadUrl('https://hs.example/_matrix/client/v3/keys/upload'), true);
assert.equal(isKeyUploadUrl('https://hs.example/_matrix/client/v3/keys/upload/'), true);
assert.equal(isKeyUploadUrl('https://hs.example/_matrix/client/v3/keys/query'), false);
assert.equal(isKeyUploadUrl('https://hs.example/_matrix/client/v3/room_keys/keys'), false);
assert.equal(isOtkConflict(400, CONFLICT), true);
assert.equal(isOtkConflict(400, '{"errcode":"M_BAD_JSON"}'), false);
assert.equal(isOtkConflict(500, CONFLICT), false);
});
test('[#201] stuck only after repeated conflicts inside the window', () => {
resetKeyUploadWatch();
const t0 = 1_000_000;
for (let i = 0; i < STUCK_AFTER - 1; i += 1) recordKeyUpload(400, CONFLICT, t0 + i * 1000);
assert.equal(getKeyUploadWatch().stuck, false, 'a couple of races is not divergence');
recordKeyUpload(400, CONFLICT, t0 + 5000);
assert.equal(getKeyUploadWatch().stuck, true);
assert.match(getKeyUploadWatch().lastError ?? '', /already exists/);
});
test('[#201] old conflicts age out; other 400s are ignored', () => {
resetKeyUploadWatch();
recordKeyUpload(400, CONFLICT, 0);
recordKeyUpload(400, CONFLICT, 1000);
recordKeyUpload(400, CONFLICT, WINDOW_MS + 60_000);
assert.equal(getKeyUploadWatch().stuck, false);
recordKeyUpload(400, '{"errcode":"M_BAD_JSON"}', WINDOW_MS + 61_000);
assert.equal(getKeyUploadWatch().conflicts, 1);
});
test('[#201] a successful upload clears it and notifies', () => {
resetKeyUploadWatch();
let calls = 0;
const off = subscribeKeyUploadWatch(() => {
calls += 1;
});
for (let i = 0; i < STUCK_AFTER; i += 1) recordKeyUpload(400, CONFLICT, i);
assert.equal(getKeyUploadWatch().stuck, true);
recordKeyUpload(200, '');
assert.equal(getKeyUploadWatch().stuck, false);
assert.ok(calls >= 2);
off();
});
test('[#201] the fetch wrapper observes without changing the response', async () => {
resetKeyUploadWatch();
const fake: typeof fetch = async (input) =>
String(input).endsWith('/keys/upload')
? new Response(CONFLICT, { status: 400 })
: new Response('{}', { status: 200 });
const f = watchKeyUploads(fake);
const responses = await Promise.all(
Array.from({ length: STUCK_AFTER }, () =>
f('https://hs.example/_matrix/client/v3/keys/upload', { method: 'POST' }),
),
);
const bodies = await Promise.all(responses.map((res) => res.text()));
responses.forEach((res) => assert.equal(res.status, 400));
bodies.forEach((b) => assert.match(b, /already exists/, 'the SDK can still read the body'));
await new Promise((r) => {
setTimeout(r, 10);
});
assert.equal(getKeyUploadWatch().stuck, true);
await f('https://hs.example/_matrix/client/v3/sync');
assert.equal(getKeyUploadWatch().stuck, true, 'unrelated requests change nothing');
});
+102
View File
@@ -0,0 +1,102 @@
/**
* [Gitea #201 KE-1] Notice when this device's encryption store has diverged
* from the server: every POST /keys/upload answers 400 "One time key ...
* already exists", and the SDK retries forever (matrix-rust-sdk#5200, open),
* so new encrypted messages and calls quietly degrade. The server saw 474k of
* these between May 30 and Jul 8 2026. The only fix is a fresh login on that
* device, so we tell the user (KeyUploadBanner) instead of looping silently.
*
* Watched at the fetch layer (MatrixClient `fetchFn`), so it doesn't depend on
* SDK log wording. Pure state + a tiny subscribe API; no network I/O of its own.
*/
/** Conflicts needed before we call the device stuck. The SDK retries within
* seconds, so a real divergence crosses this quickly; a one-off race doesn't. */
export const STUCK_AFTER = 3;
/** Conflicts older than this don't count (a long-ago blip isn't "now"). */
export const WINDOW_MS = 15 * 60 * 1000;
export type KeyUploadWatchState = { stuck: boolean; conflicts: number; lastError?: string };
let conflictTimes: number[] = [];
let lastError: string | undefined;
let state: KeyUploadWatchState = { stuck: false, conflicts: 0 };
const listeners = new Set<() => void>();
const publish = (next: KeyUploadWatchState) => {
if (next.stuck === state.stuck && next.conflicts === state.conflicts) return;
state = next;
listeners.forEach((l) => l());
};
export const isKeyUploadUrl = (url: string): boolean => {
try {
return /\/_matrix\/client\/[^/]+\/keys\/upload\/?$/.test(new URL(url, 'http://x').pathname);
} catch {
return false;
}
};
/** The 400 body that marks a diverged one-time-key store. */
export const isOtkConflict = (status: number, body: string): boolean =>
status === 400 && /one time key .*already exists/i.test(body);
/** Feed one /keys/upload response. `now` is injectable for tests. */
export const recordKeyUpload = (status: number, body: string, now = Date.now()): void => {
if (status >= 200 && status < 300) {
// A successful upload means the stores agree again.
conflictTimes = [];
lastError = undefined;
publish({ stuck: false, conflicts: 0 });
return;
}
if (!isOtkConflict(status, body)) return;
conflictTimes = [...conflictTimes, now].filter((t) => now - t <= WINDOW_MS);
lastError = body.slice(0, 300);
publish({
stuck: conflictTimes.length >= STUCK_AFTER,
conflicts: conflictTimes.length,
lastError,
});
};
export const getKeyUploadWatch = (): KeyUploadWatchState => state;
export const subscribeKeyUploadWatch = (cb: () => void): (() => void) => {
listeners.add(cb);
return () => listeners.delete(cb);
};
/** Test/logout helper: forget everything (a new session starts clean). */
export const resetKeyUploadWatch = (): void => {
conflictTimes = [];
lastError = undefined;
publish({ stuck: false, conflicts: 0 });
};
const urlOf = (input: RequestInfo | URL): string =>
typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
/**
* Wrap a fetch so /keys/upload responses are observed. The response the SDK
* gets is untouched; a clone is read in the background, never awaited.
*/
export const watchKeyUploads =
(inner: typeof fetch): typeof fetch =>
async (input, init) => {
const res = await inner(input, init);
try {
if (isKeyUploadUrl(urlOf(input))) {
if (res.ok) recordKeyUpload(res.status, '');
else if (res.status === 400)
res
.clone()
.text()
.then((body) => recordKeyUpload(res.status, body))
.catch(() => undefined);
}
} catch {
// observation must never break the request
}
return res;
};
+1 -1
View File
@@ -60,7 +60,7 @@ export const getStateEvents = (room: Room, eventType: StateEvent): MatrixEvent[]
export function sendStateEvent<T extends object>(
mx: MatrixClient,
roomId: string,
eventType: StateEvent,
eventType: StateEvent | string,
content: T,
stateKey = '',
): Promise<ISendEventResponse> {
+12
View File
@@ -179,3 +179,15 @@ test('groupScheduledByRoom: groups and sorts by sendAt', () => {
);
assert.equal(g.get('!2')?.length, 1);
});
test('[#275] the server limit maps to friendly text; other errors keep theirs', async () => {
const { describeScheduleError, SCHEDULE_TOO_FAR_TEXT, MAX_SCHEDULE_AHEAD_MS } =
await import('./scheduledMessages');
assert.equal(MAX_SCHEDULE_AHEAD_MS, 86_400_000);
const tooLarge = Object.assign(new Error('The requested delay (172800000ms) exceeds…'), {
errcode: 'ORG.MATRIX.MSC4140_DELAY_TOO_LARGE',
});
assert.equal(describeScheduleError(tooLarge), SCHEDULE_TOO_FAR_TEXT);
assert.equal(describeScheduleError(new Error('Boom')), 'Boom');
assert.equal(describeScheduleError('nope'), 'Failed to schedule message.');
});
+16
View File
@@ -1,6 +1,22 @@
import { IContent, MatrixClient, Method } from 'matrix-js-sdk';
import type { ScheduledMessage } from '../state/scheduledMessages';
/**
* [Gitea #275] Production Synapse caps delayed events at
* `max_event_delay_duration: 24h`; a later time is rejected with
* ORG.MATRIX.MSC4140_DELAY_TOO_LARGE. The dialog enforces the same limit and
* the server's error maps to the same text, in case the limit changes.
*/
export const MAX_SCHEDULE_AHEAD_MS = 24 * 60 * 60 * 1000;
export const SCHEDULE_TOO_FAR_TEXT = 'You can schedule up to 24 hours ahead.';
/** A user-facing sentence for a failed schedule. */
export const describeScheduleError = (err: unknown): string => {
const errcode = (err as { errcode?: unknown } | null)?.errcode;
if (errcode === 'ORG.MATRIX.MSC4140_DELAY_TOO_LARGE') return SCHEDULE_TOO_FAR_TEXT;
return err instanceof Error ? err.message : 'Failed to schedule message.';
};
/**
* Schedule a message via MSC4140 (delayed messages).
* Synapse implementation: pass org.matrix.msc4140.delay on the standard
+7
View File
@@ -109,3 +109,10 @@ describe('stripTrackingParamsInHtml', () => {
assert.equal(stripTrackingParamsInHtml(html), html);
});
});
it('[#280] Reddit keeps context= (it shows the parent comments) but drops share_id', () => {
assert.equal(
stripTrackingParams('https://www.reddit.com/r/x/comments/abc/def/xyz/?context=3&share_id=1'),
'https://www.reddit.com/r/x/comments/abc/def/xyz/?context=3',
);
});
+3 -1
View File
@@ -103,7 +103,9 @@ const HOST_PARAMS: Array<{ hosts: string[]; params: string[]; prefixes?: string[
},
{
hosts: ['reddit.com'],
params: ['share_id', 'rdt', 'context'],
// [Gitea #280] Not `context`: on a comment permalink, ?context=N shows the
// N parent comments, i.e. the conversation the sender meant to share.
params: ['share_id', 'rdt'],
},
{
hosts: ['tiktok.com'],
+32
View File
@@ -33,6 +33,7 @@ import {
spotifyEmbedHeight,
parseMediaEmbed,
isTwitterNoResults,
getVimeoEventParts,
} from './videoEmbed';
const HOST = 'chat.lotusguild.org';
@@ -429,3 +430,34 @@ test('isTwitterNoResults: ignores normal embed traffic and junk', () => {
assert.equal(isTwitterNoResults(null), false);
assert.equal(isTwitterNoResults({ type: 'MEASURE' }), false);
});
test('[#200] Vimeo live events embed from vimeo.com/event/{id}/embed', () => {
assert.deepEqual(getVimeoEventParts('https://vimeo.com/event/4321567'), {
id: '4321567',
hash: undefined,
});
assert.deepEqual(getVimeoEventParts('https://vimeo.com/event/4321567/a1b2c3d4e5'), {
id: '4321567',
hash: 'a1b2c3d4e5',
});
assert.equal(
getVimeoEventParts('https://vimeo.com/event/4321567/embed/a1b2c3d4e5')?.hash,
'a1b2c3d4e5',
);
assert.equal(getVimeoEventParts('https://vimeo.com/event/4321567/chat'), null);
assert.equal(getVimeoEventParts('https://vimeo.com/123456789'), null);
assert.equal(getVimeoEventParts('https://evil.example/event/4321567'), null);
assert.equal(
parseMediaEmbed('https://vimeo.com/event/4321567', 'h')?.embedUrl,
'https://vimeo.com/event/4321567/embed?autoplay=1&dnt=1',
);
assert.equal(
parseMediaEmbed('https://vimeo.com/event/4321567/a1b2c3d4e5', 'h')?.embedUrl,
'https://vimeo.com/event/4321567/embed/a1b2c3d4e5?autoplay=1&dnt=1',
);
// An ordinary video still goes to the player.
assert.match(
parseMediaEmbed('https://vimeo.com/123456789', 'h')?.embedUrl ?? '',
/^https:\/\/player\.vimeo\.com\/video\/123456789/,
);
});
+27
View File
@@ -80,6 +80,25 @@ export function getVimeoParts(url: string): { id: string; hash?: string } | null
}
}
/**
* [Gitea #200] Vimeo live events: vimeo.com/event/{id}, or /event/{id}/{hash}
* when unlisted. Embedded from vimeo.com itself (not player.vimeo.com); the
* web and desktop CSP `frame-src https:` already allow it.
*/
export function getVimeoEventParts(url: string): { id: string; hash?: string } | null {
try {
const { hostname, pathname } = new URL(url);
if (hostname !== 'vimeo.com' && hostname !== 'www.vimeo.com') return null;
const m = pathname.match(/^\/event\/(\d+)(?:\/(?:embed\/)?([0-9a-f]{6,}))?\/?$/);
return m ? { id: m[1], hash: m[2] } : null;
} catch {
return null;
}
}
export const buildVimeoEventEmbedUrl = (id: string, hash?: string): string =>
`https://vimeo.com/event/${enc(id)}/embed${hash ? `/${enc(hash)}` : ''}?autoplay=1&dnt=1`;
export function getVimeoVideoId(url: string): string | null {
return getVimeoParts(url)?.id ?? null;
}
@@ -713,6 +732,14 @@ export function parseMediaEmbed(url: string, host: string): MediaEmbed | null {
embedUrl: buildVideoEmbedUrl('youtube', ytId),
};
const vimeoEvent = getVimeoEventParts(url);
if (vimeoEvent)
return {
provider: 'vimeo',
kind: 'landscape',
embedUrl: buildVimeoEventEmbedUrl(vimeoEvent.id, vimeoEvent.hash),
};
const vimeo = getVimeoParts(url);
if (vimeo)
return {
+25 -13
View File
@@ -3,12 +3,13 @@ import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from
import { cryptoCallbacks } from './secretStorageKeys';
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
import { getFallbackSession, removeFallbackSession, Session } from '../app/state/sessions';
import { LotusOidcTokenRefresher } from './oidcTokenRefresher';
import { revokeOidcTokens } from './oidcLogout';
import { installRefreshGuard, OidcIdentity, persistRefreshedTokens } from './oidcTokenRefresher';
import { pushSessionToSW } from '../sw-session';
import { deleteSearchCacheDatabase, shouldRunBootCleanup } from '../app/utils/searchCache';
import { clearPlaintextCaches } from '../app/state/plaintextCaches';
import { watchKeyUploads } from '../app/utils/keyUploadWatch';
import { clearSoundboardClipCache } from '../app/utils/soundboardClips';
import { clearSharedPayload } from '../swShare';
// Thrown when the local IndexedDB has a higher schema version than this SDK expects.
// This happens after a downgrade (e.g. matrix-js-sdk was briefly upgraded and then reverted).
@@ -60,12 +61,19 @@ export const initClient = async (session: Session): Promise<MatrixClient> => {
const legacyCryptoStore = new IndexedDBCryptoStore(globalThis.indexedDB, 'crypto-store');
// OIDC/next-gen-auth sessions carry a refresh token; wire automatic refresh
// (the client calls this reactively on a 401) and persist rotated tokens.
const oidcRefresher =
// OIDC/next-gen-auth sessions carry a refresh token. Since SDK 43 the client
// refreshes them itself; we persist the rotated tokens and serialise
// refreshes across tabs (oidcTokenRefresher).
const oidcIdentity: OidcIdentity | undefined =
session.refreshToken && session.oidc
? new LotusOidcTokenRefresher(session.oidc, session.deviceId, session.userId, session.baseUrl)
? {
userId: session.userId,
deviceId: session.deviceId,
baseUrl: session.baseUrl,
oidc: session.oidc,
}
: undefined;
if (oidcIdentity) installRefreshGuard(oidcIdentity);
const mx = createClient({
baseUrl: session.baseUrl,
@@ -75,12 +83,16 @@ export const initClient = async (session: Session): Promise<MatrixClient> => {
store: indexedDBStore,
cryptoStore: legacyCryptoStore,
deviceId: session.deviceId,
// [Gitea #201] Observe /keys/upload so a diverged OTK store is reported to
// the user (KeyUploadBanner) instead of retrying silently forever.
fetchFn: watchKeyUploads((input, init) => globalThis.fetch(input, init)),
timelineSupport: true,
cryptoCallbacks: cryptoCallbacks as any,
// SAS (emoji) + QR-code verification (show/scan/reciprocate).
verificationMethods: ['m.sas.v1', 'm.qr_code.show.v1', 'm.qr_code.scan.v1', 'm.reciprocate.v1'],
tokenRefreshFunction: oidcRefresher
? (refreshToken) => oidcRefresher.doRefreshAccessToken(refreshToken)
oauthClientId: oidcIdentity?.oidc.clientId,
onTokenRefresh: oidcIdentity
? (tokens) => persistRefreshedTokens(oidcIdentity, tokens)
: undefined,
});
@@ -125,11 +137,8 @@ export const clearCacheAndReload = async (mx: MatrixClient) => {
export const logoutClient = async (mx: MatrixClient) => {
pushSessionToSW();
mx.stopClient();
// For OIDC sessions, revoke the tokens at the issuer too (best-effort).
const session = getFallbackSession();
if (session?.oidc) {
await revokeOidcTokens(session);
}
// For OIDC sessions the SDK revokes the tokens at the auth server instead of
// calling /logout (matrix-js-sdk 43+); best-effort either way.
try {
await mx.logout();
} catch {
@@ -146,6 +155,9 @@ export const logoutClient = async (mx: MatrixClient) => {
// [Gitea #57] Same reasoning as clearPlaintextCaches: decrypted soundboard
// clip bytes stay reachable via live blob: URLs until the reload otherwise.
clearSoundboardClipCache();
// [Gitea #267] Files stashed by the share target stay in Cache Storage until
// /share is opened; a shared photo must not outlive the logout.
await clearSharedPayload().catch(() => undefined);
// Remove only the session credential keys, preserving user preferences and
// unsent drafts (N98). The factory-reset path is clearLoginData() below.
removeFallbackSession();
-29
View File
@@ -1,29 +0,0 @@
import { discoverAndValidateOIDCIssuerWellKnown } from 'matrix-js-sdk';
import { Session } from '../app/state/sessions';
/**
* Best-effort revoke the OIDC access + refresh tokens at the issuer's revocation
* endpoint during logout. Tolerant of any failure — logout proceeds regardless
* (the local session is cleared by the caller either way).
*/
export const revokeOidcTokens = async (session: Session): Promise<void> => {
if (!session.oidc) return;
try {
const config = await discoverAndValidateOIDCIssuerWellKnown(session.oidc.issuer);
const endpoint = config.revocation_endpoint;
if (!endpoint) return;
const { clientId } = session.oidc;
const revoke = (token: string, hint: string): Promise<Response> =>
fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ token, token_type_hint: hint, client_id: clientId }),
});
const requests: Promise<Response>[] = [];
if (session.refreshToken) requests.push(revoke(session.refreshToken, 'refresh_token'));
if (session.accessToken) requests.push(revoke(session.accessToken, 'access_token'));
await Promise.allSettled(requests);
} catch {
/* issuer unreachable / no revocation endpoint — ignore */
}
};
+118
View File
@@ -0,0 +1,118 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
const store = new Map<string, string>();
(globalThis as { localStorage?: unknown }).localStorage = {
getItem: (k: string) => store.get(k) ?? null,
setItem: (k: string, v: string) => {
store.set(k, v);
},
removeItem: (k: string) => {
store.delete(k);
},
};
const sessions = await import('../app/state/sessions');
const { guardRefreshFetch, refreshGrantToken } = await import('./oidcTokenRefresher');
const id = {
userId: '@a:hs.example',
deviceId: 'DEV1',
baseUrl: 'https://hs.example',
oidc: { issuer: 'https://auth.example/', clientId: 'c1', redirectUri: 'https://app/cb' },
};
const grant = (refresh: string): RequestInit => {
const body = new URLSearchParams();
body.append('grant_type', 'refresh_token');
body.append('client_id', 'c1');
body.append('refresh_token', refresh);
return { method: 'POST', body };
};
const persist = (access: string, refresh: string) =>
sessions.setFallbackSession(access, id.deviceId, id.userId, id.baseUrl, {
refreshToken: refresh,
oidc: id.oidc,
expiresInMs: 300_000,
});
test('[#16] recognises only refresh-token grants', () => {
assert.equal(refreshGrantToken(grant('r1')), 'r1');
assert.equal(
refreshGrantToken({ method: 'POST', body: 'grant_type=refresh_token&refresh_token=r2' }),
'r2',
);
assert.equal(
refreshGrantToken({ method: 'POST', body: 'grant_type=authorization_code&code=x' }),
undefined,
);
assert.equal(refreshGrantToken({ method: 'GET' }), undefined);
assert.equal(refreshGrantToken(undefined), undefined);
});
test('[#16] a real refresh is persisted before the lock is released', async () => {
store.clear();
persist('at1', 'r1');
let calls = 0;
const inner: typeof fetch = async () => {
calls += 1;
return new Response(
JSON.stringify({
token_type: 'Bearer',
access_token: 'at2',
refresh_token: 'r2',
expires_in: 300,
}),
{ status: 200 },
);
};
const res = await guardRefreshFetch(inner, id)('https://auth.example/token', grant('r1'));
assert.equal(calls, 1);
assert.equal((await res.json()).access_token, 'at2', 'the SDK still reads the body');
const s = sessions.getFallbackSession();
assert.equal(s?.accessToken, 'at2');
assert.equal(s?.refreshToken, 'r2');
assert.ok((s?.expiresInMs ?? 0) > 290_000);
});
test('[#16] the losing tab adopts the winner instead of spending a used token', async () => {
store.clear();
persist('at-winner', 'r-winner'); // a sibling tab already rotated r-old
let calls = 0;
const inner: typeof fetch = async () => {
calls += 1;
return new Response('{"error":"invalid_grant"}', { status: 400 });
};
const res = await guardRefreshFetch(inner, id)('https://auth.example/token', grant('r-old'));
assert.equal(calls, 0, 'never hits the issuer');
const body = await res.json();
assert.equal(res.status, 200);
assert.equal(body.token_type, 'Bearer');
assert.equal(body.access_token, 'at-winner');
assert.equal(body.refresh_token, 'r-winner');
});
test('[#16] another account in storage is never adopted', async () => {
store.clear();
sessions.setFallbackSession('at-other', 'DEV9', '@b:hs.example', id.baseUrl, {
refreshToken: 'r-other',
});
let calls = 0;
const inner: typeof fetch = async () => {
calls += 1;
return new Response(JSON.stringify({ token_type: 'Bearer', access_token: 'at2' }), {
status: 200,
});
};
await guardRefreshFetch(inner, id)('https://auth.example/token', grant('r1'));
assert.equal(calls, 1);
});
test('[#16] other requests pass straight through', async () => {
let seen = '';
const inner: typeof fetch = async (input) => {
seen = String(input);
return new Response('{}');
};
await guardRefreshFetch(inner, id)('https://hs.example/_matrix/client/v3/sync');
assert.equal(seen, 'https://hs.example/_matrix/client/v3/sync');
});
+99 -71
View File
@@ -1,9 +1,13 @@
import { AccessTokens, OidcTokenRefresher } from 'matrix-js-sdk';
import type { IdTokenClaims } from 'oidc-client-ts';
import type { AccessTokens } from 'matrix-js-sdk';
import { getFallbackSession, OidcSessionMeta, setFallbackSession } from '../app/state/sessions';
// Since matrix-js-sdk 43 the SDK refreshes OAuth tokens itself (MatrixClient
// `oauthClientId` + `onTokenRefresh`). This module keeps the two things Lotus
// added on top: rotated tokens are persisted (F5), and refreshes are
// serialised across tabs (Gitea #16).
// Web Lock name serialising OIDC refreshes across tabs (Gitea #16). Every tab
// runs its own refresher against the SAME stored refresh token; with rotating
// runs its own client against the SAME stored refresh token; with rotating
// refresh tokens the second tab to hit the issuer gets `invalid_grant` and is
// signed out. Holding the lock while refreshing (and re-reading storage once
// inside it) makes the loser adopt the winner's tokens instead.
@@ -19,82 +23,106 @@ export const withRefreshLock = <T>(fn: () => Promise<T>): Promise<T> => {
return locks.request(REFRESH_LOCK_NAME, fn);
};
export type OidcIdentity = {
userId: string;
deviceId: string;
baseUrl: string;
oidc: OidcSessionMeta;
};
/** F5 — keep the stored session (and its expiry) in step with every refresh. */
export const persistRefreshedTokens = (id: OidcIdentity, tokens: AccessTokens): void => {
const expiresInMs =
tokens.expiry instanceof Date ? Math.max(0, tokens.expiry.getTime() - Date.now()) : undefined;
setFallbackSession(tokens.accessToken, id.deviceId, id.userId, id.baseUrl, {
refreshToken: tokens.refreshToken,
oidc: id.oidc,
expiresInMs,
});
};
/** The refresh token a request is spending, if it is an OAuth refresh grant. */
export const refreshGrantToken = (init?: RequestInit): string | undefined => {
if (!init || (init.method ?? 'GET').toUpperCase() !== 'POST') return undefined;
const { body } = init;
let params: URLSearchParams | undefined;
if (body instanceof URLSearchParams) params = body;
else if (typeof body === 'string') params = new URLSearchParams(body);
if (params?.get('grant_type') !== 'refresh_token') return undefined;
return params.get('refresh_token') ?? undefined;
};
/**
* OidcTokenRefresher that persists rotated tokens back to the fallback session,
* so a page reload keeps the freshest access/refresh token. The matrix client
* calls this automatically (reactively on a 401) when a refresh token is set.
* #16 — wrap `fetch` so OAuth refresh grants run one at a time across tabs.
* Inside the lock: if storage already holds a DIFFERENT refresh token for this
* user + device, a sibling tab won the race, so answer with its tokens (a
* well-formed token response) instead of spending a consumed refresh token.
* Comparing refresh tokens (not access tokens) can never adopt the token that
* just failed, so this cannot loop. A real refresh is persisted BEFORE the lock
* is released, so the next tab in line sees it. Every other request passes
* straight through.
*/
export class LotusOidcTokenRefresher extends OidcTokenRefresher {
private readonly deviceIdRef: string;
private readonly userIdRef: string;
private readonly baseUrlRef: string;
private readonly oidcRef: OidcSessionMeta;
constructor(oidc: OidcSessionMeta, deviceId: string, userId: string, baseUrl: string) {
super(
oidc.issuer,
oidc.clientId,
oidc.redirectUri,
deviceId,
(oidc.idTokenClaims ?? {}) as unknown as IdTokenClaims,
);
this.deviceIdRef = deviceId;
this.userIdRef = userId;
this.baseUrlRef = baseUrl;
this.oidcRef = oidc;
}
// #16 — before touching the issuer, check whether another tab already rotated
// the tokens. `refreshToken` is exactly what the SDK currently holds, so a
// DIFFERENT stored refresh token (same user + device) means a sibling tab won
// the race: adopt its tokens instead of burning a possibly-consumed refresh
// token. Comparing refresh tokens (not access tokens) can never adopt the very
// token that just 401'd, so this cannot loop. The whole thing runs under a
// cross-tab Web Lock so concurrent refreshes serialise and the waiter sees
// the winner's write.
public doRefreshAccessToken(refreshToken: string): Promise<AccessTokens> {
export const guardRefreshFetch =
(inner: typeof fetch, id: OidcIdentity): typeof fetch =>
(input, init) => {
const spending = refreshGrantToken(init);
if (!spending) return inner(input, init);
return withRefreshLock(async () => {
const stored = getFallbackSession();
if (
stored &&
stored.userId === this.userIdRef &&
stored.deviceId === this.deviceIdRef &&
stored.userId === id.userId &&
stored.deviceId === id.deviceId &&
stored.refreshToken &&
stored.refreshToken !== refreshToken
stored.refreshToken !== spending
) {
return {
accessToken: stored.accessToken,
refreshToken: stored.refreshToken,
expiry:
typeof stored.expiresInMs === 'number'
? new Date(Date.now() + stored.expiresInMs)
: undefined,
};
return new Response(
JSON.stringify({
token_type: 'Bearer',
access_token: stored.accessToken,
refresh_token: stored.refreshToken,
...(typeof stored.expiresInMs === 'number'
? { expires_in: Math.floor(stored.expiresInMs / 1000) }
: {}),
}),
{ status: 200, headers: { 'Content-Type': 'application/json' } },
);
}
return super.doRefreshAccessToken(refreshToken);
const started = Date.now();
const res = await inner(input, init);
if (res.ok) {
try {
const body = (await res.clone().json()) as {
access_token?: unknown;
refresh_token?: unknown;
expires_in?: unknown;
};
if (typeof body.access_token === 'string') {
persistRefreshedTokens(id, {
accessToken: body.access_token,
refreshToken: typeof body.refresh_token === 'string' ? body.refresh_token : undefined,
expiry:
typeof body.expires_in === 'number'
? new Date(started + body.expires_in * 1000)
: undefined,
});
}
} catch {
// unreadable body: the SDK will report the failure itself
}
}
return res;
});
}
};
// F5 — persist the new expiry so the stored `expiresAt` stays fresh across
// reloads instead of going stale. The SDK invokes persistTokens synchronously
// inside the refresh and passes the freshly-refreshed `expiry` (a Date) on the
// tokens object at runtime, even though its published type omits it — so read
// it here directly (a doRefreshAccessToken override would run too late, since
// persistTokens is called before that method returns).
protected async persistTokens(tokens: {
accessToken: string;
refreshToken?: string;
expiry?: Date;
}): Promise<void> {
const expiresInMs =
tokens.expiry instanceof Date ? Math.max(0, tokens.expiry.getTime() - Date.now()) : undefined;
setFallbackSession(tokens.accessToken, this.deviceIdRef, this.userIdRef, this.baseUrlRef, {
refreshToken: tokens.refreshToken,
oidc: this.oidcRef,
expiresInMs,
});
}
}
let unguardedFetch: typeof fetch | undefined;
/**
* Install the #16 guard on `globalThis.fetch`. The SDK's OAuth calls use the
* global fetch directly (not the client's `fetchFn`), so this is the only
* place to catch them. Idempotent: re-installing replaces the guard.
*/
export const installRefreshGuard = (id: OidcIdentity): void => {
unguardedFetch ??= globalThis.fetch.bind(globalThis);
globalThis.fetch = guardRefreshFetch(unguardedFetch, id);
};
+4
View File
@@ -1,5 +1,9 @@
/// <reference types="vite/client" />
// [Gitea #276] Set by vite.config.js `define`.
declare const __LOTUS_BUILD_COMMIT__: string;
declare const __LOTUS_BUILD_DATE__: string;
declare module 'browser-encrypt-attachment' {
export interface EncryptedAttachmentInfo {
v: string;
+85 -67
View File
@@ -18,75 +18,18 @@ import './app/i18n';
import { pushSessionToSW } from './sw-session';
import { getFallbackSession } from './app/state/sessions';
import { startKeychainMirror } from './app/state/keychainMirror';
import { bootKeychainSession, KeychainBootResult } from './app/state/keychainSession';
import { KeychainUnavailable } from './app/pages/KeychainUnavailable';
import { tauriInvoke } from './app/hooks/useTauri';
import { cleanupSearchCacheIfSignedOut } from './client/initMatrix';
document.body.classList.add(configClass, varsClass);
// [Gitea #105] Desktop: keep a copy of the login tokens in the OS keychain
// (step 1: mirror only; the session is still read from localStorage).
startKeychainMirror(tauriInvoke());
// Register Service Worker
// Service workers only register on http(s) pages. The desktop app loads from
// `tauri://localhost` in debug builds (and on any platform where the localhost
// plugin isn't used), where register() rejects: that surfaced in Sentry as an
// unhandled "must be called with a script URL whose protocol is either HTTP or
// HTTPS". Skip it there; the app works without a SW, only authenticated media
// falls back to the client's own fetch.
const swProtocolOk = window.location.protocol === 'https:' || window.location.protocol === 'http:';
if ('serviceWorker' in navigator && swProtocolOk) {
const swUrl =
import.meta.env.MODE === 'production'
? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
: `/dev-sw.js?dev-sw`;
const sendSessionToSW = () => {
const session = getFallbackSession();
pushSessionToSW(session?.baseUrl, session?.accessToken, session?.userId);
};
// The dev worker is an ES module (it imports workbox), so it must be
// registered as one — otherwise "script evaluation failed" and the dev
// client has no SW: authenticated media 401s and notification clicks
// never route. Production sw.js is a classic bundled script.
navigator.serviceWorker
.register(swUrl, import.meta.env.MODE === 'production' ? undefined : { type: 'module' })
.then(sendSessionToSW)
.catch((err) => {
// e.g. a private window with SWs disabled; the app still works.
console.warn('Service worker registration failed', err);
});
navigator.serviceWorker.ready.then(sendSessionToSW);
navigator.serviceWorker.addEventListener('message', (ev) => {
const { type } = ev.data ?? {};
if (type === 'requestSession') {
sendSessionToSW();
}
});
}
// Request persistent storage so the browser can't evict the IndexedDB
// rust-crypto store under storage pressure. Eviction (while the localStorage
// session/device-id survives) resurrects the device with a blank crypto store,
// which then re-uploads OTKs the server already holds → the "one time key
// already exists" upload storm and E2EE breakage. Only ask for sessions worth
// protecting (skip anonymous/landing visitors to avoid a needless Firefox
// prompt); check persisted() first so we don't re-prompt. Best-effort.
// [Gitea #45] If a logout's search-index wipe lost the multi-tab race (another
// tab still held the DB), finish it now that no session exists.
if (!getFallbackSession()) {
cleanupSearchCacheIfSignedOut().catch(() => undefined);
}
if (navigator.storage?.persist && getFallbackSession()) {
navigator.storage
.persisted()
.then((already) => (already ? undefined : navigator.storage.persist()))
.catch(() => undefined);
}
// [Gitea #105] Desktop: the login tokens live in the OS keychain. Read them
// into memory BEFORE anything reads the session (step 2), then keep the
// keychain in line with every login / refresh / logout. If the keychain should
// hold them but can't be read, show Retry instead of the app, and don't start
// the mirror: it would clear the entry it couldn't read.
// Reload once if a lazy-loaded chunk is missing (stale deployment)
window.addEventListener('vite:preloadError', () => {
@@ -121,7 +64,72 @@ window.addEventListener('load', () => sessionStorage.removeItem('chunk-reload-at
};
}
const mountApp = () => {
// Everything that reads the session runs once the keychain step decided it.
const startSessionDependent = () => {
// Register Service Worker
// Service workers only register on http(s) pages. The desktop app loads from
// `tauri://localhost` in debug builds (and on any platform where the localhost
// plugin isn't used), where register() rejects: that surfaced in Sentry as an
// unhandled "must be called with a script URL whose protocol is either HTTP or
// HTTPS". Skip it there; the app works without a SW, only authenticated media
// falls back to the client's own fetch.
const swProtocolOk =
window.location.protocol === 'https:' || window.location.protocol === 'http:';
if ('serviceWorker' in navigator && swProtocolOk) {
const swUrl =
import.meta.env.MODE === 'production'
? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
: `/dev-sw.js?dev-sw`;
const sendSessionToSW = () => {
const session = getFallbackSession();
pushSessionToSW(session?.baseUrl, session?.accessToken, session?.userId);
};
// The dev worker is an ES module (it imports workbox), so it must be
// registered as one — otherwise "script evaluation failed" and the dev
// client has no SW: authenticated media 401s and notification clicks
// never route. Production sw.js is a classic bundled script.
navigator.serviceWorker
.register(swUrl, import.meta.env.MODE === 'production' ? undefined : { type: 'module' })
.then(sendSessionToSW)
.catch((err) => {
// e.g. a private window with SWs disabled; the app still works.
console.warn('Service worker registration failed', err);
});
navigator.serviceWorker.ready.then(sendSessionToSW);
navigator.serviceWorker.addEventListener('message', (ev) => {
const { type } = ev.data ?? {};
if (type === 'requestSession') {
sendSessionToSW();
}
});
}
// Request persistent storage so the browser can't evict the IndexedDB
// rust-crypto store under storage pressure. Eviction (while the localStorage
// session/device-id survives) resurrects the device with a blank crypto store,
// which then re-uploads OTKs the server already holds → the "one time key
// already exists" upload storm and E2EE breakage. Only ask for sessions worth
// protecting (skip anonymous/landing visitors to avoid a needless Firefox
// prompt); check persisted() first so we don't re-prompt. Best-effort.
// [Gitea #45] If a logout's search-index wipe lost the multi-tab race (another
// tab still held the DB), finish it now that no session exists.
if (!getFallbackSession()) {
cleanupSearchCacheIfSignedOut().catch(() => undefined);
}
if (navigator.storage?.persist && getFallbackSession()) {
navigator.storage
.persisted()
.then((already) => (already ? undefined : navigator.storage.persist()))
.catch(() => undefined);
}
};
const mountApp = (keychainBoot: KeychainBootResult, keychainBlocked: boolean) => {
const rootContainer = document.getElementById('root');
if (rootContainer === null) {
@@ -130,7 +138,17 @@ const mountApp = () => {
}
const root = createRoot(rootContainer);
root.render(<App />);
root.render(
keychainBlocked ? <KeychainUnavailable boot={keychainBoot} invoke={tauriInvoke()} /> : <App />,
);
};
mountApp();
bootKeychainSession(tauriInvoke())
// Whatever happens, the app mounts: an unexpected failure means "no keychain".
.catch((): KeychainBootResult => ({ mode: 'off' }))
.then((keychainBoot) => {
const keychainBlocked = keychainBoot.mode === 'missing' || keychainBoot.mode === 'error';
if (!keychainBlocked) startKeychainMirror(tauriInvoke());
startSessionDependent();
mountApp(keychainBoot, keychainBlocked);
});

Some files were not shown because too many files have changed in this diff Show More