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.

Show remaining history after a confirmed cleanup

wytf62b5d24c600
diff --git a/src/renderer/modules/task-cleanup.js b/src/renderer/modules/task-cleanup.js
index 2fbdf339..5c25118b 100644
--- a/src/renderer/modules/task-cleanup.js
+++ b/src/renderer/modules/task-cleanup.js
@@ -56,6 +56,8 @@
const aliases = { retry: 'chat.retry_btn', stop: 'chat.task_stop', loading: 'common.loading', refresh: 'common.refresh', view: 'settings.recycle.view', collapse: 'settings.recycle.collapse', cancel: 'common.cancel', confirm_title: 'settings.cleanup.title' };
const tr = (key, values) => key === 'all' ? `${t('chat.message_select_all')} (${values.n})`
: key === 'page' ? `${values.from}–${values.to} / ${values.n}` : t(aliases[key] || `settings.cleanup.${key}`, values);
+ const resultText = () => tr('result', result) + (Number.isSafeInteger(result?.remaining)
+ ? ' · ' + tr('remaining', { n: result.remaining }) : '');
const esc = value => escapeHtml(String(value));
const button = (action, label, disabled = false, danger = false, projectId = '') =>
`<button type="button" class="btn btn-sm${danger ? ' btn-danger' : ''}" data-cleanup-action="${action}" data-cleanup-owner="${esc(projectId)}"${disabled ? ' disabled' : ''}>${esc(label)}</button>`;
@@ -134,10 +136,10 @@
let html = '';
if (busy) html += `<div class="settings-row" role="status"><span class="settings-row-desc">${esc(tr('progress', { done: result.done, total: result.total }))}</span>${button('stop', tr('stop'), stopped)}</div>`;
else if (loading) html += `<div class="settings-row" role="status">${esc(tr('loading'))}</div>`;
- else if (error) html += `<div class="settings-row" role="alert"><span class="settings-row-desc">${esc(tr('error'))}${result ? ' ' + esc(tr('result', result)) : ''}</span><div class="settings-cleanup-actions">${failed.length ? button('retry', tr('retry')) : ''}${button('refresh', tr('refresh'))}</div></div>`;
+ else if (error) html += `<div class="settings-row" role="alert"><span class="settings-row-desc">${esc(tr('error'))}${result ? ' ' + esc(resultText()) : ''}</span><div class="settings-cleanup-actions">${failed.length ? button('retry', tr('retry')) : ''}${button('refresh', tr('refresh'))}</div></div>`;
else {
if (confirming) html += `<div class="settings-row" role="group" aria-label="${esc(tr('confirm_title'))}"><span class="settings-row-desc">${esc(tr('confirm', { n: selected }))}</span><div class="settings-cleanup-actions">${button('cancel', tr('cancel'))}${button('confirm', tr('move', { n: selected }), !selected, true)}</div></div>`;
- else html += `<div class="settings-row"><div class="settings-cleanup-copy">${total ? `<label class="settings-cleanup-select-all">${checkbox('data-cleanup-all', selected, selectableTotal, false, tr('all', { n: total }))}<span>${esc(tr('all', { n: total }))}</span></label>` : ''}${result || !total ? `<span class="settings-row-desc" role="status">${esc(result ? tr('result', result) : tr('empty'))}</span>` : ''}</div><div class="settings-cleanup-actions">${failed.length ? button('retry', tr('retry')) : ''}${total ? button('view', tr(expanded ? 'collapse' : 'view')) : ''}${button('prepare', `${tr('clean')} (${selected})`, !selected, true)}</div></div>`;
+ else html += `<div class="settings-row"><div class="settings-cleanup-copy">${total ? `<label class="settings-cleanup-select-all">${checkbox('data-cleanup-all', selected, selectableTotal, false, tr('all', { n: total }))}<span>${esc(tr('all', { n: total }))}</span></label>` : ''}${result || !total ? `<span class="settings-row-desc" role="status">${esc(result ? resultText() : tr('empty'))}</span>` : ''}</div><div class="settings-cleanup-actions">${failed.length ? button('retry', tr('retry')) : ''}${total ? button('view', tr(expanded ? 'collapse' : 'view')) : ''}${button('prepare', `${tr('clean')} (${selected})`, !selected, true)}</div></div>`;
if (expanded && total) {
const drafts = new Set(draftIds());
html += '<div class="settings-cleanup-list">';
@@ -171,6 +173,7 @@
try {
const p = await invoke('preview', { days, draftIds: draftIds() });
if (!Array.isArray(p.entries) || !Number.isSafeInteger(p.total) || !Number.isSafeInteger(p.selectableTotal) || typeof p.token !== 'string') throw new Error('invalid_preview');
+ if (keepResult && result) result.remaining = p.total;
token = p.token; total = p.total; selectableTotal = p.selectableTotal; entries = p.entries; offset = 0;
nextOffset = p.treeNextOffset; treeTotal = p.treeTotal;
projects.clear(); knownRows.clear(); projectViews.clear(); removed.clear(); removedByProject.clear(); resetSelection(); remember(entries);
diff --git a/test/e2e/task_cleanup_e2e_history.spec.ts b/test/e2e/task_cleanup_e2e_history.spec.ts
index 4b363d39..f3a7d35f 100644
--- a/test/e2e/task_cleanup_e2e_history.spec.ts
+++ b/test/e2e/task_cleanup_e2e_history.spec.ts
@@ -3,6 +3,39 @@ import path from 'node:path';
import { test, expect } from './fixtures/orkas';
test.describe('inline historical task cleanup', () => {
+ test('shows remaining history after cleanup and requires a new selection', async ({ orkas }, testInfo) => {
+ const cids: string[] = [];
+ for (const title of ['Selected history', 'History left for review']) {
+ cids.push((await orkas.invoke<any>('conversations.create', { title })).conversation.conversation_id);
+ }
+ const root = path.join(orkas.workspaceRoot, 'account-e2e', 'cloud', 'chats');
+ const rows = JSON.parse(readFileSync(path.join(root, '_index.json'), 'utf8'));
+ const old = '2020-01-01T00:00:00Z';
+ for (const row of rows) {
+ row.created_at = row.updated_at = old;
+ writeFileSync(path.join(root, row.conversation_id, 'meta.json'), JSON.stringify(row));
+ writeFileSync(path.join(root, `${row.conversation_id}.jsonl`), JSON.stringify({ id: 'request', from: 'user', content: row.title, ts: old }) + '\n');
+ }
+ writeFileSync(path.join(root, '_index.json'), JSON.stringify(rows));
+ const page = await orkas.relaunch();
+ await page.locator('#settings-btn').click();
+ await page.locator('[data-settings-tab="data"]').click();
+ const section = page.locator('#settings-task-cleanup');
+ await section.locator('[data-cleanup-action="view"]').click();
+ await section.locator(`[data-cleanup-cid="${cids[0]}"]`).check();
+ await section.locator('[data-cleanup-action="prepare"]').click();
+ await section.locator('[data-cleanup-action="confirm"]').click();
+ await expect(section).toContainText('Still matching: 1. Review and select again to continue.');
+ await expect(section.locator('[data-cleanup-action="prepare"]')).toBeDisabled();
+ expect(existsSync(path.join(root, `${cids[0]}.jsonl`))).toBe(false);
+ expect(existsSync(path.join(root, `${cids[1]}.jsonl`))).toBe(true);
+ for (const [lang, width, height] of [['en', 1280, 900], ['zh', 1000, 720], ['en', 620, 780]] as const) {
+ await page.setViewportSize({ width, height });
+ await page.evaluate(async lang => { await (window as any).setLang(lang); }, lang);
+ await section.screenshot({ path: testInfo.outputPath(`cleanup-remaining-${lang}-${width}.png`) });
+ expect(await section.locator('[role="status"]').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
+ }
+ });
test('uses sidebar timestamps and retains tasks renamed before preview or confirmation', async ({ orkas }, testInfo) => {
const cids: string[] = [];
for (const title of ['Old task metadata', 'Rename before preview', 'Rename before confirmation']) {
diff --git a/test/renderer/task-cleanup.test.ts b/test/renderer/task-cleanup.test.ts
index 5336d3eb..ab0a9f91 100644
--- a/test/renderer/task-cleanup.test.ts
+++ b/test/renderer/task-cleanup.test.ts
@@ -44,6 +44,21 @@ function harness() {
show: () => scope.window.initTaskCleanup() };
}
describe('inline history cleanup', () => {
+ it('reports a fresh remaining count without extending the confirmed selection to later arrivals', async () => {
+ const h = harness(); const original = h.invoke.getMockImplementation()!;
+ let previews = 0;
+ h.invoke.mockImplementation(async (channel, payload) => {
+ const response = await original(channel, payload);
+ if (channel.endsWith('preview') && ++previews > 1) return { ...response, total: 1, selectableTotal: 1,
+ entries: [{ cid: 'later-arrival', title: 'Later arrival', selectable: true }], treeTotal: 1 };
+ return response;
+ });
+ await h.show(); await h.check(null, true); await h.click('prepare'); await h.click('confirm');
+ expect(h.invoke.mock.calls.filter(([c]) => c.endsWith('remove')).map(([, p]: any) => p.cid)).toEqual(['one', 'two']);
+ expect(h.body.innerHTML).toContain('Recycled 2 · Skipped 0 · Failed 0');
+ expect(h.body.innerHTML).toContain('Still matching: 1. Review and select again to continue.');
+ expect(h.body.innerHTML).toContain('Clean up (0)');
+ });
it.each([undefined, 'busy', 'unknown'])('opens a task with blocking state %s without selecting or deleting it', async blocked => {
const h = harness();
const original = h.invoke.getMockImplementation()!;