Skip to content

Commit e6f9236

Browse files
authored
refactor: simplify approval options for auto-edit modes (#734)
* refactor: simplify approval options for auto-edit modes * fix: use approvalMode instead of hardcoded autoEdit value * fix: add yolo mode option to plan approval view
1 parent 9d0bd6a commit e6f9236

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/ui/PlanMode/PlanApprovalView.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useTerminalSize } from '../useTerminalSize';
1414
export interface PlanApprovalViewProps {
1515
planFilePath: string;
1616
planContent: string | null;
17-
onApprove: (mode: 'autoEdit' | 'default') => void;
17+
onApprove: (mode: 'autoEdit' | 'default' | 'yolo') => void;
1818
onDeny: (feedback: string) => void;
1919
}
2020

@@ -25,11 +25,31 @@ export function PlanApprovalView({
2525
onDeny,
2626
}: PlanApprovalViewProps) {
2727
const { columns } = useTerminalSize();
28-
const { productName } = useAppStore();
28+
const { productName, approvalMode } = useAppStore();
2929
const isEditingRef = useRef(false);
3030

31-
const selectOptions = useMemo<SelectOption[]>(
32-
() => [
31+
const selectOptions = useMemo<SelectOption[]>(() => {
32+
// When approvalMode is 'autoEdit' or 'yolo', merge both options into a single 'Yes'
33+
// because edits will be auto-approved anyway
34+
if (approvalMode === 'autoEdit' || approvalMode === 'yolo') {
35+
return [
36+
{
37+
type: 'text',
38+
value: approvalMode,
39+
label: 'Yes',
40+
},
41+
{
42+
type: 'input',
43+
value: 'deny',
44+
label: `Type here to tell ${productName} what to change`,
45+
placeholder: `Type here to tell ${productName} what to change`,
46+
initialValue: '',
47+
},
48+
];
49+
}
50+
51+
// Default mode: show both options
52+
return [
3353
{
3454
type: 'text',
3555
value: 'autoEdit',
@@ -48,15 +68,14 @@ export function PlanApprovalView({
4868
placeholder: `Type here to tell ${productName} what to change`,
4969
initialValue: '',
5070
},
51-
],
52-
[productName],
53-
);
71+
];
72+
}, [productName, approvalMode]);
5473

5574
const handleChange = useCallback(
5675
(value: string | string[]) => {
5776
if (typeof value === 'string') {
58-
if (value === 'autoEdit' || value === 'default') {
59-
onApprove(value as 'autoEdit' | 'default');
77+
if (value === 'autoEdit' || value === 'default' || value === 'yolo') {
78+
onApprove(value as 'autoEdit' | 'default' | 'yolo');
6079
return;
6180
}
6281

0 commit comments

Comments
 (0)