Skip to content

Commit 4a5ec1f

Browse files
author
engineer
committed
fix(ui): align empty abort visibility (anomalyco#17895)
1 parent 50f1dca commit 4a5ec1f

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎packages/ui/src/components/session-turn-state.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { AssistantMessage, Part as PartType } from "@opencode-ai/sdk/v2/client"
22

33
const hidden = new Set(["todowrite", "todoread"])
4+
const shown = new Set(["compaction"])
45

56
export function partState(part: PartType, show: boolean) {
67
if (part.type === "tool") {
@@ -13,7 +14,8 @@ export function partState(part: PartType, show: boolean) {
1314
if (show && part.text?.trim()) return "visible" as const
1415
return
1516
}
16-
return "visible" as const
17+
if (shown.has(part.type)) return "visible" as const
18+
return
1719
}
1820

1921
type AbortErr = Extract<NonNullable<AssistantMessage["error"]>, { name: "MessageAbortedError" }>

‎packages/ui/src/components/session-turn.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ function reasoning(messageID: string, value: string): Part {
4949
} as Part
5050
}
5151

52+
function step(messageID: string): Part {
53+
return {
54+
id: `part_${messageID}_step`,
55+
sessionID: "ses_1",
56+
messageID,
57+
type: "step-start",
58+
} as Part
59+
}
60+
5261
function aborted(source: "server_restart" | "user_cancel" | "client_disconnect" | "timeout" | "unknown") {
5362
return {
5463
name: "MessageAbortedError" as const,
@@ -99,4 +108,16 @@ describe("abortCard", () => {
99108
),
100109
).toEqual(aborted("timeout"))
101110
})
111+
112+
test("ignores non-rendered structural parts when deciding whether to show the abort card", () => {
113+
expect(
114+
abortCard(
115+
[assistant("msg_assistant", aborted("unknown"))],
116+
{
117+
msg_assistant: [step("msg_assistant")],
118+
},
119+
true,
120+
),
121+
).toEqual(aborted("unknown"))
122+
})
102123
})

0 commit comments

Comments
 (0)