refactor: switch to Switch/Match pattern for assistant message status rendering

This commit is contained in:
Dax Raad
2025-11-19 20:18:04 -05:00
parent 52fe1a5ac5
commit 61007a9b94

View File

@@ -982,7 +982,8 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
<text fg={theme.textMuted}>{props.message.error?.data.message}</text>
</box>
</Show>
<Show when={props.last && status().type !== "idle"}>
<Switch>
<Match when={props.last && status().type !== "idle"}>
<box paddingLeft={3} flexDirection="row" gap={1} marginTop={1}>
<text fg={local.agent.color(props.message.mode)}>{Locale.titlecase(props.message.mode)}</text>
<Shimmer text={props.message.modelID} color={theme.text} />
@@ -1021,11 +1022,12 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
)
})()}
</box>
</Show>
<Show
</Match>
<Match
when={
props.message.time.completed &&
props.parts.some((item) => item.type === "step-finish" && item.reason !== "tool-calls")
(props.message.time.completed &&
props.parts.some((item) => item.type === "step-finish" && item.reason !== "tool-calls")) ||
props.last
}
>
<box paddingLeft={3}>
@@ -1034,7 +1036,8 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
<span style={{ fg: theme.textMuted }}>{props.message.modelID}</span>
</text>
</box>
</Show>
</Match>
</Switch>
</>
)
}