Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ instead, an admin confirms it there or in Approvals with their password.

### Approvals

Start → Approvals (and the "N to approve" in the taskbar, its tooltip
lists them) shows what waits for an admin, newest first: the plans of
Start → Approvals (and the "N to approve" in the taskbar, with "N being
planned" for proposals the planner still works on; its tooltip lists
them) shows what waits for an admin, newest first: the plans of
the AI agents' proposals (`#12`, see [AI agents](#ai-agents); those the
planner still works on are listed too) and the pending actions
(`A12`): deletions of domains, databases, groups, mail domains and
Expand Down
15 changes: 8 additions & 7 deletions webui/src/components/Taskbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
} = $props();

const attention = $derived(conversations.attention);
const waiting = $derived(approvals.waiting);
// proposals the planner still works on show too
const open = $derived(approvals.undecided);

let time = $state(formatHour(Date.now()));

Expand Down Expand Up @@ -70,19 +71,19 @@
⚠ {attention.length}
</button>
{/if}
{#if waiting.length}
{#if open.length}
<button
class="approve"
title={waiting.map(approvalLine).join('\n')}
title={open.map(approvalLine).join('\n')}
onclick={() => {
// the only one waiting opens selected
if (waiting.length === 1)
dialogs.approval = approvalKey(waiting[0]);
// the only one opens selected
if (open.length === 1)
dialogs.approval = approvalKey(open[0]);
dialogs.open = 'approvals';
}}
>
<Icon name="agent" />
{waiting.length} to approve
{approvals.summary}
</button>
{/if}
{#if connection.lost}
Expand Down
23 changes: 20 additions & 3 deletions webui/src/lib/approvals.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,36 @@ import { get, type Approval, type PendingAction, type Plan } from './api';

// Start → Approvals: the AI agents' proposals and the pending actions
// (deletions, the agent's remote backup changes); the taskbar shows the
// waiting ones, any admin decides
// undecided ones, any admin decides
class ApprovalStore {
list = $state<Approval[]>([]);

async load() {
this.list = await get('/approvals');
}

/** what an admin can decide on now, for the taskbar */
/** what an admin can decide on now */
get waiting(): Approval[] {
return this.list.filter(a => status(a) === 'pending');
}

/** the proposals the planner still works on */
get planning(): Approval[] {
return this.list.filter(a => status(a) === 'planning');
}

/** "2 to approve, 1 being planned", each part only when there are some */
get summary(): string {
const waiting = this.waiting.length;
const planning = this.planning.length;
return [
waiting ? `${waiting} to approve` : '',
planning ? `${planning} being planned` : '',
]
.filter(Boolean)
.join(', ');
}

/** also the proposals the planner works on */
get undecided(): Approval[] {
return this.list.filter(a => undecided(a));
Expand Down Expand Up @@ -118,7 +135,7 @@ export function approvalTitle(a: Approval): string {
return a.action.description.split('. ')[0].replace(/\.$/, '');
}

/** the taskbar's line of a waiting one */
/** the taskbar's line of an undecided one */
export function approvalLine(a: Approval): string {
const from = a.kind === 'proposal' ? `${a.proposal.from}: ` : '';
return `${approvalNumber(a)} ${from}${approvalTitle(a)}`;
Expand Down
Loading