claude-code-kanban 7.25.0 → 7.27.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/public/app.js CHANGED
@@ -95,8 +95,10 @@ let sessionsHasMore = false;
95
95
  // URL, so a query string would not survive a hub reload.
96
96
  const ZEN_KEY = 'zenMode';
97
97
  let zenMode = store.getItem(ZEN_KEY) === 'true';
98
- // Group zen: the sidebar shows one group's subtree. A view of the moment, so it is not persisted.
98
+ // Group and project zen: the sidebar shows one group's subtree or one project. A view of the
99
+ // moment, so neither is persisted.
99
100
  let zenGroup = null;
101
+ let zenProject = null;
100
102
  let filterProject = FILTER_DEFAULTS.project; // null = all, '__recent__' = last 24h, or project path
101
103
  let recentProjects = new Set();
102
104
  let projectsCacheDirty = true;
@@ -236,7 +238,7 @@ function updateUrl() {
236
238
  history.replaceState(null, '', url);
237
239
  persistLastView();
238
240
  syncTerminal();
239
- schedulePublishSession();
241
+ schedulePublish();
240
242
  }
241
243
 
242
244
  const LAST_VIEW_KEY = 'lastView';
@@ -263,6 +265,8 @@ function resetState() {
263
265
  filterProject = FILTER_DEFAULTS.project;
264
266
  zenMode = false;
265
267
  zenGroup = null;
268
+ zenProject = null;
269
+ setZenPeek(null);
266
270
  store.removeItem(ZEN_KEY);
267
271
  renderZenState();
268
272
  searchQuery = '';
@@ -335,8 +339,10 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
335
339
  // info modal both look it up in `sessions` and bail when it is absent, so a session
336
340
  // opened from outside the current filter would leave the view on the previous one.
337
341
  // The server adds the pinned sessions itself; the ones `session open` showed are this page's.
338
- // Group zen ignores the filters, and its session members come back through `include`.
339
- const zenIds = zenGroup ? sgSubtreeIds(zenGroup) : new Set();
342
+ // Group and project zen keep the Active/All filter and drop the others. Under All, a group's
343
+ // session members come back through `include`, as they may be past the page limit.
344
+ const zenScope = !!(zenGroup || zenProject);
345
+ const zenIds = zenGroup && sessionFilter !== 'active' ? sgSubtreeIds(zenGroup) : new Set();
340
346
  const zenMembers = sessionGroups
341
347
  .filter((g) => zenIds.has(g.id))
342
348
  .flatMap((g) => g.members.filter((m) => m.type === 'session').map((m) => m.ref));
@@ -347,19 +353,24 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
347
353
  ...openedStickyIds,
348
354
  ...zenMembers,
349
355
  ].filter(Boolean);
350
- const recent = !zenGroup && filterProject === '__recent__';
356
+ const recent = !zenScope && filterProject === '__recent__';
357
+ const project = zenProject || (!zenScope && !recent && filterProject) || null;
358
+ const listScope = `${project}|${recent}|${sessionFilter}|${sessionLimit}`;
351
359
  const res = await api('/api/sessions', {
352
360
  query: {
353
361
  limit: sessionLimit,
354
362
  include: include.length ? include.join(',') : null,
355
363
  recentHours: recent ? RECENT_PROJECT_HOURS : null,
356
- project: !zenGroup && !recent && filterProject ? filterProject : null,
357
- filter: !zenGroup && sessionFilter === 'active' ? 'active' : null,
364
+ project,
365
+ filter: sessionFilter === 'active' ? 'active' : null,
358
366
  },
359
367
  });
360
368
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
361
369
  sessionsHasMore = res.headers.get('X-Has-More') === 'true';
362
370
  const newSessions = await res.json();
371
+ // A list from another server scope would make every session it adds look newly active.
372
+ if (listScope !== lastListScope) prevActiveSessionIds = null;
373
+ lastListScope = listScope;
363
374
  const sessionsHash = JSON.stringify(newSessions);
364
375
  if (sessionsHash !== lastSessionsHash) {
365
376
  lastSessionsHash = sessionsHash;
@@ -368,7 +379,7 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
368
379
  sgSweepTransient();
369
380
  renderSessions();
370
381
  renderActivityChip();
371
- schedulePublishSession();
382
+ schedulePublish();
372
383
  }
373
384
  // A list too short to scroll gives no scroll event, so fill it until it can scroll.
374
385
  if (sessionsHasMore) setTimeout(() => loadMoreIfNearEnd());
@@ -490,7 +501,8 @@ function sessionSearch(onFound) {
490
501
  };
491
502
  }
492
503
 
493
- const sidebarSearch = sessionSearch(renderSessions);
504
+ // A lambda, not the function: a hub mod replaces window.renderSessions after this line runs.
505
+ const sidebarSearch = sessionSearch(() => renderSessions());
494
506
 
495
507
  // biome-ignore lint/correctness/noUnusedVariables: used in HTML
496
508
  function handleSearch(query) {
@@ -681,9 +693,11 @@ function renderActivityChip() {
681
693
  `;
682
694
  })
683
695
  .join('');
684
- if (html === lastChipHtml) return;
685
- lastChipHtml = html;
686
- container.innerHTML = html;
696
+ if (html !== lastChipHtml) {
697
+ lastChipHtml = html;
698
+ container.innerHTML = html;
699
+ }
700
+ return counts;
687
701
  }
688
702
 
689
703
  function toggleActivityKind(kind) {
@@ -818,6 +832,8 @@ async function fetchTasks(sessionId) {
818
832
  //#region TIMINGS
819
833
  const WAITING_TTL_MS = 30 * 60 * 1000;
820
834
  const AGENT_LOG_MAX = 8;
835
+ const AGENT_LOG_PAGE = 24;
836
+ let agentLogLimit = AGENT_LOG_PAGE;
821
837
  const ZEN_AGENTS_MAX = 5;
822
838
  const LIVE_INDICATOR_MS = 10 * 1000;
823
839
  const JUST_NOW_MS = 60 * 1000;
@@ -1799,8 +1815,12 @@ function planApprovalControlsHtml(inputId) {
1799
1815
 
1800
1816
  // biome-ignore lint/correctness/noUnusedVariables: used in HTML onclick
1801
1817
  function rejectWaitingPlan(inputId) {
1802
- const feedback = document.getElementById(inputId)?.value?.trim();
1803
- respondWaiting({ behavior: 'deny', message: feedback || PLAN_REJECT_MSG });
1818
+ denyWaiting(document.getElementById(inputId)?.value);
1819
+ }
1820
+
1821
+ function denyWaiting(feedback) {
1822
+ const message = feedback?.trim() || (currentWaiting?.kind === 'plan' ? PLAN_REJECT_MSG : '');
1823
+ respondWaiting({ behavior: 'deny', ...(message && { message }) });
1804
1824
  }
1805
1825
 
1806
1826
  // UI-driven approvals: POST the decision the plugin's mod is polling for.
@@ -3449,7 +3469,7 @@ function agentTaskText(a) {
3449
3469
  function agentElapsed(a, now) {
3450
3470
  return a.status === 'stopped' && a.stoppedAt
3451
3471
  ? new Date(a.stoppedAt).getTime() - new Date(a.startedAt || a.stoppedAt).getTime()
3452
- : now - new Date(a.startedAt || a.updatedAt).getTime();
3472
+ : now - agentStart(a);
3453
3473
  }
3454
3474
 
3455
3475
  function agentIdentHtml(a) {
@@ -3530,13 +3550,17 @@ function visibleAgents() {
3530
3550
  }
3531
3551
 
3532
3552
  function renderAgentFooter() {
3553
+ schedulePublish();
3533
3554
  const footer = document.getElementById('agent-footer');
3534
3555
  const content = document.getElementById('agent-footer-content');
3535
3556
  const label = document.getElementById('agent-footer-label');
3536
3557
  const now = Date.now();
3537
3558
  const agents = visibleAgents();
3538
3559
  renderZenAgents(agents);
3539
- const visible = agents.slice(0, AGENT_LOG_MAX);
3560
+ renderAgentViews(agents);
3561
+ const expanded = footer.classList.contains('expanded');
3562
+ const visible = agents.slice(0, expanded ? agentLogLimit : AGENT_LOG_MAX);
3563
+ const hidden = agents.length - visible.length;
3540
3564
 
3541
3565
  const permFresh = isWaitingFresh();
3542
3566
 
@@ -3550,7 +3574,8 @@ function renderAgentFooter() {
3550
3574
  }
3551
3575
 
3552
3576
  footer.classList.add('visible');
3553
- label.textContent = `Agents Log (${visible.length})`;
3577
+ const running = agents.filter((a) => a.status === 'active').length;
3578
+ label.innerHTML = `Agents log <span class="agent-footer-count">${agents.length}</span>${running ? `<span class="agent-footer-running">· ${running} running</span>` : ''}`;
3554
3579
 
3555
3580
  const permHtml = permFresh
3556
3581
  ? `<button type="button" class="permission-badge" onclick="showWaitingDetail()">${currentWaiting.kind === 'question' ? '❓ Question pending' : currentWaiting.kind === 'plan' ? '📋 Plan pending' : `⏳ Awaiting: ${escapeHtml(currentWaiting.toolName || 'unknown')}`}</button>`
@@ -3561,30 +3586,27 @@ function renderAgentFooter() {
3561
3586
  visible
3562
3587
  .map((a) => {
3563
3588
  const elapsed = agentElapsed(a, now);
3564
- const statusText =
3565
- a.status === 'stopped'
3566
- ? `stopped · ${formatDuration(elapsed)}`
3567
- : a.status === 'idle'
3568
- ? `idle · ${formatDuration(elapsed)}`
3569
- : `active · ${formatDuration(elapsed)}`;
3589
+ const status = agentStatus(a);
3570
3590
  const displayText = agentTaskText(a);
3571
3591
  const taskHtml = `<div class="agent-task" title="${escapeHtml(displayText)}">${escapeHtml(displayText)}</div>`;
3572
3592
  const agentNameVal = a.agentName || null;
3573
- const nameColor = agentNameVal ? getOwnerColor(agentNameVal) : null;
3593
+ const nameColor = agentNameVal ? resolveNamedColor(a.color) || getOwnerColor(agentNameVal) : null;
3574
3594
  const nameBadgeHtml = nameColor
3575
3595
  ? `<span class="task-owner-badge task-owner-badge--compact" style="background:${nameColor.bg};color:${nameColor.color}">${escapeHtml(agentNameVal)}</span>`
3576
3596
  : '';
3577
- const agentColor = resolveNamedColor(a.color);
3578
- const colorStyle = agentColor ? ` style="border-left:3px solid ${agentColor.color}"` : '';
3579
3597
  const selectedClass = a.agentId === currentAgentModalId ? ' selected' : '';
3580
- return `<div class="agent-card${selectedClass}" data-agent-id="${escapeHtml(a.agentId)}"${colorStyle} onclick="showAgentModal('${escAttrJs(a.agentId)}')">
3598
+ return `<div class="agent-card ${status}${selectedClass}" data-agent-id="${escapeHtml(a.agentId)}" onclick="showAgentModal('${escAttrJs(a.agentId)}')">
3581
3599
  ${agentLogButton(a.agentId, 'agent-card-log-btn')}
3582
3600
  ${taskHtml}
3583
3601
  <div class="agent-ident-row">${agentIdentHtml(a)}${nameBadgeHtml}</div>
3584
- <div class="agent-status-row"><span class="agent-dot ${a.status}"></span><span class="agent-status">${statusText}</span></div>
3602
+ <div class="agent-status-row"><span class="agent-status"><span class="agent-dot ${status}"></span>${status}</span><span class="agent-duration">${formatDuration(elapsed)}</span></div>
3585
3603
  </div>`;
3586
3604
  })
