cladogram 0.6.0-beta.3 → 0.6.0-beta.5

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.
@@ -268,12 +268,21 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
268
268
  position: absolute;
269
269
  inset: 0;
270
270
  display: flex;
271
+ flex-direction: column;
271
272
  align-items: center;
272
273
  justify-content: center;
274
+ gap: 16px;
273
275
  padding: 64px 28px 28px;
274
276
  background: transparent;
277
+ overflow-y: auto;
275
278
  z-index: 12;
276
279
  }
280
+ .empty-state > p {
281
+ margin: 0;
282
+ font-size: 13.5px;
283
+ color: var(--clado-ui-muted, var(--muted));
284
+ text-align: center;
285
+ }
277
286
  .clado-empty-card {
278
287
  width: min(720px, calc(100% - 32px));
279
288
  border-radius: 26px;
@@ -285,6 +294,7 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
285
294
  border: 1px solid var(--clado-ui-glass-outline);
286
295
  box-shadow: var(--clado-ui-glass-shadow);
287
296
  text-align: left;
297
+ flex: none;
288
298
  }
289
299
  .clado-prism-aura-under {
290
300
  position: absolute;
@@ -331,6 +341,135 @@ iframe { height: 100%; width: 100%; display: block; border: 0; background: trans
331
341
  box-shadow: var(--clado-ui-prism-shadow);
332
342
  }
333
343
 
344
+ /* Discovered Sub-Workspaces Grid inside Empty State */
345
+ .empty-workspaces {
346
+ margin-top: 20px;
347
+ padding-top: 18px;
348
+ border-top: 1px solid var(--clado-ui-edge, var(--line));
349
+ display: flex;
350
+ flex-direction: column;
351
+ gap: 12px;
352
+ text-align: left;
353
+ }
354
+ .empty-state > .empty-workspaces {
355
+ margin-top: 0;
356
+ width: min(720px, calc(100% - 32px));
357
+ padding: 24px 26px;
358
+ border-radius: 24px;
359
+ background: var(--clado-ui-surface);
360
+ backdrop-filter: blur(24px) saturate(190%) brightness(1.03);
361
+ -webkit-backdrop-filter: blur(24px) saturate(190%) brightness(1.03);
362
+ border: 1px solid var(--clado-ui-glass-outline, var(--line));
363
+ box-shadow: var(--clado-ui-glass-shadow);
364
+ }
365
+ .empty-workspaces-head {
366
+ display: flex;
367
+ align-items: center;
368
+ justify-content: space-between;
369
+ gap: 10px;
370
+ }
371
+ .empty-workspaces-title {
372
+ font-size: 12.5px;
373
+ font-weight: 620;
374
+ color: var(--clado-ui-text-soft, var(--ink));
375
+ letter-spacing: -0.01em;
376
+ }
377
+ .empty-workspaces-count {
378
+ font-size: 11px;
379
+ font-weight: 560;
380
+ color: var(--clado-ui-muted, var(--muted));
381
+ padding: 2px 8px;
382
+ border-radius: 999px;
383
+ background: var(--clado-ui-well);
384
+ border: 1px solid var(--clado-ui-well-border, var(--line));
385
+ }
386
+ .empty-workspaces-grid {
387
+ display: grid;
388
+ grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
389
+ gap: 10px;
390
+ max-height: 230px;
391
+ overflow-y: auto;
392
+ padding: 2px 2px 4px;
393
+ }
394
+ .empty-workspace-card {
395
+ display: flex;
396
+ align-items: center;
397
+ gap: 10px;
398
+ padding: 11px 13px;
399
+ border-radius: 14px;
400
+ background: var(--clado-ui-well);
401
+ border: 1px solid var(--clado-ui-well-border, var(--line));
402
+ box-shadow: inset 0 1px 0 var(--clado-ui-highlight, rgba(255, 255, 255, 0.5));
403
+ color: var(--clado-ui-text, var(--ink));
404
+ text-decoration: none;
405
+ min-width: 0;
406
+ transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 150ms ease, border-color 150ms ease, box-shadow 160ms ease;
407
+ }
408
+ .empty-workspace-card:hover {
409
+ transform: translateY(-1.5px);
410
+ background: var(--clado-ui-hover);
411
+ border-color: var(--clado-ui-prism-border, var(--clado-ui-hover-border));
412
+ box-shadow: 0 10px 24px -12px rgba(56, 189, 248, 0.22), inset 0 1px 0 var(--clado-ui-highlight, rgba(255, 255, 255, 0.6));
413
+ }
414
+ .empty-workspace-card:focus-visible {
415
+ outline: 2px solid var(--accent);
416
+ outline-offset: 2px;
417
+ }
418
+ .empty-workspace-ico {
419
+ width: 30px;
420
+ height: 30px;
421
+ border-radius: 9px;
422
+ flex: none;
423
+ display: inline-flex;
424
+ align-items: center;
425
+ justify-content: center;
426
+ background: var(--clado-ui-prism-bg, rgba(56, 189, 248, 0.12));
427
+ border: 1px solid var(--clado-ui-prism-border, rgba(56, 189, 248, 0.24));
428
+ color: var(--accent);
429
+ }
430
+ .empty-workspace-ico svg {
431
+ width: 15px;
432
+ height: 15px;
433
+ stroke: currentColor;
434
+ fill: none;
435
+ stroke-width: 1.85;
436
+ stroke-linecap: round;
437
+ stroke-linejoin: round;
438
+ }
439
+ .empty-workspace-meta {
440
+ min-width: 0;
441
+ flex: 1;
442
+ display: flex;
443
+ flex-direction: column;
444
+ gap: 2px;
445
+ }
446
+ .empty-workspace-name {
447
+ font-size: 12.5px;
448
+ font-weight: 600;
449
+ color: var(--clado-ui-text, var(--ink));
450
+ overflow: hidden;
451
+ text-overflow: ellipsis;
452
+ white-space: nowrap;
453
+ }
454
+ .empty-workspace-card small {
455
+ font-size: 11px;
456
+ color: var(--clado-ui-muted, var(--muted));
457
+ line-height: 1.3;
458
+ }
459
+ .empty-workspace-arrow {
460
+ flex: none;
461
+ width: 14px;
462
+ height: 14px;
463
+ color: var(--clado-ui-subtle, var(--muted));
464
+ opacity: 0.65;
465
+ transition: transform 160ms ease, opacity 160ms ease, color 160ms ease;
466
+ }
467
+ .empty-workspace-card:hover .empty-workspace-arrow {
468
+ opacity: 1;
469
+ color: var(--accent);
470
+ transform: translateX(2px);
471
+ }
472
+
334
473
  /* Toast */
335
474
  .clado-toast {
336
475
  position: absolute;
@@ -181,7 +181,6 @@
181
181
  },
182
182
  clearFocus: () => frame.contentWindow.CladoRuntime?.clearFocus(),
183
183
  showDiagnostics: () => frame.contentWindow.CladoCanvasControls?.showDiagnostics(),
184
- openHandoff: !offline && config.agent ? () => window.CladoVNext?.openHandoff?.() : null,
185
184
  });
