ai-agentmanager 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.18.0 (2026-11-04)
4
+
5
+ - **Goals.** Give an outcome for today, this week or no deadline, across one or more projects (**+ Goal** in the Backlog tab, or `agentmgr goal add`). It's planned into tasks, one agent each, which go to the backlog and run until done; autopilot ships them where it's on. When all are finished, the outcome is checked against what was delivered and what's missing is queued, for up to 2 more rounds. Each goal keeps **completed**, **pending** and **follow-ups** current, with **Copy summary**, **Carry over** when overdue, and an optional look at the plan before agents start.
6
+ - **Work record.** What your agents got done is appended, as it happens, to `~/.agentmanager/worklog.csv`: pull requests opened, merged and closed, bugs fixed, issues filed and agents finished, with dates, links and costs. A weekly summary goes to `worklog-weekly.csv`. **Work record…** in the menu shows a period's totals, the weeks and the events, with **Copy summary** (Markdown for a review) and the files to download; `agentmgr worklog`. Agents now list issues they open as `- Filed:` lines in their brief.
7
+ - **Follow-up reminders.** The Inbox reminds you about recent agents that went quiet: work that isn't finished (still open, or closed by itself, the session cap or clean up), with a nudge to send, Resume or Close session; and finished agents whose session is still open, to close. **Later** snoozes a reminder for a few hours, **Not needed** until the agent is used again (`agentmgr remind`). Timing in config.json under `reminders`.
8
+ - **Close all** next to the agent counts closes every open session at once. The assistant stays open, and so do agents working right now unless you also choose **Close them too**.
9
+ - **Autopilot ships at a score.** Per project, choose when autopilot ships: when the scorecard says ready, as before, or at 80+, 85+, 90+ or 95+ (`agentmgr backlog autopilot <project> merge --target 85`). With a score set, work that isn't there yet, *Look at these first* included, goes back to its agent with its scorecard to improve, and ships once it's ready at the target. It waits for you when the tries run out (3) or when a try raised the score by less than 3 points. Items show their scores so far (*72 → 81 → 87*).
10
+ - Autopilot sends not-ready work back with the full scorecard, as **✨ Improve** does, instead of only the reasons, and up to three times instead of two (`"autopilot": { "rounds": 3 }`).
11
+ - **The agents list puts the most recently created or used agents on top.** It's one list now, each agent tagged with its project. Above the list, switch to **Running first** (running agents on top, then the rest) or **By project** (the grouped view as before). Each browser remembers the choice.
12
+
13
+ ## 1.17.0 (2026-11-03)
14
+
15
+ - **Sessions go both ways with the Claude desktop app.** **Open in Claude desktop** on a Claude agent (and `agentmgr desktop <agent>`) continues its conversation in the desktop app through Claude Code's `claude --desktop --resume`. The agent's session here closes first, messages for it wait until you resume it here, and **Resume** picks up what was said in the desktop app. **Import** now lists sessions started in the desktop app's Code tab (marked **Claude desktop**, with their title there) and in editors. Before, it only listed sessions started from a terminal. A session open in the desktop app is protected like one open in a terminal: close it there, or continue a copy.
16
+
3
17
  ## 1.16.0 (2026-11-03)
4
18
 
5
19
  - **Faster typing and switching with many agents:** the page no longer redraws everything on every agent update. Updates are drawn once per frame, only the views they touch are redrawn (another agent's update leaves the open agent's details and terminal alone), and lists change only the cards that changed. With 40 busy agents, the page's redraw work went from about 870 ms to 35 ms per 10 seconds. Add `?perf` to the address to see how long redraws take.
package/README.md CHANGED
@@ -75,7 +75,7 @@ Claude Code on its own, including its built-in ways to run work in parallel, is
75
75
  - **Keeping up without reading transcripts:** a brief per agent (result, problem, fix, checks) and one inbox for every prompt and question.
76
76
  - **From anywhere:** your phone, another computer, or several machines through the hub.
77
77
 
78
- **Trying it costs little.** It runs the same `claude` you already use, with your plan and your repo's `CLAUDE.md` and skills. Sessions you started with `claude` in a terminal can be continued in it (**Import** above the agent list), and you can go back to a plain terminal any time with `claude --resume`.
78
+ **Trying it costs little.** It runs the same `claude` you already use, with your plan and your repo's `CLAUDE.md` and skills. Sessions you started with `claude` in a terminal or in the Claude desktop app can be continued in it (**Import** above the agent list), and you can go back any time: to a plain terminal with `claude --resume`, or to the desktop app with **Open in Claude desktop**.
79
79
 
80
80
  ## Install
81
81
 
@@ -235,11 +235,17 @@ Every agent gets **its own worktree and its own branch** (`agent/<name>-<id>`) o
235
235
  - **No upstream.** Agent branches are created without an upstream, so Claude's first `git push -u origin <branch>` sets the right one. They never accidentally track `origin/main`.
236
236
  - **Where it shows.** The agent shows **Branched from** with the ref and commit it started at.
237
237
 
238
- ## Continue sessions started in a terminal
238
+ ## Continue sessions started in a terminal or the Claude desktop app
239
239
 
240
- **Import** (next to **Save now** in the agent list) lists the Claude Code sessions you started yourself with `claude` in a terminal on this machine, from the last 7, 30 or 90 days: grouped by folder, with title, first and last ask, branch, size and last activity. Headless runs (`claude -p`, the SDK) and AI Agent Manager's own agents are left out. Each one you pick becomes an agent in the same folder that continues the same conversation (`--resume`), with the brief, inbox, PRs and usage tracked from then on.
240
+ **Import** (next to **Save now** in the agent list) lists the Claude Code sessions you started yourself on this machine, from the last 7, 30 or 90 days: with `claude` in a terminal, in the Claude desktop app's Code tab (marked **Claude desktop**, with its title there), or in an editor. They're grouped by folder, with title, first and last ask, branch, size and last activity. Headless runs (`claude -p`, the SDK, built agents) and AI Agent Manager's own agents are left out. Each one you pick becomes an agent in the same folder that continues the same conversation (`--resume`), with the brief, inbox, PRs and usage tracked from then on.
241
241
 
