Skip to content

Commit 9aad0e2

Browse files
committed
Implement mouse back/forward and esc key support to cancel generation
1 parent c30b8be commit 9aad0e2

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

apps/array/src/renderer/components/MainLayout.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ export function MainLayout() {
7676
};
7777
}, [handleOpenSettings, handleFocusTaskMode, handleResetLayout]);
7878

79+
useEffect(() => {
80+
const handleMouseButton = (event: MouseEvent) => {
81+
if (event.button === 3) {
82+
// Button 3 = back
83+
event.preventDefault();
84+
goBack();
85+
} else if (event.button === 4) {
86+
// Button 4 = forward
87+
event.preventDefault();
88+
goForward();
89+
}
90+
};
91+
92+
window.addEventListener("mouseup", handleMouseButton);
93+
return () => {
94+
window.removeEventListener("mouseup", handleMouseButton);
95+
};
96+
}, [goBack, goForward]);
97+
7998
const handleSelectTask = (task: Task) => {
8099
navigateToTask(task);
81100
};

apps/array/src/renderer/features/sessions/components/SessionView.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,25 @@ export function SessionView({
336336
openSearch();
337337
setTimeout(() => searchInputRef.current?.focus(), 0);
338338
}
339-
if (e.key === "Escape" && showSearch) {
340-
closeSearch();
339+
if (e.key === "Escape") {
340+
if (showSearch) {
341+
closeSearch();
342+
} else if (isPromptPending) {
343+
onCancelPrompt();
344+
}
341345
}
342346
};
343347

344348
window.addEventListener("keydown", handleKeyDown);
345349
return () => window.removeEventListener("keydown", handleKeyDown);
346-
}, [showRawLogs, showSearch, openSearch, closeSearch]);
350+
}, [
351+
showRawLogs,
352+
showSearch,
353+
openSearch,
354+
closeSearch,
355+
isPromptPending,
356+
onCancelPrompt,
357+
]);
347358

348359
const messages = useMemo(() => processEvents(events), [events]);
349360
const turns = useMemo(

0 commit comments

Comments
 (0)