Fix command output not being streamed when auto-approved + model ID under chat field (#1449)

* Fix bug where auto-approving commands would not stream output back to webview

* Fix model id under chat field

* Amend
This commit is contained in:
Saoud Rizwan 2025-01-24 16:33:03 -08:00 committed by GitHub
parent 54ef05f61b
commit a0e7bf60c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 36 deletions

View file

@ -25,13 +25,13 @@ export function combineCommandSequences(messages: ClineMessage[]): ClineMessage[
// First pass: combine commands with their outputs
for (let i = 0; i < messages.length; i++) {
if (messages[i].type === "ask" && (messages[i].ask === "command" || messages[i].say === "command")) {
if (messages[i].ask === "command" || messages[i].say === "command") {
let combinedText = messages[i].text || ""
let didAddOutput = false
let j = i + 1
while (j < messages.length) {
if (messages[j].type === "ask" && (messages[j].ask === "command" || messages[j].say === "command")) {
if (messages[j].ask === "command" || messages[j].say === "command") {
// Stop if we encounter the next command
break
}
@ -63,7 +63,7 @@ export function combineCommandSequences(messages: ClineMessage[]): ClineMessage[
return messages
.filter((msg) => !(msg.ask === "command_output" || msg.say === "command_output"))
.map((msg) => {
if (msg.type === "ask" && (msg.ask === "command" || msg.say === "command")) {
if (msg.ask === "command" || msg.say === "command") {
const combinedCommand = combinedCommands.find((cmd) => cmd.ts === msg.ts)
return combinedCommand || msg
}

View file

@ -3,17 +3,8 @@ import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, us
import DynamicTextArea from "react-textarea-autosize"
import { useClickAway, useWindowSize } from "react-use"
import styled from "styled-components"
import {
anthropicDefaultModelId,
bedrockDefaultModelId,
deepSeekDefaultModelId,
geminiDefaultModelId,
mistralDefaultModelId,
openAiNativeDefaultModelId,
openRouterDefaultModelId,
vertexDefaultModelId,
} from "../../../../src/shared/api"
import { mentionRegex, mentionRegexGlobal } from "../../../../src/shared/context-mentions"
import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage"
import { useExtensionState } from "../../context/ExtensionStateContext"
import {
ContextMenuOptionType,
@ -26,7 +17,7 @@ import { validateApiConfiguration, validateModelId } from "../../utils/validate"
import { vscode } from "../../utils/vscode"
import { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock"
import Thumbnails from "../common/Thumbnails"
import ApiOptions from "../settings/ApiOptions"
import ApiOptions, { normalizeApiConfiguration } from "../settings/ApiOptions"
import { MAX_IMAGES_PER_MESSAGE } from "./ChatView"
import ContextMenu from "./ContextMenu"
@ -686,35 +677,19 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
// Get model display name
const modelDisplayName = useMemo(() => {
const { selectedProvider, selectedModelId } = normalizeApiConfiguration(apiConfiguration)
const unknownModel = "unknown"
if (!apiConfiguration) return unknownModel
switch (apiConfiguration.apiProvider) {
switch (selectedProvider) {
case "anthropic":
return `anthropic:${apiConfiguration.apiModelId || anthropicDefaultModelId}`
case "openai":
return `openai:${apiConfiguration.openAiModelId || unknownModel}`
case "openrouter":
return `openrouter:${apiConfiguration.openRouterModelId || openRouterDefaultModelId}`
case "bedrock":
return `bedrock:${apiConfiguration.apiModelId || bedrockDefaultModelId}`
case "vertex":
return `vertex:${apiConfiguration.apiModelId || vertexDefaultModelId}`
case "ollama":
return `ollama:${apiConfiguration.ollamaModelId || unknownModel}`
case "lmstudio":
return `lmstudio:${apiConfiguration.lmStudioModelId || unknownModel}`
case "gemini":
return `gemini:${apiConfiguration.apiModelId || geminiDefaultModelId}`
case "openai-native":
return `openai-native:${apiConfiguration.apiModelId || openAiNativeDefaultModelId}`
case "deepseek":
return `deepseek:${apiConfiguration.apiModelId || deepSeekDefaultModelId}`
case "mistral":
return `mistral:${apiConfiguration.apiModelId || mistralDefaultModelId}`
return `${selectedProvider}:${selectedModelId}`
case "openai":
return `openai-compat:${selectedModelId}`
case "vscode-lm":
return `vscode-lm:${apiConfiguration.vsCodeLmModelSelector ? `${apiConfiguration.vsCodeLmModelSelector.vendor ?? ""}/${apiConfiguration.vsCodeLmModelSelector.family ?? ""}` : unknownModel}`
default:
return unknownModel
return `${selectedProvider}:${selectedModelId}`
}
}, [apiConfiguration])