From 5d351406a1ed0ac93975dfcff55b7764f159375a Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 5 Aug 2026 14:41:35 +0800 Subject: [PATCH] fix(app): translate legacy question tool IDs --- packages/app/src/utils/server-compat.test.ts | 22 +++++++++++++++++++- packages/app/src/utils/server-compat.ts | 8 ++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/app/src/utils/server-compat.test.ts b/packages/app/src/utils/server-compat.test.ts index 1330f846ec5..63f7d776019 100644 --- a/packages/app/src/utils/server-compat.test.ts +++ b/packages/app/src/utils/server-compat.test.ts @@ -4,7 +4,10 @@ import { createCompatibleApi } from "./server-compat" function setup( protocol: "v1" | "v2" | Promise<"v1" | "v2">, - responses?: { vcs?: { branch: string; default_branch: string } }, + responses?: { + vcs?: { branch: string; default_branch: string } + question?: { id: string; sessionID: string; questions: never[]; tool?: { messageID: string; callID: string } }[] + }, ) { const requests: Request[] = [] const fetcher = Object.assign( @@ -36,6 +39,8 @@ function setup( } if (request.method === "GET" && new URL(request.url).pathname === "/vcs") return Response.json(responses?.vcs ?? {}) + if (request.method === "GET" && new URL(request.url).pathname === "/question") + return Response.json(responses?.question ?? []) if (request.method === "GET") return Response.json([]) return new Response(undefined, { status: 204 }) }, @@ -163,6 +168,21 @@ describe("createCompatibleApi", () => { expect(new URL(requests[0]!.url).pathname).toBe("/experimental/session") }) + test("translates V1 question tool call IDs", async () => { + const { api } = setup("v1", { + question: [ + { + id: "que_1", + sessionID: "ses_1", + questions: [], + tool: { messageID: "msg_1", callID: "call_1" }, + }, + ], + }) + + expect((await api.question.request.list()).data[0]?.tool).toEqual({ messageID: "msg_1", id: "call_1" }) + }) + /* test("projects the V1 default branch", async () => { const { api } = setup("v1", { vcs: { branch: "feature", default_branch: "dev" } }) diff --git a/packages/app/src/utils/server-compat.ts b/packages/app/src/utils/server-compat.ts index 6cb5e6b1a32..30f3b4e0170 100644 --- a/packages/app/src/utils/server-compat.ts +++ b/packages/app/src/utils/server-compat.ts @@ -606,7 +606,13 @@ function createV1Api(input: CompatibleInput): CompatibleApi { request: { ...input.current.question.request, async list(value?: Parameters[0]) { - return located((await legacy(value?.location).question.list()).data ?? [], value?.location) + return located( + ((await legacy(value?.location).question.list()).data ?? []).map((request) => ({ + ...request, + tool: request.tool && { messageID: request.tool.messageID, id: request.tool.callID }, + })), + value?.location, + ) }, }, async reply(value: Parameters[0]) {