mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
* fix(coding-agent): guard tree navigation during responses * fix(coding-agent): simplify tree navigation regression * fix(coding-agent): abort active run on session replacement and tree navigation Session replacement (resume, new, fork, import) now settles the active response in teardownCurrent before disposing the outgoing session, so the aborted turn and its tool results persist instead of leaving a dangling tool call. Tree navigation aborts the active response directly once the user commits, without a confirmation gate.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { fauxAssistantMessage } from "@earendil-works/pi-ai";
|
|
import { describe, expect, it } from "vitest";
|
|
import { userMsg } from "../../utilities.ts";
|
|
import { createHarness } from "../harness.ts";
|
|
|
|
describe("tree navigation during an active response", () => {
|
|
it("rejects navigation without changing the active leaf", async () => {
|
|
const harness = await createHarness();
|
|
const targetId = harness.sessionManager.appendMessage(userMsg("first"));
|
|
let navigationResult: unknown;
|
|
let leafUnchanged = false;
|
|
|
|
try {
|
|
// Navigate from inside the response factory, while the run is active.
|
|
harness.setResponses([
|
|
async () => {
|
|
const activeLeafId = harness.sessionManager.getLeafId();
|
|
navigationResult = await harness.session
|
|
.navigateTree(targetId, { summarize: false })
|
|
.catch((error) => error);
|
|
leafUnchanged = activeLeafId !== targetId && harness.sessionManager.getLeafId() === activeLeafId;
|
|
return fauxAssistantMessage("response");
|
|
},
|
|
]);
|
|
await harness.session.prompt("second");
|
|
|
|
expect(navigationResult).toEqual(
|
|
new Error("Wait for the current response to finish before navigating the session tree."),
|
|
);
|
|
expect(leafUnchanged).toBe(true);
|
|
} finally {
|
|
harness.cleanup();
|
|
}
|
|
});
|
|
});
|