fix(collab): surface remote transcript errors after rows

This commit is contained in:
can1357
2026-07-01 21:15:50 +02:00
parent 6019be42c5
commit 3364c3c6fd
2 changed files with 42 additions and 1 deletions
@@ -548,7 +548,11 @@ export class AgentTranscriptViewer implements Component {
const headerLines = this.#headerLines(ref?.status, ref?.kind, ref?.parentId);
const footerLines = this.#footerLines();
const noticeLine = this.#notice ? ` ${theme.fg("error", this.#notice)}` : undefined;
const noticeLine = this.#notice
? ` ${theme.fg("error", this.#notice)}`
: this.#remoteError && !this.#builder.isEmpty
? ` ${theme.fg("error", this.#remoteError)}`
: undefined;
const editorLines = this.#editor ? this.#editor.render(innerWidth) : [];
// Chrome: top border + header rows + divider border + (notice) + editor + footer + bottom border.
@@ -396,6 +396,43 @@ describe("AgentTranscriptViewer", () => {
}
});
it("surfaces an oversized remote transcript error after existing rows", async () => {
const header = `${JSON.stringify({
type: "session",
version: CURRENT_SESSION_VERSION,
id: "adv",
timestamp: TS,
cwd: "/tmp",
})}\n`;
const before = `${header}${messageLine("a0", "BEFORE_OVERSIZED")}\n`;
const beforeSize = Buffer.byteLength(before, "utf-8");
const error = "transcript entry exceeds transcript fetch cap (4194304 bytes)";
const calls: number[] = [];
const remote: AgentHubRemote = {
chat: () => {},
kill: () => {},
revive: () => {},
readTranscript: async (_id: string, fromByte: number) => {
calls.push(fromByte);
if (fromByte === 0) return { text: before, newSize: beforeSize };
return { text: "", newSize: fromByte, error };
},
};
const viewer = makeViewer("", remote);
try {
await Bun.sleep(650);
const body = viewer
.render(80)
.map(l => Bun.stripANSI(l))
.join("\n");
expect(body).toContain("BEFORE_OVERSIZED");
expect(body).toContain(error);
expect(calls.filter(offset => offset === beforeSize).length).toBe(1);
} finally {
viewer.dispose();
}
});
it("drops stale rendered rows when the host transcript rotates", async () => {
const header = `${JSON.stringify({
type: "session",