fix(host-service): seed branch from typed workspace name, rename to AI names before terminals start
Problem
Workspace name, branch, and worktree folder routinely diverge at creation. A report showed a workspace named supportmaxxing on a sprinkle-violet worktree folder: the typed workspace name never feeds branch generation, and the branch falls back to friendly-random words whenever the blocking LLM naming call fails or times out. That blocking call also added up to ~25s to create latency in the worst case (5s small-model + 20s agent-CLI fallback).
Changes
- Typed name seeds the branch. When the user types a workspace name but no branch, the branch is now the sanitized slug of that name (
supportmaxxing→ branch/foldersupportmaxxing). No LLM call runs — the typed name is authoritative for both title and branch. - Worktree creation never blocks on the LLM. The naming call runs in parallel with the git work; worktree add and registration proceed immediately with the seed branch (typed-name slug or friendly random).
- AI names land as a rename strictly before terminals/agents start. After registration, create awaits the (mostly-elapsed) naming promise and applies
git branch -m+ the row update — milliseconds — beforestartSetupTerminalIfPresentand agent dispatch. Setup scripts and agents can only ever observe the final branch name, and the create response carries the renamed values (original row object kept so the createtxidsurvives). Branch rename applies only to freshly-created auto-generated branches; adopted/existing and typed branches get title-only renames. autoNameWarningremoved from the v2 create response and its renderer toast: the seed name is now a valid final state rather than a failure signal. The v1 electron flow's separate warning path is untouched.- The adopt-by-
worktreePathpath no longer fires a naming call whose result was always discarded.
The worktree folder intentionally keeps its creation-time name — renaming the directory under running terminals/agents would break their recorded absolute paths, so the folder is treated as an opaque stable path.
Testing
bun run typecheckclean (host-service + desktop),bun run lintclean, 117 existing workspace-creation tests pass.- Verified end-to-end against a live dev host-service (confirmed running this branch's bundle) with a hermetic scratch repo imported as a project:
- Prompt only: created in 1.8s including the LLM call; folder kept the friendly seed (
defiant-tablecloth), branch renamed to the AI slug (relay-websocket-exponenti), response carried final names. - Typed name: name = branch = folder =
supportmaxxing. - Typed branch + prompt: branch kept verbatim, AI title applied.
- Prompt + command terminal: the terminal's
git rev-parse --abbrev-ref HEADat startup returned the post-rename branch — the setup-script race is demonstrably gone.
- Prompt only: created in 1.8s including the LLM call; folder kept the friendly seed (
https://claude.ai/code/session_01NE4bszQTqkq9txGcJ8jx9g
Summary by cubic
Seed the branch from the typed workspace name and apply generated names via a fast rename before terminals/agents start. This removes create-time blocking and fixes cases where setup scripts saw the wrong branch.
-
Bug Fixes
- When no branch is typed, the branch is seeded from the typed name (sanitized slug). No naming call blocks creation.
- Generated names are applied as a rename strictly before terminals/agents launch, so they only ever see the final branch.
- PR checkout and worktree adoption (
worktreePath) skip naming; friendly random is used when no name and no prompt. - Worktree directory is never renamed to avoid breaking absolute paths.
-
Refactors
- Added
applyGeneratedWorkspaceNamesand exportedsanitizeBranchCandidateinpackages/host-service. - Updated
workspaces.createto kick naming only whennameis omitted, run in parallel, and apply rename after registration. - Dropped
autoNameWarningfrom the v2 response and removed its handling inapps/desktop.
- Added
Summary by CodeRabbit
-
New Features
- Workspace creation can generate AI-based names when no explicit name is provided and a prompt is available.
- Explicit workspace names and branches are preserved.
- Automatically generated branches receive friendly names, with duplicate branches handled automatically.
-
Bug Fixes
- Removed auto-name warning notifications during workspace creation.
- Improved workspace setup sequencing for more reliable terminal and agent startup.