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(chat): reposition Library picker after async loading
CloudTianTian912884d80ab1
diff --git a/src/renderer/modules/agents.js b/src/renderer/modules/agents.jsindex 31fb15b4..d5cd73e2 100644--- a/src/renderer/modules/agents.js+++ b/src/renderer/modules/agents.js@@ -4233,7 +4233,9 @@ function _renderLibraryPickerList(listEl, filterText, anchorId) {const picker = document.getElementById('agent-picker');if (!picker || picker.style.display === 'none' || _agentPickerTab !== 'library') return;const search = document.getElementById('agent-picker-search');- _renderLibraryPickerList(listEl, search ? search.value : filterText, anchorId);+ // Use the shared repaint boundary so placement measures the loaded rows,+ // not the shorter loading shell that was visible before this response.+ _renderAgentPickerList(search ? search.value : filterText);});return;}diff --git a/test/renderer/agent-picker-cli-entry.test.ts b/test/renderer/agent-picker-cli-entry.test.tsindex d928de3f..f92821a8 100644--- a/test/renderer/agent-picker-cli-entry.test.ts+++ b/test/renderer/agent-picker-cli-entry.test.ts@@ -134,7 +134,6 @@ describe('agent picker › coding-CLI entry hand-off', () => {};context.window = context;vm.createContext(context);- vm.runInContext(extractFunction('_agentsTrackClick'), context);vm.runInContext(extractFunction('bindAgentPickers'), context);vm.runInContext('bindAgentPickers();', context);return { context, cliEntry };diff --git a/test/renderer/category-tabs.test.ts b/test/renderer/category-tabs.test.tsindex a7bac3d6..bf8b63f2 100644--- a/test/renderer/category-tabs.test.ts+++ b/test/renderer/category-tabs.test.ts@@ -119,6 +119,79 @@ function loadCategoryRenderers() {return { context, el };}+describe('Library picker asynchronous placement', () => {+ function pendingLibrary() {+ const h = loadCategoryRenderers();+ const { context, el } = h;+ const picker = el('agent-picker');+ const list = el('agent-picker-list');+ const anchor = el('chat-recipient-chip');+ picker.style.display = 'flex';+ picker.dataset.anchorId = 'chat-recipient-chip';+ anchor.className = 'chat-input-area';+ anchor.getBoundingClientRect = () => ({ left: 200, right: 320, top: 500, bottom: 620, width: 120, height: 120 });+ context.window.innerHeight = 680;+ // Model the loading shell and populated box sizes; production placement+ // must measure again after the deferred response changes the content.+ picker.getBoundingClientRect = () => {+ const naturalHeight = list.innerHTML.includes('data-kind="library"') ? 560 : 120;+ const height = Math.min(naturalHeight, parseFloat(picker.style.maxHeight) || Infinity);+ const top = parseFloat(picker.style.top) || 0;+ return { left: 200, right: 540, top, bottom: top + height, width: 340, height };+ };+ let resolveTree!: (value: unknown) => void;+ const tree = new Promise((resolve) => { resolveTree = resolve; });+ context.apiFetch = async () => ({ json: () => tree });+ vm.runInContext('_agentPickerTab = "library"; _renderAgentPickerList("")', context);+ return {+ ...h, picker, list,+ finish: async () => {+ resolveTree({ ok: true, tree: [+ { type: 'file', name: 'brief.md', relPath: 'brief.md' },+ { type: 'file', name: 'notes.md', relPath: 'notes.md' },+ ] });+ await vm.runInContext('_pickerLibraryLoading', context);+ },+ };+ }++ it('keeps loaded files above the composer and within the viewport', async () => {+ const h = pendingLibrary();+ expect(h.list.innerHTML).toContain('加载中');+ expect(h.picker.getBoundingClientRect().bottom).toBeLessThan(500);++ await h.finish();++ expect(h.list.innerHTML).toContain('brief.md');+ expect(h.list.innerHTML).toContain('notes.md');+ const bounds = h.picker.getBoundingClientRect();+ expect(bounds.top).toBeGreaterThanOrEqual(12);+ expect(bounds.bottom).toBeLessThanOrEqual(492);+ expect(h.picker.dataset.placement).toBe('top');+ });++ it('uses the current search when files arrive and repositions the result', async () => {+ const h = pendingLibrary();+ (h.el('agent-picker-search') as any).value = 'brief';+ h.context._renderAgentPickerList('brief');+ await h.finish();+ expect(h.list.innerHTML).toContain('brief.md');+ expect(h.list.innerHTML).not.toContain('notes.md');+ expect(h.picker.getBoundingClientRect().bottom).toBeLessThanOrEqual(492);+ });++ it.each(['close', 'switch tab'])('does not revive Library after %s while loading', async (action) => {+ const h = pendingLibrary();+ if (action === 'close') h.context._closeAgentPicker();+ else vm.runInContext('_agentPickerTab = "connectors"; _renderAgentPickerList("")', h.context);+ const content = h.list.innerHTML;+ const style = { ...h.picker.style };+ await h.finish();+ expect(h.list.innerHTML).toBe(content);+ expect(h.picker.style).toEqual(style);+ });+});+describe('agent and skill category tabs', () => {it('maps missing and non-registry agent categories to General instead of Unknown', () => {const { context, el } = loadCategoryRenderers();