Skip to content

fix(web): new threads no longer open blank after the first send - #46

Merged
Andrey170170 merged 2 commits into
dev_vmfrom
fix/draft-thread-detail-404
Oct 31, 2026
Merged

Andrey170170 merged 2 commits into
dev_vmfrom
fix/draft-thread-detail-404

Conversation

@Andrey170170

Copy link
Copy Markdown
Owner

Summary

A new thread showed nothing after its first send (not your own message, not the working status) until a full app restart. The draft view read run-stop state for its not-yet-created thread id, the snapshot request returned 404, and the thread state stopped for good. The resume cache then kept that 404, so leaving the thread and coming back didn't help either. Now drafts don't ask for their future id, and a 404 for an unknown id is no longer remembered.

 draft opens (thread id generated, no server thread yet)
   useThreadLifecycle
-    runStopAtom(draft id) -> GET /threads/<id>/bounded -> 404
-      setDeleted(); resumeCache = deleted; subscription parked forever
+    runStopAtom only once the server lists the thread
 first send -> launchThread -> snapshot 200 -> subscribeThread -> live

 makeEnvironmentThreadState, HTTP "missing"
-  setDeleted()            # retained 5 min; a remount parks with no request
+  setDeleted("miss")      # not retained; a remount asks the server again
   (a thread.deleted event is still retained)

The run-stop read came from upstream pingdotgg#27252, merged in the Oct 30 sync. Mobile's new-task screen already passes no detail ref, so it doesn't make the early request.

Evidence

  • Before (dev client, old hook swapped in via HMR): every draft requested its own future id and got a 404.
    23:14:04  threadBoundedSnapshot  Failure  /threads/0f43737a…/bounded
    23:14:10  threadBoundedSnapshot  Failure  /threads/64b3c45f…/bounded
    
    Production trace from the original report: the 404 at 22:53:23, launchThread at 22:53:44, and no subscribeThread until the app restarted.
    After: opening and reloading a draft made no request; the first send (Replay provider) went launch → snapshot 200 → subscribe, and the user message and reply showed right away.
    23:15:12  launchThread           Success
    23:15:13  threadBoundedSnapshot  Success  /threads/64b3c45f…/bounded
    23:15:13  subscribeThread        Success  64b3c45f…
    
  • threads-sync.test.ts › "checks a missing thread again on remount instead of retaining the miss": a miss whose disk-cache removal is still pending, then unmount, then a remount where the thread exists, must go live. It fails on dev_vm and on the first version of this fix; it passes now. check:changed is green.

Merge Danger

Door: two-way

Blast Radius: client-thread-loading

Changes when web, desktop, and mobile load thread detail. A truly missing thread costs one extra HTTP request if it's reopened within 5 minutes. Run-stop shows only for threads the server lists.

🤖 Generated with Claude Code

Andrey170170 and others added 2 commits October 30, 2026 23:10
The draft view read run-stop state for its not-yet-created thread id. The
bounded snapshot 404ed, the thread state parked as deleted, and the resume
cache kept that miss, so the thread never subscribed after the first send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T05:19:41.139088Z ccfee7e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 56cdc02 and ccfee7e.

Files selected for processing: 3
  • apps/web/src/components/chat/useThreadLifecycle.tsx
  • packages/client-runtime/src/state/threads-sync.test.ts
  • packages/client-runtime/src/state/threads.ts

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

Walkthrough

Missing-thread snapshot results now clear the owning resume cache before thread removal. Drafts without a server thread use the empty run-stop atom. A remount test covers recovery when cache removal remains pending.

Changes: Missing-thread resume-cache handling

Layer / File(s) Summary
Missing snapshot and remount behavior
packages/client-runtime/src/state/threads.ts, packages/client-runtime/src/state/threads-sync.test.ts
setDeleted now distinguishes missing snapshot results from delete events. Missing results clear the owned resume snapshot before thread removal; delete events retain the existing cache behavior. The test harness can leave removal pending, and a new test verifies that a remount loads a present thread as live.

Draft run-stop state

Layer / File(s) Summary
Guard run-stop state for drafts
apps/web/src/components/chat/useThreadLifecycle.tsx
The hook selects the run-stop atom only when an active thread reference and its shell exist. Otherwise, it uses NO_RUN_STOP_ATOM.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to ccfee

The missing-thread recovery path is covered, with no identified issue requiring a fix before merge.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: new web threads no longer appear blank after the first send. It also follows the repository's conventional commit format.
Description check Passed The description clearly explains the problem, the code changes, the affected behavior, test evidence, observed results, and blast radius. It does not use the exact template headings and does not expli…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, the code changes, the affected behavior, test evidence, observed results, and blast radius. It does not use the exact template headings and does not explicitly document maintainer approval or explain why the fix qualifies without prior approval, but the required technical context is mostly complete.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@Andrey170170
Andrey170170 merged commit e23134c into dev_vm Oct 31, 2026
1 check passed
@Andrey170170
Andrey170170 deleted the fix/draft-thread-detail-404 branch October 31, 2026 05:27
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.

1 participant