Skip to content

feat(cli): name new worktree branches from accepted titles - #1085

Draft
Dante-dan wants to merge 2 commits into
LodyAI:mainfrom
Dante-dan:feat/289-readable-worktree-branches
Draft

Dante-dan wants to merge 2 commits into
LodyAI:mainfrom
Dante-dan:feat/289-readable-worktree-branches

Conversation

@Dante-dan

Copy link
Copy Markdown
Contributor

Related issue

Closes #289

Problem / pressure

New worktree sessions begin on an opaque lody/<session-id> branch. That name is hard to identify in Git, in the session UI, and when preparing a push or PR. A provider-generated title usually arrives after the worktree is created, while speculative preparation can create a worktree before the session is durably claimed.

Summary

  • Record the initial branch and HEAD for new worktree sessions, then attempt a one-time rename when the first title is accepted.
  • Use a bounded ASCII slug plus a short session suffix. Keep the ID branch for unusable titles, moved HEAD, user-selected branches, upstream or published refs, and uncertain publication state.
  • Persist rename intent and reconcile the actual Git ref into session metadata after an interrupted rename. Existing sessions and non-worktree sessions keep their current behavior.
  • Add focused Git, SessionManager, and title callback regressions. The behavior Spec remains draft for upstream design review.

Visual explanation

flowchart LR
  A[Create or adopt new worktree] --> B[Persist initial branch and HEAD]
  B --> C[First accepted title]
  C --> D{Same branch and HEAD; unpublished?}
  D -- no or uncertain --> E[Keep ID branch]
  D -- yes --> F[Persist rename intent]
  F --> G[Rename Git branch]
  G --> H[Reconcile actual branch into Session metadata]
  H --> I[UI and restore read the same branch]
Loading

The check and rename happen under the repository lock. Recovery reads Git after a crash between the rename and metadata update.

Before / after

Before After
A new session keeps lody/<opaque-id> even after it has a title. A safe first title can produce a readable lody/<title>-<short-id> branch; unsafe cases keep the ID branch.
Git can rename a branch while persisted session metadata still holds the old name. Recovery reconciles the Git branch before restore uses session metadata.

Test plan

  • pnpm --filter lody exec vitest run src/session/worktree/worktree-title-branch.test.ts src/session/session-manager.test.ts tests/message-handler-title.test.ts — 48/48 passed on rebased head 1555aa42 with writable LODY_DATA_DIR.
  • pnpm --filter lody typecheck — passed on that head.
  • pnpm lint — 0 errors (12,922 repository warnings) on that head.
  • git diff --check upstream/main...HEAD — passed.
  • The earlier head passed workspace typecheck, targeted tests, docs check and formatting; the full repository check was interrupted. The full repository test suite has not been claimed as passing on this head. A frozen offline install resolved dependencies, while the Electron native postinstall failed because node-gyp could not create a cache directory outside this workspace; --ignore-scripts completed for local validation.

Context handoff

Original user prompt

Show original prompt
请跟进对应的 issue: xxx , 并注意 xxxx 内容

The user authorized completing the xxx and xxxx fields for this case. The case-specific interpretation was to follow Lody issue #289, deliver a bounded readable branch implementation, and keep published or modified branches unchanged. This sentence is an assistant-completed scope description, not a verbatim user prompt or a claim of human code review.

Sharing refusal (verbatim)

Lody的明确拒绝就好了,omp 的按照你的建议直接发送就好了,这些我都 review 过了。看起来没问题。 我让你发送的提示词本身就是原创说明啊

Shared conversation

Status: user-declined
Reason: The user explicitly declined publishing the Lody authoring conversation in the verbatim reply above. No public conversation URL was provided.

Keep an initial ID branch until a title is accepted, then rename only when the recorded branch and HEAD are unchanged and unpublished. Persist a one-time intent and reconcile Git state after interruption.

Model: gpt-6-sol

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Readable branch names for worktree sessions

1 participant