fix(web): harden git checkout, run lifecycle, and branch-picker UX#98
Conversation
Follow-up fixes for issues found reviewing the merged PR #96. Backend changes are additive or narrowing; frontend changes are guard/copy fixes. HIGH - git checkout: reject branch names beginning with "-" before building the argv, so {branch:"-f"} can no longer become `git checkout -f` and silently discard uncommitted work while returning 200. (A "--" separator is NOT a fix — it makes git treat the ref as a pathspec and breaks switching.) - run lifecycle: guard the run-goroutine teardown with a per-run generation (Engine.runGen). A superseded old run's defer no longer nils the new run's runCancel, releases its running flag, or broadcasts a spurious idle — so a fast next turn on the same engine stays stoppable via /stop. MEDIUM - git checkout: when a stash-strategy switch fails after auto-stashing, pop the stash to restore the tree instead of orphaning it; name the stash if pop fails. - git checkout: classify the blocked response as tracked/untracked (new `kind` field) so the UI can pick safe recovery options. - setActiveEngine: fold the reclaim `running` check into the emu-guarded block so a concurrently-starting run is not torn down. - sidebar: reset the chat view (clearChat + blank currentSessionId) only when deleting the active conversation, so the next message can't target a deleted session; background-task deletes are unaffected. LOW - handleSessionDiff: capture the active engine once so snapshot and pwd come from the same repo across a swap. - handleValidatePaths: report a path missing only on confirmed not-exist, not on transient/permission stat errors that hid valid workspaces. - branch-switch copy: no longer claims only "changes"; warns discard deletes untracked files (en/zh-Hans/zh-Hant/ja/ko). - BranchPicker: route the confirm-dialog Cancel through reset() so a stale error no longer leaks into the branch list. - ProviderIcon: add the `g` flag to the initial-fallback regex. Adds regression tests for the checkout dash-reject, blockKind, and validate-paths missing detection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 14 minutes and 52 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up fixes for issues found while reviewing the (already-merged) #96. Each was reproduced against the merged code and verified; the proposed fixes from review were corrected where wrong (notably: a
--separator does not fix the checkout injection, andcontext.CancelFunccan't be compared — a generation counter is used instead).Backend changes are additive or behavior-narrowing; frontend changes are guard/copy fixes. No API breakage.
🔴 HIGH
git checkoutargv injection → silent data loss.branchflowed straight into the git argv, so{branch:"-f"}rangit checkout -f, discarding all uncommitted work and returning 200 OK. Now reject branch names beginning with-(valid git refs never do).internal/web/git.go/stopsilently dead. A finishing run'sdefercould nil the next run'srunCancel(gated only by therunningCAS), leavingrunning=true, runCancel=nil—/stopreturnedstoppedbut cancelled nothing. Now guarded by a per-run generation (Engine.runGen): a superseded defer is a no-op.internal/web/engine.go,internal/web/server.go🟠 MEDIUM
stash@{0}with no hint.git.gokind(tracked|untracked) field on the blocked response so the UI can pick safe recovery options.git.gosetActiveEnginereclaim TOCTOU. Therunningcheck is folded into theemu-guarded block so a concurrently-starting run on the outgoing engine isn't torn down.engine.goclearChat+ blankcurrentSessionId) only when the deleted task is the active one, so the next message can't be sent to a dead session; background-task deletes are unaffected.Sidebar.vue🟡 LOW
handleSessionDiffcaptures the active engine once so snapshot and pwd come from the same repo across a swap.server.gohandleValidatePathsreports a path missing only on confirmed not-exist, not on transient/permission stat errors that were hiding valid workspaces.server.goreset()so a stale error no longer leaks into the branch list.BranchPicker.vuegflag.ProviderIcon.vueTests
Adds
internal/web/git_test.go: checkout dash-reject (asserts uncommitted work survives),blockKindtracked/untracked, and validate-paths missing detection (incl. the EACCES case the fix targets).Deferred (own follow-up)
The
kind-consuming UI (hide discard for untracked), the#9backend porcelain classification, and a post-switch "stashed" toast — larger UX surface, out of scope for this bug-fix batch. The backendkindfield ships now so that follow-up needs no API change.Verification
go build ./...·go vet ./internal/web/...·go test -race ./internal/web/...·npm run build(type-check + vite) · oxlint + eslint on changed files — all green.🤖 Generated with Claude Code