fix(tui): style interrupted compaction neutrally (#37655)

Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-07-18 13:41:01 -05:00 committed by GitHub
parent 4e56998d3c
commit 0d68b0bb20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 4 deletions

View file

@ -410,7 +410,9 @@ const layer = Layer.effect(
yield* events.publish(SessionEvent.Compaction.Failed, {
sessionID,
reason: "manual",
error: { type: "compaction.failed", message: Cause.pretty(compacted.cause) },
error: Cause.hasInterruptsOnly(compacted.cause)
? { type: "aborted", message: "Compaction cancelled" }
: { type: "compaction.failed", message: Cause.pretty(compacted.cause) },
inputID: unsettled.id,
})
return yield* Effect.failCause(compacted.cause)

View file

@ -1892,6 +1892,35 @@ describe("SessionRunnerLLM", () => {
}),
)
it.effect("records cancelled manual compaction without surfacing an internal failure", () =>
Effect.gen(function* () {
const session = yield* setup
response = reply.text("Earlier answer", "text-manual-interrupt-history")
yield* admit(session, "Earlier question")
yield* session.resume(sessionID)
const streamed = yield* Deferred.make<void>()
const partial = fragmentFixture("text", "text-manual-interrupt-summary", ["Partial summary"])
responseStream = Stream.concat(
Stream.fromIterable(partial.partialEvents),
Stream.fromEffect(Deferred.succeed(streamed, undefined)).pipe(Stream.flatMap(() => Stream.never)),
)
const compaction = yield* session.compact({ sessionID })
const run = yield* session.resume(sessionID).pipe(Effect.forkChild)
yield* Deferred.await(streamed)
yield* session.interrupt(sessionID)
yield* Fiber.await(run)
expect(yield* SessionPending.compaction((yield* Database.Service).db, sessionID)).toBeUndefined()
expect((yield* session.messages({ sessionID })).find((message) => message.id === compaction.id)).toMatchObject({
type: "compaction",
status: "failed",
reason: "manual",
error: { type: "aborted", message: "Compaction cancelled" },
})
}),
)
it.effect("settles an admitted manual compaction when pre-start resolution throws", () =>
Effect.gen(function* () {
const session = yield* setup

View file

@ -1440,9 +1440,10 @@ function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type:
const ctx = use()
const { themeV2, syntax } = useTheme()
const status = () => props.message.status
const text = () => (props.message.status === "failed" ? props.message.error.message : props.message.summary)
const cancelled = () => props.message.status === "failed" && props.message.error.type === "aborted"
const text = () => (props.message.status === "failed" ? (cancelled() ? "" : props.message.error.message) : props.message.summary)
const content = createMemo(() => text().trim())
const color = () => (status() === "failed" ? themeV2.text.feedback.error() : themeV2.text.subdued())
const color = () => (status() === "failed" && !cancelled() ? themeV2.text.feedback.error() : themeV2.text.subdued())
return (
<box>
<box flexDirection="row" alignItems="center">
@ -1454,11 +1455,14 @@ function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type:
<spinner frames={SPINNER_FRAMES} interval={80} color={color()} />
</Show>
</Match>
<Match when={status() === "failed"}>
<Match when={status() === "failed" && !cancelled()}>
<text fg={color()}></text>
</Match>
</Switch>
<text fg={color()}>Compaction</text>
<Show when={cancelled()}>
<text fg={color()}>· cancelled</text>
</Show>
</box>
<box border={["top"]} borderColor={color()} flexGrow={1} />
</box>