mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-03 18:00:48 -07:00
address feedback and make no permanent
This commit is contained in:
@@ -401,7 +401,9 @@ export const AppContainer = (props: AppContainerProps) => {
|
||||
const [planModeUIHistoryStartIndex, setPlanModeUIHistoryStartIndex] =
|
||||
useState<number | null>(() =>
|
||||
// Initialize if starting in PLAN mode (e.g. session resume)
|
||||
config.getApprovalMode() === ApprovalMode.PLAN ? 0 : null,
|
||||
config.getApprovalMode() === ApprovalMode.PLAN
|
||||
? config.getPlanModeHistoryStartIndex()
|
||||
: null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -411,7 +413,7 @@ export const AppContainer = (props: AppContainerProps) => {
|
||||
// This ensures that if we are already in PLAN mode and another
|
||||
// event fires, we don't accidentally move the start index forward.
|
||||
setPlanModeUIHistoryStartIndex((prev) =>
|
||||
prev === null ? historyManager.history.length : prev,
|
||||
prev === null ? config.getPlanModeHistoryStartIndex() : prev,
|
||||
);
|
||||
} else {
|
||||
// Reset the index when leaving PLAN mode
|
||||
@@ -422,7 +424,7 @@ export const AppContainer = (props: AppContainerProps) => {
|
||||
return () => {
|
||||
coreEvents.off(CoreEvent.ApprovalModeChanged, handleApprovalModeChanged);
|
||||
};
|
||||
}, [historyManager.history.length]);
|
||||
}, [config]);
|
||||
|
||||
const logger = useLogger(config.storage);
|
||||
const { inputHistory, addInput, initializeFromLogger } =
|
||||
|
||||
@@ -169,8 +169,18 @@ export const ExitPlanModeDialog: React.FC<ExitPlanModeDialogProps> = ({
|
||||
const [step, setStep] = useState<ApprovalStep>(ApprovalStep.PLAN_APPROVAL);
|
||||
const [selectedApprovalMode, setSelectedApprovalMode] =
|
||||
useState<ApprovalMode | null>(null);
|
||||
const [pendingApproval, setPendingApproval] = useState<{
|
||||
mode: ApprovalMode;
|
||||
clear: boolean;
|
||||
} | null>(null);
|
||||
const { setSetting } = useSettingsStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (pendingApproval) {
|
||||
onApprove(pendingApproval.mode, pendingApproval.clear);
|
||||
}
|
||||
}, [pendingApproval, onApprove]);
|
||||
|
||||
const handleOpenEditor = useCallback(async () => {
|
||||
try {
|
||||
await openFileInEditor(planPath, stdin, setRawMode, getPreferredEditor());
|
||||
@@ -356,11 +366,10 @@ export const ExitPlanModeDialog: React.FC<ExitPlanModeDialogProps> = ({
|
||||
}
|
||||
|
||||
if (selectedApprovalMode) {
|
||||
// Wrap in setTimeout to avoid 'Maximum update depth exceeded'
|
||||
// when setSetting triggers a re-render of the parent.
|
||||
setTimeout(() => {
|
||||
onApprove(selectedApprovalMode, clearConversation);
|
||||
}, 0);
|
||||
setPendingApproval({
|
||||
mode: selectedApprovalMode,
|
||||
clear: clearConversation,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onCancel={() => setStep(ApprovalStep.PLAN_APPROVAL)}
|
||||
|
||||
Reference in New Issue
Block a user