claude-code-kanban 7.26.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/lib/parsers.js +65 -7
- package/lib/retention.js +10 -1
- package/lib/show.js +89 -51
- package/package.json +1 -1
- package/public/app.js +419 -24
- package/public/index.html +33 -1
- package/public/style.css +356 -21
- package/server.js +41 -6
package/public/app.js
CHANGED
|
@@ -832,6 +832,8 @@ async function fetchTasks(sessionId) {
|
|
|
832
832
|
//#region TIMINGS
|
|
833
833
|
const WAITING_TTL_MS = 30 * 60 * 1000;
|
|
834
834
|
const AGENT_LOG_MAX = 8;
|
|
835
|
+
const AGENT_LOG_PAGE = 24;
|
|
836
|
+
let agentLogLimit = AGENT_LOG_PAGE;
|
|
835
837
|
const ZEN_AGENTS_MAX = 5;
|
|
836
838
|
const LIVE_INDICATOR_MS = 10 * 1000;
|
|
837
839
|
const JUST_NOW_MS = 60 * 1000;
|
|
@@ -3467,7 +3469,7 @@ function agentTaskText(a) {
|
|
|
3467
3469
|
function agentElapsed(a, now) {
|
|
3468
3470
|
return a.status === 'stopped' && a.stoppedAt
|
|
3469
3471
|
? new Date(a.stoppedAt).getTime() - new Date(a.startedAt || a.stoppedAt).getTime()
|
|
3470
|
-
: now -
|
|
3472
|
+
: now - agentStart(a);
|
|
3471
3473
|
}
|
|
3472
3474
|
|
|
3473
3475
|
function agentIdentHtml(a) {
|
|
@@ -3555,7 +3557,10 @@ function renderAgentFooter() {
|
|
|
3555
3557
|
const now = Date.now();
|
|
3556
3558
|
const agents = visibleAgents();
|
|
3557
3559
|
renderZenAgents(agents);
|
|
3558
|
-
|
|
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;
|
|
3559
3564
|
|
|
3560
3565
|
const permFresh = isWaitingFresh();
|
|
3561
3566
|
|
|
@@ -3569,7 +3574,8 @@ function renderAgentFooter() {
|
|
|
3569
3574
|
}
|
|
3570
3575
|
|
|
3571
3576
|
footer.classList.add('visible');
|
|
3572
|
-
|
|
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>` : ''}`;
|
|
3573
3579
|
|
|
3574
3580
|
const permHtml = permFresh
|
|
3575
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>`
|
|
@@ -3580,30 +3586,27 @@ function renderAgentFooter() {
|
|
|
3580
3586
|
visible
|
|
3581
3587
|
.map((a) => {
|
|
3582
3588
|
const elapsed = agentElapsed(a, now);
|
|
3583
|
-
const
|
|
3584
|
-
a.status === 'stopped'
|
|
3585
|
-
? `stopped · ${formatDuration(elapsed)}`
|
|
3586
|
-
: a.status === 'idle'
|
|
3587
|
-
? `idle · ${formatDuration(elapsed)}`
|
|
3588
|
-
: `active · ${formatDuration(elapsed)}`;
|
|
3589
|
+
const status = agentStatus(a);
|
|
3589
3590
|
const displayText = agentTaskText(a);
|
|
3590
3591
|
const taskHtml = `<div class="agent-task" title="${escapeHtml(displayText)}">${escapeHtml(displayText)}</div>`;
|
|
3591
3592
|
const agentNameVal = a.agentName || null;
|
|
3592
|
-
const nameColor = agentNameVal ? getOwnerColor(agentNameVal) : null;
|
|
3593
|
+
const nameColor = agentNameVal ? resolveNamedColor(a.color) || getOwnerColor(agentNameVal) : null;
|
|
3593
3594
|
const nameBadgeHtml = nameColor
|
|
3594
3595
|
? `<span class="task-owner-badge task-owner-badge--compact" style="background:${nameColor.bg};color:${nameColor.color}">${escapeHtml(agentNameVal)}</span>`
|
|
3595
3596
|
: '';
|
|
3596
|
-
const agentColor = resolveNamedColor(a.color);
|
|
3597
|
-
const colorStyle = agentColor ? ` style="border-left:3px solid ${agentColor.color}"` : '';
|
|
3598
3597
|
const selectedClass = a.agentId === currentAgentModalId ? ' selected' : '';
|
|
3599
|
-
return `<div class="agent-card${selectedClass}" data-agent-id="${escapeHtml(a.agentId)}"
|
|
3598
|
+
return `<div class="agent-card ${status}${selectedClass}" data-agent-id="${escapeHtml(a.agentId)}" onclick="showAgentModal('${escAttrJs(a.agentId)}')">
|
|
3600
3599
|
${agentLogButton(a.agentId, 'agent-card-log-btn')}
|
|
3601
3600
|
${taskHtml}
|
|
3602
3601
|
<div class="agent-ident-row">${agentIdentHtml(a)}${nameBadgeHtml}</div>
|
|
3603
|
-
<div class="agent-status-row"><span class="agent-dot ${
|
|
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>
|
|
3604
3603
|
</div>`;
|
|
3605
3604
|
})
|
|
3606
|
-
.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);
|
|
3607
3610
|
|
|
3608
3611
|
clearInterval(agentDurationInterval);
|
|
3609
3612
|
if (visible.some((a) => a.status === 'active' || a.status === 'idle')) {
|
|
@@ -3632,6 +3635,348 @@ function toggleAgentFooter() {
|
|
|
3632
3635
|
applyAgentFooterCollapsed();
|
|
3633
3636
|
}
|
|
3634
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
|
+
|
|
3635
3980
|
function boardInSplit() {
|
|
3636
3981
|
const board = document.getElementById('board-side');
|
|
3637
3982
|
return board.classList.contains('side-l') || board.classList.contains('side-r');
|
|
@@ -3646,7 +3991,6 @@ function applyAgentFooterCollapsed() {
|
|
|
3646
3991
|
const saved = store.getItem(agentFooterCollapseKey());
|
|
3647
3992
|
const collapsed = saved === null ? boardInSplit() : saved === 'true';
|
|
3648
3993
|
document.getElementById('agent-footer').classList.toggle('collapsed', collapsed);
|
|
3649
|
-
document.getElementById('agent-footer-toggle').innerHTML = collapsed ? '▴' : '▾';
|
|
3650
3994
|
}
|
|
3651
3995
|
|
|
3652
3996
|
let _agentModalPromptText = null;
|
|
@@ -5254,6 +5598,24 @@ function computeChildAnchors(list) {
|
|
|
5254
5598
|
return out;
|
|
5255
5599
|
}
|
|
5256
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
|
+
|
|
5257
5619
|
function sgListFiltered() {
|
|
5258
5620
|
return !!searchQuery || activityFilter.size > 0 || (!!filterProject && filterProject !== '__recent__');
|
|
5259
5621
|
}
|
|
@@ -5598,7 +5960,9 @@ function sgGroupDropZone(target) {
|
|
|
5598
5960
|
: null;
|
|
5599
5961
|
}
|
|
5600
5962
|
const dragSession = sgDrag.kind === 'session' ? sessions.find((x) => x.id === sgDrag.ref) : null;
|
|
5601
|
-
|
|
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;
|
|
5602
5966
|
const fromGroup = dragSession ? sgGroupForSession(dragSession) : dragGroup;
|
|
5603
5967
|
const fromGroupId = fromGroup?.id || null;
|
|
5604
5968
|
// A drop that lands on the host the session already has changes nothing, and highlighting it
|
|
@@ -5615,6 +5979,7 @@ function sgGroupDropZone(target) {
|
|
|
5615
5979
|
const targetSessionId = zone.dataset.sessionId;
|
|
5616
5980
|
if (targetSessionId) {
|
|
5617
5981
|
if (targetSessionId === sgDrag.ref) return null;
|
|
5982
|
+
if (dragSession?.dispatched?.parent === targetSessionId) return anchored ? null : { zone, nest: true };
|
|
5618
5983
|
const targetSession = sessions.find((s) => s.id === targetSessionId);
|
|
5619
5984
|
const targetGroup = targetSession ? sgGroupForSession(targetSession) : null;
|
|
5620
5985
|
const targetGroupId = targetGroup?.id || null;
|
|
@@ -5635,6 +6000,7 @@ function sgGroupDropZone(target) {
|
|
|
5635
6000
|
}
|
|
5636
6001
|
const path = zone.dataset.projectPath;
|
|
5637
6002
|
if (!path || path === sgDrag.ref) return null;
|
|
6003
|
+
if (anchored && sessionProjectKey(dragSession) === path) return { zone, unnest: true };
|
|
5638
6004
|
// Dropping onto a project that already sits in a group means "join that group".
|
|
5639
6005
|
const pathGroup = sgGroupOf('project', path);
|
|
5640
6006
|
if (pathGroup) {
|
|
@@ -5695,6 +6061,18 @@ function sgOnDrop(e) {
|
|
|
5695
6061
|
sgFinishDrag();
|
|
5696
6062
|
return;
|
|
5697
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
|
+
}
|
|
5698
6076
|
if (hit.pairWith || hit.pairSession) {
|
|
5699
6077
|
// Stacked onto an ungrouped item: seed a group, then let the user name it in place.
|
|
5700
6078
|
const target = hit.pairWith
|
|
@@ -5870,7 +6248,12 @@ function sgOpenMenu(x, y, kind, ref) {
|
|
|
5870
6248
|
menu.setAttribute('role', 'menu');
|
|
5871
6249
|
const canFork = kind === 'session' && !!forkableSession(ref);
|
|
5872
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
|
+
: '';
|
|
5873
6255
|
const actions =
|
|
6256
|
+
nestItem +
|
|
5874
6257
|
(canFork
|
|
5875
6258
|
? '<button class="sg-menu-item" role="menuitem" data-sg-action="fork" title="claude --resume --fork-session">Fork</button>'
|
|
5876
6259
|
: '') +
|
|
@@ -5931,6 +6314,11 @@ document.addEventListener('click', (e) => {
|
|
|
5931
6314
|
sgCloseMenu();
|
|
5932
6315
|
if (item.dataset.sgAction === 'fork') return forkSession(sgRef);
|
|
5933
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);
|
|
5934
6322
|
if (move === '__none__') {
|
|
5935
6323
|
sgDetach(sgKind, sgRef);
|
|
5936
6324
|
persistSessionGroups();
|
|
@@ -8030,6 +8418,7 @@ const MODAL_CLOSERS = {
|
|
|
8030
8418
|
'workflow-modal': () => closeWorkflowModal(),
|
|
8031
8419
|
'team-modal': () => closeTeamModal(),
|
|
8032
8420
|
'agent-modal': () => closeAgentModal(),
|
|
8421
|
+
'agent-views-modal': () => closeAgentViews(),
|
|
8033
8422
|
'help-modal': () => closeHelpModal(),
|
|
8034
8423
|
'session-picker-modal': () => closeSessionPicker(),
|
|
8035
8424
|
'project-picker-modal': () => closeProjectPicker(),
|
|
@@ -14198,13 +14587,19 @@ function renderPaneTabs(sid, layout, split) {
|
|
|
14198
14587
|
panePin.innerHTML = pin;
|
|
14199
14588
|
paneTabs.innerHTML = html;
|
|
14200
14589
|
paneTabs.querySelector('.pane-tab.on')?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
14201
|
-
|
|
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);
|
|
14202
14597
|
}
|
|
14203
14598
|
|
|
14204
|
-
function
|
|
14205
|
-
const
|
|
14206
|
-
|
|
14207
|
-
|
|
14599
|
+
function watchScrollFades(el) {
|
|
14600
|
+
const update = () => updateScrollFades(el);
|
|
14601
|
+
el.addEventListener('scroll', update, { passive: true });
|
|
14602
|
+
new ResizeObserver(update).observe(el);
|
|
14208
14603
|
}
|
|
14209
14604
|
|
|
14210
14605
|
// A URL pane's page is on another origin, so its key presses never reach the board: the zoom
|
|
@@ -15439,7 +15834,8 @@ paneViews.addEventListener('click', (e) => {
|
|
|
15439
15834
|
if (zoom) adjustModalZoom(Number(zoom.dataset.paneZoom));
|
|
15440
15835
|
});
|
|
15441
15836
|
bindPreviewRelativeLinks(paneViews, (a) => a.closest('.pane-doc')?.dataset.path);
|
|
15442
|
-
paneTabs
|
|
15837
|
+
watchScrollFades(paneTabs);
|
|
15838
|
+
watchScrollFades(document.getElementById('agent-footer-content'));
|
|
15443
15839
|
paneTabs.addEventListener(
|
|
15444
15840
|
'wheel',
|
|
15445
15841
|
(e) => {
|
|
@@ -15450,7 +15846,6 @@ paneTabs.addEventListener(
|
|
|
15450
15846
|
},
|
|
15451
15847
|
{ passive: false },
|
|
15452
15848
|
);
|
|
15453
|
-
new ResizeObserver(updatePaneFades).observe(paneTabs);
|
|
15454
15849
|
document.getElementById('pane-add').addEventListener('click', openPanePop);
|
|
15455
15850
|
paneSplitBtn.addEventListener('click', togglePaneSplit);
|
|
15456
15851
|
document.getElementById('pane-reload').addEventListener('click', () => reloadPane());
|
package/public/index.html
CHANGED
|
@@ -350,7 +350,11 @@
|
|
|
350
350
|
<div id="agent-footer" class="agent-footer">
|
|
351
351
|
<div class="agent-footer-header" onclick="toggleAgentFooter()">
|
|
352
352
|
<span id="agent-footer-label">Agents</span>
|
|
353
|
-
<
|
|
353
|
+
<span class="agent-footer-actions">
|
|
354
|
+
<button class="agent-footer-expand" id="agent-footer-expand" onclick="event.stopPropagation(); toggleAgentFooterExpanded()" aria-label="Show all agents" title="Show all agents"><svg class="icon-expand" viewBox="0 0 24 24"><path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/></svg><svg class="icon-shrink" viewBox="0 0 24 24"><path d="M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"/></svg></button>
|
|
355
|
+
<button class="agent-footer-views" onclick="event.stopPropagation(); showAgentViews()" aria-label="Agents timeline and map" title="Agents timeline and map"><svg viewBox="0 0 24 24"><circle cx="5" cy="12" r="2.5"/><circle cx="19" cy="5" r="2.5"/><circle cx="19" cy="19" r="2.5"/><path d="M7.5 12h4M11.5 12V5h5M11.5 12v7h5"/></svg></button>
|
|
356
|
+
<button class="agent-footer-toggle" id="agent-footer-toggle" aria-label="Toggle agent panel"><svg class="collapse-chevron" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></svg></button>
|
|
357
|
+
</span>
|
|
354
358
|
</div>
|
|
355
359
|
<div class="agent-footer-content" id="agent-footer-content"></div>
|
|
356
360
|
</div>
|
|
@@ -706,6 +710,34 @@
|
|
|
706
710
|
</div>
|
|
707
711
|
</div>
|
|
708
712
|
|
|
713
|
+
<div id="agent-views-modal" class="modal-overlay plan-modal-overlay" onclick="closeAgentViews()">
|
|
714
|
+
<div class="modal agent-views-modal" onclick="event.stopPropagation()">
|
|
715
|
+
<div class="modal-header">
|
|
716
|
+
<div class="agent-views-head">
|
|
717
|
+
<h3 class="modal-title">Agents</h3>
|
|
718
|
+
<div class="agent-views-tabs" role="tablist">
|
|
719
|
+
<button type="button" role="tab" data-view="timeline" onclick="setAgentView('timeline')">Timeline</button>
|
|
720
|
+
<button type="button" role="tab" data-view="map" onclick="setAgentView('map')">Map</button>
|
|
721
|
+
</div>
|
|
722
|
+
<div class="agent-views-tabs agent-views-colors" role="group" aria-label="Color by">
|
|
723
|
+
<span>color</span>
|
|
724
|
+
<button type="button" data-color="type" onclick="setAgentColor('type')">type</button>
|
|
725
|
+
<button type="button" data-color="model" onclick="setAgentColor('model')">model</button>
|
|
726
|
+
<button type="button" data-color="status" onclick="setAgentColor('status')">status</button>
|
|
727
|
+
<button type="button" data-color="wave" onclick="setAgentColor('wave')">wave</button>
|
|
728
|
+
</div>
|
|
729
|
+
</div>
|
|
730
|
+
<button class="modal-close" aria-label="Close dialog" onclick="closeAgentViews()">
|
|
731
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
732
|
+
<path d="M18 6L6 18M6 6l12 12"/>
|
|
733
|
+
</svg>
|
|
734
|
+
</button>
|
|
735
|
+
</div>
|
|
736
|
+
<div id="agent-views-body" class="modal-body agent-views-body"></div>
|
|
737
|
+
<div id="agent-views-legend" class="agent-views-legend"></div>
|
|
738
|
+
</div>
|
|
739
|
+
</div>
|
|
740
|
+
|
|
709
741
|
<div id="agent-modal" class="modal-overlay plan-modal-overlay" onclick="closeAgentModal()">
|
|
710
742
|
<div class="modal plan-modal" onclick="event.stopPropagation()">
|
|
711
743
|
<div class="modal-header">
|