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.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
fix(agents): preserve CLI upgrade feedback across detail refreshes
BlueSkyID666bea0a39572d6
diff --git a/.github/workflows/native-dependencies.yml b/.github/workflows/native-dependencies.ymlindex 5425127b..c35f7918 100644--- a/.github/workflows/native-dependencies.yml+++ b/.github/workflows/native-dependencies.yml@@ -63,6 +63,10 @@ jobs:test/main/util/ensure-dev-dependencies.test.tstest/main/util/linux-source-dependencies.test.tstest/main/features/search/chat_store.test.ts+ test/renderer/agents-detail-layout.test.ts+ test/renderer/cli-account-usage.test.ts+ test/renderer/local-agents-status.test.ts+ test/renderer/agent-detail-return-navigation.test.ts- name: Verify workbook formulas and interrupted directory recoveryrun: >-npm run test:js -- --maxWorkers=1diff --git a/src/renderer/modules/agents.js b/src/renderer/modules/agents.jsindex 6f3b663b..61b736d5 100644--- a/src/renderer/modules/agents.js+++ b/src/renderer/modules/agents.js@@ -1982,6 +1982,11 @@ async function _renderAgentDetailRuntime(agent) {pendingTrigger.setAttribute('aria-disabled', 'true');pendingTrigger.setAttribute('aria-busy', 'true');}+ // Keep feedback mounted while discovery is pending so overlapping refreshes+ // and locale updates retain the same control and its current upgrade state.+ if (previousRuntimeKey === runtimeKey && previousUpgradeControl) {+ slot.appendChild(previousUpgradeControl);+ }// Share the process-lifetime discovery cache with the create panel.// Opening a detail must not synchronously force the same version processes@@ -1996,7 +2001,8 @@ async function _renderAgentDetailRuntime(agent) {error_type: err && err.name ? String(err.name) : typeof err,});}- if (_selectedAgent?.id !== agent.agent_id || slot.dataset.runtimeKey !== runtimeKey) return;+ if (_selectedAgent?.id !== agent.agent_id || slot.dataset.runtimeKey !== runtimeKey+ || pendingMount.parentElement !== slot) return;slot.innerHTML = '';const available = entries.filter(e => e.available);diff --git a/test/e2e/cli_upgrade_e2e_recovery.spec.ts b/test/e2e/cli_upgrade_e2e_recovery.spec.tsindex 4b19f6be..e49e3ca1 100644--- a/test/e2e/cli_upgrade_e2e_recovery.spec.ts+++ b/test/e2e/cli_upgrade_e2e_recovery.spec.ts@@ -186,6 +186,8 @@ else if (process.argv.slice(2).join(' ') === 'update') {`); chmodSync(file, 0o755);}symlinkSync(path.join(directory, '2.1.112'), bin);+ // Finish any startup probe before replacing its fixture executable.+ await app.invoke('localAgents.detect', { type: 'claude' });await app.electronApp!.evaluate((_electron, file) => { process.env.ORKAS_CLAUDE_PATH = file; }, bin);const detected = await app.invoke<any>('localAgents.detect', { type: 'claude' });expect(detected.entry).toMatchObject({ available: true, version: '2.1.112' });@@ -205,6 +207,48 @@ else if (process.argv.slice(2).join(' ') === 'update') {expect(readFileSync(calls, 'utf8')).toBe('update\n');expect(app.readCliState().invocations).toHaveLength(0);await page.screenshot({ path: testInfo.outputPath('12-claude-upgrade-success.png') });+ // Hold discovery at the renderer boundary after a real native update. A+ // locale refresh must retain that feedback, and older completions must not+ // replace the version displayed by the latest refresh.+ const response = await app.invoke<any>('agents.get', { agent_id: created.agent.agent_id });+ await page.evaluate(agent => {+ const w = window as any;+ w.__upgradeDiscoveryOriginal = w.loadLocalCliEntries;+ w.__upgradeDiscoveries = [];+ w.loadLocalCliEntries = () => new Promise(resolve => w.__upgradeDiscoveries.push(resolve));+ w.__upgradeRefreshes = [w._renderAgentDetailRuntime(agent), w._renderAgentDetailRuntime(agent)];+ }, response.agent);+ try {+ await expect(control.locator('[role="status"]')).toHaveText('升级成功');+ await expect(page.locator('#agents-detail-runtime .ai-select-trigger')).toBeDisabled();+ await page.screenshot({ path: testInfo.outputPath('13-pending-feedback-zh.png') });+ await page.setViewportSize({ width: 1000, height: 700 });+ await page.evaluate(async () => { await (window as any).setLang('en'); });+ await expect.poll(() => page.evaluate(() => (window as any).__upgradeDiscoveries.length)).toBe(3);+ await expect(control.locator('[role="status"]')).toHaveText('Upgrade successful');+ await expect(control.locator('button')).toHaveText('Upgrade CLI');+ await page.screenshot({ path: testInfo.outputPath('14-pending-feedback-en-narrow.png') });+ await page.evaluate(async () => {+ const w = window as any;+ w.__upgradeDiscoveries[2]([{ type: 'claude', available: true, version: '2.1.113' }]);+ await Promise.resolve();+ for (const resolve of w.__upgradeDiscoveries.slice(0, 2)) {+ resolve([{ type: 'claude', available: true, version: '2.1.112' }]);+ }+ await Promise.all(w.__upgradeRefreshes);+ });+ await expect(page.locator('#agents-detail-runtime .ai-select-trigger')).toContainText('2.1.113');+ await expect(control.locator('[role="status"]')).toHaveText('Upgrade successful');+ await expect(control.locator('button')).toBeEnabled();+ expect(readFileSync(calls, 'utf8')).toBe('update\n');+ expect(app.readCliState().invocations).toHaveLength(0);+ } finally {+ await page.evaluate(() => {+ const w = window as any;+ w.loadLocalCliEntries = w.__upgradeDiscoveryOriginal;+ delete w.__upgradeDiscoveryOriginal; delete w.__upgradeDiscoveries; delete w.__upgradeRefreshes;+ });+ }});diff --git a/test/renderer/agents-detail-layout.test.ts b/test/renderer/agents-detail-layout.test.tsindex 383c998c..9775c6c5 100644--- a/test/renderer/agents-detail-layout.test.ts+++ b/test/renderer/agents-detail-layout.test.ts@@ -1,6 +1,7 @@import fs from 'node:fs';import path from 'node:path';import vm from 'node:vm';+import ts from 'typescript';import { describe, expect, it } from 'vitest';@@ -175,6 +176,64 @@ describe('external CLI Agent detail layout', () => {expect(settings).toContain('_mergeAgentIntoCache(saved.agent)');expect(settings).not.toContain('_agentsCache = null');});+ it.each([false, true])('retains upgrade feedback and current discovery across overlapping detail refreshes (older first: %s)', async olderFirst => {+ const source = fs.readFileSync(path.join(rendererRoot, 'modules/agents.js'), 'utf8');+ const ast = ts.createSourceFile('agents.js', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);+ const entry = ast.statements.find(node => ts.isFunctionDeclaration(node) && node.name?.text === '_renderAgentDetailRuntime');+ expect(entry).toBeDefined();+ // A minimal DOM ownership double; the native CLI E2E separately verifies+ // the real controls, locale text and installer invocation count.+ class Element {+ dataset: Record<string, string> = {};+ style: Record<string, string> = {};+ className = '';+ parentElement: Element | null = null;+ children: Element[] = [];+ options: Array<{ value: string; label: string }> = [];+ set innerHTML(_html: string) { for (const child of this.children) child.parentElement = null; this.children = []; }+ appendChild(child: Element) {+ if (child.parentElement) child.parentElement.children = child.parentElement.children.filter(node => node !== child);+ child.parentElement = this; this.children.push(child); return child;+ }+ querySelector(selector: string): Element | null {+ for (const child of this.children) {+ if (child.className.split(' ').includes(selector.slice(1))) return child;+ const nested = child.querySelector(selector); if (nested) return nested;+ }+ return null;+ }+ setAttribute() {}+ }+ const slot = new Element(), section = new Element(), feedback = new Element();+ slot.dataset.runtimeKey = 'one::claude';+ feedback.className = 'local-cli-upgrade-control'; feedback.dataset.state = 'success';+ slot.appendChild(feedback);+ const resolveDiscovery: Array<(entries: unknown[]) => void> = [];+ const context = vm.createContext({+ document: { getElementById: (id: string) => id.endsWith('-section') ? section : slot, createElement: () => new Element() },+ _selectedAgent: { id: 'one' }, _agentsLog: { warn() {} }, t: (key: string) => key,+ loadLocalCliEntries: () => new Promise(resolve => { resolveDiscovery.push(resolve); }),+ window: { createLocalCliUpgradeControl: () => {+ const empty = new Element(); empty.className = 'local-cli-upgrade-control'; return empty;+ } },+ _aiSelectMount: (mount: Element, { options }: { options: Element['options'] }) => {+ mount.options = options; const trigger = new Element(); trigger.className = 'ai-select-trigger'; mount.appendChild(trigger);+ },+ });+ vm.runInContext(entry!.getText(ast), context);+ const agent = { agent_id: 'one', runtime: { kind: 'cli', cli: 'claude' } };+ const runs = [context._renderAgentDetailRuntime(agent), context._renderAgentDetailRuntime(agent)];+ expect.soft(slot.querySelector('.local-cli-upgrade-control')).toBe(feedback);+ for (const index of olderFirst ? [0, 1] : [1, 0]) {+ resolveDiscovery[index]([{ type: 'claude', available: true, version: index === 0 ? '2.1.112' : '2.1.113' }]);+ await runs[index];+ }+ expect(slot.querySelector('.local-cli-upgrade-control')).toBe(feedback);+ expect(slot.querySelector('.local-cli-upgrade-control')?.dataset.state).toBe('success');+ expect(slot.querySelector('.agents-detail-runtime-select')?.options[0].label).toContain('2.1.113');+ });++});// The picker is what a user reads before pinning an Agent to a model, so the