Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
const model = createMemo(() => Model.name(ctx.providers(), props.message.providerID, props.message.modelID))

const final = createMemo(() => {
return props.message.finish && !["tool-calls", "unknown"].includes(props.message.finish)
return props.message.finish && !["tool-calls", "unknown", "other"].includes(props.message.finish)
})

const duration = createMemo(() => {
Expand All @@ -1362,8 +1362,28 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las

const keybind = useKeybind()

const footer = createMemo(
() => props.last || final() || props.message.error?.name === "MessageAbortedError",
)

const visible = createMemo(() => {
if (footer()) return true
if (props.message.error && props.message.error.name !== "MessageAbortedError") return true
for (const part of props.parts) {
if (part.type === "text" && (part as TextPart).text.trim()) return true
if (part.type === "tool" && (ctx.showDetails() || (part as ToolPart).state.status !== "completed")) return true
if (
part.type === "reasoning" &&
ctx.showThinking() &&
(part as ReasoningPart).text.replace("[REDACTED]", "").trim()
)
return true
}
return false
})

return (
<>
<Show when={visible()}>
<For each={props.parts}>
{(part, index) => {
const component = createMemo(() => PART_MAPPING[part.type as keyof typeof PART_MAPPING])
Expand Down Expand Up @@ -1402,7 +1422,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
</box>
</Show>
<Switch>
<Match when={props.last || final() || props.message.error?.name === "MessageAbortedError"}>
<Match when={footer()}>
<box paddingLeft={3}>
<text marginTop={1}>
<span
Expand All @@ -1427,7 +1447,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
</box>
</Match>
</Switch>
</>
</Show>
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the

if (
lastAssistant?.finish &&
!["tool-calls"].includes(lastAssistant.finish) &&
!["tool-calls", "other"].includes(lastAssistant.finish) &&
!hasToolCalls &&
lastUser.id < lastAssistant.id
) {
Expand Down Expand Up @@ -1511,7 +1511,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
return "break" as const
}

const finished = handle.message.finish && !["tool-calls", "unknown"].includes(handle.message.finish)
const finished = handle.message.finish && !["tool-calls", "other"].includes(handle.message.finish)
if (finished && !handle.message.error) {
if (format.type === "json_schema") {
handle.message.error = new MessageV2.StructuredOutputError({
Expand Down
Loading