ai-agentmanager 1.35.0 → 1.37.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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.37.0 (2026-11-10)
4
+
5
+ - **Split screen, as in VS Code.** The area beside the agents list splits right or down into groups, each showing an agent's session or one of its shells, next to the usual panel with the agent's details. Split with **⊞ Split screen** in the terminal bar, **Ctrl+\\** (Ctrl+Shift+\\ splits down) or the buttons on a group; up to six groups. Load a session into a group by dragging an agent onto it (onto its right or bottom edge to split there), from the group's menu (open sessions first), or by clicking an agent in the list while that group is active. In a group you can switch to its shells or open a new one, resume a closed session, or move it to the main panel. Dividers resize; the layout and what each group shows are kept per browser. Narrow screens show the main panel only.
6
+ - Fixed: a built agent's test run or package that finished after the agent was deleted could crash on saving its state.
7
+
8
+ ## 1.36.0 (2026-11-10)
9
+
10
+ - **Open sessions are always at the top of the agents list.** Agents needing your input come first, then working ones, then open sessions waiting for a prompt, in every list order. In **By project**, projects with an open session come first and, inside each project, open sessions come before the rest. The *last N days* filter no longer hides an older agent whose session is open. The **Running first** order is gone, since every order now does this; a saved choice falls back to **Recently used**.
11
+ - Fixed a flaky end-to-end test: the Eval's one-minute timer could redo an Eval the test had set by hand.
12
+
3
13
  ## 1.35.0 (2026-11-09)
4
14
 
5
15
  - **Flaky CI is caught before it reaches the agent.** When GitHub Actions checks fail on an agent's pull request, the failed jobs are run once more on the same commit (`gh run rerun --failed`) before the agent is told. If they pass, the checks are marked **Flaky** on the pull request's row in the Land tab and nothing is sent; if they fail again, the agent is told, and that it failed twice. Checks from other CI systems, and a re-run GitHub refuses, go to the agent straight away as before. Once per commit; turn it off in the Land tab's settings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.35.0",
3
+ "version": "1.37.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
@@ -26,6 +26,7 @@ import { initSupport } from '/support.js';
26
26
  import { initCode } from '/code.js';
27
27
  import { initMachine } from '/machine.js';
28
28
  import { initWatch } from '/watch.js';
29
+ import { initGroups } from '/groups.js';
29
30
  import { initStandup } from '/standup.js';
30
31
  import { initIssues } from '/issues.js';
31
32
  import { initActions } from '/actions.js';
@@ -82,8 +83,9 @@ const saveRecent = () => {
82
83
  localStorage.setItem('agentmgr.recentDays', String(recent.days));
83
84
  } catch {}
84
85
  };
