This commit is contained in:
Deleted user 2026-05-27 10:50:32 +08:00 committed by GitHub
commit bfccfd9e56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 3 deletions

View file

@ -100,11 +100,16 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
} = useExtensionState()
// Find the ID and display text for the currently selected API configuration.
const { currentConfigId, displayName } = useMemo(() => {
const { currentConfigId, displayName, tooltipContent } = useMemo(() => {
const currentConfig = listApiConfigMeta?.find((config) => config.name === currentApiConfigName)
const configName = currentApiConfigName || ""
const modelId = currentConfig?.modelId
return {
currentConfigId: currentConfig?.id || "",
displayName: currentApiConfigName || "", // Use the name directly for display.
displayName: modelId ? `${configName} · ${modelId}` : configName,
tooltipContent: modelId
? `${configName}${currentConfig?.apiProvider ? ` (${currentConfig.apiProvider})` : ""} · ${modelId}`
: configName,
}
}, [listApiConfigMeta, currentApiConfigName])
@ -1309,7 +1314,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
value={currentConfigId}
displayName={displayName}
disabled={selectApiConfigDisabled}
title={t("chat:selectApiConfig")}
title={tooltipContent || t("chat:selectApiConfig")}
onChange={handleApiConfigChange}
triggerClassName="min-w-[28px] text-ellipsis overflow-hidden flex-shrink"
listApiConfigMeta={listApiConfigMeta || []}

View file

@ -1057,6 +1057,39 @@ describe("ChatTextArea", () => {
expect(apiConfigDropdown).toHaveAttribute("disabled")
})
it("should display model ID alongside config name when modelId is available", () => {
;(useExtensionState as ReturnType<typeof vi.fn>).mockReturnValue({
filePaths: [],
openedTabs: [],
taskHistory: [],
cwd: "/test/workspace",
currentApiConfigName: "my-config",
listApiConfigMeta: [
{ id: "cfg1", name: "my-config", apiProvider: "anthropic", modelId: "claude-sonnet-4-20250514" },
],
})
render(<ChatTextArea {...defaultProps} />)
const apiConfigDropdown = getApiConfigDropdown()
expect(apiConfigDropdown).toHaveTextContent("my-config · claude-sonnet-4-20250514")
})
it("should display only config name when modelId is not available", () => {
;(useExtensionState as ReturnType<typeof vi.fn>).mockReturnValue({
filePaths: [],
openedTabs: [],
taskHistory: [],
cwd: "/test/workspace",
currentApiConfigName: "my-config",
listApiConfigMeta: [{ id: "cfg1", name: "my-config" }],
})
render(<ChatTextArea {...defaultProps} />)
const apiConfigDropdown = getApiConfigDropdown()
expect(apiConfigDropdown).toHaveTextContent("my-config")
expect(apiConfigDropdown).not.toHaveTextContent("·")
})
describe("enter key behavior", () => {
it("should send on Enter and allow newline on Shift+Enter in default mode", () => {
const onSend = vi.fn()