fix(quick-pane): preserve lifecycle and answer history

This commit is contained in:
2026-08-25 23:08:45 +02:00
parent 1b0b34fad8
commit 4fc9c60ade
8 changed files with 506 additions and 65 deletions
+50 -7
View File
@@ -115,10 +115,7 @@ test("allows a per-command timeout override without serializing it to Pi", async
type: "get_state",
id: initialCommand.id,
});
await assert.rejects(
adapter.send({ type: "get_session_stats" }),
/timed out/,
);
await assert.rejects(adapter.send({ type: "get_session_stats" }), /timed out/);
await adapter.stop();
});
@@ -208,6 +205,49 @@ test("forwards extension responses without replacing Pi's request ID", async ()
await adapter.stop();
});
test("normalizes thinking changes and treats every unknown Pi notification as non-terminal", async () => {
const fixture = createFixture();
const events = [];
const errors = [];
const adapter = startPiRpcAdapter({
cwd: "/workspace/home",
sessionDir: "/workspace/sessions",
spawnProcess: fixture.spawn,
onEvent: (event) => events.push(event),
onError: (error, metadata) => errors.push({ error, metadata }),
});
const thinkingChange = {
type: "thinking_level_changed",
level: "high",
};
fixture.child.stdout.write(`${JSON.stringify(thinkingChange)}\n`);
fixture.child.stdout.write(
`${JSON.stringify({ type: "future_pi_notification", detail: "new" })}\n`,
);
fixture.child.stdout.write(
`${JSON.stringify({ type: "fatal_pi_notification", terminal: true })}\n`,
);
assert.deepEqual(events, [
{
seq: 1,
type: "transcript",
data: { event: thinkingChange },
},
]);
assert.deepEqual(
errors.map(({ error, metadata }) => ({
code: error.code,
terminal: metadata.terminal,
})),
[
{ code: "unsupported_event", terminal: false },
{ code: "unsupported_event", terminal: false },
],
);
await adapter.stop();
});
test("discards a fragmented oversized frame before processing the next frame", async () => {
const fixture = createFixture();
const errors = [];
@@ -217,7 +257,7 @@ test("discards a fragmented oversized frame before processing the next frame", a
sessionDir: "/workspace/sessions",
spawnProcess: fixture.spawn,
maxFrameBytes: 32,
onError: (error) => errors.push(error),
onError: (error, metadata) => errors.push({ error, metadata }),
onEvent: (event) => events.push(event),
});
const oversized = JSON.stringify({
@@ -230,8 +270,11 @@ test("discards a fragmented oversized frame before processing the next frame", a
);
assert.deepEqual(
errors.map((error) => error.code),
["frame_too_large"],
errors.map(({ error, metadata }) => ({
code: error.code,
terminal: metadata?.terminal !== false,
})),
[{ code: "frame_too_large", terminal: true }],
);
assert.deepEqual(events, [
{