feat: custom branch name for automations#2725
Conversation
Greptile SummaryThis PR adds an optional custom branch name to automations, letting users override the auto-generated branch name that is applied at run time. The override is persisted in a new
Confidence Score: 5/5Safe to merge — the change is well-scoped, the V1→V2 migration is additive-only, and the fallback to the generated task name preserves existing automation behavior. All git-kind paths (create-branch, pr-branch, none, and the fallback) now thread branchNameOverride correctly. The execution layer safely falls back to the auto-generated task name when the override is absent or blank. The toggle seeds from the normalized task name rather than the full generated branch string. A targeted test covers the new override path, and the schema migration is a no-op for existing records. No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/shared/core/automations/config.ts | Adds V2 schema with optional branchNameOverride field and correct no-op migration from V1. |
| apps/emdash-desktop/src/main/core/automations/actions/taskCreate.ts | Extends scopeWorkspaceConfigToRun with branchNameOverride; falls back to taskName when override is absent or blank; handles both create-branch and pr-branch git kinds. |
| apps/emdash-desktop/src/main/core/automations/actions/taskCreate.test.ts | Adds a focused test for the branchNameOverride path; fixture version bumped to '2' to match new schema. |
| apps/emdash-desktop/src/renderer/features/tasks/create-task-modal/use-branch-name.ts | Adds initialBranchName for seeding existing overrides, exposes customBranchNameSeed (normalized task name) and resetBranchName for toggle integration. |
| apps/emdash-desktop/src/renderer/features/tasks/task-config/branch-name-field.tsx | Renders the Custom branch name toggle when customBranchNameControl is true; seeds editable field with customBranchNameSeed (normalized task name) on toggle-on. |
| apps/emdash-desktop/src/renderer/features/automations/useAutomationFormState.ts | Threads branchNameOverride through all git-kind branches in workspaceInitialFromConfig; serialises it into StoredAutomationTaskConfig only when non-empty and user-modified. |
| apps/emdash-desktop/src/renderer/features/automations/components/AutomationSettingsFields.tsx | Wires autoBranchName dynamically to !isUserModified and enables customBranchNameControl, so the toggle controls both the read-only label and the editable input. |
| apps/emdash-desktop/src/renderer/features/tasks/create-task-modal/use-workspace-config.ts | Adds branchName to WorkspaceConfigInitial type and forwards it as initialBranchName to useBranchName. |
| apps/emdash-desktop/src/renderer/features/tasks/task-config/task-config-context.tsx | Adds customBranchNameControl option to TaskConfigOptions with a default of false. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant U as User (Automation UI)
participant F as AutomationSettingsFields
participant BNF as BranchNameField
participant BNS as useBranchName
participant Store as StoredAutomationTaskConfig
participant Exec as executeTaskCreate
U->>F: Toggle "Custom branch name" ON
F->>BNF: "customBranchNameControl=true, autoBranchName=false"
BNF->>BNS: setBranchName(customBranchNameSeed)
BNS-->>BNF: "isUserModified=true, branchName=custom"
U->>F: Edit branch name field
F->>BNS: setBranchName("my-feature-branch")
BNS-->>F: "branchName="my-feature-branch""
U->>Store: Save automation (buildTaskConfig)
Store-->>Store: "branchNameOverride="my-feature-branch""
Note over Store,Exec: At automation run time
Exec->>Exec: scopeWorkspaceConfigToRun(config, taskName, "my-feature-branch")
Exec-->>Exec: "git.branchName = "my-feature-branch""
Exec->>Exec: prepareCreateTask(params)
Note over U,BNS: Editing saved automation
U->>F: "Open automation (seed=existing)"
F->>BNS: "initialBranchName="my-feature-branch""
BNS-->>BNF: "isUserModified=true, branchName="my-feature-branch""
BNF-->>U: Toggle shown as ON, field pre-filled
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant U as User (Automation UI)
participant F as AutomationSettingsFields
participant BNF as BranchNameField
participant BNS as useBranchName
participant Store as StoredAutomationTaskConfig
participant Exec as executeTaskCreate
U->>F: Toggle "Custom branch name" ON
F->>BNF: "customBranchNameControl=true, autoBranchName=false"
BNF->>BNS: setBranchName(customBranchNameSeed)
BNS-->>BNF: "isUserModified=true, branchName=custom"
U->>F: Edit branch name field
F->>BNS: setBranchName("my-feature-branch")
BNS-->>F: "branchName="my-feature-branch""
U->>Store: Save automation (buildTaskConfig)
Store-->>Store: "branchNameOverride="my-feature-branch""
Note over Store,Exec: At automation run time
Exec->>Exec: scopeWorkspaceConfigToRun(config, taskName, "my-feature-branch")
Exec-->>Exec: "git.branchName = "my-feature-branch""
Exec->>Exec: prepareCreateTask(params)
Note over U,BNS: Editing saved automation
U->>F: "Open automation (seed=existing)"
F->>BNS: "initialBranchName="my-feature-branch""
BNS-->>BNF: "isUserModified=true, branchName="my-feature-branch""
BNF-->>U: Toggle shown as ON, field pre-filled
Reviews (2): Last reviewed commit: "fix(automations): preserve custom branch..." | Re-trigger Greptile
Description
Screenshot/Recording (if applicable)
https://cap.link/rbt174qgreghys3
Checklist
messages and, when possible, the PR title