Repository navigation
feat: name a new worktree in plain words - #413
Merged
Merged
Conversation
omartelo
force-pushed
the
feat/session-auto-name
branch
from
August 30, 2026 20:56
01e749d to
fb31097
Compare
The name field only ever took a branch name: anything with a space in it was refused, so naming the work meant inventing the hyphens by hand, and the blank field — the path of least resistance — handed the branch a random `calm-glacier`. That name is fine until it is the name on a pull request, and by then it cannot be fixed: renaming a branch through the GitHub API closes the PR that was open on it. So the name is settled at the only cheap moment there is, before the worktree exists. `toBranchName` keeps a name git already accepts exactly as typed, and turns anything else into a kebab slug of its first few words — grown to at least a minimum so a run of short words still reads, stopped before a maximum in words and in characters so a pasted sentence does not become the branch. The field's helper line already printed the branch that would be created; it now prints the slug, so nothing is rewritten out of sight. The "Invalid branch name" state goes with it: there is no longer such a thing to type. Nothing usable at all still means a blank, which is the auto-generated name as before. The growth loop is borrowed from JetBrains/thinkrail's `naiveWorkspaceName`. Its other half — a cheap-model pass refining the name from the session's first turn — is deliberately left out: lich's dialog has no prompt to read, and the rename it would need is the move that closes the PR.
omartelo
force-pushed
the
feat/session-auto-name
branch
from
August 30, 2026 20:58
fb31097 to
72c3513
Compare
omartelo
added a commit
that referenced
this pull request
Sep 5, 2026
The New worktree dialog's name field took a branch name or the task in plain words. It takes an issue too now — "#128", or the URL copied out of the browser — looked up through gh on the project's own account. What that buys is the other half: the session opened on that worktree finds the issue at its prompt. Number, title, link and body, as one bracketed paste so the body's newlines are text rather than a run of Enters, and unsent — the Enter stays the user's, as with the pull request handoff. Typing the context in by hand was the only way an agent learned what its worktree was for. Everything the flow needs already existed: toBranchName slugs the title and prints the exact branch under the field before anything is created (#413), CreateWorktree makes an ordinary branch off the chosen base, writeAtPrompt waits out the setup script and the provider's boot (#447), and bracketedPaste is why the paste is one block. What is new is one gh call, one pure module, and a row in the gh message table. Two refusals, both because the field is a branch name first: - A bare number stays a branch name. "#" is the marker, so there is one field with one meaning rather than a mode to be in. - A pull request's number is refused, naming the screen that does open pull requests. GitHub counts issues and pull requests in one sequence and `gh issue view` answers for either; taking it would branch off the base under its title instead of checking its head out. The URL is the only field in the answer that tells the two apart. And the reference itself never names the branch, resolved or not: git accepts "#381" as a branch name, and most shells read the "#" as the start of a comment, so `git checkout #381` is `git checkout`. Claude-Session: https://claude.ai/code/session_01GSu6sRs6pBuZHmWaJmuZ3o
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.
What
The New worktree dialog's name field only ever took a branch name: anything with a space was refused as
Invalid branch name, so naming the work meant inventing the hyphens by hand — and the blank field, the path of least resistance, handed the branch a randomcalm-glacier.That name is fine right up until it is the name on a pull request, and by then it cannot be fixed: renaming a branch through the GitHub API closes the PR that was open on it. So this settles the name at the only cheap moment there is — before the worktree exists.
Type
fix the auth redirectand the branch isfix-the-auth-redirect, printed under the field before anything is created. A name git already accepts is still used exactly as typed; a blank field still auto-generates one.How
toBranchName(frontend/src/lib/git/branch-name.ts) — pure, no model, no network:feat/xstaysfeat/x).-."", which is the same blank the dialog auto-generates a name for.The
Invalid branch namestate is deleted: there is no longer such a thing to type. The helper line under the field already printed the branch that would be created — it now prints the slug, so nothing is rewritten out of sight.Where it came from, and what was left out
The growth loop is borrowed from JetBrains/thinkrail's
naiveWorkspaceName(packages/server/src/assist). Their pattern has a second half — a cheap-model pass that refines the name from the session's first turn, plus the host flow that renames the workspace once that turn settles. Both are deliberately out:The CLI and MCP paths (
lich open --worktree <branch> --prompt <task>,open_session) are untouched: a blank worktree there means no worktree, and an agent opening one already names it knowing the task.Test plan
frontend/src/lib/git/branch-name.test.ts— passthrough of names git takes, the slug, both minimums, both maximums, the clamp on a single over-long word, the trailing separator the clamp can land on, a non-ASCII phrase, and the empty results that fall back to auto-generate.gofmt -l .,go vet ./...,go test ./...,biome check .,vitest run(1224 tests),tsc -b,vite build.