186
185
  const directory = window.CladoDirectoryPlugin(host, {
187
186
  showFilename: settings['clado.directory']?.showFilename !== false,
@@ -574,6 +573,9 @@
574
573
  renderLobbyView(cachedHubData || {});
575
574
  }
576
575
 
576
+ let discoveredWorkspaces = [];
577
+ let emptyWorkspaceSignature = '';
578
+
577
579
  function renderEmptyOnboarding(profile = {}) {
578
580
  const emptyEl = $('#emptyState');
579
581
  if (!emptyEl) return;
@@ -627,6 +629,10 @@
627
629
  showToast('主架构师正在分析源码并绘制画布…');
628
630
  window.CladoVNext?.startCodeAnalysis?.(selectedTpl);
629
631
  };
632
+ if (discoveredWorkspaces.length) {
633
+ emptyWorkspaceSignature = '';
634
+ renderEmptyWorkspaces(discoveredWorkspaces);
635
+ }
630
636
  }
631
637
 
632
638
  if (config.canSwitchWorkspace && !offline) {
@@ -992,14 +998,10 @@
992
998
  selectionBarEl.innerHTML = `
993
999
  <span class="clado-selection-dot"></span>
994
1000
  <span class="clado-selection-text" data-sel-summary>已选 0 项</span>
995
- <button type="button" class="clado-selection-send" data-sel-dev>交给开发落地</button>
996
- <button type="button" class="clado-selection-secondary" data-sel-qa>生成并跑测试</button>
1001
+ <button type="button" class="clado-selection-send" data-sel-send>发给当前会话</button>
997
1002
  <button type="button" class="clado-selection-clear" data-sel-clear>完成</button>`;
998
- selectionBarEl.querySelector('[data-sel-dev]').onclick = () => {
999
- window.CladoVNext?.triggerHandoff?.('developer');
1000
- };
1001
- selectionBarEl.querySelector('[data-sel-qa]').onclick = () => {
1002
- window.CladoVNext?.triggerHandoff?.('tester');
1003
+ selectionBarEl.querySelector('[data-sel-send]').onclick = () => {
1004
+ window.CladoVNext?.focusComposer?.();
1003
1005
  };
1004
1006
  selectionBarEl.querySelector('[data-sel-clear]').onclick = () => {
1005
1007
  objectSelection.clear();
@@ -1492,35 +1494,64 @@
1492
1494
  if(!chainModal) { const force=deferredRefresh;deferredRefresh=false;scan(force); }
1493
1495
  }
1494
1496
  function renderDirectory() { directory.update(index, selected, history.length > 0); }
1495
- let emptyWorkspaceSignature = '';
1496
1497
  function renderEmptyWorkspaces(list) {
1497
- const others = list.filter(item => item.id !== workspaceId);
1498
+ discoveredWorkspaces = Array.isArray(list) ? list : [];
1499
+ const others = discoveredWorkspaces.filter(item => item.id !== workspaceId);
1498
1500
  const next = JSON.stringify(others.map(item => [item.id, item.name, item.documents]));
1499
- if (next === emptyWorkspaceSignature) return;
1501
+ if (next === emptyWorkspaceSignature && $('#emptyState .empty-workspaces')) return;
1500
1502
  emptyWorkspaceSignature = next;
1501
1503
  let container = $('#emptyState .empty-workspaces');
1502
1504
  if (!others.length) { container?.remove(); return; }
1505
+ const hostEl = $('#emptyState .clado-empty-card') || $('#emptyState .clado-launchpad-card') || $('#emptyState');
1503
1506
  if (!container) {
1504
1507
  container = document.createElement('div');
1505
1508
  container.className = 'empty-workspaces';
1506
- ($('#emptyState .clado-launchpad-card') || $('#emptyState')).append(container);
1509
+ hostEl.append(container);
1510
+ } else if (container.parentElement !== hostEl) {
1511
+ hostEl.append(container);
1507
1512
  }
1508
1513
  container.replaceChildren();
1514
+ const head = document.createElement('div');
1515
+ head.className = 'empty-workspaces-head';
1509
1516
  const title = document.createElement('div');
1510
1517
  title.className = 'empty-workspaces-title';
1511
- title.textContent = '已发现的子工作区(点击打开)';
1512
- container.append(title);
1518
+ title.textContent = '已发现的子工作区';
1519
+ const badge = document.createElement('span');
1520
+ badge.className = 'empty-workspaces-count';
1521
+ badge.textContent = `${others.length} 个工作区`;
1522
+ head.append(title, badge);
1523
+ container.append(head);
1524
+
1525
+ const grid = document.createElement('div');
1526
+ grid.className = 'empty-workspaces-grid';
1513
1527
  for (const item of others) {
1514
1528
  const link = document.createElement('a');
1515
1529
  link.className = 'empty-workspace-card';
1516
1530
  link.href = workspaceUrl(item.id);
1531
+ const label = item.id || (item.name + '(根目录)');
1532
+ link.title = label;
1533
+
1534
+ const ico = document.createElement('span');
1535
+ ico.className = 'empty-workspace-ico';
1536
+ ico.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>';
1537
+
1538
+ const meta = document.createElement('span');
1539
+ meta.className = 'empty-workspace-meta';
1517
1540
  const name = document.createElement('span');
1518
- name.textContent = item.id || (item.name + '(根目录)');
1541
+ name.className = 'empty-workspace-name';
1542
+ name.textContent = label;
1519
1543
  const count = document.createElement('small');
1520
1544
  count.textContent = (item.documents ?? 0) + ' 份画布';
1521
- link.append(name, count);
1522
- container.append(link);
1545
+ meta.append(name, count);
1546
+
1547
+ const arrow = document.createElement('span');
1548
+ arrow.className = 'empty-workspace-arrow';
1549
+ arrow.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>';
1550
+
1551
+ link.append(ico, meta, arrow);
1552
+ grid.append(link);
1523
1553
  }
1554
+ container.append(grid);
1524
1555
  }
1525
1556
  let renderRequest = 0;
1526
1557
  async function openFromCapability(file) {
@@ -1803,6 +1834,15 @@
1803
1834
  openCodeDrawerFile(data.ref);
1804
1835
  return;
1805
1836
  }
1837
+ if (data?.type === 'clado-library:presence-click') {
1838
+ if (data.sessionId || data.roleId) {
1839
+ window.dispatchEvent(new CustomEvent('clado:focus-session', {
1840
+ detail: { sessionId: data.sessionId || '', roleId: data.roleId || '' },
1841
+ }));
1842
+ }
1843
+ if (data.codePath) openCodeDrawerFile(data.codePath);
1844
+ return;
1845
+ }
1806
1846
  if (data?.type === 'clado-library:chain-modal') { chainLock(data.value, data.mode); return; }
1807
1847
  if (data?.type === 'clado-library:lens-modal') {
1808
1848
  lensOpen = !!data.value;
@@ -1835,6 +1875,7 @@
1835
1875
  }
1836
1876
  showSelection();
1837
1877
  syncFrameObjects();
1878
+ syncPresenceConfigToCanvas();
1838
1879
  if(offline){frame.contentWindow.postMessage({type:'clado-workspace:display',mode,theme:design.theme,anchor:pendingAnchor},'*');pendingAnchor='';}
1839
1880
  else if (mode !== data.mode) frame.contentWindow.CladoPrototype?.setMode?.(mode);
1840
1881
  saveView(); $('#canvasLoading').hidden = true; syncChrome();
@@ -1851,6 +1892,29 @@
1851
1892
  status('已同步 ' + new Date(index.documents.find(d => d.file === selected)?.modified || Date.now()).toLocaleTimeString('zh-CN', { hour12: false })); post('ready');
1852
1893
  }
1853
1894
  });