85
- // How the agents list is ordered: recently used (the default), running first or newest first, one list each; or grouped by project.
86
- const ORDERS = ['recent', 'running', 'created', 'project'];
86
+ // How the agents list is ordered: recently used (the default) or newest first, one list each; or grouped by project.
87
+ // In each, open sessions come first: needing you, working, then waiting for a prompt.
88
+ const ORDERS = ['recent', 'created', 'project'];
87
89
  let listOrder = (() => {
88
90
  try {
89
91
  const v = localStorage.getItem('agentmgr.listOrder');
@@ -201,6 +203,8 @@ const watchUi = initWatch({
201
203
  projectLabel: (a) => a.projectInfo?.name ?? 'Other',
202
204
  openAgent: (id) => (showTab('agents'), select(id), term.open(id)),
203
205
  });
206
+ // Split screen: more groups beside the main panel, each with an agent's session (set up once the terminal is).
207
+ let groupsUi = null;
204
208
  $('#watch-btn').onclick = () => (mapUi.isOpen() && mapUi.show(false), watchUi.show(!watchUi.isOpen()));
205
209
 
206
210
  // Map: where each agent is in the code, and who is about to collide.
@@ -988,8 +992,8 @@ const copyBtn = (value) => `<button class="link" data-copy="${esc(value)}" title
988
992
 
989
993
  // ------------------------------------------------------------------ list
990
994
 
991
- /** Agents waiting on you first, then running ones, then the rest. */
992
- const rank = (a) => (a.runtime.attention ? 0 : a.runtime.running ? 1 : 2);
995
+ /** Agents needing you first, then working ones, then open sessions waiting for a prompt, then the rest. */
996
+ const rank = (a) => (a.runtime.attention ? 0 : a.runtime.running && a.runtime.busy ? 1 : a.runtime.running ? 2 : 3);
993
997
 
994
998
  // Agents with no work and no input from you for a day sink below the active ones.
995
999
  const ACTIVE_MS = 24 * 3600 * 1000;
@@ -1063,12 +1067,12 @@ function projectGroups(list) {
1063
1067
  }
1064
1068
  const out = [...groups.values()];
1065
1069
  for (const g of out) {
1066
- // Active in the last day first; then highest priority, agents needing you, running ones, most recent.
1070
+ // Open sessions first (needing you, working, waiting); then active in the last day, highest priority, most recent.
1067
1071
  g.agents.sort(
1068
1072
  (a, b) =>
1073
+ rank(a) - rank(b) ||
1069
1074
  isActive(b) - isActive(a) ||
1070
1075
  (a.priority ?? 2) - (b.priority ?? 2) ||
1071
- rank(a) - rank(b) ||
1072
1076
  (b.activeAt ?? b.createdAt).localeCompare(a.activeAt ?? a.createdAt),
1073
1077
  );
1074
1078
  g.active = g.agents.filter(isActive).length;
@@ -1087,6 +1091,7 @@ function projectGroups(list) {
1087
1091
  return out.sort(
1088
1092
  (a, b) =>
1089
1093
  special(a) - special(b) ||
1094
+ (b.waiting + b.running > 0) - (a.waiting + a.running > 0) ||
1090
1095
  (b.active > 0) - (a.active > 0) ||
1091
1096
  a.top - b.top ||
1092
1097
  b.waiting - a.waiting ||
@@ -1095,12 +1100,11 @@ function projectGroups(list) {
1095
1100
  );
1096
1101
  }
1097
1102
 
1098
- /** One list, most recently used first (Running first: the running agents, then the rest; Newest first: by creation). */
1103
+ /** One list: open sessions first (needing you, working, waiting), then most recently used (Newest first: by creation). */
1099
1104
  const usedAt = (a) => a.activeAt ?? a.createdAt ?? '';
1100
1105
  function orderedAgents(list) {
1101
- const top = (a) => (listOrder === 'running' && !a.runtime.running ? 1 : 0);
1102
1106
  const at = listOrder === 'created' ? (a) => a.createdAt ?? '' : usedAt;
1103
- return [...list].sort((a, b) => top(a) - top(b) || at(b).localeCompare(at(a)));
1107
+ return [...list].sort((a, b) => rank(a) - rank(b) || at(b).localeCompare(at(a)));
1104
1108
  }
1105
1109
 
1106
1110
  /** The project picker: every project with agents, by name; a project that's gone falls back to all. */
@@ -1135,9 +1139,9 @@ function renderList() {
1135
1139
  .toLowerCase()
1136
1140
  .includes(filterText),
1137
1141
  );
1138
- // The open agent stays in the list even when it's older.
1142
+ // The open agent, and agents with an open session, stay in the list even when they're older.
1139
1143
  const since = recent.on ? Date.now() - recent.days * 86_400_000 : 0;
1140
- const shown = since ? list.filter((a) => a.id === selectedId || (Date.parse(a.createdAt) || 0) >= since) : list;
1144
+ const shown = since ? list.filter((a) => a.id === selectedId || rank(a) < 3 || (Date.parse(a.createdAt) || 0) >= since) : list;
1141
1145
  const hidden = list.length - shown.length;
1142
1146
  $('#recent-bar').hidden = agents.size === 0;
1143
1147
  $('#recent-on').checked = recent.on;
@@ -2352,6 +2356,7 @@ const VIEWS = {
2352
2356
  detail: () => renderDetail(),
2353
2357
  overlay: () => term.syncOverlay(),
2354
2358
  watch: () => watchUi?.render(),
2359
+ groups: () => groupsUi?.render(),
2355
2360
  standup: () => standupUi?.render(),
2356
2361
  };
2357
2362
  const ALL_VIEWS = Object.keys(VIEWS);
@@ -3608,7 +3613,11 @@ $('#agent-list').addEventListener('click', (e) => {
3608
3613
  return renderList();
3609
3614
  }
3610
3615
  const li = e.target.closest('li[data-id]');
3611
- if (li) select(li.dataset.id);
3616
+ if (!li) return;
3617
+ // With the screen split, the active group opens it (as in VS Code); the main one shows its details.
3618
+ const group = groupsUi?.activeSplit();
3619
+ if (group && agents.get(li.dataset.id)?.workdir) return groupsUi.load(group, li.dataset.id);
3620
+ select(li.dataset.id);
3612
3621
  });
3613
3622
 
3614
3623
  const dropTarget = (e) => {
@@ -3621,7 +3630,7 @@ $('#agent-list').addEventListener('dragstart', (e) => {
3621
3630
  const li = e.target.closest?.('li[data-id][draggable="true"]');
3622
3631
  if (!li) return;
3623
3632
  dragging = li.dataset.id;
3624
- e.dataTransfer.effectAllowed = 'move';
3633
+ e.dataTransfer.effectAllowed = 'copyMove'; // move: to another project; copy: into a split-screen group
3625
3634
  e.dataTransfer.setData('text/plain', agents.get(dragging)?.name ?? dragging);
3626
3635
  li.classList.add('dragging');
3627
3636
  document.body.classList.add('dragging-agent');
@@ -4304,6 +4313,7 @@ function handleEvent(msg) {
4304
4313
  return invalidate([
4305
4314
  'list', 'backlog', 'land', 'inbox', 'race', 'team',
4306
4315
  ...(watchUi.isOpen() ? ['watch'] : []),
4316
+ ...(groupsUi?.count() ? ['groups'] : []),
4307
4317
  ...(standupUi.isOpen() ? ['standup'] : []),
4308
4318
  ...(docView?.agentId === id ? ['doc'] : []),
4309
4319
  ...(id === selectedId || msg.agent.forkOf?.agentId === selectedId ? ['detail'] : []),
@@ -4311,6 +4321,7 @@ function handleEvent(msg) {
4311
4321
  ]);
4312
4322
  } else if (msg.t === 'removed') {
4313
4323
  agents.delete(msg.id);
4324
+ groupsUi?.removed(msg.id);
4314
4325
  if (selectedId === msg.id) select(null);
4315
4326
  } else if (msg.t === 'race') {
4316
4327
  races.set(msg.race.id, msg.race);
@@ -4944,5 +4955,28 @@ async function boot() {
4944
4955
  loadEngines();
4945
4956
  }
4946
4957
 
4958
+ groupsUi = initGroups({
4959
+ $,
4960
+ esc,
4961
+ agents,
4962
+ Terminal,
4963
+ FitAddon,
4964
+ openStream,
4965
+ api,
4966
+ upsert: (a) => upsert(a),
4967
+ toast: (m, ms) => toast(m, ms),
4968
+ statusOf: (a) => statusOf(a),
4969
+ pillText: (st) => pillText(st),
4970
+ engineLabel: (e) => ENGINE_LABEL[e] ?? 'Claude',
4971
+ dragged: () => dragging,
4972
+ openInMain: (id, kind = 'claude') => {
4973
+ showTab('agents');
4974
+ select(id);
4975
+ if (kind !== 'claude' || agents.get(id)?.runtime.running) term.open(id, kind);
4976
+ },
4977
+ refitMain: () => term.refit(),
4978
+ });
4979
+ $('#group-split').onclick = () => groupsUi.split('row');
4980
+
4947
4981
  boot();
4948
4982
  setInterval(renderDetail, 30_000); // keep "x ago" labels fresh
@@ -0,0 +1,489 @@
1
+ // Split screen, like editor groups in VS Code: the area beside the agents list splits right or
2
+ // down into groups, each showing one agent's session (its Claude session or a shell). The main
3
+ // group is the usual panel (the agent's details and terminal); the others are terminals.
4
+ // Load a session into a group by dragging an agent onto it (onto its right or bottom edge to split
5
+ // there), with the group's picker, or by clicking an agent in the list while that group is active.
6
+ // The layout and what each group shows are kept per browser.
7
+
8
+ const SAVED = 'agentmgr.groups';
9
+ const MAX_GROUPS = 6;
10
+ // What a terminal answers to the program's queries (cursor position, colors, focus): never typing.
11
+ const REPLY = /^(\x1b\[[\d;?>]*[IOcRnt]|\x1b\][\d;]*[^\x07\x1b]*(\x07|\x1b\\))+$/;
12
+ const EDGE = 0.25; // a drop this close to a group's right or bottom edge splits it
13
+ const isShell = (k) => /^shell(:\d+)?$/.test(k ?? '');
14
+
15
+ export function initGroups({ $, esc, agents, Terminal, FitAddon, openStream, api, upsert, toast, statusOf, pillText, engineLabel, dragged, openInMain, refitMain }) {
16
+ const root = $('#groups');
17
+ const detail = $('#detail');
18
+ // A layout is a tree: { leaf: id } or { dir: 'row' | 'col', a, b, size } (the first part's share, %).
19
+ let tree = { leaf: 'main' };
20
+ let active = 'main';
21
+ const panes = new Map(); // group id -> { el, xterm, fit, conn, agentId, kind, replaying, exited }
22
+ let seq = 1;
23
+
24
+ const save = () => {
25
+ try {
26
+ const shows = Object.fromEntries([...panes].map(([id, p]) => [id, { agentId: p.agentId, kind: p.kind }]));
27
+ localStorage.setItem(SAVED, JSON.stringify({ tree, active, shows }));
28
+ } catch {}
29
+ };
30
+ const leaves = (n = tree) => (n.leaf ? [n.leaf] : [...leaves(n.a), ...leaves(n.b)]);
31
+ const narrow = () => matchMedia('(max-width: 760px)').matches;
32
+
33
+ // ------------------------------------------------------------------ panes
34
+
35
+ function makePane(id, show = {}) {
36
+ const el = document.createElement('section');
37
+ el.className = 'gpane';
38
+ el.dataset.group = id;
39
+ el.innerHTML = `
40
+ <div class="gbar">
41
+ <span class="pill gpill" hidden></span>
42
+ <button class="link gname" data-g="main" title="Open in the main panel, with its details"></button>
43
+ <select class="gkind" aria-label="Session" hidden></select>
44
+ <span class="spacer"></span>
45
+ <select class="gpick" aria-label="Open a session in this group" title="Open a session in this group"></select>
46
+ <button class="ghost small" data-g="right" title="Split right (Ctrl+\\)">◫</button>
47
+ <button class="ghost small" data-g="down" title="Split down">⬓</button>
48
+ <button class="ghost small" data-g="close" title="Close this group (the agent keeps running)">✕</button>
49
+ </div>
50
+ <div class="gbody">
51
+ <div class="gterm"></div>
52
+ <div class="gempty"><p>Drag an agent here from the list, pick one above, or click one in the list while this group is active.</p><p class="hint">Drop on a group's right or bottom edge to split it there.</p></div>
53
+ <div class="goverlay" hidden><span class="gover-msg"></span> <button class="small primary" data-g="resume"></button></div>
54
+ </div>`;
55
+ const xterm = new Terminal({
56
+ cursorBlink: true,
57
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
58
+ fontSize: 13,
59
+ scrollback: 10000,
60
+ theme: { background: '#0f1117' },
61
+ allowProposedApi: true,
62
+ });
63
+ const fit = new FitAddon();
64
+ xterm.loadAddon(fit);
65
+ const p = { el, xterm, fit, conn: null, agentId: null, kind: 'claude', replaying: false, exited: false, opened: false };
66
+ xterm.onData((d) => {
67
+ if (p.replaying || REPLY.test(d)) return;
68
+ p.conn?.send({ t: 'i', d });
69
+ });
70
+ xterm.onResize(({ cols, rows }) => p.conn?.send({ t: 'r', cols, rows }));
71
+ new ResizeObserver(() => refit(p)).observe(el.querySelector('.gterm'));
72
+ panes.set(id, p);
73
+ if (show.agentId) load(id, show.agentId, show.kind);
74
+ return p;
75
+ }
76
+
77
+ function refit(p) {
78
+ if (!p.opened || !p.agentId || !p.el.isConnected) return;
79
+ try {
80
+ p.fit.fit();
81
+ } catch {}
82
+ }
83
+
84
+ /** Show an agent's session (or one of its shells) in a group. */
85
+ function load(id, agentId, kind = 'claude') {
86
+ if (id === 'main') return openInMain(agentId, kind);
87
+ const p = panes.get(id);
88
+ if (!p) return;
89
+ if (p.agentId === agentId && p.kind === kind && p.conn) return p.xterm.focus();
90
+ disconnect(p);
91
+ p.agentId = agentId;
92
+ p.kind = kind;
93
+ p.exited = false;
94
+ p.failed = false;
95
+ if (agents.get(agentId)) connect(p);
96
+ renderPane(id);
97
+ save();
98
+ }
99
+
100
+ function connect(p) {
101
+ if (!p.el.isConnected) return;
102
+ if (!p.opened) {
103
+ p.xterm.open(p.el.querySelector('.gterm'));
104
+ p.opened = true;
105
+ }
106
+ p.failed = false;
107
+ p.xterm.reset();
108
+ const conn = openStream(
109
+ { agentId: p.agentId, kind: p.kind },
110
+ {
111
+ onOpen: () => {
112
+ refit(p);
113
+ p.conn?.send({ t: 'r', cols: p.xterm.cols, rows: p.xterm.rows });
114
+ },
115
+ onMessage: (msg) => {
116
+ if (p.conn !== conn) return;
117
+ if (msg.t === 'o') return p.xterm.write(msg.d);
118
+ if (msg.t === 'hello') {
119
+ p.xterm.reset();
120
+ p.replaying = true;
121
+ p.xterm.write(msg.backlog ?? '', () => (p.replaying = false));
122
+ } else if (msg.t === 'error') toast(`Terminal unavailable: ${msg.error}`, 5000);
123
+ else if (msg.t === 'exit') {
124
+ if (isShell(p.kind)) p.exited = true;
125
+ else p.xterm.write(`\r\n\x1b[2m[session exited with code ${msg.code}; session kept]\x1b[0m\r\n`);
126
+ renderPane(groupOf(p));
127
+ }
128
+ },
129
+ onClose: (ev) => {
130
+ if (p.conn !== conn) return;
131
+ p.conn = null;
132
+ p.failed = true;
133
+ if (ev.code === 1008) toast(`Terminal unavailable: ${ev.reason}`, 5000);
134
+ },
135
+ },
136
+ );
137
+ p.conn = conn;
138
+ }
139
+
140
+ function disconnect(p) {
141
+ const c = p.conn;
142
+ p.conn = null;
143
+ c?.close();
144
+ }
145
+
146
+ const groupOf = (p) => [...panes].find(([, x]) => x === p)?.[0];
147
+
148
+ /** Open sessions first (needing you, working, waiting), then the rest, most recent first. */
149
+ function pickList() {
150
+ const rank = (a) => (a.runtime?.attention ? 0 : a.runtime?.running && a.runtime?.busy ? 1 : a.runtime?.running ? 2 : 3);
151
+ return [...agents.values()]
152
+ .filter((a) => a.kind !== 'assistant' && a.workdir)
153
+ .sort((x, y) => rank(x) - rank(y) || String(y.activeAt ?? y.createdAt ?? '').localeCompare(String(x.activeAt ?? x.createdAt ?? '')));
154
+ }
155
+
156
+ function renderPane(id) {
157
+ const p = panes.get(id);
158
+ if (!p) return;
159
+ const el = p.el;
160
+ const a = p.agentId && agents.get(p.agentId);
161
+ el.classList.toggle('active', id === active);
162
+ el.classList.toggle('empty', !a);
163
+ const st = a ? statusOf(a) : null;
164
+ el.classList.toggle('attention', st === 'attention');
165
+ const pill = el.querySelector('.gpill');
166
+ pill.hidden = !a;
167
+ if (a) {
168
+ pill.className = `pill gpill ${st}`;
169
+ pill.textContent = pillText(st);
170
+ }
171
+ const name = el.querySelector('.gname');
172
+ const label = a ? `${a.name}${isShell(p.kind) ? ` · shell ${p.kind.split(':')[1] ?? 1}` : ''}` : 'Empty group';
173
+ if (name.textContent !== label) name.textContent = label;
174
+ name.disabled = !a;
175
+ el.querySelector('.gempty').hidden = Boolean(a);
176
+ el.querySelector('.gterm').hidden = !a;
177
+
178
+ // The session: the agent's own (named after its engine) or one of its shells.
179
+ const kindSel = el.querySelector('.gkind');
180
+ kindSel.hidden = !a;
181
+ if (a && document.activeElement !== kindSel) {
182
+ const shells = new Set(a.runtime?.shells ?? []);
183
+ if (isShell(p.kind)) shells.add(Number(p.kind.split(':')[1] ?? 1));
184
+ const opts = [['claude', engineLabel(a.engine)], ...[...shells].sort((x, y) => x - y).map((n) => [`shell:${n}`, `Shell ${n}`]), ['shell:new', '+ New shell']];
185
+ const html = opts.map(([k, l]) => `<option value="${k}" ${k === p.kind ? 'selected' : ''}>${esc(l)}</option>`).join('');
186
+ if (kindSel.dataset.html !== html) {
187
+ kindSel.innerHTML = html;
188
+ kindSel.dataset.html = html;
189
+ }
190
+ kindSel.value = p.kind;
191
+ }
192
+
193
+ const pick = el.querySelector('.gpick');
194
+ if (document.activeElement !== pick) {
195
+ const html = `<option value="">${a ? 'Open another…' : 'Open a session…'}</option>${pickList()
196
+ .map((x) => `<option value="${x.id}">${esc(x.runtime?.running ? '● ' : '')}${esc(x.name)}${x.runtime?.attention ? ' (needs input)' : ''}</option>`)
197
+ .join('')}`;
198
+ if (pick.dataset.html !== html) {
199
+ pick.innerHTML = html;
200
+ pick.dataset.html = html;
201
+ }
202
+ pick.value = '';
203
+ }
204
+
205
+ // A closed session or an exited shell: start it again from here.
206
+ const shell = isShell(p.kind);
207
+ const closed = a && (shell ? p.exited : !a.runtime?.running && a.status !== 'preparing');
208
+ el.querySelector('.goverlay').hidden = !closed;
209
+ if (closed) {
210
+ el.querySelector('.gover-msg').textContent = shell ? 'The shell has exited.' : "This agent's session is closed.";
211
+ el.querySelector('[data-g="resume"]').textContent = shell ? 'Start a new shell' : 'Resume session';
212
+ }
213
+ // The agent's state arrived after the group was restored: connect now.
214
+ if (a && !p.conn && !p.failed && !closed) connect(p);
215
+ }
216
+
217
+ // ------------------------------------------------------------------ layout
218
+
219
+ function nodeEl(n) {
220
+ if (n.leaf) {
221
+ if (n.leaf === 'main') {
222
+ detail.classList.toggle('gactive', active === 'main');
223
+ return detail;
224
+ }
225
+ const p = panes.get(n.leaf) ?? makePane(n.leaf);
226
+ return p.el;
227
+ }
228
+ const box = document.createElement('div');
229
+ box.className = `gsplit g${n.dir}`;
230
+ const a = nodeEl(n.a);
231
+ const b = nodeEl(n.b);
232
+ a.style.flex = `0 0 calc(${n.size}% - 3px)`;
233
+ b.style.flex = '1 1 0';
234
+ const bar = document.createElement('div');
235
+ bar.className = `gsplitter g${n.dir}`;
236
+ bar.setAttribute('role', 'separator');
237
+ bar.title = 'Drag to resize; double-click to even out';
238
+ bar.addEventListener('pointerdown', (e) => resizeFrom(e, bar, box, n, a));
239
+ bar.addEventListener('dblclick', () => {
240
+ n.size = 50;
241
+ a.style.flex = `0 0 calc(50% - 3px)`;
242
+ save();
243
+ refitAll();
244
+ });
245
+ box.append(a, bar, b);
246
+ return box;
247
+ }
248
+
249
+ function resizeFrom(e, bar, box, n, first) {
250
+ e.preventDefault();
251
+ bar.setPointerCapture(e.pointerId);
252
+ document.body.classList.add('resizing', n.dir === 'row' ? 'cols' : 'rows');
253
+ const move = (ev) => {
254
+ const r = box.getBoundingClientRect();
255
+ const at = n.dir === 'row' ? (ev.clientX - r.left) / r.width : (ev.clientY - r.top) / r.height;
256
+ n.size = Math.round(Math.min(85, Math.max(15, at * 100)));
257
+ first.style.flex = `0 0 calc(${n.size}% - 3px)`;
258
+ };
259
+ const up = () => {
260
+ document.body.classList.remove('resizing', 'cols', 'rows');
261
+ bar.removeEventListener('pointermove', move);
262
+ bar.removeEventListener('pointerup', up);
263
+ save();
264
+ refitAll();
265
+ };
266
+ bar.addEventListener('pointermove', move);
267
+ bar.addEventListener('pointerup', up);
268
+ }
269
+
270
+ function refitAll() {
271
+ requestAnimationFrame(() => {
272
+ refitMain();
273
+ for (const p of panes.values()) refit(p);
274
+ });
275
+ }
276
+
277
+ /** Rebuild the layout (only when its shape changes; groups and their terminals are moved, not redrawn). */
278
+ function layout() {
279
+ const one = narrow() || !tree.dir;
280
+ const top = one ? detail : nodeEl(tree);
281
+ if (one) detail.classList.remove('gactive');
282
+ root.classList.toggle('split', !one);
283
+ if (root.firstElementChild !== top || root.children.length !== 1) root.replaceChildren(top);
284
+ if (one) detail.style.removeProperty('flex');
285
+ for (const id of panes.keys()) renderPane(id);
286
+ refitAll();
287
+ }
288
+
289
+ function replace(n, id, next) {
290
+ if (n.leaf) return n.leaf === id ? next : n;
291
+ return { ...n, a: replace(n.a, id, next), b: replace(n.b, id, next) };
292
+ }
293
+
294
+ /** Split a group: a new group to its right ('row') or below it ('col'), active, showing `show` if given. */
295
+ function split(id = active, dir = 'row', show) {
296
+ if (leaves().length >= MAX_GROUPS) return toast(`At most ${MAX_GROUPS} groups`, 3000);
297
+ if (narrow()) return toast('Widen the window to split the screen', 3000);
298
+ const gid = `g${seq++}`;
299
+ while (panes.has(`g${seq}`)) seq++;
300
+ tree = replace(tree, id, { dir, a: { leaf: id }, b: { leaf: gid }, size: 50 });
301
+ makePane(gid);
302
+ active = gid;
303
+ layout();
304
+ if (show) load(gid, show.agentId, show.kind);
305
+ else panes.get(gid).el.querySelector('.gpick').focus();
306
+ save();
307
+ return gid;
308
+ }
309
+
310
+ function close(id) {
311
+ if (id === 'main') return;
312
+ const p = panes.get(id);
313
+ if (!p) return;
314
+ const drop = (n) => {
315
+ if (n.leaf) return n;
316
+ if (n.a.leaf === id) return n.b;
317
+ if (n.b.leaf === id) return n.a;
318
+ return { ...n, a: drop(n.a), b: drop(n.b) };
319
+ };
320
+ tree = drop(tree);
321
+ disconnect(p);
322
+ p.xterm.dispose();
323
+ p.el.remove();
324
+ panes.delete(id);
325
+ if (active === id) active = 'main';
326
+ layout();
327
+ save();
328
+ }
329
+
330
+ function activate(id) {
331
+ if (active === id) return;
332
+ active = id;
333
+ detail.classList.toggle('gactive', id === 'main' && Boolean(tree.dir) && !narrow());
334
+ for (const gid of panes.keys()) panes.get(gid).el.classList.toggle('active', gid === id);
335
+ save();
336
+ }
337
+
338
+ // ------------------------------------------------------------------ events
339
+
340
+ root.addEventListener('pointerdown', (e) => {
341
+ const g = e.target.closest('.gpane');
342
+ activate(g ? g.dataset.group : e.target.closest('#detail') ? 'main' : active);
343
+ }, true);
344
+ root.addEventListener('focusin', (e) => {
345
+ const g = e.target.closest('.gpane');
346
+ if (g) activate(g.dataset.group);
347
+ else if (e.target.closest('#detail')) activate('main');
348
+ });
349
+
350
+ root.addEventListener('click', async (e) => {
351
+ const b = e.target.closest('[data-g]');
352
+ const g = b?.closest('.gpane');
353
+ if (!g) return;
354
+ const id = g.dataset.group;
355
+ const p = panes.get(id);
356
+ switch (b.dataset.g) {
357
+ case 'right':
358
+ return split(id, 'row');
359
+ case 'down':
360
+ return split(id, 'col');
361
+ case 'close':
362
+ return close(id);
363
+ case 'main': {
364
+ if (!p.agentId) return;
365
+ const { agentId, kind } = p;
366
+ close(id);
367
+ return openInMain(agentId, kind);
368
+ }
369
+ case 'resume':
370
+ if (isShell(p.kind)) {
371
+ p.exited = false;
372
+ disconnect(p);
373
+ connect(p);
374
+ return renderPane(id);
375
+ }
376
+ try {
377
+ upsert(await api('POST', `/agents/${p.agentId}/start`, {}));
378
+ if (!p.conn) connect(p);
379
+ p.xterm.focus();
380
+ } catch (err) {
381
+ toast(`Error: ${err.message}`, 5000);
382
+ }
383
+ }
384
+ });
385
+
386
+ root.addEventListener('change', async (e) => {
387
+ const g = e.target.closest('.gpane');
388
+ if (!g) return;
389
+ const id = g.dataset.group;
390
+ const p = panes.get(id);
391
+ if (e.target.classList.contains('gpick') && e.target.value) {
392
+ const agentId = e.target.value;
393
+ e.target.blur();
394
+ return load(id, agentId, 'claude');
395
+ }
396
+ if (e.target.classList.contains('gkind')) {
397
+ let kind = e.target.value;
398
+ e.target.blur();
399
+ if (kind === 'shell:new') {
400
+ try {
401
+ kind = `shell:${(await api('POST', `/agents/${p.agentId}/shell/new`)).n}`;
402
+ } catch (err) {
403
+ renderPane(id);
404
+ return toast(`Error: ${err.message}`, 5000);
405
+ }
406
+ }
407
+ load(id, p.agentId, kind);
408
+ }
409
+ });
410
+
411
+ // Dragging an agent from the list: onto a group to show it there, onto its right or bottom edge to split.
412
+ const zoneOf = (e) => {
413
+ const target = e.target.closest?.('.gpane, #detail');
414
+ if (!target || !root.contains(target)) return null;
415
+ const r = target.getBoundingClientRect();
416
+ const x = (e.clientX - r.left) / r.width;
417
+ const y = (e.clientY - r.top) / r.height;
418
+ const id = target.classList.contains('gpane') ? target.dataset.group : 'main';
419
+ const zone = narrow() ? 'here' : x > 1 - EDGE && x - (1 - EDGE) >= y - (1 - EDGE) ? 'right' : y > 1 - EDGE ? 'down' : 'here';
420
+ return { id, zone, target };
421
+ };
422
+ const clearDrop = () => root.querySelectorAll('[data-gdrop]').forEach((el) => el.removeAttribute('data-gdrop'));
423
+ root.addEventListener('dragover', (e) => {
424
+ const agentId = dragged();
425
+ const z = agentId && zoneOf(e);
426
+ if (!z) return;
427
+ e.preventDefault();
428
+ e.dataTransfer.dropEffect = 'copy';
429
+ if (z.target.dataset.gdrop !== z.zone) {
430
+ clearDrop();
431
+ z.target.dataset.gdrop = z.zone;
432
+ }
433
+ });
434
+ root.addEventListener('dragleave', (e) => {
435
+ if (!root.contains(e.relatedTarget)) clearDrop();
436
+ });
437
+ root.addEventListener('drop', (e) => {
438
+ const agentId = dragged();
439
+ const z = agentId && zoneOf(e);
440
+ clearDrop();
441
+ if (!z) return;
442
+ e.preventDefault();
443
+ if (z.zone === 'here') {
444
+ activate(z.id);
445
+ return load(z.id, agentId, 'claude');
446
+ }
447
+ split(z.id, z.zone === 'right' ? 'row' : 'col', { agentId, kind: 'claude' });
448
+ });
449
+ document.addEventListener('dragend', clearDrop);
450
+
451
+ // Ctrl+\ (Cmd+\ on a Mac), as in VS Code: split the active group to the right.
452
+ document.addEventListener('keydown', (e) => {
453
+ if ((e.ctrlKey || e.metaKey) && !e.altKey && e.code === 'Backslash') {
454
+ e.preventDefault();
455
+ split(active, e.shiftKey ? 'col' : 'row');
456
+ }
457
+ });
458
+ matchMedia('(max-width: 760px)').addEventListener('change', () => layout());
459
+
460
+ // Restore the last layout.
461
+ try {
462
+ const saved = JSON.parse(localStorage.getItem(SAVED) ?? 'null');
463
+ if (saved?.tree) {
464
+ const ids = leaves(saved.tree);
465
+ if (ids.includes('main') && ids.length <= MAX_GROUPS) {
466
+ tree = saved.tree;
467
+ for (const id of ids) if (id !== 'main') makePane(id, saved.shows?.[id]);
468
+ active = ids.includes(saved.active) ? saved.active : 'main';
469
+ seq = Math.max(1, ...ids.map((x) => Number(x.slice(1)) || 0)) + 1;
470
+ }
471
+ }
472
+ } catch {}
473
+ layout();
474
+
475
+ return {
476
+ /** Agents changed: names, states and pickers in each group. */
477
+ render() {
478
+ for (const id of panes.keys()) renderPane(id);
479
+ },
480
+ /** The group a click in the list opens into, when it isn't the main one. */
481
+ count: () => panes.size,
482
+ activeSplit: () => (active !== 'main' && panes.has(active) && tree.dir && !narrow() ? active : null),
483
+ load,
484
+ split: (dir) => split(active, dir),
485
+ removed(agentId) {
486
+ for (const [id, p] of panes) if (p.agentId === agentId) close(id);
487
+ },
488
+ };
489
+ }
package/public/index.html CHANGED
@@ -99,9 +99,8 @@
99
99
  <input type="number" id="recent-days" min="1" max="3650" value="7" aria-label="Days"> days
100
100
  <span class="spacer"></span><span id="recent-hidden"></span>
101
101
  <select id="list-project" aria-label="Project" title="Show only one project's agents" hidden></select>
102
- <select id="list-order" aria-label="Order" title="Recently used: one list, the agents created or worked in most recently on top. Running first: running agents on top, most recently used first, then the rest. Newest first: by creation date, the newest on top. By project: grouped, busiest and most urgent first.">
102
+ <select id="list-order" aria-label="Order" title="Open sessions are always on top: needing you, then working, then waiting for a prompt. Below them, Recently used: the agents created or worked in most recently first. Newest first: by creation date, the newest first. By project: grouped, projects with open sessions first.">
103
103
  <option value="recent">Recently used</option>
104
- <option value="running">Running first</option>
105
104
  <option value="created">Newest first</option>
106
105
  <option value="project">By project</option>
107
106
  </select>
@@ -119,6 +118,7 @@
119
118
  </aside>
120
119
  <div class="splitter split-side" id="split-side" role="separator" aria-orientation="vertical" title="Drag to resize the list; double-click to reset"></div>
121
120
 
121
+ <div class="groups" id="groups">
122
122
  <section class="detail" id="detail">
123
123
  <div class="placeholder" id="placeholder">Select an agent to see its session, folder, repo, PRs and bugs.</div>
124
124
  <div id="detail-body" hidden></div>
@@ -139,6 +139,7 @@
139
139
  <input type="file" id="term-file" multiple hidden>
140
140
  <button id="term-fit" class="ghost small" title="Refit the terminal to the panel">Fit</button>
141
141
  <button id="term-split-btn" class="ghost small desk-only" title="Split: the terminal on the left, and Code, Docs (diagrams) or Changes on the right">◫ Split</button>
142
+ <button id="group-split" class="ghost small desk-only" title="Split the screen: a group to the right for another agent's session, as in VS Code (Ctrl+\; Ctrl+Shift+\ splits down). Or drag an agent from the list onto the right or bottom edge">⊞ Split screen</button>
142
143
  <button id="term-max" class="ghost small desk-only" title="Expand to fill the window (Ctrl+Shift+E)">⤢ Expand</button>
143
144
  <button id="term-full" class="ghost small desk-only" title="Full screen (Esc to leave)">⛶ Full screen</button>
144
145
  <button id="term-close" class="ghost small" title="Hide the terminal (the agent keeps running)">Hide terminal</button>
@@ -220,6 +221,7 @@
220
221
  </div>
221
222
  </div>
222
223
  </section>
224
+ </div>
223
225
  </main>
224
226
 
225
227
  <dialog id="new-dialog">
package/public/style.css CHANGED
@@ -124,6 +124,41 @@ body.resizing iframe, body.resizing .terminal { pointer-events: none; }
124
124
  body.resizing.cols { cursor: col-resize; }
125
125
  body.resizing.rows { cursor: row-resize; }
126
126
 
127
+ /* Split screen (VS Code's editor groups): the main panel plus groups with other sessions. */
128
+ .groups { display: flex; min-width: 0; min-height: 0; }
129
+ .groups > .detail { flex: 1 1 0; }
130
+ .gsplit { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; }
131
+ .gsplit.grow { flex-direction: row; }
132
+ .gsplit.gcol { flex-direction: column; }
133
+ .gsplit > * { min-width: 0; min-height: 0; }
134
+ .gsplitter { flex: none; position: relative; z-index: 3; background: var(--border); }
135
+ .gsplitter.grow { width: 1px; margin: 0 2px; cursor: col-resize; }
136
+ .gsplitter.gcol { height: 1px; margin: 2px 0; cursor: row-resize; }
137
+ .gsplitter::after { content: ''; position: absolute; }
138
+ .gsplitter.grow::after { top: 0; bottom: 0; left: -4px; width: 9px; }
139
+ .gsplitter.gcol::after { left: 0; right: 0; top: -4px; height: 9px; }
140
+ .gsplitter:hover::after { background: var(--accent); opacity: .5; }
141
+ .groups.split .detail, .gpane { outline: 1px solid transparent; outline-offset: -1px; }
142
+ .groups.split .detail.gactive, .gpane.active { outline-color: var(--accent); }
143
+ .gpane { display: flex; flex-direction: column; background: var(--panel); }
144
+ .gpane.attention .gbar { box-shadow: inset 0 -2px 0 var(--red); }
145
+ .gbar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 13px; min-width: 0; overflow: hidden; }
146
+ .gbar > * { flex: none; }
147
+ .gbar .gname { flex: 0 1 auto; min-width: 48px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
148
+ .gbar .spacer { flex: 1 1 0; min-width: 0; }
149
+ .gbar select { width: auto; min-width: 0; max-width: 140px; padding: 1px 4px; font-size: 12px; flex: 0 1 auto; }
150
+ .groups.split .detail { overflow: hidden; }
151
+ .gbody { position: relative; flex: 1; min-height: 0; background: #0f1117; }
152
+ .gterm { position: absolute; inset: 4px 0 0 6px; }
153
+ .gempty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--muted); background: var(--panel); }
154
+ .goverlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center; background: rgba(15, 17, 23, .92); color: #c9d1d9; }
155
+ body.resizing .gterm { pointer-events: none; }
156
+ [data-gdrop] { position: relative; }
157
+ [data-gdrop]::before { content: ''; position: absolute; z-index: 6; pointer-events: none; background: var(--accent); opacity: .18; border: 2px solid var(--accent); }
158
+ [data-gdrop="here"]::before { inset: 0; }
159
+ [data-gdrop="right"]::before { top: 0; bottom: 0; right: 0; width: 50%; }
160
+ [data-gdrop="down"]::before { left: 0; right: 0; bottom: 0; height: 50%; }
161
+
127
162
  /* Expanded: the terminal, shell or browser fills the window. */
128
163
  body.term-max .topbar, body.term-max .sidebar, body.term-max .split-side,
129
164
  body.term-max #detail-body, body.term-max .split-term, body.term-max #placeholder { display: none !important; }
package/src/builder.js CHANGED
@@ -170,6 +170,8 @@ export class Builder {
170
170
  }
171
171
 
172
172
  saveMeta(name, patch) {
173
+ // The agent was deleted while something of it still ran (its tests, a package): nothing to keep.
174
+ if (!fs.existsSync(this.dir(name))) return null;
173
175
  const next = { ...this.meta(name), ...patch, updatedAt: now() };
174
176
  fs.writeFileSync(path.join(this.dir(name), 'build.json'), JSON.stringify(next, null, 2));
175
177
  return next;
package/src/server.js CHANGED
@@ -90,7 +90,7 @@ const HOOK_PATH = '/api/hooks/agents';
90
90
  const REPORT_PATH = '/api/agentkit/report';
91
91
  const NO_REPO_KINDS = new Set(['general', 'assistant']);
92
92
 
93
- export async function startServer({ port = PORT, host = HOST } = {}) {
93
+ export async function startServer({ port = PORT, host = HOST, evalTimer = true } = {}) {
94
94
  ensureHome();
95
95
  const config = loadConfig();
96
96
  const store = new Store(paths.state);
@@ -176,7 +176,7 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
176
176
  transcript: (a) => (engineOf(a).id === 'claude' && a.workdir ? readTail(engineOf(a).sessionFile(a.workdir, a.sessionId)) : null),
177
177
  log: (m) => console.log(`[agentmgr] ${m}`),
178
178
  });
179
- evals.startTimer();
179
+ if (evalTimer) evals.startTimer();
180
180
  const races = new Races({ manager, store });
181
181
  const review = new Review({ manager });
182
182
  // The walkthrough explains the same diff the review screen shows.