From a909cf97e65a1ff4665d02c55090098231f6ff27 Mon Sep 17 00:00:00 2001 From: Gabrielle Oliveira Date: Tue, 13 Oct 2026 22:38:36 -0300 Subject: [PATCH] refactor(pi): remove the unused queue and pending approval reads Nothing in src called workspace.queue() or workspace.pendingApprovals(). Only their own test did. The session view gets approvals and queued messages from the bootstrap snapshot and live frames. --- src/workspace/api.ts | 27 --------------------------- src/workspace/schema.ts | 9 --------- tests/workspace/api.test.ts | 6 +----- tests/workspace/fixture.ts | 21 +-------------------- 4 files changed, 2 insertions(+), 61 deletions(-) diff --git a/src/workspace/api.ts b/src/workspace/api.ts index d21547d..0e3d665 100644 --- a/src/workspace/api.ts +++ b/src/workspace/api.ts @@ -25,10 +25,8 @@ import { memberSchema, modelCatalogSchema, type ProviderFamily, - pendingApprovalsSchema, preferencesSchema, providerAvailabilitySchema, - queueSchema, runnableFamilies, type SessionDraft, type SessionInput, @@ -369,31 +367,6 @@ export class WorkspaceClient { ); } - /** Messages waiting for their turn, in queue order. */ - async queue( - sessionId: string, - signal?: AbortSignal, - ): Promise { - const queue = await this.read( - `/api/sessions/${encodeURIComponent(sessionId)}/queue`, - queueSchema, - signal, - ); - return queue.messages; - } - - async pendingApprovals( - sessionId: string, - signal?: AbortSignal, - ): Promise { - const pending = await this.read( - `/api/sessions/${encodeURIComponent(sessionId)}/pending-approvals`, - pendingApprovalsSchema, - signal, - ); - return pending.invocations; - } - async decide( invocationId: string, decision: Decision, diff --git a/src/workspace/schema.ts b/src/workspace/schema.ts index 1f67cef..6997161 100644 --- a/src/workspace/schema.ts +++ b/src/workspace/schema.ts @@ -245,15 +245,6 @@ export const historyPageSchema = z.object({ export type HistoryPage = z.infer; -export const queueSchema = z.object({ - queuedCount: z.number(), - messages: z.array(inputSchema), -}); - -export const pendingApprovalsSchema = z.object({ - invocations: z.array(invocationSchema), -}); - export const modelSchema = z.object({ id: z.string(), label: z.string(), diff --git a/tests/workspace/api.test.ts b/tests/workspace/api.test.ts index ff2f8f1..56c371d 100644 --- a/tests/workspace/api.test.ts +++ b/tests/workspace/api.test.ts @@ -220,14 +220,11 @@ test("archive and restore wait for Leverage to apply them, and report a refusal" await rejects(readOnly.archive(SESSION, signal), /Only writers/); }); -test("reads approvals, the queue and the model catalog, and sends a decision", async () => { +test("reads the model catalog and sends a decision", async () => { const f = fixture(); const api = f.client(); const pending = invocation(); f.approvals.push(pending); - expect((await api.pendingApprovals(SESSION)).map((one) => one.id)).toEqual([ - pending.id, - ]); const decided = await api.decide(pending.id, { action: "approve", approvalScope: "session", @@ -237,7 +234,6 @@ test("reads approvals, the queue and the model catalog, and sends a decision", a action: "approve", approvalScope: "session", }); - expect(await api.queue(SESSION)).toEqual([]); expect((await api.models()).map((one) => one.id)).toEqual(["hosted-model"]); }); diff --git a/tests/workspace/fixture.ts b/tests/workspace/fixture.ts index d6df1fd..8e1699f 100644 --- a/tests/workspace/fixture.ts +++ b/tests/workspace/fixture.ts @@ -163,7 +163,6 @@ export function workspaceFixture(extra?: Extra) { "logs/run.txt": "run 1 ok", } as Record, nativeMessages: [] as SessionInput[], - queue: [] as SessionInput[], catalog: [hostedModel] as HostedModel[], preferences: {} as Record, }; @@ -331,14 +330,6 @@ export function workspaceFixture(extra?: Extra) { oldestTranscriptSeq: page[0]?.transcriptSeq ?? null, }); } - if (path.endsWith("/queue")) { - return Response.json({ - sessionId: id, - queuedCount: state.queue.length, - queueHold: null, - messages: state.queue, - }); - } if (path.endsWith("/files/resources")) { return Response.json({ basis: "active_runtime", @@ -474,13 +465,6 @@ export function workspaceFixture(extra?: Extra) { ], }); } - if (path.endsWith("/pending-approvals")) { - return Response.json({ - invocations: approvals.filter( - (one) => one.state === "pending_approval", - ), - }); - } if (path.endsWith("/read")) { return Response.json({ readState: {} }); } @@ -633,10 +617,7 @@ export function workspaceFixture(extra?: Extra) { // Taking a message back withdraws it, which empties the inbox. case "session.queue.cancel": { const uuid = String(frame.uuid); - const taken = [...state.queue, ...state.nativeMessages].find( - (one) => one.uuid === uuid, - ); - state.queue = state.queue.filter((one) => one.uuid !== uuid); + const taken = state.nativeMessages.find((one) => one.uuid === uuid); state.nativeMessages = state.nativeMessages.filter( (one) => one.uuid !== uuid, );