Skip to content

feat(desktop): add configurable branch name prefix - #1015

Merged
Kitenite merged 11 commits into
ParadevAI:mainfrom
kkjcheng:feat/configurable-default-branch-name
Jan 28, 2026
Merged

Kitenite merged 11 commits into
ParadevAI:mainfrom
kkjcheng:feat/configurable-default-branch-name

Conversation

@kkjcheng

@kkjcheng kkjcheng commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds configurable branch name prefixes when creating workspaces.

Prefix modes:

  • GitHub username (default) - kkjcheng/feature-name
  • Git author name - kevin-cheng/feature-name
  • Static "feat" - feat/feature-name
  • Custom prefix - your-prefix/feature-name
  • None - feature-name

Settings can be configured globally (Behavior settings) or per-project (Project settings). Project-level settings override global defaults.

UI: Settings include a live preview showing the generated branch name format.

Note: Branch names are always sanitized (lowercased, spaces to dashes, special chars removed) regardless of prefix mode.

Summary by CodeRabbit

  • New Features

    • Branch prefix customization: choose GitHub username, git author, custom text, or no prefix for branch names.
    • Configure a global default and override per project.
  • Enhancements

    • Live preview of the computed branch prefix when editing settings or project configuration.
    • Settings now surface Git info to improve prefix suggestions.
  • Chores

    • Settings search updated to include Branch Prefix entries.

✏️ Tip: You can customize this high-level summary in your review settings.

Add settings to configure how branch names are prefixed when creating
new workspaces. Supports five modes: GitHub username (default), git
author name, static "feat" prefix, custom prefix, or no prefix.

Settings available both globally (Features settings) and per-project
(Project settings), with project settings overriding global defaults.
@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Kitenite has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 48 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds configurable branch-prefixing: new DB columns and types, APIs to get/set branch-prefix and Git info, utilities to compute prefixes, workspace creation updated to apply prefixes, and frontend UI to configure and preview global/project branch-prefix modes.

Changes