242
- A session still open in a terminal is marked **open in a terminal** (a running `claude` names it) or **maybe open** (a `claude` runs in that folder and the session was active minutes ago). Two places writing one conversation would mix it up, so those continue as a **copy** under a new session ID and the terminal keeps the original. For the same reason, an agent that follows a `/clear` to a new session never picks up a headless run or a session a terminal has open in its folder.
242
+ A session still open in a terminal or the desktop app is marked **open in a terminal** / **open in the desktop app** (a running `claude` names it) or **maybe open** (a `claude` runs in that folder and the session was active minutes ago). Two places writing one conversation would mix it up, so those continue as a **copy** under a new session ID and the terminal keeps the original. For the same reason, an agent that follows a `/clear` to a new session never picks up a headless run or a session a terminal has open in its folder.
243
+
244
+ ### Open an agent in the Claude desktop app
245
+
246
+ **Open in Claude desktop** on a Claude agent (or `agentmgr desktop <agent>`) continues its conversation in the Claude desktop app, using Claude Code's own hand-off (`claude --desktop --resume`). Its session here closes first, and until you resume it here, messages for it (yours, Autopilot's, Landing's) wait instead of starting a second copy. **Resume** picks up what was said in the desktop app, since it's the same session; close it in the desktop app first. Needs macOS or Windows and Claude Code signed in with a Claude subscription; when Claude Code refuses, the reason is shown. Agents in a container, and agents moved to another machine, can't be opened there.
247
+
248
+ With Remote Control on (`"remoteControlAtStartup": true` in `~/.claude/settings.json`), running agents also show in the Claude apps while they run, as live sessions.
243
249
 
244
250
  ## Restarts and reboots
245
251
 
@@ -313,7 +319,8 @@ How it behaves:
313
319
  Every agent has a priority, **P0** (urgent) to **P3** (low). **P2** is the default.
314
320
 
315
321
  - **Look.** P0 shows a solid red chip and a red bar on the agent. P1 shows a red outline chip, and P3 a muted chip. P2 shows nothing, to keep the list calm.
316
- - **Ordering.** Within a project, agents sort by priority, then needs-input, then running. Projects holding a P0 or P1 agent move to the top and show the chip in their header.
322
+ - **Ordering.** In the **By project** order, agents within a project sort by priority, then needs-input, then running. Projects holding a P0 or P1 agent move to the top and show the chip in their header.
323
+ - **Order.** The list starts with the agents created or used most recently on top: one list, each agent with its project. A new agent starts at the top; after that, you or it working in it moves it up (typing, its conversation, its brief); a restart alone doesn't. Above the list, switch to **Running first** (running agents on top, most recently used first, then the rest) or **By project** (the grouping described here). Each browser remembers its choice.
317
324
  - **Setting it.** Use the selector next to the agent's name, the New agents dialog, `add --priority P1`, or `agentmgr priority <agent> P0`.
318
325
  - **Backlog.** Items use the same P0–P3 scale and pass it on to their agents.
319
326
  - **Slack.** Alerts are tagged `[P0]` / `[P1]`.
@@ -525,11 +532,29 @@ Autopilot takes a project's finished items the rest of the way when the [review
525
532
 
526
533
  What it does with work that isn't ready:
527
534
 
