fix(tui): style interrupted compaction neutrally (#37655)
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
This commit is contained in:
parent
4e56998d3c
commit
0d68b0bb20
3 changed files with 39 additions and 4 deletions
|
|
@ -410,7 +410,9 @@ const layer = Layer.effect(
|
||||||
yield* events.publish(SessionEvent.Compaction.Failed, {
|
yield* events.publish(SessionEvent.Compaction.Failed, {
|
||||||
sessionID,
|
sessionID,
|
||||||
reason: "manual",
|
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,
|
inputID: unsettled.id,
|
||||||
})
|
})
|
||||||
return yield* Effect.failCause(compacted.cause)
|
return yield* Effect.failCause(compacted.cause)
|
||||||
|
|
|
||||||
|
|
@ -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", () =>
|
it.effect("settles an admitted manual compaction when pre-start resolution throws", () =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const session = yield* setup
|
const session = yield* setup
|
||||||
|
|
|
||||||
|
|
@ -1440,9 +1440,10 @@ function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type:
|
||||||
const ctx = use()
|
const ctx = use()
|
||||||
const { themeV2, syntax } = useTheme()
|
const { themeV2, syntax } = useTheme()
|
||||||
const status = () => props.message.status
|
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 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 (
|
return (
|
||||||
<box>
|
<box>
|
||||||
<box flexDirection="row" alignItems="center">
|
<box flexDirection="row" alignItems="center">
|
||||||
|
|
@ -1454,11 +1455,14 @@ function CompactionMessage(props: { message: Extract<SessionMessageInfo, { type:
|
||||||
<spinner frames={SPINNER_FRAMES} interval={80} color={color()} />
|
<spinner frames={SPINNER_FRAMES} interval={80} color={color()} />
|
||||||
</Show>
|
</Show>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={status() === "failed"}>
|
<Match when={status() === "failed" && !cancelled()}>
|
||||||
<text fg={color()}>✗</text>
|
<text fg={color()}>✗</text>
|
||||||
</Match>
|
</Match>
|
||||||
</Switch>
|
</Switch>
|
||||||
<text fg={color()}>Compaction</text>
|
<text fg={color()}>Compaction</text>
|
||||||
|
<Show when={cancelled()}>
|
||||||
|
<text fg={color()}>· cancelled</text>
|
||||||
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
<box border={["top"]} borderColor={color()} flexGrow={1} />
|
<box border={["top"]} borderColor={color()} flexGrow={1} />
|
||||||
</box>
|
</box>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue