diff --git a/core/index.d.ts b/core/index.d.ts
index 3ec58990d..494b4e314 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -402,6 +402,7 @@ interface ToolCallState {
toolCall: ToolCall;
status: ToolStatus;
parsedArgs: any;
+ output?: ContextItem[];
}
export interface ChatHistoryItem {
diff --git a/core/tools/definitions/runTerminalCommand.ts b/core/tools/definitions/runTerminalCommand.ts
index 94a429e23..82b2d342c 100644
--- a/core/tools/definitions/runTerminalCommand.ts
+++ b/core/tools/definitions/runTerminalCommand.ts
@@ -1,5 +1,4 @@
import { Tool } from "../..";
-
import { BuiltInToolNames } from "../builtIn";
export const runTerminalCommandTool: Tool = {
@@ -9,7 +8,8 @@ export const runTerminalCommandTool: Tool = {
readonly: false,
function: {
name: BuiltInToolNames.RunTerminalCommand,
- description: "Run a terminal command in the current directory",
+ description:
+ "Run a terminal command in the current directory. The shell is not stateful and will not remember any previous commands.",
parameters: {
type: "object",
required: ["command"],
diff --git a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx
index d96afc7fe..42ee8e048 100644
--- a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx
+++ b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx
@@ -1,10 +1,10 @@
-import { CheckIcon, XMarkIcon, PlayIcon } from "@heroicons/react/24/outline";
-import Spinner from "./Spinner";
-import { lightGray, vscForeground } from "../..";
-import { useState } from "react";
-import { getMetaKeyLabel } from "../../../util";
-import { ToolbarButtonWithTooltip } from "./ToolbarButtonWithTooltip";
+import { CheckIcon, PlayIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { ApplyState } from "core";
+import { useState } from "react";
+import { lightGray, vscForeground } from "../..";
+import { getMetaKeyLabel } from "../../../util";
+import Spinner from "./Spinner";
+import { ToolbarButtonWithTooltip } from "./ToolbarButtonWithTooltip";
interface ApplyActionsProps {
applyState?: ApplyState;
diff --git a/gui/src/components/markdown/StepContainerPreToolbar/RunInTerminalButton.tsx b/gui/src/components/markdown/StepContainerPreToolbar/RunInTerminalButton.tsx
new file mode 100644
index 000000000..35bc54349
--- /dev/null
+++ b/gui/src/components/markdown/StepContainerPreToolbar/RunInTerminalButton.tsx
@@ -0,0 +1,35 @@
+import { CommandLineIcon } from "@heroicons/react/24/outline";
+import { useContext } from "react";
+import { lightGray, vscForeground } from "../..";
+import { IdeMessengerContext } from "../../../context/IdeMessenger";
+
+interface RunInTerminalButtonProps {
+ command: string;
+}
+
+export default function RunInTerminalButton({
+ command,
+}: RunInTerminalButtonProps) {
+ const ideMessenger = useContext(IdeMessengerContext);
+
+ function runInTerminal() {
+ void ideMessenger.post("runCommand", { command });
+ }
+
+ return (
+
+ );
+}
diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
index cc7de6033..ca7d78d97 100644
--- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
+++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
@@ -10,11 +10,12 @@ import { useWebviewListener } from "../../../hooks/useWebviewListener";
import { defaultModelSelector } from "../../../redux/selectors/modelSelectors";
import { RootState } from "../../../redux/store";
import { getFontSize } from "../../../util";
-import { childrenToText } from "../utils";
+import { childrenToText, isTerminalCodeBlock } from "../utils";
import ApplyActions from "./ApplyActions";
import CopyButton from "./CopyButton";
import FileInfo from "./FileInfo";
import GeneratingCodeLoader from "./GeneratingCodeLoader";
+import RunInTerminalButton from "./RunInTerminalButton";
const fadeInAnimation = keyframes`
from {
@@ -202,14 +203,17 @@ export default function StepContainerPreToolbar(
{!isGeneratingCodeBlock && (
<>
- {props.hideApply || (
-
- )}
+ {props.hideApply ||
+ (isTerminalCodeBlock(props.language, props.codeBlockContent) ? (
+
+ ) : (
+
+ ))}
>
)}
diff --git a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx
index dd06c48ca..34044d71f 100644
--- a/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx
@@ -18,7 +18,7 @@ function FunctionSpecificToolCallDiv({
);
case "run_terminal_command":
- return ;
+ return ;
case "exact_search":
return ;
default:
diff --git a/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx b/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx
index 08c00c0bd..35fc0e54f 100644
--- a/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx
@@ -1,16 +1,16 @@
+import { ToolCallState } from "core";
import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview";
interface RunTerminalCommandToolCallProps {
command: string;
+ toolCallState: ToolCallState;
}
export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) {
return (
- <>
-
- >
+
);
}
diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts
index 0a1ad6ead..475932b2a 100644
--- a/gui/src/redux/slices/stateSlice.ts
+++ b/gui/src/redux/slices/stateSlice.ts
@@ -10,6 +10,7 @@ import {
ChatHistoryItem,
ChatMessage,
Checkpoint,
+ ContextItem,
ContextItemWithId,
FileSymbolMap,
IndexingStatus,
@@ -485,6 +486,12 @@ export const stateSlice = createSlice({
toolCallState.status = "generated";
},
+ setToolCallOutput: (state, action: PayloadAction) => {
+ const toolCallState = findCurrentToolCall(state.history);
+ if (!toolCallState) return;
+
+ toolCallState.output = action.payload
+ },
cancelToolCall: (state) => {
const toolCallState = findCurrentToolCall(state.history);
if (!toolCallState) return;
@@ -598,6 +605,7 @@ export const {
acceptToolCall,
setToolGenerated,
updateDocsSuggestions,
+ setToolCallOutput
} = stateSlice.actions;
export default stateSlice.reducer;
diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts
index f326423aa..7a8c56669 100644
--- a/gui/src/redux/thunks/callTool.ts
+++ b/gui/src/redux/thunks/callTool.ts
@@ -1,5 +1,6 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall";
+import { setToolCallOutput } from "../slices/stateSlice";
import { ThunkApiType } from "../store";
import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall";
@@ -24,6 +25,8 @@ export const callTool = createAsyncThunk(
if (result.status === "success") {
const contextItems = result.content.contextItems;
+ dispatch(setToolCallOutput(contextItems));
+
// Send to the LLM to continue the conversation
dispatch(
streamResponseAfterToolCall({