cladogram 0.5.5-beta.9 → 0.6.0-beta.2

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.
@@ -45,65 +45,131 @@
45
45
  if (write) reloadWithMode(id !== 'clado.view-controls');
46
46
  return result;
47
47
  }
48
- const brand = ui.mountBrand(host, {
49
- plugins: {
50
- items, isEnabled,
51
- edit: config.hasPluginSettings ? editPluginSettings : null,
52
- install: config.canInstallPlugins && (async files => {
53
- const response = await fetch(withWorkspace('/library/install-plugin'), {
54
- method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ files }),
55
- });
56
- const result = await response.json();
57
- if (!response.ok) throw new Error(result.error);
58
- return result;
59
- }),
60
- refresh: () => reloadWithMode(true),
61
- save(disabled) {
62
- const next = new Set(disabledPlugins);
63
- for (const plugin of items) {
64
- if (plugin.reason) continue;
65
- if (disabled.includes(plugin.id)) next.add(plugin.id);
66
- else next.delete(plugin.id);
48
+ const stageEl = document.getElementById?.('clado-stage') || document.body;
49
+ const viewportEl = document.getElementById?.('clado-viewport') || null;
50
+
51
+ // ============ Toast Notification ============
52
+ let toastTimer = null;
53
+ function showToast(msg) {
54
+ const el = document.getElementById?.('clado-toast');
55
+ if (!el || !msg) return;
56
+ el.innerHTML = '<span class="clado-dot-sky"></span><span></span>';
57
+ el.querySelector('span:last-child').textContent = String(msg);
58
+ el.classList.add('show');
59
+ clearTimeout(toastTimer);
60
+ toastTimer = setTimeout(() => el.classList.remove('show'), 2400);
61
+ }
62
+ window.addEventListener?.('clado:toast', ev => showToast(ev.detail?.message));
63
+
64
+ // ============ Mobile Proportional Scale-to-Fit Stage (Zero Squish!) ============
65
+ if (viewportEl && stageEl && stageEl.id === 'clado-stage') {
66
+ const STAGE_W = 1280, STAGE_H = 820;
67
+ const mzLabel = document.querySelector('[data-mz-fit]');
68
+ let isScaled = false, fitScale = 1, curScale = 1, panX = 0, panY = 0;
69
+
70
+ const applyStageTransform = () => {
71
+ if (!isScaled) { stageEl.style.transform = ''; return; }
72
+ stageEl.style.transform = `translate3d(${panX.toFixed(1)}px, ${panY.toFixed(1)}px, 0) scale(${curScale.toFixed(4)})`;
73
+ if (mzLabel) mzLabel.textContent = Math.round(curScale * 100) + '%';
74
+ };
75
+
76
+ const resetMobileFit = () => {
77
+ const vw = window.innerWidth, vh = window.innerHeight;
78
+ if (vw >= 1160) {
79
+ isScaled = false;
80
+ viewportEl.classList.remove('scaled-mode');
81
+ stageEl.style.transform = '';
82
+ return;
83
+ }
84
+ isScaled = true;
85
+ viewportEl.classList.add('scaled-mode');
86
+ const padX = 12, padTop = 14, padBottom = 58;
87
+ fitScale = Math.min((vw - padX * 2) / STAGE_W, (vh - padTop - padBottom) / STAGE_H);
88
+ curScale = fitScale;
89
+ panX = (vw - STAGE_W * curScale) / 2;
90
+ panY = padTop + Math.max(0, (vh - padTop - padBottom - STAGE_H * curScale) / 2);
91
+ applyStageTransform();
92
+ };
93
+
94
+ const stepZoom = delta => {
95
+ if (!isScaled) return;
96
+ const vw = window.innerWidth, vh = window.innerHeight;
97
+ const next = Math.max(fitScale * 0.85, Math.min(1.6, curScale + delta));
98
+ const ratio = next / curScale;
99
+ panX = vw / 2 - (vw / 2 - panX) * ratio;
100
+ panY = vh / 2 - (vh / 2 - panY) * ratio;
101
+ curScale = next;
102
+ applyStageTransform();
103
+ };
104
+
105
+ document.querySelector('[data-mz-out]')?.addEventListener('click', () => stepZoom(-0.15));
106
+ document.querySelector('[data-mz-in]')?.addEventListener('click', () => stepZoom(0.15));
107
+ mzLabel?.addEventListener('click', resetMobileFit);
108
+
109
+ const ptrs = new Map();
110
+ let lastDist = null, lastDrag = null;
111
+ viewportEl.addEventListener('pointerdown', e => {
112
+ if (!isScaled || e.target.closest('#clado-mobile-zoom-hud')) return;
113
+ ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
114
+ if (ptrs.size === 1) lastDrag = { x: e.clientX, y: e.clientY };
115
+ else if (ptrs.size === 2) {
116
+ const p = [...ptrs.values()];
117
+ lastDist = Math.hypot(p[0].x - p[1].x, p[0].y - p[1].y);
118
+ }
119
+ });
120
+ viewportEl.addEventListener('pointermove', e => {
121
+ if (!isScaled || !ptrs.has(e.pointerId)) return;
122
+ ptrs.set(e.pointerId, { x: e.clientX, y: e.clientY });
123
+ if (ptrs.size === 2) {
124
+ const p = [...ptrs.values()];
125
+ const dist = Math.hypot(p[0].x - p[1].x, p[0].y - p[1].y);
126
+ const mx = (p[0].x + p[1].x) / 2, my = (p[0].y + p[1].y) / 2;
127
+ if (lastDist && dist > 10) {
128
+ const next = Math.max(fitScale * 0.85, Math.min(1.8, curScale * (dist / lastDist)));
129
+ const ratio = next / curScale;
130
+ panX = mx - (mx - panX) * ratio;
131
+ panY = my - (my - panY) * ratio;
132
+ curScale = next;
133
+ applyStageTransform();
67
134
  }
68
- localStorage.setItem(pluginKey, JSON.stringify([...next]));
69
- reloadWithMode(true);
70
- },
71
- },
72
- market: config.canInstallPlugins ? {
73
- load: async () => {
74
- const response = await fetch(withWorkspace('/library/plugin-registry'), { cache: 'no-store' });
75
- const result = await response.json();
76
- if (!response.ok) throw new Error(result.error || '加载插件市场失败');
77
- return result;
78
- },
79
- install: async id => {
80
- const response = await fetch(withWorkspace('/library/plugin-registry'), {
81
- method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id }),
82
- });
83
- const result = await response.json();
84
- if (!response.ok) throw new Error(result.error || '安装失败');
85
- return result;
86
- },
87
- uninstall: async id => {
88
- const response = await fetch(withWorkspace('/library/install-plugin?id=' + encodeURIComponent(id)), {
89
- method: 'DELETE',
90
- });
91
- const result = await response.json();
92
- if (!response.ok) throw new Error(result.error || '卸载失败');
93
- return result;
94
- },
95
- } : null,
96
- openWorkspacePicker: config.canSwitchWorkspace && !offline ? () => openWorkspacePicker() : null,
97
- setTheme: theme => {
98
- if (modalLocked()) return;
99
- try { localStorage.setItem('clado-theme', theme); } catch {}
100
- setDesign({ theme });
101
- post('theme', { theme });
102
- },
103
- capture: screenshot && settings['clado.brand']?.showScreenshot !== false && (async () => {
104
- try { await screenshot.download(await screenshot.capture({}, readScreenshotCanvas)); }
105
- catch (error) { directory.showMessage('截图失败', error.message); }
106
- }),
135
+ lastDist = dist;
136
+ } else if (ptrs.size === 1 && lastDrag && curScale > fitScale * 1.05) {
137
+ const dx = e.clientX - lastDrag.x, dy = e.clientY - lastDrag.y;
138
+ if (Math.hypot(dx, dy) > 2) {
139
+ panX += dx; panY += dy;
140
+ lastDrag = { x: e.clientX, y: e.clientY };
141
+ applyStageTransform();
142
+ }
143
+ }
144
+ });
145
+ const dropPtr = e => {
146
+ ptrs.delete(e.pointerId);
147
+ if (ptrs.size < 2) lastDist = null;
148
+ if (ptrs.size === 0) lastDrag = null;
149
+ };
150
+ viewportEl.addEventListener('pointerup', dropPtr);
151
+ viewportEl.addEventListener('pointercancel', dropPtr);
152
+ window.addEventListener('resize', resetMobileFit);
153
+ resetMobileFit();
154
+ }
155
+
156
+ const applyTheme = theme => {
157
+ if (modalLocked()) return;
158
+ try { localStorage.setItem('clado-theme', theme); } catch {}
159
+ setDesign({ theme });
160
+ post('theme', { theme });
161
+ };
162
+ const captureShot = screenshot && settings['clado.brand']?.showScreenshot !== false ? (async () => {
163
+ try { await screenshot.download(await screenshot.capture({}, readScreenshotCanvas)); }
164
+ catch (error) { directory.showMessage('截图失败', error.message); }
165
+ }) : null;
166
+
167
+ const brand = ui.mountBrand(host, {
168
+ workspaceName: config.workspaceName || 'clado',
169
+ openLobby: config.canSwitchWorkspace && !offline ? () => openLobby() : null,
170
+ openSettings: !offline && config.agent ? () => window.CladoVNext?.openSettings?.('extensions') : null,
171
+ setTheme: applyTheme,
172
+ capture: captureShot,
107
173
  });
