ai-agentmanager 1.36.0 → 1.38.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.38.0 (2026-11-11)
4
+
5
+ - **The top bar fits the window.** View buttons that don't fit go, in order, into a **More ▾** menu at the end of the row (with a dot when one of them has a count); the filter gives up its room first, and below 1100px the title and connection text step aside for the logo and a coloured dot. **+ New agents** and your menu always stay in view.
6
+ - **Split screen: one session in two views.** When a session shows in more than one place (the main panel, a group, another window), the view you type in or click sets its size; the others show it at that size with the font scaled to fit, instead of wrapping oddly.
7
+ - **Split screen keys**, also from inside a terminal: **Cmd+\\** on a Mac or **Ctrl+Shift+\\** splits right (add Shift on a Mac, or Alt, to split down), **Ctrl+Shift+1…6** goes to a group, **Ctrl+Shift+X** closes the active one. They're listed under **?**.
8
+ - Fixed: plain **Ctrl+\\** in a terminal split the screen *and* reached the agent as Ctrl+\\, a quit key. It now only goes to the terminal.
9
+ - Fixed: a terminal reconnecting in the main panel took the keyboard away from the split-screen group you were working in.
10
+ - Tests now drive the page in headless Chrome (`test/browser.test.js`, skipped without Chrome): the top bar at several widths, and the split screen end to end.
11
+
12
+ ## 1.37.0 (2026-11-10)
13
+
14
+ - **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.
15
+ - Fixed: a built agent's test run or package that finished after the agent was deleted could crash on saving its state.
16
+
3
17
  ## 1.36.0 (2026-11-10)
4
18
 
5
19
  - **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**.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.36.0",
3
+ "version": "1.38.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,8 @@ 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, followSize, scaleToFit, leadSize } from '/groups.js';
30
+ import { initTopNav } from '/topnav.js';
29
31
  import { initStandup } from '/standup.js';
30
32
  import { initIssues } from '/issues.js';
31
33
  import { initActions } from '/actions.js';
@@ -202,6 +204,8 @@ const watchUi = initWatch({
202
204
  projectLabel: (a) => a.projectInfo?.name ?? 'Other',
203
205
  openAgent: (id) => (showTab('agents'), select(id), term.open(id)),
204
206
  });
207
+ // Split screen: more groups beside the main panel, each with an agent's session (set up once the terminal is).
208
+ let groupsUi = null;
205
209
  $('#watch-btn').onclick = () => (mapUi.isOpen() && mapUi.show(false), watchUi.show(!watchUi.isOpen()));
206
210
 
207
211
  // Map: where each agent is in the code, and who is about to collide.
@@ -2353,6 +2357,7 @@ const VIEWS = {
2353
2357
  detail: () => renderDetail(),
2354
2358
  overlay: () => term.syncOverlay(),
2355
2359
  watch: () => watchUi?.render(),
2360
+ groups: () => groupsUi?.render(),
2356
2361
  standup: () => standupUi?.render(),
2357
2362
  };
2358
2363
  const ALL_VIEWS = Object.keys(VIEWS);
@@ -2445,10 +2450,12 @@ const term = {
2445
2450
  // answers are stale, and the program would get them as typing.
2446
2451
  if (this.replaying) return;
2447
2452
  lastTyped = Date.now();
2453
+ this.lead();
2448
2454
  this.send({ t: 'i', d });
2449
2455
  });
2450
- this.xterm.onResize(({ cols, rows }) => this.send({ t: 'r', cols, rows }));
2451
- new ResizeObserver(() => this.refit()).observe($('#terminal'));
2456
+ // Shown in a split-screen group too (or another window): the view typed in sets the size.
2457
+ this.xterm.onResize(({ cols, rows }) => !this.follow && this.send({ t: 'r', cols, rows }));
2458
+ new ResizeObserver(() => (this.follow ? scaleToFit(this, $('#terminal')) : this.refit())).observe($('#terminal'));
2452
2459
  touchScroll($('#terminal'), this.xterm);
2453
2460
  },
2454
2461
 
@@ -2456,8 +2463,13 @@ const term = {
2456
2463
  this.conn?.send(msg);
2457
2464
  },
2458
2465
 
