Fix thread loading flash#4396
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Straightforward UI bug fix that introduces a render state machine to prevent thread loading flash. Changes are self-contained with comprehensive unit tests added, and the fix logic is clear and well-scoped. You can customize Macroscope's approvability policy. Learn more. |
Waits for full thread detail before rendering a server thread, preventing the empty-thread state from flashing during navigation. Adds focused route-state coverage. Verified with the focused test, formatting, lint, and web typecheck.
Note
Low Risk
Localized routing and render gating in the web chat UI with no auth, data persistence, or API contract changes.
Overview
Fixes a brief empty-thread flash when opening a server thread by not mounting
ChatViewuntil thread data is actually ready.The chat thread route now derives a
loading|ready|missingstate via newresolveThreadRouteRenderStateinthreadRoutes.ts, using bootstrap completion, shell/detail presence, draft existence, anduseThreadStatus(includingdeleted). Shell-only threads stay in loading instead of rendering; missing threads still redirect home when the environment has other threads.Unit tests in
threadRoutes.test.tscover loading vs ready vs missing, including deleted shell-only threads.Reviewed by Cursor Bugbot for commit 4eb3ad3. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix thread loading flash in chat thread route by deferring render until thread state is resolved
resolveThreadRouteRenderStatein threadRoutes.ts to centralize render state logic, returning'loading','ready', or'missing'based on bootstrap status, server thread shell/detail existence, draft existence, and deletion status.useThreadStatushook in entities.ts to exposeEnvironmentThreadStatusfor a given thread ref, returning'empty'when ref is null.renderState === 'ready'before rendering and redirects only whenrenderState === 'missing', eliminating premature renders during loading.'loading'rather than'missing', preventing a spurious redirect or blank render.useThreadStatusnow trigger a redirect when other threads exist, instead of remaining on the deleted thread.Macroscope summarized 4eb3ad3.