3587
- .join('');
3605
+ .join('') +
3606
+ (expanded && hidden > 0
3607
+ ? `<button type="button" class="agent-footer-more" onclick="showMoreAgents()">Show ${Math.min(hidden, AGENT_LOG_PAGE)} more${hidden > AGENT_LOG_PAGE ? ` <span>of ${hidden}</span>` : ''}</button>`
3608
+ : '');
3609
+ updateScrollFades(content);
3588
3610
 
3589
3611
  clearInterval(agentDurationInterval);
3590
3612
  if (visible.some((a) => a.status === 'active' || a.status === 'idle')) {
@@ -3613,6 +3635,348 @@ function toggleAgentFooter() {
3613
3635
  applyAgentFooterCollapsed();
3614
3636
  }
3615
3637
 
3638
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
3639
+ function toggleAgentFooterExpanded() {
3640
+ const footer = document.getElementById('agent-footer');
3641
+ const expanded = footer.classList.toggle('expanded');
3642
+ agentLogLimit = AGENT_LOG_PAGE;
3643
+ if (expanded && footer.classList.contains('collapsed')) {
3644
+ store.setItem(agentFooterCollapseKey(), false);
3645
+ applyAgentFooterCollapsed();
3646
+ }
3647
+ document.getElementById('agent-footer-expand').title = expanded ? 'Show fewer agents' : 'Show all agents';
3648
+ renderAgentFooter();
3649
+ }
3650
+
3651
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
3652
+ function showMoreAgents() {
3653
+ agentLogLimit += AGENT_LOG_PAGE;
3654
+ renderAgentFooter();
3655
+ }
3656
+
3657
+ const AGENT_MAP_COL = 260;
3658
+ const AGENT_MAP_ROW = 44;
3659
+ const AGENT_MAP_NODE_W = 220;
3660
+ const AGENT_MAP_NODE_H = 36;
3661
+ const AGENT_VIEW_KEY = 'agentView';
3662
+ const AGENT_COLOR_KEY = 'agentColor';
3663
+ let agentView = 'timeline';
3664
+ let agentViewsShape = '';
3665
+ let agentViewsAt = 0;
3666
+
3667
+ function agentStatus(a) {
3668
+ return a.status === 'stopped' || a.status === 'idle' ? a.status : 'active';
3669
+ }
3670
+
3671
+ // An agent whose parent is not in the list (a ghost, or the main session) hangs off its session's root.
3672
+ function agentTree(agents) {
3673
+ const byId = new Map(agents.map((a) => [a.agentId, { agent: a, children: [] }]));
3674
+ const roots = new Map();
3675
+ for (const node of byId.values()) {
3676
+ const parent = node.agent.parent && byId.get(node.agent.parent);
3677
+ if (parent) {
3678
+ parent.children.push(node);
3679
+ continue;
3680
+ }
3681
+ const sid = node.agent._sourceSessionId || currentSessionId || '';
3682
+ if (!roots.has(sid)) roots.set(sid, { agent: null, sid, children: [] });
3683
+ roots.get(sid).children.push(node);
3684
+ }
3685
+ const byStart = (x, y) => new Date(x.agent.startedAt || 0) - new Date(y.agent.startedAt || 0);
3686
+ const sortDeep = (n) => {
3687
+ n.children.sort(byStart);
3688
+ n.children.forEach(sortDeep);
3689
+ };
3690
+ const list = [...roots.values()];
3691
+ list.forEach(sortDeep);
3692
+ return list;
3693
+ }
3694
+
3695
+ function agentRootLabel(root, many) {
3696
+ const s = many && sessions.find((x) => x.id === root.sid);
3697
+ return s ? sessionDisplayName(s) : 'main';
3698
+ }
3699
+
3700
+ function agentMapHtml(roots, now) {
3701
+ let row = 0;
3702
+ let maxDepth = 0;
3703
+ const nodes = [];
3704
+ const edges = [];
3705
+ agentWaves(roots);
3706
+ const place = (n, depth, parentWave) => {
3707
+ const wave = n.wave || parentWave;
3708
+ maxDepth = Math.max(maxDepth, depth);
3709
+ let y;
3710
+ if (n.children.length) {
3711
+ const ys = n.children.map((c) => place(c, depth + 1, wave));
3712
+ y = (ys[0] + ys[ys.length - 1]) / 2;
3713
+ for (const cy of ys) edges.push([depth, y, cy]);
3714
+ } else {
3715
+ y = row++ * AGENT_MAP_ROW;
3716
+ }
3717
+ nodes.push({ n, depth, y, wave });
3718
+ return y;
3719
+ };
3720
+ for (const r of roots) {
3721
+ place(r, 0);
3722
+ row += 0.5;
3723
+ }
3724
+ const width = maxDepth * AGENT_MAP_COL + AGENT_MAP_NODE_W;
3725
+ const height = (row - 0.5) * AGENT_MAP_ROW;
3726
+ const mid = AGENT_MAP_NODE_H / 2;
3727
+ const paths = edges.map(([depth, y1, y2]) => {
3728
+ const x1 = depth * AGENT_MAP_COL + AGENT_MAP_NODE_W;
3729
+ const x2 = (depth + 1) * AGENT_MAP_COL;
3730
+ const xm = (x1 + x2) / 2;
3731
+ return `<path d="M${x1} ${y1 + mid}C${xm} ${y1 + mid} ${xm} ${y2 + mid} ${x2} ${y2 + mid}"/>`;
3732
+ });
3733
+ const colors = new Map();
3734
+ const many = roots.length > 1;
3735
+ const html = nodes.map(({ n, depth, y, wave }) => {
3736
+ const pos = `left:${depth * AGENT_MAP_COL}px;top:${y}px`;
3737
+ if (!n.agent) return `<div class="agent-map-node root" style="${pos}">${escapeHtml(agentRootLabel(n, many))}</div>`;
3738
+ const a = n.agent;
3739
+ const status = agentStatus(a);
3740
+ const task = agentTaskText(a);
3741
+ const kind = agentKind(a);
3742
+ const fill = agentColor(a, status, wave, colors);
3743
+ return `<button type="button" class="agent-map-node ${escapeHtml(status)}" style="${pos};border-color:${fill}" title="${escapeHtml(`${kind}\n${task}`)}" onclick="showAgentModal('${escAttrJs(a.agentId)}')"><span class="agent-map-text"><span class="agent-map-kind">${escapeHtml(kind)}</span>${escapeHtml(task)}</span><span class="agent-views-time">${formatDuration(agentElapsed(a, now))}</span></button>`;
3744
+ });
3745
+ return {
3746
+ html: `<div class="agent-map" style="width:${width}px;height:${height}px;--node-w:${AGENT_MAP_NODE_W}px;--node-h:${AGENT_MAP_NODE_H}px"><svg class="agent-map-edges" width="${width}" height="${height}">${paths.join('')}</svg>${html.join('')}</div>`,
3747
+ legend: agentLegendHtml(colors),
3748
+ };
3749
+ }
3750
+
3751
+ // Agents come in bursts with long idle gaps between them. A linear axis would draw each burst as a
3752
+ // dot, so a gap longer than AGENT_SPINE_GAP_SHARE of the busy time is drawn at that width.
3753
+ const AGENT_SPINE_GAP_SHARE = 0.05;
3754
+
3755
+ function agentTimeScale(spans) {
3756
+ const sorted = [...spans].sort((x, y) => x[0] - y[0]);
3757
+ const merged = [];
3758
+ for (const [s, e] of sorted) {
3759
+ const last = merged[merged.length - 1];
3760
+ if (last && s <= last[1]) last[1] = Math.max(last[1], e);
3761
+ else merged.push([s, e]);
3762
+ }
3763
+ const busy = merged.reduce((sum, [s, e]) => sum + (e - s), 0);
3764
+ const maxGap = Math.max(busy * AGENT_SPINE_GAP_SHARE, 1000);
3765
+ const offsets = [];
3766
+ const cutAt = [];
3767
+ let x = 0;
3768
+ merged.forEach(([s, e], i) => {
3769
+ if (i) {
3770
+ const gap = s - merged[i - 1][1];
3771
+ if (gap > maxGap) cutAt.push(x + maxGap / 2);
3772
+ x += Math.min(gap, maxGap);
3773
+ }
3774
+ offsets.push(x);
3775
+ x += e - s;
3776
+ });
3777
+ const total = Math.max(x, 1000);
3778
+ const pct = (t) => {
3779
+ let i = merged.length - 1;
3780
+ while (i > 0 && t < merged[i][0]) i--;
3781
+ return ((offsets[i] + Math.max(0, t - merged[i][0])) / total) * 100;
3782
+ };
3783
+ return { pct, cuts: cutAt.map((c) => (c / total) * 100) };
3784
+ }
3785
+
3786
+ // Agents that the main session starts within this window of each other came from one turn.
3787
+ const AGENT_WAVE_MS = 10000;
3788
+ const AGENT_SPINE_TOP = 26;
3789
+ const AGENT_SPINE_ROW = 22;
3790
+ const AGENT_SPINE_BAR_H = 16;
3791
+ const AGENT_SPINE_LABEL_MAX = 260;
3792
+ const AGENT_SPINE_NEST_PX = 14;
3793
+
3794
+ const AGENT_COLOR_MODES = ['type', 'model', 'status', 'wave'];
3795
+ let agentColorBy = 'wave';
3796
+ const AGENT_STATUS_FILL = { active: 'var(--success)', idle: 'var(--warning)', stopped: 'var(--text-muted)' };
3797
+ const AGENT_CLOCK = new Intl.DateTimeFormat([], { hour: '2-digit', minute: '2-digit' });
3798
+
3799
+ function agentKind(a) {
3800
+ return `${agentTypeParts(a).raw} · ${shortModelName(agentModel(a)) || '?'}`;
3801
+ }
3802
+
3803
+ // Returns the fill for one agent and records it in the legend's colors map.
3804
+ function agentColor(a, status, wave, colors) {
3805
+ let key;
3806
+ let fill;
3807
+ if (agentColorBy === 'status') [key, fill] = [status, AGENT_STATUS_FILL[status]];
3808
+ else if (agentColorBy === 'wave') [key, fill] = [wave.time, ownerColors[wave.index % ownerColors.length].color];
3809
+ else {
3810
+ key = agentColorBy === 'model' ? shortModelName(agentModel(a)) || '?' : agentTypeParts(a).raw;
3811
+ fill = getOwnerColor(key).color;
3812
+ }
3813
+ colors.set(key, fill);
3814
+ return fill;
3815
+ }
3816
+
3817
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
3818
+ function setAgentColor(mode) {
3819
+ agentColorBy = mode;
3820
+ store.setItem(AGENT_COLOR_KEY, mode);
3821
+ renderAgentViews(visibleAgents());
3822
+ }
3823
+
3824
+ function agentStart(a) {
3825
+ return new Date(a.startedAt || a.updatedAt).getTime();
3826
+ }
3827
+
3828
+ // A wave is the top-level agents started within AGENT_WAVE_MS of the previous one.
3829
+ // Each top-level node gets its wave as `wave`.
3830
+ function agentWaves(roots) {
3831
+ const top = roots.flatMap((r) => r.children);
3832
+ for (const n of top) n.start = agentStart(n.agent);
3833
+ top.sort((x, y) => x.start - y.start);
3834
+ const waves = [];
3835
+ for (const n of top) {
3836
+ const w = waves[waves.length - 1];
3837
+ if (w && n.start - w.last <= AGENT_WAVE_MS) w.nodes.push(n);
3838
+ else waves.push({ t: n.start, nodes: [n], index: waves.length, time: AGENT_CLOCK.format(n.start) });
3839
+ n.wave = waves[waves.length - 1];
3840
+ n.wave.last = n.start;
3841
+ }
3842
+ return waves;
3843
+ }
3844
+
3845
+ function agentLegendHtml(colors) {
3846
+ const legend = [...colors]
3847
+ .map(([key, c]) => `<span><i style="background:${c}"></i>${escapeHtml(key)}</span>`)
3848
+ .join('');
3849
+ const live = agentColorBy === 'status' ? '' : '<span><i class="agent-views-live"></i>running</span>';
3850
+ return legend + live;
3851
+ }
3852
+
3853
+ // The main session is a line along time. Each wave of agents branches off it where it started,
3854
+ // and a nested agent branches off its parent's bar. A wave takes the first rows free at its start,
3855
+ // counting the label after each bar, so labels of neighbouring waves never overlap.
3856
+ function agentSpineHtml(roots, now, width) {
3857
+ const plot = Math.max(width - AGENT_SPINE_LABEL_MAX, 200);
3858
+ const px = (p) => (p / 100) * plot;
3859
+ const end = (a) => agentStart(a) + agentElapsed(a, now);
3860
+ const waves = agentWaves(roots);
3861
+ const spans = [];
3862
+ const collect = (n) => {
3863
+ spans.push([agentStart(n.agent), end(n.agent)]);
3864
+ n.children.forEach(collect);
3865
+ };
3866
+ for (const w of waves) w.nodes.forEach(collect);
3867
+ const { pct, cuts } = agentTimeScale(spans);
3868
+
3869
+ const rowEnd = [];
3870
+ const bars = [];
3871
+ const links = [];
3872
+ const dots = [];
3873
+ const ticks = [];
3874
+ const colors = new Map();
3875
+ let lastTick = -Infinity;
3876
+ const rowY = (row) => AGENT_SPINE_TOP + row * AGENT_SPINE_ROW;
3877
+ for (const w of waves) {
3878
+ const list = [];
3879
+ const walk = (n, parent) => {
3880
+ const item = { n, parent };
3881
+ list.push(item);
3882
+ for (const c of n.children) walk(c, item);
3883
+ };
3884
+ for (const n of w.nodes) walk(n, null);
3885
+ const x0 = px(pct(w.t));
3886
+ let base = 0;
3887
+ while (list.some((_, k) => (rowEnd[base + k] ?? -1) > x0)) base++;
3888
+ list.forEach((item, k) => {
3889
+ const a = item.n.agent;
3890
+ const row = base + k;
3891
+ const xs = Math.max(px(pct(agentStart(a))), item.parent ? item.parent.x + AGENT_SPINE_NEST_PX : x0 + 6);
3892
+ const barW = Math.max(px(pct(end(a))) - xs, 4);
3893
+ const task = agentTaskText(a);
3894
+ const dur = formatDuration(agentElapsed(a, now));
3895
+ const labelW = Math.min(task.length * 6.4 + 48, AGENT_SPINE_LABEL_MAX);
3896
+ rowEnd[row] = xs + barW + labelW + 12;
3897
+ item.x = xs;
3898
+ item.y = rowY(row);
3899
+ const mid = item.y + AGENT_SPINE_BAR_H / 2;
3900
+ links.push(
3901
+ item.parent
3902
+ ? `<path d="M${item.parent.x + 4} ${item.parent.y + AGENT_SPINE_BAR_H - 3}V${mid}H${xs}"/>`
3903
+ : `<path d="M${x0} 8V${mid}H${xs}"/>`,
3904
+ );
3905
+ const status = agentStatus(a);
3906
+ const fill = agentColor(a, status, w, colors);
3907
+ const tip = `${agentKind(a)} · ${dur}\n${task}`;
3908
+ bars.push(
3909
+ `<button type="button" class="agent-spine-row ${escapeHtml(status)}" style="left:${xs}px;top:${item.y}px" title="${escapeHtml(tip)}" onclick="showAgentModal('${escAttrJs(a.agentId)}')"><span class="agent-spine-bar" style="width:${barW}px;background:${fill}"></span><span class="agent-spine-label">${escapeHtml(task)}</span><span class="agent-views-time">${dur}</span></button>`,
3910
+ );
3911
+ });
3912
+ dots.push(`<span class="agent-spine-dot" style="left:${x0}px"></span>`);
3913
+ if (x0 - lastTick >= 70) {
3914
+ lastTick = x0;
3915
+ ticks.push(`<span style="left:${x0}px">${w.time}</span>`);
3916
+ }
3917
+ }
3918
+ const height = rowY(rowEnd.length);
3919
+ const lineEnd = Math.max(plot, ...rowEnd);
3920
+ const cutHtml = cuts.map((c) => `<span class="agent-spine-cut" style="left:${px(c)}px">⫽</span>`).join('');
3921
+ return {
3922
+ html: `<div class="agent-spine" style="height:${height + 18}px;width:${lineEnd}px;--row-h:${AGENT_SPINE_BAR_H}px"><svg class="agent-spine-links" width="${lineEnd}" height="${height}"><path class="agent-spine-main" d="M0 8H${lineEnd}"/>${links.join('')}</svg>${cutHtml}${dots.join('')}${bars.join('')}<div class="agent-spine-axis" style="top:${height}px">${ticks.join('')}</div></div>`,
3923
+ legend: agentLegendHtml(colors),
3924
+ };
3925
+ }
3926
+
3927
+ // Live agents change durations and bar widths every second. When only time moved, the view is
3928
+ // rebuilt at most every AGENT_VIEWS_TICK_MS and never under the pointer, so hover and tooltips hold.
3929
+ const AGENT_VIEWS_TICK_MS = 5000;
3930
+
3931
+ function renderAgentViews(agents) {
3932
+ const modal = document.getElementById('agent-views-modal');
3933
+ if (!modal.classList.contains('visible')) return;
3934
+ const body = document.getElementById('agent-views-body');
3935
+ const shape = `${agentView}|${agentColorBy}|${body.clientWidth}|${agents.map((a) => `${a.agentId}:${a.status}:${a.parent || ''}`).join(',')}`;
3936
+ const now = Date.now();
3937
+ if (shape === agentViewsShape) {
3938
+ const live = agents.some((a) => agentStatus(a) !== 'stopped');
3939
+ if (!live || now - agentViewsAt < AGENT_VIEWS_TICK_MS || body.matches(':hover')) return;
3940
+ }
3941
+ agentViewsShape = shape;
3942
+ agentViewsAt = now;
3943
+ for (const b of modal.querySelectorAll('.agent-views-tabs [data-view]')) {
3944
+ b.setAttribute('aria-selected', String(b.dataset.view === agentView));
3945
+ }
3946
+ for (const b of modal.querySelectorAll('.agent-views-colors [data-color]')) {
3947
+ b.setAttribute('aria-pressed', String(b.dataset.color === agentColorBy));
3948
+ }
3949
+ const roots = agentTree(agents);
3950
+ const view = !roots.length
3951
+ ? { html: '<div class="modal-status">No agents in this view.</div>', legend: '' }
3952
+ : agentView === 'map'
3953
+ ? agentMapHtml(roots, now)
3954
+ : agentSpineHtml(roots, now, body.clientWidth - 18);
3955
+ body.innerHTML = view.html;
3956
+ document.getElementById('agent-views-legend').innerHTML = view.legend;
3957
+ }
3958
+
3959
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
3960
+ function showAgentViews() {
3961
+ agentView = store.getItem(AGENT_VIEW_KEY) === 'map' ? 'map' : 'timeline';
3962
+ const colorBy = store.getItem(AGENT_COLOR_KEY);
3963
+ agentColorBy = AGENT_COLOR_MODES.includes(colorBy) ? colorBy : 'wave';
3964
+ agentViewsShape = '';
3965
+ document.getElementById('agent-views-modal').classList.add('visible');
3966
+ renderAgentViews(visibleAgents());
3967
+ }
3968
+
3969
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
3970
+ function setAgentView(view) {
3971
+ agentView = view;
3972
+ store.setItem(AGENT_VIEW_KEY, view);
3973
+ renderAgentViews(visibleAgents());
3974
+ }
3975
+
3976
+ function closeAgentViews() {
3977
+ hideModalOverlay('agent-views-modal');
3978
+ }
3979
+
3616
3980
  function boardInSplit() {
3617
3981
  const board = document.getElementById('board-side');
3618
3982
  return board.classList.contains('side-l') || board.classList.contains('side-r');
@@ -3627,7 +3991,6 @@ function applyAgentFooterCollapsed() {
3627
3991
  const saved = store.getItem(agentFooterCollapseKey());
3628
3992
  const collapsed = saved === null ? boardInSplit() : saved === 'true';
3629
3993
  document.getElementById('agent-footer').classList.toggle('collapsed', collapsed);
3630
- document.getElementById('agent-footer-toggle').innerHTML = collapsed ? '&#x25B4;' : '&#x25BE;';
3631
3994
  }
3632
3995
 
3633
3996
  let _agentModalPromptText = null;
@@ -3821,7 +4184,10 @@ function showNoSession() {
3821
4184
  // Filter pipeline: active filter → force-include revealed/current (non-pinned) sessions →
3822
4185
  // project filter → search filter → ensure pinned/sticky sessions are always included.
3823
4186
  // Pure over module state, so the session picker can ask for the same list without a render.
3824
- function getFilteredSessions() {
4187
+ // Zen on a group or project drops the project filter and the search: its scope replaces both.
4188
+ function getFilteredSessions({ zen = false } = {}) {
4189
+ const project = zen ? null : filterProject;
4190
+ const search = zen ? '' : searchQuery;
3825
4191
  let filteredSessions = sessions;
3826
4192
  if (sessionFilter === 'active') {
3827
4193
  const activeSessionIds = new Set();
@@ -3851,7 +4217,7 @@ function getFilteredSessions() {
3851
4217
  }
3852
4218
  }
3853
4219
  }
3854
- if (filterProject) {
4220
+ if (project) {
3855
4221
  // The open session keeps its row even when it belongs to another project, so that
3856
4222
  // revealing one by id has something to scroll to. Same exemption the active branch
3857
4223
  // above already makes, for the same reason. recentProjects lags behind the session list, so a
@@ -3861,7 +4227,7 @@ function getFilteredSessions() {
3861
4227
  (s) =>
3862
4228
  matchesProjectFilter(s.project, s.worktree?.repo) ||
3863
4229
  s.id === currentSessionId ||
3864
- (filterProject === '__recent__' && (isAnyPinned(s.id) || Date.parse(s.modifiedAt) >= recentCutoff)),
4230
+ (project === '__recent__' && (isAnyPinned(s.id) || Date.parse(s.modifiedAt) >= recentCutoff)),
3865
4231
  );
3866
4232
  }
3867
4233
 
@@ -3872,22 +4238,22 @@ function getFilteredSessions() {
3872
4238
  }
3873
4239
  }
3874
4240
 
3875
- if (searchQuery) {
4241
+ if (search) {
3876
4242
  const taskMatchIds = new Set();
3877
4243
  for (const t of allTasksCache) {
3878
4244
  if (
3879
- (t.subject && fuzzyMatch(t.subject, searchQuery)) ||
3880
- (t.description && fuzzyMatch(t.description, searchQuery)) ||
3881
- (t.activeForm && fuzzyMatch(t.activeForm, searchQuery))
4245
+ (t.subject && fuzzyMatch(t.subject, search)) ||
4246
+ (t.description && fuzzyMatch(t.description, search)) ||
4247
+ (t.activeForm && fuzzyMatch(t.activeForm, search))
3882
4248
  )
3883
4249
  taskMatchIds.add(t.sessionId);
3884
4250
  }
3885
- const groupMatchIds = sgSearchMatchIds(searchQuery);
4251
+ const groupMatchIds = sgSearchMatchIds(search);
3886
4252
  const matchesSearch = (s) =>
3887
- (s.name && fuzzyMatch(s.name, searchQuery)) ||
3888
- (s.id && fuzzyMatch(s.id, searchQuery)) ||
3889
- (s.project && fuzzyMatch(s.project, searchQuery)) ||
3890
- (s.description && fuzzyMatch(s.description, searchQuery)) ||
4253
+ (s.name && fuzzyMatch(s.name, search)) ||
4254
+ (s.id && fuzzyMatch(s.id, search)) ||
4255
+ (s.project && fuzzyMatch(s.project, search)) ||
4256
+ (s.description && fuzzyMatch(s.description, search)) ||
3891
4257
  taskMatchIds.has(s.id) ||
3892
4258
  groupMatchIds.has(s.id);
3893
4259
 
@@ -3910,7 +4276,7 @@ function getFilteredSessions() {
3910
4276
  if (
3911
4277
  sessionFilter === 'active' &&
3912
4278
  activityFilter.size === 0 &&
3913
- !searchQuery &&
4279
+ !search &&
3914
4280
  (pinnedSessionIds.size > 0 || stickySessionIds.size > 0)
3915
4281
  ) {
3916
4282
  const filteredIds = new Set(filteredSessions.map((s) => s.id));
@@ -3961,6 +4327,7 @@ function zenPanelIsEditing() {
3961
4327
  function renderSessions() {
3962
4328
  // Rebuilding the list under the pointer cancels an in-flight drop and would swallow a
3963
4329
  // half-typed group name, and the SSE path can fire at any moment — defer instead.
4330
+ schedulePublish();
3964
4331
  if (sgDrag || sgIsEditing() || zenPanelIsEditing()) return;
3965
4332
  scheduleJustFinishedExpiry();
3966
4333
  refreshProjectList();
@@ -3968,20 +4335,25 @@ function renderSessions() {
3968
4335
 
3969
4336
  if (zenGroup && !sgGroupById(zenGroup)) {
3970
4337
  zenGroup = null;
4338
+ zenPeekKey = null;
3971
4339
  renderZenState();
3972
4340
  }
3973
4341
  // Zen narrows the rendered list only — the session picker keeps calling getFilteredSessions()
3974
4342
  // and still offers everything, or there would be no way to switch sessions without leaving zen.
3975
- // Group zen renders only its subtree's buckets, so it takes every session unfiltered.
3976
4343
  const zenSession = zenMode && currentSessionId ? sessions.find((s) => s.id === currentSessionId) : null;
3977
4344
  sessionsList.classList.toggle('zen', !!zenSession);
3978
4345
  sessionsList.dataset.zenState = zenSession ? sessionState(zenSession) : '';
4346
+ const zenScope = !!(zenGroup || zenProject);
3979
4347
  let filteredSessions;
3980
- if (zenGroup) filteredSessions = applyStableSessionOrder(sessions);
3981
- else if (zenMode) filteredSessions = zenSession ? [zenSession] : [];
4348
+ if (zenScope) {
4349
+ const scoped = getFilteredSessions({ zen: true });
4350
+ filteredSessions = applyStableSessionOrder(
4351
+ zenProject ? scoped.filter((s) => sessionProjectKey(s) === zenProject) : scoped,
4352
+ );
4353
+ } else if (zenMode) filteredSessions = zenSession ? [zenSession] : [];
3982
4354
  else filteredSessions = applyStableSessionOrder(getFilteredSessions());
3983
4355
 
3984
- const outside = sidebarSearch.rows(zenMode || zenGroup ? '' : searchQuery, filteredSessions);
4356
+ const outside = sidebarSearch.rows(zenMode || zenScope ? '' : searchQuery, filteredSessions);
3985
4357
 
3986
4358
  const childDepth = new Map();
3987
4359
  const parentOf = new Map();
@@ -4056,7 +4428,7 @@ function renderSessions() {
4056
4428
  : '';
4057
4429
  const metricsHtml = progressHtml + (showCtx ? renderContextBar(session) : '');
4058
4430
  return `
4059
- <button onclick="openSession('${sid}')" draggable="true" data-session-id="${escapeHtml(session.id)}" class="session-item ${isActive ? 'active' : ''} ${sessionBarClass(session)} ${tempClass} ${idleClass} ${justFinishedClass}${childDepthClass(childDepth.get(session.id))}">
4431
+ <button onclick="openSession('${sid}')" draggable="true" data-hub-part="session-card" data-session-id="${escapeHtml(session.id)}" class="session-item ${isActive ? 'active' : ''} ${sessionBarClass(session)} ${tempClass} ${idleClass} ${justFinishedClass}${childDepthClass(childDepth.get(session.id))}">
4060
4432
  <span class="session-pin-btn${pinClass}" onclick="event.stopPropagation();toggleSessionPin('${sid}')" title="${pinTitle} session">${pinState === 'sticky' ? SESSION_STAR_SVG : SESSION_PIN_SVG}</span>
4061
4433
  <div class="session-name">${escapeHtml(sessionName)}</div>
4062
4434
  ${renderSessionIdentity(projectHtml, session.gitBranch)}
@@ -4110,7 +4482,7 @@ function renderSessions() {
4110
4482
  )
4111
4483
  : '';
4112
4484
 
4113
- if (filteredSessions.length === 0 && !zenGroup) {
4485
+ if (filteredSessions.length === 0 && !zenScope) {
4114
4486
  let emptyMsg = 'No sessions found';
4115
4487
  let emptyHint = 'Tasks appear when you use Claude Code';
4116
4488
 
@@ -4219,7 +4591,7 @@ function renderSessions() {
4219
4591
  .join('');
4220
4592
 
4221
4593
  return `
4222
- <div class="project-group-header${isCollapsed ? ' collapsed' : ''}${nestedCls}" draggable="true" data-group-path="${escapedPath}" data-project-path="${escapedPath}">
4594
+ <div class="project-group-header${isCollapsed ? ' collapsed' : ''}${nestedCls}${projectPath === zenProject ? ' sg-zen' : ''}" draggable="true" data-group-path="${escapedPath}" data-project-path="${escapedPath}">
4223
4595
  ${groupChevronSvg()}
4224
4596
  <span class="group-name">${escapeHtml(folderName)}</span>
4225
4597
  ${terminalAvailable() ? `<span class="project-new-btn" data-project-path="${escapedPath}" title="New session in ${escapeHtml(folderName)}">${PLUS_SVG}</span>` : ''}
@@ -4251,7 +4623,7 @@ function renderSessions() {
4251
4623
  }
4252
4624
  // A group emptied by a filter hides its header; a group the user just created (no filters)
4253
4625
  // shows its drop-here state instead of vanishing.
4254
- const sgFiltering = !zenGroup && sgListFiltered();
4626
+ const sgFiltering = zenGroup ? activityFilter.size > 0 : sgListFiltered();
4255
4627
 
4256
4628
  // A group whose parent is gone renders at the top.
4257
4629
  const sgIds = new Set(sessionGroups.map((g) => g.id));
@@ -4340,7 +4712,16 @@ function renderSessions() {
4340
4712
  }
4341
4713
 
4342
4714
  if (zenGroup) {
4343
- sessionsList.innerHTML = sgGroupHtml(sgGroupById(zenGroup), sessionFilter !== 'active');
4715
+ const group = sgGroupById(zenGroup);
4716
+ sessionsList.innerHTML =
4717
+ sgGroupHtml(group, sessionFilter !== 'active') ||
4718
+ `${sgHeaderHtml(group, countHtml([]))}<div class="sg-empty">No sessions match the filters</div>`;
4719
+ } else if (zenProject) {
4720
+ sessionsList.innerHTML =
4721
+ projectBlock(zenProject, filteredSessions, false) +
4722
+ (filteredSessions.length || sessionFilter !== 'active'
4723
+ ? ''
4724
+ : '<div class="sg-empty">No active sessions. Select "All Sessions" to see all</div>');
4344
4725
  } else if (sessionFilter === 'active') {
4345
4726
  // Group active sessions by project
4346
4727
  // Auto-expand a collapsed section when newly-active work lands in it (live refresh).
@@ -4574,6 +4955,7 @@ function renderTaskCard(task) {
4574
4955
  <div
4575
4956
  role="listitem"
4576
4957
  tabindex="0"
4958
+ data-hub-part="task-card"
4577
4959
  data-task-id="${escapeHtml(task.id)}"
4578
4960
  data-session-id="${escapeHtml(actualSessionId)}"
4579
4961
  onclick="showTaskDetail('${escAttrJs(task.id)}', '${escAttrJs(actualSessionId)}')"
@@ -4583,7 +4965,7 @@ function renderTaskCard(task) {
4583
4965
  class="task-card ${statusClass} ${isBlocked ? 'blocked' : ''} ${isDim ? 'dim' : ''}"
4584
4966
  aria-label="${escapeHtml(task.subject)} — ${escapeHtml(state)}">
4585
4967
  <div class="task-id">
4586
- <span>#${taskId}</span>
4968
+ <span data-hub-part="task-number">#${taskId}</span>
4587
4969
  ${renderTaskChips(chips)}
4588
4970
  ${isBlocked ? `<span class="task-blocked" title="Blocked">waiting on ${blockers.map((id) => `#${escapeHtml(id)}`).join(' ')}</span>` : ''}
4589
4971
  ${task.owner ? renderOwnerBadge(task) : ''}
@@ -4598,50 +4980,6 @@ function renderTaskCard(task) {
4598
4980
  //#endregion
4599
4981
 
4600
4982
  //#region KANBAN
4601
- // FLIP pass around renderKanban's innerHTML rebuild (#41): the rebuild lands cards at
4602
- // their final spot instantly, so a status change reads as a full-board reload. Recording
4603
- // where each card was and animating from there makes a move glide instead.
4604
- const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
4605
-
4606
- function cardFlipKey(el) {
4607
- return `${el.dataset.sessionId}|${el.dataset.taskId}`;
4608
- }
4609
-
4610
- function captureCardRects() {
4611
- const rects = new Map();
4612
- for (const el of document.querySelectorAll('.column-tasks .task-card')) {
4613
- rects.set(cardFlipKey(el), el.getBoundingClientRect());
4614
- }
4615
- return rects;
4616
- }
4617
-
4618
- function playCardFlip(before) {
4619
- // An empty board before the render means a view switch, not a move — nothing to glide.
4620
- if (reducedMotion.matches || before.size === 0) return;
4621
- for (const el of document.querySelectorAll('.column-tasks .task-card')) {
4622
- const prev = before.get(cardFlipKey(el));
4623
- if (!prev) {
4624
- el.animate(
4625
- [
4626
- { opacity: 0, transform: 'scale(0.97)' },
4627
- { opacity: 1, transform: 'none' },
4628
- ],
4629
- { duration: 150, easing: 'ease-out' },
4630
- );
4631
- continue;
4632
- }
4633
- const now = el.getBoundingClientRect();
4634
- const dx = prev.left - now.left;
4635
- const dy = prev.top - now.top;
4636
- if (dx || dy) {
4637
- el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], {
4638
- duration: 220,
4639
- easing: 'cubic-bezier(0.2, 0.7, 0.3, 1)',
4640
- });
4641
- }
4642
- }
4643
- }
4644
-
4645
4983
  // Rewrite a column only when its markup actually changed: SSE ticks fire on any task-file
4646
4984
  // write (updatedAt bumps, agent refreshes), and an unconditional innerHTML rebuild makes
4647
4985
  // the whole board blink for updates with nothing visible in them (#41).
@@ -4667,41 +5005,33 @@ function renderKanban() {
4667
5005
  const emptyIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/></svg>`;
4668
5006
  const plusIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 5v14M5 12h14"/></svg>`;
4669
5007
 
4670
- const writes = [];
4671
5008
  // Adding is a live text input inside the column, so a background refresh would blow it
4672
5009
  // away mid-typing -- leave the column alone until the input is gone.
4673
5010
  if (!addingTask) {
4674
5011
  const addTile = canAddTask()
4675
5012
  ? `<button type="button" class="column-add${pending.length ? '' : ' empty'}" onclick="startAddTask(this, event)" title="Ctrl+Click opens the dialog with a description. You can also ask the agent to add tasks with its TaskCreate tool. Make sure CLAUDE_CODE_ENABLE_TASKS is set in its environment.">${plusIcon}<span>Add task</span></button>`
4676
5013
  : '';
4677
- writes.push([
5014
+ setColumnHtml(
4678
5015
  pendingTasks,
4679
5016
  pending.length > 0
4680
5017
  ? pending.map(renderTaskCard).join('') + addTile
4681
5018
  : addTile || `<div class="column-empty">${emptyIcon}<div>No pending tasks</div></div>`,
4682
- ]);
5019
+ );
4683
5020
  }
4684
5021
 
4685
- writes.push([
5022
+ setColumnHtml(
4686
5023
  inProgressTasks,
4687
5024
  inProgress.length > 0
4688
5025
  ? inProgress.map(renderTaskCard).join('')
4689
5026
  : `<div class="column-empty">${emptyIcon}<div>No active tasks</div></div>`,
4690
- ]);
5027
+ );
4691
5028
 
4692
- writes.push([
5029
+ setColumnHtml(
4693
5030
  completedTasks,
4694
5031
  completed.length > 0
4695
5032
  ? completed.map(renderTaskCard).join('')
4696
5033
  : `<div class="column-empty">${emptyIcon}<div>No completed tasks</div></div>`,
4697
- ]);
4698
-
4699
- // Capture rects (a forced layout read per card) only when a column will
4700
- // actually be rewritten — most SSE ticks change nothing and skip the FLIP.
4701
- const willChange = writes.some(([el, html]) => el._lastHtml !== html);
4702
- const flipRects = willChange ? captureCardRects() : null;
4703
- for (const [el, html] of writes) setColumnHtml(el, html);
4704
- if (flipRects) playCardFlip(flipRects);
5034
+ );
4705
5035
 
4706
5036
  if (selectedTaskId) {
4707
5037
  const card =
@@ -5268,6 +5598,24 @@ function computeChildAnchors(list) {
5268
5598
  return out;
5269
5599
  }
5270
5600
 
5601
+ function setDispatchChild(id, child) {
5602
+ const s = sessions.find((x) => x.id === id);
5603
+ if (!s?.dispatched || !!s.dispatched.child === child) return;
5604
+ s.dispatched = { ...s.dispatched, child };
5605
+ if (child && sgGroupOf('session', id)) {
5606
+ sgDetach('session', id);
5607
+ persistSessionGroups();
5608
+ }
5609
+ api(`/api/dispatch/${encodeURIComponent(id)}/child`, { method: 'POST', body: { child } })
5610
+ .then(async (res) => {
5611
+ if (res.ok) return;
5612
+ const data = await res.json().catch(() => null);
5613
+ showToast(`Not saved (${data?.error || res.status})`, 'error');
5614
+ fetchSessions(false).catch(() => {});
5615
+ })
5616
+ .catch(() => showToast('Not saved: the server is unreachable', 'error'));
5617
+ }
5618
+
5271
5619
  function sgListFiltered() {
5272
5620
  return !!searchQuery || activityFilter.size > 0 || (!!filterProject && filterProject !== '__recent__');
5273
5621
  }
@@ -5277,7 +5625,7 @@ function sgListFiltered() {
5277
5625
  // terminal or placeholder counts. Only the full Active list can tell, so other views keep them.
5278
5626
  function sgSweepTransient() {
5279
5627
  if (sgRev === null || !sessionGroups.some((g) => g.transient)) return;
5280
- if (zenGroup || zenMode || sessionFilter !== 'active' || sessionsHasMore || sgListFiltered()) return;
5628
+ if (zenGroup || zenProject || zenMode || sessionFilter !== 'active' || sessionsHasMore || sgListFiltered()) return;
5281
5629
  const shown = new Set(getFilteredSessions().map((s) => s.id));
5282
5630
  const starting = (id) => !dismissedSessionIds.has(id) && (runningTerminals.has(id) || dispatchSpecs.has(id));
5283
5631
  const present = (m) => m.type !== 'session' || shown.has(m.ref) || starting(m.ref);
@@ -5612,7 +5960,9 @@ function sgGroupDropZone(target) {
5612
5960
  : null;
5613
5961
  }
5614
5962
  const dragSession = sgDrag.kind === 'session' ? sessions.find((x) => x.id === sgDrag.ref) : null;
5615
- if (zone.classList.contains('sg-ungroup-zone')) return dragGroup ? { zone } : null;
5963
+ const anchored = !!dragSession && childAnchors.has(dragSession.id);
5964
+ if (zone.classList.contains('sg-ungroup-zone'))
5965
+ return dragGroup ? { zone } : anchored ? { zone, unnest: true } : null;
5616
5966
  const fromGroup = dragSession ? sgGroupForSession(dragSession) : dragGroup;
5617
5967
  const fromGroupId = fromGroup?.id || null;
5618
5968
  // A drop that lands on the host the session already has changes nothing, and highlighting it
@@ -5629,6 +5979,7 @@ function sgGroupDropZone(target) {
5629
5979
  const targetSessionId = zone.dataset.sessionId;
5630
5980
  if (targetSessionId) {
5631
5981
  if (targetSessionId === sgDrag.ref) return null;
5982
+ if (dragSession?.dispatched?.parent === targetSessionId) return anchored ? null : { zone, nest: true };
5632
5983
  const targetSession = sessions.find((s) => s.id === targetSessionId);
5633
5984
  const targetGroup = targetSession ? sgGroupForSession(targetSession) : null;
5634
5985
  const targetGroupId = targetGroup?.id || null;
@@ -5649,6 +6000,7 @@ function sgGroupDropZone(target) {
5649
6000
  }
5650
6001
  const path = zone.dataset.projectPath;
5651
6002
  if (!path || path === sgDrag.ref) return null;
6003
+ if (anchored && sessionProjectKey(dragSession) === path) return { zone, unnest: true };
5652
6004
  // Dropping onto a project that already sits in a group means "join that group".
5653
6005
  const pathGroup = sgGroupOf('project', path);
5654
6006
  if (pathGroup) {
@@ -5660,7 +6012,7 @@ function sgGroupDropZone(target) {
5660
6012
  return fromHost === path && fromGroupId === pathGroup.id ? null : { zone, groupId: pathGroup.id, under: path };
5661
6013
  }
5662
6014
  // Stacking a session onto its own project block would only fold it back where it sits today.
5663
- if (dragSession && sessionProjectKey(dragSession) === path) return releasable ? { zone } : null;
6015
+ if (dragSession && sessionProjectKey(dragSession) === path) return null;
5664
6016
  return { zone, pairWith: path };
5665
6017
  }
5666
6018
 
@@ -5709,6 +6061,18 @@ function sgOnDrop(e) {
5709
6061
  sgFinishDrag();
5710
6062
  return;
5711
6063
  }
6064
+ if (hit.nest) {
6065
+ setDispatchChild(drag.ref, true);
6066
+ sgFinishDrag();
6067
+ return;
6068
+ }
6069
+ // Any other move takes a `--child` session out of its starter's place for good, so it stays
6070
+ // where it was put after it leaves a group.
6071
+ if (drag.kind === 'session') setDispatchChild(drag.ref, false);
6072
+ if (hit.unnest) {
6073
+ sgFinishDrag();
6074
+ return;
6075
+ }
5712
6076
  if (hit.pairWith || hit.pairSession) {
5713
6077
  // Stacked onto an ungrouped item: seed a group, then let the user name it in place.
5714
6078
  const target = hit.pairWith
@@ -5884,7 +6248,12 @@ function sgOpenMenu(x, y, kind, ref) {
5884
6248
  menu.setAttribute('role', 'menu');
5885
6249
  const canFork = kind === 'session' && !!forkableSession(ref);
5886
6250
  const canEnd = kind === 'session' && runningTerminals.has(ref);
6251
+ const marker = kind === 'session' ? sessions.find((s) => s.id === ref)?.dispatched : null;
6252
+ const nestItem = marker?.child
6253
+ ? '<button class="sg-menu-item" role="menuitem" data-sg-action="unnest">Unnest</button>'
6254
+ : '';
5887
6255
  const actions =
6256
+ nestItem +
5888
6257
  (canFork
5889
6258
  ? '<button class="sg-menu-item" role="menuitem" data-sg-action="fork" title="claude --resume --fork-session">Fork</button>'
5890
6259
  : '') +
@@ -5945,6 +6314,11 @@ document.addEventListener('click', (e) => {
5945
6314
  sgCloseMenu();
5946
6315
  if (item.dataset.sgAction === 'fork') return forkSession(sgRef);
5947
6316
  if (item.dataset.sgAction === 'end') return closeTerminalSession(sgRef);
6317
+ if (item.dataset.sgAction === 'unnest') {
6318
+ setDispatchChild(sgRef, false);
6319
+ return renderSessions();
6320
+ }
6321
+ if (sgKind === 'session') setDispatchChild(sgRef, false);
5948
6322
  if (move === '__none__') {
5949
6323
  sgDetach(sgKind, sgRef);
5950
6324
  persistSessionGroups();
@@ -6155,6 +6529,7 @@ function setGroupCollapsed(header, collapsed) {
6155
6529
  pinPeekKey = null;
6156
6530
  pinPeekClosedFor = currentSessionId;
6157
6531
  }
6532
+ if (projectPath === zenPeekKey) zenPeekKey = null;
6158
6533
  if (collapsed) collapsedProjectGroups.add(projectPath);
6159
6534
  else collapsedProjectGroups.delete(projectPath);
6160
6535
  header.classList.toggle('collapsed', collapsed);
@@ -6164,10 +6539,11 @@ function setGroupCollapsed(header, collapsed) {
6164
6539
  }
6165
6540
 
6166
6541
  function persistCollapsedGroups() {
6167
- store.writeJson(COLLAPSED_GROUPS_KEY, [...collapsedProjectGroups, ...(pinPeekKey ? [pinPeekKey] : [])]);
6542
+ store.writeJson(COLLAPSED_GROUPS_KEY, [...collapsedProjectGroups, ...[pinPeekKey, zenPeekKey].filter(Boolean)]);
6168
6543
  }
6169
6544
 
6170
6545
  let prevActiveSessionIds = null; // null until primed by the first onlyNew pass
6546
+ let lastListScope = null;
6171
6547
 
6172
6548
  // Expand collapsed project sections that contain active sessions; leave the rest collapsed.
6173
6549
  // onlyNew: expand only for sessions that became active since the last call, so a section the
@@ -6224,6 +6600,14 @@ function pinnedCollapseKeys(session) {
6224
6600
  // A Pinned sub-section the user collapsed opens while the open session is in it and closes once
6225
6601
  // the user leaves that session. The peek is never saved: persistCollapsedGroups writes the key back.
6226
6602
  let pinPeekKey = null;
6603
+ // The collapsed group or project that zen opened; leaving zen collapses it again, unless the user
6604
+ // toggled it meanwhile.
6605
+ let zenPeekKey = null;
6606
+
6607
+ function setZenPeek(key) {
6608
+ if (zenPeekKey) collapsedProjectGroups.add(zenPeekKey);
6609
+ zenPeekKey = key && collapsedProjectGroups.delete(key) ? key : null;
6610
+ }
6227
6611
  let pinPeekClosedFor = null;
6228
6612
 
6229
6613
  function syncPinPeek() {
@@ -6742,7 +7126,7 @@ const SHORTCUT_TABS = [
6742
7126
  {
6743
7127
  keys: ['Ctrl', 'Shift', 'Z'],
6744
7128
  combo: true,
6745
- label: 'Zen mode (current session, or the group under the cursor)',
7129
+ label: 'Zen mode (current session, or the group or project under the cursor)',
6746
7130
  },
6747
7131
  { keys: ['Ctrl', 'Shift', 'K'], combo: true, label: 'Show / hide Kanbot' },
6748
7132
  { keys: ['Ctrl', '+'], combo: true, label: 'Larger modal text' },
@@ -6780,6 +7164,7 @@ const SHORTCUT_TABS = [
6780
7164
  { keys: ['Ctrl', 'Alt', 'N'], combo: true, hubMod: true, label: 'New session' },
6781
7165
  { keys: ['Ctrl', 'Alt', 'R'], combo: true, hubMod: true, label: 'Resume session (claude -r)' },
6782
7166
  { keys: ['Ctrl', 'Alt', 'S'], combo: true, hubMod: true, label: 'Swap to previous session' },
7167
+ { keys: ['Ctrl', 'Alt', 'Shift', 'S'], combo: true, hubMod: true, label: 'Next session that needs you' },
6783
7168
  { keys: ['Shift', 'C'], combo: true, label: 'Copy session id' },
6784
7169
  { keys: ['Ctrl', 'Shift', 'C'], combo: true, label: 'Copy session name (SendMessage address)' },
6785
7170
  ],
@@ -6900,6 +7285,12 @@ function buildHelpShortcuts(groups) {
6900
7285
  for (let i = 0; i < Math.max(...sides.map(([g]) => g.rows.length)); i++) {
6901
7286
  for (const [group, side] of sides) {
6902
7287
  const row = group.rows[i];
7288
+ if (row?.say) {
7289
+ cells.push(
7290
+ `<dt class="${escapeHtml(side)}"><span class="sc-say">${escapeHtml(row.say)}</span></dt><dd class="${escapeHtml(side)}">${escapeHtml(row.label)}</dd>`,
7291
+ );
7292
+ continue;
7293
+ }
6903
7294
  const parts = row && helpKeys(row);
6904
7295
  if (!parts?.length) continue;
6905
7296
  const sep = row.combo ? '<span class="sc-plus">+</span>' : '<span class="sc-or">/</span>';
@@ -6917,10 +7308,28 @@ const helpFilter = document.getElementById('help-filter');
6917
7308
 
6918
7309
  // Hub keys do nothing outside Claude Code Hub, except the app links that the --*-url flags set.
6919
7310
  const hubRowWorks = (r) => (r.opens ? hub.can(r.opens) : hub.inHub);
7311
+ // With voice on, the hub lists the commands this app handles. A hub before SDK 1.11 has no voiceCommands.
7312
+ function voiceHelpGroup() {
7313
+ const commands = hub.voiceCommands?.() ?? [];
7314
+ if (!commands.length) return [];
7315
+ const hold = {
7316
+ keys: ['Ctrl', 'Shift', 'Space'],
7317
+ action: 'hub.voice',
7318
+ combo: true,
7319
+ label: 'Hold and say "hub", then a command',
7320
+ };
7321
+ return [{ title: 'Voice', rows: [hold, ...commands.map((c) => ({ say: `hub, ${c.say}`, label: c.help }))] }];
7322
+ }
7323
+
6920
7324
  const helpTabs = () =>
6921
7325
  SHORTCUT_TABS.map((t) =>
6922
7326
  t.hub
6923
- ? { ...t, groups: t.groups.map((g) => ({ ...g, rows: g.rows.filter(hubRowWorks) })).filter((g) => g.rows.length) }
7327
+ ? {
7328
+ ...t,
7329
+ groups: [...t.groups, ...voiceHelpGroup()]
7330
+ .map((g) => ({ ...g, rows: g.rows.filter(hubRowWorks) }))
7331
+ .filter((g) => g.rows.length),
7332
+ }
6924
7333
  : t,
6925
7334
  ).filter((t) => t.groups.length);
6926
7335
 
@@ -6930,7 +7339,9 @@ function filteredShortcutGroups(query) {
6930
7339
  .flatMap((t) => t.groups)
6931
7340
  .map((g) => ({
6932
7341
  title: g.title,
6933
- rows: g.rows.filter((r) => fuzzyMatch(`${r.label} ${helpKeys(r).join(' ')}`.replaceAll('−', '-'), query)),
7342
+ rows: g.rows.filter((r) =>
7343
+ fuzzyMatch(`${r.label} ${r.say ?? helpKeys(r).join(' ')}`.replaceAll('−', '-'), query),
7344
+ ),
6934
7345
  }))
6935
7346
  .filter((g) => g.rows.length);
6936
7347
  }
@@ -8007,6 +8418,7 @@ const MODAL_CLOSERS = {
8007
8418
  'workflow-modal': () => closeWorkflowModal(),
8008
8419
  'team-modal': () => closeTeamModal(),
8009
8420
  'agent-modal': () => closeAgentModal(),
8421
+ 'agent-views-modal': () => closeAgentViews(),
8010
8422
  'help-modal': () => closeHelpModal(),
8011
8423
  'session-picker-modal': () => closeSessionPicker(),
8012
8424
  'project-picker-modal': () => closeProjectPicker(),
@@ -11952,21 +12364,26 @@ function renderFilterState() {
11952
12364
  document.getElementById('filter-menu-btn')?.classList.toggle('has-filters', short.length > 0);
11953
12365
  }
11954
12366
 
11955
- // With the sidebar cursor on a group header, zen shows that group instead of the open session.
12367
+ // With the sidebar cursor on a group or project header, zen shows that group or project instead
12368
+ // of the open session.
11956
12369
  function toggleZenMode() {
11957
12370
  const leavingSessionZen = zenMode;
11958
12371
  if (zenMode) zenMode = false;
11959
- else if (zenGroup) zenGroup = null;
12372
+ else if (zenGroup || zenProject) zenGroup = zenProject = null;
11960
12373
  else {
11961
- zenGroup = kbSelectedGroup()?.id || null;
11962
- zenMode = !zenGroup;
12374
+ const el = focusZone === 'sidebar' && sessionsList.querySelector('.kb-selected');
12375
+ const sel = el && sgDragPayload(el);
12376
+ zenGroup = sel?.kind === 'group' ? sgGroupById(sel.ref)?.id || null : null;
12377
+ zenProject = sel?.kind === 'project' ? sel.ref : null;
12378
+ zenMode = !zenGroup && !zenProject;
11963
12379
  }
12380
+ setZenPeek(zenGroup ? sgKey(zenGroup) : zenProject);
11964
12381
  store.setItem(ZEN_KEY, String(zenMode));
11965
12382
  renderZenState();
11966
- if (zenMode || zenGroup) closeFilterMenu();
12383
+ if (zenMode) closeFilterMenu();
11967
12384
  renderSessions();
11968
- // The open session or the group's members may be outside the current server page/filter,
11969
- // and leaving group zen needs the filtered page back.
12385
+ // The open session or the scope's sessions may be outside the current server page/filter,
12386
+ // and leaving a scope needs the filtered page back.
11970
12387
  if (!leavingSessionZen) fetchSessions(false);
11971
12388
  }
11972
12389
 
@@ -11979,7 +12396,7 @@ function applyHubSettings(s) {
11979
12396
  function renderZenState() {
11980
12397
  const btn = document.getElementById('zen-mode-btn');
11981
12398
  if (!btn) return;
11982
- const on = zenMode || !!zenGroup;
12399
+ const on = zenMode || !!zenGroup || !!zenProject;
11983
12400
  btn.classList.toggle('active', on);
11984
12401
  btn.setAttribute('aria-pressed', String(on));
11985
12402
  btn.title = on ? 'Zen mode on — show all sessions (Ctrl+Shift+Z)' : 'Zen mode: current session only (Ctrl+Shift+Z)';
@@ -14170,13 +14587,19 @@ function renderPaneTabs(sid, layout, split) {
14170
14587
  panePin.innerHTML = pin;
14171
14588
  paneTabs.innerHTML = html;
14172
14589
  paneTabs.querySelector('.pane-tab.on')?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
14173
- updatePaneFades();
14590
+ updateScrollFades(paneTabs);
14591
+ }
14592
+
14593
+ function updateScrollFades(el) {
14594
+ const { scrollLeft, scrollWidth, clientWidth } = el;
14595
+ el.classList.toggle('fade-l', scrollLeft > 1);
14596
+ el.classList.toggle('fade-r', scrollLeft + clientWidth < scrollWidth - 1);
14174
14597
  }
14175
14598
 
14176
- function updatePaneFades() {
14177
- const { scrollLeft, scrollWidth, clientWidth } = paneTabs;
14178
- paneTabs.classList.toggle('fade-l', scrollLeft > 1);
14179
- paneTabs.classList.toggle('fade-r', scrollLeft + clientWidth < scrollWidth - 1);
14599
+ function watchScrollFades(el) {
14600
+ const update = () => updateScrollFades(el);
14601
+ el.addEventListener('scroll', update, { passive: true });
14602
+ new ResizeObserver(update).observe(el);
14180
14603
  }
14181
14604
 
14182
14605
  // A URL pane's page is on another origin, so its key presses never reach the board: the zoom
@@ -15411,7 +15834,8 @@ paneViews.addEventListener('click', (e) => {
15411
15834
  if (zoom) adjustModalZoom(Number(zoom.dataset.paneZoom));
15412
15835
  });
15413
15836
  bindPreviewRelativeLinks(paneViews, (a) => a.closest('.pane-doc')?.dataset.path);
15414
- paneTabs.addEventListener('scroll', updatePaneFades, { passive: true });
15837
+ watchScrollFades(paneTabs);
15838
+ watchScrollFades(document.getElementById('agent-footer-content'));
15415
15839
  paneTabs.addEventListener(
15416
15840
  'wheel',
15417
15841
  (e) => {
@@ -15422,7 +15846,6 @@ paneTabs.addEventListener(
15422
15846
  },
15423
15847
  { passive: false },
15424
15848
  );
15425
- new ResizeObserver(updatePaneFades).observe(paneTabs);
15426
15849
  document.getElementById('pane-add').addEventListener('click', openPanePop);
15427
15850
  paneSplitBtn.addEventListener('click', togglePaneSplit);
15428
15851
  document.getElementById('pane-reload').addEventListener('click', () => reloadPane());
@@ -15597,6 +16020,7 @@ function inPageField(e) {
15597
16020
  function terminalShortcut(e, probe = false) {
15598
16021
  const ctrlAlt = hubModDown(e);
15599
16022
  const ctrlShift = e.ctrlKey && e.shiftKey && !e.altKey && !e.metaKey;
16023
+ const ctrlAltShift = e.ctrlKey && e.altKey && e.shiftKey && !e.metaKey && !e.getModifierState?.('AltGraph');
15600
16024
  // Ctrl+_ is Claude Code's undo, so the zoom keys leave it to the terminal. An open ask card,
15601
16025
  // which sits in the terminal pane, takes them for its own text zoom.
15602
16026
  const zoom = e.key === '_' ? undefined : zoomDelta(e);
@@ -15604,6 +16028,7 @@ function terminalShortcut(e, probe = false) {
15604
16028
  return () => adjustTerminalFontSize(Math.sign(zoom));
15605
16029
  }
15606
16030
  if (ctrlAlt && e.code === 'KeyS') return swapToPreviousSession;
16031
+ if (ctrlAltShift && e.code === 'KeyS') return nextNeedsYou;
15607
16032
  if (matchKey(e, 'KeyR') && terminalConnectSlow() && wantsTerminal() && !inPageField(e)) return reconnectTerminal;
15608
16033
  // Cancelling the default also stops Chrome's system print dialog, which this page has no use for.
15609
16034
  if (ctrlShift && e.code === 'KeyP') return toggleSessionPicker;
@@ -16628,7 +17053,7 @@ async function endAllTerminals() {
16628
17053
  // The board's own assistant (docs/kanbot.md): a claude session the server keeps hidden from the list,
16629
17054
  // shown in a popover through a second terminal frame on the board terminal's frame origin.
16630
17055
  const KANBOT_SVG =
16631
- '<svg viewBox="0 0 16 13" width="16" height="13" shape-rendering="crispEdges" aria-hidden="true">' +
17056
+ '<svg data-hub-part="kanbot" viewBox="0 0 16 13" width="16" height="13" shape-rendering="crispEdges" aria-hidden="true">' +
16632
17057
  '<path fill="#d97757" d="M3 0h10v4h3v3h-3v3H3V7H0V4h3z"/>' +
16633
17058
  '<path fill="#d97757" d="M4 10h1v3H4zM6 10h1v3H6zM9 10h1v3H9zM11 10h1v3h-1z"/>' +
16634
17059
  '<path fill="#1f1e1d" d="M5 2h1v2H5zM10 2h1v2h-1z"/></svg>';
@@ -19412,13 +19837,16 @@ hub.handle('session.open', (p) => p.session && openSessionFromOutside(p.session)
19412
19837
  hub.handle('session.find', (p) => findSessionFromHub(p));
19413
19838
  hub.handle('session.paste', (p) => pasteFromHub(p));
19414
19839
  hub.handle('task.add', (p) => addTaskFromHub(p));
19840
+ hub.handle('session.approve', () => answerWaitingFromHub('allow'));
19841
+ hub.handle('session.deny', (p) => answerWaitingFromHub('deny', p.message));
19842
+ hub.handle('session.next', () => nextNeedsYou());
19415
19843
  hub.handle('task.live', (p) => liveTaskFromHub(p));
19416
19844
  // After pending session.live calls, so the hub's clear of words typed into the terminal lands there, not in the dialog.
19417
19845
  hub.handle('session.new', (p) => {
19418
- hubNewSession = liveChain.then(() => newSessionFromHub(p)).catch(() => {});
19846
+ hubNewSession = liveChain.then(() => newSessionFromHub(p)).catch((e) => console.error('[hub] session.new', e));
19419
19847
  });
19420
19848
  hub.handle('session.live', (p) => {
19421
- liveChain = liveChain.then(() => liveFromHub(p)).catch(() => {});
19849
+ liveChain = liveChain.then(() => liveFromHub(p)).catch((e) => console.error('[hub] session.live', e));
19422
19850
  });
19423
19851
 
19424
19852
  // Action params are strings, so flags come as "true" and `args` as claude args split on spaces
@@ -19512,17 +19940,88 @@ function findSessionFromHub({ name }) {
19512
19940
  openSessionPicker({ query: name?.trim() ?? '', ranked: ranked.length ? ranked.map((r) => r.s) : null });
19513
19941
  }
19514
19942
 
19943
+ function answerWaitingFromHub(behavior, message) {
19944
+ if (!isWaitingAnswerable()) return showToast('Nothing to answer on this session', 'info');
19945
+ if (currentWaiting.kind === 'question') {
19946
+ showWaitingDetail();
19947
+ return showToast('Pick the answer on the card', 'info');
19948
+ }
19949
+ if (behavior === 'deny') return denyWaiting(message);
19950
+ return respondWaiting({ behavior });
19951
+ }
19952
+
19953
+ function needsYouQueue() {
19954
+ const live = sessions.filter((s) => (!s.placeholder || trustWaiting.has(s.id)) && !dismissedSessionIds.has(s.id));
19955
+ return [...live.filter(isWaitingSession), ...live.filter((s) => !isWaitingSession(s) && s.unread)];
19956
+ }
19957
+
19958
+ function nextNeedsYou() {
19959
+ const queue = needsYouQueue();
19960
+ const next = queue[(queue.findIndex((s) => s.id === currentSessionId) + 1) % queue.length];
19961
+ if (!next || next.id === currentSessionId) return showToast('No other session needs you', 'info');
19962
+ if (terminalPaneFocused() || isShowCardFocused()) termState.focusNext = true;
19963
+ return revealSession(next.id);
19964
+ }
19965
+
19966
+ // voice.context tells the hub's voice help what fits now: the open session's ask as the title, and per
19967
+ // action false to hide its row or a help text. The agent footer renders every second, so the ask is
19968
+ // parsed once per marker.
19969
+ let publishedVoiceContext = '';
19970
+ let askTitle = { id: null, title: null };
19971
+
19972
+ function waitingTitle() {
19973
+ if (!isWaitingAnswerable() || currentWaiting.kind === 'question') return null;
19974
+ if (askTitle.id === currentWaiting.id) return askTitle.title;
19975
+ const tool = currentWaiting.toolName || 'unknown';
19976
+ const detail = deriveWaitingDetail(tool, parseWaitingInput());
19977
+ const title = isPlanAsk(currentWaiting.kind, tool)
19978
+ ? detail || getWaitingPill(currentWaiting.kind, tool)
19979
+ : `${tool} ${detail}`.trim();
19980
+ askTitle = { id: currentWaiting.id, title };
19981
+ return title;
19982
+ }
19983
+
19984
+ function publishVoiceContext() {
19985
+ const title = waitingTitle();
19986
+ const answerable = !!title;
19987
+ const others = needsYouQueue().filter((s) => s.id !== currentSessionId).length;
19988
+ const payload = {
19989
+ title,
19990
+ rows: {
19991
+ 'session.approve': answerable,
19992
+ 'session.deny': answerable,
19993
+ 'session.next': others > 0 && `${others} more ${others === 1 ? 'needs' : 'need'} you`,
19994
+ },
19995
+ };
19996
+ const json = JSON.stringify(payload);
19997
+ if (json === publishedVoiceContext) return;
19998
+ publishedVoiceContext = json;
19999
+ hub.publish('voice.context', payload);
20000
+ }
20001
+
19515
20002
  // Voice while the New session dialog is open is dictation into its prompt; Enter on Start sends it.
19516
20003
  function voiceIntoNewSession(text) {
19517
- promptInserter()(text.trim());
20004
+ fieldInserter(document.getElementById('ns-prompt'))(text.trim());
19518
20005
  if (ns.folder) document.getElementById('ns-start').focus();
19519
20006
  }
19520
20007
 
19521
- // The hub's voice control sends dictated text here; with no session named, it goes to the one on screen.
20008
+ // The hub's voice control sends dictated text here; with no session named, it goes to the one on screen,
20009
+ // else to the open session when its terminal runs behind the board or a pane.
19522
20010
  const newSessionOpen = () => document.getElementById('new-session-modal').classList.contains('visible');
19523
- const hubTargetSession = (session) => session || (viewMode === 'session' && termState.shown && termState.sessionId);
20011
+ const hubTargetSession = (session) =>
20012
+ session ||
20013
+ (viewMode === 'session' &&
20014
+ (termState.shown ? termState.sessionId : runningTerminals.has(currentSessionId) && currentSessionId));
19524
20015
  const noSessionToast = (text) =>
19525
20016
  showToast('No session on screen', 'info', { label: 'Copy', onClick: () => copyText(text, 'text') }, text);
20017
+ function typedInBackgroundToast(id) {
20018
+ if (termState.shown && termState.sessionId === id) return;
20019
+ const s = sessions.find((x) => x.id === id);
20020
+ showToast(`Typed into ${s ? sessionDisplayName(s) : id.slice(0, 8)}`, 'success', {
20021
+ label: 'Show',
20022
+ onClick: () => showSessionTerminal(id),
20023
+ });
20024
+ }
19526
20025
 
19527
20026
  async function pasteFromHub({ session, text, submit }) {
19528
20027
  if (!text) return;
@@ -19533,7 +20032,8 @@ async function pasteFromHub({ session, text, submit }) {
19533
20032
  text,
19534
20033
  submit: submit === 'true',
19535
20034
  });
19536
- if (!res.ok) showToast((await res.json().catch(() => ({}))).error || `Paste failed (${res.status})`, 'error');
20035
+ if (res.ok) typedInBackgroundToast(id);
20036
+ else showToast((await res.json().catch(() => ({}))).error || `Paste failed (${res.status})`, 'error');
19537
20037
  }
19538
20038
 
19539
20039
  // session.live: one key hold sends the words so far many times, then once with final. Calls run in
@@ -19560,9 +20060,9 @@ async function liveFromHub({ session, text, final, submit, cancel }) {
19560
20060
  const hold = liveText;
19561
20061
  if (done) liveText = { insert: null, typed: '', at: 0 };
19562
20062
  if (!session && newSessionOpen()) {
19563
- hold.insert ??= promptInserter();
19564
- hold.insert(text.trim());
19565
20063
  const prompt = document.getElementById('ns-prompt');
20064
+ hold.insert ??= fieldInserter(prompt);
20065
+ hold.insert(text.trim());
19566
20066
  prompt.scrollTop = prompt.scrollHeight;
19567
20067
  setNewSessionVoice(!done);
19568
20068
  if (cancel === 'close') closeNewSession();
@@ -19579,18 +20079,24 @@ async function liveFromHub({ session, text, final, submit, cancel }) {
19579
20079
  text,
19580
20080
  submit: done && submit === 'true',
19581
20081
  });
19582
- if (res.ok) hold.typed = text;
19583
- else if (done) showToast((await res.json().catch(() => ({}))).error || `Typing failed (${res.status})`, 'error');
20082
+ if (res.ok) {
20083
+ hold.typed = text;
20084
+ if (done && text) typedInBackgroundToast(id);
20085
+ } else if (done) showToast((await res.json().catch(() => ({}))).error || `Typing failed (${res.status})`, 'error');
19584
20086
  }
19585
20087
 
19586
20088
  // session.changed goes out once the switch settles, so arrowing through the list sends one event.
20089
+ // voice.context shares the timer; each publisher skips a payload it already sent.
19587
20090
  let publishTimer = 0;
19588
20091
  let publishedSessionId;
19589
20092
  let cliOpenedId = null;
19590
20093
 
19591
- function schedulePublishSession() {
20094
+ function schedulePublish() {
19592
20095
  clearTimeout(publishTimer);
19593
- publishTimer = setTimeout(publishSession, 150);
20096
+ publishTimer = setTimeout(() => {
20097
+ publishSession();
20098
+ publishVoiceContext();
20099
+ }, 150);
19594
20100
  }
19595
20101
 
19596
20102
  function publishSession() {
@@ -19685,3 +20191,22 @@ hub.subscribe('project.changed', (p) => {
19685
20191
  filterByProject(dirPath);
19686
20192
  });
19687
20193
  // #endregion HUB_INTEGRATION
20194
+
20195
+ // #region MOD_SURFACE
20196
+ // Hub mods change the board through the names in mod-surface.json (docs/hub-contract.md, Mods).
20197
+ // With no mod installed, or an older hub's SDK that has no ClaudeHub.mod, the renders stay unwrapped.
20198
+ if (ClaudeHub.mod?.list.length) {
20199
+ for (const [name, event] of [
20200
+ ['renderSessions', 'sessions.rendered'],
20201
+ ['renderKanban', 'board.rendered'],
20202
+ ['renderActivityChip', 'activity.rendered'],
20203
+ ]) {
20204
+ const render = window[name];
20205
+ window[name] = function emitAfterRender(...args) {
20206
+ const out = render.apply(this, args);
20207
+ ClaudeHub.mod.emit(event, out);
20208
+ return out;
20209
+ };
20210
+ }
20211
+ }
20212
+ // #endregion MOD_SURFACE