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
import { describe, expect, it } from 'vitest';
import * as fs from 'node:fs';
import * as path from 'node:path';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const auto = require('../../src/renderer/modules/auto.js') as {
_autoDisplayDeviceName: (name: string) => string;
_autoIsTaskOnCurrentDevice: (task: { device_id?: string }, device: { id: string }) => boolean;
_autoCanTransferTaskToCurrentDevice: (task: { device_id?: string }, device: { id: string } | null) => boolean;
_autoRunDeviceOptions: (
task: { device_id?: string; device_name?: string },
device: { id: string },
translate: (key: string) => string,
) => Array<{ value: string; label: string }>;
};
const rendererRoot = path.resolve(__dirname, '../../src/renderer');
describe('auto device display name', () => {
it('strips the mDNS .local suffix from hostnames', () => {
expect(auto._autoDisplayDeviceName('claw2deMac-mini.local')).toBe('claw2deMac-mini');
expect(auto._autoDisplayDeviceName('Desk.LOCAL.')).toBe('Desk');
});
it('leaves non-mDNS identifiers unchanged', () => {
expect(auto._autoDisplayDeviceName('aa:bb:cc:dd:ee:ff')).toBe('aa:bb:cc:dd:ee:ff');
expect(auto._autoDisplayDeviceName('workstation.localdomain')).toBe('workstation.localdomain');
});
it('offers a transfer only for tasks assigned to another device', () => {
const current = { id: 'aa:bb:cc:dd:ee:ff' };
expect(auto._autoIsTaskOnCurrentDevice({ device_id: current.id }, current)).toBe(true);
expect(auto._autoCanTransferTaskToCurrentDevice({ device_id: current.id }, current)).toBe(false);
expect(auto._autoCanTransferTaskToCurrentDevice({ device_id: '11:22:33:44:55:66' }, current)).toBe(true);
});
it('keeps legacy unstamped tasks local and hides transfer without device context', () => {
const current = { id: 'aa:bb:cc:dd:ee:ff' };
expect(auto._autoIsTaskOnCurrentDevice({}, current)).toBe(true);
expect(auto._autoCanTransferTaskToCurrentDevice({}, current)).toBe(false);
expect(auto._autoCanTransferTaskToCurrentDevice({ device_id: '11:22:33:44:55:66' }, null)).toBe(false);
expect(auto._autoCanTransferTaskToCurrentDevice({ device_id: '11:22:33:44:55:66' }, { id: '' })).toBe(false);
});
it('offers the assigned hostname and this device for a remote task', () => {
const current = { id: 'aa:bb:cc:dd:ee:ff' };
const options = auto._autoRunDeviceOptions(
{ device_id: '11:22:33:44:55:66', device_name: 'Remote-Mac.local' },
current,
() => 'This device',
);
expect(options).toEqual([
{ value: 'assigned', label: 'Remote-Mac' },
{ value: 'current', label: 'This device' },
]);
expect(auto._autoRunDeviceOptions({ device_id: current.id }, current, () => 'This device')).toEqual([]);
expect(auto._autoRunDeviceOptions(
{ device_id: '11:22:33:44:55:66' },
{ id: '' },
() => 'This device',
)).toEqual([]);
});
it('places the shared device selector below Project and removes the dialog note', () => {
const html = fs.readFileSync(path.join(rendererRoot, 'index.html'), 'utf8');
const zh = JSON.parse(fs.readFileSync(path.join(rendererRoot, 'locales/zh.json'), 'utf8'));
const projectIndex = html.indexOf('id="auto-row-project"');
const runIndex = html.indexOf('id="auto-row-run-device"');
const titleIndex = html.indexOf('id="auto-title-input"');
expect(projectIndex).toBeGreaterThan(0);
expect(runIndex).toBeGreaterThan(projectIndex);
expect(titleIndex).toBeGreaterThan(runIndex);
expect(html).toContain('id="auto-run-device-select"');
expect(html).not.toContain('id="auto-run-current-device-input"');
expect(html).not.toContain('id="auto-task-dialog-sync-note"');
expect(zh['auto.run_label']).toBe('执行设备');
expect(zh['auto.sync_note_create']).toBeUndefined();
});
it('renders the row action menu as focusable buttons with focus-visible styling', () => {
const source = fs.readFileSync(path.join(rendererRoot, 'modules/auto.js'), 'utf8');
const css = fs.readFileSync(path.join(rendererRoot, 'style.css'), 'utf8');
for (const action of ['run-now', 'toggle-enabled', 'edit', 'delete']) {
expect(source).toMatch(new RegExp(`<button type="button" role="menuitem" class="[^"]*auto-row-menu-item[^"]*" data-action="${action}"`));
}
expect(source).toContain("m.setAttribute('role', 'menu')");
expect(source).toContain("anchorBtn.setAttribute('aria-haspopup', 'menu')");
expect(source).toContain("e.key === 'ArrowDown'");
expect(source).toContain("_closeAutoRowMenu(true)");
expect(source).toContain("menu.querySelector('.auto-row-menu-item')?.focus()");
expect(css).toContain('.auto-row-menu-item:focus-visible');
});
});