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.

Fix keyed conversation recovery and desktop diagnostic collection

wytdd21665fbe6f
diff --git a/src/renderer/modules/conversation.js b/src/renderer/modules/conversation.js
index cc591225..0e6390d1 100644
--- a/src/renderer/modules/conversation.js
+++ b/src/renderer/modules/conversation.js
@@ -8110,29 +8110,30 @@ async function _recoverPolledVisibleMessages(cid, rawMessages) {
for (const gm of visible) {
if (!gm.id) continue;
const existing = _findRenderedGroupMessage(container, gm);
- if (existing && String(existing.dataset.msgId || '') === String(gm.id)) {
+ if (existing) {
+ if (existing.dataset.placeholder === '1' && existing.dataset.finalized !== '1') {
+ const live = _claimRenderNodeForMessage(cid, gm);
+ if (live) {
+ _finalizeActorPlaceholder(live, gm, cid, true);
+ changed = true;
+ continue;
+ }
+ }
+ _syncRenderedGroupMessageIdentity(existing, gm);
if (!_messageRecordHasMountedSidecars(gm, existing, { checkMutableState: false })) {
loadConversationHistory(cid, { preserveScroll: true });
return true;
}
continue;
}
- const ph = _claimRenderNodeForMessage(cid, gm)
- || _adoptFallbackRowForMessage(cid, gm, pendingConvs.get(cid)?.loadingEl);
- if (ph && ph.parentElement) {
- _finalizeActorPlaceholder(ph, gm, cid, true);
- changed = true;
- continue;
- }
- // An uncorrelated interruption row can be stale while a newer exact turn
- // for the same actor is live (or can itself be a false row from deferred
- // boot maintenance). Do not append a second bubble mid-stream. Once the
- // runtime settles, normal history reconciliation either removes the row as
- // superseded by the final message or renders it when it was genuine.
+ // Recovery may precede mounting the newer live row. Keep its older
+ // interruption deferred using runtime identity until that turn settles.
if (_isInterruptedAssistantMessage(gm) && (_latestActiveTurns.get(cid) || []).some((turn) => (
String(turn.actor || '') === String(gm.from || '')
&& (!gm.turn_id || String(turn.turn_id || '') !== String(gm.turn_id))
))) continue;
+ // No row owns this record's identity. The shared interruption cleanup
+ // below removes any status superseded by a newer live row for its actor.
const legacy = _groupMsgToLegacy(gm);
const bubble = appendChatMessage(legacy, true, { cid, archive: true });
if (bubble) bubble.dataset.fromActor = String(gm.from || '');
@@ -12336,8 +12337,8 @@ function _removeSupersededInterruptionBubbles(container) {
if (el.dataset.systemKind === 'reply_interrupted') {
// A boot-maintenance race used to append a false interruption below a
// still-running placeholder. Never show that as a second bubble. The
- // polling path defers the record too; this DOM guard repairs an already
- // mounted row from an earlier poll without discarding the process rail.
+ // recovery path uses this same guard to repair a row mounted by an
+ // earlier poll without discarding the process rail.
if (liveByActor.has(actor)) {
el.remove();
removed += 1;
diff --git a/test/e2e/connectors_e2e_validation.spec.ts b/test/e2e/connectors_e2e_validation.spec.ts
index 8f49abdb..8e7a7bf8 100644
--- a/test/e2e/connectors_e2e_validation.spec.ts
+++ b/test/e2e/connectors_e2e_validation.spec.ts
@@ -1,6 +1,100 @@
import { readFileSync, writeFileSync } from 'node:fs';
-import { expect, test } from './fixtures/orkas';
+import { expect, test, type OrkasTestApp } from './fixtures/orkas';
+
+async function connectLocalMcp(modelOrkas: OrkasTestApp) {
+ if (!modelOrkas.page) throw new Error('Orkas renderer is unavailable');
+ const page = modelOrkas.page;
+ expect(await modelOrkas.invoke('permissions.setLocalExecMode', { mode: 'all_files_approval' }))
+ .toMatchObject({ ok: true, mode: 'all_files_approval' });
+ const callStatePath = modelOrkas.createFixtureFile('e2e-mcp-call-state.json', '[]\n');
+ const serverPath = modelOrkas.createFixtureFile('e2e-mcp-server.cjs', String.raw`
+const fs = require('node:fs');
+const readline = require('node:readline');
+const rl = readline.createInterface({ input: process.stdin, terminal: false });
+function reply(id, result) {
+ process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id, result }) + '\n');
+}
+rl.on('line', (line) => {
+ let msg;
+ try { msg = JSON.parse(line); } catch { return; }
+ if (msg.method === 'initialize') {
+ reply(msg.id, {
+ protocolVersion: msg.params.protocolVersion,
+ capabilities: { tools: {} },
+ serverInfo: { name: 'orkas-e2e-mcp', version: '1.0.0' },
+ });
+ } else if (msg.method === 'tools/list') {
+ reply(msg.id, { tools: [{
+ name: 'e2e_echo',
+ description: 'Returns deterministic E2E text.',
+ inputSchema: { type: 'object', properties: { text: { type: 'string' } } },
+ }] });
+ } else if (msg.method === 'tools/call') {
+ let calls = [];
+ try { calls = JSON.parse(fs.readFileSync(process.env.E2E_MCP_STATE, 'utf8')); } catch {}
+ calls.push({ name: msg.params.name, arguments: msg.params.arguments });
+ fs.writeFileSync(process.env.E2E_MCP_STATE, JSON.stringify(calls, null, 2));
+ reply(msg.id, { content: [{ type: 'text', text: 'echo:' + String(msg.params.arguments.text || '') }] });
+ } else if (msg.method === 'ping') {
+ reply(msg.id, {});
+ }
+});
+`);
+
+ await page.locator('#connectors-btn').click();
+ await expect(page.locator('#panel-connectors')).toHaveClass(/\bactive\b/);
+ await page.locator('#connectors-add-custom-btn').click();
+ const dialog = page.locator('.connector-custom-dialog');
+ await dialog.locator('[data-f="name"]').fill('E2E Local MCP');
+ await dialog.locator('[data-f="kind"]').selectOption('stdio');
+ await dialog.locator('[data-f="command"]').fill(process.execPath);
+ await dialog.locator('[data-f="args"]').fill(serverPath);
+ await dialog.locator('[data-f="env"]').fill([
+ 'E2E_SECRET=must-not-reach-renderer',
+ `E2E_MCP_STATE=${callStatePath}`,
+ ].join('\n'));
+ await dialog.locator('[data-act="ok"]').click();
+ await expect(dialog).toHaveCount(0, { timeout: 15_000 });
+
+ const listed = await modelOrkas.invoke<{
+ instances: Array<{
+ id: string;
+ display_name: string;
+ enabled?: boolean;
+ status: { kind: string };
+ transport?: { kind: string; summary: string };
+ tools_cache: Array<{ name: string }>;
+ }>;
+ }>('connectors.list');
+ const instance = listed.instances.find((item) => item.display_name === 'E2E Local MCP');
+ expect(instance).toMatchObject({
+ enabled: true,
+ status: { kind: 'connected' },
+ transport: { kind: 'stdio' },
+ });
+ expect(instance?.tools_cache.map((tool) => tool.name)).toContain('e2e_echo');
+ expect(JSON.stringify(instance)).not.toContain('must-not-reach-renderer');
+
+ const card = page.locator(`.connector-card[data-id="${instance?.id}"]`);
+ await expect(card).toContainText('E2E Local MCP');
+ await expect(card).not.toHaveClass(/\bis-disabled\b/);
+
+ if (!instance?.id) throw new Error('Connected E2E MCP instance was not returned');
+ const startConnectorChat = async () => {
+ await page.locator('#new-chat-btn').click();
+ await page.locator('#new-chat-recipient-chip').click();
+ const picker = page.locator('#agent-picker');
+ await picker.locator('[data-agent-picker-tab="connectors"]').click();
+ const connectorOption = picker.locator(
+ `.skill-picker-item[data-kind="connector"][data-id="${instance.id}"]`,
+ );
+ await expect(connectorOption).toContainText('E2E Local MCP');
+ await connectorOption.click();
+ await expect(page.locator('#new-chat-input')).toHaveValue(/Connector: E2E Local MCP/);
+ };
+ return { page, instance, card, callStatePath, startConnectorChat };
+}
test.describe('connectors', () => {
test('browses available connectors by category with localized chips and a narrow layout', async ({ connectorOrkas }, testInfo) => {
@@ -255,100 +349,8 @@ test.describe('connectors', () => {
await expect(custom).toHaveCount(0);
});
- test('connects to a real local MCP server, approves a task, changes operation trust, toggles it, and disconnects', async ({ modelOrkas }, testInfo) => {
- // This journey includes multiple model/tool rounds, permission changes and disconnect.
- // Budget the whole journey separately; individual UI and operation deadlines stay unchanged.
- test.setTimeout(120_000);
- if (!modelOrkas.page) throw new Error('Orkas renderer is unavailable');
- const page = modelOrkas.page;
- expect(await modelOrkas.invoke('permissions.setLocalExecMode', { mode: 'all_files_approval' }))
- .toMatchObject({ ok: true, mode: 'all_files_approval' });
- const callStatePath = modelOrkas.createFixtureFile('e2e-mcp-call-state.json', '[]\n');
- const serverPath = modelOrkas.createFixtureFile('e2e-mcp-server.cjs', String.raw`
-const fs = require('node:fs');
-const readline = require('node:readline');
-const rl = readline.createInterface({ input: process.stdin, terminal: false });
-function reply(id, result) {
- process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id, result }) + '\n');
-}
-rl.on('line', (line) => {
- let msg;
- try { msg = JSON.parse(line); } catch { return; }
- if (msg.method === 'initialize') {
- reply(msg.id, {
- protocolVersion: msg.params.protocolVersion,
- capabilities: { tools: {} },
- serverInfo: { name: 'orkas-e2e-mcp', version: '1.0.0' },
- });
- } else if (msg.method === 'tools/list') {
- reply(msg.id, { tools: [{
- name: 'e2e_echo',
- description: 'Returns deterministic E2E text.',
- inputSchema: { type: 'object', properties: { text: { type: 'string' } } },
- }] });
- } else if (msg.method === 'tools/call') {
- let calls = [];
- try { calls = JSON.parse(fs.readFileSync(process.env.E2E_MCP_STATE, 'utf8')); } catch {}
- calls.push({ name: msg.params.name, arguments: msg.params.arguments });
- fs.writeFileSync(process.env.E2E_MCP_STATE, JSON.stringify(calls, null, 2));
- reply(msg.id, { content: [{ type: 'text', text: 'echo:' + String(msg.params.arguments.text || '') }] });
- } else if (msg.method === 'ping') {
- reply(msg.id, {});
- }
-});
-`);
-
- await page.locator('#connectors-btn').click();
- await expect(page.locator('#panel-connectors')).toHaveClass(/\bactive\b/);
- await page.locator('#connectors-add-custom-btn').click();
- const dialog = page.locator('.connector-custom-dialog');
- await dialog.locator('[data-f="name"]').fill('E2E Local MCP');
- await dialog.locator('[data-f="kind"]').selectOption('stdio');
- await dialog.locator('[data-f="command"]').fill(process.execPath);
- await dialog.locator('[data-f="args"]').fill(serverPath);
- await dialog.locator('[data-f="env"]').fill([
- 'E2E_SECRET=must-not-reach-renderer',
- `E2E_MCP_STATE=${callStatePath}`,
- ].join('\n'));
- await dialog.locator('[data-act="ok"]').click();
- await expect(dialog).toHaveCount(0, { timeout: 15_000 });
-
- const listed = await modelOrkas.invoke<{
- instances: Array<{
- id: string;
- display_name: string;
- enabled?: boolean;
- status: { kind: string };
- transport?: { kind: string; summary: string };
- tools_cache: Array<{ name: string }>;
- }>;
- }>('connectors.list');
- const instance = listed.instances.find((item) => item.display_name === 'E2E Local MCP');
- expect(instance).toMatchObject({
- enabled: true,
- status: { kind: 'connected' },
- transport: { kind: 'stdio' },
- });
- expect(instance?.tools_cache.map((tool) => tool.name)).toContain('e2e_echo');
- expect(JSON.stringify(instance)).not.toContain('must-not-reach-renderer');
-
- const card = page.locator(`.connector-card[data-id="${instance?.id}"]`);
- await expect(card).toContainText('E2E Local MCP');
- await expect(card).not.toHaveClass(/\bis-disabled\b/);
-
- if (!instance?.id) throw new Error('Connected E2E MCP instance was not returned');
- const startConnectorChat = async () => {
- await page.locator('#new-chat-btn').click();
- await page.locator('#new-chat-recipient-chip').click();
- const picker = page.locator('#agent-picker');
- await picker.locator('[data-agent-picker-tab="connectors"]').click();
- const connectorOption = picker.locator(
- `.skill-picker-item[data-kind="connector"][data-id="${instance.id}"]`,
- );
- await expect(connectorOption).toContainText('E2E Local MCP');
- await connectorOption.click();
- await expect(page.locator('#new-chat-input')).toHaveValue(/Connector: E2E Local MCP/);
- };
+ test('connects to a real local MCP server and expires task approval before the next task', async ({ modelOrkas }, testInfo) => {
+ const { page, instance, callStatePath, startConnectorChat } = await connectLocalMcp(modelOrkas);
await startConnectorChat();
modelOrkas.setConnectorToolScenario(instance.id);
@@ -401,7 +403,7 @@ rl.on('line', (line) => {
arguments: { text: 'roundtrip' },
}]);
// Task approval leaves global permissions unchanged and expires at task
- // completion. A new task must ask again before switching to Trusted.
+ // completion. A new task must ask again without changing global trust.
expect(await modelOrkas.invoke('permissions.getLocalExec')).toMatchObject({ mode: 'all_files_approval' });
await startConnectorChat();
modelOrkas.setConnectorToolScenario(instance.id);
@@ -409,6 +411,24 @@ rl.on('line', (line) => {
await page.locator('#new-chat-send-btn').click();
await expect(actionConfirmation).toBeVisible();
expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toHaveLength(1);
+ await actionConfirmation.locator('[data-id="allow_run"]').click();
+ await expect(actionConfirmation).toHaveCount(0);
+ await expect(page.locator('#chat-history .chat-message.assistant [data-role="final"]', {
+ hasText: 'E2E connector tool round trip completed.',
+ })).toBeVisible({ timeout: 20_000 });
+ expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toHaveLength(2);
+ expect(await modelOrkas.invoke('permissions.getLocalExec')).toMatchObject({ mode: 'all_files_approval' });
+ });
+
+ test('connects to a real local MCP server and persists operation trust across tasks', async ({ modelOrkas }, testInfo) => {
+ const { page, instance, callStatePath, startConnectorChat } = await connectLocalMcp(modelOrkas);
+ await startConnectorChat();
+ modelOrkas.setConnectorToolScenario(instance.id);
+ await page.locator('#new-chat-input').type('Call the echo connector.');
+ await page.locator('#new-chat-send-btn').click();
+ const actionConfirmation = page.locator('.bash-permission-dialog');
+ await expect(actionConfirmation).toBeVisible();
+ expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toEqual([]);
await actionConfirmation.locator('.bash-permission-mode-trigger').click();
const modeMenu = page.getByRole('listbox').filter({ has: page.locator('[data-mode="all_files_auto"]') });
await expect(modeMenu).toBeVisible();
@@ -424,7 +444,7 @@ rl.on('line', (line) => {
hasText: 'E2E connector tool round trip completed.',
})).toBeVisible({ timeout: 20_000 });
expect(await modelOrkas.invoke('permissions.getLocalExec')).toMatchObject({ mode: 'all_files_auto' });
- expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toHaveLength(2);
+ expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toHaveLength(1);
await startConnectorChat();
modelOrkas.setConnectorToolScenario(instance.id);
@@ -434,9 +454,28 @@ rl.on('line', (line) => {
hasText: 'E2E connector tool round trip completed.',
})).toBeVisible({ timeout: 20_000 });
await expect(actionConfirmation).toHaveCount(0);
- expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toEqual(Array.from({ length: 3 }, () => ({
+ expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toEqual(Array.from({ length: 2 }, () => ({
name: 'e2e_echo', arguments: { text: 'roundtrip' },
})));
+ });
+
+ // Availability has its own journey and deadline; approval/trust coverage above
+ // remains complete instead of sharing a cumulative multi-journey timeout.
+ test('connects to a real local MCP server, toggles availability, and disconnects', async ({ modelOrkas }) => {
+ const { page, instance, card, callStatePath, startConnectorChat } = await connectLocalMcp(modelOrkas);
+ // Warm the real connector through an agent call before disabling it, so
+ // stale tool visibility cannot hide behind a never-used instance.
+ await modelOrkas.invoke('permissions.setLocalExecMode', { mode: 'all_files_auto' });
+ await startConnectorChat();
+ modelOrkas.setConnectorToolScenario(instance.id);
+ await page.locator('#new-chat-input').type('Call the echo connector before disabling it.');
+ await page.locator('#new-chat-send-btn').click();
+ await expect(page.locator('#chat-history .chat-message.assistant [data-role="final"]', {
+ hasText: 'E2E connector tool round trip completed.',
+ })).toBeVisible({ timeout: 20_000 });
+ expect(JSON.parse(readFileSync(callStatePath, 'utf8'))).toEqual([
+ { name: 'e2e_echo', arguments: { text: 'roundtrip' } },
+ ]);
await page.locator('#connectors-btn').click();
await card.hover();
await card.locator('.connector-card-menu-btn').click();
diff --git a/test/e2e/fixtures/electron-log-files.cjs b/test/e2e/fixtures/electron-log-files.cjs
new file mode 100644
index 00000000..4a541870
--- /dev/null
+++ b/test/e2e/fixtures/electron-log-files.cjs
@@ -0,0 +1,43 @@
+const { readdirSync, readFileSync } = require('node:fs');
+const path = require('node:path');
+const MAX_LOG_BYTES = 2 * 1024 * 1024;
+
+function collectLogFiles(root) {
+ const chunks = [];
+ let totalBytes = 0;
+
+ const visit = (directory) => {
+ let entries;
+ try {
+ entries = readdirSync(directory, { withFileTypes: true });
+ } catch {
+ return;
+ }
+ for (const entry of entries) {
+ if (totalBytes >= MAX_LOG_BYTES) return;
+ const fullPath = path.join(directory, entry.name);
+ if (entry.isDirectory()) {
+ visit(fullPath);
+ continue;
+ }
+ if (!entry.isFile() || !entry.name.endsWith('.log')) continue;
+ try {
+ const body = readFileSync(fullPath, 'utf8');
+ const available = MAX_LOG_BYTES - totalBytes;
+ const slice = body.slice(0, available);
+ chunks.push(`\n===== ${path.relative(root, fullPath)} =====\n${slice}`);
+ totalBytes += Buffer.byteLength(slice);
+ } catch {
+ // A log may be rotated while Electron is shutting down.
+ }
+ }
+ };
+
+ // Chromium LevelDB uses binary .log files outside these diagnostic roots.
+ // Scanning the whole workspace can consume the budget before app logs.
+ visit(path.join(root, 'workspace', 'logs'));
+ visit(path.join(root, 'electron-user-data', 'logs'));
+ return chunks.join('');
+}
+
+module.exports = { collectLogFiles };
diff --git a/test/e2e/fixtures/orkas.ts b/test/e2e/fixtures/orkas.ts
index 437c1c59..5e4fe9e3 100644
--- a/test/e2e/fixtures/orkas.ts
+++ b/test/e2e/fixtures/orkas.ts
@@ -27,7 +27,7 @@ const PC_ROOT = path.resolve(__dirname, '../../..');
// Shared E2E scenarios address this local registry identity directly. The
// value is a fixture UID; it does not create an official account or session.
const LOCAL_USER_ID = 'account-e2e';
-const MAX_LOG_BYTES = 2 * 1024 * 1024;
+const { collectLogFiles } = require('./electron-log-files.cjs') as { collectLogFiles: (root: string) => string };
/** Evidence files read per model round in the context-compaction scenario.
* Four ~11.2K-token results stay well under the per-round inline allowance,
* so the batch builds context instead of spilling to disk. */
@@ -706,41 +706,6 @@ function seedWorkspace(workspaceRoot: string): void {
}
-function collectLogFiles(root: string): string {
- const chunks: string[] = [];
- let totalBytes = 0;
-
- const visit = (directory: string): void => {
- let entries;
- try {
- entries = readdirSync(directory, { withFileTypes: true });
- } catch {
- return;
- }
- for (const entry of entries) {
- if (totalBytes >= MAX_LOG_BYTES) return;
- const fullPath = path.join(directory, entry.name);
- if (entry.isDirectory()) {
- visit(fullPath);
- continue;
- }
- if (!entry.isFile() || !entry.name.endsWith('.log')) continue;
- try {
- const body = readFileSync(fullPath, 'utf8');
- const available = MAX_LOG_BYTES - totalBytes;
- const slice = body.slice(0, available);
- chunks.push(`\n===== ${path.relative(root, fullPath)} =====\n${slice}`);
- totalBytes += Buffer.byteLength(slice);
- } catch {
- // A log may be rotated while Electron is shutting down.
- }
- }
- };
-
- visit(root);
- return chunks.join('');
-}
-
export class OrkasTestApp {
readonly root: string;
readonly workspaceRoot: string;
@@ -900,6 +865,9 @@ export class OrkasTestApp {
// Automation shells can use Electron as their Node runtime and leak this
// switch into child processes. Playwright must launch Electron in app mode.
delete environment.ELECTRON_RUN_AS_NODE;
+ // Preserve no-color output without leaking contradictory runner settings
+ // into Electron's stderr (which the app records as console errors).
+ if (environment.NO_COLOR !== undefined) delete environment.FORCE_COLOR;
if (this.cliStub) {
environment.ORKAS_E2E_CLI_STATE = this.cliStatePath;
environment.ORKAS_OPENCODE_PATH = this.fakeOpenCodePath || '';
@@ -1633,7 +1601,7 @@ export class OrkasTestApp {
contentType: 'application/json',
}).catch(() => undefined);
}
- const appLogs = collectLogFiles(path.join(this.workspaceRoot, 'logs'));
+ const appLogs = collectLogFiles(this.root);
const diagnosticText = [this.diagnostics.join('\n'), appLogs].filter(Boolean).join('\n');
if (diagnosticText) {
// Written to the failure's output directory, not only attached: line/list
@@ -1661,7 +1629,7 @@ export class OrkasTestApp {
// renderer diagnostics and app logs as a failed run. File logs alone
// omit direct console output, including renderer warnings.
if (process.env.ORKAS_E2E_KEEP_LOGS === '1') {
- const appLogs = collectLogFiles(path.join(this.workspaceRoot, 'logs'));
+ const appLogs = collectLogFiles(this.root);
const diagnosticText = [this.diagnostics.join('\n'), appLogs].filter(Boolean).join('\n');
if (diagnosticText) {
try {
diff --git a/test/e2e/task_board_e2e_scheduling.spec.ts b/test/e2e/task_board_e2e_scheduling.spec.ts
index b3339d6d..4cca594f 100644
--- a/test/e2e/task_board_e2e_scheduling.spec.ts
+++ b/test/e2e/task_board_e2e_scheduling.spec.ts
@@ -308,6 +308,12 @@ test.describe('task board scheduling (D18 serial chain)', () => {
const board = page.locator('#chat-task-board');
const rows = page.locator('#chat-task-board-list .chat-queue-item');
const before = app.modelRequests.length;
+ const recoveryWarnings: string[] = [];
+ page.on('console', message => {
+ if (message.text().includes('plan recovery history reconcile failed')) {
+ recoveryWarnings.push(message.text());
+ }
+ });
app.setModelMode('very-slow');
await sendMultiMention(page, '@ContentWriter slow research task. @UIDesigner deck after research.');
@@ -326,6 +332,11 @@ test.describe('task board scheduling (D18 serial chain)', () => {
// user clicked (the click itself must re-attach event delivery).
app.setModelMode('success');
app.setModelTextReplies(['ran anyway fine.']);
+ // Simulate a missed history render while the canonical seed reply remains
+ // on disk. Reattaching must recover it once as well as show the new reply.
+ const seedReply = page.locator('#chat-history .chat-message.assistant').filter({ hasText: 'ok task board' });
+ await expect(seedReply).toHaveCount(1);
+ await seedReply.evaluate(node => node.remove());
await runAnyway.click();
await expect.poll(() => app.modelRequests.length, { timeout: 15_000 }).toBe(before + 2);
await expect(page.locator('#chat-history')).toContainText('ran anyway fine.', { timeout: 15_000 });
@@ -333,6 +344,8 @@ test.describe('task board scheduling (D18 serial chain)', () => {
// is released into an ordinary single run, the board retracts and the
// final result remains in chat history.
await expect(board).toBeHidden({ timeout: 10_000 });
+ await expect(seedReply).toHaveCount(1);
+ expect(recoveryWarnings).toEqual([]);
});
test('groups by agent, drags queued messages only within that agent, and removes cancelled sends', async ({ modelOrkas, boardPage }, testInfo) => {
diff --git a/test/main/features/group_chat/bus-integration.test.ts b/test/main/features/group_chat/bus-integration.test.ts
index 6f90a5aa..e0787320 100644
--- a/test/main/features/group_chat/bus-integration.test.ts
+++ b/test/main/features/group_chat/bus-integration.test.ts
@@ -4768,6 +4768,10 @@ describe('group_chat bus integration › task terminal boundary', () => {
const permissions = await import('../../../../src/main/features/permissions');
permissions.setLocalExecMode('all_files_approval');
const prompts: any[] = [];
+ const terminals: string[] = [];
+ const unsubscribe = bus.subscribeTaskTerminals(event => {
+ if (event.conversation_id === cid) terminals.push(event.status);
+ });
confirm._setBroadcastForTest((channel, payload) => { if (channel === 'connectors:action-confirm') prompts.push(payload); });
const opts = { userId: TEST_UID, cid, connectorId: 'feishu', displayName: 'Feishu', toolName: 'send', risk: 'H' as const, args: {} };
try {
@@ -4778,11 +4782,14 @@ describe('group_chat bus integration › task terminal boundary', () => {
_setScript(state.buildGconvSessionId(cid), [{ type: 'final', text: 'Done.' }]);
await bus.enqueue({ uid: TEST_UID, cid, fromActorId: 'user', text: 'Finish this task.' });
await waitForQuiescent(TEST_UID, cid, 3000);
+ // Worker quiescence precedes the persisted status and terminal notification.
+ await expect.poll(() => terminals).toEqual(['completed']);
const next = confirm.requestActionConfirm(opts);
expect(prompts).toHaveLength(2);
confirm.respond(prompts[1].request_id, false);
await expect(next).resolves.toBe(false);
} finally {
+ unsubscribe();
confirm.cancelForCid(cid);
confirm._setBroadcastForTest(null);
}
diff --git a/test/renderer/conversation-keyed-rendering.test.ts b/test/renderer/conversation-keyed-rendering.test.ts
index 8e36e06f..26f7c16e 100644
--- a/test/renderer/conversation-keyed-rendering.test.ts
+++ b/test/renderer/conversation-keyed-rendering.test.ts
@@ -215,6 +215,28 @@ function loadRenderer(cid: string) {
const CID = 'c1';
const TURN = 'turn-1';
+describe('keyed rendering › reconnect history', () => {
+ it('recovers missing replies once without merging same-text replies from different turns', async () => {
+ const { context, container, appended, finalized } = loadRenderer(CID);
+ const first = { id: 'saved-1', from: 'commander', to: ['user'], text: 'Saved answer',
+ ts: '2026-09-10T12:00:00Z', turn_id: 'first-turn', seg: 0 };
+ const second = { ...first, id: 'saved-2', turn_id: 'second-turn' };
+ const live = new FakeNode();
+ live.dataset.renderKey = 's:first-turn:0';
+ live.dataset.placeholder = '1';
+ container.appendChild(live);
+
+ await context._recoverPolledVisibleMessages(CID, [first]);
+ await context._recoverPolledVisibleMessages(CID, [first, second]);
+ await context._recoverPolledVisibleMessages(CID, [first, second]);
+
+ expect(container.rows.map(row => row.dataset.msgId)).toEqual(['saved-1', 'saved-2']);
+ expect(container.rows[0]).toBe(live);
+ expect(appended).toHaveLength(1);
+ expect(finalized.map(item => item.gm.text)).toEqual(['Saved answer']);
+ });
+});
+
function delta(seg: number, text: string, actor = 'commander') {
return { type: 'process', cid: CID, actor, turn_id: TURN, seg, data: { type: 'delta', text } };
}
diff --git a/test/renderer/conversation-sidebar.test.ts b/test/renderer/conversation-sidebar.test.ts
index 73103c70..cb608f04 100644
--- a/test/renderer/conversation-sidebar.test.ts
+++ b/test/renderer/conversation-sidebar.test.ts
@@ -2347,9 +2347,10 @@ describe('conversation stream lifecycle idempotency', () => {
it('catches up persisted replies after subscribing to an already-running task', async () => {
const context = loadConversationRenderer();
- const { loadingEl } = setupRunningObserverTestContext(context);
- context._findRenderedMessageForHistoryRecord = () => null;
- context._consumePlaceholderForHistoryRecord = () => loadingEl;
+ const { historyEl, loadingEl } = setupRunningObserverTestContext(context);
+ loadingEl.dataset = { placeholder: '1', renderKey: 's:turn-1:0' };
+ historyEl.querySelector = (selector: string) => selector.includes('data-render-key="s:turn-1:0"') ? loadingEl : null;
+ historyEl.querySelectorAll = (selector: string) => selector.includes('data-render-key="s:turn-1:0"') ? [loadingEl] : [];
const finalizedTexts: string[] = [];
context._finalizeActorPlaceholder = (_el: any, message: any) => {
@@ -9823,10 +9824,14 @@ describe('polled history recovery identity', () => {
it('settles a keyed live row once when its durable reply arrives through polling', async () => {
const context = recoveryHarness();
- const row = { dataset: { renderKey: 's:turn-a:0' }, parentElement: {} };
+ const row = { dataset: { renderKey: 's:turn-a:0', placeholder: '1', finalized: '0' }, parentElement: {} };
const record = { id: 'reply-a', from: 'commander', turn_id: 'turn-a', seg: 0, text: 'Done' };
context._findRenderedGroupMessage = () => row;
- context._claimRenderNodeForMessage = () => row;
+ context._claimRenderNodeForMessage = () => {
+ if (row.dataset.finalized === '1') return null;
+ row.dataset.finalized = '1';
+ return row;
+ };
context._finalizeActorPlaceholder = vi.fn((node: any, gm: any) => { node.dataset.msgId = gm.id; });
context._messageRecordHasMountedSidecars = () => true;
expect(await context._recoverPolledVisibleMessages('c1', [record])).toBe(true);
diff --git a/test/web/electron-e2e-log-files.test.ts b/test/web/electron-e2e-log-files.test.ts
new file mode 100644
index 00000000..381c8552
--- /dev/null
+++ b/test/web/electron-e2e-log-files.test.ts
@@ -0,0 +1,34 @@
+import { afterEach, expect, it } from 'vitest';
+import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+
+const { collectLogFiles } = require('../e2e/fixtures/electron-log-files.cjs');
+const roots: string[] = [];
+afterEach(() => roots.splice(0).forEach(root => rmSync(root, { recursive: true, force: true })));
+
+it('retains application and runtime errors even when Chromium has a larger binary database log', () => {
+ const root = mkdtempSync(path.join(tmpdir(), 'orkas-log-evidence-'));
+ roots.push(root);
+ const put = (name: string, body: string | Buffer) => {
+ const target = path.join(root, name);
+ mkdirSync(path.dirname(target), { recursive: true });
+ writeFileSync(target, body);
+ };
+ put('electron-user-data/Local Storage/leveldb/000003.log', Buffer.alloc(3 * 1024 * 1024));
+ put('workspace/logs/current.log', '[error] application failure\n');
+ put('workspace/logs/previous.old.log', '[warn] recovered failure\n');
+ put('electron-user-data/logs/runtime.log', '[error] runtime failure\n');
+ const logs = collectLogFiles(root);
+ expect(logs).toContain('[error] application failure');
+ expect(logs).toContain('[warn] recovered failure');
+ expect(logs).toContain('[error] runtime failure');
+ expect(logs).not.toContain('leveldb');
+ expect(logs).not.toContain('\0');
+});
+
+it('handles fixtures that exit before creating a diagnostic directory', () => {
+ const root = mkdtempSync(path.join(tmpdir(), 'orkas-log-evidence-'));
+ roots.push(root);
+ expect(collectLogFiles(root)).toBe('');
+});