Skip to content

Commit 4ddbcab

Browse files
committedMar 25, 2025
disable stuff while generated
1 parent 30bfc4f commit 4ddbcab

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed
 

‎gui/src/components/mainInput/InputToolbar.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "..";
1414
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
1515
import { selectUseActiveFile } from "../../redux/selectors";
16+
import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall";
1617
import { selectDefaultModel } from "../../redux/slices/configSlice";
1718
import {
1819
selectHasCodeToEdit,
@@ -49,15 +50,21 @@ const StyledDiv = styled.div<{ isHidden?: boolean }>`
4950
}
5051
`;
5152

52-
const EnterButton = styled.button<{ isPrimary?: boolean }>`
53+
const EnterButton = styled.button<{
54+
isPrimary?: boolean;
55+
disabled?: boolean;
56+
}>`
5357
all: unset;
5458
padding: 2px 4px;
5559
display: flex;
5660
align-items: center;
5761
background-color: ${(props) =>
58-
props.isPrimary ? vscButtonBackground : lightGray + "33"};
62+
!props.disabled && props.isPrimary
63+
? vscButtonBackground
64+
: lightGray + "33"};
5965
border-radius: ${defaultBorderRadius};
60-
color: ${(props) => (props.isPrimary ? vscButtonForeground : vscForeground)};
66+
color: ${(props) =>
67+
!props.disabled && props.isPrimary ? vscButtonForeground : vscForeground};
6168
cursor: pointer;
6269
6370
:disabled {
@@ -94,8 +101,13 @@ function InputToolbar(props: InputToolbarProps) {
94101
const useActiveFile = useAppSelector(selectUseActiveFile);
95102
const isInEditMode = useAppSelector(selectIsInEditMode);
96103
const hasCodeToEdit = useAppSelector(selectHasCodeToEdit);
104+
const toolCallState = useAppSelector(selectCurrentToolCall);
97105
const isEditModeAndNoCodeToEdit = isInEditMode && !hasCodeToEdit;
98-
const isEnterDisabled = props.disabled || isEditModeAndNoCodeToEdit;
106+
107+
const isEnterDisabled =
108+
props.disabled ||
109+
isEditModeAndNoCodeToEdit ||
110+
toolCallState?.status === "generated";
99111
const toolsSupported = defaultModel && modelSupportsTools(defaultModel);
100112

101113
const supportsImages =

‎gui/src/components/mainInput/tiptap/TipTapEditor.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ function TipTapEditor(props: TipTapEditorProps) {
223223
}}
224224
>
225225
<div className="px-2.5 pb-1 pt-2">
226-
{/* <TopInputToolbar
227-
lumpOpen={props.lumpOpen}
228-
setLumpOpen={props.setLumpOpen}
229-
/> */}
230226
<EditorContent
231227
className={`scroll-container overflow-y-scroll ${props.isMainInput ? "max-h-[70vh]" : ""}`}
232228
spellCheck={false}

‎gui/src/pages/gui/Chat.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import {
55
ExclamationTriangleIcon,
66
} from "@heroicons/react/24/outline";
77
import { Editor, JSONContent } from "@tiptap/react";
8-
import { InputModifiers, RangeInFileWithContents, ToolCallState } from "core";
8+
import { InputModifiers, RangeInFileWithContents } from "core";
99
import { streamResponse } from "core/llm/stream";
1010
import { renderChatMessage, stripImages } from "core/util/messageContent";
1111
import { usePostHog } from "posthog-js/react";
1212
import { useCallback, useContext, useEffect, useRef, useState } from "react";
1313
import { ErrorBoundary } from "react-error-boundary";
14-
import { useSelector } from "react-redux";
1514
import styled from "styled-components";
1615
import { Button, lightGray, vscBackground } from "../../components";
1716
import CodeToEditCard from "../../components/CodeToEditCard";
@@ -45,7 +44,6 @@ import {
4544
setDialogMessage,
4645
setShowDialog,
4746
} from "../../redux/slices/uiSlice";
48-
import { RootState } from "../../redux/store";
4947
import { cancelStream } from "../../redux/thunks/cancelStream";
5048
import { exitEditMode } from "../../redux/thunks/exitEditMode";
5149
import { loadLastSession } from "../../redux/thunks/session";
@@ -116,9 +114,7 @@ export function Chat() {
116114
(state) => state.config.config.ui?.showChatScrollbar,
117115
);
118116
const codeToEdit = useAppSelector((state) => state.session.codeToEdit);
119-
const toolCallState = useSelector<RootState, ToolCallState | undefined>(
120-
selectCurrentToolCall,
121-
);
117+
const toolCallState = useAppSelector(selectCurrentToolCall);
122118
const applyStates = useAppSelector(
123119
(state) => state.session.codeBlockApplyStates.states,
124120
);
@@ -163,6 +159,11 @@ export function Chat() {
163159
index?: number,
164160
editorToClearOnSend?: Editor,
165161
) => {
162+
if (toolCallState?.status === "generated") {
163+
return console.error(
164+
"Cannot submit message while awaiting tool confirmation",
165+
);
166+
}
166167
if (defaultModel?.provider === "free-trial") {
167168
const newCount = incrementFreeTrialCount();
168169

@@ -226,6 +227,7 @@ export function Chat() {
226227
streamResponse,
227228
isSingleRangeEditOrInsertion,
228229
codeToEdit,
230+
toolCallState,
229231
],
230232
);
231233

0 commit comments

Comments
 (0)