terminal: lembas run --terminal-context end to end; the publisher's session reset said plainly

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-12-01 19:30:27 +00:00
1 parent 07f4d9715e
commit 743d64cebb
2 files changed
+22 -2

No files matched your search

+4 -2
View File
@@ -94,8 +94,10 @@ export class StatePublisher {
else if (e.type === "usage" && !e.child) {
this.used = e.used ?? e.usage.input + e.usage.output
this.total = e.context
} else if (e.type === "session" || e.type === "compacted") {
if (e.type === "session") (this.used = undefined), (this.total = undefined)
} else if (e.type === "session") {
// Another session: its window is not known yet.
this.used = undefined
this.total = undefined
} else if (e.type === "done") this.phase = null
else if (e.type === "task" && e.state === "end") this.readSpend()
this.schedule()
+18
View File
@@ -587,3 +587,21 @@ test("lembas --version is unchanged; --version --json is one object; run --termi
expect(usage.status).toBe(2)
expect(usage.out).toBe("")
})
test("lembas run --terminal-context: the chip on the screen, the block in the message, the file gone", async () => {
const dir = setup([{ chunks: [delta({ content: "It failed in the oven test." }, "stop"), usage(50, 5)] }])
const f = contextFile()
const { LLEMBAS_TTY_PANE: _b, LLEMBAS_TTY_EXECUTABLE: _c, TMUX: _t, ...rest } = process.env
const p = Bun.spawn(["bun", join(import.meta.dir, "..", "src", "cli.ts"), "run", "--no-store", "--terminal-context", f, "why did it fail?"], { cwd: dir, env: { ...rest, LLEMBAS_TTY: "1.0.0" } as Record<string, string>, stdin: "ignore", stdout: "pipe", stderr: "pipe" })
const [out, err, status] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
expect({ status, err: err.includes("terminal context: 1 command from pane 7") }).toEqual({ status: 0, err: true })
expect(out + err).toContain("It failed in the oven test.")
// The content is in the message, never on the screen.
expect(out + err).not.toContain("FAIL src/oven.test.ts")
const sent = fake!.requests.find((r) => JSON.stringify(r.messages).includes("why did it fail?"))!
expect(JSON.stringify(sent.messages.at(-1))).toContain("<terminal>\\nWhat the person's terminal showed when they sent this (pane 7).")
expect(JSON.stringify(sent.messages.at(-1))).toContain("FAIL src/oven.test.ts")
// No program was named: the tools are in no list.
expect(names(sent)).not.toContain("terminal_run")
expect(existsSync(f)).toBe(false)
})