1895
+ function readPresenceAfterglowMs() {
1896
+ try {
1897
+ const raw = localStorage.getItem('clado-presence-ttl');
1898
+ if (raw !== null && raw !== '') {
1899
+ const sec = Number(raw);
1900
+ if (Number.isFinite(sec) && sec >= 0) return Math.round(sec * 1000);
1901
+ }
1902
+ } catch {}
1903
+ return 15000;
1904
+ }
1905
+ function syncPresenceConfigToCanvas(overrideMs) {
1906
+ if (readyCanvas?.frame !== frame) return;
1907
+ const afterglowMs = typeof overrideMs === 'number' && Number.isFinite(overrideMs) ? overrideMs : readPresenceAfterglowMs();
1908
+ try {
1909
+ frame.contentWindow.postMessage({
1910
+ type: 'clado-workspace:presence-config',
1911
+ config: { afterglowMs },
1912
+ }, offline ? '*' : location.origin);
1913
+ } catch {}
1914
+ }
1915
+ addEventListener('clado:presence-config', ev => {
1916
+ syncPresenceConfigToCanvas(ev.detail?.afterglowMs);
1917
+ });
1854
1918
  function setDesign(next) { design = { ...design, ...next }; document.documentElement.dataset.theme = design.theme || 'light'; if (design.accent) document.documentElement.style.setProperty('--accent', design.accent); try { frame.contentWindow.CladoPrototype?.setDesign(design); } catch {} syncChrome(); }
