feat: switch a worktree's branch in place #500
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #500"
general
weight: 0.35
mzdluo123
Summary
Implements
switch-worktree-branchfrom #495. Stacked on #498 (basefeat/git-repository-management); the first commit archivesenrich-repository-detailsso this change validates against the archived specs.internal/workspace/switch.go): two-phasePreviewSwitch/SwitchWorktreewith apurposeSwitchconfirmation bound to worktree id+path, branch/head, target OID (and local tip) and the running-session set. Targets: local, remote (--track --createfromrefs/remotes/…), new (--no-track --create), detach — always--end-of-options, never--force/--discard-changes/--merge/--orphan/--ignore-other-worktrees. Blockers: tracked changes, in-progress operation, branch occupied (with occupant path), same target, unverifiable, existing local name. Warnings: untracked, locked,.gitmodules, sessions. Execution usesWithoutCancel+ 3 min; overwritten-untracked → 409 listing ≤50 paths; hook/filter failures → 409 with the redacted first Git line and the refreshed state.POST …/worktrees/{wid}/switch-previewand…/switch; snapshotworktree-switch-preview.json.webmux worktree switch REPO WORKTREE (BRANCH | --track R/B | --create NAME [--from REF] | --detach REF) [--yes] [--json]with exit codes 0/1/2.SwitchBranchflow hosted bySwitchBranchDialog(home/sidebar) or as a RepositoryPanel subview (the panel's single detail view became a subview stack). Segmented 已有分支 / 新建分支 / 分离到提交, grouped searchable branch list with current/occupied branches disabled, auto preview viaLatestRequest, 409 → re-preview, session acknowledgement, 改为在新工作树打开 (prefills the new-worktree dialog via a newpreset) and 转到该工作树. "切换分支…" inWorktreeMenuItems; 在新工作树打开… on unoccupied branches in the 分支 tab. NewButton wrapoption (registered in the architecture guard).Verification
make format,make checkpass;make test-gogreen.base64url.test.tsfails locally (Node 24 lacksUint8Array.prototype.toBase64; repo pins 26). Fixed a menu-close race inRepositoryPanel.test.ts(3 consecutive green runs).worktree-switch.spec.ts(incl. open code tab marked 内容已更新 after the switch),worktrees,repository-scope,workspace-discovery— 48 passed.User stories
New US-J16 (switch an existing worktree's branch); updated US-J05, coverage index, usage/protocol docs, verification log.
Screenshots
Demo repo as in #498.
Worktree "⋯" menu gains 切换分支…
| Viewport / theme | Before (#498) | After |
|---|---|---|
| desktop 1280×900 light | !before | !after |
| desktop 1280×900 dark | !before | !after |
| tablet 768×800 light | !before | !after |
| tablet 768×800 dark | !before | !after |
| phone 390×844 light | !before | !after |
| phone 390×844 dark | !before | !after |
切换分支 dialog from the sidebar (new)
| Viewport | Light | Dark |
|---|---|---|
| desktop 1280×900 | !light | !dark |
| tablet 768×800 | !light | !dark |
| phone 390×844 | !light | !dark |
切换 as a repository-panel subview (new)
| Viewport | Light | Dark |
|---|---|---|
| desktop 1280×900 | !light | !dark |
| tablet 768×800 | !light | !dark |
| phone 390×844 | !light | !dark |
Interaction
chore/old-deps→ preview → 切换 → sidebar/home now showchore/old-deps:!switch flow desktop
docs/refresh→ subview → preview blocked by uncommitted changes → 改为在新工作树打开 offered → 返回:!blocked switch phone