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(todos): accept pasted files in the editor
BlueSkyID666ef174d5dac4e
diff --git a/src/renderer/modules/project-detail.js b/src/renderer/modules/project-detail.jsindex b05bacdc..c7de9d9c 100644--- a/src/renderer/modules/project-detail.js+++ b/src/renderer/modules/project-detail.js@@ -2017,6 +2017,13 @@ function _bindProjectTodos() {if (input && input.dataset.bound !== '1') {input.dataset.bound = '1';input.addEventListener('input', _updateProjectTodoEditor);+ input.addEventListener('paste', (event) => {+ if (_todoEditorPid === null) return;+ const files = event.clipboardData?.files;+ if (!files?.length) return;+ event.preventDefault();+ void _todoPickAndUploadFiles(files);+ });input.addEventListener('keydown', (e) => {if (e.isComposing || e.keyCode === 229) return; // IME composition guardif (e.key === 'Escape') {diff --git a/test/e2e/todos_e2e_attachment_input.spec.ts b/test/e2e/todos_e2e_attachment_input.spec.tsnew file mode 100644index 00000000..e1fcf5eb--- /dev/null+++ b/test/e2e/todos_e2e_attachment_input.spec.ts@@ -0,0 +1,108 @@+import { existsSync, readFileSync } from 'node:fs';+import { expect, OrkasTestApp, test as base } from './fixtures/orkas';++// Attachment input exercises local storage rather than GPU composition.+const test = base.extend({+ orkas: async ({}, use, testInfo) => {+ const app = new OrkasTestApp(testInfo, { softwareRendering: true });+ try { await app.launch(); await use(app); } finally { await app.dispose(); }+ },+});++for (const scope of ['global', 'project'] as const) {+ test(`adds pasted and dropped files to a ${scope} todo and preserves their bytes on Save`, async ({ orkas }, info) => {+ const page = orkas.page!;+ await page.evaluate(() => (window as any).setLang('en'));+ const project = scope === 'project' ? await orkas.invoke<any>('projects.create', { name: 'Attachment project' }) : null;+ const projectId = project?.project.project_id || '';+ if (projectId) {+ await page.evaluate(async (pid) => { await (window as any).setView('project', pid); }, projectId);+ const todoTab = page.locator('[data-project-tab="todo"]');+ await expect(todoTab).toHaveAttribute('data-bound', '1');+ await todoTab.click();+ await page.locator('#project-todo-add-btn').click();+ } else {+ await page.locator('#todos-btn').click();+ await page.locator('#todos-add-btn').click();+ }+ const input = page.locator('#project-todo-input');+ await input.fill('Review the attached files');+ const pasteHandled = await input.evaluate((element) => {+ const clipboard = new DataTransfer();+ clipboard.items.add(new File(['Pasted document bytes'], 'pasted.txt', { type: 'text/plain' }));+ clipboard.items.add(new File(['Second pasted document'], 'second.md', { type: 'text/markdown' }));+ const event = new ClipboardEvent('paste', { bubbles: true, cancelable: true, clipboardData: clipboard });+ element.dispatchEvent(event);+ return event.defaultPrevented;+ });+ expect(pasteHandled).toBe(true);+ const chips = page.locator('#project-todo-attachments .chat-attach-chip');+ await expect(chips).toHaveCount(2);+ await expect(page.locator('#project-todo-attachments .is-uploading')).toHaveCount(0);++ // Dropping directly on the textarea bubbles to the generous composer target.+ const dropHandled = await input.evaluate((element) => {+ const transfer = new DataTransfer();+ transfer.items.add(new File(['Dropped document bytes'], 'dropped.txt', { type: 'text/plain' }));+ const handled = [];+ for (const type of ['dragenter', 'dragover', 'drop']) {+ const event = new DragEvent(type, { bubbles: true, cancelable: true, dataTransfer: transfer });+ element.dispatchEvent(event);+ handled.push(event.defaultPrevented);+ }+ return handled;+ });+ expect(dropHandled).toEqual([true, true, true]);+ await expect(chips).toHaveCount(3);+ await expect(page.locator('#project-todo-attachments .is-uploading')).toHaveCount(0);+ await expect(input).toHaveValue('Review the attached files');+ await expect(page.locator('#project-todo-composer')).not.toHaveClass(/drag-over/);+ await page.locator('#todo-editor-modal').screenshot({ path: info.outputPath('pasted-and-dropped-attachments.png') });+ await page.locator('#project-todo-save').click();+ await expect(page.locator('#todo-editor-modal')).not.toHaveClass(/\bopen\b/);+ const saved = await orkas.invoke<any>('projects.tasks.list', { projectId });+ const task = saved.tasks.find((item: any) => item.content === 'Review the attached files');+ expect(task.attachments.slice().sort()).toEqual(['dropped.txt', 'pasted.txt', 'second.md']);+ for (const [name, body] of [+ ['pasted.txt', 'Pasted document bytes'], ['second.md', 'Second pasted document'], ['dropped.txt', 'Dropped document bytes'],+ ]) {+ const file = await orkas.invoke<any>('projects.tasks.attachments.absPath', { projectId, taskId: task.id, name });+ expect(file.ok).toBe(true);+ expect(readFileSync(file.path, 'utf8')).toBe(body);+ }+ });+}++test('keeps ordinary text paste native and discards pasted draft attachments on Cancel', async ({ orkas }) => {+ const page = orkas.page!;+ await page.locator('#todos-btn').click();+ await page.locator('#todos-add-btn').click();+ const input = page.locator('#project-todo-input');+ const textHandled = await input.evaluate((element) => {+ const clipboard = new DataTransfer();+ clipboard.setData('text/plain', 'Ordinary pasted text');+ const event = new ClipboardEvent('paste', { bubbles: true, cancelable: true, clipboardData: clipboard });+ element.dispatchEvent(event);+ return event.defaultPrevented;+ });+ expect(textHandled).toBe(false);+ await expect(page.locator('#project-todo-attachments .chat-attach-chip')).toHaveCount(0);+ await input.evaluate((element) => {+ const clipboard = new DataTransfer();+ clipboard.items.add(new File(['Cancelled attachment bytes'], 'cancelled.txt', { type: 'text/plain' }));+ element.dispatchEvent(new ClipboardEvent('paste', { bubbles: true, cancelable: true, clipboardData: clipboard }));+ });+ const chip = page.locator('#project-todo-attachments .chat-attach-chip');+ await expect(chip).toContainText('cancelled.txt');+ await expect(chip).not.toHaveClass(/is-uploading/);+ const taskId = await page.evaluate(() => eval('_todoEditorTid'));+ const file = await orkas.invoke<any>('projects.tasks.attachments.absPath', { taskId, name: 'cancelled.txt' });+ expect(file.ok).toBe(true);+ await page.locator('#project-todo-cancel').click();+ await expect.poll(() => existsSync(file.path)).toBe(false);+ const saved = await orkas.invoke<any>('projects.tasks.list', {});+ expect(saved.tasks.some((task: any) => task.id === taskId)).toBe(false);+ await page.locator('#todos-add-btn').click();+ await expect(page.locator('#project-todo-attachments .chat-attach-chip')).toHaveCount(0);+ await page.locator('#project-todo-cancel').click();+});