From f59c36f6f89ff58a009cda4e1020080716849d1c Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 7 Nov 2025 23:27:28 +0000 Subject: [PATCH] Improve MCP status display and message metadata --- src/components/instance-info.tsx | 89 ++++++++++++++++++++------------ src/components/message-item.tsx | 49 ++++++++++++++++-- 2 files changed, 101 insertions(+), 37 deletions(-) diff --git a/src/components/instance-info.tsx b/src/components/instance-info.tsx index 41bc38fc..3f0e9c02 100644 --- a/src/components/instance-info.tsx +++ b/src/components/instance-info.tsx @@ -6,32 +6,39 @@ interface InstanceInfoProps { compact?: boolean } -function parseMcpStatus(status: unknown): Array<{ name: string; status: "running" | "stopped" | "error" }> { +type ParsedMcpStatus = { + name: string + status: "running" | "stopped" | "error" + error?: string +} + +function parseMcpStatus(status: unknown): ParsedMcpStatus[] { if (!status || typeof status !== "object") return [] - try { - const obj = status as Record - return Object.entries(obj).map(([name, statusValue]) => { - let mappedStatus: "running" | "stopped" | "error" + const result: ParsedMcpStatus[] = [] - if (statusValue === "connected") { - mappedStatus = "running" - } else if (statusValue === "disabled") { - mappedStatus = "stopped" - } else if (statusValue === "failed") { - mappedStatus = "error" - } else { - mappedStatus = "stopped" - } + for (const [name, value] of Object.entries(status as Record)) { + if (!value || typeof value !== "object") continue + const rawStatus = (value as { status?: string }).status + if (!rawStatus) continue - return { - name, - status: mappedStatus, - } + let mappedStatus: ParsedMcpStatus["status"] + if (rawStatus === "connected") { + mappedStatus = "running" + } else if (rawStatus === "failed") { + mappedStatus = "error" + } else { + mappedStatus = "stopped" + } + + result.push({ + name, + status: mappedStatus, + error: typeof (value as { error?: unknown }).error === "string" ? (value as { error?: string }).error : undefined, }) - } catch { - return [] } + + return result } const InstanceInfo: Component = (props) => { @@ -173,19 +180,37 @@ const InstanceInfo: Component = (props) => {
{(server) => ( -
- {server.name} -
- -
- - -
- - -
- +
+
+ {server.name} +
+
+ + { + server.status === "running" + ? "Connected" + : server.status === "error" + ? "Error" + : "Disabled" + } + +
+ + {(error) => ( +
+ {error()} +
+ )} +
)} diff --git a/src/components/message-item.tsx b/src/components/message-item.tsx index 39342e27..9617e256 100644 --- a/src/components/message-item.tsx +++ b/src/components/message-item.tsx @@ -63,13 +63,51 @@ export default function MessageItem(props: MessageItemProps) { isUser() ? "message-item-base bg-[var(--message-user-bg)] border-l-4 border-[var(--message-user-border)]" : "message-item-base assistant-message bg-[var(--message-assistant-bg)] border-l-4 border-[var(--message-assistant-border)]" - + + const agentIdentifier = () => { + if (isUser()) return "" + return ( + props.messageInfo?.agent || + props.messageInfo?.mode || + props.messageInfo?.agentID || + props.messageInfo?.agentId || + props.messageInfo?.metadata?.agentID || + "" + ) + } + + const modelIdentifier = () => { + if (isUser()) return "" + const modelID = + props.messageInfo?.modelID || + props.messageInfo?.modelId || + props.messageInfo?.model?.modelID || + props.messageInfo?.model?.id || + "" + const providerID = + props.messageInfo?.providerID || + props.messageInfo?.providerId || + props.messageInfo?.model?.providerID || + "" + if (modelID && providerID) return `${providerID}/${modelID}` + return modelID + } + return ( +
- - {isUser() ? "You" : "Assistant"} - +
+ + You + + +
+ {(value) => Agent: {value()}} + {(value) => Model: {value()}} +
+
+
{timestamp()} @@ -94,8 +132,9 @@ export default function MessageItem(props: MessageItemProps) {
- +
+
QUEUED