Skip to content

fix(app): eliminate session switch latency — deferRender, Suspense flash, instant rendering#31395

Open
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:fix/session-switch-responsiveness
Open

fix(app): eliminate session switch latency — deferRender, Suspense flash, instant rendering#31395
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:fix/session-switch-responsiveness

Conversation

@BYK

@BYK BYK commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #19793

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes three compounding session-switch responsiveness issues:

  1. Remove deferRender mechanism — eliminates the one-frame blank + 140ms setTimeout in session-composer-region that caused a ~170ms gap where the composer was invisible on every session switch. The composer now re-shows after a single rAF yield (~16ms).

  2. Remove sessionSync JSX read{sessionSync() ?? ""} was read in JSX, triggering the app-level <Suspense> boundary (splash screen) on every session switch. Since the resource returns void, the read is removed entirely — the fetcher still runs reactively from its source signal.

  3. Widen messagesReady gate — allow rendering when the session exists in the session list, even before messages have loaded. This eliminates the blank screen on session switch; the composer and timeline render immediately with cached session data.

  4. Remove 140ms artificial setTimeout in session-composer-region — the composer now re-shows after a single rAF yield (~16ms).

How did you verify your code works?

Tested locally by rapidly switching between sessions in the web UI. Verified no blank flashes, no splash screen flicker, and the composer appears instantly. Messages load in the background with a spinner shown during loading.

Screenshots / recordings

N/A — performance/latency improvement.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ense flash, and instant rendering

Remove three compounding session-switch responsiveness issues:

1. Remove deferRender mechanism — eliminates the rAF + setTimeout chain in
   session.tsx that blanked the review panel and gated the composer on every
   session switch, causing a ~170ms gap where UI was invisible.

2. Remove sessionSync() JSX read — the createResource was read in JSX
   ({sessionSync() ?? ""}), triggering the nearest Suspense boundary (the
   app-level splash screen) on every session switch while the sync Promise
   was pending. The resource returns void so the read was a no-op.

3. Widen messagesReady gate — accept when the session exists in the session
   list even before messages have loaded. This eliminates the blank screen
   on session switch; the composer and timeline render immediately with
   cached session data.

4. Remove 140ms artificial setTimeout in session-composer-region — the
   composer now re-shows after a single rAF yield (~16ms).
Copilot AI review requested due to automatic review settings June 8, 2026 17:30
@BYK BYK requested review from Brendonovich and Hona as code owners June 8, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR removes deferred rendering and artificial readiness delays in the session UI, aiming to render sooner (including when cached session data exists) and simplify render timing logic.

Changes:

  • Remove the deferRender mechanism and stop gating major UI sections on it.
  • Make messagesReady true when either messages are loaded or the session is already present in the local session list.
  • Remove the extra timeout-based delay before marking the composer region as ready.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/app/src/pages/session/composer/session-composer-region.tsx Removes the setTimeout delay in the composer readiness effect, making readiness flip on the next animation frame.
packages/app/src/pages/session.tsx Eliminates deferRender, adjusts readiness logic to allow cached-session rendering, and removes a render-time sessionSync() invocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 101 to 113
createEffect(() => {
route.sessionKey()
const ready = props.ready
const delay = 140

clear()
setStore("ready", false)
if (!ready) return

frame = requestAnimationFrame(() => {
frame = undefined
timer = window.setTimeout(() => {
setStore("ready", true)
timer = undefined
}, delay)
setStore("ready", true)
})
})
Comment on lines 320 to 325
const messagesReady = createMemo(() => {
const id = params.id
if (!id) return true
return sync.data.message[id] !== undefined
// Ready when messages are loaded OR session exists in the list (render immediately with cached data)
return sync.data.message[id] !== undefined || sync.session.get(id) !== undefined
})
Comment on lines 1699 to 1700
<div class="relative size-full overflow-hidden flex flex-col">
{sessionSync() ?? ""}
<SessionHeader />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session navigation blocks UI when switching between large conversations

2 participants