Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Restore interrupted CLI process history without replaying work

wyt8ea9d012c617
diff --git a/src/main/features/conversation_history_cache.ts b/src/main/features/conversation_history_cache.ts
index e17911ec..2f35a437 100644
--- a/src/main/features/conversation_history_cache.ts
+++ b/src/main/features/conversation_history_cache.ts
@@ -27,10 +27,11 @@ import { readJson, readJsonlPageWithOffsets, readJsonlWindow, readJsonlWindowAtM
import type { JsonlPage, JsonlRecordWithOffset, JsonlWindow } from '../storage';
import type { GroupMessage } from './group_chat/visibility';
import { normalizeNativeMessageDisplay } from './group_chat/message-display';
+import { restoreInterruptedCliHistory } from './local_agents/interrupted-history';
import { DEFER_PROCESS_ITEMS, PROCESS_PAGE_REBUILD, PROCESS_PAGE_BYTES, processTextChunks, storeProcessPages, processSummary, readProcessPage, processPageReference } from './conversation-process-cache';
const log = createLogger('conversation-history-cache');
-const CACHE_VERSION = 6;
+const CACHE_VERSION = 8;
const MAX_INLINE_PROCESS_OUTPUT_BYTES = 1024;
const MAX_FAILURE_OUTPUT_PREVIEW_CHARS = 600;
const SOURCE_TAIL_FINGERPRINT_BYTES = 4 * 1024;
@@ -121,7 +122,7 @@ function cachePaths(userId: string, sourceFile: string): CachePaths {
entryDir,
// Never parse an older, potentially hundreds-of-megabytes projection just
// to discover its version. A new filename makes invalidation cheap.
- latestPageFile: path.join(entryDir, 'latest-page-v6.json'),
+ latestPageFile: path.join(entryDir, 'latest-page-v8.json'),
toolResultsDir: path.join(entryDir, 'tool-results'),
};
}
@@ -377,8 +378,18 @@ function projectHistoryRecord(userId: string, sourceFile: string, record: GroupM
return projectConversationHistoryRecord(record, toolResultsDir);
}
-function projectHistoryRecords(userId: string, sourceFile: string, records: GroupMessage[]): GroupMessage[] {
- return records.map(record => projectHistoryRecord(userId, sourceFile, record));
+async function projectHistoryRecords(userId: string, sourceFile: string, records: GroupMessage[], before: number | null): Promise<GroupMessage[]> {
+ const projected = records.map(record => projectHistoryRecord(userId, sourceFile, record));
+ return restoreInterruptedProcessRecords(userId, sourceFile, projected, before);
+}
+
+function restoreInterruptedProcessRecords(userId: string, sourceFile: string, projected: GroupMessage[], before: number | null): Promise<GroupMessage[]> {
+ const { entryDir, toolResultsDir } = cachePaths(userId, sourceFile);
+ return restoreInterruptedCliHistory(userId, sourceFile, projected, before, items => {
+ const visible = items.map(item => projectProcessItem(item, toolResultsDir))
+ .filter(item => item !== null) as NonNullable<GroupMessage['process']>;
+ return visible.length ? storeProcessPages(entryDir, visible) : undefined;
+ });
}
export async function readConversationProcessPage(
@@ -520,10 +531,11 @@ async function coldLatestPage(
const startedAt = Date.now();
const page = await readJsonlPageWithOffsets<GroupMessage>(sourceFile, wanted, identity.size);
const readFinishedAt = Date.now();
- const projected = projectHistoryRecords(
+ const projected = await projectHistoryRecords(
userId,
sourceFile,
page.entries.map(({ record }) => record),
+ page.entries[0]?.start ?? null,
);
const projectedAt = Date.now();
const source = await snapshotWithHash(sourceFile, identity);
@@ -567,10 +579,11 @@ async function extendLatestPage(
cached.source.size,
identity.size,
);
- const projected = projectHistoryRecords(
+ const projected = await projectHistoryRecords(
userId,
sourceFile,
appended.map(({ record }) => record),
+ appended[0]?.start ?? null,
);
const capacity = Math.max(wanted, cached.records.length);
const merged = cached.records.concat(
@@ -614,6 +627,8 @@ async function buildLatestPage(
await writeJson(files.latestPageFile, next);
await fsp.rm(path.join(files.entryDir, 'latest-page.json'), { force: true });
await fsp.rm(path.join(files.entryDir, 'latest-page-v5.json'), { force: true });
+ await fsp.rm(path.join(files.entryDir, 'latest-page-v6.json'), { force: true });
+ await fsp.rm(path.join(files.entryDir, 'latest-page-v7.json'), { force: true });
return next;
}
// A message landed while the page was being projected. Keep the valid
@@ -655,10 +670,11 @@ async function latestPage(
// Stabilization/cache failures must not make history unavailable.
const page = await readJsonlPageWithOffsets<GroupMessage>(sourceFile, wanted);
return {
- records: projectHistoryRecords(
+ records: await projectHistoryRecords(
userId,
sourceFile,
page.entries.map(({ record }) => record),
+ page.entries[0]?.start ?? null,
),
nextCursor: page.nextCursor,
};
@@ -681,10 +697,11 @@ export async function readConversationHistoryPage(
}
const page = await readJsonlPageWithOffsets<GroupMessage>(sourceFile, wanted, before ?? undefined);
return {
- records: projectHistoryRecords(
+ records: await projectHistoryRecords(
userId,
sourceFile,
page.entries.map(({ record }) => record),
+ page.entries[0]?.start ?? null,
),
nextCursor: page.nextCursor,
};
@@ -706,8 +723,9 @@ export async function readConversationHistoryWindow(
userId: string, sourceFile: string, start: number, limit = 10, after = 0,
): Promise<JsonlWindow<GroupMessage>> {
if (isMainThread) return historyRequest({ kind: 'window', userId, sourceFile, start, limit, after });
- return readJsonlWindow<GroupMessage>(sourceFile, start, limit,
+ const window = await readJsonlWindow<GroupMessage>(sourceFile, start, limit,
record => projectHistoryRecord(userId, sourceFile, record), after);
+ return { ...window, records: await restoreInterruptedProcessRecords(userId, sourceFile, window.records, window.previousCursor) };
}
/** Project the page holding a message id. The worker finds it and reads the
@@ -716,9 +734,11 @@ export async function readConversationHistoryWindowAtMessage(
userId: string, sourceFile: string, messageId: string, limit = 10,
): Promise<(JsonlWindow<GroupMessage> & { start: number; index: number }) | null> {
if (isMainThread) return historyRequest({ kind: 'window-at-message', userId, sourceFile, messageId, limit });
- return readJsonlWindowAtMatch<GroupMessage>(sourceFile,
+ const window = await readJsonlWindowAtMatch<GroupMessage>(sourceFile,
record => String(record?.id || '') === messageId && !record?.deleted_at, limit,
record => projectHistoryRecord(userId, sourceFile, record));
+ return window ? { ...window,
+ records: await restoreInterruptedProcessRecords(userId, sourceFile, window.records, window.previousCursor) } : null;
}
/** Active turns have no complete disk snapshot yet. Clone one record at a time
diff --git a/src/main/features/file_indexer.ts b/src/main/features/file_indexer.ts
index 110b3078..8c8fa899 100644
--- a/src/main/features/file_indexer.ts
+++ b/src/main/features/file_indexer.ts
@@ -835,7 +835,9 @@ export async function pruneOrphans(
const wsRoot = opts?.workspacePath ? path.resolve(opts.workspacePath) : '';
for (const e of items) {
- if (!e.isDirectory()) continue;
+ // This owner writes only 16-hex extraction entries. Other features share
+ // file_cache (notably local-agent-runs) and own their own retention.
+ if (!e.isDirectory() || !/^[a-f0-9]{16}$/.test(e.name)) continue;
const dir = path.join(root, e.name);
const meta = readMeta(dir);
const reason =
diff --git a/src/main/features/local_agents/interrupted-history.ts b/src/main/features/local_agents/interrupted-history.ts
new file mode 100644
index 00000000..e4ec465a
--- /dev/null
+++ b/src/main/features/local_agents/interrupted-history.ts
@@ -0,0 +1,219 @@
+/** Display-only recovery of an interrupted CLI run. Canonical/model history,
+ * execution status and CLI resumption never depend on this projection. */
+import * as fs from 'node:fs';
+import * as fsp from 'node:fs/promises';
+import * as path from 'node:path';
+import { userLocalAgentRunsDir } from '../../paths';
+import { readJsonlPageWithOffsets } from '../../storage';
+import { redactPaths } from '../../util/redact';
+import { sanitizeLogTextForUpload } from '../../util/log-sanitize';
+import type { GroupMessage } from '../group_chat/visibility';
+import type { HistoryProcessPart } from '../conversation-process-cache';
+import { processTextChunks } from '../conversation-process-cache';
+import { CodexFileCitationStreamFilter } from './public-output';
+
+type Item = NonNullable<GroupMessage['process']>[number];
+type Candidate = { record: GroupMessage; users: Map<string, number>; settled: boolean; invalid: boolean };
+type Run = { directory: string; cid: string; agentId: string; cli: string;
+ startedAt: string; endedAt?: string; durationMs?: number; currentMessageId?: string };
+const MAX_LINE_BYTES = 16 * 1024 * 1024;
+
+async function openRegular(file: string): Promise<fsp.FileHandle> {
+ // O_NOFOLLOW is absent on Windows; lstat rejects links on both platforms.
+ const before = await fsp.lstat(file);
+ if (!before.isFile() || before.isSymbolicLink()) throw new Error('Invalid CLI archive');
+ const handle = await fsp.open(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
+ const after = await handle.stat();
+ if (!after.isFile() || before.dev !== after.dev || before.ino !== after.ino) {
+ await handle.close(); throw new Error('Changed CLI archive');
+ }
+ return handle;
+}
+
+/** Ignore an incomplete crash tail, while keeping each complete line before
+ * it. A damaged oversized line cannot make buffers grow with the whole run. */
+async function* archiveEvents(file: string): AsyncGenerator<Record<string, any>> {
+ const handle = await openRegular(file);
+ const stream = handle.createReadStream({ autoClose: false, highWaterMark: 64 * 1024 });
+ let chunks: Buffer[] = [], bytes = 0, oversized = false;
+ try {
+ for await (const block of stream) {
+ let start = 0;
+ while (start < block.length) {
+ const newline = block.indexOf(10, start);
+ const end = newline < 0 ? block.length : newline;
+ const chunk = block.subarray(start, end);
+ bytes += chunk.length;
+ if (bytes > MAX_LINE_BYTES) { oversized = true; chunks = []; }
+ if (!oversized) chunks.push(chunk);
+ if (newline < 0) break;
+ if (!oversized && bytes) {
+ let event;
+ try { event = JSON.parse(Buffer.concat(chunks, bytes).toString('utf8')); } catch { /* damaged line */ }
+ if (event && typeof event === 'object' && !Array.isArray(event)) yield event;
+ }
+ chunks = []; bytes = 0; oversized = false; start = newline + 1;
+ }
+ }
+ } finally { stream.destroy(); await handle.close(); }
+}
+
+async function archiveRuns(userId: string, cid: string, actors: Set<string>): Promise<Run[]> {
+ const root = userLocalAgentRunsDir(userId);
+ const runs: Run[] = [];
+ let entries;
+ try { entries = await fsp.opendir(root); } catch { return runs; }
+ for await (const entry of entries) {
+ if (!entry.isDirectory() || !/^[a-f0-9]{12}$/.test(entry.name)) continue;
+ const directory = path.join(root, entry.name);
+ let handle;
+ try {
+ handle = await openRegular(path.join(directory, 'meta.json'));
+ if ((await handle.stat()).size > 4 * 1024 * 1024) continue;
+ const meta = JSON.parse(await handle.readFile('utf8'));
+ if (meta.cid !== cid || !actors.has(meta.agentId)
+ || !['codex', 'claude', 'opencode', 'openclaw', 'hermes'].includes(meta.cli)) continue;
+ runs.push({ directory, cid: meta.cid, agentId: meta.agentId, cli: meta.cli,
+ startedAt: meta.startedAt, endedAt: meta.endedAt, durationMs: meta.durationMs,
+ currentMessageId: meta.currentMessageId });
+ } catch { /* Expired or incomplete diagnostic archives are optional. */ }
+ finally { await handle?.close(); }
+ }
+ return runs;
+}
+
+function collectTrigger(record: GroupMessage, candidate: Candidate): void {
+ if (candidate.settled) return;
+ if (record.from === candidate.record.from && (record.system_kind === 'reply_interrupted'
+ || record.source_message_id || record.process?.length || record.process_parts?.length)) {
+ // Official replies/already-saved trails close the preceding attempt.
+ // An async question with no terminal receipt does not end a CLI run.
+ candidate.settled = true;
+ } else if (record.from === 'user') {
+ const ts = Date.parse(record.ts);
+ if (!record.id || !Number.isFinite(ts)) { candidate.invalid = true; candidate.settled = true; }
+ else candidate.users.set(record.id, ts);
+ }
+}
+
+async function recoverRun(run: Run, store: (items: Item[]) => HistoryProcessPart | undefined): Promise<HistoryProcessPart[]> {
+ const parts: HistoryProcessPart[] = [];
+ let batch: Item[] = [];
+ const flush = () => {
+ if (!batch.length) return;
+ const part = store(batch);
+ if (part) parts.push(part);
+ batch = [];
+ };
+ const addText = (text: string) => {
+ // Only explicit public commentary is restored. Unfinished answers remain
+ // absent from the notice body and private reasoning is never replayed.
+ for (const chunk of processTextChunks(text)) {
+ batch.push({ type: 'progress', text: chunk,
+ event: { stream: 'assistant', data: { phase: 'commentary' } } });
+ if (batch.length >= 200) flush();
+ }
+ };
+ const filter = run.cli === 'codex' ? new CodexFileCitationStreamFilter() : null;
+ let commentary = '';
+ const flushText = () => {
+ if (filter) commentary += filter.flush();
+ if (commentary) addText(commentary);
+ commentary = '';
+ };
+ for await (const event of archiveEvents(path.join(run.directory, 'events.jsonl'))) {
+ if (event.type === 'text-delta') {
+ if (event.phase === 'commentary' && typeof event.text === 'string') {
+ commentary += filter ? filter.push(event.text) : event.text;
+ if (commentary.length >= 16 * 1024) { addText(commentary); commentary = ''; }
+ } else flushText();
+ continue;
+ }
+ flushText();
+ if (event.heartbeat === true || event.type === 'idle') continue;
+ if (event.type === 'thinking') {
+ // Old diagnostic archives may predate runner-side raw-thought removal.
+ // A summary already passed the public runner boundary; never copy text.
+ batch.push({ type: 'event', event: { stream: 'cli', data: {
+ type: 'thinking', chars: Number(event.chars) || 0,
+ ...(typeof event.summary === 'string' ? { summary: redactPaths(sanitizeLogTextForUpload(event.summary))
+ .replace(/\s+/g, ' ').trim().slice(0, 2048) } : {}),
+ } } });
+ } else if (['tool-event', 'file-change', 'status', 'permission-request',
+ 'stderr-line', 'raw-line', 'log', 'media-output'].includes(event.type)) {
+ batch.push({ type: 'event', event: { stream: 'cli', data: event } });
+ }
+ if (batch.length >= 200) flush();
+ }
+ flushText(); flush();
+ return parts;
+}
+
+/** `before` names the byte start of this selected page, so a notice whose
+ * trigger is on the previous page does not require a whole-chat scan. */
+export async function restoreInterruptedCliHistory(
+ userId: string, sourceFile: string, records: GroupMessage[], before: number | null,
+ store: (items: Item[]) => HistoryProcessPart | undefined,
+): Promise<GroupMessage[]> {
+ const candidates: Candidate[] = [];
+ for (let index = 0; index < records.length; index++) {
+ const record = records[index];
+ if (record.system_kind !== 'reply_interrupted' || record.deleted_at
+ || record.process?.length || record.process_parts?.length) continue;
+ const candidate: Candidate = { record, users: new Map(), settled: false, invalid: false };
+ for (let n = index - 1; n >= 0 && !candidate.settled; n--) {
+ collectTrigger(records[n], candidate);
+ }
+ candidates.push(candidate);
+ }
+ if (!candidates.length) return records;
+ let cursor = before;
+ while (cursor && candidates.some(candidate => !candidate.settled)) {
+ const page = await readJsonlPageWithOffsets<GroupMessage>(sourceFile, 10, cursor);
+ for (let n = page.entries.length - 1; n >= 0; n--) {
+ for (const candidate of candidates) {
+ collectTrigger(page.entries[n].record, candidate);
+ }
+ }
+ if (page.nextCursor === cursor) break;
+ cursor = page.nextCursor;
+ }
+ if (!candidates.some(candidate => !candidate.invalid && candidate.users.size)) return records;
+ const runs = await archiveRuns(userId, path.basename(sourceFile, '.jsonl'), new Set(candidates.map(c => c.record.from)));
+ const recovered = new Map<string, GroupMessage>();
+ for (const { record, users, invalid } of candidates) {
+ if (invalid || !users.size) continue;
+ const end = Date.parse(record.ts);
+ const earliestUser = Math.min(...users.values());
+ const latestUser = Math.max(...users.values());
+ const matches = runs.filter(run => run.agentId === record.from
+ && Date.parse(run.startedAt) >= (run.currentMessageId ? users.get(run.currentMessageId) ?? Infinity : earliestUser)
+ && Date.parse(run.startedAt) < end
+ && (!run.endedAt || (Date.parse(run.endedAt) >= latestUser && Date.parse(run.endedAt) <= end)));
+ // A legacy archive has no trigger identity. Ambiguity must not show work
+ // from another run as if it belonged to this interrupted reply.
+ if (!matches.length || (matches.length > 1
+ && (matches.some(run => !run.currentMessageId) || new Set(matches.map(run => run.currentMessageId)).size !== 1))) continue;
+ try {
+ const parts: HistoryProcessPart[] = [];
+ for (const run of matches.sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt))) {
+ parts.push(...await recoverRun(run, store));
+ }
+ // A single archived attempt has a defined elapsed time. Prefer its
+ // measured duration; use retained endpoints when both are known. Never
+ // count app downtime up to the later startup notice or invent a terminal
+ // success receipt merely to display the clock.
+ const run = matches.length === 1 ? matches[0] : undefined;
+ const span = run ? Date.parse(run.endedAt || '') - Date.parse(run.startedAt) : NaN;
+ const duration = typeof run?.durationMs === 'number' && Number.isFinite(run.durationMs) && run.durationMs >= 0
+ ? run.durationMs : span;
+ const runtime: Item[] = Number.isFinite(duration) && duration >= 0
+ ? [{ type: 'event', event: { stream: 'runtime', data: { phase: 'interrupted', duration_ms: Math.round(duration) } } }]
+ : [];
+ if (parts.length) recovered.set(record.id, { ...record,
+ ...(runtime.length ? { process: [...(record.process || []), ...runtime] } : {}),
+ process_parts: parts.map(part => 'ref' in part ? { ...part, message_id: record.id } : part) });
+ } catch { /* Missing archive/cache must not hide the interruption notice. */ }
+ }
+ return records.map(record => recovered.get(record.id) || record);
+}
diff --git a/src/main/features/local_agents/persist.ts b/src/main/features/local_agents/persist.ts
index 03679833..bcca3207 100644
--- a/src/main/features/local_agents/persist.ts
+++ b/src/main/features/local_agents/persist.ts
@@ -31,6 +31,8 @@ export interface RunMeta {
runId: string;
agentId: string;
cid: string;
+ /** Exact persisted trigger; optional for archives written by older builds. */
+ currentMessageId?: string;
cli: string;
startedAt: string;
endedAt?: string;
@@ -70,6 +72,7 @@ export async function start(uid: string, init: Omit<RunMeta, 'runId' | 'startedA
runId,
agentId: init.agentId,
cid: init.cid,
+ ...(init.currentMessageId ? { currentMessageId: init.currentMessageId } : {}),
cli: init.cli,
cliPath: init.cliPath,
startedAt: new Date().toISOString(),
diff --git a/src/main/features/local_agents/runner.ts b/src/main/features/local_agents/runner.ts
index 4181713c..8bec53c5 100644
--- a/src/main/features/local_agents/runner.ts
+++ b/src/main/features/local_agents/runner.ts
@@ -1309,6 +1309,7 @@ export async function run(opts: RunCliAgentOpts): Promise<RunCliAgentResult> {
const handle = await persist.start(opts.uid, {
agentId: opts.agentId,
cid: opts.cid,
+ currentMessageId: opts.currentMessageId,
cli: opts.cli,
cliPath: entry.path,
prompt: opts.prompt,
diff --git a/test/e2e/chat_e2e_interrupted_process.spec.ts b/test/e2e/chat_e2e_interrupted_process.spec.ts
new file mode 100644
index 00000000..017eaf36
--- /dev/null
+++ b/test/e2e/chat_e2e_interrupted_process.spec.ts
@@ -0,0 +1,67 @@
+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import path from 'node:path';
+import { expect, test } from './fixtures/orkas';
+
+
+for (const [language, width] of [['en', 1280], ['zh', 760]] as const) {
+ test(`opens archived process details after an application interruption (${language})`, async ({ orkas }, testInfo) => {
+ test.setTimeout(120_000);
+ await orkas.invoke('config.setLanguage', { language });
+ const { conversation } = await orkas.invoke<{ conversation: { conversation_id: string } }>(
+ 'conversations.create', { title: 'Interrupted submission task' });
+ const cid = conversation.conversation_id;
+ const file = path.join(orkas.workspaceRoot, 'account-e2e', 'cloud', 'chats', `${cid}.jsonl`);
+ const notice = language === 'zh'
+ ? '应用退出时,上一次回复被中断。已完成的持久化进度仍会保留,请发送消息继续。'
+ : 'The previous response was interrupted when the app exited. Durable progress was kept; send a message to continue.';
+ writeFileSync(file, [
+ { id: 'user-1', from: 'user', to: ['commander'], ts: '2026-10-17T01:00:00Z', text: 'Continue the submissions.' },
+ { id: 'async-question', from: 'commander', to: ['user'], ts: '2026-10-17T02:02:00Z', text: 'Continue with the original target?' },
+ { id: 'steering-user', from: 'user', to: ['commander'], ts: '2026-10-17T02:47:00Z', text: 'Continue the original target.' },
+ { id: 'interruption-1', from: 'commander', to: ['user'], ts: '2026-10-17T12:14:00Z', text: notice,
+ system_kind: 'reply_interrupted' },
+ ].map(row => JSON.stringify(row)).join('\n') + '\n');
+ const archive = path.join(orkas.workspaceRoot, 'account-e2e', 'local', 'file_cache', 'local-agent-runs', '123456abcdef');
+ mkdirSync(archive, { recursive: true });
+ writeFileSync(path.join(archive, 'meta.json'), JSON.stringify({ runId: '123456abcdef', cid,
+ agentId: 'commander', cli: 'codex', currentMessageId: 'user-1',
+ startedAt: '2026-10-17T01:00:03.973Z', endedAt: '2026-10-17T12:13:55.849Z' }));
+ writeFileSync(path.join(archive, 'events.jsonl'), [
+ { type: 'text-delta', phase: 'commentary', text: 'Checking the saved submission records.' },
+ { type: 'tool-event', phase: 'use', tool: 'bash', callId: 'saved-check', input: { command: 'python submission_queue.py report' } },
+ { type: 'tool-event', phase: 'result', tool: 'bash', callId: 'saved-check', output: 'Confirmed 15 of 50 submissions.' },
+ { type: 'text-delta', phase: 'final_answer', text: 'UNFINISHED ANSWER' },
+ ].map(row => JSON.stringify(row)).join('\n') + '\n');
+ const original = readFileSync(file, 'utf8');
+
+ // Relaunch uses the real history worker, IPC and renderer with an old
+ // interruption row. No model or CLI process is started by viewing history.
+ for (let attempt = 0; attempt < 2; attempt++) {
+ const page = await orkas.relaunch();
+ await page.setViewportSize({ width, height: 800 });
+ await page.locator(`#conversation-list .conv-item[data-cid="${cid}"]`).click();
+ const reply = page.locator('#chat-history .chat-message.assistant[data-system-kind="reply_interrupted"]');
+ await expect(reply).toHaveCount(1);
+ await expect(reply).toContainText(notice);
+ const rail = reply.locator('.stream-process');
+ await expect(rail).toBeVisible();
+ await expect(rail.locator('.stream-process-runtime')).toHaveText(language === 'zh' ? '11小时13分52秒' : '11h 13m 52s');
+ await rail.locator('.stream-process-summary').focus();
+ await page.keyboard.press('Enter');
+ await expect(rail).toHaveAttribute('open', '');
+ await expect(rail).toContainText('Checking the saved submission records.');
+ // Tool operations use the shipped nested disclosure inside the rail.
+ await rail.locator('.stream-process-compact-summary').click();
+ const tool = rail.locator('[data-process-call-id="cli:saved-check"]');
+ await expect(tool).toBeVisible();
+ await expect(tool).toContainText('submission_queue.py report');
+ await tool.press('Enter');
+ await expect(tool).toHaveAttribute('aria-expanded', 'true');
+ await expect(rail).toContainText('Confirmed 15 of 50 submissions.');
+ await expect(reply).not.toContainText('UNFINISHED ANSWER');
+ await expect(page.locator('#chat-send-btn')).not.toHaveClass(/\bstreaming\b/);
+ if (!attempt) await page.screenshot({ path: testInfo.outputPath(`interrupted-process-${language}.png`) });
+ }
+ expect(readFileSync(file, 'utf8')).toBe(original);
+ });
+}
diff --git a/test/main/features/conversation-history-cache.test.ts b/test/main/features/conversation-history-cache.test.ts
index 1d998a15..b43a179c 100644
--- a/test/main/features/conversation-history-cache.test.ts
+++ b/test/main/features/conversation-history-cache.test.ts
@@ -75,6 +75,174 @@ afterEach(async () => {
});
describe('conversation history projection cache', () => {
+ it.each(['timestamps', 'measured', 'missing-end', 'invalid-end'])(
+ 'restores only an evidenced elapsed duration for an interrupted run: %s', async timing => {
+ writeRows([
+ { ...message('user-1'), from: 'user', ts: '2026-10-17T01:00:00Z' },
+ { ...message('interrupted'), from: 'codex-agent', ts: '2026-10-17T12:14:21Z', system_kind: 'reply_interrupted' },
+ ]);
+ const paths = await import('../../../src/main/paths');
+ const run = paths.localAgentRunDir(TEST_UID, '123456abcdef');
+ fs.mkdirSync(run, { recursive: true });
+ fs.writeFileSync(path.join(run, 'meta.json'), JSON.stringify({ runId: '123456abcdef',
+ cid: 'canonical', agentId: 'codex-agent', cli: 'codex', startedAt: '2026-10-17T01:00:03.973Z',
+ ...(timing === 'missing-end' ? {} : { endedAt: timing === 'invalid-end' ? 'invalid' : '2026-10-17T12:13:55.849Z' }),
+ ...(timing === 'measured' ? { durationMs: 40_430_000 } : {}) }));
+ fs.writeFileSync(path.join(run, 'events.jsonl'), JSON.stringify({ type: 'tool-event', phase: 'result', tool: 'bash', callId: 'saved', output: 'Saved work' }) + '\n');
+ const original = fs.readFileSync(sourceFile, 'utf8');
+ const cache = await import('../../../src/main/features/conversation_history_cache');
+ const { records: [record] } = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1);
+ if (timing === 'timestamps' || timing === 'measured') {
+ expect(record.process).toContainEqual({ type: 'event', event: { stream: 'runtime', data: {
+ phase: 'interrupted', duration_ms: timing === 'timestamps' ? 40_431_876 : 40_430_000,
+ } } });
+ expect(record.process_parts?.length).toBe(1);
+ await (await import('../../../src/main/features/conversation-history-client')).closeConversationHistoryWorker();
+ expect((await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1)).records[0].process).toEqual(record.process);
+ } else {
+ expect(record.process?.some(item => item.event?.stream === 'runtime')).not.toBe(true);
+ }
+ expect(record.system_kind).toBe('reply_interrupted');
+ expect(record.process?.some(item => (item.event?.data as any)?.phase === 'end')).not.toBe(true);
+ expect(fs.readFileSync(sourceFile, 'utf8')).toBe(original);
+ });
+
+ it('restores an interrupted CLI trail from its scoped archive across reopen, paging and cache clearing', async () => {
+ const user = { ...message('user-1'), from: 'user', ts: '2026-10-17T01:00:00Z' };
+ const notice = { ...message('interrupted'), from: 'codex-agent', ts: '2026-10-17T12:14:00Z',
+ system_kind: 'reply_interrupted', text: 'The previous reply was interrupted.' };
+ writeRows([user, notice]);
+ const paths = await import('../../../src/main/paths');
+ const run = paths.localAgentRunDir(TEST_UID, '123456abcdef');
+ fs.mkdirSync(run, { recursive: true });
+ fs.writeFileSync(path.join(run, 'meta.json'), JSON.stringify({ runId: '123456abcdef',
+ cid: 'canonical', agentId: 'codex-agent', cli: 'codex', startedAt: '2026-10-17T01:00:01Z' }));
+ const fullOutput = '🌟工具输出\n'.repeat(400);
+ const events = [
+ { type: 'text-delta', phase: 'commentary', text: 'Checking the saved submissions.' },
+ { type: 'thinking', text: 'PRIVATE REASONING', chars: 17, summary: 'Checking progress' },
+ ...Array.from({ length: 20_001 }, (_, n) => ({ type: 'tool-event', phase: 'result', tool: 'bash',
+ callId: `call-${n}`, input: { command: `check ${n}` }, output: n ? `result-${n}` : fullOutput })),
+ { type: 'text-delta', phase: 'final_answer', text: 'UNFINISHED ANSWER' },
+ { type: 'idle', stalledMs: 30_000 },
+ ];
+ fs.writeFileSync(path.join(run, 'events.jsonl'), events.map(e => JSON.stringify(e)).join('\n') + '\n{"type":');
+ const original = fs.readFileSync(sourceFile, 'utf8');
+ const cache = await import('../../../src/main/features/conversation_history_cache');
+ const history = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1);
+ expect(history.records[0]).toMatchObject({ id: notice.id, text: notice.text, system_kind: notice.system_kind });
+ expect(history.records[0].process_parts?.length).toBeGreaterThan(0);
+ expect(Buffer.byteLength(JSON.stringify(history))).toBeLessThan(32 * 1024);
+ const readTrail = async (record: any) => {
+ const items: any[] = [];
+ for (const part of record.process_parts || []) {
+ let cursor: number | null = 0;
+ do {
+ const page = await cache.readConversationProcessPage(TEST_UID, sourceFile, part.ref, cursor!, notice.id);
+ items.push(...page.items); cursor = page.nextCursor;
+ } while (cursor !== null);
+ }
+ return items;
+ };
+ const trail = await readTrail(history.records[0]);
+ expect(trail.filter(item => item.event?.data?.type === 'tool-event').map(item => item.event.data.callId))
+ .toEqual(Array.from({ length: 20_001 }, (_, n) => `call-${n}`));
+ expect(trail[0]).toMatchObject({ type: 'progress', text: events[0].text });
+ const savedResult = trail.find(item => item.event?.data?.callId === 'call-0').event.data;
+ expect(fs.readFileSync(savedResult.outputPath, 'utf8')).toBe(fullOutput);
+ expect(JSON.stringify(trail)).not.toMatch(/PRIVATE REASONING|UNFINISHED ANSWER|stalledMs/);
+ await (await import('../../../src/main/features/conversation-history-client')).closeConversationHistoryWorker();
+ expect((await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1)).records).toEqual(history.records);
+ await cache.purgeConversationHistoryCache(TEST_UID, sourceFile);
+ expect(await readTrail(history.records[0])).toEqual(trail);
+ expect((await cache.readConversationHistoryWindowAtMessage(TEST_UID, sourceFile, notice.id, 1))?.records[0].process_parts?.length)
+ .toBeGreaterThan(0);
+ expect((await cache.readConversationHistoryWindow(TEST_UID, sourceFile, 1, 1)).records[0].process_parts?.length)
+ .toBeGreaterThan(0);
+ expect(fs.readFileSync(sourceFile, 'utf8')).toBe(original);
+ });
+
+ it('keeps multiple exactly identified attempts in chronological order without claiming task completion', async () => {
+ writeRows([
+ { ...message('user-1'), from: 'user', ts: '2026-10-17T01:00:00Z' },
+ { ...message('interrupted'), from: 'codex-agent', ts: '2026-10-17T12:14:00Z', system_kind: 'reply_interrupted' },
+ ]);
+ const paths = await import('../../../src/main/paths');
+ for (const [id, startedAt, callId] of [
+ ['123456abcdef', '2026-10-17T02:00:00Z', 'second'],
+ ['abcdef123456', '2026-10-17T01:00:01Z', 'first'],
+ ]) {
+ const directory = paths.localAgentRunDir(TEST_UID, id);
+ fs.mkdirSync(directory, { recursive: true });
+ fs.writeFileSync(path.join(directory, 'meta.json'), JSON.stringify({ runId: id, cid: 'canonical',
+ cli: 'codex', agentId: 'codex-agent', currentMessageId: 'user-1', startedAt }));
+ fs.writeFileSync(path.join(directory, 'events.jsonl'), JSON.stringify({ type: 'tool-event', phase: 'result', tool: 'bash', callId, output: callId }) + '\n');
+ }
+ const cache = await import('../../../src/main/features/conversation_history_cache');
+ const { records: [record] } = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1);
+ const items: any[] = [];
+ for (const part of record.process_parts || []) {
+ if ('ref' in part) items.push(...(await cache.readConversationProcessPage(TEST_UID, sourceFile, part.ref, 0, record.id)).items);
+ }
+ expect(items.map(item => item.event.data.callId)).toEqual(['first', 'second']);
+ expect(record.system_kind).toBe('reply_interrupted');
+ expect(record.text).toBe('message interrupted');
+ });
+
+ it.each([false, true])('restores a run that began before an in-flight user reply (trigger identity: %s)', async identified => {
+ writeRows([
+ { ...message('initial-user'), from: 'user', ts: '2026-10-17T01:00:00Z' },
+ { ...message('async-question'), from: 'codex-agent', ts: '2026-10-17T02:02:00Z' },
+ { ...message('steering-user'), from: 'user', ts: '2026-10-17T02:47:00Z' },
+ { ...message('interrupted'), from: 'codex-agent', ts: '2026-10-17T12:14:00Z', system_kind: 'reply_interrupted' },
+ ]);
+ const paths = await import('../../../src/main/paths');
+ const run = paths.localAgentRunDir(TEST_UID, '123456abcdef');
+ fs.mkdirSync(run, { recursive: true });
+ fs.writeFileSync(path.join(run, 'meta.json'), JSON.stringify({ runId: '123456abcdef', cid: 'canonical',
+ agentId: 'codex-agent', cli: 'codex', startedAt: '2026-10-17T01:00:01Z',
+ ...(identified ? { currentMessageId: 'initial-user' } : {}) }));
+ fs.writeFileSync(path.join(run, 'events.jsonl'), JSON.stringify({ type: 'tool-event', phase: 'result', tool: 'bash', callId: 'same-run', output: 'Saved work' }) + '\n');
+ const cache = await import('../../../src/main/features/conversation_history_cache');
+ const { records: [record] } = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1);
+ expect(record.process_parts?.length).toBe(1);
+ const part = record.process_parts![0];
+ if (!('ref' in part)) throw new Error('Missing archived process');
+ expect((await cache.readConversationProcessPage(TEST_UID, sourceFile, part.ref, 0, record.id)).items)
+ .toContainEqual({ type: 'event', event: { stream: 'cli', data: { type: 'tool-event', phase: 'result', tool: 'bash', callId: 'same-run', output: 'Saved work' } } });
+ });
+
+ it.each(['other-account', 'other-conversation', 'other-actor', 'older-turn', 'newer-run', 'ambiguous', 'symlink', 'wrong-source', 'existing-process', 'invalid-barrier', 'prior-reply'])(
+ 'does not attach unrelated or duplicate CLI history: %s', async variation => {
+ const rows = [
+ { ...message('user-1'), from: 'user', ts: '2026-10-17T01:00:00Z' },
+ ...(variation === 'invalid-barrier' ? [{ ...message('bad-date'), from: 'user', ts: 'invalid' }] : []),
+ ...(variation === 'prior-reply' ? [{ ...message('saved-reply'), from: 'codex-agent', ts: '2026-10-17T02:00:00Z',
+ source_message_id: 'user-1' }] : []),
+ { ...message('interrupted'), from: 'codex-agent', ts: '2026-10-17T12:14:00Z', system_kind: 'reply_interrupted',
+ ...(variation === 'existing-process' ? { process: [{ type: 'progress', text: 'Already saved' }] } : {}) },
+ ];
+ writeRows(rows);
+ const paths = await import('../../../src/main/paths');
+ const run = paths.localAgentRunDir(variation === 'other-account' ? 'other-user' : TEST_UID, '123456abcdef');
+ fs.mkdirSync(run, { recursive: true });
+ fs.writeFileSync(path.join(run, 'meta.json'), JSON.stringify({ runId: '123456abcdef', cli: 'codex',
+ cid: variation === 'other-conversation' ? 'other' : 'canonical',
+ agentId: variation === 'other-actor' ? 'other' : 'codex-agent',
+ startedAt: variation === 'older-turn' ? '2026-10-16T01:00:01Z'
+ : variation === 'newer-run' ? '2026-10-17T13:00:00Z' : '2026-10-17T01:00:01Z',
+ ...(variation === 'wrong-source' ? { currentMessageId: 'another-user-message' } : {}) }));
+ fs.writeFileSync(path.join(run, 'events.jsonl'), JSON.stringify({ type: 'tool-event', phase: 'use', tool: 'bash', input: { command: 'WRONG RUN' } }) + '\n');
+ if (variation === 'ambiguous') fs.cpSync(run, paths.localAgentRunDir(TEST_UID, 'abcdef123456'), { recursive: true });
+ if (variation === 'symlink') {
+ fs.renameSync(path.join(run, 'events.jsonl'), path.join(tmpDir, 'private-events.jsonl'));
+ fs.symlinkSync(path.join(tmpDir, 'private-events.jsonl'), path.join(run, 'events.jsonl'));
+ }
+ const cache = await import('../../../src/main/features/conversation_history_cache');
+ const history = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 1);
+ expect(history.records[0].process_parts).toBeUndefined();
+ expect(history.records[0].process).toEqual(rows.at(-1).process);
+ });
it.each([0, 1001])('caches legacy native classification with %s process items across page boundaries without rewriting raw history', async count => {
const earlier = { ...message('native-0'), from: 'claude', text: 'Checking the files.',
turn_id: 'turn-native', source_message_id: 'user-1', seg: 0,
@@ -276,14 +444,18 @@ describe('conversation history projection cache', () => {
const cache = await import('../../../src/main/features/conversation_history_cache');
await cache.readConversationHistoryPage(TEST_UID, sourceFile, 10);
const entry = onlyCacheEntry();
- fs.rmSync(path.join(entry, 'latest-page-v6.json'));
+ fs.rmSync(path.join(entry, 'latest-page-v8.json'));
fs.writeFileSync(path.join(entry, 'latest-page.json'), JSON.stringify({ version: 4, unrelated: 'x'.repeat(1024 * 1024) }));
fs.writeFileSync(path.join(entry, 'latest-page-v5.json'), JSON.stringify({ version: 5, unrelated: 'x'.repeat(1024 * 1024) }));
+ fs.writeFileSync(path.join(entry, 'latest-page-v6.json'), JSON.stringify({ version: 6, unrelated: 'x'.repeat(1024 * 1024) }));
+ fs.writeFileSync(path.join(entry, 'latest-page-v7.json'), JSON.stringify({ version: 7, unrelated: 'x'.repeat(1024 * 1024) }));
const next = await cache.readConversationHistoryPage(TEST_UID, sourceFile, 10);
expect(next.records.map(record => record.id)).toEqual(['latest']);
expect(fs.existsSync(path.join(entry, 'latest-page.json'))).toBe(false);
expect(fs.existsSync(path.join(entry, 'latest-page-v5.json'))).toBe(false);
- expect(fs.statSync(path.join(entry, 'latest-page-v6.json')).size).toBeLessThan(4096);
+ expect(fs.existsSync(path.join(entry, 'latest-page-v6.json'))).toBe(false);
+ expect(fs.existsSync(path.join(entry, 'latest-page-v7.json'))).toBe(false);
+ expect(fs.statSync(path.join(entry, 'latest-page-v8.json')).size).toBeLessThan(4096);
});
it('keeps the answer available during a process-cache write failure and recovers its details', async () => {
@@ -334,7 +506,7 @@ describe('conversation history projection cache', () => {
);
expect(page.nextCursor).not.toBeNull();
const cacheEntry = onlyCacheEntry();
- const latestPageFile = path.join(cacheEntry, 'latest-page-v6.json');
+ const latestPageFile = path.join(cacheEntry, 'latest-page-v8.json');
const cached = JSON.parse(fs.readFileSync(latestPageFile, 'utf8'));
expect(cached.records).toHaveLength(10);
expect(fs.statSync(latestPageFile).size).toBeLessThan(canonicalBytes / 20);
@@ -367,7 +539,7 @@ describe('conversation history projection cache', () => {
const result = (page.records[0].process as any[])[0].event.data;
expect(result.output).toBeUndefined();
expect(result.outputPath).toBeUndefined();
- expect(fs.statSync(path.join(onlyCacheEntry(), 'latest-page-v6.json')).size).toBeLessThan(4_000);
+ expect(fs.statSync(path.join(onlyCacheEntry(), 'latest-page-v8.json')).size).toBeLessThan(4_000);
const canonical = JSON.parse(fs.readFileSync(sourceFile, 'utf8').trim());
expect(canonical.process[0].event.data.output).toEqual(structuredOutput);
@@ -402,7 +574,7 @@ describe('conversation history projection cache', () => {
const extended = await readConversationHistoryPage(TEST_UID, sourceFile, 2);
expect(extended.records.map((record) => record.id)).toEqual(['m3', 'm4']);
- const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v6.json'), 'utf8'));
+ const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v8.json'), 'utf8'));
expect(cached.records.map((entry: any) => entry.record.id)).toEqual(['m3', 'm4']);
});
@@ -435,7 +607,7 @@ describe('conversation history projection cache', () => {
expect(expanded.records.map((record) => record.id)).toEqual(
Array.from({ length: 8 }, (_, index) => `m${index + 5}`),
);
- const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v6.json'), 'utf8'));
+ const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v8.json'), 'utf8'));
expect(cached.records).toHaveLength(8);
});
@@ -453,7 +625,7 @@ describe('conversation history projection cache', () => {
expect(whole.records.map((record) => record.id)).toEqual(
Array.from({ length: 30 }, (_, index) => `m${index + 1}`),
);
- const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v6.json'), 'utf8'));
+ const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v8.json'), 'utf8'));
expect(cached.records).toHaveLength(10);
});
@@ -468,7 +640,7 @@ describe('conversation history projection cache', () => {
);
expect(pages.every((page) => page.records.length === 10)).toBe(true);
- const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v6.json'), 'utf8'));
+ const cached = JSON.parse(fs.readFileSync(path.join(onlyCacheEntry(), 'latest-page-v8.json'), 'utf8'));
expect(cached.records).toHaveLength(10);
});
diff --git a/test/main/features/file_indexer.test.ts b/test/main/features/file_indexer.test.ts
index ab205f66..dd56cb26 100644
--- a/test/main/features/file_indexer.test.ts
+++ b/test/main/features/file_indexer.test.ts
@@ -478,6 +478,21 @@ describe('file_indexer › invalidate + purge + prune', () => {
expect(fs.readdirSync(userFileCacheRoot()).length).toBe(0);
});
+ it('preserves CLI run archives across startup and workspace-change pruning while removing orphaned extraction entries', async () => {
+ const m = await loadMod();
+ const persist = await import('../../../src/main/features/local_agents/persist');
+ const handle = await persist.start(UID, { agentId: 'codex-agent', cid: 'interrupted-chat', cli: 'codex', prompt: 'Fixture task' });
+ persist.append(handle, { type: 'text-delta', phase: 'commentary', text: 'Saved work in progress.' });
+ const archive = fs.readFileSync(handle.eventsPath, 'utf8');
+ const abs = writeWorkspaceFile('orphan.pdf', makeMinimalPdf(['Orphan']));
+ await m.statFile(UID, abs);
+ fs.unlinkSync(abs);
+ expect((await m.pruneOrphans(UID)).deleted).toBe(1);
+ expect(fs.readFileSync(handle.eventsPath, 'utf8')).toBe(archive);
+ expect((await m.pruneOrphans(UID, { workspacePath: path.join(tmpDir, 'other-workspace') })).deleted).toBe(0);
+ expect(fs.readFileSync(handle.eventsPath, 'utf8')).toBe(archive);
+ });
+
it('pruneOrphans drops protected-source cache entries without statting the source', async () => {
process.env.ORKAS_TCC_GUARD_FORCE = '1';
const home = path.join(tmpDir, 'fake-home');
@@ -486,7 +501,7 @@ describe('file_indexer › invalidate + purge + prune', () => {
process.env.HOME = home;
const m = await loadMod();
const protectedSource = path.join(downloads, 'old.pdf');
- const cacheDir = path.join(userFileCacheRoot(), 'manual-cache');
+ const cacheDir = path.join(userFileCacheRoot(), crypto.createHash('sha1').update(protectedSource).digest('hex').slice(0, 16));
fs.mkdirSync(cacheDir, { recursive: true });
fs.writeFileSync(path.join(cacheDir, 'meta.json'), JSON.stringify({
absPath: protectedSource,
diff --git a/test/main/features/local_agents/persist.test.ts b/test/main/features/local_agents/persist.test.ts
index e6e4c1a2..a9740395 100644
--- a/test/main/features/local_agents/persist.test.ts
+++ b/test/main/features/local_agents/persist.test.ts
@@ -30,6 +30,7 @@ describe('local_agents/persist', () => {
const handle = await persist.start(TEST_UID, {
agentId: 'agent-1',
cid: 'conv-1',
+ currentMessageId: 'user-trigger-1',
cli: 'claude',
cliPath: '/fake/claude',
prompt: 'write tests',
@@ -65,6 +66,7 @@ describe('local_agents/persist', () => {
cli: 'claude',
cliPath: '/fake/claude',
status: 'completed',
+ currentMessageId: 'user-trigger-1',
durationMs: 42,
output: 'complete body',
sessionId: 'sess-1',
diff --git a/test/main/features/local_agents/runner.test.ts b/test/main/features/local_agents/runner.test.ts
index 444f3dec..e2509b6a 100644
--- a/test/main/features/local_agents/runner.test.ts
+++ b/test/main/features/local_agents/runner.test.ts
@@ -490,7 +490,7 @@ describe('local_agents/runner', () => {
const runner = await loadRunner();
const events: any[] = [];
const result = await runner.run({
- uid: TEST_UID, cid: 'c', agentId: 'agent-x',
+ uid: TEST_UID, cid: 'c', agentId: 'agent-x', currentMessageId: 'persisted-user-trigger',
cli: 'claude', prompt: 'do work', cwd: tmpDir,
signal: new AbortController().signal,
onEvent: e => events.push(e),
@@ -509,6 +509,7 @@ describe('local_agents/runner', () => {
expect(fs.readFileSync(path.join(dir, 'output.txt'), 'utf8')).toBe('hello world');
const meta = JSON.parse(fs.readFileSync(path.join(dir, 'meta.json'), 'utf8'));
expect(meta.status).toBe('completed');
+ expect(meta.currentMessageId).toBe('persisted-user-trigger');
expect(meta.cli).toBe('claude');
expect(meta.cliPath).toBe('/fake/claude');
expect(meta.endedAt).toBeTruthy();