Skip to content

Commit 976ce9c

Browse files
committed
fix: setting local state for first tool use set if no models, then user can click and change tool use
1 parent 13a4bb9 commit 976ce9c

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

refact-agent/gui/src/components/ChatForm/ChatControls.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
setAutomaticPatch,
3636
setChatMode,
3737
setEnabledCheckpoints,
38+
setToolUse,
3839
} from "../../features/Chat/Thread";
3940
import { useAppSelector, useAppDispatch, useCapsForToolUse } from "../../hooks";
4041
import { getChatById } from "../../features/History/historySlice";
@@ -355,14 +356,14 @@ export const ChatControls: React.FC<ChatControlsProps> = ({
355356
host,
356357
}) => {
357358
const refs = useTourRefs();
359+
const dispatch = useAppDispatch();
358360
const isStreaming = useAppSelector(selectIsStreaming);
359361
const isWaiting = useAppSelector(selectIsWaiting);
360362
const messages = useAppSelector(selectMessages);
361363
const toolUse = useAppSelector(selectToolUse);
362-
const { handleManualToolUseChange } = useCapsForToolUse();
363364
const onSetToolUse = useCallback(
364-
(value: ToolUse) => handleManualToolUseChange(value),
365-
[handleManualToolUseChange],
365+
(value: ToolUse) => dispatch(setToolUse(value)),
366+
[dispatch],
366367
);
367368

368369
const showControls = useMemo(

refact-agent/gui/src/hooks/useCapsForToolUse.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const PAID_AGENT_LIST = [
2525
];
2626

2727
export function useCapsForToolUse() {
28-
const [wasInteracted, setWasInteracted] = useState(false);
28+
const [wasAdjusted, setWasAdjusted] = useState(false);
2929
const caps = useGetCapsQuery();
3030
const toolUse = useAppSelector(selectThreadToolUse);
3131
const usage = useAgentUsage();
@@ -129,39 +129,31 @@ export function useCapsForToolUse() {
129129
};
130130

131131
const handleAutomaticToolUseChange = () => {
132-
if (!caps.isSuccess || wasInteracted) return;
132+
if (!caps.isSuccess || wasAdjusted) return;
133133

134134
const newToolUse = determineNewToolUse();
135135
if (newToolUse) {
136136
dispatch(setToolUse(newToolUse));
137+
setWasAdjusted(true);
137138
}
138139
};
139140

140141
handleAutomaticToolUseChange();
141142
}, [
142143
dispatch,
143-
wasInteracted,
144+
wasAdjusted,
144145
caps.isSuccess,
145146
toolUse,
146147
modelsSupportingAgent,
147148
modelsSupportingTools,
148149
]);
149150

150-
const handleManualToolUseChange = useCallback(
151-
(newToolUse: ToolUse) => {
152-
setWasInteracted(true);
153-
dispatch(setToolUse(newToolUse));
154-
},
155-
[dispatch],
156-
);
157-
158151
return {
159152
usableModels,
160153
usableModelsForPlan,
161154
currentModel,
162155
setCapModel,
163156
isMultimodalitySupportedForCurrentModel,
164157
loading: !caps.data && (caps.isFetching || caps.isLoading),
165-
handleManualToolUseChange,
166158
};
167159
}

0 commit comments

Comments
 (0)