Skip to content

feat: custom branch name for automations#2725

Open
janburzinski wants to merge 3 commits into
mainfrom
emdash/automaiton-branch-prefix-ifxov
Open

feat: custom branch name for automations#2725
janburzinski wants to merge 3 commits into
mainfrom
emdash/automaiton-branch-prefix-ifxov

Conversation

@janburzinski

Copy link
Copy Markdown
Collaborator

Description

  • add custom branch name for automations
  • preserve auto-generated names by default

Screenshot/Recording (if applicable)

https://cap.link/rbt174qgreghys3

Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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 StoredAutomationTaskConfig V2 schema and restored correctly when the automation is edited again.

  • Schema versioning (config.ts): V2 adds branchNameOverride?: string with a transparent migration from V1, so existing automations silently upgrade with no override set.
  • Execution layer (taskCreate.ts): scopeWorkspaceConfigToRun now receives the override and applies it to both create-branch and pr-branch git configs; falls back to the generated task name when the override is absent or blank.
  • UI / form state: useBranchName gains initialBranchName, customBranchNameSeed (normalized task name only — no prefix/random suffix), and resetBranchName; the "Custom branch name" toggle in BranchNameField seeds the editable field with the clean normalized name and drives the autoBranchName prop in AutomationSettingsFields.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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
Loading
%%{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
Loading

Reviews (2): Last reviewed commit: "fix(automations): preserve custom branch..." | Re-trigger Greptile

@janburzinski

Copy link
Copy Markdown
Collaborator Author

@greptileai

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.

1 participant