From 5834d2df1b5d7e1b8a20524d3d48bc03f7d889a2 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Wed, 25 Feb 2026 22:29:27 +0000 Subject: [PATCH] fix(ui): use v2 message info and show model variant --- .../instance/shell/right-panel/RightPanel.tsx | 2 +- .../instance/shell/right-panel/tabs/StatusTab.tsx | 2 +- .../instance/shell/useInstanceSessionContext.ts | 2 +- packages/ui/src/components/message-block.tsx | 8 ++++---- packages/ui/src/components/message-item.tsx | 14 +++++++++++--- packages/ui/src/components/tool-call.tsx | 2 +- .../ui/src/components/tool-call/diagnostics.ts | 2 +- .../src/components/tool-call/markdown-render.tsx | 2 +- .../ui/src/components/tool-call/question-block.tsx | 2 +- .../ui/src/components/tool-call/renderers/task.tsx | 2 +- .../ui/src/components/tool-call/renderers/todo.tsx | 2 +- packages/ui/src/components/tool-call/tool-title.ts | 2 +- packages/ui/src/components/tool-call/types.ts | 2 +- packages/ui/src/components/tool-call/utils.ts | 8 ++++---- packages/ui/src/types/message.ts | 8 +++++--- 15 files changed, 35 insertions(+), 25 deletions(-) diff --git a/packages/ui/src/components/instance/shell/right-panel/RightPanel.tsx b/packages/ui/src/components/instance/shell/right-panel/RightPanel.tsx index fc0e58aa..a4168973 100644 --- a/packages/ui/src/components/instance/shell/right-panel/RightPanel.tsx +++ b/packages/ui/src/components/instance/shell/right-panel/RightPanel.tsx @@ -7,7 +7,7 @@ import { type Accessor, type Component, } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { FileContent, FileNode, File as GitFileStatus } from "@opencode-ai/sdk/v2/client" import IconButton from "@suid/material/IconButton" import MenuOpenIcon from "@suid/icons-material/MenuOpen" diff --git a/packages/ui/src/components/instance/shell/right-panel/tabs/StatusTab.tsx b/packages/ui/src/components/instance/shell/right-panel/tabs/StatusTab.tsx index e6839af6..b52c16d9 100644 --- a/packages/ui/src/components/instance/shell/right-panel/tabs/StatusTab.tsx +++ b/packages/ui/src/components/instance/shell/right-panel/tabs/StatusTab.tsx @@ -1,5 +1,5 @@ import { For, Show, type Accessor, type Component } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import { Accordion } from "@kobalte/core" import { Tooltip } from "@kobalte/core/tooltip" diff --git a/packages/ui/src/components/instance/shell/useInstanceSessionContext.ts b/packages/ui/src/components/instance/shell/useInstanceSessionContext.ts index faee193a..5eb98bf2 100644 --- a/packages/ui/src/components/instance/shell/useInstanceSessionContext.ts +++ b/packages/ui/src/components/instance/shell/useInstanceSessionContext.ts @@ -1,5 +1,5 @@ import { batch, createMemo, type Accessor } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { Session } from "../../../types/session" import { activeParentSessionId, diff --git a/packages/ui/src/components/message-block.tsx b/packages/ui/src/components/message-block.tsx index 0d485c94..50f9f4b9 100644 --- a/packages/ui/src/components/message-block.tsx +++ b/packages/ui/src/components/message-block.tsx @@ -23,10 +23,10 @@ const TOOL_BORDER_COLOR = "var(--message-tool-border)" type ToolCallPart = Extract -type ToolState = import("@opencode-ai/sdk").ToolState -type ToolStateRunning = import("@opencode-ai/sdk").ToolStateRunning -type ToolStateCompleted = import("@opencode-ai/sdk").ToolStateCompleted -type ToolStateError = import("@opencode-ai/sdk").ToolStateError +type ToolState = import("@opencode-ai/sdk/v2").ToolState +type ToolStateRunning = import("@opencode-ai/sdk/v2").ToolStateRunning +type ToolStateCompleted = import("@opencode-ai/sdk/v2").ToolStateCompleted +type ToolStateError = import("@opencode-ai/sdk/v2").ToolStateError function isToolStateRunning(state: ToolState | undefined): state is ToolStateRunning { return Boolean(state && state.status === "running") diff --git a/packages/ui/src/components/message-item.tsx b/packages/ui/src/components/message-item.tsx index 719d660d..f968858a 100644 --- a/packages/ui/src/components/message-item.tsx +++ b/packages/ui/src/components/message-item.tsx @@ -1,6 +1,6 @@ import { For, Show, createSignal } from "solid-js" import { Copy, ExternalLink, Split, Trash2, Undo } from "lucide-solid" -import type { MessageInfo, ClientPart } from "../types/message" +import type { MessageInfo, ClientPart, SDKAssistantMessageV2 } from "../types/message" import { partHasRenderableText } from "../types/message" import type { MessageRecord } from "../stores/message-v2/types" import MessagePart from "./message-part" @@ -258,8 +258,16 @@ export default function MessageItem(props: MessageItemProps) { if (!info || info.role !== "assistant") return "" const modelID = info.modelID || "" const providerID = info.providerID || "" - if (modelID && providerID) return `${providerID}/${modelID}` - return modelID + + const base = modelID && providerID ? `${providerID}/${modelID}` : modelID + if (!base) return "" + + const variant = (info as SDKAssistantMessageV2).variant + if (typeof variant === "string" && variant.trim().length > 0) { + return `${base} (${variant.trim()})` + } + + return base } const agentMeta = () => { diff --git a/packages/ui/src/components/tool-call.tsx b/packages/ui/src/components/tool-call.tsx index 5d3af5f5..f0086016 100644 --- a/packages/ui/src/components/tool-call.tsx +++ b/packages/ui/src/components/tool-call.tsx @@ -44,7 +44,7 @@ import { getLogger } from "../lib/logger" const log = getLogger("session") -type ToolState = import("@opencode-ai/sdk").ToolState +type ToolState = import("@opencode-ai/sdk/v2").ToolState const TOOL_CALL_CACHE_SCOPE = "tool-call" const TOOL_SCROLL_SENTINEL_MARGIN_PX = 48 diff --git a/packages/ui/src/components/tool-call/diagnostics.ts b/packages/ui/src/components/tool-call/diagnostics.ts index 4ec94fc3..304e92b8 100644 --- a/packages/ui/src/components/tool-call/diagnostics.ts +++ b/packages/ui/src/components/tool-call/diagnostics.ts @@ -1,4 +1,4 @@ -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import { getRelativePath, isToolStateCompleted, isToolStateError, isToolStateRunning } from "./utils" import { tGlobal } from "../../lib/i18n" diff --git a/packages/ui/src/components/tool-call/markdown-render.tsx b/packages/ui/src/components/tool-call/markdown-render.tsx index c94859db..17142718 100644 --- a/packages/ui/src/components/tool-call/markdown-render.tsx +++ b/packages/ui/src/components/tool-call/markdown-render.tsx @@ -1,5 +1,5 @@ import type { Accessor, JSXElement } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { TextPart } from "../../types/message" import { Markdown } from "../markdown" import type { MarkdownRenderOptions, ToolScrollHelpers } from "./types" diff --git a/packages/ui/src/components/tool-call/question-block.tsx b/packages/ui/src/components/tool-call/question-block.tsx index 75544190..dee5fee9 100644 --- a/packages/ui/src/components/tool-call/question-block.tsx +++ b/packages/ui/src/components/tool-call/question-block.tsx @@ -1,5 +1,5 @@ import { createMemo, Show, For, createEffect, type Accessor } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { QuestionRequest } from "@opencode-ai/sdk/v2" import { useI18n } from "../../lib/i18n" diff --git a/packages/ui/src/components/tool-call/renderers/task.tsx b/packages/ui/src/components/tool-call/renderers/task.tsx index 80659458..1c420f7d 100644 --- a/packages/ui/src/components/tool-call/renderers/task.tsx +++ b/packages/ui/src/components/tool-call/renderers/task.tsx @@ -1,5 +1,5 @@ import { For, Show, createEffect, createMemo, createSignal, untrack } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { ToolRenderer } from "../types" import { ensureMarkdownContent, getDefaultToolAction, getToolIcon, getToolName, readToolStatePayload } from "../utils" import { resolveTitleForTool } from "../tool-title" diff --git a/packages/ui/src/components/tool-call/renderers/todo.tsx b/packages/ui/src/components/tool-call/renderers/todo.tsx index 689cfb90..5169c7ab 100644 --- a/packages/ui/src/components/tool-call/renderers/todo.tsx +++ b/packages/ui/src/components/tool-call/renderers/todo.tsx @@ -1,5 +1,5 @@ import { For, Show } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { ToolRenderer } from "../types" import { readToolStatePayload } from "../utils" import { useI18n, tGlobal } from "../../../lib/i18n" diff --git a/packages/ui/src/components/tool-call/tool-title.ts b/packages/ui/src/components/tool-call/tool-title.ts index 6d2526c5..7385a514 100644 --- a/packages/ui/src/components/tool-call/tool-title.ts +++ b/packages/ui/src/components/tool-call/tool-title.ts @@ -1,4 +1,4 @@ -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { ToolRendererContext, ToolRenderer, ToolCallPart } from "./types" import { getDefaultToolAction, getToolName, isToolStateCompleted, isToolStateRunning } from "./utils" import { enMessages } from "../../lib/i18n/messages/en" diff --git a/packages/ui/src/components/tool-call/types.ts b/packages/ui/src/components/tool-call/types.ts index c3578a07..e0d994de 100644 --- a/packages/ui/src/components/tool-call/types.ts +++ b/packages/ui/src/components/tool-call/types.ts @@ -1,5 +1,5 @@ import type { Accessor, JSXElement } from "solid-js" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { ClientPart } from "../../types/message" export type ToolCallPart = Extract diff --git a/packages/ui/src/components/tool-call/utils.ts b/packages/ui/src/components/tool-call/utils.ts index 993630b8..b0fd38fd 100644 --- a/packages/ui/src/components/tool-call/utils.ts +++ b/packages/ui/src/components/tool-call/utils.ts @@ -1,15 +1,15 @@ import { isRenderableDiffText } from "../../lib/diff-utils" import { getLanguageFromPath } from "../../lib/markdown" -import type { ToolState } from "@opencode-ai/sdk" +import type { ToolState } from "@opencode-ai/sdk/v2" import type { DiffPayload } from "./types" import { getLogger } from "../../lib/logger" import { tGlobal } from "../../lib/i18n" const log = getLogger("session") -export type ToolStateRunning = import("@opencode-ai/sdk").ToolStateRunning -export type ToolStateCompleted = import("@opencode-ai/sdk").ToolStateCompleted -export type ToolStateError = import("@opencode-ai/sdk").ToolStateError +export type ToolStateRunning = import("@opencode-ai/sdk/v2").ToolStateRunning +export type ToolStateCompleted = import("@opencode-ai/sdk/v2").ToolStateCompleted +export type ToolStateError = import("@opencode-ai/sdk/v2").ToolStateError export const diffCapableTools = new Set(["edit", "patch"]) diff --git a/packages/ui/src/types/message.ts b/packages/ui/src/types/message.ts index db964d27..6bca8238 100644 --- a/packages/ui/src/types/message.ts +++ b/packages/ui/src/types/message.ts @@ -1,4 +1,4 @@ -// SDK types +// SDK v2 types import type { EventMessageUpdated as MessageUpdateEvent, EventMessageRemoved as MessageRemovedEvent, @@ -6,7 +6,8 @@ import type { EventMessagePartRemoved as MessagePartRemovedEvent, Part as SDKPart, Message as SDKMessage, -} from "@opencode-ai/sdk" + AssistantMessage as SDKAssistantMessageV2, +} from "@opencode-ai/sdk/v2" import type { PermissionRequestLike } from "./permission" @@ -17,7 +18,8 @@ export type { MessagePartUpdatedEvent, MessagePartRemovedEvent, SDKPart, - SDKMessage + SDKMessage, + SDKAssistantMessageV2, } // Server streaming event: append-only delta updates.