Automations workspace phase 1: sidebar groups, detail view, recompile-to-edit, named runs

Promotes Automations to a top-level sidebar group (below Bookmarks) with
user-defined AgentGroup folders (migration 025, FK SET NULL on delete).
The /automations page becomes master-detail: overview (composer + grouped
list + named global runs) and per-task detail (original prompt, group
assignment, run-now/pause/delete, per-task run timeline with true/false/
error pills). Editing recompiles through /api/agent/compile and confirms
the proposal before a versioned PATCH applies spec+prompt — the model
never writes. Tasks store prompt+groupId; projections add runCount/
errorCount; runs carry taskName. The engine is untouched: groups/prompt
are metadata, the validated spec remains the only thing it executes.
Chaining, refinements and dry-run stay phase 2.

Verified: full DB integration suite under -race, db-converge + migration
atomicity, web lint/SSR/build, and a rewritten browser regression covering
the sidebar folder, detail prompt, per-task runs, recompile-to-edit and
named global runs.
This commit is contained in:
Andrew S Erwin
2026-11-25 14:16:45 -06:00
parent e32eed93ea
commit 060a8115ec
10 changed files with 719 additions and 192 deletions
+48 -11
View File
@@ -85,8 +85,15 @@ let lastNextcloudConnect = null
const agentTasks = [{
id: 'task-1', name: 'Watch the price', summary: 'Checks flights.example hourly and emails when below $400',
spec: { condition: { type: 'url_watch', url: 'https://flights.example/q/123', question: 'price?', op: 'lt', threshold: 400 }, action: { type: 'email', to: 'david@email.com' }, pollMinutes: 60, once: false },
prompt: 'when the price on flights.example drops below $400, email david@email.com', groupId: 'g1',
runCount: 2, errorCount: 1,
enabled: true, status: 'active', fireCount: 2, lastCheckedAt: '2026-11-23T00:00:00Z', lastFiredAt: null, version: 1, createdAt: '2026-11-20T00:00:00Z',
}]
const agentGroups = [{ id: 'g1', name: 'Travel', position: 0, version: 1 }]
const agentRuns = [
{ id: 'r1', taskId: 'task-1', taskName: 'Watch the price', outcome: 'fired', detail: 'Found $389 nonstop', createdAt: '2026-11-23T09:57:00Z' },
{ id: 'r2', taskId: 'task-1', taskName: 'Watch the price', outcome: 'failed', detail: 'Page timed out', createdAt: '2026-11-23T05:41:00Z' },
]
// The identity is mutable: Settings → Profile PATCHes it, and the NextAuth
// jwt "update" trigger re-reads it from /api/me (session name refresh).
const fixtureUser = {
@@ -327,10 +334,26 @@ const api = http.createServer(async (req, res) => {
result = { results }
} else if (url.pathname === '/api/mcp/connections') {
result = { connections: [], suggestions: mcpSuggestions }
} else if (url.pathname === '/api/agent/groups') {
if (req.method === 'POST') {
const g = { id: `g${agentGroups.length + 1}`, name: body.name, position: agentGroups.length, version: 1 }
agentGroups.push(g); result = g
} else result = agentGroups
} else if (url.pathname === '/api/agent/compile' && req.method === 'POST') {
result = { name: 'Recompiled task', spec: { condition: { type: 'url_watch', url: 'https://flights.example/q/123', question: 'price?', op: 'lt', threshold: 350 }, action: { type: 'email', to: 'david@email.com' }, pollMinutes: 60, once: false }, summary: 'Emails david@email.com when below $350' }
} else if (/^\/api\/agent\/tasks\/[^/]+$/.test(url.pathname) && req.method === 'PATCH') {
const t = agentTasks.find(x => x.id === url.pathname.split('/')[4])
if (!t) { res.writeHead(404); res.end('{}'); return }
if (body.version !== t.version) { res.writeHead(409, { 'Content-Type': 'application/json' }); res.end('{"error":"stale"}'); return }
Object.assign(t, body, { version: t.version + 1 }); result = t
} else if (url.pathname === '/api/agent/tasks') {
result = agentTasks
if (req.method === 'POST') {
const t = { id: `task-${agentTasks.length + 1}`, name: body.name, spec: body.spec, summary: 'compiled', prompt: body.prompt || '', groupId: body.groupId || null, runCount: 0, errorCount: 0, enabled: true, status: 'active', fireCount: 0, lastFiredAt: null, version: 1, createdAt: new Date().toISOString() }
agentTasks.push(t); result = t
} else result = agentTasks
} else if (url.pathname === '/api/agent/runs') {
result = []
const tid = url.searchParams.get('taskId')
result = tid ? agentRuns.filter(r => r.taskId === tid) : agentRuns
} else if (url.pathname === '/api/notifications/channels') {
result = []
} else if (url.pathname === '/api/ai/status') {
@@ -900,17 +923,31 @@ try {
await page.getByText('House docs').first().waitFor()
console.log('PASS: Settings → Nextcloud connects files/calendars/contacts with one credential, syncs via the sibling surfaces, stays idempotent and never echoes the password')
// Automations moved from Settings to the sidebar: the caret drops down to
// the user's tasks, a task deep-links to /automations?task=<id> with the
// card highlighted, the legacy settings deep link redirects, and the
// settings tab is gone.
await page.getByRole('button', { name: 'Expand Automations' }).click()
// Automations workspace (redesign phase 1): promoted to a top-level sidebar
// group with folders; the detail view shows the original prompt, a per-task
// run timeline, and editing recompiles through /compile before applying.
await page.getByRole('button', { name: 'Automations', exact: true }).click()
await page.getByText('Travel', { exact: true }).first().waitFor()
await page.getByRole('link', { name: 'Watch the price' }).waitFor()
await page.getByRole('link', { name: 'Watch the price' }).click()
await page.waitForURL('**/automations?task=task-1')
await page.getByText('Hey Superbrain').waitFor()
await page.getByText('Your automations').waitFor()
assert.ok(await page.locator('#automation-task-1').evaluate(el => el.className.includes('ring-1')), 'deep-linked task card not highlighted')
await page.getByText('Original prompt').waitFor()
await page.getByText('when the price on flights.example drops below $400, email david@email.com').waitFor()
// Per-task run timeline with true/error outcomes.
await page.getByText('Found $389 nonstop').waitFor()
await page.getByText('Page timed out').waitFor()
// Edit → recompile → confirm → apply (the model never writes directly).
await page.getByRole('button', { name: 'Edit automation' }).click()
await page.getByPlaceholder('Describe what should happen…').fill('when the price drops below $350, email david@email.com')
await page.getByRole('button', { name: 'Recompile' }).click()
await page.getByText('Recompiled proposal').waitFor()
await page.getByRole('button', { name: 'Apply changes' }).click()
await page.getByText('Automation updated').waitFor()
// Overview: global runs carry the automation name.
await page.getByRole('button', { name: 'All automations' }).click()
await page.waitForURL('**/automations')
await page.getByRole('button', { name: 'Watch the price', exact: true }).first().waitFor()
// Legacy settings deep link still redirects; the settings tab stays gone.
await page.goto(`${base}/settings?tab=automations`)
await page.waitForURL('**/automations')
await page.goto(`${base}/settings`)
@@ -921,7 +958,7 @@ try {
assert.equal(await page.getByRole('tab', { name: 'Contacts sync' }).count(), 0, 'Contacts sync tab still present in Settings')
await page.goto(`${base}/settings?tab=nextcloud`)
await page.getByPlaceholder('https://cloud.example.com').waitFor()
console.log('PASS: Automations lives in the sidebar with a task dropdown, deep-links to /automations, and the legacy settings tab redirects')
console.log('PASS: Automations workspace — sidebar group + folders, prompt detail, per-task runs, recompile-to-edit, named global runs')
// Settings → MCP: the suggestion catalog offers GitHub and Make (token
// auth) with a Use prefill; HubSpot is honestly flagged OAuth-required