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.

Keep local project actions and synchronize sidebar selection

wyt357ee1a50e94
diff --git a/src/main/features/projects.ts b/src/main/features/projects.ts
index 620aa21b..77355b01 100644
--- a/src/main/features/projects.ts
+++ b/src/main/features/projects.ts
@@ -310,7 +310,7 @@ async function _readBindings(uid: string, pid: string): Promise<ProjectBindings>
const raw: any = await readJson(f);
return _normaliseBindings(raw);
} catch (err) {
- log.warn(`read bindings user=${uid} pid=${pid}: ${(err as Error).message}`);
+ log.warn('read bindings failed', { pid: maskId(pid), error: logErrorSummary(err) });
return { agents: [] };
}
}
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 22470829..fd9b5ac2 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -689,8 +689,7 @@
<section class="panel" id="panel-project">
<div class="project-detail-view">
<div class="project-detail-content" id="project-detail-content">
- <!-- Local rename and delete use the shared header menu. The
- existing member invite action keeps commercial guidance. -->
+ <!-- Local rename and delete use the shared header menu. -->
<header class="project-detail-header">
<div class="project-detail-header-main">
<div class="project-detail-header-title-row">
@@ -700,7 +699,6 @@
</div>
</div>
<div class="project-detail-actions">
- <button type="button" class="btn btn-sm" id="project-action-invite" data-i18n="project.menu.invite_members">Invite project members</button>
<button type="button" class="btn btn-sm" id="project-action-rename" data-i18n="project.action.done" hidden>Done</button>
<button type="button" class="project-header-icon-btn" id="project-action-more" aria-haspopup="menu"
data-i18n-title="project.menu.more_actions" data-i18n-aria-label="project.menu.more_actions" title="More actions" aria-label="More actions">
diff --git a/src/renderer/modules/auto.js b/src/renderer/modules/auto.js
index 33cf752c..c9dadefd 100644
--- a/src/renderer/modules/auto.js
+++ b/src/renderer/modules/auto.js
@@ -950,7 +950,7 @@ function _autoRenderList() {
const groups = _autoGroupTasks(_autoTasks, projects);
if (!groups.some((group) => group.projectId === _autoActiveScope)) _autoActiveScope = groups[0].projectId;
const switcher = document.createElement('nav');
- switcher.className = 'todo-scope-switcher auto-scope-switcher';
+ switcher.className = 'todo-scope-switcher todo-scroll-track auto-scope-switcher';
switcher.setAttribute('aria-label', t('todo.by_project'));
for (const group of groups) {
const name = group.projectId ? (group.name || t('auto.project_unavailable')) : t('auto.global');
@@ -1080,7 +1080,11 @@ function _autoProjectOptions() {
try {
if (typeof _projectsCache !== 'undefined' && Array.isArray(_projectsCache)) {
for (const p of _projectsCache) {
- if (p && p.project_id) opts.push({ value: p.project_id, label: p.name || p.project_id });
+ if (p && p.project_id) opts.push({
+ value: p.project_id,
+ label: p.name || p.project_id,
+ iconName: typeof window.projectIconName === 'function' ? window.projectIconName(p) : 'folder',
+ });
}
}
} catch (_) { /* ignore */ }
diff --git a/src/renderer/modules/boot.js b/src/renderer/modules/boot.js
index 25c7b4dd..37c5b1c5 100644
--- a/src/renderer/modules/boot.js
+++ b/src/renderer/modules/boot.js
@@ -390,6 +390,7 @@ async function initUser() {
// ─── View routing ───
function setView(view, cid, opts = {}) {
+ const restoreTaskCleanup = window.TaskCleanupNavigation?.beforeNavigate(view, cid, opts) === true;
// A resource detail opened from another page is only a transient overlay.
// Any explicit sidebar/programmatic navigation dismisses it first, so a
// later visit to AI Team or Skills always starts from its list.
@@ -609,7 +610,7 @@ function setView(view, cid, opts = {}) {
});
} else if (view === 'settings') {
currentCid = null;
- _deferSidebarNavWork('settings-tab-load', () => {
+ if (!restoreTaskCleanup) _deferSidebarNavWork('settings-tab-load', () => {
_loadViewFeature('settings', 'settings', () => {
if (typeof loadSettings === 'function') {
Promise.resolve(loadSettings())
@@ -623,7 +624,9 @@ function setView(view, cid, opts = {}) {
currentCid = null;
if (typeof primeProjectDetailShell === 'function') primeProjectDetailShell(cid || '');
_deferSidebarNavWork('project-tab-load', () => {
+ if (!_isProjectSelected(cid || '')) return;
_loadViewFeature('project', 'project', () => {
+ if (!_isProjectSelected(cid || '')) return;
if (typeof loadProjectDetail === 'function') loadProjectDetail(cid || '', { refreshShared: true });
});
});
diff --git a/src/renderer/modules/project-detail.js b/src/renderer/modules/project-detail.js
index b9d565b8..819ec500 100644
--- a/src/renderer/modules/project-detail.js
+++ b/src/renderer/modules/project-detail.js
@@ -1760,7 +1760,12 @@ function _openProjectTodoEditor(task, context = _projectTodoContext(), status =
options.push(project);
}
_todoEditorProjectSelect.setOptions(
- options.map((project) => ({ value: project.project_id, label: project.name })),
+ options.map((project) => ({
+ value: project.project_id,
+ label: project.name,
+ iconName: project.project_id
+ ? (typeof projectIconName === 'function' ? projectIconName(project) : 'folder') : '',
+ })),
{ value: context.pid || '' },
);
projectInput.dataset.locked = (!context.projects || !!task?.id) ? '1' : '0';
@@ -4812,10 +4817,6 @@ function _initProjectDetailBindings() {
e.stopPropagation();
_openAddPicker();
});
- document.getElementById('project-action-invite')?.addEventListener('click', (e) => {
- e.stopPropagation();
- void _showProjectMemberInviteGate();
- });
document.getElementById('project-action-rename')?.addEventListener('mousedown', (e) => {
if (_isProjectDetailRenameMode()) e.preventDefault();
});
diff --git a/src/renderer/modules/projects.js b/src/renderer/modules/projects.js
index 78ecf17c..5e7f1e6a 100644
--- a/src/renderer/modules/projects.js
+++ b/src/renderer/modules/projects.js
@@ -66,6 +66,10 @@ function _projectUiIconHtml(name, className) {
// `_skillsCache` patterns. `null` = not yet fetched.
let _projectsCache = null;
let _projectsLoadRequestId = 0;
+// Navigation is eager; the detail module may still be loading or showing the
+// previous project. Keep sidebar selection independent of its loaded data.
+let _projectSidebarPid = '';
+let _projectSidebarRevealPid = '';
// Per-project expand/collapse state, persisted across sessions so the user's
// layout sticks. Default: collapsed.
@@ -167,6 +171,7 @@ function _convsByProject() {
/** Project list at the top of the sidebar. Auto-expands the project that
* owns the active conversation so the live row is visible. */
function renderProjectsSection() {
+ if (currentView !== 'project') _projectSidebarRevealPid = '';
const container = document.getElementById('projects-list');
if (!container) return;
if (typeof _conversationInlineRenameBlocksRender === 'function'
@@ -249,6 +254,17 @@ function renderProjectsSection() {
}
// Re-paint pending / queued badges on the conv items we just (re)rendered.
if (typeof _refreshAllConvBadges === 'function') _refreshAllConvBadges();
+ if (_projectSidebarRevealPid && _isProjectSelected(_projectSidebarRevealPid)) {
+ const row = container.querySelector('.project-row.active');
+ if (row) {
+ // Reveal once per navigation, including when the project list arrives
+ // later. Background refreshes must respect subsequent manual scrolling.
+ _projectSidebarRevealPid = '';
+ const toggle = document.getElementById('projects-section-toggle');
+ if (toggle?.getAttribute('aria-expanded') === 'false') toggle.click();
+ row.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
+ }
+ }
}
function _renderInlineCreateRow() {
@@ -339,15 +355,15 @@ function _renderProjectRow(p, convs) {
}
function _isProjectSelected(pid) {
- return currentView === 'project'
- && typeof _projectDetailPid !== 'undefined'
- && _projectDetailPid === pid;
+ return currentView === 'project' && _projectSidebarPid === pid;
}
/** Paint cached identity before the deferred project-detail script is parsed.
* The panel markup is already eager, so first click can acknowledge the target
* in the same frame instead of showing an anonymous blank surface. */
function primeProjectDetailShell(pid) {
+ _projectSidebarPid = pid;
+ _projectSidebarRevealPid = pid;
const project = Array.isArray(_projectsCache)
? _projectsCache.find((item) => item && item.project_id === pid)
: null;
diff --git a/test/e2e/projects_e2e_smoke.spec.ts b/test/e2e/projects_e2e_smoke.spec.ts
index b84d8995..893a92f9 100644
--- a/test/e2e/projects_e2e_smoke.spec.ts
+++ b/test/e2e/projects_e2e_smoke.spec.ts
@@ -64,6 +64,51 @@ async function createProject(orkas: OrkasTestApp, name: string): Promise<void> {
}
test.describe('projects', () => {
+ test('selects and reveals a project opened outside the sidebar without pinning later scroll', async ({ orkas }, testInfo) => {
+ const page = orkas.page!;
+ let targetId = '';
+ for (let index = 0; index < 24; index += 1) {
+ const result = await orkas.invoke<{ project: { project_id: string } }>('projects.create', {
+ name: `Navigation ${String(index).padStart(2, '0')} long project title`,
+ });
+ targetId = result.project.project_id;
+ }
+ await page.evaluate(() => (window as any).loadProjects(true));
+ try {
+ for (const [locale, width, height] of [['zh', 1440, 900], ['en', 900, 600]] as const) {
+ await page.setViewportSize({ width, height });
+ await page.evaluate((lang) => (window as any).setLang(lang), locale);
+ await page.evaluate(() => {
+ (window as any).setView('settings');
+ const toggle = document.getElementById('projects-section-toggle')!;
+ if (toggle.getAttribute('aria-expanded') === 'true') toggle.click();
+ document.querySelector('.sidebar-conversation-nav')!.scrollTop = 0;
+ });
+ await expect(page.locator('#panel-settings')).toHaveClass(/\bactive\b/);
+ await page.evaluate(pid => (window as any).setView('project', pid), targetId);
+ const row = page.locator(`.project-row[data-pid="${targetId}"]`);
+ await expect(row).toHaveClass(/\bactive\b/);
+ await expect(page.locator('.project-row.active')).toHaveCount(1);
+ await expect(page.locator('#project-detail-title')).toHaveText('Navigation 23 long project title');
+ await expect.poll(async () => row.evaluate(el => {
+ const bounds = el.getBoundingClientRect();
+ const scroll = document.querySelector('.sidebar-conversation-nav')!.getBoundingClientRect();
+ return bounds.top >= scroll.top && bounds.bottom <= scroll.bottom;
+ })).toBe(true);
+ await page.screenshot({ path: testInfo.outputPath(`project-navigation-${locale}.png`) });
+ await page.evaluate(() => {
+ document.querySelector('.sidebar-conversation-nav')!.scrollTop = 0;
+ (window as any).renderProjectsSection();
+ });
+ expect(await page.locator('.sidebar-conversation-nav').evaluate(el => el.scrollTop)).toBe(0);
+ await page.evaluate(() => (window as any).setView('settings'));
+ await expect(page.locator('.project-row.active')).toHaveCount(0);
+ }
+ } finally {
+ await page.evaluate(() => (window as any).setView('new-chat'));
+ }
+ });
+
test('keeps member invitation visible as a commercial download guide', async ({ orkas }, testInfo) => {
const projectName = 'E2E Invite Guide';
if (!orkas.page) throw new Error('Orkas renderer is unavailable');
@@ -112,7 +157,7 @@ test.describe('projects', () => {
const guidance = await page.evaluate(() => (globalThis as any).t('project.invite_members.commercial_only'));
const inviteLabel = await page.evaluate(() => (globalThis as any).t('project.menu.invite_members'));
const headerInvite = page.locator('#panel-project .project-detail-actions').getByRole('button', { name: inviteLabel, exact: true });
- await expect(headerInvite).toBeVisible();
+ await expect(headerInvite).toHaveCount(0);
await page.locator('#panel-project').screenshot({ path: testInfo.outputPath('project-member-invite-entry.png') });
const cancelGuide = async () => {
const dialog = page.locator('.ui-dialog-overlay:visible');
@@ -126,8 +171,6 @@ test.describe('projects', () => {
await expect(page.locator('#project-detail-title')).toHaveText(projectName);
await expect(row).toHaveCount(1);
};
- await headerInvite.click();
- await cancelGuide();
await row.hover();
await row.locator('[data-project-menu]').click();
const invite = page.locator('#project-row-menu [data-action="invite-members"]');
@@ -759,6 +802,7 @@ test.describe('projects', () => {
const renamedName = 'E2E Header Rename After';
await createProject(orkas, originalName);
const page = orkas.page!;
+ await expect(page.locator('#project-action-invite')).toHaveCount(0);
const more = page.locator('#project-action-more');
const done = page.locator('#project-action-rename');
const title = page.locator('#project-detail-title');
diff --git a/test/renderer/project-sidebar-navigation.test.ts b/test/renderer/project-sidebar-navigation.test.ts
new file mode 100644
index 00000000..c11e3ffa
--- /dev/null
+++ b/test/renderer/project-sidebar-navigation.test.ts
@@ -0,0 +1,126 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import vm from 'node:vm';
+import { describe, expect, it, vi } from 'vitest';
+
+const source = (name: string) => readFileSync(join(__dirname, `../../src/renderer/modules/${name}.js`), 'utf8');
+
+function mount({ cached = true, collapsed = false, previous = '' } = {}) {
+ const scrolled: string[] = [];
+ const nodes = new Map<string, any>();
+ const deferred: Array<() => void> = [];
+ const featureLoads: Array<() => void> = [];
+ const projects = ['alpha', 'beta'].map(project_id => ({ project_id, name: project_id }));
+ const node = () => ({
+ innerHTML: '', textContent: '', hidden: false, dataset: {} as Record<string, string>,
+ attributes: {} as Record<string, string>,
+ classList: { add() {}, remove() {}, toggle() {} },
+ setAttribute(key: string, value: string) { this.attributes[key] = value; },
+ getAttribute(key: string) { return this.attributes[key]; },
+ querySelector: (_selector: string): any => null,
+ querySelectorAll: (_selector: string): any[] => [],
+ addEventListener() {},
+ });
+ for (const id of ['panel-project', 'panel-settings', 'new-chat-btn', 'agents-btn', 'skills-btn',
+ 'project-detail-title', 'project-detail-content', 'projects-list', 'projects-section-toggle']) {
+ nodes.set(id, node());
+ }
+ const list = nodes.get('projects-list');
+ const toggle = nodes.get('projects-section-toggle');
+ toggle.attributes['aria-expanded'] = String(!collapsed);
+ list.hidden = collapsed;
+ toggle.click = vi.fn(() => {
+ list.hidden = !list.hidden;
+ toggle.attributes['aria-expanded'] = String(!list.hidden);
+ });
+ list.querySelector = (selector: string) => {
+ if (selector !== '.project-row.active') return null;
+ const id = /class="project-row active" data-pid="([^"]+)"/.exec(list.innerHTML)?.[1];
+ return id ? { scrollIntoView: () => scrolled.push(id) } : null;
+ };
+ const loadProjectDetail = vi.fn();
+ const context: any = {
+ currentView: 'settings', currentCid: null, conversations: [], _projectDetailPid: previous,
+ _composerNavigationEpoch: 0, composerBindOwner() {}, _saveLastView() {},
+ _bootLog: { info() {}, warn() {} }, createLogger: () => ({ info() {}, warn() {} }),
+ _clearLazyFeatureError() {}, _showLazyFeatureError() {},
+ setTimeout: () => 0, clearTimeout() {}, t: String, escapeHtml: String,
+ localStorage: { getItem: () => null, setItem() {} },
+ document: {
+ addEventListener() {}, getElementById: (id: string) => nodes.get(id) || null,
+ querySelector: () => null, querySelectorAll: () => [],
+ },
+ addEventListener() {},
+ orkas: { invoke: vi.fn(async () => ({ ok: true, projects })) },
+ _deferSidebarNavWork: (_key: string, run: () => void) => deferred.push(run),
+ loadRendererFeature: () => new Promise<void>(resolve => featureLoads.push(resolve)),
+ loadProjectDetail,
+ };
+ context.window = context;
+ vm.createContext(context);
+ vm.runInContext(source('projects'), context);
+ const boot = source('boot');
+ vm.runInContext(boot.slice(boot.indexOf('function _loadViewFeature('), boot.indexOf('function _lazyFeaturePanel(')), context);
+ vm.runInContext(boot.slice(boot.indexOf('function setView(')), context);
+ if (cached) vm.runInContext(`_projectsCache = ${JSON.stringify(projects)}`, context);
+ const selected = () => [...list.innerHTML.matchAll(/class="project-row active" data-pid="([^"]+)"/g)]
+ .map(match => match[1]);
+ return { context, list, toggle, scrolled, selected, deferred, featureLoads, loadProjectDetail };
+}
+
+describe('project navigation follows the destination in the sidebar', () => {
+ it.each(['', 'alpha'])('selects and reveals the target before detail loading, with previous detail %j', previous => {
+ const h = mount({ previous, collapsed: true });
+ h.context.setView('project', 'beta');
+ expect(h.selected()).toEqual(['beta']);
+ expect(h.list.hidden).toBe(false);
+ expect(h.scrolled).toEqual(['beta']);
+ expect(h.loadProjectDetail).not.toHaveBeenCalled();
+
+ // Manual collapse and scrolling after entry win over background renders.
+ h.toggle.click();
+ h.context.renderProjectsSection();
+ expect(h.list.hidden).toBe(true);
+ expect(h.scrolled).toEqual(['beta']);
+ h.context.setView('settings');
+ expect(h.selected()).toEqual([]);
+ });
+
+ it('reveals a cold-start target once the project list arrives', async () => {
+ const h = mount({ cached: false, collapsed: true });
+ h.context.setView('project', 'beta');
+ expect(h.scrolled).toEqual([]);
+ await h.context.loadProjects();
+ expect(h.selected()).toEqual(['beta']);
+ expect(h.list.hidden).toBe(false);
+ expect(h.scrolled).toEqual(['beta']);
+ await h.context.loadProjects(true);
+ expect(h.scrolled).toEqual(['beta']);
+ });
+
+ it('does not reveal a late project list after navigating away', async () => {
+ const h = mount({ cached: false, collapsed: true });
+ h.context.setView('project', 'beta');
+ h.context.setView('settings');
+ await h.context.loadProjects();
+ expect(h.selected()).toEqual([]);
+ expect(h.list.hidden).toBe(true);
+ expect(h.scrolled).toEqual([]);
+ });
+
+ it('ignores the old deferred detail when switching projects during feature loading', async () => {
+ const h = mount();
+ h.context.setView('project', 'alpha');
+ h.deferred.shift()!();
+ h.context.setView('project', 'beta');
+ h.deferred.shift()!();
+ expect(h.selected()).toEqual(['beta']);
+ h.featureLoads[1]();
+ await new Promise(resolve => setImmediate(resolve));
+ h.featureLoads[0]();
+ await new Promise(resolve => setImmediate(resolve));
+ expect(h.loadProjectDetail.mock.calls.map(([pid]) => pid)).toEqual(['beta']);
+ expect(h.selected()).toEqual(['beta']);
+ expect(h.scrolled).toEqual(['alpha', 'beta']);
+ });
+});