2466
+ follow: false,
2467
+ lead() {
2468
+ leadSize(this, () => this.fit.fit(), (m) => this.send(m));
2469
+ },
2470
+
2459
2471
  refit() {
2460
- if (!this.agentId) return;
2472
+ if (!this.agentId || this.follow) return;
2461
2473
  try {
2462
2474
  this.fit.fit();
2463
2475
  } catch {}
@@ -2485,6 +2497,8 @@ const term = {
2485
2497
  this.agentId = id;
2486
2498
  this.kind = kind;
2487
2499
  this.shellExited = false;
2500
+ this.follow = false;
2501
+ this.xterm.options.fontSize = 13;
2488
2502
  this.xterm.reset();
2489
2503
  this.syncOverlay();
2490
2504
  requestAnimationFrame(() => this.refit());
@@ -2515,7 +2529,10 @@ const term = {
2515
2529
  this.xterm.reset();
2516
2530
  this.replaying = true;
2517
2531
  this.xterm.write(msg.backlog, () => (this.replaying = false));
2518
- if (!matchMedia('(pointer: coarse)').matches) this.xterm.focus();
2532
+ // Not while you work in a split-screen group: it would take the keyboard from there.
2533
+ if (!matchMedia('(pointer: coarse)').matches && !groupsUi?.activeSplit()) this.xterm.focus();
2534
+ } else if (msg.t === 'size') {
2535
+ return followSize(this, msg.cols, msg.rows, $('#terminal'));
2519
2536
  } else if (msg.t === 'error') {
2520
2537
  toast(`Terminal unavailable: ${msg.error}`, 5000);
2521
2538
  } else if (msg.t === 'o') {
@@ -3609,7 +3626,11 @@ $('#agent-list').addEventListener('click', (e) => {
3609
3626
  return renderList();
3610
3627
  }
3611
3628
  const li = e.target.closest('li[data-id]');
3612
- if (li) select(li.dataset.id);
3629
+ if (!li) return;
3630
+ // With the screen split, the active group opens it (as in VS Code); the main one shows its details.
3631
+ const group = groupsUi?.activeSplit();
3632
+ if (group && agents.get(li.dataset.id)?.workdir) return groupsUi.load(group, li.dataset.id);
3633
+ select(li.dataset.id);
3613
3634
  });
3614
3635
 
3615
3636
  const dropTarget = (e) => {
@@ -3622,7 +3643,7 @@ $('#agent-list').addEventListener('dragstart', (e) => {
3622
3643
  const li = e.target.closest?.('li[data-id][draggable="true"]');
3623
3644
  if (!li) return;
3624
3645
  dragging = li.dataset.id;
3625
- e.dataTransfer.effectAllowed = 'move';
3646
+ e.dataTransfer.effectAllowed = 'copyMove'; // move: to another project; copy: into a split-screen group
3626
3647
  e.dataTransfer.setData('text/plain', agents.get(dragging)?.name ?? dragging);
3627
3648
  li.classList.add('dragging');
3628
3649
  document.body.classList.add('dragging-agent');
@@ -4305,6 +4326,7 @@ function handleEvent(msg) {
4305
4326
  return invalidate([
4306
4327
  'list', 'backlog', 'land', 'inbox', 'race', 'team',
4307
4328
  ...(watchUi.isOpen() ? ['watch'] : []),
4329
+ ...(groupsUi?.count() ? ['groups'] : []),
4308
4330
  ...(standupUi.isOpen() ? ['standup'] : []),
4309
4331
  ...(docView?.agentId === id ? ['doc'] : []),
4310
4332
  ...(id === selectedId || msg.agent.forkOf?.agentId === selectedId ? ['detail'] : []),
@@ -4312,6 +4334,7 @@ function handleEvent(msg) {
4312
4334
  ]);
4313
4335
  } else if (msg.t === 'removed') {
4314
4336
  agents.delete(msg.id);
4337
+ groupsUi?.removed(msg.id);
4315
4338
  if (selectedId === msg.id) select(null);
4316
4339
  } else if (msg.t === 'race') {
4317
4340
  races.set(msg.race.id, msg.race);
@@ -4349,13 +4372,13 @@ function connectEvents() {
4349
4372
  { events: true },
4350
4373
  {
4351
4374
  onOpen: () => {
4352
- $('#conn').textContent = REMOTE ? 'connected (remote)' : 'daemon connected';
4375
+ $('#conn').textContent = $('#conn').title = REMOTE ? 'connected (remote)' : 'daemon connected';
4353
4376
  $('#conn').className = 'conn ok';
4354
4377
  reloadIfUpdated();
4355
4378
  },
4356
4379
  onMessage: handleEvent,
4357
4380
  onClose: async () => {
4358
- $('#conn').textContent = 'daemon offline, retrying…';
4381
+ $('#conn').textContent = $('#conn').title = 'daemon offline, retrying…';
4359
4382
  $('#conn').className = 'conn bad';
4360
4383
  if (REMOTE && !(await sessionOk())) return showLogin();
4361
4384
  setTimeout(connectEvents, 2000);
@@ -4945,5 +4968,31 @@ async function boot() {
4945
4968
  loadEngines();
4946
4969
  }
4947
4970
 
4971
+ groupsUi = initGroups({
4972
+ $,
4973
+ esc,
4974
+ agents,
4975
+ Terminal,
4976
+ FitAddon,
4977
+ openStream,
4978
+ api,
4979
+ upsert: (a) => upsert(a),
4980
+ toast: (m, ms) => toast(m, ms),
4981
+ statusOf: (a) => statusOf(a),
4982
+ pillText: (st) => pillText(st),
4983
+ engineLabel: (e) => ENGINE_LABEL[e] ?? 'Claude',
4984
+ dragged: () => dragging,
4985
+ openInMain: (id, kind = 'claude') => {
4986
+ showTab('agents');
4987
+ select(id);
4988
+ if (kind !== 'claude' || agents.get(id)?.runtime.running) term.open(id, kind);
4989
+ },
4990
+ refitMain: () => term.refit(),
4991
+ mainActive: () => term.xterm && term.lead(),
4992
+ focusMain: () => (term.agentId && !$('#term-wrap').hidden ? term.xterm.focus() : $('#detail').focus?.()),
4993
+ });
4994
+ $('#group-split').onclick = () => groupsUi.split('row');
4995
+ initTopNav({ $ });
4996
+
4948
4997
  boot();
4949
4998
  setInterval(renderDetail, 30_000); // keep "x ago" labels fresh
@@ -0,0 +1,555 @@
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
+ // Keys: Cmd+\ or Ctrl+Shift+\ splits, Ctrl+Shift+1…6 focuses a group, Ctrl+Shift+X closes one.
5
+ // Load a session into a group by dragging an agent onto it (onto its right or bottom edge to split
6
+ // there), with the group's picker, or by clicking an agent in the list while that group is active.
7
+ // The layout and what each group shows are kept per browser.
8
+
9
+ const SAVED = 'agentmgr.groups';
10
+ const MAX_GROUPS = 6;
11
+ // What a terminal answers to the program's queries (cursor position, colors, focus): never typing.
12
+ const REPLY = /^(\x1b\[[\d;?>]*[IOcRnt]|\x1b\][\d;]*[^\x07\x1b]*(\x07|\x1b\\))+$/;
13
+ const EDGE = 0.25; // a drop this close to a group's right or bottom edge splits it
14
+ const isShell = (k) => /^shell(:\d+)?$/.test(k ?? '');
15
+ const FONT = 13;
16
+
17
+ // One session, several views (the main panel, groups, another window): the view you type in or
18
+ // click sets the session's size; the others show it at that size, the font scaled to fit, until
19
+ // you type in or click one of them. `v` is { xterm, follow }.
20
+
21
+ /** Another view resized the session: show it at that size. */
22
+ export function followSize(v, cols, rows, box) {
23
+ if (!(cols > 0 && rows > 0) || (cols === v.xterm.cols && rows === v.xterm.rows)) return;
24
+ v.follow = true;
25
+ v.xterm.resize(cols, rows);
26
+ requestAnimationFrame(() => scaleToFit(v, box));
27
+ }
28
+
29
+ /** While following: the font that fits the session's size into the panel. */
30
+ export function scaleToFit(v, box) {
31
+ const screen = box.querySelector('.xterm-screen');
32
+ if (!v.follow || !screen?.offsetWidth || !box.clientWidth) return;
33
+ const f = v.xterm.options.fontSize;
34
+ const ratio = Math.min(box.clientWidth / screen.offsetWidth, box.clientHeight / screen.offsetHeight);
35
+ const next = Math.max(6, Math.min(FONT, Math.floor(f * ratio * 10) / 10));
36
+ if (Math.abs(next - f) > 0.05) v.xterm.options.fontSize = next;
37
+ }
38
+
39
+ /** This view sets the size again: its own font, fitted to its panel, sent to the session. */
40
+ export function leadSize(v, fit, send) {
41
+ if (!v.follow) return;
42
+ v.follow = false;
43
+ v.xterm.options.fontSize = FONT;
44
+ try {
45
+ fit();
46
+ } catch {}
47
+ send({ t: 'r', cols: v.xterm.cols, rows: v.xterm.rows });
48
+ }
49
+
50
+ export function initGroups({ $, esc, agents, Terminal, FitAddon, openStream, api, upsert, toast, statusOf, pillText, engineLabel, dragged, openInMain, refitMain, mainActive, focusMain }) {
51
+ const root = $('#groups');
52
+ const detail = $('#detail');
53
+ // A layout is a tree: { leaf: id } or { dir: 'row' | 'col', a, b, size } (the first part's share, %).
54
+ let tree = { leaf: 'main' };
55
+ let active = 'main';
56
+ const panes = new Map(); // group id -> { el, xterm, fit, conn, agentId, kind, replaying, exited }
57
+ let seq = 1;
58
+
59
+ const save = () => {
60
+ try {
61
+ const shows = Object.fromEntries([...panes].map(([id, p]) => [id, { agentId: p.agentId, kind: p.kind }]));
62
+ localStorage.setItem(SAVED, JSON.stringify({ tree, active, shows }));
63
+ } catch {}
64
+ };
65
+ const leaves = (n = tree) => (n.leaf ? [n.leaf] : [...leaves(n.a), ...leaves(n.b)]);
66
+ const narrow = () => matchMedia('(max-width: 760px)').matches;
67
+
68
+ // ------------------------------------------------------------------ panes
69
+
70
+ function makePane(id, show = {}) {
71
+ const el = document.createElement('section');
72
+ el.className = 'gpane';
73
+ el.dataset.group = id;
74
+ el.innerHTML = `
75
+ <div class="gbar">
76
+ <span class="pill gpill" hidden></span>
77
+ <button class="link gname" data-g="main" title="Open in the main panel, with its details"></button>
78
+ <select class="gkind" aria-label="Session" hidden></select>
79
+ <span class="spacer"></span>
80
+ <select class="gpick" aria-label="Open a session in this group" title="Open a session in this group"></select>
81
+ <button class="ghost small" data-g="right" title="Split right (Cmd+\\ on a Mac, or Ctrl+Shift+\\)">◫</button>
82
+ <button class="ghost small" data-g="down" title="Split down (Cmd+Shift+\\ on a Mac, or Ctrl+Alt+Shift+\\)">⬓</button>
83
+ <button class="ghost small" data-g="close" title="Close this group; the agent keeps running (Ctrl+Shift+X)">✕</button>
84
+ </div>
85
+ <div class="gbody">
86
+ <div class="gterm"></div>
87
+ <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>
88
+ <div class="goverlay" hidden><span class="gover-msg"></span> <button class="small primary" data-g="resume"></button></div>
89
+ </div>`;
90
+ const xterm = new Terminal({
91
+ cursorBlink: true,
92
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
93
+ fontSize: FONT,
94
+ scrollback: 10000,
95
+ theme: { background: '#0f1117' },
96
+ allowProposedApi: true,
97
+ });
98
+ const fit = new FitAddon();
99
+ xterm.loadAddon(fit);
100
+ const p = { el, xterm, fit, conn: null, agentId: null, kind: 'claude', replaying: false, exited: false, opened: false, follow: false };
101
+ xterm.onData((d) => {
102
+ if (p.replaying || REPLY.test(d)) return;
103
+ lead(p);
104
+ p.conn?.send({ t: 'i', d });
105
+ });
106
+ xterm.onResize(({ cols, rows }) => !p.follow && p.conn?.send({ t: 'r', cols, rows }));
107
+ new ResizeObserver(() => (p.follow ? scaleToFit(p, el.querySelector('.gterm')) : refit(p))).observe(el.querySelector('.gterm'));
108
+ panes.set(id, p);
109
+ if (show.agentId) load(id, show.agentId, show.kind);
110
+ return p;
111
+ }
112
+
113
+ const lead = (p) => leadSize(p, () => p.fit.fit(), (m) => p.conn?.send(m));
114
+
115
+ function refit(p) {
116
+ if (!p.opened || !p.agentId || !p.el.isConnected || p.follow) return;
117
+ try {
118
+ p.fit.fit();
119
+ } catch {}
120
+ }
121
+
122
+ /** Show an agent's session (or one of its shells) in a group. */
123
+ function load(id, agentId, kind = 'claude') {
124
+ if (id === 'main') return openInMain(agentId, kind);
125
+ const p = panes.get(id);
126
+ if (!p) return;
127
+ if (p.agentId === agentId && p.kind === kind && p.conn) return p.xterm.focus();
128
+ disconnect(p);
129
+ p.agentId = agentId;
130
+ p.kind = kind;
131
+ p.exited = false;
132
+ p.failed = false;
133
+ if (agents.get(agentId)) connect(p);
134
+ renderPane(id);
135
+ save();
136
+ }
137
+
138
+ function connect(p) {
139
+ if (!p.el.isConnected) return;
140
+ if (!p.opened) {
141
+ p.xterm.open(p.el.querySelector('.gterm'));
142
+ p.opened = true;
143
+ }
144
+ p.failed = false;
145
+ p.follow = false;
146
+ p.xterm.options.fontSize = FONT;
147
+ p.xterm.reset();
148
+ const conn = openStream(
149
+ { agentId: p.agentId, kind: p.kind },
150
+ {
151
+ onOpen: () => {
152
+ refit(p);
153
+ p.conn?.send({ t: 'r', cols: p.xterm.cols, rows: p.xterm.rows });
154
+ },
155
+ onMessage: (msg) => {
156
+ if (p.conn !== conn) return;
157
+ if (msg.t === 'o') return p.xterm.write(msg.d);
158
+ if (msg.t === 'hello') {
159
+ p.xterm.reset();
160
+ p.replaying = true;
161
+ p.xterm.write(msg.backlog ?? '', () => (p.replaying = false));
162
+ } else if (msg.t === 'size') followSize(p, msg.cols, msg.rows, p.el.querySelector('.gterm'));
163
+ else if (msg.t === 'error') toast(`Terminal unavailable: ${msg.error}`, 5000);
164
+ else if (msg.t === 'exit') {
165
+ if (isShell(p.kind)) p.exited = true;
166
+ else p.xterm.write(`\r\n\x1b[2m[session exited with code ${msg.code}; session kept]\x1b[0m\r\n`);
167
+ renderPane(groupOf(p));
168
+ }
169
+ },
170
+ onClose: (ev) => {
171
+ if (p.conn !== conn) return;
172
+ p.conn = null;
173
+ p.failed = true;
174
+ if (ev.code === 1008) toast(`Terminal unavailable: ${ev.reason}`, 5000);
175
+ },
176
+ },
177
+ );
178
+ p.conn = conn;
179
+ }
180
+
181
+ function disconnect(p) {
182
+ const c = p.conn;
183
+ p.conn = null;
184
+ c?.close();
185
+ }
186
+
187
+ const groupOf = (p) => [...panes].find(([, x]) => x === p)?.[0];
188
+
189
+ /** Open sessions first (needing you, working, waiting), then the rest, most recent first. */
190
+ function pickList() {
191
+ const rank = (a) => (a.runtime?.attention ? 0 : a.runtime?.running && a.runtime?.busy ? 1 : a.runtime?.running ? 2 : 3);
192
+ return [...agents.values()]
193
+ .filter((a) => a.kind !== 'assistant' && a.workdir)
194
+ .sort((x, y) => rank(x) - rank(y) || String(y.activeAt ?? y.createdAt ?? '').localeCompare(String(x.activeAt ?? x.createdAt ?? '')));
195
+ }
196
+
197
+ function renderPane(id) {
198
+ const p = panes.get(id);
199
+ if (!p) return;
200
+ const el = p.el;
201
+ const a = p.agentId && agents.get(p.agentId);
202
+ el.classList.toggle('active', id === active);
203
+ el.classList.toggle('empty', !a);
204
+ const st = a ? statusOf(a) : null;
205
+ el.classList.toggle('attention', st === 'attention');
206
+ const pill = el.querySelector('.gpill');
207
+ pill.hidden = !a;
208
+ if (a) {
209
+ pill.className = `pill gpill ${st}`;
210
+ pill.textContent = pillText(st);
211
+ }
212
+ const name = el.querySelector('.gname');
213
+ const label = a ? `${a.name}${isShell(p.kind) ? ` · shell ${p.kind.split(':')[1] ?? 1}` : ''}` : 'Empty group';
214
+ if (name.textContent !== label) name.textContent = label;
215
+ name.disabled = !a;
216
+ el.querySelector('.gempty').hidden = Boolean(a);
217
+ el.querySelector('.gterm').hidden = !a;
218
+
219
+ // The session: the agent's own (named after its engine) or one of its shells.
220
+ const kindSel = el.querySelector('.gkind');
221
+ kindSel.hidden = !a;
222
+ if (a && document.activeElement !== kindSel) {
223
+ const shells = new Set(a.runtime?.shells ?? []);
224
+ if (isShell(p.kind)) shells.add(Number(p.kind.split(':')[1] ?? 1));
225
+ const opts = [['claude', engineLabel(a.engine)], ...[...shells].sort((x, y) => x - y).map((n) => [`shell:${n}`, `Shell ${n}`]), ['shell:new', '+ New shell']];
226
+ const html = opts.map(([k, l]) => `<option value="${k}" ${k === p.kind ? 'selected' : ''}>${esc(l)}</option>`).join('');
227
+ if (kindSel.dataset.html !== html) {
228
+ kindSel.innerHTML = html;
229
+ kindSel.dataset.html = html;
230
+ }
231
+ kindSel.value = p.kind;
232
+ }
233
+
234
+ const pick = el.querySelector('.gpick');
235
+ if (document.activeElement !== pick) {
236
+ const html = `<option value="">${a ? 'Open another…' : 'Open a session…'}</option>${pickList()
237
+ .map((x) => `<option value="${x.id}">${esc(x.runtime?.running ? '● ' : '')}${esc(x.name)}${x.runtime?.attention ? ' (needs input)' : ''}</option>`)
238
+ .join('')}`;
239
+ if (pick.dataset.html !== html) {
240
+ pick.innerHTML = html;
241
+ pick.dataset.html = html;
242
+ }
243
+ pick.value = '';
244
+ }
245
+
246
+ // A closed session or an exited shell: start it again from here.
247
+ const shell = isShell(p.kind);
248
+ const closed = a && (shell ? p.exited : !a.runtime?.running && a.status !== 'preparing');
249
+ el.querySelector('.goverlay').hidden = !closed;
250
+ if (closed) {
251
+ el.querySelector('.gover-msg').textContent = shell ? 'The shell has exited.' : "This agent's session is closed.";
252
+ el.querySelector('[data-g="resume"]').textContent = shell ? 'Start a new shell' : 'Resume session';
253
+ }
254
+ // The agent's state arrived after the group was restored: connect now.
255
+ if (a && !p.conn && !p.failed && !closed) connect(p);
256
+ }
257
+
258
+ // ------------------------------------------------------------------ layout
259
+
260
+ function nodeEl(n) {
261
+ if (n.leaf) {
262
+ if (n.leaf === 'main') {
263
+ detail.classList.toggle('gactive', active === 'main');
264
+ return detail;
265
+ }
266
+ const p = panes.get(n.leaf) ?? makePane(n.leaf);
267
+ return p.el;
268
+ }
269
+ const box = document.createElement('div');
270
+ box.className = `gsplit g${n.dir}`;
271
+ const a = nodeEl(n.a);
272
+ const b = nodeEl(n.b);
273
+ a.style.flex = `0 0 calc(${n.size}% - 3px)`;
274
+ b.style.flex = '1 1 0';
275
+ const bar = document.createElement('div');
276
+ bar.className = `gsplitter g${n.dir}`;
277
+ bar.setAttribute('role', 'separator');
278
+ bar.title = 'Drag to resize; double-click to even out';
279
+ bar.addEventListener('pointerdown', (e) => resizeFrom(e, bar, box, n, a));
280
+ bar.addEventListener('dblclick', () => {
281
+ n.size = 50;
282
+ a.style.flex = `0 0 calc(50% - 3px)`;
283
+ save();
284
+ refitAll();
285
+ });
286
+ box.append(a, bar, b);
287
+ return box;
288
+ }
289
+
290
+ function resizeFrom(e, bar, box, n, first) {
291
+ e.preventDefault();
292
+ bar.setPointerCapture(e.pointerId);
293
+ document.body.classList.add('resizing', n.dir === 'row' ? 'cols' : 'rows');
294
+ const move = (ev) => {
295
+ const r = box.getBoundingClientRect();
296
+ const at = n.dir === 'row' ? (ev.clientX - r.left) / r.width : (ev.clientY - r.top) / r.height;
297
+ n.size = Math.round(Math.min(85, Math.max(15, at * 100)));
298
+ first.style.flex = `0 0 calc(${n.size}% - 3px)`;
299
+ };
300
+ const up = () => {
301
+ document.body.classList.remove('resizing', 'cols', 'rows');
302
+ bar.removeEventListener('pointermove', move);
303
+ bar.removeEventListener('pointerup', up);
304
+ save();
305
+ refitAll();
306
+ };
307
+ bar.addEventListener('pointermove', move);
308
+ bar.addEventListener('pointerup', up);
309
+ }
310
+
311
+ function refitAll() {
312
+ requestAnimationFrame(() => {
313
+ refitMain();
314
+ for (const p of panes.values()) refit(p);
315
+ });
316
+ }
317
+
318
+ /** Rebuild the layout (only when its shape changes; groups and their terminals are moved, not redrawn). */
319
+ function layout() {
320
+ const one = narrow() || !tree.dir;
321
+ const top = one ? detail : nodeEl(tree);
322
+ if (one) detail.classList.remove('gactive');
323
+ root.classList.toggle('split', !one);
324
+ if (root.firstElementChild !== top || root.children.length !== 1) root.replaceChildren(top);
325
+ if (one) detail.style.removeProperty('flex');
326
+ for (const id of panes.keys()) renderPane(id);
327
+ refitAll();
328
+ }
329
+
330
+ function replace(n, id, next) {
331
+ if (n.leaf) return n.leaf === id ? next : n;
332
+ return { ...n, a: replace(n.a, id, next), b: replace(n.b, id, next) };
333
+ }
334
+
335
+ /** Split a group: a new group to its right ('row') or below it ('col'), active, showing `show` if given. */
336
+ function split(id = active, dir = 'row', show) {
337
+ if (leaves().length >= MAX_GROUPS) return toast(`At most ${MAX_GROUPS} groups`, 3000);
338
+ if (narrow()) return toast('Widen the window to split the screen', 3000);
339
+ const gid = `g${seq++}`;
340
+ while (panes.has(`g${seq}`)) seq++;
341
+ tree = replace(tree, id, { dir, a: { leaf: id }, b: { leaf: gid }, size: 50 });
342
+ makePane(gid);
343
+ active = gid;
344
+ layout();
345
+ if (show) load(gid, show.agentId, show.kind);
346
+ else panes.get(gid).el.querySelector('.gpick').focus();
347
+ save();
348
+ return gid;
349
+ }
350
+
351
+ function close(id) {
352
+ if (id === 'main') return;
353
+ const p = panes.get(id);
354
+ if (!p) return;
355
+ const drop = (n) => {
356
+ if (n.leaf) return n;
357
+ if (n.a.leaf === id) return n.b;
358
+ if (n.b.leaf === id) return n.a;
359
+ return { ...n, a: drop(n.a), b: drop(n.b) };
360
+ };
361
+ tree = drop(tree);
362
+ disconnect(p);
363
+ p.xterm.dispose();
364
+ p.el.remove();
365
+ panes.delete(id);
366
+ if (active === id) {
367
+ active = 'main';
368
+ mainActive();
369
+ }
370
+ layout();
371
+ save();
372
+ }
373
+
374
+ function activate(id) {
375
+ if (id === 'main') mainActive();
376
+ else if (panes.get(id)) lead(panes.get(id));
377
+ if (active === id) return;
378
+ active = id;
379
+ detail.classList.toggle('gactive', id === 'main' && Boolean(tree.dir) && !narrow());
380
+ for (const gid of panes.keys()) panes.get(gid).el.classList.toggle('active', gid === id);
381
+ save();
382
+ }
383
+
384
+ // ------------------------------------------------------------------ events
385
+
386
+ root.addEventListener('pointerdown', (e) => {
387
+ const g = e.target.closest('.gpane');
388
+ activate(g ? g.dataset.group : e.target.closest('#detail') ? 'main' : active);
389
+ }, true);
390
+ root.addEventListener('focusin', (e) => {
391
+ const g = e.target.closest('.gpane');
392
+ if (g) activate(g.dataset.group);
393
+ else if (e.target.closest('#detail')) activate('main');
394
+ });
395
+
396
+ root.addEventListener('click', async (e) => {
397
+ const b = e.target.closest('[data-g]');
398
+ const g = b?.closest('.gpane');
399
+ if (!g) return;
400
+ const id = g.dataset.group;
401
+ const p = panes.get(id);
402
+ switch (b.dataset.g) {
403
+ case 'right':
404
+ return split(id, 'row');
405
+ case 'down':
406
+ return split(id, 'col');
407
+ case 'close':
408
+ return close(id);
409
+ case 'main': {
410
+ if (!p.agentId) return;
411
+ const { agentId, kind } = p;
412
+ close(id);
413
+ return openInMain(agentId, kind);
414
+ }
415
+ case 'resume':
416
+ if (isShell(p.kind)) {
417
+ p.exited = false;
418
+ disconnect(p);
419
+ connect(p);
420
+ return renderPane(id);
421
+ }
422
+ try {
423
+ upsert(await api('POST', `/agents/${p.agentId}/start`, {}));
424
+ if (!p.conn) connect(p);
425
+ p.xterm.focus();
426
+ } catch (err) {
427
+ toast(`Error: ${err.message}`, 5000);
428
+ }
429
+ }
430
+ });
431
+
432
+ root.addEventListener('change', async (e) => {
433
+ const g = e.target.closest('.gpane');
434
+ if (!g) return;
435
+ const id = g.dataset.group;
436
+ const p = panes.get(id);
437
+ if (e.target.classList.contains('gpick') && e.target.value) {
438
+ const agentId = e.target.value;
439
+ e.target.blur();
440
+ return load(id, agentId, 'claude');
441
+ }
442
+ if (e.target.classList.contains('gkind')) {
443
+ let kind = e.target.value;
444
+ e.target.blur();
445
+ if (kind === 'shell:new') {
446
+ try {
447
+ kind = `shell:${(await api('POST', `/agents/${p.agentId}/shell/new`)).n}`;
448
+ } catch (err) {
449
+ renderPane(id);
450
+ return toast(`Error: ${err.message}`, 5000);
451
+ }
452
+ }
453
+ load(id, p.agentId, kind);
454
+ }
455
+ });
456
+
457
+ // Dragging an agent from the list: onto a group to show it there, onto its right or bottom edge to split.
458
+ const zoneOf = (e) => {
459
+ const target = e.target.closest?.('.gpane, #detail');
460
+ if (!target || !root.contains(target)) return null;
461
+ const r = target.getBoundingClientRect();
462
+ const x = (e.clientX - r.left) / r.width;
463
+ const y = (e.clientY - r.top) / r.height;
464
+ const id = target.classList.contains('gpane') ? target.dataset.group : 'main';
465
+ const zone = narrow() ? 'here' : x > 1 - EDGE && x - (1 - EDGE) >= y - (1 - EDGE) ? 'right' : y > 1 - EDGE ? 'down' : 'here';
466
+ return { id, zone, target };
467
+ };
468
+ const clearDrop = () => root.querySelectorAll('[data-gdrop]').forEach((el) => el.removeAttribute('data-gdrop'));
469
+ root.addEventListener('dragover', (e) => {
470
+ const agentId = dragged();
471
+ const z = agentId && zoneOf(e);
472
+ if (!z) return;
473
+ e.preventDefault();
474
+ e.dataTransfer.dropEffect = 'copy';
475
+ if (z.target.dataset.gdrop !== z.zone) {
476
+ clearDrop();
477
+ z.target.dataset.gdrop = z.zone;
478
+ }
479
+ });
480
+ root.addEventListener('dragleave', (e) => {
481
+ if (!root.contains(e.relatedTarget)) clearDrop();
482
+ });
483
+ root.addEventListener('drop', (e) => {
484
+ const agentId = dragged();
485
+ const z = agentId && zoneOf(e);
486
+ clearDrop();
487
+ if (!z) return;
488
+ e.preventDefault();
489
+ if (z.zone === 'here') {
490
+ activate(z.id);
491
+ return load(z.id, agentId, 'claude');
492
+ }
493
+ split(z.id, z.zone === 'right' ? 'row' : 'col', { agentId, kind: 'claude' });
494
+ });
495
+ document.addEventListener('dragend', clearDrop);
496
+
497
+ // Keys, taken before a focused terminal gets them (plain Ctrl+\ stays the terminal's: it's "quit").
498
+ // Cmd+\ (Mac) or Ctrl+Shift+\: split right; with Shift (Mac) or Alt: split down.
499
+ // Ctrl+Shift+1…6: focus group 1…6 (left to right, top to bottom). Ctrl+Shift+X: close the active group.
500
+ document.addEventListener('keydown', (e) => {
501
+ const mac = e.metaKey && !e.ctrlKey;
502
+ const ctrl = e.ctrlKey && e.shiftKey && !e.metaKey;
503
+ let act = null;
504
+ if (e.code === 'Backslash' && mac && !e.altKey) act = () => split(active, e.shiftKey ? 'col' : 'row');
505
+ else if (e.code === 'Backslash' && ctrl) act = () => split(active, e.altKey ? 'col' : 'row');
506
+ else if (ctrl && !e.altKey && /^Digit[1-6]$/.test(e.code)) act = () => focusGroup(Number(e.code.slice(5)));
507
+ else if (ctrl && !e.altKey && e.code === 'KeyX' && active !== 'main' && tree.dir) act = () => close(active);
508
+ if (!act) return;
509
+ e.preventDefault();
510
+ e.stopPropagation();
511
+ act();
512
+ }, true);
513
+
514
+ function focusGroup(n) {
515
+ if (!tree.dir || narrow()) return;
516
+ const id = leaves()[n - 1];
517
+ if (!id) return;
518
+ activate(id);
519
+ if (id === 'main') return focusMain();
520
+ const p = panes.get(id);
521
+ if (p.opened) p.xterm.focus();
522
+ else p.el.querySelector('.gpick').focus();
523
+ }
524
+ matchMedia('(max-width: 760px)').addEventListener('change', () => layout());
525
+
526
+ // Restore the last layout.
527
+ try {
528
+ const saved = JSON.parse(localStorage.getItem(SAVED) ?? 'null');
529
+ if (saved?.tree) {
530
+ const ids = leaves(saved.tree);
531
+ if (ids.includes('main') && ids.length <= MAX_GROUPS) {
532
+ tree = saved.tree;
533
+ for (const id of ids) if (id !== 'main') makePane(id, saved.shows?.[id]);
534
+ active = ids.includes(saved.active) ? saved.active : 'main';
535
+ seq = Math.max(1, ...ids.map((x) => Number(x.slice(1)) || 0)) + 1;
536
+ }
537
+ }
538
+ } catch {}
539
+ layout();
540
+
541
+ return {
542
+ /** Agents changed: names, states and pickers in each group. */
543
+ render() {
544
+ for (const id of panes.keys()) renderPane(id);
545
+ },
546
+ /** The group a click in the list opens into, when it isn't the main one. */
547
+ count: () => panes.size,
548
+ activeSplit: () => (active !== 'main' && panes.has(active) && tree.dir && !narrow() ? active : null),
549
+ load,
550
+ split: (dir) => split(active, dir),
551
+ removed(agentId) {
552
+ for (const [id, p] of panes) if (p.agentId === agentId) close(id);
553
+ },
554
+ };
555
+ }
package/public/index.html CHANGED
@@ -29,6 +29,7 @@
29
29
  </div>
30
30
  <div class="top-actions">
31
31
  <input id="filter" type="search" placeholder="Filter agents" aria-label="Filter agents" />
32
+ <nav class="top-nav" id="top-nav" aria-label="Views">
32
33
  <button id="today-btn" title="Today: what needs you, from every list, most pressing first, and why (y)">Today <span id="today-count" class="badge ready"></span></button>
33
34
  <button id="assistant-btn" title="An always-on session that finds new work and starts agents for it">Assistant <span id="assistant-dot" class="assistant-dot" hidden></span></button>
34
35
  <button id="spend-btn" title="Results across agents (merge rate, time to PR, cost per merged PR), what they cost, and spending limits">Results <span id="spend-today" class="spend-today"></span></button>
@@ -43,6 +44,11 @@
43
44
  <button id="watch-btn" title="Running agents' sessions side by side, live: follow them all without clicking from one to the next">Watch</button>
44
45
  <button id="machine-btn" title="A terminal on this computer (your home folder), from any device you're signed in on">Terminal</button>
45
46
  <button id="ask-btn" title="A general session with no repo or folder, on Claude Code or another engine you have (Codex, Muse Code, …)">Ask Agent</button>
47
+ <div class="menu-wrap top-more" id="top-more" hidden>
48
+ <button id="top-more-btn" type="button" aria-haspopup="menu" aria-expanded="false">More ▾</button>
49
+ <div id="top-more-menu" class="menu" role="menu" hidden></div>
50
+ </div>
51
+ </nav>
46
52
  <button id="new-btn" class="primary">+ New agents</button>
47
53
  <div class="menu-wrap">
48
54
  <button id="menu-btn" class="menu-btn" type="button" aria-haspopup="menu" aria-expanded="false" title="Settings and preferences">
@@ -118,6 +124,7 @@
118
124
  </aside>
119
125
  <div class="splitter split-side" id="split-side" role="separator" aria-orientation="vertical" title="Drag to resize the list; double-click to reset"></div>
120
126
 
127
+ <div class="groups" id="groups">
121
128
  <section class="detail" id="detail">
122
129
  <div class="placeholder" id="placeholder">Select an agent to see its session, folder, repo, PRs and bugs.</div>
123
130
  <div id="detail-body" hidden></div>
@@ -138,6 +145,7 @@
138
145
  <input type="file" id="term-file" multiple hidden>
139
146
  <button id="term-fit" class="ghost small" title="Refit the terminal to the panel">Fit</button>
140
147
  <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>
148
+ <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 (Cmd+\ on a Mac, or Ctrl+Shift+\; add Shift on a Mac, or Alt, to split down). Or drag an agent from the list onto the right or bottom edge">⊞ Split screen</button>
141
149
  <button id="term-max" class="ghost small desk-only" title="Expand to fill the window (Ctrl+Shift+E)">⤢ Expand</button>
142
150
  <button id="term-full" class="ghost small desk-only" title="Full screen (Esc to leave)">⛶ Full screen</button>
143
151
  <button id="term-close" class="ghost small" title="Hide the terminal (the agent keeps running)">Hide terminal</button>
@@ -219,6 +227,7 @@
219
227
  </div>
220
228
  </div>
221
229
  </section>
230
+ </div>
222
231
  </main>
223
232
 
224
233
  <dialog id="new-dialog">
package/public/keys.js CHANGED
@@ -59,6 +59,12 @@ export const SHORTCUTS = [
59
59
  [['Ctrl+Shift+L'], 'Leave the terminal (then the keys above work)', 'leave'],
60
60
  [['Ctrl+Shift+E'], 'Expand or shrink the terminal', null],
61
61
  ]],
62
+ ['Split screen (also from a terminal)', [
63
+ [['Cmd+\\', 'Ctrl+Shift+\\'], 'Split the active group to the right', null],
64
+ [['Cmd+Shift+\\', 'Ctrl+Alt+Shift+\\'], 'Split it down', null],
65
+ [['Ctrl+Shift+1…6'], 'Go to group 1 to 6 (left to right, top to bottom)', null],
66
+ [['Ctrl+Shift+X'], 'Close the active group (its agent keeps running)', null],
67
+ ]],
62
68
  ];
63
69
 
64
70
  // A single key, as an event names it, to its action.
package/public/style.css CHANGED
@@ -88,8 +88,25 @@ a:hover { text-decoration: underline; }
88
88
  .about-list .sep { grid-column: 1 / -1; border-top: 1px solid var(--border); margin: 4px 0; }
89
89
  .conn.ok::before { content: '● '; color: var(--green); }
90
90
  .conn.bad::before { content: '● '; color: var(--red); }
91
- .top-actions { display: flex; gap: 8px; }
92
- .top-actions input { width: 220px; }
91
+ /* Below 1100px the title and connection text step aside for the view buttons: the logo and a dot stay. */
92
+ @media (max-width: 1100px) {
93
+ .brand { gap: 6px; }
94
+ .brand h1 { display: none; }
95
+ .conn { font-size: 0; }
96
+ .conn::before { font-size: 12px; }
97
+ .about-btn { padding: 2px 6px; }
98
+ }
99
+ .top-actions { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
100
+ .top-actions > * { flex-shrink: 0; }
101
+ /* The filter gives up its room first, then the view buttons go into More (topnav.js). */
102
+ .top-actions > input { width: 220px; flex: 0 1000 220px; min-width: 120px; }
103
+ .top-nav { display: flex; gap: 8px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
104
+ .top-nav > * { flex: none; }
105
+ .top-actions > .top-nav { flex-shrink: 1; }
106
+ .top-more { position: static; }
107
+ #top-more-btn.has-news::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
108
+ #top-more-menu { position: fixed; top: auto; right: 16px; margin-top: 6px; min-width: 200px; }
109
+ #top-more-menu > button { display: flex; align-items: center; gap: 8px; }
93
110
 
94
111
  /* ---------- controls */
95
112
  button {
@@ -124,6 +141,41 @@ body.resizing iframe, body.resizing .terminal { pointer-events: none; }
124
141
  body.resizing.cols { cursor: col-resize; }
125
142
  body.resizing.rows { cursor: row-resize; }
126
143
 
144
+ /* Split screen (VS Code's editor groups): the main panel plus groups with other sessions. */
145
+ .groups { display: flex; min-width: 0; min-height: 0; }
146
+ .groups > .detail { flex: 1 1 0; }
147
+ .gsplit { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; }
148
+ .gsplit.grow { flex-direction: row; }
149
+ .gsplit.gcol { flex-direction: column; }
150
+ .gsplit > * { min-width: 0; min-height: 0; }
151
+ .gsplitter { flex: none; position: relative; z-index: 3; background: var(--border); }
152
+ .gsplitter.grow { width: 1px; margin: 0 2px; cursor: col-resize; }
153
+ .gsplitter.gcol { height: 1px; margin: 2px 0; cursor: row-resize; }
154
+ .gsplitter::after { content: ''; position: absolute; }
155
+ .gsplitter.grow::after { top: 0; bottom: 0; left: -4px; width: 9px; }
156
+ .gsplitter.gcol::after { left: 0; right: 0; top: -4px; height: 9px; }
157
+ .gsplitter:hover::after { background: var(--accent); opacity: .5; }
158
+ .groups.split .detail, .gpane { outline: 1px solid transparent; outline-offset: -1px; }
159
+ .groups.split .detail.gactive, .gpane.active { outline-color: var(--accent); }
160
+ .gpane { display: flex; flex-direction: column; background: var(--panel); }
161
+ .gpane.attention .gbar { box-shadow: inset 0 -2px 0 var(--red); }
162
+ .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; }
163
+ .gbar > * { flex: none; }
164
+ .gbar .gname { flex: 0 1 auto; min-width: 48px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
165
+ .gbar .spacer { flex: 1 1 0; min-width: 0; }
166
+ .gbar select { width: auto; min-width: 0; max-width: 140px; padding: 1px 4px; font-size: 12px; flex: 0 1 auto; }
167
+ .groups.split .detail { overflow: hidden; }
168
+ .gbody { position: relative; flex: 1; min-height: 0; background: #0f1117; }
169
+ .gterm { position: absolute; inset: 4px 0 0 6px; }
170
+ .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); }
171
+ .goverlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center; background: rgba(15, 17, 23, .92); color: #c9d1d9; }
172
+ body.resizing .gterm { pointer-events: none; }
173
+ [data-gdrop] { position: relative; }
174
+ [data-gdrop]::before { content: ''; position: absolute; z-index: 6; pointer-events: none; background: var(--accent); opacity: .18; border: 2px solid var(--accent); }
175
+ [data-gdrop="here"]::before { inset: 0; }
176
+ [data-gdrop="right"]::before { top: 0; bottom: 0; right: 0; width: 50%; }
177
+ [data-gdrop="down"]::before { left: 0; right: 0; bottom: 0; height: 50%; }
178
+
127
179
  /* Expanded: the terminal, shell or browser fills the window. */
128
180
  body.term-max .topbar, body.term-max .sidebar, body.term-max .split-side,
129
181
  body.term-max #detail-body, body.term-max .split-term, body.term-max #placeholder { display: none !important; }
@@ -466,6 +518,7 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
466
518
  html, body { overflow-x: hidden; max-width: 100vw; }
467
519
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
468
520
  .top-actions { width: 100%; flex-wrap: wrap; }
521
+ .top-actions > .top-nav { flex: 1 1 100%; order: 1; }
469
522
  .top-actions input { flex: 1 1 140px; width: auto; min-width: 0; }
470
523
  .d-head, .d-actions { min-width: 0; }
471
524
  .d-actions button { flex: 1 1 auto; }
@@ -0,0 +1,75 @@
1
+ // The top bar's view buttons fit the window: the ones that don't fit move, in order, into a
2
+ // "More" menu at the end of the row (as VS Code does with tabs). The buttons themselves move, so
3
+ // their handlers, counts and shortcuts keep working; a count on a moved one shows as a dot on More.
4
+
5
+ export function initTopNav({ $ }) {
6
+ const nav = $('#top-nav');
7
+ const wrap = $('#top-more');
8
+ const btn = $('#top-more-btn');
9
+ const menu = $('#top-more-menu');
10
+ const order = [...nav.querySelectorAll(':scope > button')];
11
+ let fitting = false;
12
+
13
+ const counted = (b) => [...b.querySelectorAll('.badge')].some((x) => x.textContent.trim()) || Boolean(b.querySelector('.assistant-dot:not([hidden])'));
14
+
15
+ function fit() {
16
+ if (fitting) return;
17
+ fitting = true;
18
+ observer.disconnect();
19
+ // Everything back in the row, in order; then move the last ones out until the row fits.
20
+ for (const b of order) nav.insertBefore(b, wrap);
21
+ wrap.hidden = false;
22
+ const moved = [];
23
+ while (nav.scrollWidth > nav.clientWidth + 1) {
24
+ const last = order.filter((b) => b.parentElement === nav && !b.hidden).pop();
25
+ if (!last) break;
26
+ moved.unshift(last);
27
+ menu.prepend(last);
28
+ }
29
+ wrap.hidden = moved.length === 0;
30
+ if (!moved.length) close();
31
+ btn.classList.toggle('has-news', moved.some(counted));
32
+ btn.title = moved.length ? `More: ${moved.map((b) => b.firstChild?.textContent?.trim()).filter(Boolean).join(', ')}` : '';
33
+ observe();
34
+ fitting = false;
35
+ }
36
+
37
+ let queued = false;
38
+ const later = () => {
39
+ if (queued) return;
40
+ queued = true;
41
+ requestAnimationFrame(() => {
42
+ queued = false;
43
+ fit();
44
+ });
45
+ };
46
+ // Counts change the buttons' widths; the window and the rest of the bar change the room.
47
+ const observer = new MutationObserver(later);
48
+ const observe = () => {
49
+ for (const b of order) observer.observe(b, { childList: true, characterData: true, subtree: true, attributes: true, attributeFilter: ['hidden', 'class'] });
50
+ };
51
+ new ResizeObserver(later).observe(nav.parentElement);
52
+ addEventListener('resize', later);
53
+
54
+ function close() {
55
+ menu.hidden = true;
56
+ btn.setAttribute('aria-expanded', 'false');
57
+ }
58
+ btn.addEventListener('click', (e) => {
59
+ e.stopPropagation();
60
+ menu.hidden = !menu.hidden;
61
+ btn.setAttribute('aria-expanded', String(!menu.hidden));
62
+ });
63
+ // A button in the menu does its own thing (its handler is unchanged); then the menu closes.
64
+ menu.addEventListener('click', () => setTimeout(close));
65
+ document.addEventListener('click', (e) => {
66
+ if (!menu.hidden && !wrap.contains(e.target)) close();
67
+ });
68
+ document.addEventListener('keydown', (e) => {
69
+ if (e.key === 'Escape' && !menu.hidden) close();
70
+ });
71
+
72
+ fit();
73
+ document.fonts?.ready.then(later);
74
+ return { fit };
75
+ }
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;