Skip to content

fix(web): unblock new drafts during environment reconnect - #11646

Open
coygeek wants to merge 3 commits into
pingdotgg:mainfrom
coygeek:fix/10548-new-local-reconnecting
Open

coygeek wants to merge 3 commits into
pingdotgg:mainfrom
coygeek:fix/10548-new-local-reconnecting

Conversation

@coygeek

@coygeek coygeek commented Sep 13, 2026 •

Copy link
Copy Markdown

Summary

Fixes #10548. Cmd+Shift+N hangs on a project whose environment is reconnecting: the new-thread handler waits for that environment's t3.json, and the file query does not settle until the connection returns.

 useNewThreadHandler(projectRef)
   resolveDefaultEnvMode
-    if environment leaves defaultThreadEnvMode unset
+    if environment leaves defaultThreadEnvMode unset
+       and the environment's connection phase is "connected"
       readT3ProjectFile                      # file query on the environment
+        abort after 3 s → null               # connection dropped mid-read
     resolveProjectSettings(…, projectFile)   # null → built-in default
   register draft
   navigate to /draft/:draftId

Evidence

  • Before: the new tests against main's useHandleNewThread.ts and t3ProjectFileDefaults.ts time out because draft creation never finishes.
    given environment phase ∈ {connecting, reconnecting, offline, available, error}
      and t3.json read stays pending
    when the user opens a new thread
    expect draft registered and route = /draft/:draftId
    
    × opens without waiting for t3.json while the target is <phase>   (×10)
    × keeps an invested draft intact when opening while reconnecting  (×2)
    × falls back when a file query stays pending past its deadline
    Tests  13 failed | 21 passed (34)
    
    After: this branch
    ✓ opens without waiting for t3.json while the target is <phase>
    ✓ keeps an invested draft intact when opening while reconnecting
    ✓ honors t3.json while the target is connected                    # control
    ✓ falls back when a file query stays pending past its deadline
    Tests  34 passed (34)
    
    Web typecheck, lint, format, and knip:check pass.

Merge Danger

Door: two-way

Client-only. No contract, persisted state, or server change. Reverting restores the old wait.

Blast Radius: new-thread defaults

New threads from web and desktop on a project whose environment is not connected, or whose t3.json read takes longer than 3 s, skip t3.json and use the built-in thread mode. If t3.json sets worktree, that draft opens in local mode. Project and environment settings still take precedence. Mobile has its own new-thread flow and is unaffected.


Implemented with GPT-6 Astra in Codex desktop; rebased onto main and adapted with Claude Opus 5.5 in Claude Code.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 13, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This is a focused, well-tested fix that prevents new drafts from blocking during environment reconnects and bounds optional defaults-file reads. It also changes the effective workspace mode selected when the environment is unavailable, so the resulting product-default behavior warrants human review.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ebd3247-390b-498d-b5bf-43b644c5b1de
📥 Commits

Reviewing files that changed from the base of the PR and between b4aff7e and 0eb6846.

📒 Files selected for processing (4)
  • apps/web/src/hooks/useHandleNewThread.test.ts
  • apps/web/src/hooks/useHandleNewThread.ts
  • apps/web/src/lib/t3ProjectFileDefaults.test.ts
  • apps/web/src/lib/t3ProjectFileDefaults.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The new-thread flow checks environment connectivity before it reads project-file defaults. The project-file query now has a three-second timeout. Tests cover connection phases, draft-context preservation, timeout fallback, and successful default parsing.

Changes

New thread connection handling

Layer / File(s) Summary
Connection-phase gate
apps/web/src/hooks/useHandleNewThread.ts, apps/web/src/hooks/useHandleNewThread.test.ts
resolveDefaultEnvMode reads project-file defaults only when the project has no configured mode and its environment is connected. Tests cover non-connected phases, connected lookup, and preserving draft context when user content exists.
Project-file query timeout
apps/web/src/lib/t3ProjectFileDefaults.ts, apps/web/src/lib/t3ProjectFileDefaults.test.ts
The project-file query uses a three-second timeout. Tests verify timeout fallback and successful parsing of defaultThreadEnvMode.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 0eb68

New-thread creation no longer waits indefinitely for project-file defaults when the remote environment is unavailable. No actionable merge-blocking risk remains.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 0eb68

The change bounds an optional defaults read while preserving the selected environment and configured permissions. No introduced security issue was established. Interruption of the waiting operation is supported, but cancellation of the underlying remote read remains unconfirmed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The reviewed change affects optional default selection and subsequent draft state for the selected project. It does not broaden the reader's environment, workspace, or filename inputs: the connectivity gate adds a precondition to the existing read rather than introducing a broader read target.

Trust Boundaries and Controls

  • observed — Project-file contents pass through the existing schema decoder, which treats invalid contents as absent. File-backed settings fill only unset higher-priority settings. The reader rejects truncated data and preserves the existing environment-and-workspace-scoped optimistic-data overlay.

Resilience and Maintainability Implications

  • observed — The timeout signal reaches Effect.runPromiseExit around a scoped atom mount and query wait. The added regression uses the real interruptible wait with a deliberately pending atom. This supports caller settlement and scoped-wait cleanup, but does not establish cancellation of an already-started remote transport request.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy the coding requirements in [#10548]. useNewThreadHandler skips the optional t3.json read unless the target environment is connected. readT3ProjectFile applies a three-second …
Out of Scope Changes check ✅ Passed The changes stay within [#10548]. The implementation and tests modify the web new-thread default resolution path and its optional project-file read. The summary shows no unrelated changes to mobile, p…
Title check ✅ Passed The title is concise, specific, and accurately describes unblocking new draft creation during environment reconnect.
Description check ✅ Passed The description clearly explains the problem, implementation, affected scope, regression coverage, test results, and linked issue. It does not use the template headings exactly, but it provides the re…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

@cursor

cursor Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
coygeek and others added 3 commits October 7, 2026 21:44
Skip optional project defaults reads while the selected environment is unavailable and bound reads that lose connectivity. This lets Cmd+Shift+N and other new-thread entry points open a draft immediately while preserving the configured fallback.
Explain why new-thread default resolution skips unavailable environment file reads.
Upstream now reads t3.json only when the environment leaves
defaultThreadEnvMode unset. Run the reconnect regressions with that
setting unset so they reach the guarded file read, and add a connected
control that still honors t3.json. Move the reader test to the
renamed readT3ProjectFile and the effect/reactivity Atom import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coygeek
coygeek force-pushed the fix/10548-new-local-reconnecting branch from b4aff7e to 0eb6846 Compare October 8, 2026 04:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): Cmd+Shift+N stalls while the selected remote computer is reconnecting

2 participants