Skip to content

Smooth channel loading: single-surface timeline state machine#1099

Merged
wpfleger96 merged 9 commits into
mainfrom
brain/channel-loading-signal
Jun 18, 2026
Merged

Smooth channel loading: single-surface timeline state machine#1099
wpfleger96 merged 9 commits into
mainfrom
brain/channel-loading-signal

Conversation

@wesbillman

@wesbillman wesbillman commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

Switching channels showed the loading skeleton "multiple times" with a vertical shake, then the messages shook/faded when the skeleton cleared. Goal (from #weird-ui-flicker-and-loading): show loading, then show messages — one surface at a time, buttery smooth.

Root cause

Two thrash engines, both around the skeleton:

  1. Multiple skeleton surfaces. The historical full-pane ViewLoadingFallback data branch in ChannelScreen could swap a differently-laid-out skeleton in front of MessageTimeline's own skeleton — overlapping skeleton regions on screen at once.
  2. The reveal animation restarted on every commit. MessageTimeline used SkeletonReveal with loading={isLoading || isDeferredListPending}. useDeferredValue re-defers on every new messages identity while events stream in, so isDeferredListPending blipped pending→list→pending across commits. Each blip re-fired SkeletonReveal's useLayoutEffect reset + rAF crossfade + relative↔absolute layout swap → the skeleton re-appeared/re-pulsed (vertical shake) and content faded in on reveal.

Fix — one timeline state machine, one visible surface

A strict, derived single-surface model. Exactly one of skeleton | direct-message-intro | channel-intro | empty | list renders at any time. No overlap, no crossfade, no animation on the skeleton.

  • ChannelScreen: remove the dead full-pane channel-loading branch; always mount ChannelPane (real header/composer/timeline) and pass isTimelineLoading down. Keep the per-channel monotonic loading latch and the scroll-freeze.
  • MessageTimeline: drop SkeletonReveal entirely; render plain conditional surfaces driven by a new pure selectTimelineSurface(...). Both hard-loading and the deferred catch-up window map to skeleton, so the same TimelineSkeleton node stays mounted across the hold — no remount flash, no reveal restart, zero gap before rows. Scroll/search/load-older are gated on the same skeleton state so rows don't shake during catch-up; skeleton row estimate ignores uncommitted messages so its height doesn't jump.

Invariants (enforced by unit tests)

  1. Exactly one surface renders — no overlap.
  2. Loading is monotonic per channel (latch).
  3. The loading surface is a plain conditional, not SkeletonReveal — no layout-effect reset, no rAF, no absolute↔relative swap.
  4. Deferred-pending never restarts the skeleton — it holds the same static frame, then swaps to list once.
  5. Stable container geometry across loading→list (min-h-[18rem]).

Tests

  • New selectTimelineSurface table in timelineSnapshot.test.mjs (loading + pending both → skeleton; live rows win; empty picks exactly one intro/empty surface).
  • Existing timelineLoadingState.test.mjs latch cases retained.
  • Full desktop unit suite: 902/902.
  • pnpm typecheck, pnpm check, pnpm build all clean (pre-existing chunk warnings only).

Note: the "buttery smooth" feel is best confirmed in a running build (fast A→B→A switching, empty channel, throttled relay) — the suite proves the logic/invariants.

Co-authored by Pinky (MessageTimeline state machine + selectTimelineSurface) and Brain (ChannelScreen full-pane removal, loading latch, scroll-freeze, integration). Closes the channel-load flicker reported in #weird-ui-flicker-and-loading.

@wesbillman wesbillman changed the title Smooth channel loading: robust timeline-loading signal Smooth channel loading: single-surface timeline state machine Jun 17, 2026
wesbillman and others added 8 commits June 17, 2026 16:33
Drop the pending-render opacity transition from the main timeline and thread
reply list while keeping the deferred render state marker for e2e synchronization.

Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Keep timeline intro and empty affordances hidden while live messages are waiting
for the deferred list commit, so channel entry shows the message skeleton until
rows are ready instead of briefly flashing the channel intro.

Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
The channel intro/empty state could flash on entry to a channel that has
messages, then get replaced by the real timeline. `isTimelineLoading` keyed
off `data !== undefined`, but the per-channel query cache is seeded early by a
stale placeholder on revisit and by the live subscription's setQueryData, so
the signal flipped to "loaded" while the authoritative history fetch was still
in flight over an empty result.

Derive the loading state from a pure `selectTimelineLoadingState` helper that
stays loading while the fetch is in flight over a placeholder or empty result,
and does not re-skeleton populated channels on background refetch. Combined
with the deferred-list render-state gate, both flash windows are covered.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
The robust loading signal ties loading to the in-flight history fetch, but
isFetching/data can toggle during channel entry (the live subscription writes
to the cache while the fetch runs), so the skeleton could flip up and down.

Latch loaded per channel: once the timeline settles for a channel, a later
background refetch no longer re-shows the skeleton. A channel switch resets the
latch so the new channel loads fresh. Extracted as a pure
resolveTimelineLoadingLatch helper with unit coverage.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Both timeline ResizeObservers reacted to height changes regardless of load
state, while the initial scroll-to-bottom was gated on !isLoading. On entry,
as the deferred list streams in under the skeleton, the content observer kept
firing scrollToBottom/syncScrollState, so the timeline shook continuously.

Mirror isLoading into a ref and skip the observers' scroll reactions while
loading; the init layout-effect still owns the single scroll-to-bottom once
content settles. The timeline observer keeps tracking height so the first
post-load comparison is fresh.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
The full-pane ViewLoadingFallback data-loading branch was skeleton #1 of the
two-skeleton topology behind the channel-switch shake. ChannelPane already
always mounts and receives isTimelineLoading, so this branch only ever swapped
a differently-laid-out skeleton in front of the timeline's own. Remove it; the
timeline owns the single loading surface.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Replace the timeline skeleton reveal path with an explicit surface state so loading, deferred catch-up, empty intro, and message rows are mutually exclusive. Deferred catch-up now holds the same static skeleton surface instead of restarting a reveal animation.

Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
@wesbillman wesbillman force-pushed the brain/channel-loading-signal branch from 0962c02 to c6678ce Compare June 17, 2026 23:34
selectTimelineSurface collapsed intro and list into one mutually
exclusive surface, so a channel with messages returned "list" and
silently dropped the channel/DM intro header. Split into two
independent axes: selectTimelineBodySurface (skeleton | empty | list,
still single-surface so the loading frame can't tear) and
selectTimelineIntroSurface (an overlay above the body, suppressed only
during the skeleton). The intro now renders at the top of the list as
the E2E contract requires.

Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
@wpfleger96 wpfleger96 enabled auto-merge (squash) June 18, 2026 00:00
@wpfleger96 wpfleger96 merged commit d475722 into main Jun 18, 2026
25 checks passed
@wpfleger96 wpfleger96 deleted the brain/channel-loading-signal branch June 18, 2026 00:01
tlongwell-block pushed a commit that referenced this pull request Jun 18, 2026
…te-response

* origin/main: (194 commits)
  Fold agent core memory into the session system prompt (#1112)
  feat(cli): add patches and issues commands for NIP-34 git collaboration (#1073)
  fix(desktop): stop random timeline message loss + page reconnect replay (#1105)
  Update README.md
  fix(desktop): keep thread replies from scrolling channel (#1109)
  fix(buzz-acp): accept siblings under allowlist author gate (#1108)
  feat(deploy): add production Helm chart for Buzz (#990)
  fix(desktop): keep MembersSidebar input usable while an add is in flight (#1106)
  chore(release): release version 0.3.25 (#1102)
  fix(desktop): stop dimming deferred message lists (#1104)
  Smooth channel loading: single-surface timeline state machine (#1099)
  feat: surface base + persona system prompts in observer feed (#1103)
  ci: move reminder e2e to a dedicated backend-integration job (#1098)
  fix: give agent-observer sub a replay-capable limit (#1100)
  fix: make managed-agent spawn and teardown portable to Windows (#1097)
  fix(desktop): constrain message timeline width with min-w-0 (#1092)
  feat(desktop): reminders notifications, snooze, overlay, and inbox view mode (#1093)
  feat(prompt): add memory hygiene and hoist universal engineering discipline to base prompt (#1085)
  fix(desktop): correct thread-unread badge flicker, stale clear, phantom count, mention gate, and nested count (#1080)
  Fix mention chip alignment (#1094)
  ...

# Conflicts:
#	crates/buzz-cli/src/commands/workflows.rs
tlongwell-block pushed a commit that referenced this pull request Jun 18, 2026
…te-response

* origin/main: (194 commits)
  Fold agent core memory into the session system prompt (#1112)
  feat(cli): add patches and issues commands for NIP-34 git collaboration (#1073)
  fix(desktop): stop random timeline message loss + page reconnect replay (#1105)
  Update README.md
  fix(desktop): keep thread replies from scrolling channel (#1109)
  fix(buzz-acp): accept siblings under allowlist author gate (#1108)
  feat(deploy): add production Helm chart for Buzz (#990)
  fix(desktop): keep MembersSidebar input usable while an add is in flight (#1106)
  chore(release): release version 0.3.25 (#1102)
  fix(desktop): stop dimming deferred message lists (#1104)
  Smooth channel loading: single-surface timeline state machine (#1099)
  feat: surface base + persona system prompts in observer feed (#1103)
  ci: move reminder e2e to a dedicated backend-integration job (#1098)
  fix: give agent-observer sub a replay-capable limit (#1100)
  fix: make managed-agent spawn and teardown portable to Windows (#1097)
  fix(desktop): constrain message timeline width with min-w-0 (#1092)
  feat(desktop): reminders notifications, snooze, overlay, and inbox view mode (#1093)
  feat(prompt): add memory hygiene and hoist universal engineering discipline to base prompt (#1085)
  fix(desktop): correct thread-unread badge flicker, stale clear, phantom count, mention gate, and nested count (#1080)
  Fix mention chip alignment (#1094)
  ...

Co-authored-by: Tyler Longwell <tlongwell@squareup.com>
Signed-off-by: Tyler Longwell <tlongwell@squareup.com>

# Conflicts:
#	crates/buzz-cli/src/commands/workflows.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants