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(home): open linked to-dos on their cards

wytbaeae7b55e61
diff --git a/src/renderer/modules/home.js b/src/renderer/modules/home.js
index dbce54b5..41344086 100644
--- a/src/renderer/modules/home.js
+++ b/src/renderer/modules/home.js
@@ -255,9 +255,6 @@ function _homeTodoRowHtml(task, index) {
'data-home-pid': pid,
'data-home-status': status,
'data-home-position': index + 1,
- // The conversation this to-do belongs to (saved from it, or last run in
- // it). Opening the row returns there when that conversation still exists.
- ...(task.origin_cid ? { 'data-home-origin-cid': String(task.origin_cid) } : {}),
},
status,
icon: 'clipboard-list',
@@ -410,34 +407,9 @@ function _homeOpenRun(row) {
setView('conversation', cid, { entryPoint: 'home' });
}
-// Whether a conversation can still be opened: the sidebar cache first, then one
-// read-only lookup. A failed lookup counts as missing so the row falls back to
-// the To-dos page.
-async function _homeConversationExists(cid) {
- if (!cid) return false;
- const rows = typeof conversations !== 'undefined' && Array.isArray(conversations) ? conversations : [];
- if (rows.some((c) => c && c.conversation_id === cid)) return true;
- try {
- const res = await window.orkas.invoke('conversations.getMany', { cids: [cid] });
- return ((res && res.conversations) || []).some((row) => row && row.conversation_id === cid);
- } catch (err) {
- _homeLog.warn('to-do conversation lookup failed', { error_type: _homeErrorType(err) });
- return false;
- }
-}
-
async function _homeOpenTodo(row) {
const pid = row.dataset.homePid || '';
const id = row.dataset.homeTodo || '';
- const originCid = row.dataset.homeOriginCid || '';
- const openConversation = !!originCid && await _homeConversationExists(originCid);
- // A to-do that belongs to a conversation returns the user there, so the
- // work continues with that conversation's plan and history. Nothing is
- // prefilled; the user decides what to send.
- if (openConversation) {
- setView('conversation', originCid, { entryPoint: 'home' });
- return;
- }
// The To-dos page code loads with the page; load it first so the page can
// open on this to-do.
try {
diff --git a/test/e2e/home_e2e_continuation.spec.ts b/test/e2e/home_e2e_continuation.spec.ts
index 511548e9..ecca79ee 100644
--- a/test/e2e/home_e2e_continuation.spec.ts
+++ b/test/e2e/home_e2e_continuation.spec.ts
@@ -1,4 +1,5 @@
import { expect, test } from './fixtures/orkas';
+import path from 'node:path';
// Commander home (PATTERNS.md P15): an open to-do or a finished run the user
// has not opened turns the New task view into its populated state. The
@@ -132,4 +133,64 @@ test.describe('Commander home continuation', () => {
await expect(appPage.locator('#panel-todos')).toHaveClass(/\bactive\b/);
await expect(appPage.locator('#todos-content .project-todo-item.is-highlighted')).toHaveCount(1);
});
+
+ for (const language of ['en', 'zh']) {
+ test(`opens linked to-dos on their cards and keeps the conversation as a card action (${language})`, async ({ orkas }, testInfo) => {
+ const page = orkas.page!;
+ await page.evaluate(lang => (window as any).setLang(lang), language);
+ await page.setViewportSize({ width: language === 'en' ? 1440 : 1024, height: language === 'en' ? 900 : 720 });
+ const { project } = await orkas.invoke<any>('projects.create', { name: language === 'en' ? 'Release checks' : '发布核对' });
+ const linked: Array<{ pid: string; tid: string; cid: string; title: string }> = [];
+ for (const pid of ['', project.project_id]) {
+ const title = pid ? 'Project execution history' : 'Global execution history';
+ const { conversation } = await orkas.invoke<any>('conversations.create', { title, projectId: pid });
+ const { task } = await orkas.invoke<any>('projects.tasks.create', { projectId: pid, status: 'progress',
+ content: language === 'en'
+ ? 'Review installation and cross-device synchronization before completing the release checklist'
+ : '核对安装流程与多设备同步状态,确认发布检查清单中的问题已处理完成' });
+ linked.push({ pid, tid: task.id, cid: conversation.conversation_id, title });
+ }
+ // Represent prior successful executions without running an agent. The
+ // actual task module saves these facts in the isolated installation.
+ await orkas.electronApp!.evaluate(async (_electron, input) => {
+ const load = (process as any).mainModule.require.bind((process as any).mainModule);
+ const path = load('node:path');
+ const uid = load(path.join(input.sourceRoot, 'features/users.ts')).getActiveUserId();
+ const { updateTask } = load(path.join(input.sourceRoot, 'features/project_tasks.ts'));
+ for (const row of input.linked) {
+ const result = await updateTask(uid, row.pid, row.tid, { origin_cid: row.cid });
+ if (!result.ok) throw new Error('Could not seed the prior execution link');
+ }
+ }, { sourceRoot: path.resolve(__dirname, '../../src/main'), linked });
+
+ for (const row of linked) {
+ await page.locator('#new-chat-btn').click();
+ // The page focuses its composer shortly after entry. Start keyboard
+ // navigation after that transition rather than racing its focus.
+ await expect(page.locator('#new-chat-input')).toBeFocused();
+ const shortcut = page.locator(`[data-home-todo="${row.tid}"]`);
+ await expect(shortcut).toBeVisible();
+ if (row.pid) await page.screenshot({ path: testInfo.outputPath(`home-linked-todos-${language}.png`) });
+ await shortcut.press('Enter');
+ await expect(page.locator('#panel-todos')).toHaveClass(/\bactive\b/);
+ const card = page.locator(`#todos-content .project-todo-item[data-tid="${row.tid}"]`);
+ await expect(card).toHaveClass(/\bis-highlighted\b/);
+ await expect(card).toBeInViewport();
+ if (row.pid) await page.screenshot({ path: testInfo.outputPath(`home-todo-card-${language}.png`) });
+
+ // A collapsed column must still reveal the target after a repeat visit.
+ await page.locator('#todos-content .todo-column.is-progress .todo-collapse').click();
+ await expect(card).toBeHidden();
+ await page.locator('#new-chat-btn').click();
+ await shortcut.click();
+ await expect(card).toBeVisible();
+ await expect(card).toHaveClass(/\bis-highlighted\b/);
+ const conversation = card.locator('[data-action="todo-conversation"]');
+ await expect(conversation).toBeVisible();
+ await conversation.press('Enter');
+ await expect(page.locator('#panel-conversation')).toHaveClass(/\bactive\b/);
+ await expect(page.locator('#chat-header-title')).toHaveText(row.title);
+ }
+ });
+ }
});
diff --git a/test/renderer/home.test.ts b/test/renderer/home.test.ts
index aba5a522..dd650d11 100644
--- a/test/renderer/home.test.ts
+++ b/test/renderer/home.test.ts
@@ -370,7 +370,7 @@ describe('Commander home states', () => {
expect(h.views.slice(1)).toEqual([['auto', null, { entryPoint: 'home' }], ['todos', null, { entryPoint: 'home' }]]);
});
- it('returns to the conversation a to-do belongs to, and falls back to the To-dos page when it is gone', async () => {
+ it('opens linked global and project to-dos on their cards even when the conversation exists or is gone', async () => {
const h = loadHome({
todos: { total: 2, tasks: [
{ id: 't-saved', project_id: '', status: 'todo', content: 'Write chapter 3', origin_cid: 'conv-origin' },
@@ -381,23 +381,28 @@ describe('Commander home states', () => {
});
h.context.homeOnEnter();
await h.settle();
- expect(h.html()).toContain('data-home-origin-cid="conv-origin"');
-
- h.els['home-groups'].fire('click', click({
- '.home-row': { dataset: { homeTodo: 't-saved', homePid: '', homeStatus: 'todo', homePosition: '1', homeOriginCid: 'conv-origin' } },
- }));
- await h.settle();
- // Back to the original conversation, with nothing prefilled.
- expect(h.views).toEqual([['conversation', 'conv-origin', { entryPoint: 'home' }]]);
- expect(h.context.focusTodo).not.toHaveBeenCalled();
+ const readsBeforeOpen = h.invokes.length;
+ for (const [index, task] of h.data().todos.entries()) {
+ h.els['home-groups'].fire('click', click({
+ '.home-row': { dataset: { homeTodo: task.id, homePid: task.project_id, homeStatus: task.status,
+ homePosition: String(index + 1), homeOriginCid: task.origin_cid } },
+ }));
+ await h.settle();
+ expect(h.context.focusTodo).toHaveBeenNthCalledWith(index + 1, task.project_id, task.id, { entryPoint: 'home' });
+ }
+ expect(h.views).toEqual([]);
+ // Opening a to-do must not depend on reading its execution conversation.
+ expect(h.invokes.slice(readsBeforeOpen)).toEqual([]);
+ });
- h.els['home-groups'].fire('click', click({
- '.home-row': { dataset: { homeTodo: 't-gone', homePid: 'p1', homeStatus: 'progress', homePosition: '2', homeOriginCid: 'conv-deleted' } },
- }));
- await h.settle();
- expect(h.context.focusTodo).toHaveBeenCalledWith('p1', 't-gone', { entryPoint: 'home' });
- expect(h.invokes.some(([channel, payload]) => channel === 'conversations.getMany'
- && JSON.stringify(payload.cids) === JSON.stringify(['conv-deleted']))).toBe(true);
+ it.each(['unavailable', 'failed'])('opens the To-dos page when its card locator is %s', async state => {
+ const h = loadHome();
+ h.context.focusTodo = undefined;
+ if (state === 'failed') h.context.loadRendererFeature.mockRejectedValueOnce(new Error('controlled feature load failure'));
+ else h.context.loadRendererFeature = undefined;
+ await h.context._homeOpenTodo({ dataset: { homeTodo: 't_saved', homePid: 'p1', homeOriginCid: 'linked-chat' } });
+ expect(h.views).toEqual([['todos', null, { entryPoint: 'home' }]]);
+ expect(h.invokes).toEqual([]);
});
it('hides only the group whose lookup failed', async () => {