Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Task board host side: dismiss mark, newest problem only, one plain line per run, pending approvals of every chat

Niko1221ff18fbb8682d
diff --git a/apps/host/server/agent/agent-bridge.mjs b/apps/host/server/agent/agent-bridge.mjs
index 542ccacee..988fe2069 100644
--- a/apps/host/server/agent/agent-bridge.mjs
+++ b/apps/host/server/agent/agent-bridge.mjs
@@ -1180,6 +1180,12 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir =
.map(p => (p.sessionId === sessionId ? p : { ...p, callId: `${p.sessionId}:${p.callId}` })).map(({ callId, tool, reason, at }) => ({ callId, tool, reason, at }));
}
+ /** Every chat that has an approval waiting, for the task board: the chat, its working folder and what is waiting (same items as pendingFor). */
+ function pendingAll() {
+ if (!pending.size) return [];
+ return Object.keys(sessionMap).map(chatId => ({ chatId, folder: sessionMap[chatId]?.cwd ?? null, pending: pendingFor(chatId) })).filter(c => c.pending.length);
+ }
+
async function close() {
const r = rt; rt = null;
if (r) { r.events?.close(); r.gw.close(); await r.hp.stop(); }
@@ -1188,7 +1194,7 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir =
/** Let go of a chat's Harness session mapping (a task starts every run in a session of its own). */
function forget(chatId) { if (chats.get(chatId)?.turn) return; delete sessionMap[chatId]; chats.delete(chatId); persist(); }
- return { goalState, goalControl, harnessDir, status, runTurn, goalCommand, planCommand, researchCommand, llmTarget, setPlanBriefing, resetSession, reopenPlan, skipStep, planGoal, planControl, planState, queueMessage, cancelQueued, takeQueue, forget, approve, setMode, stop, pendingFor, close, sessionOf: chatId => sessionMap[chatId]?.sessionId ?? null, workingFolder: chatId => sessionMap[chatId]?.cwd ?? null, isRunning: chatId => !!chats.get(chatId)?.turn, _debug: () => ({ rt, sessionMap }) };
+ return { goalState, goalControl, harnessDir, status, runTurn, goalCommand, planCommand, researchCommand, llmTarget, setPlanBriefing, resetSession, reopenPlan, skipStep, planGoal, planControl, planState, queueMessage, cancelQueued, takeQueue, forget, approve, setMode, stop, pendingFor, pendingAll, close, sessionOf: chatId => sessionMap[chatId]?.sessionId ?? null, workingFolder: chatId => sessionMap[chatId]?.cwd ?? null, isRunning: chatId => !!chats.get(chatId)?.turn, _debug: () => ({ rt, sessionMap }) };
}
/** A goal that stopped by itself, in words. */
diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs
index 30914ba57..0b2766a02 100644
--- a/apps/host/server/index.mjs
+++ b/apps/host/server/index.mjs
@@ -1857,8 +1857,10 @@ async function api(req, res, path, method, url) {
try { return json(res, 200, agentTools.removeCustom(customToolRoute[1])); } catch (e) { return error(res, 400, e.message); }
}
if (path === '/api/agent/pending' && method === 'GET') {
- const chat = new URL(req.url, 'http://x').searchParams.get('chatId') ?? '';
- return json(res, 200, { pending: agent.pendingFor(chat) });
+ const params = new URL(req.url, 'http://x').searchParams;
+ // No chat named: every chat with an approval waiting (the task board lists them without opening each chat).
+ if (!params.has('chatId')) return json(res, 200, { chats: agent.pendingAll() });
+ return json(res, 200, { pending: agent.pendingFor(params.get('chatId') ?? '') });
}
/* Approve / Deny a tool the agent asked about. The answer reaches the Harness approval for exactly
that chat and call; a stale or foreign id is refused. */
diff --git a/apps/host/server/task-report.mjs b/apps/host/server/task-report.mjs
index 3df7e8b10..d0ba613c0 100644
--- a/apps/host/server/task-report.mjs
+++ b/apps/host/server/task-report.mjs
@@ -33,3 +33,19 @@ export function taskReport({ text, cards }) {
if (attention) out += `\n\n> ${attention}`;
return { text: out, attention, demo: false };
}
+
+/**
+ * One plain line for a board card: the first sentence of the answer, with the markdown taken off and the "What it did" list and the
+ * "needed a yes" note left out. '' when there is nothing to say.
+ */
+export function lastLine(text, max = 160) {
+ let body = String(text ?? '').split(/\n\n---\n\n/)[0].replace(/\n\n> [\s\S]*$/, '');
+ body = body.replace(/```[\s\S]*?```/g, ' ').replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/^\s*(#{1,6}|[-*+]|\d+[.)]|>)\s+/gm, '').replace(/[*_`~]/g, '');
+ body = body.replace(/\s+/g, ' ').trim();
+ if (!body) return '';
+ const sentence = /^.*?[.!?](?=\s|$)/.exec(body)?.[0] ?? body;
+ // A very short first sentence ("Done.") says nothing: take the next one too.
+ const two = /^.*?[.!?](?=\s|$)\s*.*?[.!?](?=\s|$)/.exec(body)?.[0] ?? body;
+ const pick = sentence.length < 24 && body.length > sentence.length ? two : sentence;
+ return clip(pick, max);
+}
diff --git a/apps/host/server/tasks.mjs b/apps/host/server/tasks.mjs
index 952c94af5..5127ac4e9 100644
--- a/apps/host/server/tasks.mjs
+++ b/apps/host/server/tasks.mjs
@@ -4,6 +4,7 @@
* first thing that needs a yes and says what that was) or `bypass` (full access). The default is `plan`.
*/
import { randomUUID } from 'node:crypto';
+import { lastLine } from './task-report.mjs';
const frequencies = ['hourly', 'daily', 'weekdays', 'weekly'];
export const TASK_MODES = ['plan', 'manual', 'bypass'];
export function validateTask(input) {
@@ -52,6 +53,8 @@ export function createTaskService({ read, write, run, notify = () => {}, now = D
if (old?.status === 'running') throw new Error('Stop the current run before editing.');
const fields = validateTask({ ...old, ...input });
const task = { ...old, ...fields, id: old?.id ?? randomUUID(), createdAt: old?.createdAt ?? new Date(now()).toISOString(), status: old?.status ?? 'idle', archived: input.archived ?? old?.archived ?? false };
+ // "I have seen this": the board hides a finished or failed run the person dismissed. It is only a mark; the result stays in the task.
+ if ('ackedAt' in input) task.ackedAt = input.ackedAt ? String(input.ackedAt) : null;
task.nextRunAt = task.enabled && !task.archived ? nextRun(task, now()) : null;
records = old ? records.map(t => t.id === id ? task : t) : [...records, task]; save(); return task;
}
@@ -59,12 +62,13 @@ export function createTaskService({ read, write, run, notify = () => {}, now = D
const t = find(id); if (t.status === 'running') return;
if (t.archived) throw new Error('Restore this task first.');
const controller = new AbortController(); controllers.set(id, controller);
- t.status = 'running'; t.lastRunAt = new Date(now()).toISOString(); t.error = null; t.files = [];
+ // A new run replaces the last one's problem (error and the note that something needed a yes) and its dismissal, so the board only ever shows the newest.
+ t.status = 'running'; t.lastRunAt = new Date(now()).toISOString(); t.error = null; t.attention = null; t.ackedAt = null; t.lastLine = null; t.finishedAt = null; t.files = [];
t.nextRunAt = t.enabled ? nextRun(t, now()) : null; save();
const timeout = setTimeout(() => controller.abort(), timeoutMs); timeout.unref?.();
- try { const result = await run(t, controller.signal); t.output = result.text.slice(0, 100000); t.demo = result.demo; t.attention = result.attention ?? null; t.files = Array.isArray(result.files) ? result.files.slice(0, 30) : []; t.status = 'done'; }
+ try { const result = await run(t, controller.signal); t.output = result.text.slice(0, 100000); t.demo = result.demo; t.attention = result.attention ?? null; t.lastLine = lastLine(result.text); t.files = Array.isArray(result.files) ? result.files.slice(0, 30) : []; t.status = 'done'; }
catch (e) { t.status = controller.signal.aborted ? 'cancelled' : 'error'; t.error = controller.signal.aborted ? 'Run stopped.' : String(e.message ?? e); }
- finally { clearTimeout(timeout); controllers.delete(id); save(); try { notify(t); } catch { /* a notification is a courtesy */ } }
+ finally { t.finishedAt = new Date(now()).toISOString(); clearTimeout(timeout); controllers.delete(id); save(); try { notify(t); } catch { /* a notification is a courtesy */ } }
}
function tick() { for (const t of records) if (t.enabled && !t.archived && t.status !== 'running' && t.nextRunAt && Date.parse(t.nextRunAt) <= now()) void execute(t.id); }
return { list, put, execute, tick, stop: id => controllers.get(id)?.abort(), close: () => controllers.forEach(c => c.abort()) };
diff --git a/apps/host/src/lib/tasks.ts b/apps/host/src/lib/tasks.ts
index 303dca5c1..37eafc28b 100644
--- a/apps/host/src/lib/tasks.ts
+++ b/apps/host/src/lib/tasks.ts
@@ -1,2 +1,2 @@
-export interface Task { id?: string; title: string; prompt: string; frequency: string; at: string; weekday: number; timeZone: string; mode?: 'plan' | 'manual' | 'bypass'; enabled: boolean; archived?: boolean; nextRunAt?: string; lastRunAt?: string; status?: string; output?: string; demo?: boolean; error?: string; attention?: string | null; /** The files the last run made or changed (name, full path). */ files?: { name: string; path: string }[]; }
+export interface Task { id?: string; title: string; prompt: string; frequency: string; at: string; weekday: number; timeZone: string; mode?: 'plan' | 'manual' | 'bypass'; enabled: boolean; archived?: boolean; nextRunAt?: string; lastRunAt?: string; status?: string; output?: string; demo?: boolean; error?: string; attention?: string | null; /** The files the last run made or changed (name, full path). */ files?: { name: string; path: string }[]; /** When the last run ended, and one plain sentence of its answer (the board's card line). */ finishedAt?: string | null; lastLine?: string | null; /** The person dismissed this run's card on the board. A new run clears it. */ ackedAt?: string | null; }
export const blankTask = (): Task => ({ title:'', prompt:'', frequency:'daily', at:'09:00', weekday:1, timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone, mode:'bypass', enabled:true });
diff --git a/apps/host/tests/agent-bridge.test.mjs b/apps/host/tests/agent-bridge.test.mjs
index b724983d3..d2c6a67e0 100644
--- a/apps/host/tests/agent-bridge.test.mjs
+++ b/apps/host/tests/agent-bridge.test.mjs
@@ -178,6 +178,7 @@ test('A08 two chats run independently, each with its own session and approval',
assert.notEqual(r.bridge.sessionOf('chat-a08-a'), r.bridge.sessionOf('chat-a08-b'));
assert.equal(r.bridge.pendingFor('chat-a08-b').length, 0);
assert.equal(r.bridge.pendingFor('chat-a08-a').length, 1);
+ assert.deepEqual(r.bridge.pendingAll().map(c => c.chatId), ['chat-a08-a'], 'the board lists every chat that waits, and only those');
const callId = a.frames.find(f => f.type === 'agent-tool').tool.id;
// An approval cannot be answered through the wrong chat.
await assert.rejects(r.bridge.approve({ chatId: 'chat-a08-b', callId, decision: 'approve' }), /no longer waiting/);