fix: low-tail correctness — thread notifs, call audio, OIDC expiry

Verify-then-fix batch of minor bugs; each staged diff reviewed by 2 agents
(both SHIP). Two listed items (N6 receipt-avatar refresh, H10 room-name
length reject) were already handled and left unchanged.

Threads:
- T5: a just-sent reply no longer under-notifies — `participated` also checks
  the local thread timeline for our own events, since the server-bundle
  `hasCurrentUserParticipated` lags.
- T6: a room set to "Mentions & Keywords only" no longer over-notifies Default
  thread replies — new `roomMentionsOnly` gate (behavior-identical when false;
  +4 unit tests).
- T7: thread-mode account-data writes are serialized with content carried
  forward (setAccountData is a bare PUT whose result lags the /sync echo, so
  plain serialization wouldn't stop the lost update); carry only on success.

Calls / audio:
- C-L2: a real incoming ring cancels a lingering Settings ringtone preview.
- C-L3: the ringtone AudioContext is primed on the first page gesture (via the
  always-mounted CallEmbedProvider) so the first ring after a cold load isn't
  silent.
- C-L5: useCallSpeakers depends on a stable boolean, so the tile MutationObserver
  + io.lotus.call_state subscription aren't rebuilt on every membership change.

Crypto:
- F5: the OIDC refresher forwards the freshly-refreshed token expiry
  (passed on the tokens object at runtime) as expiresInMs, so the persisted
  expiresAt no longer goes stale across reloads.

Gates: tsc 0, eslint 0, prettier clean, 860/860 tests, build ok.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 02:47:27 -04:00
co-authored by Claude Opus 4.8
parent 291e14ab48
commit a267e9e960
8 changed files with 147 additions and 25 deletions
+16
View File
@@ -29,6 +29,18 @@ const getCtx = (): AudioContext | undefined => {
}
};
/**
* C-L3 — prime (create + resume) the shared ringtone AudioContext from within a
* user gesture. Browsers keep a fresh context suspended until a gesture, and an
* incoming-call ring fires with no gesture of its own, so the first ring after a
* cold page load could be silent (resume() is async and may not finish before
* the notes are scheduled). Call this on any early app gesture so a later ring
* plays through an already-running context. Mirrors `unlockCallSounds`.
*/
export const unlockRingtoneAudio = (): void => {
getCtx();
};
type Note = {
freq: number;
/** Offset from phrase start, in seconds */
@@ -173,6 +185,10 @@ const startSynth = (style: SynthStyle, volume: number, loop: boolean): (() => vo
* silent. This matches the pre-existing behaviour of the classic ringtone.
*/
export const startRingtone = (id: RingtoneId, volume: number): (() => void) => {
// C-L2 — a real incoming ring supersedes any lingering Settings preview so the
// two don't overlap (the preview is otherwise only cleared by its own timer).
activePreviewStop?.();
activePreviewStop = null;
if (id === 'none') return () => undefined;
if (id === 'classic') return startClassic(volume, true);
return startSynth(id, volume, true);
+20
View File
@@ -23,6 +23,7 @@ const decide = (
highlight: false,
notify: false,
roomMuted: false,
roomMentionsOnly: false,
...overrides,
});
@@ -53,6 +54,25 @@ describe('shouldNotifyThreadReply', () => {
assert.equal(decide({ mode: ThreadNotificationMode.All, highlight: false }), 'notify');
});
it('roomMentionsOnly: Default + participating + participated but no highlight => none', () => {
assert.equal(decide({ roomMentionsOnly: true, participated: true }), 'none');
});
it('roomMentionsOnly: Default + highlight still notifies loudly', () => {
assert.equal(decide({ roomMentionsOnly: true, highlight: true }), 'loud');
});
it('roomMentionsOnly does NOT suppress an explicit All override', () => {
assert.equal(
decide({ roomMentionsOnly: true, mode: ThreadNotificationMode.All, highlight: false }),
'notify',
);
});
it('roomMentionsOnly: Default + defaultBehavior all + no highlight => none', () => {
assert.equal(decide({ roomMentionsOnly: true, defaultBehavior: 'all' }), 'none');
});
it('mode MentionsOnly + highlight => loud', () => {
assert.equal(decide({ mode: ThreadNotificationMode.MentionsOnly, highlight: true }), 'loud');
});
+15 -7
View File
@@ -106,8 +106,16 @@ export function shouldNotifyThreadReply(input: {
highlight: boolean;
notify: boolean;
roomMuted: boolean;
/**
* The room is set to "Mentions & Keywords only" (room push rule, not the
* global default). When the thread mode is Default, this makes only
* highlights notify — honoring the room preference instead of the
* all/participating default (which otherwise over-notifies). An explicit
* per-thread All/MentionsOnly/Mute override still wins.
*/
roomMentionsOnly: boolean;
}): ThreadNotifyDecision {
const { mode, defaultBehavior, participated, highlight, roomMuted } = input;
const { mode, defaultBehavior, participated, highlight, roomMuted, roomMentionsOnly } = input;
if (roomMuted) return 'none';
if (mode === ThreadNotificationMode.Mute) return 'none';
@@ -120,13 +128,13 @@ export function shouldNotifyThreadReply(input: {
return highlight ? 'loud' : 'none';
}
// ThreadNotificationMode.Default
if (defaultBehavior === 'all') {
return highlight ? 'loud' : 'notify';
}
// defaultBehavior === 'participating'
// ThreadNotificationMode.Default — highlights always notify loudly.
if (highlight) return 'loud';
// Room is "Mentions & Keywords only": a Default thread inherits that, so a
// non-highlight reply does not notify.
if (roomMentionsOnly) return 'none';
if (defaultBehavior === 'all') return 'notify';
// defaultBehavior === 'participating'
return participated ? 'notify' : 'none';
}