chore: checkpoint turso and ai runtime work

This commit is contained in:
Agent Board
2026-07-03 23:20:16 +08:00
parent a75b3d11f9
commit 36d027a4a1
67 changed files with 4224 additions and 914 deletions
@@ -122,9 +122,17 @@ async function main() {
window.EventSource = FakeEventSource;
window.__mnoteTask540EventSources = sources;
window.__mnoteTask540CompatEvents = [];
window.__mnoteTask540FileChangeBatches = [];
window.__mnoteTask540FileChangeReactions = [];
window.addEventListener("tree:local-folder-watch-batch", (event) => {
window.__mnoteTask540CompatEvents.push(event.detail || {});
});
window.addEventListener("mnote:file-change-batch", (event) => {
window.__mnoteTask540FileChangeBatches.push(event.detail || {});
});
window.addEventListener("mnote:file-change-reaction", (event) => {
window.__mnoteTask540FileChangeReactions.push(event.detail || {});
});
});
const page = await context.newPage();
@@ -203,7 +211,7 @@ async function main() {
window.__mnoteTask540FileProjectionRequests = [];
window.__mnoteTask540SidebarProjectionRequests = [];
});
await page.evaluate(({ rootUriValue, pagePath, assetPath }) => {
await page.evaluate(({ rootUriValue, workspaceIdValue, pagePath, assetPath }) => {
const detail = {
source: "synthetic_page_ai_receipt",
reason: "agent_run_receipt",
@@ -214,15 +222,37 @@ async function main() {
rootUri: rootUriValue,
revision: "task540-revision",
changedPaths: [
{ relativePath: pagePath, changeType: "modified" },
{
relativePath: pagePath,
documentId: `local-md:${pagePath.replaceAll("/", "~2F")}`,
changeType: "modified",
eventKind: "Modify(Data(Content))",
observedFileVersion: "sha256:task540-observed",
bufferFileVersion: "sha256:task540-buffer",
selfWriteEcho: false,
},
{ relativePath: assetPath, changeType: "modified" },
],
affectedParents: [{ relativePath: "", reason: "task540" }],
},
};
window.__mnoteLocalFolderEventBus.emitSyntheticWatchBatch(detail);
window.__mnoteLocalFolderEventBus.emitSyntheticWatchBatch(detail);
}, { rootUriValue: rootUri, pagePath: relativePath, assetPath: resourcePath });
window.__mnoteLocalFolderEventBus.emitChangedFiles({
source: detail.source,
reason: detail.reason,
rootUri: rootUriValue,
workspaceId: workspaceIdValue,
changedFiles: detail.payload.changedPaths,
affectedParents: detail.payload.affectedParents,
});
window.__mnoteLocalFolderEventBus.emitChangedFiles({
source: detail.source,
reason: detail.reason,
rootUri: rootUriValue,
workspaceId: workspaceIdValue,
changedFiles: detail.payload.changedPaths,
affectedParents: detail.payload.affectedParents,
});
}, { rootUriValue: rootUri, workspaceIdValue: workspaceId, pagePath: relativePath, assetPath: resourcePath });
await page.waitForFunction(() => {
const events = window.__mnoteTask540CompatEvents || [];
@@ -251,6 +281,14 @@ async function main() {
lastReason: document.documentElement.getAttribute("data-mnote-local-folder-event-bus-last-reason") || "",
compatEventCount: compatEvents.length,
lastCompatViaEventBus: Boolean(compatEvents.at(-1)?.viaEventBus),
fileChangeService: document.documentElement.getAttribute("data-mnote-file-change-service") || "",
fileChangeSchema: document.documentElement.getAttribute("data-mnote-file-change-service-last-schema") || "",
fileChangeCount: document.documentElement.getAttribute("data-mnote-file-change-service-last-count") || "",
fileChangeDroppedCount: document.documentElement.getAttribute("data-mnote-file-change-service-dropped-count") || "",
fileChangeLastReaction: document.documentElement.getAttribute("data-mnote-file-change-service-last-reaction") || "",
fileChangeBatchCount: (window.__mnoteTask540FileChangeBatches || []).length,
fileChangeReactionTypes: (window.__mnoteTask540FileChangeReactions || []).map((event) => event.type),
lastFileChangeBatch: (window.__mnoteTask540FileChangeBatches || []).at(-1) || null,
hasPageAiSyntheticCompatEvent: compatEvents.some((event) => (
event?.source === "synthetic_page_ai_receipt"
&& event?.reason === "agent_run_receipt"
@@ -268,6 +306,30 @@ async function main() {
assert.equal(result.connectionCount, "1", "event bus diagnostics connectionCount 应为 1");
assert.equal(result.hasPageAiSyntheticCompatEvent, true, "Page AI synthetic 事件应保留 source/reason 并通过 bus 派发兼容事件");
assert.equal(result.lastCompatViaEventBus, true, "兼容 tree:local-folder-watch-batch 必须标记 viaEventBus");
assert.equal(result.fileChangeService, "ready", "FileChangeService diagnostics 未 ready");
assert.equal(typeof result.lastFileChangeBatch, "object", "应暴露标准 FileChange batch");
assert.equal(result.fileChangeSchema, "mnote.file_change_batch.v1", "应生成标准 FileChange batch");
assert.equal(result.fileChangeCount, "2", "同 tick 两个 changed path 应进入同一个 FileChange batch");
assert.equal(result.fileChangeDroppedCount, "0", "rootUri 内 changed path 不应被丢弃");
assert.equal(result.fileChangeBatchCount, 1, "同 tick 两个 receipt 应合并成一次标准 FileChange batch");
assert(
result.fileChangeReactionTypes.includes("refresh_current_document"),
`当前 Markdown 应生成 refresh_current_document reaction: ${JSON.stringify(result.fileChangeReactionTypes)}`,
);
assert(
result.fileChangeReactionTypes.includes("refresh_resource_tab"),
`资源文件应生成 refresh_resource_tab reaction: ${JSON.stringify(result.fileChangeReactionTypes)}`,
);
assert.equal(
result.lastFileChangeBatch?.changes?.[0]?.observedFileVersion,
"sha256:task540-observed",
"FileChange batch 应保留 observedFileVersion",
);
assert.equal(
result.lastFileChangeBatch?.changes?.[0]?.selfWriteEcho,
false,
"FileChange batch 应保留 selfWriteEcho",
);
assert.equal(result.resourceWatchReady, "event-bus", "resource tab watch 应通过 event bus 准备好");
assert(
result.browserStatRequests.some((url) => String(url).includes(encodeURIComponent(resourcePath)) || String(url).includes(resourcePath)),