Cohort / File(s) Summary
Database schema & types
packages/local-db/src/schema/zod.ts, packages/local-db/src/schema/schema.ts
Adds BRANCH_PREFIX_MODES and BranchPrefixMode; adds branchPrefixMode and branchPrefixCustom columns to projects and settings.
Migrations & metadata
packages/local-db/drizzle/0014_add_branch_prefix_config.sql, packages/local-db/drizzle/meta/0014_snapshot.json, packages/local-db/drizzle/meta/_journal.json
Adds migration to create four new text columns and corresponding snapshot/journal entries.
Backend — settings router
apps/desktop/src/lib/trpc/routers/settings/index.ts
Adds getBranchPrefix, setBranchPrefix, and getGitInfo procedures; imports BRANCH_PREFIX_MODES; persists global branch-prefix settings.
Backend — projects router
apps/desktop/src/lib/trpc/routers/projects/projects.ts
Update project update input and mutation to accept and persist branchPrefixMode and branchPrefixCustom.
Backend — workspaces create flow
apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts
Reads project/global settings, resolves effective prefix mode/custom, computes prefix via new util, and applies it when generating/normalizing branch names.
Backend — git utilities
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
Adds getBranchPrefix({ repoPath, mode, customPrefix }) to compute prefix (none/custom/author/github fallback).
Frontend — Behavior settings UI
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx
Adds Branch Prefix section: mode select, optional custom input, preview, TRPC queries/mutations and state handling.
Frontend — Project settings UI
apps/desktop/src/renderer/routes/_authenticated/settings/project/$projectId/components/ProjectSettings/ProjectSettings.tsx
Adds project-level Branch Prefix override UI, handlers, preview, and update mutation.
Frontend — branch-prefix labels & sanitizer
apps/desktop/src/renderer/routes/_authenticated/settings/utils/branch-prefix/branch-prefix.ts, .../index.ts
Adds BRANCH_PREFIX_MODE_LABELS, BRANCH_PREFIX_MODE_LABELS_WITH_DEFAULT, and sanitizePrefix.
Frontend — settings search
apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts
Adds searchable items BEHAVIOR_BRANCH_PREFIX and PROJECT_BRANCH_PREFIX.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as Frontend UI
    participant API as Backend API
    participant DB as Database
    participant Git as Git Utils

    User->>UI: Configure branch prefix (global or project)
    UI->>API: setBranchPrefix() / updateProject()
    API->>DB: Persist branchPrefixMode & branchPrefixCustom
    DB-->>API: Saved
    API-->>UI: Success

    Note over User,Git: Later — creating a workspace

    User->>UI: Create workspace
    UI->>API: createWorkspace mutation
    API->>DB: Read project & global settings
    DB-->>API: branch prefix config
    API->>Git: getBranchPrefix(repoPath, mode, customPrefix)
    Git-->>API: Computed prefix (or null)
    API->>API: Generate/sanitize branch name with prefix
    API->>DB: Create workspace record (branch name)
    DB-->>API: Created
    API-->>UI: Workspace ready
    UI-->>User: Workspace created
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I nibble settings, stitch a name,
github, author, custom — none the same.
A prefix here, a preview there,
Branches bloom with rabbit care.
Hop!—a workspace born with flair 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature addition: configurable branch name prefixes for branch naming in the application.
Description check ✅ Passed The description comprehensively covers the feature with prefix modes, configuration options, UI capabilities, and sanitization details, though it does not strictly follow the template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts`:
- Around line 305-313: The code currently mixes levels: it reads prefixMode from
project but still falls back to global customPrefix even when the project
explicitly set branchPrefixMode; change the logic so mode and customPrefix come
from the same source (project if project.branchPrefixMode is defined, otherwise
globalSettings) and only fallback to the default "github" when neither level
provides a mode. Specifically, replace the current assignments for prefixMode
and customPrefix (which use project.branchPrefixMode and
project.branchPrefixCustom) with a branch that (1) if project.branchPrefixMode
!== undefined/null then set prefixMode = project.branchPrefixMode and
customPrefix = project.branchPrefixCustom, (2) else set prefixMode =
globalSettings?.branchPrefixMode ?? "github" and customPrefix =
globalSettings?.branchPrefixCustom.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx`:
- Around line 71-85: The onError handler for the setBranchPrefix mutation
(created via electronTrpc.settings.setBranchPrefix.useMutation) currently
swallows errors; update the onError callback to log the error with context
before restoring previous data: capture the incoming error parameter, then call
console.error with a prefixed message like "[settings/setBranchPrefix] Failed to
update branch prefix:" followed by the error and any relevant vars/context;
leave the existing restore logic using
utils.settings.getBranchPrefix.setData(...) intact so failures are both logged
and rolled back.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/project/`$projectId/components/ProjectSettings/ProjectSettings.tsx:
- Around line 37-72: The project patch mutations (used by updateProject and
triggered from handleBranchPrefixModeChange and handleCustomPrefixChange) need
optimistic cache updates so the controlled Input bound to
project.branchPrefixCustom reflects keystrokes immediately; implement an
onMutate handler on electronTrpc.projects.update.useMutation that snapshots the
current utils.projects.get.getData({ id: projectId }), applies the optimistic
patch via utils.projects.get.setData({ id: projectId }, updatedProject)
(updating branchPrefixMode and branchPrefixCustom per the patch), and then
rollback the snapshot in onError and call utils.projects.get.invalidate({ id:
projectId }) in onSettled; apply the same optimistic pattern to the other
mutation referenced in the comment (the mutation around lines 141-145).
🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx (1)

18-26: Consider centralizing BranchPrefixMode labels to prevent drift.

This label map is duplicated in ProjectSettings and should stay aligned with backend modes; a shared constant/module would reduce maintenance risk.

kkjcheng and others added 7 commits January 27, 2026 22:03
Show a live preview of what branch names will look like based on the
selected prefix mode. Uses the user's actual GitHub username or git
author name when available.
Adds columns for configurable branch name prefix to projects and settings tables.
- Fix project override logic to use project's customPrefix when mode is set
- Add error logging to branch prefix mutation handlers
- Add optimistic updates to project settings mutation
Previously the prefix was only applied to auto-generated branch names.
Now user-provided names also get the configured prefix.
- Import BranchPrefixMode from @superset/local-db instead of duplicating
- Extract shared BRANCH_PREFIX_MODE_LABELS to utils/branch-prefix
- Remove redundant "feat" prefix option (use custom instead)
- Make branch prefix setting a single-row layout
- Add trailing newline to migration file

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx`:
- Around line 85-90: handleBranchPrefixModeChange currently clears customPrefix
whenever mode !== "custom", causing the user's previous custom prefix to be
lost; change the behavior so setBranchPrefix.mutate always sends the last known
custom prefix (e.g., branchPrefix?.customPrefix or a component state like
lastCustomPrefix) and only set customPrefix to null when the user explicitly
clears the input. Update the handler (handleBranchPrefixModeChange) and ensure
the input's onChange updates lastCustomPrefix/branchPrefix so toggling modes
preserves the value.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx (1)

92-96: Avoid persisting on every keystroke.

onChange triggers a mutation for each keypress, which can spam IPC/DB writes and hurt typing responsiveness. Consider buffering input locally and persisting on blur/Enter or with a debounce, while still using the local draft for the live preview.

Also applies to: 181-188

- Change default branch prefix mode from "github" to "none"
- Add sanitizePrefix function to trim/sanitize custom prefix on blur
- Update both global settings and project settings
- Add resolveBranchPrefix function to shared/utils/branch.ts
- Update NewWorkspaceModal to show correct branch preview with prefix
- Remove duplicate switch logic from BehaviorSettings and ProjectSettings
- Use sanitizeSegment from shared utils instead of local sanitizePrefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants