fix: migrate legacy boss console state
This commit is contained in:
@@ -2,7 +2,7 @@ import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
|
||||
let runtimeRoot = "";
|
||||
let readState: (typeof import("../src/lib/boss-data"))["readState"];
|
||||
@@ -246,3 +246,71 @@ test("default seeded conversations no longer expose Boss 移动控制台", async
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("readState migrates away persisted legacy boss-console conversations", async () => {
|
||||
await setup();
|
||||
const state = await readState();
|
||||
|
||||
const legacyState = structuredClone(state) as typeof state;
|
||||
legacyState.projects.push({
|
||||
id: "boss-console",
|
||||
name: "Boss 移动控制台",
|
||||
pinned: false,
|
||||
systemPinned: false,
|
||||
deviceIds: ["mac-studio"],
|
||||
preview: "历史遗留的 boss-console 会话。",
|
||||
updatedAt: "2026-04-04T12:20:00+08:00",
|
||||
lastMessageAt: "2026-04-04T12:20:00+08:00",
|
||||
isGroup: false,
|
||||
threadMeta: {
|
||||
projectId: "boss-console",
|
||||
threadId: "thread-boss-console",
|
||||
threadDisplayName: "Boss 移动控制台",
|
||||
folderName: "Boss",
|
||||
activityIconCount: 1,
|
||||
updatedAt: "2026-04-04T12:20:00+08:00",
|
||||
codexThreadRef: "thread-boss-console",
|
||||
codexFolderRef: "boss-console",
|
||||
},
|
||||
groupMembers: [],
|
||||
createdByAgent: true,
|
||||
collaborationMode: "development",
|
||||
approvalState: "not_required",
|
||||
unreadCount: 0,
|
||||
riskLevel: "low",
|
||||
messages: [],
|
||||
goals: [],
|
||||
versions: [],
|
||||
});
|
||||
legacyState.threadContextSnapshots.push({
|
||||
snapshotId: "legacy-boss-console-snapshot",
|
||||
projectId: "boss-console",
|
||||
taskId: "legacy-task",
|
||||
threadId: "thread-boss-console",
|
||||
title: "Boss 移动控制台线程",
|
||||
summary: "遗留摘要",
|
||||
nodeId: "mac-studio",
|
||||
workerId: "worker-legacy",
|
||||
sourceKind: "worker_estimator",
|
||||
status: "running",
|
||||
contextBudgetRemainingPct: 48,
|
||||
contextBudgetLevel: "watch",
|
||||
mustFinishBeforeCompaction: false,
|
||||
estimatedRemainingTurns: 5,
|
||||
estimatedRemainingLargeMessages: 2,
|
||||
compactionCount: 0,
|
||||
patchPending: false,
|
||||
testsPending: false,
|
||||
evidencePending: false,
|
||||
checklist: [],
|
||||
capturedAt: "2026-04-04T12:20:00+08:00",
|
||||
});
|
||||
|
||||
const stateFile = process.env.BOSS_STATE_FILE;
|
||||
assert.ok(stateFile, "expected test state file path");
|
||||
await writeFile(stateFile, JSON.stringify(legacyState, null, 2), "utf8");
|
||||
|
||||
const migratedState = await readState();
|
||||
assert.equal(migratedState.projects.some((item) => item.id === "boss-console"), false);
|
||||
assert.equal(migratedState.threadContextSnapshots.some((item) => item.projectId === "boss-console"), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user