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
Keep an active Library rename intact during refresh
wytb9b06316e8d2
diff --git a/src/renderer/modules/contexts.js b/src/renderer/modules/contexts.jsindex 3c54c64e..3462a035 100644--- a/src/renderer/modules/contexts.js+++ b/src/renderer/modules/contexts.js@@ -492,6 +492,14 @@ function renderCtxTree() {_refreshCtxCounts();return;}+ // A background refresh must not remove the live rename input: Electron+ // emits blur on removal, which would submit a draft and interrupt IME.+ // State keeps updating; submission/cancellation clears the pending rename+ // and lets the next render apply the accumulated tree/status changes.+ if (_ctxPendingRename) {+ const input = container.querySelector('.ctx-tree-rename-input');+ if (input?.closest('.ctx-tree-wrap')?.dataset.path === _ctxPendingRename.path) return;+ }if (!_ctxTree.length) {_ctxSelected.clear();_ctxSelectionAnchor = null;diff --git a/test/e2e/library_e2e_search.spec.ts b/test/e2e/library_e2e_search.spec.tsindex 686ff2e2..00f685f7 100644--- a/test/e2e/library_e2e_search.spec.ts+++ b/test/e2e/library_e2e_search.spec.ts@@ -452,6 +452,11 @@ test.describe('library and global search', () => {const renameInput = page.locator('.ctx-tree-rename-input');await expect(renameInput).toBeFocused();await renameInput.fill(renamedName);+ // Indexing can finish while a name is still being edited. Its status+ // refresh must not blur the input or submit the draft on the user's behalf.+ await page.evaluate(async () => (window as any)._refreshKbStatusSnapshot());+ await expect(renameInput).toHaveValue(renamedName);+ await expect(renameInput).toBeFocused();await renameInput.press('Enter');row = page.locator(`.ctx-tree-wrap[data-path="${renamedName}"]`);await expect(row).toBeVisible();diff --git a/test/renderer/contexts-external-drop.test.ts b/test/renderer/contexts-external-drop.test.tsindex f44c7b3e..3873d687 100644--- a/test/renderer/contexts-external-drop.test.ts+++ b/test/renderer/contexts-external-drop.test.ts@@ -99,6 +99,57 @@ function dropEvent(dataTransfer: any, closestEntry: any = null) {};}+describe('Library rename continuity during status refresh', () => {+ it.each([true, false].flatMap(available => ['Enter', 'Escape'].map(key => ({ available, key }))))(+ 'keeps the draft and focus until $key (status available: $available)', async ({ available, key }) => {+ const context = loadContextsScript();+ const listeners: Record<string, Listener> = {};+ const input = {+ value: 'Unsubmitted draft.md',+ closest: () => ({ dataset: { path: 'original.md' } }),+ addEventListener: (name: string, listener: Listener) => { listeners[name] = listener; },+ focus: () => { context.document.activeElement = input; },+ setSelectionRange: vi.fn(),+ };+ let mounted: typeof input | null = input;+ const container = {+ querySelector: () => mounted,+ querySelectorAll: (selector: string) => selector === '.ctx-tree-rename-input' && mounted ? [mounted] : [],+ addEventListener: vi.fn(), dataset: {}, classList: fakeClassList(),+ get innerHTML() { return ''; },+ set innerHTML(_value: string) {+ // Electron emits blur when a focused input is removed by innerHTML.+ // This is the observed failure, not an explicit user submission.+ if (mounted) listeners.blur?.({});+ mounted = null;+ context.document.activeElement = null;+ },+ };+ context.document.getElementById = (id: string) => id === 'contexts-tree' ? container : null;+ context.setTimeout = (callback: () => void) => { callback(); return 0; };+ context._commitInlineRename = vi.fn(async () => {});+ context._ctxFetch = vi.fn(async () => ({ json: async () => available+ ? { ok: true, files: [{ path: 'original.md', status: 'ready' }] }+ : { ok: false, code: 'E_LIBRARY_STATUS_UNAVAILABLE' } }));+ vm.runInContext('_ctxPendingRename = { path: "original.md" }; _ctxTree = [{ type: "file", name: "original.md", path: "original.md" }];', context);+ context._bindCtxTreeHandlers(container);+ input.value = 'Still composing.md';+ await context._refreshKbStatusSnapshot();+ expect(mounted).toBe(input);+ expect(input.value).toBe('Still composing.md');+ expect(context.document.activeElement).toBe(input);+ expect(context._commitInlineRename).not.toHaveBeenCalled();+ listeners.keydown({ key: 'Enter', isComposing: true });+ expect(context._commitInlineRename).not.toHaveBeenCalled();+ listeners.keydown({ key, preventDefault: vi.fn() });+ if (key === 'Enter') expect(context._commitInlineRename).toHaveBeenCalledExactlyOnceWith('original.md', 'Still composing.md');+ else expect(context._commitInlineRename).not.toHaveBeenCalled();+ expect(vm.runInContext('_ctxPendingRename', context)).toBeNull();+ context.renderCtxTree();+ expect(mounted).toBeNull();+ });+});+describe('Library external file drag-and-drop', () => {it('retains hidden and collapsed file status without rebuilding the tree for every event', () => {const context = loadContextsScript();