Compare commits

...
Author SHA1 Message Date
Mohamed Boudra 953264a3f9 fix(omp): give unanswered idle notices their own turns
An OMP extension UI notice issued while idle is a complete turn. Give it a fresh ID in the adapter so the existing timeline separates both adjacent executions.
2026-11-18 13:55:04 +01:00
Mohamed Boudra 18b39f195d fix(chat): keep replies visible across idle notices
Mark an OMP extension notice emitted outside a run so it cannot join adjacent turns. The background completion and its reply still carry the same turn ID.
2026-11-18 13:43:06 +01:00
2 changed files with 49 additions and 1 deletions
@@ -1347,6 +1347,51 @@ describe("OMP agent client and session", () => {
expect(omp.timeline().filter((item) => item.type === "assistant_message")).toEqual([]);
});
test("gives each idle extension notice its own turn without starting an execution", async () => {
const runtime = new FakeOmp();
const client = new OmpAgentClient({ logger: createTestLogger(), runtime });
const session = await client.createSession({ provider: "omp", cwd: process.cwd() });
onTestFinished(() => session.close());
const events: AgentStreamEvent[] = [];
session.subscribe((event) => events.push(event));
const turnCompleted = (event: AgentStreamEvent) => event.type === "turn_completed";
const provider = runtime.latestSession();
const notify = (id: string) => {
provider.emit({ type: "extension_ui_request", id, method: "notify", message: id });
};
const { turnId: foregroundTurnId } = await session.startTurn("start background work");
provider.beginTurn();
notify("while working");
provider.streamAssistantText("first reply");
provider.finishTurn();
await expect.poll(() => events.some(turnCompleted)).toBe(true);
const settledEvents = events.length;
notify("idle notice");
notify("another idle notice");
const idleNotices = events.slice(settledEvents);
expect(idleNotices.map(({ type }) => type)).toEqual(["timeline", "timeline"]);
provider.emit({ type: "agent_start" });
provider.beginTurn();
notify("during the autonomous run");
provider.streamAssistantText("second reply");
provider.finishTurn();
const noticeTurnIds = events.flatMap((event) =>
event.type === "timeline" && event.item.type === "notification" ? [event.turnId] : [],
);
expect(noticeTurnIds).toEqual([
foregroundTurnId,
expect.any(String),
expect.any(String),
undefined, // The manager assigns the active autonomous turn ID.
]);
expect(new Set(noticeTurnIds).size).toBe(noticeTurnIds.length);
});
test("maps legacy select options without descriptions and preserves ordinary responses", async () => {
const omp = new OmpHarness();
await omp.start();
@@ -1580,10 +1580,13 @@ export class OmpAgentSession implements AgentSession {
): void {
const message = optionalString(event.message);
if (event.method === "notify" && message) {
// An idle UI notice has no model response. It is a turn of its own.
const turnId =
this.currentTurnIdForEvent() ?? (this.activeTurnStarted ? undefined : randomUUID());
this.emit({
type: "timeline",
provider: this.provider,
turnId: this.currentTurnIdForEvent(),
turnId,
item: {
type: "notification",
level: