fix: restore model activity reasoning stream

This commit is contained in:
User
2026-07-14 15:03:07 +02:00
parent 1b1554b353
commit c7474f3852
11 changed files with 490 additions and 14 deletions
+59
View File
@@ -47,6 +47,65 @@ test("POST /sessions usa i settings (workspace/provider/model/thinking) e crea+a
unlinkSync(modelKey);
});
test("POST /sessions configura Pi con il thinking globale selezionato", async () => {
let configured: any;
const bridge = { onClientEvent: () => {}, emitClientEvent: () => {} };
const runtime = { bridge } as any;
const mgr = {
createFor: () => runtime,
configure: async (_rt: any, options: any) => { configured = options; },
start: () => {},
teardown: () => {},
} as any;
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
mgr,
thtRunner: {
ollamaEnsure: async () => ({ ok: true }),
searchPack: async () => {},
sessionNew: async () => ({ id: "s-thinking" }),
} as any,
getSettings: () => ({ workspace: "psd", provider: "zai", model: "glm-5.2", thinking: "high" }) as any,
});
await app.inject({ method: "POST", url: "/sessions", payload: { question: "q" } });
await new Promise((resolve) => setImmediate(resolve));
expect(configured.thinking).toBe("high");
});
test("POST /sessions/:id/resume configura Pi con il thinking persistito", async () => {
let configured: any;
const bridge = { onClientEvent: () => {}, emitClientEvent: () => {} };
const runtime = { bridge } as any;
const mgr = {
get: () => undefined,
createFor: () => runtime,
configure: async (_rt: any, options: any) => { configured = options; },
start: () => {},
teardown: () => {},
} as any;
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
mgr,
thtRunner: {
ollamaEnsure: async () => ({ ok: true }),
sessionShow: async () => ({
status: "open",
archived: false,
provider: "zai",
model: "glm-5.2",
thinking: "medium",
}),
reopenSession: async () => {},
} as any,
getSettings: () => ({ workspace: "psd", thinking: "low" }) as any,
});
await app.inject({ method: "POST", url: "/sessions/s-thinking/resume" });
await new Promise((resolve) => setImmediate(resolve));
expect(configured.thinking).toBe("medium");
});
test("POST /sessions/:id/response inoltra al bridge (no error)", async () => {
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
thtRunner: {
+14
View File
@@ -28,6 +28,20 @@ test("real Pi message_update (assistantMessageEvent text_delta) becomes a text_d
expect(seen).toHaveLength(1);
});
test("real Pi thinking_delta becomes a dedicated activity_delta to the FE", () => {
const { rpc, fire } = fakeRpc();
const b = new SessionBridge(rpc);
const seen: any[] = [];
b.onClientEvent((e) => seen.push(e));
fire({
type: "message_update",
assistantMessageEvent: { type: "thinking_delta", contentIndex: 0, delta: "Valuto le ambiguità" },
});
expect(seen).toEqual([{ type: "activity_delta", text: "Valuto le ambiguità" }]);
});
test("extension_ui_request nativo (method:input, title=json) diventa ui_request col descriptor ed è il pendente", () => {
const { rpc, fire } = fakeRpc();
const b = new SessionBridge(rpc);