108
174
  const updateControls = ui.mountViewControls(host, {
109
175
  setMode: next => {
@@ -115,6 +181,7 @@
115
181
  },
116
182
  clearFocus: () => frame.contentWindow.CladoRuntime?.clearFocus(),
117
183
  showDiagnostics: () => frame.contentWindow.CladoCanvasControls?.showDiagnostics(),
184
+ openHandoff: !offline && config.agent ? () => window.CladoVNext?.openHandoff?.() : null,
118
185
  });
119
186
  const directory = window.CladoDirectoryPlugin(host, {
120
187
  showFilename: settings['clado.directory']?.showFilename !== false,
@@ -122,7 +189,7 @@
122
189
  openFromCapability,
123
190
  workspaceUrl,
124
191
  switchWorkspace: id => { location.href = workspaceUrl(id); },
125
- openWorkspacePicker: config.canSwitchWorkspace && !offline ? () => openWorkspacePicker() : null,
192
+ openWorkspacePicker: config.canSwitchWorkspace && !offline ? () => openLobby() : null,
126
193
  createCanvas: config.canSwitchWorkspace && !offline ? () => createCanvasFlow() : null,
127
194
  renameCanvas: config.canSwitchWorkspace && !offline ? doc => renameCanvasFlow(doc) : null,
128
195
  deleteCanvas: config.canSwitchWorkspace && !offline ? doc => deleteCanvasFlow(doc) : null,
@@ -232,65 +299,59 @@
232
299
  location.href = '/';
233
300
  }
234
301
 
302
+ const escHtml = s => String(s ?? '').replace(/[&<>"']/g, m => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[m]));
303
+ const lobbyEl = document.getElementById?.('clado-lobby') || null;
304
+ let lobbySearchQuery = '';
305
+ let cachedHubData = null;
306
+
235
307
  function ensureWorkspacePicker() {
236
- if (wsPickerOverlay || !document.body) return wsPickerOverlay;
308
+ if (wsPickerOverlay || !stageEl) return wsPickerOverlay;
237
309
  wsPickerOverlay = document.createElement('div');
238
310
  wsPickerOverlay.id = 'clado-workspace-picker';
239
- wsPickerOverlay.className = 'clado-market-overlay';
311
+ wsPickerOverlay.className = 'clado-vnext-mask';
312
+ wsPickerOverlay.hidden = true;
240
313
  wsPickerOverlay.innerHTML = `
241
- <div class="clado-market-sheet" style="max-width:500px;">
242
- <div class="clado-market-well" style="padding:12px 14px;display:flex;align-items:center;justify-content:space-between;gap:8px;">
314
+ <div class="clado-folder-sheet">
315
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;">
243
316
  <div>
244
- <strong style="font-size:15px;">选择或新建工作区</strong>
245
- <div data-ws-cur style="font-size:11px;color:var(--clado-ui-muted);margin-top:2px;"></div>
317
+ <div style="font-size:15.5px;font-weight:630;">打开本地目录或新建工作区</div>
318
+ <div data-ws-cur style="font-size:11.5px;color:var(--clado-ui-muted);margin-top:2px;font-family:ui-monospace,monospace;"></div>
246
319
  </div>
247
- <button type="button" class="clado-market-tab active" data-ws-close style="padding:5px 11px;">关闭</button>
248
- </div>
249
-
250
- <div class="clado-market-well" data-ws-recents-wrap style="padding:11px 12px;display:none;flex-direction:column;gap:5px;">
251
- <div style="font-size:11px;font-weight:650;color:var(--clado-ui-muted);">最近打开的项目</div>
252
- <div data-ws-recents style="display:flex;flex-direction:column;gap:3px;"></div>
320
+ <button type="button" class="clado-ui-button" data-ws-close style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">关闭</button>
253
321
  </div>
254
322
 
255
- <div class="clado-market-well" style="padding:11px 12px;display:flex;flex-direction:column;gap:8px;">
323
+ <div class="clado-well-box" style="padding:11px 12px;display:flex;flex-direction:column;gap:8px;">
256
324
  <div style="display:flex;align-items:center;justify-content:space-between;gap:6px;">
257
- <span style="font-size:11.5px;font-weight:650;color:var(--clado-ui-muted);">浏览本机目录</span>
258
- <div style="display:flex;gap:4px;">
259
- <button type="button" class="clado-market-tab active" data-ws-up style="font-size:11px;padding:3px 8px;">↑ 上级</button>
260
- <button type="button" class="clado-market-tab active" data-ws-home style="font-size:11px;padding:3px 8px;">⌂ 主目录</button>
325
+ <span style="font-size:11.5px;font-weight:610;color:var(--clado-ui-muted);">浏览本机文件夹</span>
326
+ <div style="display:flex;gap:5px;">
327
+ <button type="button" class="clado-ui-button" data-ws-up style="min-height:26px;font-size:11.5px;padding:3px 9px;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">上级</button>
328
+ <button type="button" class="clado-ui-button" data-ws-home style="min-height:26px;font-size:11.5px;padding:3px 9px;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">主目录</button>
261
329
  </div>
262
330
  </div>
263
- <div data-ws-browse-list style="max-height:190px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;"></div>
331
+ <div data-ws-browse-list style="max-height:210px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;"></div>
264
332
  </div>
265
333
 
266
- <div class="clado-market-well" style="padding:12px;display:flex;flex-direction:column;gap:8px;">
267
- <div style="font-size:11.5px;color:var(--clado-ui-muted);">目标工作区路径(回车浏览目录,或直接输入新目录路径自动创建)</div>
334
+ <div class="clado-well-box" style="padding:12px;display:flex;flex-direction:column;gap:8px;">
335
+ <div style="font-size:11.5px;color:var(--clado-ui-muted);">输入或选择项目路径(若目录不存在将自动新建)</div>
268
336
  <div style="display:flex;gap:6px;">
269
- <input type="text" data-ws-input style="flex:1;height:35px;padding:0 11px;border-radius:10px;border:1px solid var(--clado-ui-well-border);background:var(--clado-ui-well);color:var(--clado-ui-text);font:inherit;font-size:12.5px;outline:none;" placeholder="/path/to/your-project" />
270
- <button type="button" class="clado-market-tab active" data-ws-go style="height:35px;padding:0 11px;font-size:12px;">浏览</button>
337
+ <input type="text" class="clado-field" data-ws-input placeholder="/path/to/your-project" />
338
+ <button type="button" class="clado-ui-button" data-ws-go style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">定位</button>
271
339
  </div>
272
- <div data-ws-err style="font-size:11.5px;color:#e11d48;display:none;"></div>
273
- <div style="display:flex;gap:8px;flex-wrap:wrap;">
274
- <button type="button" class="clado-market-tab active" data-ws-open style="flex:1;height:35px;font-size:12.5px;">打开此目录</button>
275
- <button type="button" data-ws-init style="flex:1.2;height:35px;border:0;border-radius:10px;background:var(--clado-ui-brand);color:#fff;font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;">在此新建工作区并建首张画布</button>
340
+ <div data-ws-err style="font-size:11.5px;color:#be123c;display:none;"></div>
341
+ <div style="display:flex;gap:8px;margin-top:2px;">
342
+ <button type="button" class="clado-ui-button" data-ws-open style="flex:1;border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);">打开此目录</button>
343
+ <button type="button" class="clado-ui-button clado-ui-button-primary" data-ws-init style="flex:1.2;">打开并新建首张画布</button>
276
344
  </div>
277
345
  </div>
278
346
  </div>`;
279
- document.body.append(wsPickerOverlay);
347
+ stageEl.append(wsPickerOverlay);
280
348
 
281
- let parentDir = '';
282
- let homeDir = '';
349
+ let parentDir = '', homeDir = '';
283
350
  const curEl = wsPickerOverlay.querySelector('[data-ws-cur]');
284
- const recentsWrap = wsPickerOverlay.querySelector('[data-ws-recents-wrap]');
285
- const recentsList = wsPickerOverlay.querySelector('[data-ws-recents]');
286
351
  const browseList = wsPickerOverlay.querySelector('[data-ws-browse-list]');
287
352
  const pathInput = wsPickerOverlay.querySelector('[data-ws-input]');
288
353
  const errEl = wsPickerOverlay.querySelector('[data-ws-err]');
289
-
290
- const showErr = msg => {
291
- errEl.textContent = msg || '';
292
- errEl.style.display = msg ? 'block' : 'none';
293
- };
354
+ const showErr = msg => { errEl.textContent = msg || ''; errEl.style.display = msg ? 'block' : 'none'; };
294
355
 
295
356
  const loadDir = async (dir = '') => {
296
357
  showErr('');
@@ -299,69 +360,43 @@
299
360
  const res = await fetch('/library/fs-workspaces' + qs, { cache: 'no-store' });
300
361
  const data = await res.json();
301
362
  if (!res.ok) throw new Error(data.error || '读取目录失败');
363
+ cachedHubData = data;
302
364
  parentDir = data.parentDir || '';
303
365
  homeDir = data.homeDir || '';
304
- curEl.textContent = data.hubMode ? '请选择一个项目目录开始协作' : `当前:${data.currentWorkspace}`;
366
+ curEl.textContent = data.currentDir || data.currentWorkspace || '';
305
367
  pathInput.value = data.currentDir || data.currentWorkspace || '';
306
368
 
307
- const recents = Array.isArray(data.recentWorkspaces) ? data.recentWorkspaces : [];
308
- if (recents.length) {
309
- recentsWrap.style.display = 'flex';
310
- recentsList.replaceChildren();
311
- for (const r of recents.slice(0, 5)) {
312
- const row = document.createElement('button');
313
- row.type = 'button';
314
- row.className = 'clado-folder-row';
315
- row.innerHTML = `<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><strong>${r.name}</strong> <small style="color:var(--clado-ui-muted);">${r.path}</small></span><span style="font-size:11px;color:var(--clado-ui-brand);flex:none;">${r.documents ?? 0} 画布</span>`;
316
- row.onclick = () => applyWorkspaceSwitch(r.path, { createIfMissing: false }).catch(e => showErr(e.message));
317
- recentsList.append(row);
318
- }
319
- } else {
320
- recentsWrap.style.display = 'none';
321
- }
322
-
323
369
  browseList.replaceChildren();
324
370
  const entries = Array.isArray(data.entries) ? data.entries : [];
325
371
  if (!entries.length) {
326
372
  const empty = document.createElement('div');
327
- empty.style.cssText = 'padding:12px;text-align:center;color:var(--clado-ui-muted);font-size:12px;';
328
- empty.textContent = '当前文件夹下暂无子目录,可直接打开此目录或下方输入新子目录名新建。';
373
+ empty.style.cssText = 'padding:14px;text-align:center;color:var(--clado-ui-muted);font-size:12px;';
374
+ empty.textContent = '当前目录下无子文件夹,可直接打开此目录或输入新目录名。';
329
375
  browseList.append(empty);
330
376
  } else {
331
377
  for (const item of entries) {
332
378
  const row = document.createElement('button');
333
379
  row.type = 'button';
334
380
  row.className = 'clado-folder-row';
335
- row.dataset.folderPath = item.path;
336
381
  const badges = [
337
- item.hasClado ? '<span style="color:#059669;font-weight:600;">Clado</span>' : '',
338
- item.isGit ? '<span style="color:var(--clado-ui-muted);">Git</span>' : '',
339
- item.mdCount ? `<span>${item.mdCount} md</span>` : '',
340
- ].filter(Boolean).join(' · ');
341
- row.innerHTML = `<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">📁 ${item.name}</span><small style="color:var(--clado-ui-subtle);flex:none;">${badges || '进入 ›'}</small>`;
382
+ item.hasClado ? '<span class="clado-chip clado-chip-sky">Clado</span>' : '',
383
+ item.isGit ? '<span class="clado-chip clado-chip-neutral">Git</span>' : '',
384
+ ].filter(Boolean).join(' ');
385
+ row.innerHTML = `<span style="display:inline-flex;align-items:center;gap:7px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"><svg class="clado-svg-ico" style="color:var(--clado-ui-muted)" viewBox="0 0 24 24"><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>${escHtml(item.name)}</span><span style="display:inline-flex;gap:4px;flex:none;">${badges}</span>`;
342
386
  row.onclick = () => loadDir(item.path);
343
387
  browseList.append(row);
344
388
  }
345
389
  }
346
- } catch (err) {
347
- showErr(err.message || '读取目录失败');
348
- }
390
+ } catch (err) { showErr(err.message || '读取目录失败'); }
349
391
  };
350
392
 
351
393
  wsPickerOverlay.addEventListener('click', ev => {
352
- if (ev.target === wsPickerOverlay || ev.target.closest('[data-ws-close]')) {
353
- wsPickerOverlay.classList.remove('show');
354
- }
394
+ if (ev.target === wsPickerOverlay || ev.target.closest('[data-ws-close]')) wsPickerOverlay.hidden = true;
355
395
  });
356
396
  pathInput.addEventListener('keydown', ev => {
357
- if (ev.key === 'Enter') {
358
- ev.preventDefault();
359
- if (pathInput.value.trim()) loadDir(pathInput.value.trim());
360
- }
397
+ if (ev.key === 'Enter') { ev.preventDefault(); if (pathInput.value.trim()) loadDir(pathInput.value.trim()); }
361
398
  });
362
- wsPickerOverlay.querySelector('[data-ws-go]').onclick = () => {
363
- if (pathInput.value.trim()) loadDir(pathInput.value.trim());
364
- };
399
+ wsPickerOverlay.querySelector('[data-ws-go]').onclick = () => { if (pathInput.value.trim()) loadDir(pathInput.value.trim()); };
365
400
  wsPickerOverlay.querySelector('[data-ws-up]').onclick = () => { if (parentDir) loadDir(parentDir); };
366
401
  wsPickerOverlay.querySelector('[data-ws-home]').onclick = () => { if (homeDir) loadDir(homeDir); };
367
402
  wsPickerOverlay.querySelector('[data-ws-open]').onclick = () => {
@@ -375,52 +410,240 @@
375
410
  }
376
411
 
377
412
  function openWorkspacePicker(initialDir = '') {
378
- if (!config.canSwitchWorkspace || offline || !document.body) return;
413
+ if (!config.canSwitchWorkspace || offline) return;
379
414
  const modal = ensureWorkspacePicker();
380
415
  if (!modal) return;
381
- modal.classList.add('show');
416
+ modal.hidden = false;
382
417
  modal._loadDir(initialDir);
383
418
  }
384
419
 
385
- if (config.canSwitchWorkspace && !offline && document.body) {
386
- window.addEventListener('clado:open-workspace-picker', () => openWorkspacePicker());
387
- const emptyEl = $('#emptyState');
388
- if (emptyEl) {
389
- const wsTitle = config.hubMode ? '欢迎使用 Clado · 请先选择工作区' : `当前工作区:${config.workspaceName || '未命名项目'}`;
390
- const wsSub = config.hubMode
391
- ? '选择一个已有代码仓库或新建空白工作区,配置好模型供应商即可开始与多角色分身协作设计。'
392
- : `路径:${config.workspacePath || '.'} · 当前目录尚无画布文档,你可以一键新建首张画布或直接在右下角向 Agent 提问。`;
393
- emptyEl.style.padding = '0';
394
- emptyEl.innerHTML = `
395
- <div class="clado-launchpad-wrap">
396
- <div class="clado-launchpad-card">
420
+ function closeLobby() {
421
+ if (lobbyEl) lobbyEl.hidden = true;
422
+ }
423
+
424
+ function renderLobbyView(hubData) {
425
+ if (!lobbyEl) return;
426
+ const meta = window.CladoVNext?.getMeta?.() || {};
427
+ const recents = Array.isArray(hubData?.recentWorkspaces) ? hubData.recentWorkspaces : [];
428
+ const currentInRecents = recents.some(r => r.path === hubData?.currentWorkspace);
429
+ const allWorkspaces = [...recents];
430
+ if (!config.hubMode && hubData?.currentWorkspace && !currentInRecents) {
431
+ allWorkspaces.unshift({
432
+ path: hubData.currentWorkspace,
433
+ name: hubData.currentName || config.workspaceName || '当前项目',
434
+ gitBranch: hubData.currentProfile?.gitBranch || '',
435
+ codeFiles: hubData.currentProfile?.codeFiles || 0,
436
+ primaryLang: hubData.currentProfile?.primaryLang || '',
437
+ documents: index.documents.length,
438
+ });
439
+ }
440
+ const q = lobbySearchQuery.trim().toLowerCase();
441
+ const filtered = allWorkspaces.filter(w => !q || (w.name + ' ' + w.path).toLowerCase().includes(q));
442
+ const eco = meta.ecosystem || {};
443
+ const extCount = (eco.packages?.length || 0) + (eco.skills?.length || 0) + 1;
444
+ const mcpCount = eco.mcpServers?.length || 0;
445
+ const roleCount = meta.roles?.length || 4;
446
+ const activeModel = meta.activeModelLabel || '点击设置模型';
447
+
448
+ lobbyEl.innerHTML = `
449
+ <div class="clado-lobby-inner">
450
+ <header class="clado-lobby-head">
451
+ <div style="display:flex;align-items:center;gap:13px;">
452
+ <div class="clado-brand-gem">
453
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round">
454
+ <path d="M17 7.5A6.5 6.5 0 1 0 17 16.5"/>
455
+ <circle cx="17.5" cy="12" r="1.4" fill="currentColor" stroke="none"/>
456
+ </svg>
457
+ </div>
397
458
  <div>
398
- <div style="font-size:16px;font-weight:700;color:var(--clado-ui-text);">${wsTitle}</div>
399
- <div style="font-size:12px;line-height:1.55;color:var(--clado-ui-muted);margin-top:5px;">${wsSub}</div>
459
+ <div style="display:flex;align-items:center;gap:8px;">
460
+ <span style="font-size:19px;font-weight:640;letter-spacing:-0.02em;">clado</span>
461
+ <span class="clado-chip clado-chip-sky">Pi Engine</span>
462
+ </div>
463
+ <div style="font-size:12px;color:var(--clado-ui-muted);margin-top:2px;">空间画布设计 · 多角色编排 · 代码与测试交付</div>
400
464
  </div>
401
- <div class="clado-launchpad-actions">
402
- <button type="button" class="clado-launchpad-btn primary" data-lp-pick>
403
- <span><strong>📂 选择或切换本机工作区</strong><br/><small style="color:var(--clado-ui-muted);">浏览电脑目录、打开已有仓库或新建项目</small></span>
404
- <span style="color:var(--clado-ui-brand);font-weight:700;">›</span>
405
- </button>
406
- <button type="button" class="clado-launchpad-btn" data-lp-new-canvas>
407
- <span><strong>✨ 在当前工作区新建首张画布</strong><br/><small style="color:var(--clado-ui-muted);">立即创建初始架构画布进入三视图协作</small></span>
408
- <span style="opacity:.5;">+</span>
409
- </button>
410
- <button type="button" class="clado-launchpad-btn" data-lp-llm>
411
- <span><strong>⚙ 配置供应商与主力模型</strong><br/><small style="color:var(--clado-ui-muted);">支持 OpenAI / Anthropic / DeepSeek / OpenRouter / Ollama</small></span>
412
- <span style="opacity:.5;">›</span>
413
- </button>
465
+ </div>
466
+
467
+ <div style="display:flex;align-items:center;gap:10px;">
468
+ <div class="clado-ui-glass" style="display:flex;align-items:center;gap:8px;padding:7px 14px;border-radius:999px;width:230px;">
469
+ <svg class="clado-svg-ico" style="color:var(--clado-ui-subtle)" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
470
+ <input type="text" data-lobby-search value="${escHtml(lobbySearchQuery)}" placeholder="搜索项目工作区…" style="border:0;outline:0;background:transparent;width:100%;font-size:12.5px;color:var(--clado-ui-text);" />
471
+ </div>
472
+ <div class="clado-ui-glass" style="display:flex;align-items:center;gap:8px;padding:5px 7px 5px 13px;border-radius:999px;">
473
+ <span class="clado-dot-ok"></span>
474
+ <span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-text-soft);">${escHtml(activeModel)}</span>
475
+ <span class="clado-top-pill-sep"></span>
476
+ <button type="button" class="clado-ui-button" data-lobby-settings style="min-height:28px;padding:4px 10px;font-size:12px;">设置</button>
414
477
  </div>
415
478
  </div>
416
- </div>`;
417
- emptyEl.querySelector('[data-lp-pick]').onclick = () => openWorkspacePicker();
418
- emptyEl.querySelector('[data-lp-new-canvas]').onclick = () => createCanvasFlow('系统架构概览');
419
- emptyEl.querySelector('[data-lp-llm]').onclick = () => window.dispatchEvent(new CustomEvent('clado:open-llm-settings'));
420
- }
421
- if (config.hubMode) {
422
- setTimeout(() => openWorkspacePicker(), 60);
479
+ </header>
480
+
481
+ <div style="display:flex;align-items:flex-end;justify-content:space-between;gap:14px;">
482
+ <div>
483
+ <div style="font-size:24px;font-weight:640;letter-spacing:-0.025em;">工作区</div>
484
+ <div style="font-size:13px;color:var(--clado-ui-muted);margin-top:5px;">选择已有项目进入空间画布,或打开本地代码仓库一键梳理架构。</div>
485
+ </div>
486
+ <div style="display:flex;align-items:center;gap:10px;">
487
+ ${!config.hubMode ? '<button type="button" class="clado-ui-button" data-lobby-back style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);padding:8px 14px;border-radius:13px;">返回当前画布</button>' : ''}
488
+ <button type="button" class="clado-ui-button" data-lobby-open style="border-color:var(--clado-ui-well-border);background:var(--clado-ui-well);padding:8px 15px;border-radius:13px;">打开本地目录</button>
489
+ <button type="button" class="clado-ui-button clado-ui-button-primary" data-lobby-new style="padding:8px 16px;border-radius:13px;">+ 新建工作区</button>
490
+ </div>
491
+ </div>
492
+
493
+ <div class="clado-lobby-grid" data-lobby-cards></div>
494
+
495
+ <div class="clado-ui-glass" style="margin-top:26px;border-radius:18px;padding:13px 20px;display:flex;align-items:center;justify-content:space-between;font-size:12.5px;">
496
+ <div style="display:flex;align-items:center;gap:14px;">
497
+ <span style="display:inline-flex;align-items:center;gap:7px;font-weight:540;color:var(--clado-ui-text-soft);"><span class="clado-dot-ok"></span>Pi 1.0 运行时就绪</span>
498
+ <span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-subtle);">${escHtml(meta.agentDir || '~/.pi/agent')}</span>
499
+ <span class="clado-top-pill-sep"></span>
500
+ <span style="color:var(--clado-ui-muted);">${extCount} 个扩展 · ${mcpCount} 个 MCP · ${roleCount} 套角色</span>
501
+ </div>
502
+ <button type="button" class="clado-ui-button" data-lobby-ext style="min-height:28px;font-size:12px;">管理扩展与能力 →</button>
503
+ </div>
504
+ </div>
505
+ `;
506
+
507
+ const cardsWrap = lobbyEl.querySelector('[data-lobby-cards]');
508
+ if (!filtered.length) {
509
+ cardsWrap.innerHTML = `<div class="clado-well-box" style="grid-column:1/-1;padding:28px;text-align:center;color:var(--clado-ui-muted);">暂无最近工作区,点击右上角「打开本地目录」或「+ 新建工作区」立即开始。</div>`;
510
+ } else {
511
+ for (const w of filtered.slice(0, 9)) {
512
+ const card = document.createElement('button');
513
+ card.type = 'button';
514
+ card.className = 'clado-ws-card';
515
+ const initials = (w.name || 'WS').replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '').slice(0, 2).toUpperCase() || 'WS';
516
+ const needsAnalysis = (w.documents || 0) === 0 && (w.codeFiles || 0) > 0;
517
+ const badgeHtml = needsAnalysis
518
+ ? '<span class="clado-chip clado-chip-amber">待分析</span>'
519
+ : w.gitBranch
520
+ ? `<span class="clado-chip clado-chip-sky">${escHtml(w.gitBranch)}</span>`
521
+ : '<span class="clado-chip clado-chip-mint">工作区</span>';
522
+ const desc = needsAnalysis
523
+ ? `已检测到 ${escHtml(w.primaryLang || '本地')} 源码仓库(${w.codeFiles} 个文件),尚未生成架构画布,可一键分析出图。`
524
+ : (w.documents || 0) > 0
525
+ ? `包含 ${w.documents} 张空间画布${w.primaryLang ? ` · ${w.primaryLang} 工程` : ''},可继续梳理架构或交接交付。`
526
+ : '空白工作区,进入后可直接起稿画布或让角色协助拆解设计。';
527
+ card.innerHTML = `
528
+ <div>
529
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;">
530
+ <div style="display:flex;align-items:center;gap:11px;min-width:0;">
531
+ <div class="clado-ws-mono">${escHtml(initials)}</div>
532
+ <div style="min-width:0;">
533
+ <div style="font-size:14.5px;font-weight:620;color:var(--clado-ui-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${escHtml(w.name)}</div>
534
+ <div style="font-family:ui-monospace,monospace;font-size:11px;color:var(--clado-ui-subtle);margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${escHtml(w.path)}</div>
535
+ </div>
536
+ </div>
537
+ ${badgeHtml}
538
+ </div>
539
+ <p style="font-size:12.5px;line-height:1.62;color:var(--clado-ui-muted);margin:15px 0 0;">${desc}</p>
540
+ </div>
541
+ <div style="display:flex;align-items:center;justify-content:space-between;padding-top:13px;border-top:1px solid var(--clado-ui-edge);font-size:12px;">
542
+ <span style="color:var(--clado-ui-subtle);">${w.documents || 0} 张画布</span>
543
+ <span style="font-weight:560;color:var(--clado-ui-text-soft);">${needsAnalysis ? '分析并进入 →' : '进入 →'}</span>
544
+ </div>
545
+ `;
546
+ card.onclick = () => {
547
+ if (w.path === hubData?.currentWorkspace && !config.hubMode) {
548
+ closeLobby();
549
+ return;
550
+ }
551
+ applyWorkspaceSwitch(w.path, { createIfMissing: false }).catch(e => showToast(e.message));
552
+ };
553
+ cardsWrap.append(card);
554
+ }
423
555
  }
556
+
557
+ const searchInput = lobbyEl.querySelector('[data-lobby-search]');
558
+ searchInput.addEventListener('input', () => { lobbySearchQuery = searchInput.value; renderLobbyView(hubData); });
559
+ lobbyEl.querySelector('[data-lobby-settings]').onclick = () => window.CladoVNext?.openSettings?.('models');
560
+ lobbyEl.querySelector('[data-lobby-ext]').onclick = () => window.CladoVNext?.openSettings?.('extensions');
561
+ lobbyEl.querySelector('[data-lobby-open]').onclick = () => openWorkspacePicker();
562
+ lobbyEl.querySelector('[data-lobby-new]').onclick = () => openWorkspacePicker();
563
+ const backBtn = lobbyEl.querySelector('[data-lobby-back]');
564
+ if (backBtn) backBtn.onclick = () => closeLobby();
565
+ }
566
+
567
+ async function openLobby() {
568
+ if (!config.canSwitchWorkspace || offline || !lobbyEl) return;
569
+ lobbyEl.hidden = false;
570
+ try {
571
+ const res = await fetch('/library/fs-workspaces', { cache: 'no-store' });
572
+ if (res.ok) cachedHubData = await res.json();
573
+ } catch {}
574
+ renderLobbyView(cachedHubData || {});
575
+ }
576
+
577
+ function renderEmptyOnboarding(profile = {}) {
578
+ const emptyEl = $('#emptyState');
579
+ if (!emptyEl) return;
580
+ let selectedTpl = 'arch';
581
+ const hasCode = (profile.codeFiles || 0) > 0;
582
+ const chipLabel = hasCode
583
+ ? `已识别本地仓库 · ${profile.codeFiles} 个 ${profile.primaryLang || '源码'} 文件`
584
+ : `当前工作区 · ${config.workspaceName || '新建项目'}`;
585
+ emptyEl.innerHTML = `
586
+ <div class="clado-empty-card">
587
+ <div class="clado-prism-aura-under"></div>
588
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;">
589
+ <span class="clado-chip clado-chip-sky" style="padding:4px 11px;"><span class="clado-dot-sky" style="width:6px;height:6px;"></span>${escHtml(chipLabel)}</span>
590
+ <span style="font-family:ui-monospace,monospace;font-size:11.5px;color:var(--clado-ui-subtle);">${escHtml(config.workspacePath || '')}</span>
591
+ </div>
592
+ <div style="font-size:22px;font-weight:630;letter-spacing:-0.02em;margin-top:16px;">想怎样开始这张画布?</div>
593
+ <p style="font-size:13px;color:var(--clado-ui-muted);margin:6px 0 0;line-height:1.6;">
594
+ 选择一个分析模板让「主架构师」快速读取源码并生成人可读的架构图,或直接从空白画布自由起稿。
595
+ </p>
596
+ <div class="clado-tpl-grid">
597
+ <button type="button" class="clado-tpl-btn selected" data-tpl="arch">
598
+ <svg class="clado-svg-ico" style="width:17px;height:17px;color:#0284c7;" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="8.5" y="14" width="7" height="7" rx="1.5"/><path d="M6.5 10v2h11v-2M12 12v2"/></svg>
599
+ <div style="font-size:13.5px;font-weight:610;margin-top:2px;">老代码架构梳理</div>
600
+ <div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">扫描模块边界、调用链与核心入口,自动铺出清晰卡片图。</div>
601
+ </button>
602
+ <button type="button" class="clado-tpl-btn" data-tpl="req">
603
+ <svg class="clado-svg-ico" style="width:17px;height:17px;color:#059669;" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M8 13h8M8 17h5"/></svg>
604
+ <div style="font-size:13.5px;font-weight:610;margin-top:2px;">新需求拆解设计</div>
605
+ <div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">把需求拆为数据契约、状态流转与风险清单,边改边定稿。</div>
606
+ </button>
607
+ <button type="button" class="clado-tpl-btn" data-tpl="qa">
608
+ <svg class="clado-svg-ico" style="width:17px;height:17px;color:#7c3aed;" viewBox="0 0 24 24"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/></svg>
609
+ <div style="font-size:13.5px;font-weight:610;margin-top:2px;">测试与压测矩阵</div>
610
+ <div style="font-size:11.5px;color:var(--clado-ui-muted);line-height:1.55;">提炼主链路与异常分支,准备一键交付给测试角色跑通。</div>
611
+ </button>
612
+ </div>
613
+ <div style="display:flex;align-items:center;justify-content:space-between;margin-top:22px;padding-top:18px;border-top:1px solid var(--clado-ui-edge);">
614
+ <button type="button" class="clado-ui-button" data-empty-skip>跳过引导,新建空白画布</button>
615
+ <button type="button" class="clado-ui-button clado-ui-button-primary" data-empty-start style="padding:9px 20px;">开始分析并生成画布 →</button>
616
+ </div>
617
+ </div>
618
+ `;
619
+ emptyEl.querySelectorAll('[data-tpl]').forEach(btn => {
620
+ btn.onclick = () => {
621
+ selectedTpl = btn.dataset.tpl;
622
+ emptyEl.querySelectorAll('[data-tpl]').forEach(b => b.classList.toggle('selected', b === btn));
623
+ };
624
+ });
625
+ emptyEl.querySelector('[data-empty-skip]').onclick = () => createCanvasFlow('系统架构概览');
626
+ emptyEl.querySelector('[data-empty-start]').onclick = () => {
627
+ showToast('主架构师正在分析源码并绘制画布…');
628
+ window.CladoVNext?.startCodeAnalysis?.(selectedTpl);
629
+ };
630
+ }
631
+
632
+ if (config.canSwitchWorkspace && !offline) {
633
+ window.addEventListener('clado:open-workspace-picker', () => openLobby());
634
+ window.addEventListener('clado:meta-updated', () => {
635
+ if (lobbyEl && !lobbyEl.hidden) renderLobbyView(cachedHubData || {});
636
+ });
637
+ renderEmptyOnboarding({});
638
+ fetch('/library/fs-workspaces', { cache: 'no-store' })
639
+ .then(r => r.ok ? r.json() : null)
640
+ .then(data => {
641
+ if (!data) return;
642
+ cachedHubData = data;
643
+ renderEmptyOnboarding(data.currentProfile || {});
644
+ if (config.hubMode) openLobby();
645
+ })
646
+ .catch(() => { if (config.hubMode) openLobby(); });
424
647
  }
