diff --git a/.plans/branch-environment-picker-in-chatview-input.md b/.plans/branch-environment-picker-in-chatview-input.md new file mode 100644 index 0000000000000000000000000000000000000000..2c1994d2c8d6f05995134a7173ae6465e9486178 --- /dev/null +++ b/.plans/branch-environment-picker-in-chatview-input.md @@ -0,0 +1,74 @@ +# Branch/Environment Picker in ChatView Input + +## Summary + +Add a secondary toolbar below the ChatView input area (similar to Codex UI) that lets users select the target branch and environment mode (Local vs New worktree) before sending their first message. + +## UX + +- A toolbar appears **below** the input form (always visible when it's a git repo) +- Two controls: + 1. **Environment mode** (left side): toggles between "Local" and "New worktree" — **locked after first message** (no longer clickable, just shows current mode as label) + 2. **Branch picker** (right side): dropdown showing local branches — **always changeable**, even after messages are sent +- If not a git repo, the toolbar is hidden entirely (thread uses project cwd as-is) + +## Changes + +### 0. Install `@tanstack/react-query` in `apps/renderer` + +Add dependency + wrap app in `QueryClientProvider`. + +### 1. `apps/renderer/src/store.ts` — MODIFY + +Add a new action to the reducer: + +```ts +| { type: "SET_THREAD_BRANCH"; threadId: string; branch: string | null; worktreePath: string | null } +``` + +Reducer case updates `branch` and `worktreePath` on the thread. + +### 2. `apps/renderer/src/components/ChatView.tsx` — MODIFY + +**Fetch branches** via `useQuery`: + +```ts +const branchQuery = useQuery({ + queryKey: ["git-branches", activeProject?.cwd], + queryFn: () => api.git.listBranches({ cwd: activeProject!.cwd }), + enabled: !!activeProject, +}); +``` + +**Local state:** + +- `envMode: "local" | "worktree"` — environment mode (local component state) + +**UI:** Below the `