Skip to content

Fix thread loading flash#4396

Merged
t3dotgg merged 3 commits into
mainfrom
t3code/diagnose-thread-loading-state
Jul 23, 2026
Merged

Fix thread loading flash#4396
t3dotgg merged 3 commits into
mainfrom
t3code/diagnose-thread-loading-state

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Jul 23, 2026

Copy link
Copy Markdown
Member

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 ChatView until thread data is actually ready.

The chat thread route now derives a loading | ready | missing state via new resolveThreadRouteRenderState in threadRoutes.ts, using bootstrap completion, shell/detail presence, draft existence, and useThreadStatus (including deleted). 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.ts cover 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

  • Introduces resolveThreadRouteRenderState in 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.
  • Adds useThreadStatus hook in entities.ts to expose EnvironmentThreadStatus for a given thread ref, returning 'empty' when ref is null.
  • The chat thread route now waits for renderState === 'ready' before rendering and redirects only when renderState === 'missing', eliminating premature renders during loading.
  • Shell-only server threads (detail not yet loaded) are now treated as 'loading' rather than 'missing', preventing a spurious redirect or blank render.
  • Behavioral Change: threads marked as deleted via useThreadStatus now trigger a redirect when other threads exist, instead of remaining on the deleted thread.

Macroscope summarized 4eb3ad3.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0684fd14-7e6b-4d2e-a5f9-64449afb7e85

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/diagnose-thread-loading-state

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/threadRoutes.ts
Comment thread apps/web/src/routes/_chat.$environmentId.$threadId.tsx
@macroscopeapp

macroscopeapp Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jul 23, 2026
Comment thread apps/web/src/threadRoutes.ts Outdated
@t3dotgg
t3dotgg merged commit 91dfe60 into main Jul 23, 2026
16 checks passed
@t3dotgg
t3dotgg deleted the t3code/diagnose-thread-loading-state branch July 23, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant