Skip to content

Use project cwd when opening draft threads without a worktree path#183

Merged
juliusmarminge merged 1 commit into
mainfrom
t3code/draft-thread-open-in-default-cwd
Mar 6, 2026
Merged

Use project cwd when opening draft threads without a worktree path#183
juliusmarminge merged 1 commit into
mainfrom
t3code/draft-thread-open-in-default-cwd

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Mar 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Pass openInCwd from ChatView into ChatHeader/OpenInPicker so editor open actions no longer depend on thread/project lookups inside the picker.
  • Prefer activeThread.worktreePath and fall back to activeProject.cwd when computing the open path.
  • Update OpenInPicker click/shortcut handlers and button disabled state to use openInCwd directly.
  • Add a browser test covering draft-only threads to verify shellOpenInEditor is sent with project cwd when no worktree path exists.

Testing

  • Added test: opens the project cwd for draft threads without a worktree path in apps/web/src/components/ChatView.browser.tsx.
  • Not run: bun lint.
  • Not run: bun typecheck.
  • Not run: bun run test.

Note

Medium Risk
Adjusts the path used for native shell.openInEditor actions (button + shortcut) and could change behavior for some thread/project edge cases, though the change is small and covered by a new browser test.

Overview
Ensures the Open in editor action works for local draft threads that don’t yet have a worktreePath by computing an openInCwd in ChatView (worktreePath fallback to project cwd) and passing it down to ChatHeader/OpenInPicker.

OpenInPicker no longer does its own thread/project store lookups; its click handler, keyboard shortcut handler, and disabled state now rely solely on openInCwd.

Adds a browser test that mounts a draft-only thread (no server threads in snapshot), clicks Open, and asserts a shellOpenInEditor WS request is sent with the project cwd (including test harness support to capture WS requests and reset draft store state between tests).

Written by Cursor Bugbot for commit 19d5853. This will update automatically on new commits. Configure here.

Note

Route Chat header Open control to use the draft thread worktree path or fall back to the project cwd when calling api.shell.openInEditor in ChatView.tsx

Introduce openInCwd in ChatView and pass it through ChatHeader to OpenInPicker, which now calls api.shell.openInEditor with that cwd and disables the control when null; add tests that capture WebSocket RPCs and verify the cwd fallback behavior.

📍Where to Start

Start with ChatView computing openInCwd in ChatView.tsx, then follow its propagation through ChatHeader to OpenInPicker.

Macroscope summarized 19d5853.

- Pass resolved `openInCwd` from ChatView into OpenInPicker
- Fall back to project `cwd` when draft thread has no `worktreePath`
- Add browser test covering Open action for draft-only snapshot
@coderabbitai

coderabbitai Bot commented Mar 6, 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: e30a8770-19b5-49b1-99d3-2ce0d5d897e0

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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch t3code/draft-thread-open-in-default-cwd

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

@juliusmarminge juliusmarminge merged commit c63ea8d into main Mar 6, 2026
4 of 5 checks passed
@juliusmarminge juliusmarminge deleted the t3code/draft-thread-open-in-default-cwd branch March 6, 2026 07:44
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