1855
1919
  window.CladoPrototype = { setDesign, fit: () => frame.contentWindow.CladoPrototype?.fit(), closeLens: () => frame.contentWindow.CladoPrototype?.closeLens() };
1856
1920
  setDesign(design);
@@ -1885,6 +1949,14 @@
1885
1949
  }
1886
1950
  } catch {}
1887
1951
  });
1952
+ es.addEventListener('agent.presence', event => {
1953
+ try {
1954
+ const payload = JSON.parse(event.data || '{}');
1955
+ if (readyCanvas?.frame === frame && (!payload.file || payload.file === selected || payload.phase === 'afterglow' || payload.phase === 'clear')) {
1956
+ frame.contentWindow.postMessage({ type: 'clado-workspace:presence', presence: payload }, location.origin);
1957
+ }
1958
+ } catch {}
1959
+ });
1888
1960
  es.addEventListener('agent.focus', event => {
1889
1961
  try {
1890
1962
  const payload = JSON.parse(event.data || '{}');
@@ -1926,7 +1998,7 @@
1926
1998
  } catch {}
1927
1999
  });
1928
2000
  es.onerror = () => { sseReady = false; pushDebugLog('sse', 'SSE 连接中断,正在重试'); };
1929
- for (const evtName of ['ready', 'doc.updated', 'agent.activity', 'agent.stage', 'canvas.draft', 'code.activity', 'code.diff']) {
2001
+ for (const evtName of ['ready', 'doc.updated', 'agent.activity', 'agent.presence', 'agent.stage', 'canvas.draft', 'code.activity', 'code.diff']) {
1930
2002
  es.addEventListener(evtName, ev => pushDebugLog('sse', evtName + (ev.data ? ' ' + String(ev.data).slice(0, 140) : '')));
1931
2003
  }
1932
2004
  addEventListener('pagehide', () => es.close());
@@ -31,7 +31,12 @@ import {
31
31
  import { readFileGitState, readWorkspaceCodeFile, resolveSymbolInWorkspace } from './code-inspect.js';
32
32
  import { z } from 'zod/v4';
33
33
  const assets = join(dirname(fileURLToPath(import.meta.url)), 'assets');
34
- const resourceTypes = {png:'image/png',jpg:'image/jpeg',jpeg:'image/jpeg',gif:'image/gif',webp:'image/webp',svg:'image/svg+xml',pdf:'application/pdf',txt:'text/plain',csv:'text/csv',json:'application/json'};
34
+ const resourceTypes = {
35
+ png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', svg: 'image/svg+xml',
36
+ pdf: 'application/pdf', txt: 'text/plain', csv: 'text/csv', json: 'application/json',
37
+ mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime', ogv: 'video/ogg',
38
+ mp3: 'audio/mpeg', wav: 'audio/wav', m4a: 'audio/mp4', ogg: 'audio/ogg', flac: 'audio/flac',
39
+ };
35
40
  const types = { html: 'text/html', css: 'text/css', js: 'text/javascript', json: 'application/json', md: 'text/markdown' };
36
41
  const REMOTE_COOKIE = 'clado_remote_token';
37
42