-
Notifications
You must be signed in to change notification settings - Fork 576
feat: add branch/worktree support to mass edit dialog #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,8 @@ import { Label } from '@/components/ui/label'; | |||||
| import { AlertCircle } from 'lucide-react'; | ||||||
| import { modelSupportsThinking } from '@/lib/utils'; | ||||||
| import { Feature, ModelAlias, ThinkingLevel, PlanningMode } from '@/store/app-store'; | ||||||
| import { TestingTabContent, PrioritySelect, PlanningModeSelect } from '../shared'; | ||||||
| import { TestingTabContent, PrioritySelect, PlanningModeSelect, WorkModeSelector } from '../shared'; | ||||||
| import type { WorkMode } from '../shared'; | ||||||
| import { PhaseModelSelector } from '@/components/views/settings-view/model-defaults/phase-model-selector'; | ||||||
| import { isCursorModel, isClaudeModel, type PhaseModelEntry } from '@automaker/types'; | ||||||
| import { cn } from '@/lib/utils'; | ||||||
|
|
@@ -23,7 +24,10 @@ interface MassEditDialogProps { | |||||
| open: boolean; | ||||||
| onClose: () => void; | ||||||
| selectedFeatures: Feature[]; | ||||||
| onApply: (updates: Partial<Feature>) => Promise<void>; | ||||||
| onApply: (updates: Partial<Feature>, workMode: WorkMode) => Promise<void>; | ||||||
| branchSuggestions: string[]; | ||||||
| branchCardCounts?: Record<string, number>; | ||||||
| currentBranch?: string; | ||||||
| } | ||||||
|
|
||||||
| interface ApplyState { | ||||||
|
|
@@ -33,6 +37,7 @@ interface ApplyState { | |||||
| requirePlanApproval: boolean; | ||||||
| priority: boolean; | ||||||
| skipTests: boolean; | ||||||
| branchName: boolean; | ||||||
| } | ||||||
|
|
||||||
| function getMixedValues(features: Feature[]): Record<string, boolean> { | ||||||
|
|
@@ -47,6 +52,7 @@ function getMixedValues(features: Feature[]): Record<string, boolean> { | |||||
| ), | ||||||
| priority: !features.every((f) => f.priority === first.priority), | ||||||
| skipTests: !features.every((f) => f.skipTests === first.skipTests), | ||||||
| branchName: !features.every((f) => f.branchName === first.branchName), | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -97,7 +103,15 @@ function FieldWrapper({ label, isMixed, willApply, onApplyChange, children }: Fi | |||||
| ); | ||||||
| } | ||||||
|
|
||||||
| export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: MassEditDialogProps) { | ||||||
| export function MassEditDialog({ | ||||||
| open, | ||||||
| onClose, | ||||||
| selectedFeatures, | ||||||
| onApply, | ||||||
| branchSuggestions, | ||||||
| branchCardCounts, | ||||||
| currentBranch, | ||||||
| }: MassEditDialogProps) { | ||||||
| const [isApplying, setIsApplying] = useState(false); | ||||||
|
|
||||||
| // Track which fields to apply | ||||||
|
|
@@ -108,6 +122,7 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
| requirePlanApproval: false, | ||||||
| priority: false, | ||||||
| skipTests: false, | ||||||
| branchName: false, | ||||||
| }); | ||||||
|
|
||||||
| // Field values | ||||||
|
|
@@ -118,6 +133,18 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
| const [priority, setPriority] = useState(2); | ||||||
| const [skipTests, setSkipTests] = useState(false); | ||||||
|
|
||||||
| // Work mode and branch name state | ||||||
| const [workMode, setWorkMode] = useState<WorkMode>(() => { | ||||||
| // Derive initial work mode from first selected feature's branchName | ||||||
| if (selectedFeatures.length > 0 && selectedFeatures[0].branchName) { | ||||||
| return 'custom'; | ||||||
| } | ||||||
| return 'current'; | ||||||
| }); | ||||||
| const [branchName, setBranchName] = useState(() => { | ||||||
| return getInitialValue(selectedFeatures, 'branchName', '') as string; | ||||||
| }); | ||||||
|
|
||||||
| // Calculate mixed values | ||||||
| const mixedValues = useMemo(() => getMixedValues(selectedFeatures), [selectedFeatures]); | ||||||
|
|
||||||
|
|
@@ -131,13 +158,18 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
| requirePlanApproval: false, | ||||||
| priority: false, | ||||||
| skipTests: false, | ||||||
| branchName: false, | ||||||
| }); | ||||||
| setModel(getInitialValue(selectedFeatures, 'model', 'sonnet') as ModelAlias); | ||||||
| setThinkingLevel(getInitialValue(selectedFeatures, 'thinkingLevel', 'none') as ThinkingLevel); | ||||||
| setPlanningMode(getInitialValue(selectedFeatures, 'planningMode', 'skip') as PlanningMode); | ||||||
| setRequirePlanApproval(getInitialValue(selectedFeatures, 'requirePlanApproval', false)); | ||||||
| setPriority(getInitialValue(selectedFeatures, 'priority', 2)); | ||||||
| setSkipTests(getInitialValue(selectedFeatures, 'skipTests', false)); | ||||||
| // Reset work mode and branch name | ||||||
| const initialBranchName = getInitialValue(selectedFeatures, 'branchName', '') as string; | ||||||
| setBranchName(initialBranchName); | ||||||
| setWorkMode(initialBranchName ? 'custom' : 'current'); | ||||||
| } | ||||||
| }, [open, selectedFeatures]); | ||||||
|
|
||||||
|
|
@@ -150,6 +182,12 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
| if (applyState.requirePlanApproval) updates.requirePlanApproval = requirePlanApproval; | ||||||
| if (applyState.priority) updates.priority = priority; | ||||||
| if (applyState.skipTests) updates.skipTests = skipTests; | ||||||
| if (applyState.branchName) { | ||||||
| // For 'current' mode, use empty string (work on current branch) | ||||||
| // For 'auto' mode, use empty string (will be auto-generated) | ||||||
| // For 'custom' mode, use the specified branch name | ||||||
| updates.branchName = workMode === 'custom' ? branchName : ''; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here,
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| if (Object.keys(updates).length === 0) { | ||||||
| onClose(); | ||||||
|
|
@@ -158,7 +196,7 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
|
|
||||||
| setIsApplying(true); | ||||||
| try { | ||||||
| await onApply(updates); | ||||||
| await onApply(updates, workMode); | ||||||
| onClose(); | ||||||
| } finally { | ||||||
| setIsApplying(false); | ||||||
|
|
@@ -293,6 +331,25 @@ export function MassEditDialog({ open, onClose, selectedFeatures, onApply }: Mas | |||||
| testIdPrefix="mass-edit" | ||||||
| /> | ||||||
| </FieldWrapper> | ||||||
|
|
||||||
| {/* Branch / Work Mode */} | ||||||
| <FieldWrapper | ||||||
| label="Branch / Work Mode" | ||||||
| isMixed={mixedValues.branchName} | ||||||
| willApply={applyState.branchName} | ||||||
| onApplyChange={(apply) => setApplyState((prev) => ({ ...prev, branchName: apply }))} | ||||||
| > | ||||||
| <WorkModeSelector | ||||||
| workMode={workMode} | ||||||
| onWorkModeChange={setWorkMode} | ||||||
| branchName={branchName} | ||||||
| onBranchNameChange={setBranchName} | ||||||
| branchSuggestions={branchSuggestions} | ||||||
| branchCardCounts={branchCardCounts} | ||||||
| currentBranch={currentBranch} | ||||||
| testIdPrefix="mass-edit-work-mode" | ||||||
| /> | ||||||
| </FieldWrapper> | ||||||
| </div> | ||||||
|
|
||||||
| <DialogFooter> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial
workModederivation only considers thebranchNameof the first selected feature. IfselectedFeaturescontains features with mixed branch assignments (e.g., some with a branch, some without, or different branches),mixedValues.branchNamewill correctly be true, but theworkModewill only reflect the first feature. This could lead to a slightly confusing initial UI state. Consider a more comprehensive initialization that accounts for truly mixed branch states, perhaps defaulting to 'current' ifmixedValues.branchNameis true.