425
648
  const liveObjectsEnabled = Boolean(config.selection && !offline && document.body);
426
649
  let canvasObjectsList = [];
@@ -619,28 +842,30 @@
619
842
  });
620
843
  } else {
621
844
  addLabel('画布空白处');
622
- addItem('+ 在此处新建便签', () => {
623
- saveObject({ kind: 'sticky', title: '灵感便签', pluginId: 'starter.sticky-notes', x: detail.wx, y: detail.wy, tint: 'amber', text: '记录一条新想法…' });
845
+ addItem('+ 在此处新建便签', () => {
846
+ saveObject({ kind: 'sticky', title: '设计便签', pluginId: 'starter.sticky-notes', x: detail.wx, y: detail.wy, tint: 'amber', text: '记录一条新想法…' });
624
847
  });
625
- addItem('+ 添加专注播放器组件', () => {
626
- saveObject({
627
- kind: 'music',
628
- title: 'Lo-Fi 专注播放器',
629
- pluginId: 'starter.lofi-player',
630
- x: detail.wx,
631
- y: detail.wy,
632
- width: 326,
633
- data: {
634
- expanded: false,
635
- selRenderMode: 'custom',
636
- tracks: [
637
- { id: 't1', title: 'Midnight Rain · 深夜雨声', duration: '03:24', liked: true },
638
- { id: 't2', title: 'Glass Horizon · 玻璃天际线', duration: '02:58', liked: false },
639
- { id: 't3', title: 'Soft Focus · 柔焦白噪音', duration: '04:12', liked: false },
640
- ],
641
- },
848
+ if (window.CladoVNext?.isComponentEnabled?.('lofi-studio-widget')) {
849
+ addItem('+ 添加 Lo-Fi 专注播放器', () => {
850
+ saveObject({
851
+ kind: 'music',
852
+ title: 'Lo-Fi 专注播放器',
853
+ pluginId: 'starter.lofi-player',
854
+ x: detail.wx,
855
+ y: detail.wy,
856
+ width: 326,
857
+ data: {
858
+ expanded: false,
859
+ selRenderMode: 'custom',
860
+ tracks: [
861
+ { id: 't1', title: 'Midnight Rain · 深夜雨声', duration: '03:24', liked: true },
862
+ { id: 't2', title: 'Glass Horizon · 玻璃天际线', duration: '02:58', liked: false },
863
+ { id: 't3', title: 'Soft Focus · 柔焦白噪音', duration: '04:12', liked: false },
864
+ ],
865
+ },
866
+ });
642
867
  });
643
- });
868
+ }
644
869
  addSep();
645
870
  addItem('居中复位画布', () => frame.contentWindow.CladoPrototype?.fit());
646
871
  }
@@ -663,11 +888,14 @@
663
888
  selectionBarEl.innerHTML = `
664
889
  <span class="clado-selection-dot"></span>
665
890
  <span class="clado-selection-text" data-sel-summary>已选 0 项</span>
666
- <button type="button" class="clado-selection-send" data-sel-send>发给当前会话</button>
891
+ <button type="button" class="clado-selection-send" data-sel-dev>交给开发落地</button>
892
+ <button type="button" class="clado-selection-secondary" data-sel-qa>生成并跑测试</button>
667
893
  <button type="button" class="clado-selection-clear" data-sel-clear>完成</button>`;
668
- selectionBarEl.querySelector('[data-sel-send]').onclick = () => {
669
- const names = collectSelectionLabels().join('、');
670
- window.dispatchEvent(new CustomEvent('clado:send-selection', { detail: { names } }));
894
+ selectionBarEl.querySelector('[data-sel-dev]').onclick = () => {
895
+ window.CladoVNext?.triggerHandoff?.('developer');
896
+ };
897
+ selectionBarEl.querySelector('[data-sel-qa]').onclick = () => {
898
+ window.CladoVNext?.triggerHandoff?.('tester');
671
899
  };
672
900
  selectionBarEl.querySelector('[data-sel-clear]').onclick = () => {
673
901
  objectSelection.clear();
@@ -675,7 +903,7 @@
675
903
  syncFrameObjects();
676
904
  renderSelectionSummary();
677
905
  };
678
- document.body.append(selectionBarEl);
906
+ stageEl.append(selectionBarEl);
679
907
 
680
908
  canvasCtxMenuEl = document.createElement('div');
681
909
  canvasCtxMenuEl.id = 'clado-canvas-ctx-menu';
@@ -727,20 +955,17 @@
727
955
  }
728
956
  }
729
957
  if (isEnabled('clado.agent')) window.CladoAgentPlugin(host, {
730
- placeholder: settings['clado.agent']?.placeholder,
731
- agentName: config.agentProfile === 'codex' ? 'Codex' : settings['clado.agent']?.name,
732
- endpoint: withWorkspace('/library/agent'),
733
- followAi,
734
- setFollowAi,
735
- focusTarget,
736
- readCanvas() {
958
+ withWorkspace,
959
+ setTheme: applyTheme,
960
+ capture: captureShot,
961
+ focusCanvas: (file, heading) => focusTarget(file, heading ? [heading] : null, heading || ''),
962
+ readContext() {
737
963
  const objSel = objectSelection.size ? [...objectSelection.values()] : undefined;
738
- if (readyCanvas?.frame !== frame) return objSel ? { objectSelection: objSel } : undefined;
964
+ if (readyCanvas?.frame !== frame) return { file: selected || '', selection: [], ...(objSel ? { objectSelection: objSel } : {}) };
739
965
  const { file, revision } = readyCanvas;
740
966
  const selection = aiSelection?.file === file && aiSelection.version === revision ? aiSelection.nodes : [];
741
967
  return { file, revision, selection, ...(objSel ? { objectSelection: objSel } : {}) };
742
968
  },
743
- viewId: capabilities?.viewId,
744
969
  });
745
970
  if (!['light', 'dark'].includes(design.theme)) design.theme = 'light';
746
971
  try { const savedTheme = localStorage.getItem('clado-theme'); if (['light', 'dark'].includes(savedTheme)) design.theme = savedTheme; } catch {}