528
- - **Not ready, for a concrete reason** (failing CI, acceptance criteria not met, barely verified): the item goes back to the same agent with those reasons. This happens twice at most; after that it waits for you.
535
+ - **Not ready, for a concrete reason** (failing CI, acceptance criteria not met, barely verified): the item goes back to the same agent with its scorecard, as [**✨ Improve**](#review-changes) sends it: the low scores with why, the criteria not met, where a reviewer would look. This happens three times at most (`"autopilot": { "rounds": 3 }`); after that it waits for you.
529
536
  - **Look at these first, a failed step, or a closed pull request:** autopilot stops and it waits for you in the **Inbox** ("Autopilot held"), saying why. You can **Review changes**, **Ship it** (go ahead anyway), or **Send back** with a note.
530
537
 
538
+ **Ship at a score.** Next to the level, choose when it ships: **when ready** (the scorecard says *Ready to approve*), or **at 80+**, **85+**, **90+** or **95+** (`agentmgr backlog autopilot <project> merge --target 85`; `--target none` goes back to when ready; a default for all projects goes in config.json as `"autopilot": { "target": 85 }`). With a score set, work that isn't there yet, *Look at these first* included, goes back to its agent to improve, and is scored again when the agent is done. It ships once the scorecard says ready and rates it at least the target. It waits for you when the tries are used up, or earlier when a try raised the score by less than 3 points, since more of the same won't get there. The item shows the scores so far (*scores 72 → 81 → 87*).
539
+
531
540
  An item whose pull request merges is done. Each item shows where autopilot stands ("pull request open #12", "waiting for checks to merge", "sent back to the agent"). **Ship it** is also on every item in review, so you can ship one by hand with autopilot off. Plugins can still refuse the commit, the pull request or the merge (`agent.commit`, `agent.pr`, `agent.merge`).
532
541
 
542
+ ### Goals
543
+
544
+ A goal is a work order for an outcome, not a task: *"This week: users can sign in with SSO on web, and the API paginates /orders, both with tests."* **+ Goal** at the top of the Backlog tab (or `agentmgr goal add "…" -p web,api`) takes the outcome, when it's due (**today**, **this week** or **no deadline**) and the projects it spans.
545
+
546
+ 1. **Planned.** A model breaks the outcome into tasks, one agent each, each in one of the goal's projects, at most 12. With **Show me the plan before agents start** (`--review`) you see the plan first, untick what you don't want and **Start**; otherwise it starts right away.
547
+ 2. **Worked.** The tasks go to the backlog, tagged with the goal. The backlog's limits start the agents, and where a project's [autopilot](#autopilot) is on, finished work is opened as a pull request (and merged) by itself.
548
+ 3. **Checked.** When every task is finished, the model compares the outcome with what each task delivered (its brief's results and pull requests). Whatever is still missing is queued as new tasks, for up to 2 more rounds; then the goal is done.
549
+
550
+ Each goal's card shows how far it got and keeps three lists current:
551
+
552
+ - **Completed:** finished tasks, with their pull requests.
553
+ - **Pending:** tasks queued, being worked on, or with autopilot.
554
+ - **Follow-ups:** what needs you, with the reason. That covers blocked tasks, work autopilot held, work waiting for your review (autopilot off), and agents that need input, asked a question, seem stuck or went quiet.
555
+
556
+ **Copy summary** (`agentmgr goal show <id>`) gives the same as Markdown for a stand-up or status update. A goal past its due date shows as overdue, with **Carry over to tomorrow / next week**. **Stop** cancels its queued tasks; agents already working go on as ordinary backlog items. `agentmgr goal ls | approve | replan | extend | stop | rm`.
557
+
533
558
  ## Playbooks
534
559
 
535
560
  Saved requests you run again: **Backlog → Playbooks**, **Save as playbook…** in New agents, or `agentmgr playbook`. A playbook is a request, the projects to run it in (one agent each), and optionally a model, permission mode, priority and schedule:
@@ -571,6 +596,10 @@ The **Inbox** tab (and `agentmgr inbox`) lists what needs you, across all agents
571
596
  | AI review | The agent said it was done and the judge checked the work against the intent and brief | **Send back to finish** (types the missing items in) or **Looks good** |
572
597
  | Stuck? | The agent seems to be going in circles | Send the suggested nudge (edit it first if you like) or dismiss |
573
598
  | Overlap | It changes the same files as another agent | Tell one or both agents; see the suggested merge order |
599
+ | Follow up | An agent used in the last 3 days has been quiet for 2 hours and isn't finished: still open, or its session ended by itself or was closed by the session cap or clean up | Send the suggested nudge (edit it first), **Resume** a closed one, or **Close session**; **Later** (4 hours) or **Not needed** (until it's used again) |
600
+ | Close session? | It's done (its brief says so, or its pull request merged), quiet for 2 hours, and its session is still open | **Close session** (it resumes when you open it), **Later** or **Not needed** |
601
+
602
+ Follow-up reminders skip agents that are working or already waiting on you for something else, and agents you closed yourself. Change the timing in config.json: `"reminders": { "quietHours": 2, "recentDays": 3, "laterHours": 4 }`, or turn them off with `"enabled": false`. From the command line: `agentmgr remind <agent> later|dismiss`.
574
603
 
575
604
  **Fewer questions: approval rules.** Each yes you give a permission prompt counts toward the command, per repo (`npm test`, `pytest`, `git status`; an MCP tool; fetching from a site). After 3, the inbox offers to always allow it there. An allowed rule goes to every agent in that repo when it starts (Claude Code's `--allowedTools`), and answers its prompts that are already open, so you aren't asked again. Rules are never offered for commands that chain, redirect or substitute (`&&`, `|`, `>`, `$(…)`), or that delete, escalate, publish or reach the network (`rm`, `sudo`, `git push`, `npm publish`, `curl`…). Settings → Approval rules (or `agentmgr rules`) lists them with how many prompts each answered; **Remove** to be asked again. Stored in `~/.agentmanager/rules.json`; In config.json, `"rules": { "auto": false }` stops rules answering open prompts and `"rules": { "suggestAfter": 5 }` changes the count. Claude Code agents only for now.
576
605
 
@@ -908,6 +937,19 @@ Agents started this way are marked **⚡ GitHub** or **⚡ webhook**, Slack aler
908
937
 
909
938
  **Results** in the top bar shows how agents did over the last 7, 30 or 90 days (or all time): how many started and how many opened a pull request, PRs merged and closed, the merge rate, the median time from starting an agent to its first PR and to merge, and the cost per merged PR. The same by engine and model (which one gets merged more, for less), by where agents came from (you, the assistant, triggers, the backlog, teams, races) and by project. `agentmgr stats --days 30`.
910
939
 
940
+ ### Work record
941
+
942
+ **Work record…** in the menu (and `agentmgr worklog`) keeps what your agents got done, for your own notes and for performance reviews. It's recorded as it happens, into two spreadsheets (CSV files that open in Excel or Numbers, or File → Import in Google Sheets):
943
+
944
+ - **`~/.agentmanager/worklog.csv`**: one row per event, with the date, project, agent, title, link, linked bugs, engine and model:
945
+ - *pull request opened*, *merged* (with the hours from opening to merge) or *closed* unmerged;
946
+ - *bug fixed*: a bug the agent's request linked (a Jira or GitHub issue), once its pull request merges;
947
+ - *issue filed*: an issue the agent opened, from a `- Filed: <link> <title>` line in its brief's Results (agents are asked to add one for each);
948
+ - *agent finished*: its brief says done, with the hours since it started and what it cost.
949
+ - **`~/.agentmanager/worklog-weekly.csv`**: one row per week, Monday to Sunday, added once the week is over. It counts PRs opened, merged and closed, the merge rate, bugs fixed, issues filed, agents finished, the median time to merge, and the week's spend.
950
+
951
+ Rows are only ever added; edit or chart them in your spreadsheet. The first time, the history already recorded is written too, with the dates it happened. The dialog shows a period's totals, the weeks and every event. **Copy summary** (`agentmgr worklog --days 90 --summary`) gives the period as Markdown with links, ready for a review document. To keep the files somewhere else, such as a synced folder, set `"worklog": { "dir": "~/Documents/agent-work" }` in config.json; `"enabled": false` stops recording.
952
+
911
953
  ### Spend and budgets
912
954
 
913
955
  The same dialog shows what agents cost today, the last two weeks and the costliest agents, from the cost Claude Code records for each session (the API price, even on a subscription plan; Codex and Antigravity record none). Set limits there, with `agentmgr spend --per-agent 5 --per-day 50`, or in config.json (`"budgets": { "perAgentUsd": 5, "perDayUsd": 50 }`):
@@ -919,6 +961,8 @@ Alerts for both go to Slack with **Alerts → nears or reaches its budget**.
919
961
 
920
962
  ## Cleaning up old agents
921
963
 
964
+ **Close all** (next to the agent counts above the list) closes every open agent session at once. The assistant's stays open, and so do agents working at that moment unless you choose **Close them too**. Closed sessions keep their conversation and resume when you open them. From the command line: `agentmgr close --all`.
965
+
922
966
  Agents you no longer use keep a session open and a worktree on disk. **Clean up** (in the top bar, or `agentmgr cleanup`) closes agents with no activity for a while and deletes agents that stayed closed long after that. Pick a strategy:
923
967
 
924
968
  | Strategy | What happens on its own (checked every few hours) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.16.0",
3
+ "version": "1.18.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
package/public/app.js CHANGED
@@ -15,6 +15,8 @@ import { initReview } from '/review.js';
15
15
  import { initLand, prChips } from '/land.js';
16
16
  import { initTriggers } from '/triggers.js';
17
17
  import { initSpend } from '/spend.js';
18
+ import { initGoals } from '/goals.js';
19
+ import { initWorklog } from '/worklog.js';
18
20
  import { initPlaybooks } from '/playbooks.js';
19
21
  import { initSetup } from '/setup.js';
20
22
  import { initUpdate } from '/update.js';
@@ -58,6 +60,16 @@ const saveRecent = () => {
58
60
  localStorage.setItem('agentmgr.recentDays', String(recent.days));
59
61
  } catch {}
60
62
  };
63
+ // How the agents list is ordered: recently used (the default) or running first, one list each; or grouped by project.
64
+ const ORDERS = ['recent', 'running', 'project'];
65
+ let listOrder = (() => {
66
+ try {
67
+ const v = localStorage.getItem('agentmgr.listOrder');
68
+ return ORDERS.includes(v) ? v : 'recent';
69
+ } catch {
70
+ return 'recent';
71
+ }
72
+ })();
61
73
 
62
74
  // ------------------------------------------------------------------ helpers
63
75
 
@@ -114,6 +126,8 @@ async function act(fn, okMsg) {
114
126
  const reviewUi = initReview({ api, esc, toast, agents, $ });
115
127
  const triggersUi = initTriggers({ api, esc, toast, $ });
116
128
  initSpend({ api, esc, toast, $ });
129
+ const goalsUi = initGoals({ api, esc, toast, $, ago: (t) => ago(t), getProjects: () => projectsState, rerender: () => renderBacklog() });
130
+ initWorklog({ api, esc, toast, $ });
117
131
  initSetup({ api, esc, $ });
118
132
  const updateUi = initUpdate({ api, esc, toast, $ });
119
133
  initMenu({ api, esc, toast, $ });
@@ -730,15 +744,18 @@ const prioChip = (p, { always = false } = {}) =>
730
744
 
731
745
  const noRepo = (a) => a.kind === 'general' || a.kind === 'assistant';
732
746
 
733
- function agentItem(a) {
747
+ function agentItem(a, { project = false } = {}) {
734
748
  const st = statusOf(a);
735
749
  const idle = !isActive(a);
750
+ const p = project && a.projectInfo && !['other', 'general', 'assistant'].includes(a.projectInfo.key) ? a.projectInfo : null;
736
751
  return `<li data-id="${a.id}" ${a.kind === 'general' || a.kind === 'assistant' ? '' : 'draggable="true" '}class="agent pr${a.priority ?? 2} ${a.id === selectedId ? 'selected' : ''} ${idle ? 'idle' : ''}">
737
752
  <div class="line1">${prioChip(a.priority ?? 2)}${a.results?.outcome === 'blocked' ? '<span class="outcome-mark" title="Blocked">⛔</span>' : a.results?.outcome === 'done' ? '<span class="outcome-mark" title="Done">✅</span>' : ''}<span class="name">${esc(a.name)}</span>${flags(a)}<span class="pill ${st}">${pillText(st)}</span></div>
738
753
  <div class="intent" title="${esc(describeTitle(a) ?? '')}">${a.builds ? `<span class="tag assistant" title="Develops the agent ${esc(a.builds.name)} (Built tab)">⚙ builds agent</span> ` : ''}${a.kind === 'general' ? '<span class="tag">general</span> ' : a.kind === 'assistant' ? '<span class="tag assistant">assistant</span> ' : a.startedBy ? '<span class="tag assistant" title="Started by the assistant">🤖 by assistant</span> ' : a.trigger ? `<span class="tag assistant" title="Started from ${a.trigger.source === 'github' ? 'a labeled GitHub issue' : 'the webhook'}${a.trigger.url ? `: ${esc(a.trigger.url)}` : ''}">⚡ ${a.trigger.source === 'github' ? 'GitHub' : 'webhook'}</span> ` : a.playbook ? `<span class="tag assistant" title="Started by the playbook ${esc(a.playbook.name)}">▶ ${esc(a.playbook.name)}</span> ` : ''}${a.engine && a.engine !== 'claude' ? `<span class="tag engine">${esc(ENGINE_LABEL[a.engine] ?? a.engine)}</span> ` : ''}${a.isolation === 'container' ? '<span class="tag engine" title="Runs in its own Docker container: it sees only its own folder">📦 container</span> ' : ''}${esc(describe(a) || (a.kind === 'assistant' ? 'Finds new work and starts agents for it' : 'General session'))}</div>
739
754
  ${a.status === 'preparing' && a.progress ? `<div class="progress-line">${esc(progressText(a.progress))}</div>` : ''}
740
755
  <div class="meta">
741
756
  <span class="mono">${a.id}</span>
757
+ ${p ? `<span class="tag proj" title="Project: ${esc(p.full || p.name)}">${esc(p.shortcut || p.name)}</span>` : ''}
758
+ ${!idle && project && a.activeAt ? `<span title="Last used">${ago(a.activeAt)}</span>` : ''}
742
759
  ${idle && a.activeAt ? `<span title="Idle: no work and no input from you for over a day">💤 ${ago(a.activeAt)}</span>` : ''}
743
760
  ${a.git?.branch ? `<span class="branch" title="${esc(a.git.branch)}">⎇ ${esc(a.git.branch)}</span>` : ''}
744
761
  ${a.prs.length ? `<span>${a.prs.length} PR</span>` : ''}
@@ -804,6 +821,13 @@ function projectGroups(list) {
804
821
  );
805
822
  }
806
823
 
824
+ /** One list, most recently used first (Running first: the running agents, then the rest). */
825
+ const usedAt = (a) => a.activeAt ?? a.createdAt ?? '';
826
+ function orderedAgents(list) {
827
+ const top = (a) => (listOrder === 'running' && !a.runtime.running ? 1 : 0);
828
+ return [...list].sort((a, b) => top(a) - top(b) || usedAt(b).localeCompare(usedAt(a)));
829
+ }
830
+
807
831
  function renderList() {
808
832
  if (dragging) return void (listStale = true);
809
833
  const waiting = [...agents.values()].filter((a) => a.runtime.attention).length;
@@ -831,16 +855,19 @@ function renderList() {
831
855
  const all = [...agents.values()];
832
856
  const projects = new Set(all.map((a) => a.projectInfo?.key ?? 'other')).size;
833
857
  const running = all.filter((a) => a.runtime.running).length;
858
+ const open = all.filter((a) => a.runtime.running && a.kind !== 'assistant').length;
834
859
  $('#counts').innerHTML = agents.size
835
860
  ? `<span title="Projects">${projects} project${projects === 1 ? '' : 's'}</span><span>${agents.size} agents</span><span>${running} running</span>
836
861
  ${waiting ? `<span class="fail">${waiting} need${waiting === 1 ? 's' : ''} input</span>` : ''}
837
- <span class="spacer"></span><button class="link" id="import-btn" title="Continue Claude sessions you started in a terminal on this machine">Import</button><button class="link" id="flush-btn" title="Save session IDs, terminal scrollback and state to disk now (also automatic every 30s)">Save now</button>`
862
+ <span class="spacer"></span><button class="link" id="import-btn" title="Continue Claude sessions you started in a terminal or the Claude desktop app on this machine">Import</button>${open ? `<button class="link" id="close-all-btn" title="Close every open agent session (the assistant's stays); they resume when you open them">Close all</button>` : ''}<button class="link" id="flush-btn" title="Save session IDs, terminal scrollback and state to disk now (also automatic every 30s)">Save now</button>`
838
863
  : '';
839
864
 
840
865
  // Every agent a project has, also the ones a filter hides.
841
866
  const totals = new Map();
842
867
  for (const a of all) totals.set(a.projectInfo?.key ?? 'other', (totals.get(a.projectInfo?.key ?? 'other') ?? 0) + 1);
843
868
 
869
+ $('#list-order').value = listOrder;
870
+ if (listOrder !== 'project') return void morph($('#agent-list'), orderedAgents(shown).map((a) => agentItem(a, { project: true })).join(''));
844
871
  morph($('#agent-list'), projectGroups(shown)
845
872
  .map((g) => {
846
873
  const total = totals.get(g.key) ?? g.agents.length;
@@ -901,6 +928,7 @@ function renderBacklog() {
901
928
  <button class="link" data-bl="playbooks" title="Saved requests you run again, by hand or on a schedule">Playbooks</button>
902
929
  </div>
903
930
  ${!backlogState.autoRun ? '<p class="hint bl-paused">Paused: queued items wait until you resume.</p>' : ''}
931
+ ${goalsUi.html()}
904
932
  ${items.length
905
933
  ? `<ul class="agent-list">${[...groups.values()]
906
934
  .map((g) => {
@@ -910,7 +938,7 @@ function renderBacklog() {
910
938
  ${p.shortcut ? `<span class="shortcut">${esc(p.shortcut)}</span>` : ''}
911
939
  <span class="pname">${esc(g.name)}</span>
912
940
  <button class="link" data-bl="limit" data-project="${esc(g.key)}" data-name="${esc(g.name)}" title="How many items of this project agents work on at once">${p.limit} at a time ✎</button>
913
- <label class="bl-autopilot" title="${esc(AUTOPILOT_HINT)}">🛫 <select aria-label="Autopilot" data-bl-autopilot="${esc(g.key)}">${Object.entries(AUTOPILOT_LEVELS).map(([v, l]) => `<option value="${v}" ${(p.autopilot ?? 'off') === v ? 'selected' : ''}>${l}</option>`).join('')}</select></label>
941
+ <label class="bl-autopilot" title="${esc(AUTOPILOT_HINT)}">🛫 <select aria-label="Autopilot" data-bl-autopilot="${esc(g.key)}">${Object.entries(AUTOPILOT_LEVELS).map(([v, l]) => `<option value="${v}" ${(p.autopilot ?? 'off') === v ? 'selected' : ''}>${l}</option>`).join('')}</select>${(p.autopilot ?? 'off') !== 'off' ? ` <select aria-label="Ships at" title="${esc(TARGET_HINT)}" data-bl-target="${esc(g.key)}">${AUTOPILOT_TARGETS.map((n) => `<option value="${n}" ${(p.target ?? 0) === n ? 'selected' : ''}>${n ? `at ${n}+` : 'when ready'}</option>`).join('')}</select>` : ''}</label>
914
942
  </div>
915
943
  <ul class="project-agents">${g.items.map(itemRow).join('')}</ul>
916
944
  </li>`;
@@ -922,13 +950,16 @@ function renderBacklog() {
922
950
 
923
951
  const AUTOPILOT_LEVELS = { off: 'Off', pr: 'Open PRs', merge: 'Merge' };
924
952
  const AUTOPILOT_HINT = 'When an item is done and its review scorecard says ready: Open PRs commits, pushes and opens the pull request; Merge also merges it once checks pass. Not-ready work goes back to the agent; anything else waits for you in the inbox.';
953
+ const AUTOPILOT_TARGETS = [0, 80, 85, 90, 95];
954
+ const TARGET_HINT = 'When it ships. At a score: work goes back to its agent to improve until the scorecard says ready and rates it at least that, a few times at most, stopping early when a try no longer raises the score.';
925
955
  const AUTOPILOT_STATE = { queued: 'going ahead', scoring: 'scoring the changes', shipping: 'opening the pull request', pr: 'pull request open', landing: 'waiting for checks to merge', merging: 'merging', returned: 'sent back to the agent', held: 'waiting for you', merged: 'merged' };
926
956
  /** Where autopilot stands on an item, under it in the backlog. */
927
957
  function autopilotLine(it) {
928
958
  const ap = it.autopilot;
929
959
  if (!ap?.state || !['review', 'active', 'done'].includes(it.status) || (it.status === 'active' && ap.state !== 'returned')) return '';
930
960
  const pr = ap.pr ? ` <a href="${esc(ap.pr)}" target="_blank" rel="noopener">#${esc(ap.pr.split('/').pop())} ↗</a>` : '';
931
- return `<p class="hint bl-ai bl-ap ${ap.state === 'held' ? 'held' : ''}">🛫 Autopilot: ${AUTOPILOT_STATE[ap.state] ?? esc(ap.state)}${pr}${ap.note ? ` · ${esc(ap.note)}` : ''}</p>`;
961
+ const trail = ap.scores?.length > (ap.state === 'returned' ? 1 : 0) ? ` · scores ${ap.scores.map((n) => n ?? '?').join(' → ')}` : '';
962
+ return `<p class="hint bl-ai bl-ap ${ap.state === 'held' ? 'held' : ''}">🛫 Autopilot: ${AUTOPILOT_STATE[ap.state] ?? esc(ap.state)}${pr}${ap.note ? ` · ${esc(ap.note)}` : ''}${trail}</p>`;
932
963
  }
933
964
 
934
965
  function itemRow(it) {
@@ -972,12 +1003,18 @@ function showTab(tab) {
972
1003
  for (const b of document.querySelectorAll('.side-tab')) b.onclick = () => showTab(b.dataset.tab);
973
1004
 
974
1005
  $('#backlog-view').addEventListener('change', (e) => {
1006
+ const tkey = e.target.dataset?.blTarget;
1007
+ if (tkey) {
1008
+ const n = Number(e.target.value);
1009
+ return act(() => api('POST', '/backlog/settings', { project: tkey, target: n || null }), n ? `Autopilot ships at ${n}/100 or more` : 'Autopilot ships when the scorecard says ready');
1010
+ }
975
1011
  const key = e.target.dataset?.blAutopilot;
976
1012
  if (!key) return;
977
1013
  const level = e.target.value;
978
1014
  act(() => api('POST', '/backlog/settings', { project: key, autopilot: level }), level === 'off' ? 'Autopilot off' : `Autopilot: ${AUTOPILOT_LEVELS[level]}`);
979
1015
  });
980
1016
  $('#backlog-view').addEventListener('click', async (e) => {
1017
+ if (e.target.closest('[data-goal-act]')) return goalsUi.onClick(e);
981
1018
  const el = e.target.closest('[data-bl]');
982
1019
  if (!el) return;
983
1020
  const what = el.dataset.bl;
@@ -1051,7 +1088,7 @@ function flags(a) {
1051
1088
  }
1052
1089
 
1053
1090
  const TRIAGED = { now: 'sent (AI: urgent)', digest: 'held for the digest', skip: 'dropped by the AI judge' };
1054
- const NEED_ORDER = { approval: 0, prompt: 0, waiting: 1, plan: 1, question: 1, team: 1, rule: 2, review: 2, autopilot: 2, stuck: 3, conflict: 4, repeat: 5 };
1091
+ const NEED_ORDER = { approval: 0, prompt: 0, waiting: 1, plan: 1, question: 1, team: 1, rule: 2, review: 2, autopilot: 2, stuck: 3, conflict: 4, reminder: 5, close: 5, repeat: 5 };
1055
1092
  /** What an agent needs from the user. `both`: overlaps on both agents (detail), else only the one that should rebase (inbox). */
1056
1093
  function needsFor(a, { both = false } = {}) {
1057
1094
  const items = [];
@@ -1061,6 +1098,7 @@ function needsFor(a, { both = false } = {}) {
1061
1098
  if (a.aiReview?.verdict && !a.aiReview.seen) items.push({ a, kind: 'review', key: `review:${a.id}` });
1062
1099
  for (const q of a.questions ?? []) if (!q.answer) items.push({ a, kind: 'question', key: `q:${a.id}:${q.id}`, q });
1063
1100
  for (const f of a.stuck ?? []) items.push({ a, kind: 'stuck', key: `stuck:${a.id}:${f.key}`, f });
1101
+ if (a.followUp) items.push({ a, kind: a.followUp.kind === 'close' ? 'close' : 'reminder', key: `reminder:${a.id}`, r: a.followUp });
1064
1102
  for (const g of a.conflicts ?? []) if (both || g.mergeFirst !== a.id) items.push({ a, kind: 'conflict', key: `conflict:${a.id}:${g.agent.id}`, g });
1065
1103
  return items;
1066
1104
  }
@@ -1096,7 +1134,7 @@ function inboxItems() {
1096
1134
  .sort((x, y) => NEED_ORDER[x.kind] - NEED_ORDER[y.kind] || (x.a.priority ?? 2) - (y.a.priority ?? 2));
1097
1135
  }
1098
1136
 
1099
- const NEED_LABEL = { repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', plan: 'Plan review', question: 'Question', review: 'AI review', stuck: 'Stuck?', conflict: 'Overlap' };
1137
+ const NEED_LABEL = { reminder: 'Follow up', close: 'Close session?', repeat: 'Make it a playbook?', autopilot: 'Autopilot held', rule: 'Always allow?', approval: 'Approval', team: 'Team', prompt: 'Needs input', waiting: 'Waiting on you', plan: 'Plan review', question: 'Question', review: 'AI review', stuck: 'Stuck?', conflict: 'Overlap' };
1100
1138
  /** Why the AI judge thinks so, as a small tag. */
1101
1139
  const aiTag = (confidence, what = 'AI') => `<span class="tag ai" title="Judged by a model from the agent's activity; your reactions tune later calls">🤖 ${what}${confidence != null ? ` ${Math.round(confidence * 100)}%` : ''}</span>`;
1102
1140
  /** What a permission prompt asks about: the command, file or tool. */
@@ -1120,6 +1158,7 @@ function groupCard(g) {
1120
1158
  <p class="need-title">${toolLine(t)}</p><p class="hint">${names}</p>
1121
1159
  <div class="need-actions"><button class="small primary" data-ib="yes-all">Yes to all ${g.length}</button></div></div>`;
1122
1160
  }
1161
+ const FOLLOW_UP = "Where are you on this? Carry on with the next step, or update the brief with what's left and what's blocking you.";
1123
1162
  function needCard(it, { inDetail = false } = {}) {
1124
1163
  const { a } = it;
1125
1164
  const who = inDetail
@@ -1202,6 +1241,19 @@ function needCard(it, { inDetail = false } = {}) {
1202
1241
  <input data-draft="${esc(it.key)}:text" placeholder="Or type an answer…" value="${draft('text')}" />
1203
1242
  <button class="small primary">Send</button>
1204
1243
  </form>`;
1244
+ } else if (it.kind === 'reminder' || it.kind === 'close') {
1245
+ const r = it.r;
1246
+ const later = `<button type="button" class="small ghost" data-ib="remind-later" title="Remind me again in a few hours">Later</button><button type="button" class="small ghost" data-ib="remind-dismiss" title="No reminder until it's used again">Not needed</button>`;
1247
+ body = `<p class="need-title">${esc(r.title)} <span class="hint">last used ${ago(r.since)}</span></p>
1248
+ ${r.detail ? `<p class="hint">${esc(r.detail)}</p>` : ''}
1249
+ ${it.kind === 'close'
1250
+ ? `<div class="need-actions"><button class="small primary" data-ib="remind-close">Close session</button><button class="small ghost" data-ib="terminal">Open terminal</button>${later}</div>`
1251
+ : r.closed
1252
+ ? `<div class="need-actions"><button class="small primary" data-ib="remind-resume">Resume</button>${later}</div>`
1253
+ : `<form class="need-reply col" data-ib-form="remind">
1254
+ <textarea rows="2" data-draft="${esc(it.key)}:text">${draft('text', FOLLOW_UP)}</textarea>
1255
+ <div class="need-actions"><button class="small primary">Send</button><button type="button" class="small ghost" data-ib="terminal">Open terminal</button><button type="button" class="small ghost" data-ib="remind-close">Close session</button>${later}</div>
1256
+ </form>`}`;
1205
1257
  } else if (it.kind === 'stuck') {
1206
1258
  const f = it.f;
1207
1259
  const judged = f.ai?.verdict === 'stuck' ? aiTag(f.ai.confidence, 'confirmed') : f.ai?.verdict === 'checking' ? '<span class="tag ai">🤖 checking…</span>' : '';
@@ -1355,6 +1407,14 @@ async function onNeed(e) {
1355
1407
  return act(async () => upsert(await api('POST', `/agents/${id}/conflicts/dismiss`, { with: el.dataset.with })));
1356
1408
  case 'waiting-choice':
1357
1409
  return act(async () => upsert(await api('POST', `/agents/${id}/waiting/answer`, { text: el.dataset.text })), 'Answer queued');
1410
+ case 'remind-close':
1411
+ return act(async () => upsert(await api('POST', `/agents/${id}/stop`)), 'Session closed; resume it any time');
1412
+ case 'remind-resume':
1413
+ return act(async () => upsert(await api('POST', `/agents/${id}/start`, {})), 'Resumed');
1414
+ case 'remind-later':
1415
+ return act(async () => upsert(await api('POST', `/agents/${id}/reminder`, { action: 'later' })), 'Reminding you later');
1416
+ case 'remind-dismiss':
1417
+ return act(async () => upsert(await api('POST', `/agents/${id}/reminder`, { action: 'dismiss' })));
1358
1418
  case 'waiting-dismiss':
1359
1419
  return act(async () => upsert(await api('POST', `/agents/${id}/waiting/dismiss`)));
1360
1420
  case 'review-finish':
@@ -1384,6 +1444,8 @@ async function onNeedSubmit(e) {
1384
1444
  const done = () => needDrafts.delete(field.dataset.draft);
1385
1445
  if (form.dataset.ibForm === 'waiting') {
1386
1446
  await act(async () => upsert(await api('POST', `/agents/${id}/waiting/answer`, { text })), 'Answer queued');
1447
+ } else if (form.dataset.ibForm === 'remind') {
1448
+ await act(() => api('POST', `/agents/${id}/tell`, { text }), 'Sent');
1387
1449
  } else if (form.dataset.ibForm === 'answer') {
1388
1450
  await act(async () => upsert(await api('POST', `/agents/${id}/answer`, { question: form.dataset.q, text })), 'Answer sent');
1389
1451
  } else {
@@ -1843,6 +1905,7 @@ function renderDetail() {
1843
1905
  ? ''
1844
1906
  : `<button data-act="start" ${a.status === 'preparing' ? 'disabled' : ''}>Resume in background</button>`}
1845
1907
  <button data-act="fresh" ${running || a.status === 'preparing' ? 'disabled' : ''} title="Start over with a new session ID (old ones are kept)">New session</button>
1908
+ ${(a.engine ?? 'claude') === 'claude' && a.isolation !== 'container' && !a.movedTo && !REMOTE ? `<button data-act="desktop" ${a.sessionId && a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Continue this conversation in the Claude desktop app. Its session here closes; Resume here later picks up what was said there">Open in Claude desktop</button>` : ''}
1846
1909
  <button data-act="shell" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="A separate terminal in this agent's folder for running commands by hand">Open shell</button>
1847
1910
  ${noRepo(a) ? '' : `<button data-act="changes" ${a.workdir && a.status !== 'preparing' ? '' : 'disabled'} title="Read its changes, comment on lines for the agent, commit and open a pull request">Review changes${a.git?.dirtyFiles ? ` <span class="count">${a.git.dirtyFiles}</span>` : ''}</button>`}
1848
1911
  <button data-act="fork" ${a.workdir && a.git?.branch ? '' : 'disabled'} title="A new agent with this one's code and conversation, in its own worktree, to try another approach">Fork</button>
@@ -1859,6 +1922,7 @@ function renderDetail() {
1859
1922
  ${it.status === 'review' ? `<span class="spacer"></span><button class="small primary" data-backlog-accept="${it.id}">Accept</button> <button class="small" data-backlog-reopen="${it.id}">Reopen</button>` : ''}</div>`;
1860
1923
  })()}
1861
1924
  ${a.error ? `<div class="error-box">${esc(a.error)}</div>` : ''}
1925
+ ${a.desktop && !running ? `<p class="hint">Continued in the <b>Claude desktop app</b> ${ago(a.desktop.at)}. Messages for it wait here; <b>Resume</b> picks up what was said there (close it in the desktop app first).</p>` : ''}
1862
1926
  ${a.movedTo ? `<p class="hint">Moved to <b>${esc(a.movedTo.machine)}</b> ${ago(a.movedTo.at)}: it continues there with the same conversation and work. This copy stays closed; delete it when you no longer need its folder.</p>` : ''}
1863
1927
  ${a.movedFrom ? `<p class="hint">Moved here from <b>${esc(a.movedFrom.machine ?? 'another machine')}</b> ${ago(a.movedFrom.at)}, with its conversation and uncommitted work.</p>` : ''}
1864
1928
  ${!running && a.closedBy === 'cap' ? `<p class="hint">Closed ${ago(a.closedAt)} to stay under the limit on open agents (Settings), as the one idle longest. Resume it any time${a.keep ? '' : ', or mark it Keep'}.</p>` : ''}
@@ -2765,7 +2829,8 @@ function renderImport() {
2765
2829
  (s) => `<label class="import-row ${s.exists ? '' : 'off'}">
2766
2830
  <input type="checkbox" data-sid="${s.sessionId}" ${importPicked.has(s.sessionId) ? 'checked' : ''} ${s.exists ? '' : 'disabled'}>
2767
2831
  <span class="import-main"><b>${esc(s.title || s.firstAsk.slice(0, 80))}</b>
2768
- ${s.inUse ? `<span class="tag warn" title="${s.inUse === 'open' ? 'A claude process in a terminal has this session open' : 'A claude process runs in this folder and the session was active minutes ago'}">${s.inUse === 'open' ? 'open in a terminal' : 'maybe open in a terminal'}</span>` : ''}
2832
+ ${s.source === 'desktop' ? `<span class="tag" title="Started in the Claude desktop app${s.archived ? '; archived there' : ''}">Claude desktop${s.archived ? ' · archived' : ''}</span>` : s.source === 'editor' ? '<span class="tag" title="Started in an editor (VS Code, JetBrains)">editor</span>' : ''}
2833
+ ${s.inUse ? `<span class="tag warn" title="${s.inUse === 'open' ? 'A claude process has this session open' : 'A claude process runs in this folder and the session was active minutes ago'}">${s.inUse === 'open' ? 'open' : 'maybe open'} ${s.source === 'desktop' ? 'in the desktop app' : 'in a terminal'}</span>` : ''}
2769
2834
  <span class="hint">${s.title ? `${esc(s.firstAsk.slice(0, 120))}${s.lastAsk ? ` … last: ${esc(s.lastAsk.slice(0, 80))}` : ''}` : s.lastAsk ? `last: ${esc(s.lastAsk.slice(0, 100))}` : ''}</span>
2770
2835
  <span class="hint">${ago(s.lastActivity)}${s.branch ? ` · ⎇ ${esc(s.branch)}` : ''} · ${Math.max(1, Math.round(s.bytes / 1024))} KB · <code>${s.sessionId.slice(0, 8)}</code></span>
2771
2836
  </span></label>`,
@@ -2773,13 +2838,13 @@ function renderImport() {
2773
2838
  .join('')}</div>`,
2774
2839
  )
2775
2840
  .join('')
2776
- : `<p class="hint">${importSessions.length ? 'Nothing matches.' : 'No Claude sessions started in a terminal in this period (AI Agent Manager\'s own agents are left out).'}</p>`;
2841
+ : `<p class="hint">${importSessions.length ? 'Nothing matches.' : 'No Claude sessions started in a terminal or the Claude desktop app in this period (AI Agent Manager\'s own agents are left out).'}</p>`;
2777
2842
  const picked = importSessions.filter((s) => importPicked.has(s.sessionId));
2778
2843
  const open = picked.filter((s) => s.inUse).length;
2779
2844
  Object.assign($('#import-go'), {
2780
2845
  disabled: !picked.length,
2781
2846
  textContent: picked.length ? `Continue ${picked.length} session${picked.length > 1 ? 's' : ''}${open ? ` (${open} as a copy)` : ''}` : 'Continue',
2782
- title: open ? 'Sessions still open in a terminal continue as a copy, so the terminal keeps the original' : '',
2847
+ title: open ? 'Sessions still open in a terminal or the desktop app continue as a copy, so the original stays there' : '',
2783
2848
  });
2784
2849
  }
2785
2850
  $('#import-list').addEventListener('change', (e) => {
@@ -3199,8 +3264,21 @@ function agentChanged(a) {
3199
3264
  sidePane?.agentChanged(a);
3200
3265
  }
3201
3266
 
3267
+ /** Close all: every open session but the assistant's; agents working right now only when you say so. */
3268
+ async function closeAll(working = false) {
3269
+ const open = [...agents.values()].filter((a) => a.runtime.running && a.kind !== 'assistant');
3270
+ const busy = open.filter((a) => a.runtime.busy).length;
3271
+ if (!working && !confirm(`Close ${open.length - busy} open session${open.length - busy === 1 ? '' : 's'}? They resume when you open them.${busy ? `\n\n${busy} working right now stay open.` : ''}`)) return;
3272
+ const r = await act(() => api('POST', '/agents/close-all', { working }));
3273
+ if (!r) return;
3274
+ const msg = `Closed ${r.closed.length} session${r.closed.length === 1 ? '' : 's'}${r.failed.length ? `; ${r.failed.length} couldn't be closed` : ''}`;
3275
+ if (r.working.length) toast(`${msg}. ${r.working.length} still working: ${r.working.map((x) => x.name).slice(0, 3).join(', ')}${r.working.length > 3 ? '…' : ''}`, 10000, { label: 'Close them too', run: () => closeAll(true) });
3276
+ else toast(msg);
3277
+ }
3278
+
3202
3279
  $('#counts').addEventListener('click', (e) => {
3203
3280
  if (e.target.id === 'import-btn') return openImport();
3281
+ if (e.target.id === 'close-all-btn') return closeAll();
3204
3282
  if (e.target.id !== 'flush-btn') return;
3205
3283
  act(async () => {
3206
3284
  const r = await api('POST', '/flush');
@@ -3411,6 +3489,14 @@ $('#detail-body').addEventListener('click', async (e) => {
3411
3489
  term.open(a.id);
3412
3490
  });
3413
3491
  break;
3492
+ case 'desktop':
3493
+ btn.disabled = true;
3494
+ btn.textContent = 'Opening…';
3495
+ act(async () => upsert(await api('POST', `/agents/${a.id}/desktop`)), 'Opened in the Claude desktop app; Resume here picks it back up').finally(() => {
3496
+ btn.disabled = false;
3497
+ btn.textContent = 'Open in Claude desktop';
3498
+ });
3499
+ break;
3414
3500
  case 'stop':
3415
3501
  btn.disabled = true;
3416
3502
  act(async () => upsert(await api('POST', `/agents/${a.id}/stop`)), 'Session closed; the ID is kept for resuming');
@@ -3467,6 +3553,13 @@ $('#filter').addEventListener('input', (e) => {
3467
3553
  renderList();
3468
3554
  });
3469
3555
 
3556
+ $('#list-order').addEventListener('change', (e) => {
3557
+ listOrder = ORDERS.includes(e.target.value) ? e.target.value : 'recent';
3558
+ try {
3559
+ localStorage.setItem('agentmgr.listOrder', listOrder);
3560
+ } catch {}
3561
+ renderList();
3562
+ });
3470
3563
  $('#recent-days').value = recent.days;
3471
3564
  $('#recent-on').addEventListener('change', (e) => {
3472
3565
  recent.on = e.target.checked;
@@ -3830,6 +3923,7 @@ function handleEvent(msg) {
3830
3923
  agents.clear();
3831
3924
  msg.agents.forEach((a) => agents.set(a.id, a));
3832
3925
  if (msg.backlog) backlogState = msg.backlog;
3926
+ if (msg.goals) goalsUi.set(msg.goals);
3833
3927
  if (msg.projects) projectsState = msg.projects;
3834
3928
  races.clear();
3835
3929
  for (const r of msg.races ?? []) races.set(r.id, r);
@@ -3879,6 +3973,8 @@ function handleEvent(msg) {
3879
3973
  builtUi.render();
3880
3974
  } else if (msg.t === 'backlog') {
3881
3975
  backlogState = msg.backlog;
3976
+ } else if (msg.t === 'goals') {
3977
+ goalsUi.set(msg.goals);
3882
3978
  } else if (msg.t === 'projects') {
3883
3979
  projectsState = msg.projects;
3884
3980
  renderProjectOptions();