Fix model switching between plan/act; enable toggle and model switcher during generation

This commit is contained in:
Saoud Rizwan 2025-01-31 03:08:24 -08:00
parent 6500b7c210
commit 03f07b7626
2 changed files with 10 additions and 4 deletions

View file

@ -564,10 +564,16 @@ export class ClineProvider implements vscode.WebviewViewProvider {
await this.updateGlobalState("lmStudioModelId", newModelId)
break
}
if (this.cline) {
const { apiConfiguration: updatedApiConfiguration } = await this.getState()
this.cline.api = buildApiHandler(updatedApiConfiguration)
}
}
await this.updateGlobalState("chatSettings", message.chatSettings)
await this.postStateToWebview()
// console.log("chatSettings", message.chatSettings)
if (this.cline) {
this.cline.updateChatSettings(message.chatSettings)
if (this.cline.isAwaitingPlanResponse && didSwitchToActMode) {

View file

@ -597,7 +597,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
}, [apiConfiguration, openRouterModels])
const onModeToggle = useCallback(() => {
if (textAreaDisabled) return
// if (textAreaDisabled) return
let changeModeDelay = 0
if (showModelSelector) {
// user has model selector open, so we should save it before switching modes
@ -617,7 +617,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
textAreaRef.current?.focus()
}, 100)
}, changeModeDelay)
}, [chatSettings.mode, textAreaDisabled, showModelSelector, submitApiConfig])
}, [chatSettings.mode, showModelSelector, submitApiConfig])
const handleContextButtonClick = useCallback(() => {
if (textAreaDisabled) return
@ -1038,7 +1038,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
<ModelDisplayButton
role="button"
isActive={showModelSelector}
disabled={textAreaDisabled}
disabled={false}
onClick={handleModelButtonClick}
// onKeyDown={(e) => {
// if (e.key === "Enter" || e.key === " ") {
@ -1068,7 +1068,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
</ModelContainer>
</ButtonGroup>
<SwitchContainer data-testid="mode-switch" disabled={textAreaDisabled} onClick={onModeToggle}>
<SwitchContainer data-testid="mode-switch" disabled={false} onClick={onModeToggle}>
<Slider isAct={chatSettings.mode === "act"} isPlan={chatSettings.mode === "plan"} />
<SwitchOption isActive={chatSettings.mode === "plan"}>Plan</SwitchOption>
<SwitchOption isActive={chatSettings.mode === "act"}>Act</SwitchOption>