Start a new session in the main checkout or a selected/new worktree - #15
Draft
felipeorlando wants to merge 1 commit into
Draft
felipeorlando wants to merge 1 commit into
felipeorlando wants to merge 1 commit into
Conversation
…tree Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2
New sessions in a git repo can now start in the main checkout, an existing worktree, or a newly created one.
What the removed history actually said
48403famade the composer branch picker implicitly create/enter a worktree at<git-common-dir>/monocode-worktrees/<branch>— a hidden folder inside.git/— every time you picked a branch. The session's cwd moved out from under the user and the provider session was dropped with it.fc8cbb8(0.1.10) reverted all 274 lines.The removal was about implicitness and an invisible destination, not about worktrees. This design is explicit, chosen once at session creation, and lands in a visible sibling folder. The lesson carried over: the branch picker must not be the thing that moves a session.
Implementation
Rust — three new commands:
git_worktrees(list, main-first),git_worktree_create(new branch + start-from ref),git_worktree_verify. New worktrees go to<repo>-worktrees/<slug>next to the repo — not inside.git/like the reverted version, and not inside the repo where they would be untracked noise.git worktree addnever moves the main checkout's HEAD; the start point is resolved before any directory is created, and specs starting with-are rejected.TypeScript —
sessionCheckout.tsholds pure picker-row and session-binding logic.CheckoutPicker.tsxfollowsBranchPicker's structure and renders only for empty sessions in a git repo.restoreSessionCheckoutwas inverted: it used to delete the pin on every restore, and now verifies the worktree and keeps it, falling back to the main checkout only when the tree is really gone — this is what makes sessions durably bound.Behavior change to an existing control — please review
BranchPickerwas receivingcwd(the repo root). A worktree-bound session using it would have switched the main checkout's branch, violating the issue's own constraint. It now receivesexecutionCwd, andonBranchChangeno longer unpins the session's worktree.Verification
npm run check:web— exit 0, 128 files / 1343 tests,tsc --noEmitcleancargo fmt --checkclean,clippy -D warningsclean,cargo test217 passed8 new Rust
#[test]s on real temp repos, including one asserting the main checkout keeps its branch and its newer commit after a create from an older ref, and one asserting a rejected name/start point leaves zero registered worktrees. 20 new TS tests.Not verified / out of scope