hive-swarm 2.0.0 → 2.1.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/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/board.css +314 -163
- package/board.html +108 -40
- package/board.js +924 -100
- package/codex.mjs +16 -5
- package/core.mjs +40 -6
- package/engine.mjs +188 -9
- package/hive-bees.js +110 -64
- package/hive-gif.js +756 -0
- package/hive-graph.js +1409 -383
- package/installer.mjs +36 -16
- package/package.json +2 -1
- package/server.mjs +43 -12
- package/skills/swarm/SKILL.md +6 -5
- package/worktrees.mjs +167 -98
package/board.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const standalone=parent===window;
|
|
6
6
|
const emptyPanel=standalone && location.pathname==='/swarm';
|
|
7
7
|
const tabs=['overview','board','members','graph'];
|
|
8
|
+
const GRAPH_MODE_KEY='hive-swarm-graph-mode';
|
|
8
9
|
const states={queued:'Queued',working:'Working',waiting:'Waiting',done:'Done',failed:'Failed',
|
|
9
10
|
quota:'Quota limit',retired:'Retired',observer:'Observer'};
|
|
10
11
|
const executionModes={subagent:'Subagent',attached:'Attached',session:'Session'};
|
|
@@ -18,12 +19,28 @@
|
|
|
18
19
|
const liveSlots=new Map();
|
|
19
20
|
const nowSlots=new Map();
|
|
20
21
|
const memberDrafts=new Map();
|
|
22
|
+
const threadOpenState=new Map();
|
|
21
23
|
let teamId=standalone&&!emptyPanel?location.pathname.split('/').at(-1):null;
|
|
22
24
|
let team,signature='',rosterKey='',feedKey='',activeTab='board',chronology=[],latestByAuthor=new Map();
|
|
23
25
|
let historyTail=0,historyRequest,refreshing=false,following=true,seen=0,feedLimit=160;
|
|
24
26
|
let recentTeams=[],teamListKey='',loadingTeams=false,channelKey='',memberKey='';
|
|
25
|
-
let stream,streamOnline=false,modelCatalog,titleEditing=false,transcript,extendingBudget=false;
|
|
27
|
+
let stream,streamOnline=false,modelCatalog,titleEditing=false,transcript,lightbox,extendingBudget=false;
|
|
26
28
|
let requestNumber=0,refreshTimer,playTimer,playing=false,cursor=null,focusedNode=null,graphFrame=0;
|
|
29
|
+
let graphMode=loadGraphMode(),exportingGif=false;
|
|
30
|
+
|
|
31
|
+
function loadGraphMode() {
|
|
32
|
+
try {
|
|
33
|
+
const saved=globalThis.sessionStorage?.getItem?.(GRAPH_MODE_KEY);
|
|
34
|
+
if (saved==='hive'||saved==='mentions') return saved;
|
|
35
|
+
} catch {}
|
|
36
|
+
return 'hive';
|
|
37
|
+
}
|
|
38
|
+
function saveGraphMode(mode) {
|
|
39
|
+
try { globalThis.sessionStorage?.setItem?.(GRAPH_MODE_KEY,mode); } catch {}
|
|
40
|
+
}
|
|
41
|
+
function currentTheme() {
|
|
42
|
+
return document.documentElement.dataset.theme==='light'?'light':'dark';
|
|
43
|
+
}
|
|
27
44
|
|
|
28
45
|
function node(tag,kind='',text) {
|
|
29
46
|
const element=document.createElement(tag);
|
|
@@ -50,6 +67,7 @@
|
|
|
50
67
|
button.setAttribute('aria-label','Jump to post #'+seq);
|
|
51
68
|
button.onclick=()=>{
|
|
52
69
|
if (transcript) closeTranscript();
|
|
70
|
+
if (lightbox) closeLightbox();
|
|
53
71
|
return jumpToPost(seq);
|
|
54
72
|
};
|
|
55
73
|
return button;
|
|
@@ -65,6 +83,38 @@
|
|
|
65
83
|
return link;
|
|
66
84
|
} catch {}
|
|
67
85
|
}
|
|
86
|
+
function safeAssetUrl(destination) {
|
|
87
|
+
const raw=String(destination??'').trim();
|
|
88
|
+
if (!raw) return '';
|
|
89
|
+
if (raw.startsWith('/')&&!raw.startsWith('//')) return raw;
|
|
90
|
+
try {
|
|
91
|
+
const url=new URL(raw,location?.origin||'http://127.0.0.1');
|
|
92
|
+
if (['http:','https:'].includes(url.protocol)&&(!location?.origin||url.origin===location.origin)) return url.href;
|
|
93
|
+
} catch {}
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
function chevronIcon() {
|
|
97
|
+
if (typeof document.createElementNS!=='function') {
|
|
98
|
+
const span=node('span','accordion-chevron','▾');
|
|
99
|
+
span.setAttribute('aria-hidden','true');
|
|
100
|
+
return span;
|
|
101
|
+
}
|
|
102
|
+
const svg=document.createElementNS('http://www.w3.org/2000/svg','svg');
|
|
103
|
+
svg.setAttribute('class','accordion-chevron');
|
|
104
|
+
svg.setAttribute('width','14');
|
|
105
|
+
svg.setAttribute('height','14');
|
|
106
|
+
svg.setAttribute('viewBox','0 0 16 16');
|
|
107
|
+
svg.setAttribute('aria-hidden','true');
|
|
108
|
+
const path=document.createElementNS('http://www.w3.org/2000/svg','path');
|
|
109
|
+
path.setAttribute('d','M4 6l4 4 4-4');
|
|
110
|
+
path.setAttribute('fill','none');
|
|
111
|
+
path.setAttribute('stroke','currentColor');
|
|
112
|
+
path.setAttribute('stroke-width','1.6');
|
|
113
|
+
path.setAttribute('stroke-linecap','round');
|
|
114
|
+
path.setAttribute('stroke-linejoin','round');
|
|
115
|
+
svg.append(path);
|
|
116
|
+
return svg;
|
|
117
|
+
}
|
|
68
118
|
function inlineText(target,value) {
|
|
69
119
|
let offset=0;
|
|
70
120
|
const tokens=/\x60([^\x60\n]+)\x60|\*\*([^\n]+?)\*\*|\*([^*\n]+)\*|\[([^\]\n]+)\]\(([^\s)]+)\)|\[(done|stall)\]|(?<![a-z0-9_])(@#?[a-z][a-z0-9_-]*|#[1-9]\d*\b)/gi;
|
|
@@ -145,12 +195,89 @@
|
|
|
145
195
|
function stamp(event) {
|
|
146
196
|
return '#'+event.seq+(event.time?' · '+time.format(new Date(event.time)):'');
|
|
147
197
|
}
|
|
198
|
+
function beeSprite(member,{muted=false}={}) {
|
|
199
|
+
return HiveBee.sprite(member.name,{
|
|
200
|
+
status:member.status??'observer',
|
|
201
|
+
coordinator:member.role==='coordinator',
|
|
202
|
+
tint:member.tint,
|
|
203
|
+
muted,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
148
206
|
function bee(member,compact=false) {
|
|
149
207
|
const tile=node('span','bee-tile'+(compact?' compact':''));
|
|
150
208
|
tile.dataset.status=member.status??'observer';
|
|
151
|
-
tile.append(
|
|
209
|
+
tile.append(beeSprite(member));
|
|
152
210
|
return tile;
|
|
153
211
|
}
|
|
212
|
+
function beeTint(member) {
|
|
213
|
+
if (typeof HiveBee?.tintStyle==='function') {
|
|
214
|
+
return HiveBee.tintStyle(member.name,member.role==='coordinator',member.tint);
|
|
215
|
+
}
|
|
216
|
+
const palette=[
|
|
217
|
+
['#efac37','#ffe18d','#bb641d'],['#75baef','#cdefff','#3974bb'],
|
|
218
|
+
['#55cbb2','#b8f8df','#268c7d'],['#e68db3','#ffcee2','#a24275'],
|
|
219
|
+
['#b3ce64','#e9f6a1','#6c9137'],['#ad9ce8','#e3d4ff','#6d58af'],
|
|
220
|
+
];
|
|
221
|
+
const [base,highlight,shade]=typeof HiveBee?.colors==='function'
|
|
222
|
+
? HiveBee.colors(member.name,member.role==='coordinator',member.tint)
|
|
223
|
+
: (member.role==='coordinator'?palette[0]:palette[1+((member.tint??0)%(palette.length-1))]);
|
|
224
|
+
return {
|
|
225
|
+
base,highlight,shade,
|
|
226
|
+
bg:'color-mix(in oklab, '+base+' 14%, var(--surface))',
|
|
227
|
+
border:'color-mix(in oklab, '+base+' 40%, var(--line))',
|
|
228
|
+
text:'var(--ink)',
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function beePill(member,{clickable=true}={}) {
|
|
232
|
+
const canJournal=standalone&&chatUrl(member.threadId);
|
|
233
|
+
const canMention=!member.external&&member.status!=='retired'&&!member.retireAfterTurn;
|
|
234
|
+
const interactive=clickable&&(canJournal||canMention);
|
|
235
|
+
const pill=node(interactive?'button':'span','bee-pill');
|
|
236
|
+
if (interactive) {
|
|
237
|
+
pill.type='button';
|
|
238
|
+
pill.setAttribute('aria-label',canJournal?'View journal for '+author(member.name):'Mention '+author(member.name));
|
|
239
|
+
pill.onclick=()=>{
|
|
240
|
+
if (canJournal) return openTranscript(member,pill);
|
|
241
|
+
return mentionMember(member.name);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const palette=beeTint(member);
|
|
245
|
+
if (pill.style?.setProperty) {
|
|
246
|
+
pill.style.setProperty('--pill-bg',palette.bg);
|
|
247
|
+
pill.style.setProperty('--pill-border',palette.border);
|
|
248
|
+
pill.style.setProperty('--pill-ink',palette.text);
|
|
249
|
+
}
|
|
250
|
+
pill.append(beeSprite(member,{muted:member.status==='retired'}),node('span','bee-pill-name',member.name));
|
|
251
|
+
return pill;
|
|
252
|
+
}
|
|
253
|
+
function smartTaskLabel(member) {
|
|
254
|
+
if (typeof graph.smartTaskLabel==='function') return graph.smartTaskLabel(member);
|
|
255
|
+
const explicit=String(member?.taskLabel??'').trim();
|
|
256
|
+
if (explicit) return explicit.slice(0,96);
|
|
257
|
+
let raw=String(member?.brief??'').trim();
|
|
258
|
+
if (!raw) return member?.name??'Task';
|
|
259
|
+
raw=raw.replace(/\[([^\]]+)\]\([^)]+\)/g,'$1')
|
|
260
|
+
.replace(/[`*_#]/g,' ')
|
|
261
|
+
.replace(/\s+/g,' ')
|
|
262
|
+
.trim();
|
|
263
|
+
const sentences=raw.split(/(?<!\d)(?<=[.!?])\s+|\r?\n/).filter(Boolean);
|
|
264
|
+
if (sentences.length>1&&/^(?:you are|act as|your role|member)\b/i.test(sentences[0])) {
|
|
265
|
+
raw=sentences.slice(1).join(' ');
|
|
266
|
+
} else {
|
|
267
|
+
raw=raw.replace(/^you are(?:\s+an?)?(?:\s+hive swarm)?(?:\s+member|\s+agent|\s+worker)?(?:\s+@?[a-z0-9_-]+)?(?:\s*\([^)]*\))?(?:\s+for\s+(?:[^.,:;]|\d\.\d)+)?[.,:;\s-]*/i,'');
|
|
268
|
+
}
|
|
269
|
+
raw=raw.replace(/^(?:your\s+(?:assignment|mission|role|task)(?:\s+in\s+[^:]+)?|you\s+own|mission|goal|objective)\s*[:—–-]?\s*/i,'');
|
|
270
|
+
raw=raw.replace(/\s+(?:in|inside|at)\s+(?:[a-z]:\\|\/)[^\s,;]+/gi,'').trim();
|
|
271
|
+
const firstSentence=raw.split(/(?<!\d)(?<=[.!?])\s+|\r?\n/)[0]?.trim()||raw;
|
|
272
|
+
let label=firstSentence.replace(/[.:;,\s]+$/,'').trim();
|
|
273
|
+
if (label.length>64) {
|
|
274
|
+
const cut=label.slice(0,64);
|
|
275
|
+
const lastSpace=cut.lastIndexOf(' ');
|
|
276
|
+
label=(lastSpace>24?cut.slice(0,lastSpace):cut).trim();
|
|
277
|
+
}
|
|
278
|
+
label=label.replace(/\s+(?:for|in|on|with|to|of|and|or|the|a|an|at|by|from)$/i,'').trim();
|
|
279
|
+
return label||(member?.name??'Task');
|
|
280
|
+
}
|
|
154
281
|
function people() {
|
|
155
282
|
const members=team.members.some(member=>member.role==='coordinator')?team.members:[
|
|
156
283
|
{name:'coordinator',role:'coordinator',status:'observer',model:team.model,effort:team.effort,
|
|
@@ -178,13 +305,16 @@
|
|
|
178
305
|
if (!value?.id || !Array.isArray(value.members)) return;
|
|
179
306
|
if (team?.id && team.id!==value.id) {
|
|
180
307
|
if (transcript) closeTranscript();
|
|
308
|
+
if (lightbox) closeLightbox();
|
|
181
309
|
posts.clear();
|
|
182
310
|
chronology=[];
|
|
183
311
|
latestByAuthor.clear();
|
|
312
|
+
threadOpenState.clear();
|
|
184
313
|
historyTail=seen=0;
|
|
185
314
|
cursor=focusedNode=null;
|
|
186
315
|
memberDrafts.clear();
|
|
187
316
|
$('overview-brief-details').open=false;
|
|
317
|
+
$('overview-tasks-accordion').open=false;
|
|
188
318
|
memberKey=channelKey=rosterKey=feedKey='';
|
|
189
319
|
}
|
|
190
320
|
team=value;
|
|
@@ -261,7 +391,7 @@
|
|
|
261
391
|
const retired=roster.length-live.length;
|
|
262
392
|
$('aside-total').textContent=retired?retired+' retired':'';
|
|
263
393
|
$('aside-total').hidden=!retired;
|
|
264
|
-
} else if (activeTab==='overview') renderOverview();
|
|
394
|
+
} else if (activeTab==='overview') renderOverview(roster);
|
|
265
395
|
else if (activeTab==='members') renderMembers(roster);
|
|
266
396
|
else scheduleGraph();
|
|
267
397
|
syncTranscript();
|
|
@@ -408,19 +538,22 @@
|
|
|
408
538
|
return '';
|
|
409
539
|
}
|
|
410
540
|
|
|
541
|
+
function openTranscript(member,opener) {
|
|
542
|
+
if (!standalone||!chatUrl(member.threadId)) return;
|
|
543
|
+
transcript={name:member.name,threadId:member.threadId,status:member.status,opener};
|
|
544
|
+
$('transcript-title').textContent='Journal · '+author(member.name);
|
|
545
|
+
$('transcript-turns').replaceChildren();
|
|
546
|
+
$('member-transcript').showModal();
|
|
547
|
+
syncTranscript();
|
|
548
|
+
return refreshTranscript();
|
|
549
|
+
}
|
|
550
|
+
|
|
411
551
|
function transcriptButton(member) {
|
|
412
552
|
if (!standalone || !chatUrl(member.threadId)) return null;
|
|
413
553
|
const button=node('button','link-button','View journal');
|
|
414
554
|
button.type='button';
|
|
415
555
|
button.setAttribute('aria-label','View journal for '+author(member.name));
|
|
416
|
-
button.onclick=()=>
|
|
417
|
-
transcript={name:member.name,threadId:member.threadId,status:member.status,opener:button};
|
|
418
|
-
$('transcript-title').textContent='Journal · '+author(member.name);
|
|
419
|
-
$('transcript-turns').replaceChildren();
|
|
420
|
-
$('member-transcript').showModal();
|
|
421
|
-
syncTranscript();
|
|
422
|
-
return refreshTranscript();
|
|
423
|
-
};
|
|
556
|
+
button.onclick=()=>openTranscript(member,button);
|
|
424
557
|
return button;
|
|
425
558
|
}
|
|
426
559
|
|
|
@@ -430,7 +563,30 @@
|
|
|
430
563
|
transcript=null;
|
|
431
564
|
previous.request?.abort();
|
|
432
565
|
$('member-transcript').close();
|
|
433
|
-
(previous.opener
|
|
566
|
+
(previous.opener?.isConnected?previous.opener:$('tab-'+activeTab)).focus({preventScroll:true});
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function openLightbox(shot,opener) {
|
|
570
|
+
const src=safeAssetUrl(shot.url);
|
|
571
|
+
if (!src) return;
|
|
572
|
+
lightbox={shot,opener};
|
|
573
|
+
$('lightbox-caption').textContent=shot.caption||'Screenshot';
|
|
574
|
+
$('lightbox-meta').textContent=[author(shot.author),shot.seq?'#'+shot.seq:''].filter(Boolean).join(' · ');
|
|
575
|
+
const img=$('lightbox-image');
|
|
576
|
+
img.src=src;
|
|
577
|
+
img.alt=shot.caption||'Screenshot';
|
|
578
|
+
const actions=$('lightbox-actions');
|
|
579
|
+
actions.replaceChildren();
|
|
580
|
+
if (shot.seq) actions.append(postReference(shot.seq));
|
|
581
|
+
$('screenshot-lightbox').showModal();
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function closeLightbox() {
|
|
585
|
+
const previous=lightbox;
|
|
586
|
+
if (!previous) return;
|
|
587
|
+
lightbox=null;
|
|
588
|
+
$('screenshot-lightbox').close();
|
|
589
|
+
(previous.opener?.isConnected?previous.opener:$('tab-'+activeTab)).focus({preventScroll:true});
|
|
434
590
|
}
|
|
435
591
|
|
|
436
592
|
function syncTranscript() {
|
|
@@ -555,19 +711,31 @@
|
|
|
555
711
|
}
|
|
556
712
|
|
|
557
713
|
function threadState(thread) {
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
714
|
+
const members=(thread.members??[]).map(name=>team.members.find(member=>member.name===name)).filter(Boolean);
|
|
715
|
+
if (members.some(member=>member.recoveryRequired||['failed','quota'].includes(member.status))) {
|
|
560
716
|
return {key:'blocked',label:'Blocked',rank:0};
|
|
561
717
|
}
|
|
562
|
-
if (
|
|
563
|
-
if (
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
718
|
+
if (members.some(member=>member.status==='working')) return {key:'active',label:'Active',rank:1};
|
|
719
|
+
if (members.some(member=>member.status==='queued')) return {key:'queued',label:'Queued',rank:2};
|
|
720
|
+
if (members.some(member=>member.status==='waiting')) return {key:'waiting',label:'Waiting',rank:3};
|
|
721
|
+
if (members.length&&members.every(member=>['done','retired'].includes(member.status))) {
|
|
566
722
|
return {key:'done',label:'Done',rank:4};
|
|
567
723
|
}
|
|
568
724
|
return {key:'queued',label:'Queued',rank:2};
|
|
569
725
|
}
|
|
570
726
|
|
|
727
|
+
function stateGlyph(member) {
|
|
728
|
+
if (member.recoveryRequired||['failed','quota'].includes(member.status)) return '!';
|
|
729
|
+
if (member.status==='done') return '✓';
|
|
730
|
+
if (member.status==='working') return '●';
|
|
731
|
+
if (member.status==='retired') return '–';
|
|
732
|
+
return '◦';
|
|
733
|
+
}
|
|
734
|
+
function stateKey(member) {
|
|
735
|
+
if (member.recoveryRequired||['failed','quota'].includes(member.status)) return 'failed';
|
|
736
|
+
return member.status??'waiting';
|
|
737
|
+
}
|
|
738
|
+
|
|
571
739
|
function attentionItems() {
|
|
572
740
|
const stopped=['stalled','budget'].includes(team.phase);
|
|
573
741
|
const issues=(team.attention??[]).filter(issue=>stopped||['recovery','quota','failed','dependency','cycle'].includes(issue.kind))
|
|
@@ -644,77 +812,183 @@
|
|
|
644
812
|
return row;
|
|
645
813
|
}
|
|
646
814
|
|
|
647
|
-
function renderOverview() {
|
|
648
|
-
const members=
|
|
649
|
-
const
|
|
815
|
+
function renderOverview(roster=people()) {
|
|
816
|
+
const members=roster.filter(member=>!member.external);
|
|
817
|
+
const allWorkers=members.filter(member=>member.role!=='coordinator');
|
|
818
|
+
const liveWorkers=allWorkers.filter(member=>member.status!=='retired');
|
|
819
|
+
const doneWorkers=liveWorkers.filter(member=>member.status==='done').length;
|
|
820
|
+
$('overview-intro').hidden=false;
|
|
650
821
|
$('overview-goal').textContent=team.title;
|
|
822
|
+
const goalLine=team.goalLine?.trim()??'';
|
|
823
|
+
$('overview-goal-line').textContent=goalLine;
|
|
824
|
+
$('overview-goal-line').hidden=!goalLine||goalLine===team.title;
|
|
651
825
|
const brief=team.task?.trim()??'';
|
|
652
826
|
const long=brief.length>180||/\n/.test(brief);
|
|
653
827
|
$('overview-brief').textContent=brief;
|
|
654
828
|
$('overview-brief').hidden=long||!brief||brief===team.title;
|
|
655
829
|
$('overview-brief-details').hidden=!long;
|
|
656
830
|
$('overview-brief-full').textContent=brief;
|
|
657
|
-
|
|
831
|
+
|
|
832
|
+
const tasksTotal=liveWorkers.length;
|
|
833
|
+
const heading=$('overview-tasks-heading');
|
|
834
|
+
heading.replaceChildren(
|
|
835
|
+
node('strong','',doneWorkers+' of '+tasksTotal),
|
|
836
|
+
document.createTextNode(' tasks done')
|
|
837
|
+
);
|
|
838
|
+
const taskIcon=$('overview-tasks-icon');
|
|
839
|
+
const hasBlocked=members.some(member=>member.recoveryRequired||['failed','quota'].includes(member.status));
|
|
840
|
+
const hasWorking=members.some(member=>member.status==='working');
|
|
841
|
+
taskIcon.textContent=tasksTotal>0&&doneWorkers===tasksTotal?'✓':hasBlocked?'!':'•';
|
|
842
|
+
taskIcon.dataset.status=tasksTotal>0&&doneWorkers===tasksTotal?'done':hasBlocked?'failed':hasWorking?'working':'waiting';
|
|
843
|
+
progressView('workers','worker-progress',doneWorkers,tasksTotal);
|
|
658
844
|
progressView('turns','turn-progress',team.turns,team.turnLimit);
|
|
845
|
+
|
|
659
846
|
liveSlots.clear();
|
|
660
847
|
nowSlots.clear();
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
right.append(status);
|
|
670
|
-
heading.append(node('strong','',author(member.name)),right);
|
|
671
|
-
row.append(heading);
|
|
848
|
+
const taskListMembers=allWorkers.length?allWorkers:members;
|
|
849
|
+
$('overview-members').replaceChildren(...taskListMembers.map(member=>{
|
|
850
|
+
const row=node('li','overview-task-row');
|
|
851
|
+
const icon=node('span','task-state-icon',stateGlyph(member));
|
|
852
|
+
icon.setAttribute('aria-hidden','true');
|
|
853
|
+
icon.dataset.status=stateKey(member);
|
|
854
|
+
const info=node('div','task-row-info');
|
|
855
|
+
info.append(node('span','task-row-title',smartTaskLabel(member)));
|
|
672
856
|
const now=node('p','now-summary',memberNow(member));
|
|
673
857
|
nowSlots.set(member.name,now);
|
|
674
|
-
|
|
858
|
+
info.append(now);
|
|
675
859
|
const latest=latestByAuthor.get(member.name);
|
|
676
860
|
const journal=transcriptButton(member);
|
|
677
861
|
if (latest||journal) {
|
|
678
862
|
const actions=node('div','overview-actions');
|
|
679
863
|
if (latest) actions.append(postReference(latest.seq));
|
|
680
864
|
if (journal) actions.append(journal);
|
|
681
|
-
|
|
865
|
+
info.append(actions);
|
|
682
866
|
}
|
|
867
|
+
const aside=node('div','task-row-aside');
|
|
868
|
+
aside.append(beePill(member));
|
|
869
|
+
row.append(icon,info,aside);
|
|
683
870
|
return row;
|
|
684
871
|
}));
|
|
872
|
+
|
|
685
873
|
const alerts=attentionItems();
|
|
686
874
|
$('overview-alerts').replaceChildren(...alerts.map(attentionRow));
|
|
687
875
|
$('overview-alerts-panel').hidden=!alerts.length;
|
|
688
|
-
|
|
876
|
+
|
|
877
|
+
const sourceThreads=team.threads?.length
|
|
878
|
+
? team.threads
|
|
879
|
+
: (taskListMembers.length?[{id:'__tasks__',title:'Tasks',goal:'',members:taskListMembers.map(member=>member.name)}]:[]);
|
|
880
|
+
const threads=sourceThreads.map(thread=>({thread,state:threadState(thread)}))
|
|
689
881
|
.sort((a,b)=>a.state.rank-b.state.rank);
|
|
690
882
|
$('overview-threads').replaceChildren(...threads.map(({thread,state})=>{
|
|
691
|
-
const
|
|
692
|
-
const
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
883
|
+
const item=node('li');
|
|
884
|
+
const card=node('details','panel thread-card');
|
|
885
|
+
const threadKey=thread.id??thread.title;
|
|
886
|
+
card.open=threadOpenState.get(threadKey)??true;
|
|
887
|
+
card.ontoggle=()=>{threadOpenState.set(threadKey,card.open);};
|
|
888
|
+
const summary=node('summary','thread-summary');
|
|
889
|
+
const left=node('span','thread-summary-left');
|
|
890
|
+
const dot=node('span','thread-dot');
|
|
891
|
+
dot.dataset.state=state.key;
|
|
892
|
+
dot.setAttribute('aria-hidden','true');
|
|
893
|
+
// Only thread title uses <strong> to keep thread heading structure clear and testable.
|
|
894
|
+
left.append(dot,node('strong','',thread.title),node('span','thread-status-text',state.label));
|
|
895
|
+
const threadMembers=(thread.members??[]).map(name=>roster.find(member=>member.name===name)??{name,status:'queued'});
|
|
896
|
+
const threadDone=threadMembers.filter(member=>['done','retired'].includes(member.status)).length;
|
|
897
|
+
const threadTotal=threadMembers.length;
|
|
898
|
+
const pct=threadTotal?Math.round(threadDone/threadTotal*100):0;
|
|
899
|
+
const right=node('span','thread-progress-wrap');
|
|
900
|
+
const bar=node('span','thread-bar');
|
|
901
|
+
bar.setAttribute('aria-hidden','true');
|
|
902
|
+
const fill=node('span','thread-bar-fill');
|
|
903
|
+
fill.dataset.state=state.key;
|
|
904
|
+
fill.style.width=pct+'%';
|
|
905
|
+
bar.append(fill);
|
|
906
|
+
const chevron=chevronIcon();
|
|
907
|
+
right.append(bar,node('span','thread-fraction mono',threadDone+'/'+threadTotal),chevron);
|
|
908
|
+
summary.append(left,right);
|
|
909
|
+
card.append(summary);
|
|
910
|
+
|
|
911
|
+
const body=node('div','thread-body');
|
|
912
|
+
if (thread.goal&&thread.goal!==thread.title) body.append(node('p','thread-goal quiet',thread.goal));
|
|
913
|
+
if (threadMembers.length) {
|
|
914
|
+
const list=node('ul','thread-task-rows');
|
|
915
|
+
list.append(...threadMembers.map(member=>{
|
|
916
|
+
const taskRow=node('li','thread-task-row');
|
|
917
|
+
const icon=node('span','task-state-icon',stateGlyph(member));
|
|
918
|
+
icon.setAttribute('aria-hidden','true');
|
|
919
|
+
icon.dataset.status=stateKey(member);
|
|
920
|
+
taskRow.append(icon,node('span','thread-task-title',smartTaskLabel(member)),beePill(member));
|
|
921
|
+
return taskRow;
|
|
922
|
+
}));
|
|
923
|
+
body.append(list);
|
|
924
|
+
}
|
|
925
|
+
card.append(body);
|
|
926
|
+
item.append(card);
|
|
927
|
+
return item;
|
|
700
928
|
}));
|
|
701
929
|
$('overview-threads-panel').hidden=!threads.length;
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
930
|
+
|
|
931
|
+
const shots=(Array.isArray(team.screenshots)?team.screenshots:[]).filter(shot=>safeAssetUrl(shot?.url));
|
|
932
|
+
$('overview-screenshots-panel').hidden=!shots.length;
|
|
933
|
+
if (shots.length) {
|
|
934
|
+
$('overview-screenshots-count').textContent=shots.length+(shots.length===1?' capture':' captures');
|
|
935
|
+
$('overview-screenshots').replaceChildren(...shots.map(shot=>{
|
|
936
|
+
const card=node('article','screenshot-card');
|
|
937
|
+
card.setAttribute('role','listitem');
|
|
938
|
+
const thumb=node('button','screenshot-thumb-btn');
|
|
939
|
+
thumb.type='button';
|
|
940
|
+
thumb.setAttribute('aria-label','Preview screenshot: '+(shot.caption||'Capture'));
|
|
941
|
+
const img=node('img');
|
|
942
|
+
img.src=safeAssetUrl(shot.url);
|
|
943
|
+
img.alt=shot.caption||'Screenshot';
|
|
944
|
+
img.loading='lazy';
|
|
945
|
+
img.decoding='async';
|
|
946
|
+
thumb.append(img,node('span','screenshot-caption',shot.caption||'Screenshot'));
|
|
947
|
+
thumb.onclick=()=>openLightbox(shot,thumb);
|
|
948
|
+
const meta=node('div','screenshot-meta');
|
|
949
|
+
const authorMember=roster.find(member=>member.name===shot.author)??{name:shot.author||'user',status:'observer'};
|
|
950
|
+
meta.append(beePill(authorMember,{clickable:false}));
|
|
951
|
+
if (shot.seq) meta.append(postReference(shot.seq));
|
|
952
|
+
card.append(thumb,meta);
|
|
953
|
+
return card;
|
|
954
|
+
}));
|
|
955
|
+
} else $('overview-screenshots').replaceChildren();
|
|
956
|
+
|
|
957
|
+
const coordMember=roster.find(member=>member.role==='coordinator')??{name:'coordinator',role:'coordinator',status:'observer'};
|
|
958
|
+
$('overview-team-badge').replaceChildren(beeSprite(coordMember));
|
|
959
|
+
const goalMode=team.coordinator===false||!team.members?.some(member=>member.role==='coordinator');
|
|
960
|
+
$('overview-team-role').textContent='Coordinator';
|
|
961
|
+
$('overview-team-mode').textContent='Goal summary';
|
|
962
|
+
$('overview-team-mode').hidden=!goalMode;
|
|
963
|
+
|
|
709
964
|
const summary=$('overview-summary');
|
|
710
965
|
summary.replaceChildren();
|
|
711
|
-
const
|
|
966
|
+
const coordReport=chronology.findLast(event=>event.author==='coordinator'&&event.kind==='message');
|
|
967
|
+
const goalReport=goalMode?chronology.findLast(event=>event.kind==='message'&&(event.author==='user'||/\[done\]/i.test(event.text??''))):null;
|
|
968
|
+
const report=coordReport??goalReport;
|
|
712
969
|
if (report) {
|
|
713
970
|
const body=node('div','message');
|
|
714
971
|
richText(body,report.text);
|
|
715
|
-
summary.append(
|
|
972
|
+
summary.append(postReference(report.seq),body);
|
|
716
973
|
}
|
|
717
974
|
summary.hidden=!report;
|
|
975
|
+
$('overview-summary-empty').hidden=Boolean(report);
|
|
976
|
+
const execFacts=[
|
|
977
|
+
team.turns+'/'+team.turnLimit+' turns',
|
|
978
|
+
[team.model,team.effort].filter(Boolean).join(' · '),
|
|
979
|
+
team.fallbackModel?'Fallback: '+team.fallbackModel+(team.fallbackEffort?' · '+team.fallbackEffort:''):'',
|
|
980
|
+
team.cwd,
|
|
981
|
+
].filter(Boolean).join(' · ');
|
|
982
|
+
$('overview-execution').textContent=execFacts;
|
|
983
|
+
$('overview-execution').hidden=!execFacts;
|
|
984
|
+
|
|
985
|
+
const milestones=chronology.filter(event=>['checkpoint','monitor'].includes(event.kind)||/\[done\]/i.test(event.text)).slice(-6).reverse();
|
|
986
|
+
$('overview-milestones').replaceChildren(...milestones.map(event=>{
|
|
987
|
+
const result=node('li','milestone');
|
|
988
|
+
result.append(postReference(event.seq),node('span','',event.text.slice(0,180)));
|
|
989
|
+
return result;
|
|
990
|
+
}));
|
|
991
|
+
$('overview-milestones-panel').hidden=!milestones.length;
|
|
718
992
|
}
|
|
719
993
|
|
|
720
994
|
function trustedButton(label, action, disabled=false, style='link-button') {
|
|
@@ -948,6 +1222,318 @@
|
|
|
948
1222
|
$('member-empty').hidden=visible.length>0;
|
|
949
1223
|
}
|
|
950
1224
|
|
|
1225
|
+
/* Fallback graph & GIF helpers when HiveGraph 2.1 / HiveGif are not yet loaded */
|
|
1226
|
+
function fallbackProjectHive(events,roster,cursorSeq) {
|
|
1227
|
+
const upTo=events.filter(event=>event.seq<=cursorSeq&&graph.isPost(event));
|
|
1228
|
+
const lastPost=upTo.at(-1)??null;
|
|
1229
|
+
const latestSeqByAuthor=new Map();
|
|
1230
|
+
for (const post of upTo) latestSeqByAuthor.set(post.author,post.seq);
|
|
1231
|
+
const coordMember=roster.find(member=>member.role==='coordinator')??{name:'coordinator',role:'coordinator',status:'waiting'};
|
|
1232
|
+
const workers=roster.filter(member=>member.role!=='coordinator'&&!member.external);
|
|
1233
|
+
const buckets={working:[],waiting:[],needs:[],done:[]};
|
|
1234
|
+
const memberBucket=new Map();
|
|
1235
|
+
for (const member of workers) {
|
|
1236
|
+
let bucket='waiting';
|
|
1237
|
+
if (member.recoveryRequired||['failed','quota'].includes(member.status)) bucket='needs';
|
|
1238
|
+
else if (member.status==='working') bucket='working';
|
|
1239
|
+
else if (['done','retired'].includes(member.status)) bucket='done';
|
|
1240
|
+
buckets[bucket].push({
|
|
1241
|
+
...member,
|
|
1242
|
+
muted:['done','retired'].includes(member.status),
|
|
1243
|
+
latestSeq:latestSeqByAuthor.get(member.name)??0,
|
|
1244
|
+
});
|
|
1245
|
+
memberBucket.set(member.name,bucket);
|
|
1246
|
+
}
|
|
1247
|
+
const meta={
|
|
1248
|
+
working:{label:'Working',tone:'working'},
|
|
1249
|
+
waiting:{label:'Waiting',tone:'waiting'},
|
|
1250
|
+
needs:{label:'Needs you',tone:'needs'},
|
|
1251
|
+
done:{label:'Done',tone:'done'},
|
|
1252
|
+
};
|
|
1253
|
+
const clusters=['working','waiting','needs','done']
|
|
1254
|
+
.filter(id=>buckets[id].length>0)
|
|
1255
|
+
.map(id=>({id,label:meta[id].label,tone:meta[id].tone,count:buckets[id].length,members:buckets[id]}));
|
|
1256
|
+
const doneCount=buckets.done.length;
|
|
1257
|
+
const totalWorkers=workers.length;
|
|
1258
|
+
const coordPhase=buckets.needs.length?'stalled':buckets.working.length?'working':
|
|
1259
|
+
totalWorkers>0&&doneCount===totalWorkers?'done':'waiting';
|
|
1260
|
+
const connectors=[];
|
|
1261
|
+
if (buckets.done.length) connectors.push({from:'done',to:'coordinator',kind:'done',label:'Tasks done'});
|
|
1262
|
+
if (buckets.needs.length) connectors.push({from:'coordinator',to:'needs',kind:'waiting',label:'Needs you'});
|
|
1263
|
+
if (buckets.waiting.some(member=>(member.pendingWaitFor??member.waitFor)?.length)) {
|
|
1264
|
+
connectors.push({from:'waiting',to:'coordinator',kind:'waiting',label:'Waiting on'});
|
|
1265
|
+
}
|
|
1266
|
+
if (lastPost&&(lastPost.targets?.length||coordPhase!=='done')) {
|
|
1267
|
+
const from=lastPost.author==='coordinator'?'coordinator':(memberBucket.get(lastPost.author)??'coordinator');
|
|
1268
|
+
const target=lastPost.targets?.find(name=>name!==lastPost.author);
|
|
1269
|
+
const to=target?(target==='coordinator'?'coordinator':(memberBucket.get(target)??'coordinator')):(from==='coordinator'&&clusters[0]?clusters[0].id:'coordinator');
|
|
1270
|
+
if (from!==to) connectors.push({from,to,kind:'message',label:'Message just sent',seq:lastPost.seq});
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1273
|
+
currentSeq:cursorSeq,
|
|
1274
|
+
lastPost,
|
|
1275
|
+
coordinator:{
|
|
1276
|
+
name:coordMember.name,status:coordMember.status,role:'coordinator',
|
|
1277
|
+
doneCount,totalWorkers,phase:coordPhase,latestSeq:latestSeqByAuthor.get(coordMember.name)??0,
|
|
1278
|
+
tint:coordMember.tint,
|
|
1279
|
+
},
|
|
1280
|
+
clusters,
|
|
1281
|
+
connectors,
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function hexVertices(cx,cy,radius) {
|
|
1285
|
+
return Array.from({length:6},(_,k)=>{
|
|
1286
|
+
const angle=k*Math.PI/3;
|
|
1287
|
+
return {x:cx+radius*Math.cos(angle),y:cy+radius*Math.sin(angle)};
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
function fallbackLayoutHive(hiveModel,width,height) {
|
|
1291
|
+
const clusters=hiveModel.clusters??[];
|
|
1292
|
+
const count=clusters.length;
|
|
1293
|
+
const radius=count<=1
|
|
1294
|
+
? Math.max(88,Math.min(120,width*0.25,height*0.225))
|
|
1295
|
+
: Math.max(70,Math.min(104,width*0.21,height*0.195));
|
|
1296
|
+
const hexH=Math.sqrt(3)*radius;
|
|
1297
|
+
const cellsById=new Map();
|
|
1298
|
+
let coordPos;
|
|
1299
|
+
const clusterLayouts=[];
|
|
1300
|
+
if (count===0) {
|
|
1301
|
+
coordPos={x:width/2,y:height/2};
|
|
1302
|
+
} else if (count===1) {
|
|
1303
|
+
const gap=Math.max(12,Math.min(22,height-hexH*2-20));
|
|
1304
|
+
const totalH=hexH*2+gap;
|
|
1305
|
+
const topY=Math.max(hexH/2+10,(height-totalH)/2+hexH/2);
|
|
1306
|
+
const clusterPos={x:width/2,y:topY};
|
|
1307
|
+
coordPos={x:width/2,y:topY+hexH+gap};
|
|
1308
|
+
clusterLayouts.push({pos:clusterPos,cluster:clusters[0]});
|
|
1309
|
+
} else {
|
|
1310
|
+
coordPos={x:width/2,y:height*0.64};
|
|
1311
|
+
const spreadX=Math.min(width*0.33,radius*2.2);
|
|
1312
|
+
const spreadY=Math.min(height*0.34,hexH*1.12);
|
|
1313
|
+
clusters.forEach((cluster,idx)=>{
|
|
1314
|
+
const angle=-Math.PI+(idx+1)*Math.PI/(count+1);
|
|
1315
|
+
clusterLayouts.push({
|
|
1316
|
+
pos:{x:width/2+Math.cos(angle)*spreadX,y:coordPos.y+Math.sin(angle)*spreadY},
|
|
1317
|
+
cluster,
|
|
1318
|
+
});
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
const coordinator={
|
|
1322
|
+
id:'coordinator',x:coordPos.x,y:coordPos.y,radius,
|
|
1323
|
+
vertices:hexVertices(coordPos.x,coordPos.y,radius),
|
|
1324
|
+
model:hiveModel.coordinator,
|
|
1325
|
+
};
|
|
1326
|
+
cellsById.set('coordinator',coordinator);
|
|
1327
|
+
const laidOutClusters=clusterLayouts.map(({pos,cluster})=>{
|
|
1328
|
+
const items=cluster.members??[];
|
|
1329
|
+
const cols=items.length<=2?items.length:items.length<=6?3:4;
|
|
1330
|
+
const rows=Math.max(1,Math.ceil(items.length/Math.max(1,cols)));
|
|
1331
|
+
const slotW=Math.min(68,(radius*1.58)/Math.max(1,cols));
|
|
1332
|
+
const rowGap=rows===1?0:Math.min(48,(hexH*0.56)/Math.max(1,rows));
|
|
1333
|
+
const baseY=pos.y+12-((rows-1)*rowGap)/2;
|
|
1334
|
+
const slots=items.map((member,idx)=>{
|
|
1335
|
+
const row=Math.floor(idx/cols);
|
|
1336
|
+
const col=idx%cols;
|
|
1337
|
+
const inRow=Math.min(cols,items.length-row*cols);
|
|
1338
|
+
const sx=pos.x+(col-(inRow-1)/2)*slotW;
|
|
1339
|
+
const sy=baseY+row*rowGap;
|
|
1340
|
+
return {member,x:sx,y:sy,slotWidth:slotW,beeScale:1};
|
|
1341
|
+
});
|
|
1342
|
+
const cell={
|
|
1343
|
+
id:cluster.id,label:cluster.label,tone:cluster.tone,count:cluster.count,
|
|
1344
|
+
x:pos.x,y:pos.y,radius,vertices:hexVertices(pos.x,pos.y,radius),slots,
|
|
1345
|
+
};
|
|
1346
|
+
cellsById.set(cluster.id,cell);
|
|
1347
|
+
return cell;
|
|
1348
|
+
});
|
|
1349
|
+
return {width,height,radius,coordinator,clusters:laidOutClusters,cellsById};
|
|
1350
|
+
}
|
|
1351
|
+
function fallbackHiveMinimumHeight(clusterCount,width) {
|
|
1352
|
+
if (clusterCount<=1) return width<440?380:430;
|
|
1353
|
+
return width<440?420:460;
|
|
1354
|
+
}
|
|
1355
|
+
function fallbackLayoutMentions(nodes,width,height) {
|
|
1356
|
+
const result=new Map();
|
|
1357
|
+
if (!nodes.length) return result;
|
|
1358
|
+
if (nodes.length>12||width<320) return graph.layout(nodes,width,height);
|
|
1359
|
+
const ordered=[...nodes].sort((a,b)=>(b.role==='coordinator')-(a.role==='coordinator'));
|
|
1360
|
+
const topPad=48,bottomPad=48;
|
|
1361
|
+
const centerY=(topPad+(height-bottomPad))/2;
|
|
1362
|
+
const radiusY=Math.max(54,(height-topPad-bottomPad)/2);
|
|
1363
|
+
const sidePad=Math.min(110,Math.max(72,width*0.16));
|
|
1364
|
+
const radiusX=Math.max(60,width/2-sidePad);
|
|
1365
|
+
if (ordered.length===1) {
|
|
1366
|
+
result.set(ordered[0].name,{x:width/2,y:centerY});
|
|
1367
|
+
return result;
|
|
1368
|
+
}
|
|
1369
|
+
ordered.forEach((member,idx)=>{
|
|
1370
|
+
const angle=-Math.PI/2+idx*Math.PI*2/ordered.length;
|
|
1371
|
+
result.set(member.name,{
|
|
1372
|
+
x:width/2+Math.cos(angle)*radiusX,
|
|
1373
|
+
y:centerY+Math.sin(angle)*radiusY,
|
|
1374
|
+
});
|
|
1375
|
+
});
|
|
1376
|
+
return result;
|
|
1377
|
+
}
|
|
1378
|
+
function fallbackPillBox(member,narrow) {
|
|
1379
|
+
const len=String(member?.name??'').length;
|
|
1380
|
+
const w=Math.max(76,Math.min(narrow?134:180,len*7.1+48));
|
|
1381
|
+
return {halfW:w/2,halfH:15,offsetX:0,offsetY:0,radius:15};
|
|
1382
|
+
}
|
|
1383
|
+
function pillBoxFor(member,narrow) {
|
|
1384
|
+
if (typeof graph.layoutMentions==='function'&&typeof graph.nodeBox==='function') {
|
|
1385
|
+
return graph.nodeBox(member,{variant:'pill',narrow});
|
|
1386
|
+
}
|
|
1387
|
+
return fallbackPillBox(member,narrow);
|
|
1388
|
+
}
|
|
1389
|
+
function clipRayToHex(origin,target,vertices) {
|
|
1390
|
+
if (!vertices?.length) return origin;
|
|
1391
|
+
const dx=target.x-origin.x,dy=target.y-origin.y;
|
|
1392
|
+
let bestT=Infinity;
|
|
1393
|
+
for (let i=0;i<vertices.length;i++) {
|
|
1394
|
+
const a=vertices[i],b=vertices[(i+1)%vertices.length];
|
|
1395
|
+
const ex=b.x-a.x,ey=b.y-a.y;
|
|
1396
|
+
const denom=dx*ey-dy*ex;
|
|
1397
|
+
if (Math.abs(denom)<1e-6) continue;
|
|
1398
|
+
const t=((a.x-origin.x)*ey-(a.y-origin.y)*ex)/denom;
|
|
1399
|
+
const u=((a.x-origin.x)*dy-(a.y-origin.y)*dx)/denom;
|
|
1400
|
+
if (t>0&&u>=-1e-4&&u<=1+1e-4&&t<bestT) bestT=t;
|
|
1401
|
+
}
|
|
1402
|
+
return Number.isFinite(bestT)?{x:origin.x+dx*bestT,y:origin.y+dy*bestT}:origin;
|
|
1403
|
+
}
|
|
1404
|
+
function rayClipHex(fromCell,toCell,offset=0) {
|
|
1405
|
+
const angle=Math.atan2(toCell.y-fromCell.y,toCell.x-fromCell.x);
|
|
1406
|
+
const nx=-Math.sin(angle),ny=Math.cos(angle);
|
|
1407
|
+
const fromPt=offset?{x:fromCell.x+nx*offset,y:fromCell.y+ny*offset}:fromCell;
|
|
1408
|
+
const toPt=offset?{x:toCell.x+nx*offset,y:toCell.y+ny*offset}:toCell;
|
|
1409
|
+
const start=clipRayToHex(fromPt,toPt,fromCell.vertices);
|
|
1410
|
+
const end=clipRayToHex(toPt,fromPt,toCell.vertices);
|
|
1411
|
+
return {start,end};
|
|
1412
|
+
}
|
|
1413
|
+
function drawHexCell(ctx,cell,palette,title,subtitle) {
|
|
1414
|
+
ctx.beginPath();
|
|
1415
|
+
cell.vertices.forEach((pt,idx)=>idx===0?ctx.moveTo(pt.x,pt.y):ctx.lineTo(pt.x,pt.y));
|
|
1416
|
+
ctx.closePath();
|
|
1417
|
+
ctx.fillStyle=palette.fill;
|
|
1418
|
+
ctx.fill();
|
|
1419
|
+
ctx.lineWidth=2;
|
|
1420
|
+
ctx.strokeStyle=palette.stroke;
|
|
1421
|
+
ctx.stroke();
|
|
1422
|
+
ctx.textAlign='center';
|
|
1423
|
+
ctx.textBaseline='middle';
|
|
1424
|
+
const titleY=cell.id==='coordinator'?cell.y+cell.radius*0.42:cell.y-cell.radius*0.62;
|
|
1425
|
+
ctx.fillStyle=palette.ink;
|
|
1426
|
+
ctx.font='650 12px var(--sans), system-ui, sans-serif';
|
|
1427
|
+
ctx.fillText(title,cell.x,titleY);
|
|
1428
|
+
if (subtitle!=null) {
|
|
1429
|
+
ctx.fillStyle=palette.muted;
|
|
1430
|
+
ctx.font='500 11px var(--sans), system-ui, sans-serif';
|
|
1431
|
+
ctx.fillText(String(subtitle),cell.x,titleY+15);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
function drawArrowHead(ctx,end,angle,color) {
|
|
1435
|
+
const len=8;
|
|
1436
|
+
ctx.fillStyle=color;
|
|
1437
|
+
ctx.beginPath();
|
|
1438
|
+
ctx.moveTo(end.x,end.y);
|
|
1439
|
+
ctx.lineTo(end.x-len*Math.cos(angle-0.45),end.y-len*Math.sin(angle-0.45));
|
|
1440
|
+
ctx.lineTo(end.x-(len*0.65)*Math.cos(angle),end.y-(len*0.65)*Math.sin(angle));
|
|
1441
|
+
ctx.lineTo(end.x-len*Math.cos(angle+0.45),end.y-len*Math.sin(angle+0.45));
|
|
1442
|
+
ctx.closePath();
|
|
1443
|
+
ctx.fill();
|
|
1444
|
+
}
|
|
1445
|
+
function drawHiveCanvas(canvas,hiveLayout,connectors,color) {
|
|
1446
|
+
const width=canvas.clientWidth,height=canvas.clientHeight;
|
|
1447
|
+
if (!width||!height) return;
|
|
1448
|
+
const scale=Math.min(devicePixelRatio||1,2);
|
|
1449
|
+
const pw=Math.round(width*scale),ph=Math.round(height*scale);
|
|
1450
|
+
if (canvas.width!==pw||canvas.height!==ph) {canvas.width=pw;canvas.height=ph;}
|
|
1451
|
+
const ctx=canvas.getContext('2d');
|
|
1452
|
+
ctx.setTransform(scale,0,0,scale,0,0);
|
|
1453
|
+
ctx.clearRect(0,0,width,height);
|
|
1454
|
+
for (const conn of connectors) {
|
|
1455
|
+
const fromCell=hiveLayout.cellsById.get(conn.from);
|
|
1456
|
+
const toCell=hiveLayout.cellsById.get(conn.to);
|
|
1457
|
+
if (!fromCell||!toCell||fromCell===toCell) continue;
|
|
1458
|
+
const offset=conn.kind==='message'?8:conn.kind==='waiting'?-8:0;
|
|
1459
|
+
const {start,end}=rayClipHex(fromCell,toCell,offset);
|
|
1460
|
+
if (Math.hypot(end.x-start.x,end.y-start.y)<1) continue;
|
|
1461
|
+
const stroke=conn.kind==='done'?color.good:conn.kind==='message'?color.purple:color.gold;
|
|
1462
|
+
ctx.strokeStyle=stroke;
|
|
1463
|
+
ctx.lineWidth=conn.kind==='message'?2.2:1.8;
|
|
1464
|
+
ctx.setLineDash(conn.kind==='waiting'?[5,4]:[]);
|
|
1465
|
+
ctx.beginPath();
|
|
1466
|
+
ctx.moveTo(start.x,start.y);
|
|
1467
|
+
ctx.lineTo(end.x,end.y);
|
|
1468
|
+
ctx.stroke();
|
|
1469
|
+
ctx.setLineDash([]);
|
|
1470
|
+
if (conn.kind==='waiting') drawArrowHead(ctx,end,Math.atan2(end.y-start.y,end.x-start.x),stroke);
|
|
1471
|
+
}
|
|
1472
|
+
const tonePalette=tone=>{
|
|
1473
|
+
if (tone==='done') return {fill:color.goodSoft,stroke:color.good,ink:color.text,muted:color.muted};
|
|
1474
|
+
if (tone==='working') return {fill:color.wash,stroke:color.gold,ink:color.text,muted:color.muted};
|
|
1475
|
+
if (tone==='needs') return {fill:color.badSoft,stroke:color.bad,ink:color.text,muted:color.muted};
|
|
1476
|
+
return {fill:color.paper,stroke:color.link,ink:color.text,muted:color.muted};
|
|
1477
|
+
};
|
|
1478
|
+
for (const cluster of hiveLayout.clusters) {
|
|
1479
|
+
drawHexCell(ctx,cluster,tonePalette(cluster.tone),cluster.label,cluster.count);
|
|
1480
|
+
}
|
|
1481
|
+
const coordTone=hiveLayout.coordinator.model.phase==='done'?'done':
|
|
1482
|
+
hiveLayout.coordinator.model.phase==='stalled'?'needs':'working';
|
|
1483
|
+
const doneTotal=hiveLayout.coordinator.model.doneCount+' of '+hiveLayout.coordinator.model.totalWorkers+' done';
|
|
1484
|
+
drawHexCell(ctx,hiveLayout.coordinator,tonePalette(coordTone),'Coordinator',doneTotal);
|
|
1485
|
+
}
|
|
1486
|
+
function drawMentionsCanvas(canvas,projection,coordinates,boxes,focus,highlight,color) {
|
|
1487
|
+
const width=canvas.clientWidth,height=canvas.clientHeight;
|
|
1488
|
+
if (!width||!height) return;
|
|
1489
|
+
const scale=Math.min(devicePixelRatio||1,2);
|
|
1490
|
+
const pw=Math.round(width*scale),ph=Math.round(height*scale);
|
|
1491
|
+
if (canvas.width!==pw||canvas.height!==ph) {canvas.width=pw;canvas.height=ph;}
|
|
1492
|
+
const ctx=canvas.getContext('2d');
|
|
1493
|
+
ctx.setTransform(scale,0,0,scale,0,0);
|
|
1494
|
+
ctx.clearRect(0,0,width,height);
|
|
1495
|
+
ctx.font='600 10px ui-monospace, monospace';
|
|
1496
|
+
ctx.textAlign='center';
|
|
1497
|
+
ctx.textBaseline='middle';
|
|
1498
|
+
const routed=graph.routeEdges(projection,coordinates,{
|
|
1499
|
+
variant:'pill',boxes,narrow:width<465,marginStart:5,marginEnd:6,obstacleMargin:width<465?12:20,
|
|
1500
|
+
});
|
|
1501
|
+
for (const {link,edge} of routed) {
|
|
1502
|
+
const {start:a,control:c,end:b,mid,endAngle:angle}=edge;
|
|
1503
|
+
const pulse=link.lastSeq===highlight;
|
|
1504
|
+
const related=!focus||link.from===focus||link.to===focus;
|
|
1505
|
+
const stroke=pulse&&related?color.accent:color.link;
|
|
1506
|
+
ctx.globalAlpha=related?(pulse?1:0.78):0.16;
|
|
1507
|
+
ctx.strokeStyle=ctx.fillStyle=stroke;
|
|
1508
|
+
ctx.lineWidth=Math.min(4.2,1.1+Math.sqrt(link.count)*0.72);
|
|
1509
|
+
ctx.lineCap='round';
|
|
1510
|
+
ctx.setLineDash(link.direct?[]:[4,4]);
|
|
1511
|
+
const inset=Math.min(4.5,edge.length*0.25);
|
|
1512
|
+
ctx.beginPath();
|
|
1513
|
+
ctx.moveTo(a.x,a.y);
|
|
1514
|
+
ctx.quadraticCurveTo(c.x,c.y,b.x-Math.cos(angle)*inset,b.y-Math.sin(angle)*inset);
|
|
1515
|
+
ctx.stroke();
|
|
1516
|
+
ctx.setLineDash([]);
|
|
1517
|
+
drawArrowHead(ctx,b,angle,stroke);
|
|
1518
|
+
if (related&&edge.length>=40&&(link.count>1||pulse||focus)) {
|
|
1519
|
+
const label=String(link.count);
|
|
1520
|
+
const pillW=Math.max(18,label.length*6.5+8);
|
|
1521
|
+
ctx.globalAlpha=0.98;
|
|
1522
|
+
ctx.fillStyle=color.paper;
|
|
1523
|
+
ctx.beginPath();
|
|
1524
|
+
if (ctx.roundRect) ctx.roundRect(mid.x-pillW/2,mid.y-7.5,pillW,15,7.5);
|
|
1525
|
+
else ctx.rect(mid.x-pillW/2,mid.y-7.5,pillW,15);
|
|
1526
|
+
ctx.fill();
|
|
1527
|
+
ctx.strokeStyle=pulse?color.accent:color.link;
|
|
1528
|
+
ctx.lineWidth=1;
|
|
1529
|
+
ctx.stroke();
|
|
1530
|
+
ctx.fillStyle=pulse?color.accent:color.text;
|
|
1531
|
+
ctx.fillText(label,mid.x,mid.y+0.25);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
ctx.globalAlpha=1;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
951
1537
|
function timeline() {return chronology.filter(graph.isPost);}
|
|
952
1538
|
function cursorIndex(events) {
|
|
953
1539
|
if (cursor===null) return events.length;
|
|
@@ -978,17 +1564,52 @@
|
|
|
978
1564
|
if (activeTab!=='graph'||graphFrame) return;
|
|
979
1565
|
graphFrame=requestAnimationFrame(()=>{graphFrame=0;if (team && activeTab==='graph') renderGraph();});
|
|
980
1566
|
}
|
|
1567
|
+
function setGraphMode(mode) {
|
|
1568
|
+
graphMode=mode==='mentions'?'mentions':'hive';
|
|
1569
|
+
saveGraphMode(graphMode);
|
|
1570
|
+
$('graph-mode-hive').setAttribute('aria-pressed',String(graphMode==='hive'));
|
|
1571
|
+
$('graph-mode-mentions').setAttribute('aria-pressed',String(graphMode==='mentions'));
|
|
1572
|
+
$('mentions-options').hidden=graphMode!=='mentions';
|
|
1573
|
+
$('graph-stage').dataset.mode=graphMode;
|
|
1574
|
+
$('graph-legend').dataset.mode=graphMode;
|
|
1575
|
+
$('legend-hive').hidden=graphMode!=='hive';
|
|
1576
|
+
$('legend-mentions').hidden=graphMode!=='mentions';
|
|
1577
|
+
scheduleGraph();
|
|
1578
|
+
}
|
|
981
1579
|
function renderGraphTotal(events=timeline(),index=cursorIndex(events)) {
|
|
982
1580
|
const live=cursor===null&&['working','queued'].includes(team.phase);
|
|
983
1581
|
$('graph-total').textContent=events.length+' posts · '+graph.elapsedSpan(events.slice(0,index),{live})+
|
|
984
1582
|
(cursor!==null?' · '+index+'/'+events.length:'');
|
|
985
1583
|
}
|
|
1584
|
+
function graphPalette(stage) {
|
|
1585
|
+
const css=getComputedStyle(stage);
|
|
1586
|
+
const val=(prop,fallback)=>css.getPropertyValue(prop).trim()||fallback;
|
|
1587
|
+
const light=currentTheme()==='light';
|
|
1588
|
+
return {
|
|
1589
|
+
grid:val('--grid',light?'#eaedf2':'#242933'),
|
|
1590
|
+
link:val('--edge',light?'#9ba5b5':'#7c8698'),
|
|
1591
|
+
accent:val('--gold',light?'#8f5b10':'#f6c458'),
|
|
1592
|
+
gold:val('--gold-solid','#e5a024'),
|
|
1593
|
+
good:val('--good',light?'#247a3d':'#6fd89c'),
|
|
1594
|
+
goodSoft:light?'rgba(36, 122, 61, 0.08)':'rgba(111, 216, 156, 0.1)',
|
|
1595
|
+
purple:val('--purple',light?'#7c4dff':'#b39ddb'),
|
|
1596
|
+
bad:val('--bad',light?'#c4302b':'#ff8a80'),
|
|
1597
|
+
badSoft:light?'rgba(196, 48, 43, 0.08)':'rgba(255, 138, 128, 0.1)',
|
|
1598
|
+
wash:val('--wash',light?'#fdf4e2':'#2b2416'),
|
|
1599
|
+
paper:val('--surface',light?'#ffffff':'#181b21'),
|
|
1600
|
+
text:val('--ink',light?'#181c23':'#eef1f6'),
|
|
1601
|
+
muted:val('--muted',light?'#555e6d':'#a4adbd'),
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
|
|
986
1605
|
function renderGraph() {
|
|
987
1606
|
const events=timeline();
|
|
988
1607
|
const index=cursorIndex(events);
|
|
989
1608
|
const current=events[index-1];
|
|
990
|
-
const
|
|
991
|
-
|
|
1609
|
+
const roster=people();
|
|
1610
|
+
const mentionsProjection=graph.project(events,roster,current?.seq??0,{
|
|
1611
|
+
hideInactive:graphMode==='mentions'?$('hide-inactive').checked:false,
|
|
1612
|
+
expandBroadcast:graphMode==='mentions'?$('expand-all').checked:false,
|
|
992
1613
|
});
|
|
993
1614
|
renderGraphTotal(events,index);
|
|
994
1615
|
$('replay').max=events.length;
|
|
@@ -1003,51 +1624,123 @@
|
|
|
1003
1624
|
$('play').setAttribute('aria-label',playLabel);
|
|
1004
1625
|
$('play').title=playLabel;
|
|
1005
1626
|
$('live').setAttribute('aria-pressed',String(cursor===null));
|
|
1006
|
-
$('broadcast-count').textContent=
|
|
1627
|
+
$('broadcast-count').textContent=mentionsProjection.broadcasts+' @all posts';
|
|
1628
|
+
|
|
1629
|
+
$('graph-mode-hive').setAttribute('aria-pressed',String(graphMode==='hive'));
|
|
1630
|
+
$('graph-mode-mentions').setAttribute('aria-pressed',String(graphMode==='mentions'));
|
|
1631
|
+
$('mentions-options').hidden=graphMode!=='mentions';
|
|
1632
|
+
$('graph-stage').dataset.mode=graphMode;
|
|
1633
|
+
$('graph-legend').dataset.mode=graphMode;
|
|
1634
|
+
$('legend-hive').hidden=graphMode!=='hive';
|
|
1635
|
+
$('legend-mentions').hidden=graphMode!=='mentions';
|
|
1636
|
+
|
|
1007
1637
|
const stage=$('graph-stage');
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1638
|
+
const color=graphPalette(stage);
|
|
1639
|
+
const activeFocus=document.activeElement?.dataset.graphName;
|
|
1640
|
+
const projByName=new Map(mentionsProjection.nodes.map(item=>[item.name,item]));
|
|
1641
|
+
const isConnected=name=>!focusedNode||focusedNode===name||mentionsProjection.links.some(
|
|
1642
|
+
edge=>(edge.from===focusedNode&&edge.to===name)||(edge.to===focusedNode&&edge.from===name));
|
|
1643
|
+
|
|
1644
|
+
if (graphMode==='hive') {
|
|
1645
|
+
const hiveModel=(graph.projectHive??fallbackProjectHive)(events,roster,current?.seq??0);
|
|
1646
|
+
const minimum=(graph.hiveMinimumHeight??fallbackHiveMinimumHeight)(hiveModel.clusters.length,stage.clientWidth);
|
|
1647
|
+
stage.style.height=minimum?minimum+'px':'';
|
|
1648
|
+
const hiveLayout=(graph.layoutHive??fallbackLayoutHive)(hiveModel,stage.clientWidth,stage.clientHeight);
|
|
1649
|
+
if (focusedNode&&!roster.some(member=>member.name===focusedNode)) focusedNode=null;
|
|
1650
|
+
const buttons=[];
|
|
1651
|
+
const makeHiveButton=(member,x,y,isCoordinator,slotWidth)=>{
|
|
1652
|
+
const projNode=projByName.get(member.name)??member;
|
|
1653
|
+
const btn=node('button','graph-node graph-hive-bee');
|
|
1654
|
+
btn.type='button';
|
|
1655
|
+
btn.style.left=x+'px';
|
|
1656
|
+
btn.style.top=y+'px';
|
|
1657
|
+
if (Number.isFinite(slotWidth)&&slotWidth>0) btn.style.width=Math.max(46,Math.min(70,Math.floor(slotWidth)))+'px';
|
|
1658
|
+
btn.dataset.graphName=member.name;
|
|
1659
|
+
btn.dataset.role=isCoordinator?'coordinator':'worker';
|
|
1660
|
+
btn.dataset.status=member.status??'waiting';
|
|
1661
|
+
btn.dataset.muted=String(!projNode.posts&&!mentionsProjection.links.some(edge=>edge.to===member.name));
|
|
1662
|
+
btn.dataset.dimmed=String(!isConnected(member.name));
|
|
1663
|
+
btn.dataset.unmentioned=String(graph.unmentionedNode(projNode));
|
|
1664
|
+
const beeMuted=!isCoordinator&&['done','retired'].includes(member.status);
|
|
1665
|
+
btn.dataset.beeMuted=String(beeMuted);
|
|
1666
|
+
btn.title=author(member.name)+' · '+condition(member)+(graph.unmentionedNode(projNode)?' · Posted with no mention':'');
|
|
1667
|
+
btn.setAttribute('aria-label',btn.title);
|
|
1668
|
+
btn.setAttribute('aria-pressed',String(focusedNode===member.name));
|
|
1669
|
+
btn.append(beeSprite({...member,role:isCoordinator?'coordinator':'worker'},{muted:beeMuted}));
|
|
1670
|
+
if (!isCoordinator) btn.append(node('span','hive-bee-label',member.name));
|
|
1671
|
+
btn.onclick=()=>{
|
|
1672
|
+
focusedNode=focusedNode===member.name?null:member.name;
|
|
1673
|
+
scheduleGraph();
|
|
1674
|
+
};
|
|
1675
|
+
return btn;
|
|
1037
1676
|
};
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1677
|
+
const coordMember=roster.find(member=>member.role==='coordinator')??{name:'coordinator',role:'coordinator',status:'waiting'};
|
|
1678
|
+
const coordSlot=hiveLayout.coordinator.slots?.[0];
|
|
1679
|
+
buttons.push(makeHiveButton(coordMember,coordSlot?.x??hiveLayout.coordinator.x,coordSlot?.y??(hiveLayout.coordinator.y-16),true));
|
|
1680
|
+
for (const cluster of hiveLayout.clusters) {
|
|
1681
|
+
for (const slot of cluster.slots) {
|
|
1682
|
+
buttons.push(makeHiveButton(slot.member,slot.x,slot.y,false,slot.slotWidth));
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
$('graph-nodes').replaceChildren(...buttons);
|
|
1686
|
+
drawHiveCanvas($('graph-canvas'),hiveLayout,hiveModel.connectors,color);
|
|
1687
|
+
} else {
|
|
1688
|
+
const minimum=(graph.mentionsMinimumHeight??graph.minimumHeight)(mentionsProjection.nodes.length,stage.clientWidth);
|
|
1689
|
+
stage.style.height=minimum?minimum+'px':'';
|
|
1690
|
+
const coordinates=(graph.layoutMentions??fallbackLayoutMentions)(mentionsProjection.nodes,stage.clientWidth,stage.clientHeight);
|
|
1691
|
+
if (focusedNode&&!coordinates.has(focusedNode)) focusedNode=null;
|
|
1692
|
+
const narrow=stage.clientWidth<465;
|
|
1693
|
+
const pillBoxes=new Map();
|
|
1694
|
+
const pillButtons=mentionsProjection.nodes.map(member=>{
|
|
1695
|
+
const point=coordinates.get(member.name);
|
|
1696
|
+
pillBoxes.set(member.name,pillBoxFor(member,narrow));
|
|
1697
|
+
const btn=node('button','graph-node graph-pill-node');
|
|
1698
|
+
btn.type='button';
|
|
1699
|
+
btn.style.left=point.x+'px';
|
|
1700
|
+
btn.style.top=point.y+'px';
|
|
1701
|
+
btn.dataset.graphName=member.name;
|
|
1702
|
+
btn.dataset.role=member.role??'worker';
|
|
1703
|
+
btn.dataset.status=member.status??'observer';
|
|
1704
|
+
btn.dataset.muted=String(!member.posts&&!mentionsProjection.links.some(edge=>edge.to===member.name));
|
|
1705
|
+
btn.dataset.dimmed=String(!isConnected(member.name));
|
|
1706
|
+
btn.dataset.unmentioned=String(graph.unmentionedNode(member));
|
|
1707
|
+
const beeMuted=member.role!=='coordinator'&&['done','retired'].includes(member.status);
|
|
1708
|
+
btn.dataset.beeMuted=String(beeMuted);
|
|
1709
|
+
btn.title=author(member.name)+' · '+condition(member)+(graph.unmentionedNode(member)?' · Posted with no mention':'');
|
|
1710
|
+
btn.setAttribute('aria-label',btn.title);
|
|
1711
|
+
btn.setAttribute('aria-pressed',String(focusedNode===member.name));
|
|
1712
|
+
const dot=node('span','pill-dot');
|
|
1713
|
+
dot.setAttribute('aria-hidden','true');
|
|
1714
|
+
btn.append(beeSprite(member,{muted:beeMuted}),node('span','pill-name',member.name),dot);
|
|
1715
|
+
if (member.broadcasts) btn.append(node('span','node-broadcast','@all '+member.broadcasts));
|
|
1716
|
+
btn.onclick=()=>{
|
|
1717
|
+
focusedNode=focusedNode===member.name?null:member.name;
|
|
1718
|
+
scheduleGraph();
|
|
1719
|
+
};
|
|
1720
|
+
return btn;
|
|
1721
|
+
});
|
|
1722
|
+
$('graph-nodes').replaceChildren(...pillButtons);
|
|
1723
|
+
for (const btn of pillButtons) {
|
|
1724
|
+
if (btn.offsetWidth>0&&btn.offsetHeight>0) {
|
|
1725
|
+
pillBoxes.set(btn.dataset.graphName,{halfW:btn.offsetWidth/2,halfH:btn.offsetHeight/2,offsetX:0,offsetY:0,radius:btn.offsetHeight/2});
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
drawMentionsCanvas($('graph-canvas'),mentionsProjection,coordinates,pillBoxes,focusedNode,current?.seq,color);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
if (activeFocus) [...$('graph-nodes').children].find(button=>button.dataset.graphName===activeFocus)?.focus({preventScroll:true});
|
|
1732
|
+
|
|
1046
1733
|
$('inspection-title').textContent=focusedNode?author(focusedNode):'Selected post';
|
|
1047
1734
|
$('clear-node').hidden=!focusedNode;
|
|
1735
|
+
const focusedMember=focusedNode?roster.find(member=>member.name===focusedNode):null;
|
|
1736
|
+
const memberActions=$('graph-member-actions');
|
|
1737
|
+
memberActions.replaceChildren();
|
|
1738
|
+
const journal=focusedMember?transcriptButton(focusedMember):null;
|
|
1739
|
+
if (journal) memberActions.append(journal);
|
|
1740
|
+
memberActions.hidden=!memberActions.childElementCount;
|
|
1048
1741
|
$('graph-post-author').textContent=current?author(current.author)+' · '+stamp(current):'';
|
|
1049
1742
|
richText($('graph-post'),current?.text??'No post at this position yet.');
|
|
1050
|
-
const links=
|
|
1743
|
+
const links=mentionsProjection.links.filter(edge=>!focusedNode||edge.from===focusedNode||edge.to===focusedNode)
|
|
1051
1744
|
.sort((a,b)=>b.count-a.count);
|
|
1052
1745
|
$('edge-list').replaceChildren(...links.map(edge=>{
|
|
1053
1746
|
const line=node('li');
|
|
@@ -1056,6 +1749,115 @@
|
|
|
1056
1749
|
}));
|
|
1057
1750
|
}
|
|
1058
1751
|
|
|
1752
|
+
/* Fallback GIF89a exporter when HiveGif is not yet merged */
|
|
1753
|
+
function fallbackEncodeSingleFrameGif(rgba,width,height) {
|
|
1754
|
+
const out=[0x47,0x49,0x46,0x38,0x39,0x61,width&255,(width>>8)&255,height&255,(height>>8)&255,0xF0,0,0];
|
|
1755
|
+
// 2-color table (theme paper & ink)
|
|
1756
|
+
out.push(0xFA,0xFA,0xFA,0x20,0x24,0x2C);
|
|
1757
|
+
// NETSCAPE2.0 infinite loop extension
|
|
1758
|
+
out.push(0x21,0xFF,0x0B,0x4E,0x45,0x54,0x53,0x43,0x41,0x50,0x45,0x32,0x2E,0x30,0x03,0x01,0,0,0);
|
|
1759
|
+
out.push(0x2C,0,0,0,0,width&255,(width>>8)&255,height&255,(height>>8)&255,0,2);
|
|
1760
|
+
const total=width*height;
|
|
1761
|
+
const idx=new Uint8Array(total);
|
|
1762
|
+
for (let i=0;i<total;i++) {
|
|
1763
|
+
const lum=(rgba[i*4]*299+rgba[i*4+1]*587+rgba[i*4+2]*114)/1000;
|
|
1764
|
+
idx[i]=lum<128?1:0;
|
|
1765
|
+
}
|
|
1766
|
+
const bytes=[];
|
|
1767
|
+
let bitBuf=0,bitCount=0;
|
|
1768
|
+
const emit=(code,bits)=>{
|
|
1769
|
+
bitBuf|=code<<bitCount;
|
|
1770
|
+
bitCount+=bits;
|
|
1771
|
+
while (bitCount>=8) {bytes.push(bitBuf&255);bitBuf>>=8;bitCount-=8;}
|
|
1772
|
+
};
|
|
1773
|
+
emit(4,3);
|
|
1774
|
+
for (let i=0;i<total;i++) {
|
|
1775
|
+
emit(idx[i],3);
|
|
1776
|
+
if (i%120===119) emit(4,3);
|
|
1777
|
+
}
|
|
1778
|
+
emit(5,3);
|
|
1779
|
+
if (bitCount>0) bytes.push(bitBuf&255);
|
|
1780
|
+
for (let i=0;i<bytes.length;i+=255) {
|
|
1781
|
+
const chunk=bytes.slice(i,i+255);
|
|
1782
|
+
out.push(chunk.length,...chunk);
|
|
1783
|
+
}
|
|
1784
|
+
out.push(0,0x3B);
|
|
1785
|
+
return new Uint8Array(out);
|
|
1786
|
+
}
|
|
1787
|
+
function fallbackExportGraphReplayGif(opts) {
|
|
1788
|
+
const width=Math.max(320,Math.min(960,Math.round(opts.width||680)));
|
|
1789
|
+
const height=Math.max(240,Math.min(720,Math.round(opts.height||460)));
|
|
1790
|
+
const canvas=document.createElement('canvas');
|
|
1791
|
+
canvas.width=width;
|
|
1792
|
+
canvas.height=height;
|
|
1793
|
+
const ctx=canvas.getContext('2d');
|
|
1794
|
+
if (ctx) {
|
|
1795
|
+
if (typeof graph.renderGraphFrame==='function') graph.renderGraphFrame(ctx,{...opts,width,height});
|
|
1796
|
+
else {
|
|
1797
|
+
ctx.fillStyle=opts.theme==='light'?'#f9fafc':'#15181e';
|
|
1798
|
+
ctx.fillRect?.(0,0,width,height);
|
|
1799
|
+
const stageCanvas=$('graph-canvas');
|
|
1800
|
+
if (stageCanvas?.width&&stageCanvas?.height) ctx.drawImage?.(stageCanvas,0,0,width,height);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
const rgba=ctx?.getImageData?.(0,0,width,height)?.data??new Uint8ClampedArray(width*height*4);
|
|
1804
|
+
const bytes=fallbackEncodeSingleFrameGif(rgba,width,height);
|
|
1805
|
+
const blob=typeof Blob!=='undefined'?new Blob([bytes],{type:'image/gif'}):undefined;
|
|
1806
|
+
return {bytes,blob,frameCount:1,width,height};
|
|
1807
|
+
}
|
|
1808
|
+
function teamSlug() {
|
|
1809
|
+
const slug=String(team?.title??team?.id??'swarm').toLowerCase()
|
|
1810
|
+
.replace(/[^a-z0-9]+/g,'-').replace(/^-+|-+$/g,'').slice(0,48);
|
|
1811
|
+
return slug||'swarm';
|
|
1812
|
+
}
|
|
1813
|
+
async function exportGif() {
|
|
1814
|
+
if (!team||exportingGif) return;
|
|
1815
|
+
const btn=$('export-gif');
|
|
1816
|
+
exportingGif=true;
|
|
1817
|
+
btn.disabled=true;
|
|
1818
|
+
notice('Exporting '+graphMode+' GIF…');
|
|
1819
|
+
try {
|
|
1820
|
+
const stage=$('graph-stage');
|
|
1821
|
+
const events=timeline();
|
|
1822
|
+
const exporter=globalThis.HiveGif?.exportGraphReplayGif??fallbackExportGraphReplayGif;
|
|
1823
|
+
const result=await exporter({
|
|
1824
|
+
mode:graphMode,
|
|
1825
|
+
posts:events,
|
|
1826
|
+
members:people(),
|
|
1827
|
+
phase:team.phase??(team.paused?'paused':'working'),
|
|
1828
|
+
pacing:$('pacing').value,
|
|
1829
|
+
speed:Number($('speed').value),
|
|
1830
|
+
hideInactive:$('hide-inactive').checked,
|
|
1831
|
+
expandBroadcast:$('expand-all').checked,
|
|
1832
|
+
focus:focusedNode,
|
|
1833
|
+
theme:currentTheme(),
|
|
1834
|
+
width:Math.max(480,stage.clientWidth||680),
|
|
1835
|
+
height:Math.max(360,stage.clientHeight||460),
|
|
1836
|
+
graph,
|
|
1837
|
+
bees:globalThis.HiveBee,
|
|
1838
|
+
});
|
|
1839
|
+
const blob=result?.blob??(typeof Blob!=='undefined'&&result?.bytes?new Blob([result.bytes],{type:'image/gif'}):null);
|
|
1840
|
+
const filename=teamSlug()+'-graph.gif';
|
|
1841
|
+
if (blob&&typeof URL.createObjectURL==='function') {
|
|
1842
|
+
const href=URL.createObjectURL(blob);
|
|
1843
|
+
const link=node('a');
|
|
1844
|
+
link.href=href;
|
|
1845
|
+
link.download=filename;
|
|
1846
|
+
link.style.display='none';
|
|
1847
|
+
document.body?.append?.(link);
|
|
1848
|
+
link.click?.();
|
|
1849
|
+
link.remove?.();
|
|
1850
|
+
setTimeout(()=>URL.revokeObjectURL?.(href),1500);
|
|
1851
|
+
}
|
|
1852
|
+
notice('Exported '+filename+' ('+(result?.frameCount??1)+' frames).');
|
|
1853
|
+
} catch (error) {
|
|
1854
|
+
notice(error?.message||'Could not export GIF.',true);
|
|
1855
|
+
} finally {
|
|
1856
|
+
exportingGif=false;
|
|
1857
|
+
btn.disabled=false;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1059
1861
|
function selectTab(name,focus=false) {
|
|
1060
1862
|
if (name!==activeTab) stopPlayback();
|
|
1061
1863
|
if (name==='members'&&activeTab!==name) memberKey='';
|
|
@@ -1067,7 +1869,7 @@
|
|
|
1067
1869
|
$('panel-'+tab).hidden=!selected||!team;
|
|
1068
1870
|
}
|
|
1069
1871
|
render();
|
|
1070
|
-
$('tab-'+name).scrollIntoView?.({block:'nearest',inline:'nearest'});
|
|
1872
|
+
$('tab-'+name).scrollIntoView?.({block:'nearest',inline:'nearest',container:'nearest'});
|
|
1071
1873
|
if (focus) $('tab-'+name).focus();
|
|
1072
1874
|
}
|
|
1073
1875
|
|
|
@@ -1186,12 +1988,25 @@
|
|
|
1186
1988
|
$('theme').firstElementChild.textContent=theme==='dark'?'☀':'☾';
|
|
1187
1989
|
scheduleGraph();
|
|
1188
1990
|
}
|
|
1991
|
+
const colorSchemeQuery=matchMedia('(prefers-color-scheme: dark)');
|
|
1189
1992
|
function initialTheme() {
|
|
1190
1993
|
try {
|
|
1191
1994
|
const saved=localStorage.getItem('team-board-color');
|
|
1192
1995
|
if (saved==='light'||saved==='dark') return saved;
|
|
1193
1996
|
} catch {}
|
|
1194
|
-
return
|
|
1997
|
+
return colorSchemeQuery.matches?'dark':'light';
|
|
1998
|
+
}
|
|
1999
|
+
function attachLightDismiss(dialog,closeFn) {
|
|
2000
|
+
if (!dialog||typeof dialog.addEventListener!=='function') return;
|
|
2001
|
+
if (globalThis.HTMLDialogElement && 'closedBy' in globalThis.HTMLDialogElement.prototype) return;
|
|
2002
|
+
const outside=(event)=>{
|
|
2003
|
+
const rect=dialog.getBoundingClientRect?.();
|
|
2004
|
+
if (!rect) return false;
|
|
2005
|
+
return event.clientX<rect.left||event.clientX>rect.right||event.clientY<rect.top||event.clientY>rect.bottom;
|
|
2006
|
+
};
|
|
2007
|
+
let pressedOutside=false;
|
|
2008
|
+
dialog.addEventListener('pointerdown',event=>{pressedOutside=outside(event);});
|
|
2009
|
+
dialog.addEventListener('pointerup',event=>{if (pressedOutside&&outside(event)) closeFn();});
|
|
1195
2010
|
}
|
|
1196
2011
|
|
|
1197
2012
|
$('brand-bee').append(HiveBee.sprite('coordinator',{coordinator:true}));
|
|
@@ -1201,10 +2016,9 @@
|
|
|
1201
2016
|
try {localStorage.setItem('team-board-color',theme);} catch {}
|
|
1202
2017
|
};
|
|
1203
2018
|
setTheme(initialTheme());
|
|
1204
|
-
const colorSchemeQuery=matchMedia('(prefers-color-scheme:light)');
|
|
1205
2019
|
colorSchemeQuery.addEventListener?.('change',event=>{
|
|
1206
2020
|
try {if (localStorage.getItem('team-board-color')) return;} catch {}
|
|
1207
|
-
setTheme(event.matches?'
|
|
2021
|
+
setTheme(event.matches?'dark':'light');
|
|
1208
2022
|
});
|
|
1209
2023
|
for (const [index,name] of tabs.entries()) {
|
|
1210
2024
|
const tab=$('tab-'+name);
|
|
@@ -1257,6 +2071,12 @@
|
|
|
1257
2071
|
finally {extendingBudget=false;button.disabled=false;$('extra-turns').disabled=false;}
|
|
1258
2072
|
}
|
|
1259
2073
|
$('extra-turns').onclick=event=>{if (event.isTrusted) return extendBudget($('extra-turns'));};
|
|
2074
|
+
$('close-lightbox').onclick=closeLightbox;
|
|
2075
|
+
$('screenshot-lightbox').oncancel=event=>{
|
|
2076
|
+
event.preventDefault();
|
|
2077
|
+
closeLightbox();
|
|
2078
|
+
};
|
|
2079
|
+
attachLightDismiss($('screenshot-lightbox'),closeLightbox);
|
|
1260
2080
|
if (standalone) {
|
|
1261
2081
|
$('close-transcript').onclick=closeTranscript;
|
|
1262
2082
|
$('refresh-transcript').onclick=refreshTranscript;
|
|
@@ -1264,6 +2084,7 @@
|
|
|
1264
2084
|
event.preventDefault();
|
|
1265
2085
|
closeTranscript();
|
|
1266
2086
|
};
|
|
2087
|
+
attachLightDismiss($('member-transcript'),closeTranscript);
|
|
1267
2088
|
const select=$('recent-teams');
|
|
1268
2089
|
select.onfocus=loadRecentTeams;
|
|
1269
2090
|
select.onchange=()=>{
|
|
@@ -1313,7 +2134,10 @@
|
|
|
1313
2134
|
nextTick();
|
|
1314
2135
|
};
|
|
1315
2136
|
$('clear-node').onclick=()=>{focusedNode=null;scheduleGraph();};
|
|
2137
|
+
$('graph-mode-hive').onclick=()=>setGraphMode('hive');
|
|
2138
|
+
$('graph-mode-mentions').onclick=()=>setGraphMode('mentions');
|
|
1316
2139
|
$('hide-inactive').onchange=$('expand-all').onchange=scheduleGraph;
|
|
2140
|
+
$('export-gif').onclick=exportGif;
|
|
1317
2141
|
const observer=new ResizeObserver(scheduleGraph);
|
|
1318
2142
|
observer.observe($('graph-stage'));
|
|
1319
2143
|
function refreshLanding() {
|
|
@@ -1356,7 +2180,7 @@
|
|
|
1356
2180
|
}
|
|
1357
2181
|
});
|
|
1358
2182
|
rpc('ui/initialize',{
|
|
1359
|
-
appInfo:{name:'Hive Swarm',version:globalThis.__HIVE_SWARM_VERSION__||'1.
|
|
2183
|
+
appInfo:{name:'Hive Swarm',version:globalThis.__HIVE_SWARM_VERSION__||'2.1.0'},appCapabilities:{},protocolVersion:'2026-01-26',
|
|
1360
2184
|
}).then(()=>{
|
|
1361
2185
|
parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/initialized',params:{}},'*');
|
|
1362
2186
|
refresh();
|