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(automation): show background runs as running in the sidebar

BlueSkyID666938c582315e9
diff --git a/src/renderer/modules/auto-events.js b/src/renderer/modules/auto-events.js
index 429ea7ea..2178b078 100644
--- a/src/renderer/modules/auto-events.js
+++ b/src/renderer/modules/auto-events.js
@@ -45,6 +45,12 @@ function _autoEventsOpenSubscription() {
Promise.resolve(loadConversations())
.catch(() => _autoEventsLog.warn('reload after fire failed'));
}
+ // Main started this run, so no renderer send is observing it. Attach
+ // the run observer like a project auto-advance does, so the sidebar
+ // row shows it running without the user opening it first.
+ if (inner.cid && typeof _observeConversationRunFromPlanAction === 'function') {
+ _observeConversationRunFromPlanAction(inner.cid, { attachExisting: true, allowWithController: true });
+ }
} else if (inner.type !== 'fire_failed') {
return;
}
diff --git a/test/e2e/automation_e2e_crud.spec.ts b/test/e2e/automation_e2e_crud.spec.ts
index 39db2752..b41098cd 100644
--- a/test/e2e/automation_e2e_crud.spec.ts
+++ b/test/e2e/automation_e2e_crud.spec.ts
@@ -227,6 +227,34 @@ test.describe('automation', () => {
expect(modelOrkas.modelRequests).toHaveLength(1);
});
+ test('shows a scheduled run as running before opening its conversation', async ({ modelOrkas }, testInfo) => {
+ const page = modelOrkas.page!;
+ modelOrkas.setModelMode('controlled-slow');
+ const created = await modelOrkas.invoke<{ task: AutoTask }>('autoTasks.create', {
+ content: 'Summarize the release checks',
+ title: 'Scheduled status check',
+ schedule: { type: 'one_time', at: new Date(Date.now() + 1_500).toISOString() },
+ });
+ let cid = '';
+ await expect.poll(async () => {
+ const result = await modelOrkas.invoke<{
+ conversations: Array<{ conversation_id: string; origin_auto_task_id?: string }>;
+ }>('conversations.list');
+ cid = result.conversations.find(item => item.origin_auto_task_id === created.task.id)?.conversation_id || '';
+ return cid;
+ }, { timeout: 30_000 }).not.toBe('');
+ await expect.poll(() => modelOrkas.modelRequests.length).toBe(1);
+ const row = page.locator(`#conversation-list .conv-item[data-cid="${cid}"]`);
+ await expect(row).toBeVisible();
+ await expect(row.locator('.conv-status-badge.is-streaming')).toBeVisible();
+ await expect(page.locator('#panel-new-chat')).toHaveClass(/\bactive\b/);
+ await page.screenshot({ path: testInfo.outputPath('scheduled-running-status.png') });
+ modelOrkas.releaseControlledModelChunk();
+ modelOrkas.finishControlledModelStream();
+ await expect(row.locator('.conv-status-badge.is-streaming')).toHaveCount(0);
+ expect(modelOrkas.modelRequests).toHaveLength(1);
+ });
+
test('fires while the runnable app is locked or idle', async ({ modelOrkas }) => {
if (!modelOrkas.page) throw new Error('Orkas renderer is unavailable');
const page = modelOrkas.page;
diff --git a/test/renderer/auto-events.test.ts b/test/renderer/auto-events.test.ts
index 7069b440..43fe4c15 100644
--- a/test/renderer/auto-events.test.ts
+++ b/test/renderer/auto-events.test.ts
@@ -22,6 +22,7 @@ function createHarness() {
const monitorError = vi.fn();
const loadConversations = vi.fn(async () => {});
const loadAutoList = vi.fn(async () => {});
+ const observeRun = vi.fn();
const warn = vi.fn();
const stream = vi.fn((_name: string, _payload: unknown, callback: (event: unknown) => void) => {
let resolvePromise!: () => void;
@@ -53,6 +54,7 @@ function createHarness() {
createLogger: () => ({ warn }),
loadConversations,
loadAutoList,
+ _observeConversationRunFromPlanAction: observeRun,
_autoLoadedOnce: true,
setTimeout,
clearTimeout,
@@ -69,6 +71,7 @@ function createHarness() {
monitorError,
loadConversations,
loadAutoList,
+ observeRun,
warn,
};
}
@@ -133,6 +136,30 @@ describe('automation event subscription', () => {
expect(harness.monitorEvent).not.toHaveBeenCalled();
});
+ // A fire creates and starts its conversation in main, so the renderer never
+ // sent it. Without an observer the sidebar row stays idle until the user
+ // opens it, unlike a run the user started.
+ it.each([
+ ['on time', {}],
+ ['caught up after wake', { catch_up: true }],
+ ])('shows a run that main started %s as running in the sidebar', (_label, mark) => {
+ const harness = createHarness();
+ harness.window.startAutoEventsSubscription();
+ harness.streamRecords[0].callback({
+ event: { type: 'conv_created', source: 'scheduled', ...mark, user_id: 'account-b', task_id: 'b', cid: 'foreign' },
+ });
+ harness.streamRecords[0].callback({
+ event: { type: 'fire_failed', source: 'scheduled', ...mark, user_id: 'account-a', task_id: 'a', error_code: 'send_not_ok' },
+ });
+ expect(harness.observeRun).not.toHaveBeenCalled();
+
+ harness.streamRecords[0].callback({
+ event: { type: 'conv_created', source: 'scheduled', ...mark, user_id: 'account-a', task_id: 'a', cid: 'fired' },
+ });
+ expect(harness.observeRun).toHaveBeenCalledTimes(1);
+ expect(harness.observeRun).toHaveBeenCalledWith('fired', expect.objectContaining({ attachExisting: true }));
+ });
+
it('never reports telemetry from the best-effort UI stream', () => {
const harness = createHarness();
harness.window.startAutoEventsSubscription();