diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx
index f234f2640..092468f06 100644
--- a/gui/src/pages/gui/ToolCallDiv/index.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/index.tsx
@@ -16,6 +16,10 @@ import { RunTerminalCommand } from "./RunTerminalCommand";
import { ToolState } from "./types";
const Container = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+
margin: 8px;
overflow: hidden;
border-left: 1px solid ${lightGray};
@@ -120,6 +124,26 @@ export function ToolCallDiv(props: ToolCallDivProps) {
}
}, [props.toolCall.function.arguments]);
+ useEffect(() => {
+ function handleKeyDown(e: KeyboardEvent) {
+ if (e.key === "Tab") {
+ e.preventDefault();
+ callTool();
+ }
+ if (e.key === "Backspace" && e.metaKey) {
+ e.preventDefault();
+ cancelTool();
+ }
+ }
+
+ window.addEventListener("keydown", handleKeyDown);
+ return () => window.removeEventListener("keydown", handleKeyDown);
+ }, []);
+
+ async function cancelTool() {
+ setState("canceled");
+ }
+
async function callTool() {
let setCallingState = true;
@@ -157,14 +181,15 @@ export function ToolCallDiv(props: ToolCallDivProps) {
className="flex w-full items-center justify-center gap-4"
style={{
color: lightGray,
+ minHeight: "40px",
}}
>
Thinking...
-
+ {/* */}
) : state === "generated" ? (
<>
- {}}>Cancel
+ Cancel
Continue
>
) : state === "calling" ? (
diff --git a/gui/src/pages/gui/ToolCallDiv/types.ts b/gui/src/pages/gui/ToolCallDiv/types.ts
index fa041be64..2a21a7bb9 100644
--- a/gui/src/pages/gui/ToolCallDiv/types.ts
+++ b/gui/src/pages/gui/ToolCallDiv/types.ts
@@ -1 +1,6 @@
-export type ToolState = "generating" | "generated" | "calling" | "done";
+export type ToolState =
+ | "generating"
+ | "generated"
+ | "calling"
+ | "done"
+ | "canceled";