fix: filter codex subthreads during auto import

This commit is contained in:
kris
2026-03-30 14:25:25 +08:00
parent 03ac40f427
commit 40861c63da
7 changed files with 145 additions and 6 deletions

View File

@@ -537,7 +537,7 @@ test("existing bound production devices auto-sync suggested candidates into conv
assert.equal(payload.importDraft?.status, "applied");
assert.equal(payload.importDraft?.selectedCandidateIds.length, 2);
const nextState = await readState();
let nextState = await readState();
const yuandiProject = nextState.projects.find(
(project) => project.threadMeta.codexThreadRef === "session-yuandi-1",
);
@@ -551,4 +551,50 @@ test("existing bound production devices auto-sync suggested candidates into conv
const device = nextState.devices.find((item) => item.id === "mac-studio");
assert.deepEqual(device?.projects, ["yuandi", "wenshenapp"]);
const followupHeartbeat = await deviceHeartbeatRoute(
new NextRequest("http://127.0.0.1:3000/api/device-heartbeat", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
deviceId: "mac-studio",
token: "boss-mac-studio-token",
name: "Mac Studio",
avatar: "M",
account: "17600003315",
status: "online",
quota5h: 68,
quota7d: 81,
projects: ["Boss 移动控制台", "硬件审计协作"],
endpoint: "mac://kris.local",
projectCandidates: [
{
folderName: "yuandi",
folderRef: "/Users/kris/code/yuandi",
threadId: "session-yuandi-1",
threadDisplayName: "Epicurus",
codexFolderRef: "/Users/kris/code/yuandi",
codexThreadRef: "session-yuandi-1",
lastActiveAt: "2026-03-30T12:55:56+08:00",
suggestedImport: true,
},
],
}),
}),
);
assert.equal(followupHeartbeat.status, 200);
nextState = await readState();
const remainingYuandi = nextState.projects.find(
(project) => project.threadMeta.codexThreadRef === "session-yuandi-1",
);
const removedWenshen = nextState.projects.find(
(project) => project.threadMeta.codexThreadRef === "session-wenshenapp-1",
);
assert.ok(remainingYuandi, "expected still-selected candidate to stay imported");
assert.equal(removedWenshen, undefined, "auto-sync should prune stale imported threads that disappeared from candidates");
assert.deepEqual(
nextState.devices.find((item) => item.id === "mac-studio")?.projects,
["yuandi"],
);
});