Files
buzz/desktop
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d 6b7dc42001 fix(desktop): paint own thread replies optimistically instead of waiting for the relay echo
The thread pane renders the thread-replies query cache, whose only live
writer was the relay's WebSocket echo (post-commit, fire-and-forget on
the relay). useSendMessageMutation optimistically painted the channel
window but never threadRepliesKey(channelId, rootId), so a user's own
thread reply waited a full round-trip plus fanout lag to appear while
the main pane painted instantly — the thread pane absorbed 100% of echo
lag.

Mirror the optimistic lifecycle into the thread cache:

- onMutate inserts the pending reply under the resolved thread root
  (insertPendingThreadReply). Root resolution now searches cached
  thread subtrees too (collectReplyParentContext) — a nested reply's
  parent lives in the thread cache, not the channel timeline, and the
  old channel-only lookup would mis-root it.
- onSuccess swaps pending → confirmed under the same localKey
  (reconcileSentThreadReply), so the row never remounts and a WS echo
  racing ahead of the REST response cannot duplicate
  (isMatchingPendingMessage already reconciles the echo in place).
- onError removes only the failed pending entry
  (rollbackPendingThreadReply) — a snapshot restore would drop live
  replies that arrived during the in-flight send.
- useThreadReplies' refetch snapshot now also preserves still-pending
  optimistic sends, which the server cannot return yet.

The e2e mock relay previously echoed sends synchronously inside the
send command — exactly why no test ever caught this. Add a
sendEchoDelayMs knob that defers the echo like the real relay's
post-commit fanout, plus a regression spec (proven red pre-fix) that
asserts own-sends paint before the echo, the late echo reconciles
without duplicating, and a thread switch mid-send never bleeds the
pending reply into the wrong thread.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-28 11:27:06 -04:00
..
2026-03-09 13:02:11 -07:00
2026-06-11 15:06:24 +00:00
2026-03-09 13:02:11 -07:00

Buzz

Desktop chat shell with:

  • Tauri + React + TypeScript + Vite
  • Tailwind CSS
  • shadcn/ui-ready shared components
  • Biome (lint/format/check)
  • Feature-driven frontend structure

Scripts

  • pnpm dev - run the web frontend
  • pnpm tauri dev - run the desktop app
  • pnpm build - typecheck and build frontend
  • pnpm typecheck - TypeScript checks
  • pnpm lint - Biome lint
  • pnpm format - Biome format (write)
  • pnpm check - Biome check

Structure

  • src/shared - reusable app-wide code (ui, lib, styles)
  • src/features - feature modules (vertical slices)
  • src/app - top-level app composition