@ninkch/dsh-infinite-canvas 0.19.20 → 0.20.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/README.md +23 -0
- package/README.zh-CN.md +23 -0
- package/assets/canvas-layout/SKILL.md +19 -2
- package/assets/canvas-studio/SKILL.md +156 -378
- package/client.js +847 -61
- package/cordis.patch.yml +13 -0
- package/docs/UI-RULES.md +4 -0
- package/docs/auto-creation-design.md +68 -0
- package/docs/guide.en.md +13 -1
- package/docs/guide.zh-CN.md +14 -0
- package/index.js +1547 -30
- package/package.json +2 -1
- package/production.js +427 -0
package/client.js
CHANGED
|
@@ -956,6 +956,22 @@ function revealCanvasInRight() {
|
|
|
956
956
|
'keysTitle': '快捷键与操作',
|
|
957
957
|
'guideDesc': '在对话旁直接分镜、生成视频与成片',
|
|
958
958
|
'hostTakenTitle': '画布已在另一侧打开',
|
|
959
|
+
// —— 会话↔画布绑定(composer 画布选择器)——
|
|
960
|
+
'bindSessionOnly': '仅会话',
|
|
961
|
+
'bindCreateProjectAction': '创建项目',
|
|
962
|
+
'bindNewCanvas': '新建子画布',
|
|
963
|
+
'bindNewCanvasPlaceholder': '',
|
|
964
|
+
'bindOpenCanvas': '打开画布',
|
|
965
|
+
'bindOccupied': '占用中',
|
|
966
|
+
'bindFail': '绑定失败',
|
|
967
|
+
'bindCreating': '创建中…',
|
|
968
|
+
'bindHostStale': '宿主插件是旧版本:请完全退出并重启 DeepSeek Harness 后再试',
|
|
969
|
+
'bindChipBound': '{project}·{name}',
|
|
970
|
+
// —— 记忆查看器(统一弹窗「记忆」页签)——
|
|
971
|
+
'memViewerTab': '记忆',
|
|
972
|
+
'memViewerEmpty': '项目还没有记忆。各集会话在创作中用 canvas_write_memory 回写后,这里能看到每一集的记忆索引与全文。',
|
|
973
|
+
'memRefresh': '刷新',
|
|
974
|
+
'memViewerHint': '点任一集查看完整记忆(只读)',
|
|
959
975
|
'hostTakenHint': '同一时刻画布只能在一处运行(共享同一份节点与生成状态),点击下方按钮把画布切换到这里。',
|
|
960
976
|
'hostTakeOver': '把画布切换到这里',
|
|
961
977
|
'keysHint': '点击按钮收起;Esc 也可关闭',
|
|
@@ -1194,6 +1210,23 @@ function revealCanvasInRight() {
|
|
|
1194
1210
|
'dataRootMigratedDone': '已迁移',
|
|
1195
1211
|
'dataRootMigrating': '迁移中',
|
|
1196
1212
|
'dataRootUnsupported': '当前插件后台版本较旧(不支持数据根目录):重启 Harness 后可用',
|
|
1213
|
+
'autoTitle': '自动创作(实验)',
|
|
1214
|
+
'autoOn': '已开启',
|
|
1215
|
+
'autoOff': '已关闭',
|
|
1216
|
+
'autoEnable': '开启',
|
|
1217
|
+
'autoDisable': '关闭',
|
|
1218
|
+
'autoCapsOk': '多智能体:可用',
|
|
1219
|
+
'autoCapsNo': '多智能体:宿主未暴露会话服务(暂不可用)',
|
|
1220
|
+
'autoOldHost': '宿主插件是旧版本(不支持自动创作开关):完全重启 Harness 后可用',
|
|
1221
|
+
'stageCurrent': '制作阶段',
|
|
1222
|
+
'stageReadyYes': '可交付',
|
|
1223
|
+
'stageReadyNo': '未就绪',
|
|
1224
|
+
'stageBlockers': '阻塞',
|
|
1225
|
+
'imageGenTitle': '桥接dsh-image-gen',
|
|
1226
|
+
'imageGenStatusNo': 'dsh-image-gen模型·未配置',
|
|
1227
|
+
'imageGenMissing': '未检测到 dsh-image-gen',
|
|
1228
|
+
'imageGenStatusYes': 'dsh-image-gen模型·已配置',
|
|
1229
|
+
'imageGenNoModel': '(未选择模型)',
|
|
1197
1230
|
'dataRootSaved': '数据根目录已设置',
|
|
1198
1231
|
'storageInfo': '存储',
|
|
1199
1232
|
'storageDetails': '存储详情',
|
|
@@ -1904,6 +1937,22 @@ function revealCanvasInRight() {
|
|
|
1904
1937
|
'keysTitle': 'Shortcuts & gestures',
|
|
1905
1938
|
'guideDesc': 'Storyboard, generate and cut right beside the chat',
|
|
1906
1939
|
'hostTakenTitle': 'The canvas is open elsewhere',
|
|
1940
|
+
// —— Session↔canvas binding (composer canvas selector) ——
|
|
1941
|
+
'bindSessionOnly': 'Session only',
|
|
1942
|
+
'bindCreateProjectAction': 'Create project',
|
|
1943
|
+
'bindNewCanvas': 'New sub-canvas',
|
|
1944
|
+
'bindNewCanvasPlaceholder': '',
|
|
1945
|
+
'bindOpenCanvas': 'Open canvas',
|
|
1946
|
+
'bindOccupied': 'Occupied',
|
|
1947
|
+
'bindFail': 'Binding failed',
|
|
1948
|
+
'bindCreating': 'Creating…',
|
|
1949
|
+
'bindHostStale': 'The host plugin is outdated: fully quit and restart DeepSeek Harness, then retry.',
|
|
1950
|
+
'bindChipBound': '{project} · {name}',
|
|
1951
|
+
// —— Memory viewer (studio modal "memory" tab) ——
|
|
1952
|
+
'memViewerTab': 'Memory',
|
|
1953
|
+
'memViewerEmpty': 'No memories yet. As episode sessions write back via canvas_write_memory, the per-episode index and full memory appear here.',
|
|
1954
|
+
'memRefresh': 'Refresh',
|
|
1955
|
+
'memViewerHint': 'Click an episode to read its full memory (read-only)',
|
|
1907
1956
|
'hostTakenHint': 'The canvas runs in one place at a time (one shared node graph and generation state). Move it here with the button below.',
|
|
1908
1957
|
'hostTakeOver': 'Move the canvas here',
|
|
1909
1958
|
'keysHint': 'Click the button again to collapse; Esc also closes',
|
|
@@ -2142,6 +2191,23 @@ function revealCanvasInRight() {
|
|
|
2142
2191
|
'dataRootMigratedDone': 'Migrated',
|
|
2143
2192
|
'dataRootMigrating': 'Migrating',
|
|
2144
2193
|
'dataRootUnsupported': 'The plugin backend is older and lacks data-root support — restart Harness to enable',
|
|
2194
|
+
'autoTitle': 'Auto creation (experimental)',
|
|
2195
|
+
'autoOn': 'On',
|
|
2196
|
+
'autoOff': 'Off',
|
|
2197
|
+
'autoEnable': 'Turn on',
|
|
2198
|
+
'autoDisable': 'Turn off',
|
|
2199
|
+
'autoCapsOk': 'Multi-agent: available',
|
|
2200
|
+
'autoCapsNo': 'Multi-agent: host does not expose session services (unavailable)',
|
|
2201
|
+
'autoOldHost': 'The plugin backend is older and lacks the auto-creation switch — fully restart Harness to enable',
|
|
2202
|
+
'stageCurrent': 'Stage',
|
|
2203
|
+
'stageReadyYes': 'deliverable',
|
|
2204
|
+
'stageReadyNo': 'not ready',
|
|
2205
|
+
'stageBlockers': 'blocked',
|
|
2206
|
+
'imageGenTitle': 'Bridge: dsh-image-gen',
|
|
2207
|
+
'imageGenStatusNo': 'dsh-image-gen models · not configured',
|
|
2208
|
+
'imageGenMissing': 'dsh-image-gen not detected',
|
|
2209
|
+
'imageGenStatusYes': 'dsh-image-gen models · configured',
|
|
2210
|
+
'imageGenNoModel': '(no model)',
|
|
2145
2211
|
'dataRootSaved': 'Data root set',
|
|
2146
2212
|
'storageInfo': 'Storage',
|
|
2147
2213
|
'storageDetails': 'Storage details',
|
|
@@ -2499,6 +2565,7 @@ body[data-ds-dark-theme] .dshic-studio-modal{border-color:var(--dsw-alias-border
|
|
|
2499
2565
|
/* 弹窗内部再开确认框/PhotoCraft:层级必须高于统一弹窗(否则被遮罩盖住点不到) */
|
|
2500
2566
|
.dshic-studio-overlay .dshic-modal-overlay{z-index:340;}
|
|
2501
2567
|
.dshic-studio-bible{display:flex;flex-direction:column;gap:8px;width:100%;max-width:820px;margin:0 auto;}
|
|
2568
|
+
.dshic-studio-memory{display:flex;flex-direction:column;min-height:0;width:100%;max-width:820px;margin:0 auto;}
|
|
2502
2569
|
/* ── 3D 导演台:三栏(对象 / 视口 / 属性);视口是纯 Canvas2D 软件渲染(见 directorRenderScene) ── */
|
|
2503
2570
|
.dshic-dir-modal{width:min(1220px,calc(100vw - 40px));height:min(820px,calc(100vh - 40px));}
|
|
2504
2571
|
.dshic-dir-body{flex:1;min-height:0;display:flex;gap:0;overflow:hidden;}
|
|
@@ -2994,6 +3061,47 @@ body[data-ds-dark-theme] .dshic-inline-input{border-color:var(--dsw-alias-border
|
|
|
2994
3061
|
color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;text-align:left;white-space:nowrap;}
|
|
2995
3062
|
.dshic-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover,color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent));}
|
|
2996
3063
|
body[data-ds-dark-theme] .dshic-menu{border-color:var(--dsw-alias-border-l2);}
|
|
3064
|
+
/* —— 会话↔画布绑定(composer 画布选择 chip):与宿主会话输入行 chip 同一视觉语言 —— */
|
|
3065
|
+
.dshic-bind{position:relative;display:inline-flex;align-items:center;gap:2px;flex:0 1 auto;min-width:0;max-width:180px;}
|
|
3066
|
+
.dshic-bind-chip{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border-radius:10px;border:1px solid transparent;
|
|
3067
|
+
background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;}
|
|
3068
|
+
.dshic-bind-chip:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-3));color:var(--dsw-alias-label-primary);}
|
|
3069
|
+
.dshic-bind-chip.is-bound{color:var(--dsw-alias-label-primary);}
|
|
3070
|
+
.dshic-bind-ico{display:inline-flex;align-items:center;flex:none;opacity:.85;}
|
|
3071
|
+
.dshic-bind-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
|
|
3072
|
+
.dshic-bind-caret{font-size:10px;opacity:.75;flex:none;margin-left:2px;}
|
|
3073
|
+
.dshic-bind-menu{position:absolute;top:calc(100% + 6px);left:0;z-index:70;max-height:340px;overflow:auto;min-width:240px;border-radius:12px;padding:4px;}
|
|
3074
|
+
.dshic-bind-sep{height:1px;background:var(--dsw-alias-border-l1);margin:4px 6px;}
|
|
3075
|
+
.dshic-bind-rowico{display:inline-flex;align-items:center;flex:none;opacity:.8;}
|
|
3076
|
+
.dshic-bind-rowlabel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
3077
|
+
.dshic-bind-exp{margin-left:auto;padding-left:12px;font-size:10px;opacity:.65;flex:none;}
|
|
3078
|
+
.dshic-bind-indent{padding-left:26px;}
|
|
3079
|
+
.dshic-menu-item.is-selected{background:var(--dsw-alias-interactive-bg-hover,color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent));}
|
|
3080
|
+
.dshic-bind-occ{color:var(--dsw-alias-label-secondary);font-size:11px;margin-left:auto;padding-left:12px;}
|
|
3081
|
+
.dshic-menu-item.is-dim{opacity:.55;cursor:not-allowed;}
|
|
3082
|
+
.dshic-menu-item.is-dim:hover{background:transparent;}
|
|
3083
|
+
.dshic-bind-newrow{display:flex;gap:6px;padding:4px 8px 6px;}
|
|
3084
|
+
.dshic-bind-newrow input{flex:1;min-width:0;height:28px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:0 8px;box-sizing:border-box;}
|
|
3085
|
+
.dshic-bind-newrow button{height:28px;padding:0 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;}
|
|
3086
|
+
.dshic-bind-newrow button:hover{border-color:var(--dsw-alias-brand-primary);}
|
|
3087
|
+
.dshic-bind-err{position:absolute;top:calc(100% + 4px);left:0;font-size:11px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:2px 8px;z-index:70;max-width:260px;}
|
|
3088
|
+
.dshic-bind-err-inmenu{font-size:11px;color:var(--dsw-alias-label-primary);padding:6px 10px;margin-top:4px;border-top:1px solid var(--dsw-alias-border-l1);white-space:pre-wrap;word-break:break-word;}
|
|
3089
|
+
.dshic-bind-warn{font-size:11px;color:var(--dsw-alias-label-primary);padding:6px 10px;margin-bottom:4px;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:pre-wrap;word-break:break-word;}
|
|
3090
|
+
/* —— 记忆查看器(统一弹窗「记忆」页签)—— */
|
|
3091
|
+
.dshic-memtab{display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;}
|
|
3092
|
+
.dshic-memtab-bar{display:flex;align-items:center;gap:10px;flex:none;}
|
|
3093
|
+
.dshic-memtab-hint{font-size:11px;color:var(--dsw-alias-label-secondary);}
|
|
3094
|
+
.dshic-memtab-empty{padding:26px 10px;text-align:center;font-size:12px;color:var(--dsw-alias-label-secondary);}
|
|
3095
|
+
.dshic-memtab-list{display:flex;flex-direction:column;gap:4px;overflow:auto;flex:1;min-height:0;}
|
|
3096
|
+
.dshic-memtab-row{display:flex;align-items:baseline;gap:8px;padding:7px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;
|
|
3097
|
+
background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;cursor:pointer;text-align:left;flex-wrap:wrap;}
|
|
3098
|
+
.dshic-memtab-row:hover{border-color:var(--dsw-alias-brand-primary);}
|
|
3099
|
+
.dshic-memtab-row.is-open{border-color:var(--dsw-alias-brand-primary);}
|
|
3100
|
+
.dshic-memtab-row-title{font-weight:600;flex:none;}
|
|
3101
|
+
.dshic-memtab-row-status{flex:none;color:var(--dsw-alias-label-secondary);font-size:11px;}
|
|
3102
|
+
.dshic-memtab-row-sum{color:var(--dsw-alias-label-secondary);font-size:11px;}
|
|
3103
|
+
.dshic-memtab-body{flex:none;max-height:45%;overflow:auto;margin:0;padding:10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;
|
|
3104
|
+
background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:1.6;white-space:pre-wrap;word-break:break-word;}
|
|
2997
3105
|
.dshic-overlay{position:fixed;inset:0;z-index:50;background:transparent;}
|
|
2998
3106
|
.dshic-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;}
|
|
2999
3107
|
.dshic-empty-card{pointer-events:auto;text-align:center;display:flex;flex-direction:column;gap:10px;align-items:center;
|
|
@@ -3480,6 +3588,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
|
|
|
3480
3588
|
videoProviders: Array.isArray(s.videoProviders) ? s.videoProviders : [],
|
|
3481
3589
|
imageStar: s.imageStar || '',
|
|
3482
3590
|
videoStar: s.videoStar || '',
|
|
3591
|
+
// dsh-image-gen 桥接:启用后画布不自配图片 API,直接走它的 /studio(密钥留在它宿主侧)
|
|
3592
|
+
imageGen: { enabled: !!(s.imageGen && s.imageGen.enabled), provider: (s.imageGen && s.imageGen.provider) || '', model: (s.imageGen && s.imageGen.model) || '' },
|
|
3483
3593
|
ttsApis: Array.isArray(s.ttsApis) ? s.ttsApis : [],
|
|
3484
3594
|
ttsApiId: s.ttsApiId || '',
|
|
3485
3595
|
lang: s.lang || '',
|
|
@@ -5765,6 +5875,46 @@ function queueThumb(assetId) {
|
|
|
5765
5875
|
return null;
|
|
5766
5876
|
}
|
|
5767
5877
|
|
|
5878
|
+
/** dsh-image-gen 桥接生图:走它的 /studio 路由(密钥留在它宿主侧,前端零配置)。
|
|
5879
|
+
* GET 取模型清单由探测函数负责;这里只做 POST 生成 + 取图。返回 Blob(与 apiImage 同契约)。 */
|
|
5880
|
+
async function apiGenBridge(prompt, refBlobs, g, opts) {
|
|
5881
|
+
const cfg = g || {};
|
|
5882
|
+
if (!cfg.provider || !cfg.model) throw new Error('dsh-image-gen 未选择服务商/模型(设置 → 图片模型 → 来自 dsh-image-gen)');
|
|
5883
|
+
const refs = [];
|
|
5884
|
+
for (const b of (refBlobs || []).slice(0, 4)) {
|
|
5885
|
+
try {
|
|
5886
|
+
const dataUrl = await blobToDataUrl(b);
|
|
5887
|
+
const m = /^data:([^;]+);base64,(.+)$/.exec(String(dataUrl || ''));
|
|
5888
|
+
if (m) refs.push({ mediaType: m[1], data: m[2] });
|
|
5889
|
+
} catch { /* 单张参考图转换失败不阻塞 */ }
|
|
5890
|
+
}
|
|
5891
|
+
const body = {
|
|
5892
|
+
mode: refs.length ? 'edit' : 'generate',
|
|
5893
|
+
provider: cfg.provider,
|
|
5894
|
+
model: cfg.model,
|
|
5895
|
+
prompt: String(prompt || ''),
|
|
5896
|
+
ratio: String((opts && opts.ratio) || '1:1'),
|
|
5897
|
+
quality: String((opts && opts.quality) || 'high'),
|
|
5898
|
+
};
|
|
5899
|
+
if (refs.length) body.references = refs;
|
|
5900
|
+
const res = await fetch('/plugins/dsh-image-gen/studio', {
|
|
5901
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body),
|
|
5902
|
+
});
|
|
5903
|
+
const raw = await res.text();
|
|
5904
|
+
let json = null;
|
|
5905
|
+
try { json = JSON.parse(raw); } catch { /* 非 JSON(网关页/空响应)走下面的错误 */ }
|
|
5906
|
+
if (!res.ok || !json) {
|
|
5907
|
+
throw new Error('dsh-image-gen 生成失败:' + ((json && (json.error || json.message)) || ('HTTP ' + res.status + (raw ? ' · ' + raw.slice(0, 160) : ''))));
|
|
5908
|
+
}
|
|
5909
|
+
if (json.error) throw new Error('dsh-image-gen 生成失败:' + json.error);
|
|
5910
|
+
const att = (Array.isArray(json.items) && json.items[0] && json.items[0].attachment) || json.attachment;
|
|
5911
|
+
if (!att) throw new Error('dsh-image-gen 未返回图片(响应缺少 attachment)');
|
|
5912
|
+
const img = await fetch('/plugins/dsh-image-gen/image', {
|
|
5913
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ attachment: att }),
|
|
5914
|
+
});
|
|
5915
|
+
if (!img.ok) throw new Error('读取 dsh-image-gen 生成的图片失败 HTTP ' + img.status);
|
|
5916
|
+
return await img.blob();
|
|
5917
|
+
}
|
|
5768
5918
|
async function apiImage(prompt, refBlobs, s, opts) {
|
|
5769
5919
|
if (!s.baseUrl) throw new Error('未配置图片 API');
|
|
5770
5920
|
// URL 归一化:裸域 → /v1;粘贴完整端点也不会被二次拼接
|
|
@@ -9429,8 +9579,9 @@ function queueThumb(assetId) {
|
|
|
9429
9579
|
rightTab: 'projects',
|
|
9430
9580
|
// 多画布预留:当前项目下只有默认画布(null);将来 = 子目录/子画布 id
|
|
9431
9581
|
activeCanvasId: null,
|
|
9432
|
-
// 统一弹窗(资产 +
|
|
9582
|
+
// 统一弹窗(资产 + 设定集 + 记忆):'bible' | 'assets' | 'memory' | null;纯 UI 状态
|
|
9433
9583
|
panelModal: null,
|
|
9584
|
+
memoryViewer: null, // 记忆查看器状态:{ loaded, index, open, body }(随项目切换重拉)
|
|
9434
9585
|
// 工具栏项目下拉(位置由按钮真实矩形计算):{left, top} | null;纯 UI 状态
|
|
9435
9586
|
projectMenu: null,
|
|
9436
9587
|
// 项目下拉的搜索与分页(最多 5 行/页,分页在列表底部、带页码输入框);打开下拉时重置
|
|
@@ -9464,6 +9615,16 @@ function queueThumb(assetId) {
|
|
|
9464
9615
|
keysOpen: false, // 左上角快捷键面板是否展开(纯 UI 状态,不持久化)
|
|
9465
9616
|
skillPalette: false, // 创作技能浮层(Ctrl/⌘+Shift+K 打开;纯 UI 状态,不持久化)
|
|
9466
9617
|
canvasHost: null, // 画布当前宿主:'main'(全屏面板)| 'pane'(会话右栏页签)| null——同一时刻只允许一处实例
|
|
9618
|
+
activeSessionId: null, // 当前活动会话(composer 画布 chip 上报):会话↔画布绑定与面板跟随的锚点
|
|
9619
|
+
sessionBinding: null, // sessionBindingGet 结果缓存(活动会话的绑定态:workspace/project/binding/canvases/occupied)
|
|
9620
|
+
bindingRev: 0, // 绑定刷新信号:驱动画布面板跟随 effect
|
|
9621
|
+
bindingMenuOpen: false,// chip 下拉开关
|
|
9622
|
+
bindingMenuProject: null, // 未绑定态展开的项目 id(两级菜单)
|
|
9623
|
+
bindableProjects: null,// 可绑定项目清单(菜单打开时懒加载;null=加载中)
|
|
9624
|
+
bindingNewFor: null, // 正在内联「新建子画布」的项目 id
|
|
9625
|
+
bindingError: null, // 绑定动作失败提示
|
|
9626
|
+
bindingCreating: false,// 「创建项目」进行中
|
|
9627
|
+
hostBindingStale: false, // 宿主进程为旧版(缺 bindingCapabilities rev>=2)→ 菜单提示重启并拦截动作
|
|
9467
9628
|
// 3D 导演台(纯 UI 状态;场景数据存在节点/项目的 director 文档里,见 directorDoc)
|
|
9468
9629
|
directorOpen: false,
|
|
9469
9630
|
directorFull: false, // 导演台是否全屏
|
|
@@ -10600,15 +10761,18 @@ function queueThumb(assetId) {
|
|
|
10600
10761
|
const lock = await buildShotLockText(lockKind, { medium: 'image' });
|
|
10601
10762
|
if (lock) p = p + '\n' + lock;
|
|
10602
10763
|
} catch { /* 技能包不可用时不影响生成 */ }
|
|
10603
|
-
//
|
|
10764
|
+
// 模型解析:节点下拉里的「桥接dsh-image-gen」条目走 studio 生成(无需画布自配);其余照旧
|
|
10604
10765
|
const mcfg = resolveImageModelCfg(settings, nodeImageModelRef(n));
|
|
10766
|
+
const useBridge = !!(mcfg && mcfg.viaImageGen);
|
|
10605
10767
|
if (!mcfg) throw new Error(T('errNoImageModel'));
|
|
10606
10768
|
// 张数(1–4):同一提示词一次生成多张;历史条保留全部结果,节点显示最后一张
|
|
10607
10769
|
const want = clamp(Number(n.data.imageCount) || 1, 1, 4);
|
|
10608
10770
|
const cases = [];
|
|
10609
10771
|
for (let i = 0; i < want; i++) {
|
|
10610
10772
|
if (want > 1) update((s) => { const nd = s.graph.nodes[n.id]; if (nd) nd.data.progress = (i + 1) + '/' + want; });
|
|
10611
|
-
const blob =
|
|
10773
|
+
const blob = useBridge
|
|
10774
|
+
? await apiGenBridge(p, metas, { provider: mcfg.imageGenProvider, model: mcfg.model }, { ratio: n.data.ratio })
|
|
10775
|
+
: await apiImage(p, metas, mcfg, {
|
|
10612
10776
|
size: n.data.size, ratio: n.data.ratio, nodeExtra: n.data.imgExtra, warn: addWarn,
|
|
10613
10777
|
// 任务式厂商(三宝图片):任务 id 就是凭证——代理超时/页面关闭后仍可凭 id 回查(与视频同口径)
|
|
10614
10778
|
onTask: (tid, qurl) => {
|
|
@@ -11467,6 +11631,8 @@ function queueThumb(assetId) {
|
|
|
11467
11631
|
keyboard: 'M3 6h18v12H3zM7 10h.01M10 10h.01M13 10h.01M16 10h.01M7 13h.01M10 13h.01M13 13h.01M16 13h.01M8 16h8',
|
|
11468
11632
|
link: 'M10 13a5 5 0 007.1 0l2.4-2.4a5 5 0 00-7.1-7.1L11 4.9M14 11a5 5 0 00-7.1 0L4.5 13.4a5 5 0 007.1 7.1L13 19.1',
|
|
11469
11633
|
camera: 'M4 8h3l1.5-2h7L17 8h3v11H4zM12 16a3 3 0 100-6 3 3 0 000 6z',
|
|
11634
|
+
memory: 'M5 5h14M5 10h14M5 15h9M5 20h6M18 15v5M15.5 17.5h5',
|
|
11635
|
+
chat: 'M4 5h16v11H9l-5 4V5z',
|
|
11470
11636
|
};
|
|
11471
11637
|
function Ic(name, size) { return h(Icon, { d: ICONS[name], size: size || 14 }); }
|
|
11472
11638
|
|
|
@@ -14204,10 +14370,10 @@ function queueThumb(assetId) {
|
|
|
14204
14370
|
// 统一弹窗 / 项目命名弹窗的状态与动作(供图标列、工具栏、测试缝共用)
|
|
14205
14371
|
// ============================================================
|
|
14206
14372
|
function openStudioModal(tab) {
|
|
14207
|
-
update((s) => { s.panelModal = tab === 'assets' ? 'assets' : 'bible'; });
|
|
14373
|
+
update((s) => { s.panelModal = tab === 'assets' ? 'assets' : (tab === 'memory' ? 'memory' : 'bible'); });
|
|
14208
14374
|
}
|
|
14209
14375
|
function setStudioModalTab(tab) {
|
|
14210
|
-
update((s) => { if (s.panelModal) s.panelModal = tab === 'assets' ? 'assets' : 'bible'; });
|
|
14376
|
+
update((s) => { if (s.panelModal) s.panelModal = tab === 'assets' ? 'assets' : (tab === 'memory' ? 'memory' : 'bible'); });
|
|
14211
14377
|
}
|
|
14212
14378
|
function closeStudioModal() {
|
|
14213
14379
|
update((s) => { s.panelModal = null; });
|
|
@@ -17656,6 +17822,13 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17656
17822
|
'data-action': 'open-bible', title: T('bibleTab'),
|
|
17657
17823
|
onClick: () => openStudioModal('bible'),
|
|
17658
17824
|
}, Ic('script', 16)),
|
|
17825
|
+
// 记忆查看器:项目级每集记忆索引 + 全文(只读;agent 经 canvas_write_memory 维护)
|
|
17826
|
+
h('button', {
|
|
17827
|
+
key: 'memory', type: 'button',
|
|
17828
|
+
className: cls('dshic-rail-btn', S.panelModal === 'memory' && 'is-active'),
|
|
17829
|
+
'data-action': 'open-memory', title: T('memViewerTab'),
|
|
17830
|
+
onClick: () => openStudioModal('memory'),
|
|
17831
|
+
}, Ic('memory', 16)),
|
|
17659
17832
|
h('div', { key: 'sep-actions', className: 'dshic-rail-sep' }),
|
|
17660
17833
|
// 3D 导演台:摆位 + 取景 + 导出镜头首帧(参考项目 BeefTV 的导演台能力,只借鉴设计、独立实现)
|
|
17661
17834
|
h('button', {
|
|
@@ -17703,7 +17876,8 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17703
17876
|
h('div', { className: 'dshic-studio-head' },
|
|
17704
17877
|
h('div', { className: 'dshic-studio-tabs' },
|
|
17705
17878
|
tabBtn('bible', T('bibleTab')),
|
|
17706
|
-
tabBtn('assets', T('assets'))
|
|
17879
|
+
tabBtn('assets', T('assets')),
|
|
17880
|
+
tabBtn('memory', T('memViewerTab'))),
|
|
17707
17881
|
h('span', { className: 'dshic-studio-title' }, proj ? proj.name : ''),
|
|
17708
17882
|
h('button', {
|
|
17709
17883
|
type: 'button', className: 'dshic-iconbtn', title: T('cancel'),
|
|
@@ -17712,10 +17886,73 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17712
17886
|
h('div', { className: 'dshic-studio-body' },
|
|
17713
17887
|
tab === 'bible'
|
|
17714
17888
|
? h('div', { className: 'dshic-studio-bible' }, h(BibleTab))
|
|
17715
|
-
:
|
|
17889
|
+
: (tab === 'memory'
|
|
17890
|
+
? h('div', { className: 'dshic-studio-memory' }, h(MemoryTab))
|
|
17891
|
+
: h('div', { className: 'dshic-modal-assets' }, h(AssetsTab, { variant: 'modal' })))),
|
|
17716
17892
|
));
|
|
17717
17893
|
}
|
|
17718
17894
|
|
|
17895
|
+
// ============================================================
|
|
17896
|
+
// 记忆查看器(统一弹窗「记忆」页签):项目级每集记忆索引 + 全文(只读;
|
|
17897
|
+
// 写入由 agent 经 canvas_write_memory 维护,人只看不改,避免与 agent 打架)
|
|
17898
|
+
// ============================================================
|
|
17899
|
+
async function loadMemoryIndex(pid) {
|
|
17900
|
+
if (!pid) return;
|
|
17901
|
+
try {
|
|
17902
|
+
const r = await hostRpc('memoryGet', { projectId: pid });
|
|
17903
|
+
update((s) => {
|
|
17904
|
+
s.memoryViewer = { loaded: true, index: (r && r.index) || { episodes: [] }, open: null, body: null };
|
|
17905
|
+
});
|
|
17906
|
+
} catch {
|
|
17907
|
+
update((s) => { s.memoryViewer = { loaded: true, index: { episodes: [] }, open: null, body: null }; });
|
|
17908
|
+
}
|
|
17909
|
+
}
|
|
17910
|
+
async function loadMemoryBody(pid, canvasId) {
|
|
17911
|
+
try {
|
|
17912
|
+
const r = await hostRpc('memoryGet', { projectId: pid, canvasId });
|
|
17913
|
+
update((s) => {
|
|
17914
|
+
const prev = s.memoryViewer || { index: { episodes: [] } };
|
|
17915
|
+
s.memoryViewer = {
|
|
17916
|
+
loaded: true,
|
|
17917
|
+
index: (r && r.index) || prev.index,
|
|
17918
|
+
open: canvasId,
|
|
17919
|
+
body: (r && r.episode && r.episode.body) || '',
|
|
17920
|
+
};
|
|
17921
|
+
});
|
|
17922
|
+
} catch { /* 静默:正文拉取失败保持原状 */ }
|
|
17923
|
+
}
|
|
17924
|
+
function MemoryTab() {
|
|
17925
|
+
useApp();
|
|
17926
|
+
const pid = S.activeId;
|
|
17927
|
+
useEffect(() => {
|
|
17928
|
+
loadMemoryIndex(pid);
|
|
17929
|
+
return undefined;
|
|
17930
|
+
}, [pid]);
|
|
17931
|
+
const st = S.memoryViewer || { loaded: false, index: { episodes: [] }, open: null, body: null };
|
|
17932
|
+
const eps = (st.index && Array.isArray(st.index.episodes)) ? st.index.episodes : [];
|
|
17933
|
+
return h('div', { className: 'dshic-memtab' },
|
|
17934
|
+
h('div', { className: 'dshic-memtab-bar' },
|
|
17935
|
+
h('button', { type: 'button', className: 'dshic-mini', onClick: () => loadMemoryIndex(pid) }, T('memRefresh')),
|
|
17936
|
+
h('span', { className: 'dshic-memtab-hint' }, T('memViewerHint'))),
|
|
17937
|
+
!st.loaded
|
|
17938
|
+
? h('div', { className: 'dshic-memtab-empty' }, '…')
|
|
17939
|
+
: (!eps.length
|
|
17940
|
+
? h('div', { className: 'dshic-memtab-empty' }, T('memViewerEmpty'))
|
|
17941
|
+
: h('div', { className: 'dshic-memtab-list' }, eps.map((e, i) => h('button', {
|
|
17942
|
+
key: String(e.canvasId) + ':' + i,
|
|
17943
|
+
type: 'button',
|
|
17944
|
+
className: 'dshic-memtab-row' + (st.open === e.canvasId ? ' is-open' : ''),
|
|
17945
|
+
onClick: () => loadMemoryBody(pid, e.canvasId),
|
|
17946
|
+
},
|
|
17947
|
+
h('span', { className: 'dshic-memtab-row-title' }, (i + 1) + '. ' + (e.title || e.canvasId || '')),
|
|
17948
|
+
h('span', { className: 'dshic-memtab-row-status' }, e.status === 'done' ? '✓' : '…'),
|
|
17949
|
+
h('span', { className: 'dshic-memtab-row-sum' }, e.summary || ''))))),
|
|
17950
|
+
st.open != null && st.body != null
|
|
17951
|
+
? h('pre', { className: 'dshic-memtab-body' }, st.body)
|
|
17952
|
+
: null,
|
|
17953
|
+
);
|
|
17954
|
+
}
|
|
17955
|
+
|
|
17719
17956
|
// ============================================================
|
|
17720
17957
|
// 顶部工具栏:最左「返回」图标 → 项目名(下拉切换 / 双击或铅笔重命名 / 新建)
|
|
17721
17958
|
// 说明:添节点在左侧图标列,运行工作流也在图标列;快捷键/帮助/检查更新是右上角纯图标按钮。
|
|
@@ -18006,6 +18243,28 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18006
18243
|
// ============================================================
|
|
18007
18244
|
// 右侧边栏:项目 / 资产 / 设置
|
|
18008
18245
|
// ============================================================
|
|
18246
|
+
/** 制作阶段行(0.20.0):当前画布的阶段 + 可交付/阻塞概览。旧宿主(无 RPC)整行隐藏,零打扰。 */
|
|
18247
|
+
function ProductionStageRow({ projectId, canvasId }) {
|
|
18248
|
+
const [st, setSt] = useState(null);
|
|
18249
|
+
useEffect(() => {
|
|
18250
|
+
let alive = true;
|
|
18251
|
+
const load = async () => {
|
|
18252
|
+
try {
|
|
18253
|
+
const r = await hostRpc('productionStatus', { projectId, canvasId });
|
|
18254
|
+
if (alive && r && r.ok) setSt(r);
|
|
18255
|
+
} catch { if (alive) setSt(null); } // 旧宿主/项目已删 → 静默隐藏
|
|
18256
|
+
};
|
|
18257
|
+
load();
|
|
18258
|
+
const t = setInterval(load, 30000); // 阶段由工具事件推进,30s 轮询足够
|
|
18259
|
+
return () => { alive = false; clearInterval(t); };
|
|
18260
|
+
}, [projectId, canvasId]);
|
|
18261
|
+
if (!st) return null;
|
|
18262
|
+
const blockers = (st.blockers || []).length;
|
|
18263
|
+
const readyText = st.ready ? T('stageReadyYes') : (blockers ? T('stageBlockers') + ' ' + blockers : T('stageReadyNo'));
|
|
18264
|
+
return h('div', { className: 'dshic-hint', 'data-role': 'production-stage', style: { alignSelf: 'flex-start', padding: '2px 2px 0' } },
|
|
18265
|
+
T('stageCurrent') + ':' + (st.stageZh || st.stage) + ' · ' + readyText);
|
|
18266
|
+
}
|
|
18267
|
+
|
|
18009
18268
|
function ProjectsTab() {
|
|
18010
18269
|
// 新建项目统一走左上角项目名下拉(「+ 新建项目…」),右栏只管理当前项目,不再放新建项目按钮
|
|
18011
18270
|
const [delTarget, setDelTarget] = useState(null);
|
|
@@ -18162,8 +18421,11 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18162
18421
|
? h('div', { key: 'emptystate', className: 'dshic-hint', style: { alignSelf: 'flex-start', padding: '6px 2px', maxWidth: 260 } },
|
|
18163
18422
|
T('emptyProjectHint'))
|
|
18164
18423
|
: null,
|
|
18424
|
+
// 制作阶段行(0.20.0 阶段机):当前画布的阶段 + 可交付/阻塞概览;旧宿主无 RPC 时整行隐藏
|
|
18425
|
+
proj ? h(ProductionStageRow, { key: 'stage', projectId: proj.id, canvasId: activeCanvasId() === DEFAULT_CANVAS_ID ? null : activeCanvasId() }) : null,
|
|
18165
18426
|
// 项目区域顶部:一行「+ 新建画布(纯图标)」+ 搜索框(放大镜内嵌在输入框右侧)
|
|
18166
|
-
|
|
18427
|
+
// 折叠只折叠**下方画布列表**:搜索行始终可见(折叠不能把上方工具行一起吞掉)
|
|
18428
|
+
proj
|
|
18167
18429
|
? h('div', { key: 'searchbar', className: 'dshic-canvas-searchbar', 'data-role': 'canvas-searchbar' },
|
|
18168
18430
|
h('button', {
|
|
18169
18431
|
key: 'add', type: 'button', className: 'dshic-canvas-add',
|
|
@@ -19497,61 +19759,49 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19497
19759
|
],
|
|
19498
19760
|
);
|
|
19499
19761
|
}
|
|
19500
|
-
|
|
19501
|
-
|
|
19502
|
-
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
}
|
|
19762
|
+
/** 图片模型桥接卡(0.20.0):检测 dsh-image-gen 并直接选用它的服务商/模型(密钥留在它宿主侧)。 */
|
|
19763
|
+
/** 自动创作开关(实验):只留开关与状态;入口在 Harness 原生对话框(canvas_auto_* 工具)。 */
|
|
19764
|
+
function AutoModeCard() {
|
|
19765
|
+
const [st, setSt] = useState(null);
|
|
19766
|
+
const refresh = async () => {
|
|
19767
|
+
try {
|
|
19768
|
+
const r = await hostRpc('autoModeGet');
|
|
19769
|
+
setSt({ enabled: !!r.enabled, caps: r.caps || null, oldHost: false, busy: false });
|
|
19770
|
+
} catch {
|
|
19771
|
+
setSt({ enabled: false, caps: null, oldHost: true, busy: false });
|
|
19772
|
+
}
|
|
19509
19773
|
};
|
|
19510
|
-
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19520
|
-
|
|
19521
|
-
|
|
19522
|
-
|
|
19523
|
-
|
|
19524
|
-
|
|
19525
|
-
|
|
19526
|
-
)
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
),
|
|
19539
|
-
h(ModelProviderEditor, { key: 'imglist', kind: 'image' }),
|
|
19540
|
-
h(ModelProviderEditor, { key: 'vidlist', kind: 'video' }),
|
|
19541
|
-
h(ApiListEditor, { key: 'ttslist', kind: 'tts' }),
|
|
19542
|
-
// 帮助与反馈:一行入口(点开弹窗看二维码与提 Issue)
|
|
19543
|
-
h('div', {
|
|
19544
|
-
key: 'support', className: 'dshic-card', style: { cursor: 'pointer' },
|
|
19545
|
-
onClick: () => update((s) => { s.supportOpen = true; }),
|
|
19546
|
-
},
|
|
19547
|
-
h('div', { className: 'dshic-row' },
|
|
19548
|
-
Ic('help', 12),
|
|
19549
|
-
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('supportBtn')),
|
|
19550
|
-
h('span', { className: 'dshic-hint', style: { flex: 'none' } }, T('supportIssues') + ' / ' + T('supportWechat') + ' ›'),
|
|
19551
|
-
),
|
|
19774
|
+
useEffect(() => { refresh(); }, []);
|
|
19775
|
+
const toggle = async () => {
|
|
19776
|
+
if (!st || st.busy || st.oldHost) return;
|
|
19777
|
+
setSt({ ...st, busy: true });
|
|
19778
|
+
try {
|
|
19779
|
+
const r = await hostRpc('autoModeSet', { enabled: !st.enabled });
|
|
19780
|
+
setSt({ ...st, enabled: !!r.enabled, busy: false });
|
|
19781
|
+
} catch {
|
|
19782
|
+
setSt({ ...st, busy: false });
|
|
19783
|
+
}
|
|
19784
|
+
};
|
|
19785
|
+
const lines = [];
|
|
19786
|
+
if (!st) lines.push(T('storageLoading'));
|
|
19787
|
+
else if (st.oldHost) lines.push(T('autoOldHost'));
|
|
19788
|
+
else {
|
|
19789
|
+
lines.push(st.enabled ? T('autoOn') : T('autoOff'));
|
|
19790
|
+
lines.push(st.caps && st.caps.multiAgent ? T('autoCapsOk') : T('autoCapsNo'));
|
|
19791
|
+
}
|
|
19792
|
+
return h('div', { className: 'dshic-card' },
|
|
19793
|
+
h('div', { className: 'dshic-row' },
|
|
19794
|
+
Ic('spark', 12),
|
|
19795
|
+
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('autoTitle')),
|
|
19796
|
+
st && !st.oldHost
|
|
19797
|
+
? h('button', {
|
|
19798
|
+
type: 'button', className: cls('dshic-mini', st.enabled && 'is-on'),
|
|
19799
|
+
disabled: st.busy, onPointerDown: (e) => e.stopPropagation(), onClick: toggle,
|
|
19800
|
+
}, st.enabled ? T('autoOn') : T('autoEnable'))
|
|
19801
|
+
: null,
|
|
19552
19802
|
),
|
|
19553
|
-
h('div', {
|
|
19554
|
-
|
|
19803
|
+
h('div', { className: 'dshic-hint', style: { marginTop: 4 }, 'data-role': 'auto-mode-status' }, lines.join(' · ')),
|
|
19804
|
+
);
|
|
19555
19805
|
}
|
|
19556
19806
|
|
|
19557
19807
|
/** 从项目现有创作意图/剧本一键起草设定集(世界观/风格/角色/场景/道具)。 */
|
|
@@ -19614,6 +19864,139 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19614
19864
|
|
|
19615
19865
|
/** 设定条目 ↔ 资产绑定对话框:从当前项目的资产库里多选图片/音频/视频。 */
|
|
19616
19866
|
/** 绑定对话框的资产行:组件化以便用 useAssetUrl 显示缩略图。 */
|
|
19867
|
+
/** 桥接卡(0.20.0):开关 + 配置状态;开启时把 dsh-image-gen 的模型同步进图片模型下拉(节点直接可选)。 */
|
|
19868
|
+
function ImageGenBridgeCard() {
|
|
19869
|
+
const [st, setSt] = useState({ missing: false, configured: false });
|
|
19870
|
+
const [enabled, setEnabled] = useState(!!(loadSettings().imageGen || {}).enabled);
|
|
19871
|
+
/** 把 studio describe 的已配置服务商/模型写进 settings.imageProviders 的桥接条目;关闭/未配置时移除。 */
|
|
19872
|
+
const syncBridgeModels = (desc, on) => {
|
|
19873
|
+
const s0 = loadSettings();
|
|
19874
|
+
const list = (s0.imageProviders || []).filter((p) => p.id !== 'image-gen-bridge');
|
|
19875
|
+
const conf = desc ? (desc.providers || []).filter((p) => p && p.configured) : [];
|
|
19876
|
+
const models = [];
|
|
19877
|
+
if (on) for (const p of conf) {
|
|
19878
|
+
const opts = (p.modelOptions || []).map((o) => o.value).filter(Boolean);
|
|
19879
|
+
for (const m of (opts.length ? opts : [p.model].filter(Boolean))) {
|
|
19880
|
+
models.push({ id: p.provider + '|' + m, model: m, viaImageGen: p.provider });
|
|
19881
|
+
}
|
|
19882
|
+
}
|
|
19883
|
+
if (models.length) {
|
|
19884
|
+
list.unshift({ id: 'image-gen-bridge', name: '桥接dsh-image-gen', baseUrl: '', apiKey: '', viaImageGen: true, models });
|
|
19885
|
+
}
|
|
19886
|
+
s0.imageProviders = list;
|
|
19887
|
+
saveSettings(s0);
|
|
19888
|
+
return models.length;
|
|
19889
|
+
};
|
|
19890
|
+
useEffect(() => {
|
|
19891
|
+
let alive = true;
|
|
19892
|
+
(async () => {
|
|
19893
|
+
const on = !!(loadSettings().imageGen || {}).enabled;
|
|
19894
|
+
try {
|
|
19895
|
+
const r = await fetch('/plugins/dsh-image-gen/studio', { headers: { accept: 'application/json' } });
|
|
19896
|
+
if (!r.ok) throw new Error('HTTP ' + r.status);
|
|
19897
|
+
const j = await r.json();
|
|
19898
|
+
const conf = (j.providers || []).filter((p) => p && p.configured);
|
|
19899
|
+
const modelsN = syncBridgeModels(j, on);
|
|
19900
|
+
if (alive) setSt({ missing: false, configured: on && conf.length > 0 && modelsN > 0 });
|
|
19901
|
+
} catch {
|
|
19902
|
+
syncBridgeModels(null, false);
|
|
19903
|
+
if (alive) setSt({ missing: true, configured: false });
|
|
19904
|
+
}
|
|
19905
|
+
})();
|
|
19906
|
+
return () => { alive = false; };
|
|
19907
|
+
}, []);
|
|
19908
|
+
const toggle = () => {
|
|
19909
|
+
const v = !enabled;
|
|
19910
|
+
setEnabled(v);
|
|
19911
|
+
const s0 = loadSettings();
|
|
19912
|
+
s0.imageGen = { ...(s0.imageGen || {}), enabled: v };
|
|
19913
|
+
saveSettings(s0);
|
|
19914
|
+
// 开/关即时生效:重跑一次探测同步(加回或移除桥接模型条目)
|
|
19915
|
+
(async () => {
|
|
19916
|
+
try {
|
|
19917
|
+
const r = await fetch('/plugins/dsh-image-gen/studio', { headers: { accept: 'application/json' } });
|
|
19918
|
+
const j = r.ok ? await r.json() : null;
|
|
19919
|
+
const conf = j ? (j.providers || []).filter((p) => p && p.configured) : [];
|
|
19920
|
+
const modelsN = syncBridgeModels(j, v && conf.length > 0);
|
|
19921
|
+
setSt({ missing: !r.ok, configured: v && conf.length > 0 && modelsN > 0 });
|
|
19922
|
+
} catch { syncBridgeModels(null, false); setSt({ missing: true, configured: false }); }
|
|
19923
|
+
})();
|
|
19924
|
+
};
|
|
19925
|
+
const statusText = st.missing ? T('imageGenMissing') : (st.configured ? T('imageGenStatusYes') : T('imageGenStatusNo'));
|
|
19926
|
+
return h('div', { className: 'dshic-card', 'data-role': 'image-gen-bridge' },
|
|
19927
|
+
h('div', { className: 'dshic-row' },
|
|
19928
|
+
Ic('image', 12),
|
|
19929
|
+
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('imageGenTitle')),
|
|
19930
|
+
st.missing
|
|
19931
|
+
? null
|
|
19932
|
+
: h('button', {
|
|
19933
|
+
type: 'button', className: cls('dshic-mini', enabled && 'is-on'),
|
|
19934
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
19935
|
+
onClick: toggle,
|
|
19936
|
+
}, enabled ? T('autoOn') : T('autoEnable')),
|
|
19937
|
+
),
|
|
19938
|
+
h('div', { className: 'dshic-hint', style: { marginTop: 4 }, 'data-role': 'image-gen-status' }, statusText),
|
|
19939
|
+
);
|
|
19940
|
+
}
|
|
19941
|
+
function SettingsTab() {
|
|
19942
|
+
const [s, setS] = useState(loadSettings);
|
|
19943
|
+
const apply = (fn) => {
|
|
19944
|
+
setS((prev) => {
|
|
19945
|
+
const next = JSON.parse(JSON.stringify(prev));
|
|
19946
|
+
fn(next);
|
|
19947
|
+
saveSettings(next);
|
|
19948
|
+
return next;
|
|
19949
|
+
});
|
|
19950
|
+
};
|
|
19951
|
+
const field = (label, value, onChange, placeholder, password) => h(Field, { label, value, onChange, placeholder, password });
|
|
19952
|
+
return [
|
|
19953
|
+
h('div', { key: 'lang', className: 'dshic-card' },
|
|
19954
|
+
h('div', { className: 'dshic-row' }, Ic('text', 12), h('strong', { style: { fontSize: 12 } }, T('langLabel'))),
|
|
19955
|
+
h('select', {
|
|
19956
|
+
className: 'dshic-select', value: s.lang || '',
|
|
19957
|
+
onChange: (e) => {
|
|
19958
|
+
apply((d) => { d.lang = e.target.value; });
|
|
19959
|
+
LANG_OVERRIDE = e.target.value;
|
|
19960
|
+
notify();
|
|
19961
|
+
},
|
|
19962
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
19963
|
+
},
|
|
19964
|
+
h('option', { value: '' }, T('langFollow')),
|
|
19965
|
+
h('option', { value: 'zh' }, T('langZh')),
|
|
19966
|
+
h('option', { value: 'en' }, T('langEn'))),
|
|
19967
|
+
),
|
|
19968
|
+
h(DataRootCard, { key: 'dataroot' }),
|
|
19969
|
+
h(CraftCard, { key: 'craft' }),
|
|
19970
|
+
h(AutoModeCard, { key: 'automode' }),
|
|
19971
|
+
h(ImageGenBridgeCard, { key: 'imagegenbridge' }),
|
|
19972
|
+
// 「技能增强」已升级为右侧独立「技能」页(SkillsTab):四层图标瓦片 + 预览/写设定集
|
|
19973
|
+
// 文本模型卡:只选模型,参数全用 Harness 默认;紧挨图片/视频/TTS 模型卡片
|
|
19974
|
+
h('div', { key: 'llm', className: 'dshic-card' },
|
|
19975
|
+
h('div', { className: 'dshic-row' },
|
|
19976
|
+
Ic('spark', 12),
|
|
19977
|
+
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('llmLabel')),
|
|
19978
|
+
InfoTip(T('llmHint')),
|
|
19979
|
+
),
|
|
19980
|
+
h(LlmModelSelect),
|
|
19981
|
+
),
|
|
19982
|
+
h(ModelProviderEditor, { key: 'imglist', kind: 'image' }),
|
|
19983
|
+
h(ModelProviderEditor, { key: 'vidlist', kind: 'video' }),
|
|
19984
|
+
h(ApiListEditor, { key: 'ttslist', kind: 'tts' }),
|
|
19985
|
+
// 帮助与反馈:一行入口(点开弹窗看二维码与提 Issue)
|
|
19986
|
+
h('div', {
|
|
19987
|
+
key: 'support', className: 'dshic-card', style: { cursor: 'pointer' },
|
|
19988
|
+
onClick: () => update((s) => { s.supportOpen = true; }),
|
|
19989
|
+
},
|
|
19990
|
+
h('div', { className: 'dshic-row' },
|
|
19991
|
+
Ic('help', 12),
|
|
19992
|
+
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('supportBtn')),
|
|
19993
|
+
h('span', { className: 'dshic-hint', style: { flex: 'none' } }, T('supportIssues') + ' / ' + T('supportWechat') + ' ›'),
|
|
19994
|
+
),
|
|
19995
|
+
),
|
|
19996
|
+
h('div', { key: 'note', className: 'dshic-hint' }, 'DeepSeek Harness · dsh-infinite-canvas' + ((S.updateInfo && S.updateInfo.runningVersion) ? ' v' + S.updateInfo.runningVersion : '')),
|
|
19997
|
+
];
|
|
19998
|
+
}
|
|
19999
|
+
|
|
19617
20000
|
function AssetPickRow({ a, checked, onToggle }) {
|
|
19618
20001
|
const url = useAssetUrl(a.kind === 'image' ? a.id : null);
|
|
19619
20002
|
return h('label', { className: 'dshic-row', style: { gap: 6, fontSize: 11, cursor: 'pointer', alignItems: 'center' }, onPointerDown: (e) => e.stopPropagation(), onClick: () => onToggle() },
|
|
@@ -20823,6 +21206,393 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20823
21206
|
);
|
|
20824
21207
|
}
|
|
20825
21208
|
|
|
21209
|
+
// ============================================================
|
|
21210
|
+
// 会话↔画布绑定(0.20.x):composer 画布选择 chip + 画布面板跟随
|
|
21211
|
+
// ============================================================
|
|
21212
|
+
const TPL = (tpl, vars) => String(tpl || '').replace(/\{(\w+)\}/g, (m, k) => (vars && vars[k] != null ? String(vars[k]) : m));
|
|
21213
|
+
/** 拉取活动会话的绑定态(sessionBindingGet)。旧宿主 supported:false → chip 整体隐藏。 */
|
|
21214
|
+
async function refreshSessionBinding(sessionId) {
|
|
21215
|
+
if (!sessionId) return;
|
|
21216
|
+
try {
|
|
21217
|
+
const r = await hostRpc('sessionBindingGet', { sessionId });
|
|
21218
|
+
update((s) => {
|
|
21219
|
+
if (s.activeSessionId !== sessionId) return; // 会话已切走:丢弃过期回包
|
|
21220
|
+
s.sessionBinding = Object.assign({ loaded: true }, r);
|
|
21221
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21222
|
+
});
|
|
21223
|
+
} catch (e) {
|
|
21224
|
+
update((s) => {
|
|
21225
|
+
if (s.activeSessionId !== sessionId) return;
|
|
21226
|
+
s.sessionBinding = { loaded: true, supported: false, error: String((e && e.message) || e) };
|
|
21227
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21228
|
+
});
|
|
21229
|
+
}
|
|
21230
|
+
}
|
|
21231
|
+
/** 画布在绑定清单里的序位(默认画布算第 1 集)。 */
|
|
21232
|
+
function canvasEpisodeOf(binding, canvasId) {
|
|
21233
|
+
if (!binding) return null;
|
|
21234
|
+
const cid = canvasId == null ? null : canvasId;
|
|
21235
|
+
const list = Array.isArray(binding.canvases) ? binding.canvases : [];
|
|
21236
|
+
const i = list.findIndex((c) => (c.id || null) === cid);
|
|
21237
|
+
return i >= 0 ? { n: i + 1, total: list.length, name: list[i].name || '' } : null;
|
|
21238
|
+
}
|
|
21239
|
+
/** 绑定打开/跟随:切项目 → 切画布 → 拉远端文档。
|
|
21240
|
+
* opts.force=true(chip 显式动作)无视宿主守卫;否则仅 pane(会话旁画布)自动跟随。 */
|
|
21241
|
+
function followBoundCanvas(opts) {
|
|
21242
|
+
const b = S.sessionBinding;
|
|
21243
|
+
if (!b || !b.loaded || !b.binding || !b.project) return false;
|
|
21244
|
+
if (!(opts && opts.force === true) && S.canvasHost !== 'pane') return false;
|
|
21245
|
+
const pid = b.project.id;
|
|
21246
|
+
const cid = b.binding.canvasId == null ? null : b.binding.canvasId;
|
|
21247
|
+
if (S.activeId !== pid) switchProject(pid);
|
|
21248
|
+
if (activeCanvasId() !== cid) switchCanvas(cid, { skipFlush: true });
|
|
21249
|
+
hydrateCanvasFromHost(pid, cid); // 远端兜底(本地缓存可能为空/过期;对默认画布 switchCanvas 不触发 hydrate)
|
|
21250
|
+
return true;
|
|
21251
|
+
}
|
|
21252
|
+
/** chip 点击(已绑定态):打开右栏画布并落到绑定画布。 */
|
|
21253
|
+
function openBoundCanvasFromChip() {
|
|
21254
|
+
try { revealCanvasInRight(); } catch { /* 布局服务缺失 → 仅切换不展开 */ }
|
|
21255
|
+
followBoundCanvas({ force: true });
|
|
21256
|
+
}
|
|
21257
|
+
/** 客户端项目条目 → 画布清单(默认画布 id=null 在前;与画布管理器同源)。 */
|
|
21258
|
+
function canvasesFromProject(proj) {
|
|
21259
|
+
if (!proj) return [];
|
|
21260
|
+
const list = proj.defaultCanvasDeleted ? [] : [{ id: null, name: proj.defaultCanvasName || '默认画布' }];
|
|
21261
|
+
return list.concat((proj.canvases || []).map((c) => ({ id: c.id, name: c.name })));
|
|
21262
|
+
}
|
|
21263
|
+
/** 确保项目在客户端项目表里(绑定到尚未同步的项目时本地先可见)。 */
|
|
21264
|
+
function ensureLocalProject(id, name) {
|
|
21265
|
+
const pid = String(id || '');
|
|
21266
|
+
if (!pid) return;
|
|
21267
|
+
if ((S.projects || []).some((p) => p.id === pid)) return;
|
|
21268
|
+
// 名字未知(旧宿主 / 竞态)→ 交给宿主下一次同步补登记;绝不把项目 id 当名字写进本地表
|
|
21269
|
+
if (!String(name || '').trim()) return;
|
|
21270
|
+
update((s) => {
|
|
21271
|
+
s.projects = [{
|
|
21272
|
+
id: pid, name: String(name).trim(), canvases: [], defaultCanvasName: '默认画布',
|
|
21273
|
+
createdAt: Date.now(), updatedAt: Date.now(),
|
|
21274
|
+
}].concat(s.projects || []);
|
|
21275
|
+
});
|
|
21276
|
+
}
|
|
21277
|
+
/** 绑定能力探针:识别宿主进程是否仍是旧版(旧宿主无此 RPC → 抛错 → stale=true)。 */
|
|
21278
|
+
async function refreshBindingCapabilities() {
|
|
21279
|
+
try {
|
|
21280
|
+
const r = await hostRpc('bindingCapabilities');
|
|
21281
|
+
update((s) => { s.hostBindingStale = !(r && r.ok && Number(r.rev) >= 2); });
|
|
21282
|
+
} catch {
|
|
21283
|
+
update((s) => { s.hostBindingStale = true; });
|
|
21284
|
+
}
|
|
21285
|
+
}
|
|
21286
|
+
/** 旧宿主守卫:所有绑定动作统一拦截并给出重启提示(不再静默失败)。 */
|
|
21287
|
+
function bindingStaleGuard() {
|
|
21288
|
+
if (!S.hostBindingStale) return false;
|
|
21289
|
+
update((s) => { s.bindingError = T('bindHostStale'); });
|
|
21290
|
+
return true;
|
|
21291
|
+
}
|
|
21292
|
+
async function bindSessionToCanvas(sessionId, projectId, canvasId) {
|
|
21293
|
+
if (!sessionId || !projectId) return;
|
|
21294
|
+
if (bindingStaleGuard()) return;
|
|
21295
|
+
try {
|
|
21296
|
+
const r = await hostRpc('sessionBindingSet', { sessionId, projectId, canvasId: canvasId == null ? null : canvasId });
|
|
21297
|
+
if (!r || r.ok === false) {
|
|
21298
|
+
update((s) => { s.bindingError = (r && (r.error || (r.occupied && T('bindOccupied')))) || T('bindFail'); });
|
|
21299
|
+
return;
|
|
21300
|
+
}
|
|
21301
|
+
// 乐观更新:绑定成功立即用本地项目表显示「项目·画布」,不等宿主回读
|
|
21302
|
+
const local = (Array.isArray(S.projects) ? S.projects : []).find((p) => p.id === projectId);
|
|
21303
|
+
ensureLocalProject(projectId, (local && local.name) || projectId);
|
|
21304
|
+
update((s) => {
|
|
21305
|
+
const prev = s.sessionBinding || {};
|
|
21306
|
+
s.sessionBinding = {
|
|
21307
|
+
loaded: true, supported: true,
|
|
21308
|
+
workspace: prev.workspace || null,
|
|
21309
|
+
project: { id: projectId, name: (local && local.name) || projectId },
|
|
21310
|
+
binding: { canvasId: canvasId == null ? null : canvasId, boundAt: Date.now() },
|
|
21311
|
+
canvasId: canvasId == null ? null : canvasId,
|
|
21312
|
+
canvases: canvasesFromProject(local),
|
|
21313
|
+
occupied: prev.occupied || {},
|
|
21314
|
+
defaultCanvasName: (local && local.defaultCanvasName) || '默认画布',
|
|
21315
|
+
};
|
|
21316
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21317
|
+
s.bindingError = null;
|
|
21318
|
+
s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null;
|
|
21319
|
+
});
|
|
21320
|
+
await refreshSessionBinding(sessionId);
|
|
21321
|
+
followBoundCanvas({ force: true });
|
|
21322
|
+
} catch (e) {
|
|
21323
|
+
update((s) => { s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21324
|
+
}
|
|
21325
|
+
}
|
|
21326
|
+
async function unbindSession(sessionId) {
|
|
21327
|
+
if (bindingStaleGuard()) return;
|
|
21328
|
+
// 乐观清态:chip 立即回「仅会话」(回到可重新选项目的状态),宿主清除随后回读校正
|
|
21329
|
+
update((s) => {
|
|
21330
|
+
const prev = s.sessionBinding || {};
|
|
21331
|
+
s.sessionBinding = {
|
|
21332
|
+
loaded: true, supported: true,
|
|
21333
|
+
workspace: prev.workspace || null,
|
|
21334
|
+
project: null, binding: null, canvasId: null,
|
|
21335
|
+
canvases: [], occupied: {},
|
|
21336
|
+
};
|
|
21337
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21338
|
+
s.bindingError = null;
|
|
21339
|
+
s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null;
|
|
21340
|
+
});
|
|
21341
|
+
try {
|
|
21342
|
+
const r = await hostRpc('sessionBindingClear', { sessionId });
|
|
21343
|
+
if (r && r.ok === false) update((s) => { s.bindingError = r.error || T('bindFail'); });
|
|
21344
|
+
} catch (e) {
|
|
21345
|
+
update((s) => { s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21346
|
+
}
|
|
21347
|
+
await refreshSessionBinding(sessionId);
|
|
21348
|
+
}
|
|
21349
|
+
/** 「创建项目」:优先工作区内嵌项目;会话未挂工作区等失败场景退回普通建项目通道,然后绑定。 */
|
|
21350
|
+
async function createWorkspaceProject(sessionId) {
|
|
21351
|
+
if (bindingStaleGuard()) return;
|
|
21352
|
+
update((s) => { s.bindingCreating = true; s.bindingError = null; });
|
|
21353
|
+
const formerName = () => {
|
|
21354
|
+
const ws = S.sessionBinding && S.sessionBinding.workspace;
|
|
21355
|
+
const seg = ws && ws.path ? String(ws.path).split(/[\\/]/).filter(Boolean).pop() : '';
|
|
21356
|
+
return (seg || '画布项目') + ' ' + new Date().toISOString().slice(0, 16).replace('T', ' ');
|
|
21357
|
+
};
|
|
21358
|
+
const fallbackCreate = async () => {
|
|
21359
|
+
const name = formerName();
|
|
21360
|
+
const cp = await hostRpc('canvasCreateProject', { name });
|
|
21361
|
+
if (!cp || !cp.ok || !cp.projectId) throw new Error((cp && cp.error) || T('bindFail'));
|
|
21362
|
+
ensureLocalProject(cp.projectId, cp.name || name);
|
|
21363
|
+
update((s) => { s.bindingCreating = false; });
|
|
21364
|
+
refreshDataRoot().catch(() => { /* 下一轮 3s 同步也会带 */ });
|
|
21365
|
+
await bindSessionToCanvas(sessionId, cp.projectId, null);
|
|
21366
|
+
};
|
|
21367
|
+
try {
|
|
21368
|
+
const r = await hostRpc('workspaceProjectCreate', { sessionId });
|
|
21369
|
+
if (r && r.ok) {
|
|
21370
|
+
update((s) => { s.bindingCreating = false; s.bindingMenuOpen = false; });
|
|
21371
|
+
ensureLocalProject(r.projectId, r.name || '');
|
|
21372
|
+
refreshDataRoot().catch(() => { /* 项目清单下一轮 3s 同步也会带 */ });
|
|
21373
|
+
await refreshSessionBinding(sessionId);
|
|
21374
|
+
const sb = S.sessionBinding;
|
|
21375
|
+
if (!(sb && sb.binding && sb.project && sb.project.id === r.projectId)) {
|
|
21376
|
+
await bindSessionToCanvas(sessionId, r.projectId, null); // 宿主未自动绑定时本地补绑
|
|
21377
|
+
}
|
|
21378
|
+
followBoundCanvas({ force: true });
|
|
21379
|
+
return;
|
|
21380
|
+
}
|
|
21381
|
+
// 工作区通道失败(如会话未挂工作区):退回普通建项目通道
|
|
21382
|
+
await fallbackCreate();
|
|
21383
|
+
} catch (e) {
|
|
21384
|
+
try {
|
|
21385
|
+
await fallbackCreate();
|
|
21386
|
+
} catch {
|
|
21387
|
+
update((s) => { s.bindingCreating = false; s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21388
|
+
}
|
|
21389
|
+
}
|
|
21390
|
+
}
|
|
21391
|
+
/** 会话侧新建子画布后的本地登记:项目树/画布列表立即出现(与画布管理器同一数据源)。 */
|
|
21392
|
+
function registerLocalCanvas(projectId, canvasId, name) {
|
|
21393
|
+
const pid = String(projectId || '');
|
|
21394
|
+
const cid = String(canvasId || '');
|
|
21395
|
+
const cname = String(name || '').slice(0, 80);
|
|
21396
|
+
if (!pid || !cid) return;
|
|
21397
|
+
update((s) => {
|
|
21398
|
+
const pp = s.projects.find((x) => x.id === pid);
|
|
21399
|
+
if (!pp) return;
|
|
21400
|
+
const list = Array.isArray(pp.canvases) ? pp.canvases : [];
|
|
21401
|
+
if (!list.some((c) => c.id === cid)) {
|
|
21402
|
+
pp.canvases = [...list, { id: cid, name: cname, createdAt: Date.now() }];
|
|
21403
|
+
}
|
|
21404
|
+
});
|
|
21405
|
+
lsSet(LS_PROJECTS, S.projects);
|
|
21406
|
+
if (!loadGraphDoc(pid, cid)) saveGraphDoc(pid, emptyGraph(), cid); // 新画布首入空白
|
|
21407
|
+
scheduleSave();
|
|
21408
|
+
}
|
|
21409
|
+
/** 新建子画布并绑定(Host 先落登记;projectId 显式传入——未绑定态的项目二级菜单也能用)。 */
|
|
21410
|
+
async function createCanvasAndBind(sessionId, projectId, rawName) {
|
|
21411
|
+
if (bindingStaleGuard()) return;
|
|
21412
|
+
const name = String(rawName == null ? '' : rawName).trim();
|
|
21413
|
+
if (!sessionId || !projectId) return;
|
|
21414
|
+
if (!name) { update((s) => { s.bindingError = T('canvasNameRequired'); }); return; }
|
|
21415
|
+
try {
|
|
21416
|
+
const made = await hostRpc('canvasCreate', { projectId, name });
|
|
21417
|
+
update((s) => { s.bindingError = null; });
|
|
21418
|
+
if (made && made.ok && made.canvasId) {
|
|
21419
|
+
registerLocalCanvas(projectId, made.canvasId, made.name || name); // 本地先登记:项目树立即可见
|
|
21420
|
+
await bindSessionToCanvas(sessionId, projectId, made.canvasId);
|
|
21421
|
+
} else {
|
|
21422
|
+
update((s) => { s.bindingError = (made && made.error) || T('bindFail'); });
|
|
21423
|
+
}
|
|
21424
|
+
} catch (e) {
|
|
21425
|
+
update((s) => { s.bindingError = String((e && e.message) || e); });
|
|
21426
|
+
}
|
|
21427
|
+
}
|
|
21428
|
+
let bindingNewCanvasName = ''; // 内联新建输入(非受控:回车/按钮提交后弃用)
|
|
21429
|
+
/** 下拉菜单(宿主选择器格式:图标行 + 选中高亮 + 分隔线)。
|
|
21430
|
+
* 未绑定 = 仅会话 / 创建项目 / 已有项目列表(项目展开二级子画布 + 新建子画布);
|
|
21431
|
+
* 已绑定 = 项目锁定,只列本项目子画布。 */
|
|
21432
|
+
function BindingMenu() {
|
|
21433
|
+
const sessionId = S.activeSessionId;
|
|
21434
|
+
const b = S.sessionBinding || {};
|
|
21435
|
+
useEffect(() => {
|
|
21436
|
+
const onDown = (e) => {
|
|
21437
|
+
const t = e && e.target;
|
|
21438
|
+
if (t && t.closest && t.closest('.dshic-bind-menu, .dshic-bind-chip')) return;
|
|
21439
|
+
update((s) => { s.bindingMenuOpen = false; });
|
|
21440
|
+
};
|
|
21441
|
+
const esc = (e) => { if (e && e.key === 'Escape') update((s) => { s.bindingMenuOpen = false; }); };
|
|
21442
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
21443
|
+
document.addEventListener('keydown', esc, true);
|
|
21444
|
+
return () => {
|
|
21445
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
21446
|
+
document.removeEventListener('keydown', esc, true);
|
|
21447
|
+
};
|
|
21448
|
+
}, []);
|
|
21449
|
+
// 未绑定态懒加载可绑定项目(已绑定不需要项目列表——项目锁定)
|
|
21450
|
+
useEffect(() => {
|
|
21451
|
+
if (b.binding) return undefined;
|
|
21452
|
+
let alive = true;
|
|
21453
|
+
hostRpc('bindableProjects').then((r) => {
|
|
21454
|
+
if (alive) update((s) => { s.bindableProjects = (r && r.projects) || []; });
|
|
21455
|
+
}).catch(() => { if (alive) update((s) => { s.bindableProjects = []; }); });
|
|
21456
|
+
return () => { alive = false; };
|
|
21457
|
+
}, []);
|
|
21458
|
+
const close = () => update((s) => { s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null; });
|
|
21459
|
+
const row = (key, icon, label, onClick, o) => h('button', {
|
|
21460
|
+
key, type: 'button',
|
|
21461
|
+
className: 'dshic-menu-item'
|
|
21462
|
+
+ (o && o.selected ? ' is-selected' : '')
|
|
21463
|
+
+ (o && o.dim ? ' is-dim' : '')
|
|
21464
|
+
+ (o && o.indent ? ' dshic-bind-indent' : ''),
|
|
21465
|
+
onClick,
|
|
21466
|
+
},
|
|
21467
|
+
icon ? h('span', { key: 'i', className: 'dshic-bind-rowico' }, icon) : null,
|
|
21468
|
+
h('span', { key: 'l', className: 'dshic-bind-rowlabel' }, label),
|
|
21469
|
+
o && o.suffix ? h('span', { key: 's', className: 'dshic-bind-exp' }, o.suffix) : null,
|
|
21470
|
+
o && o.tail ? o.tail : null);
|
|
21471
|
+
const sep = (key) => h('div', { key, className: 'dshic-bind-sep' });
|
|
21472
|
+
const newRow = (pid, indent) => (S.bindingNewFor === pid
|
|
21473
|
+
? h('div', { key: 'newrow:' + pid, className: 'dshic-bind-newrow' + (indent ? ' dshic-bind-indent' : '') },
|
|
21474
|
+
h('input', {
|
|
21475
|
+
type: 'text', autoFocus: true,
|
|
21476
|
+
onInput: (e) => { bindingNewCanvasName = (e && e.target && e.target.value) || ''; },
|
|
21477
|
+
onKeyDown: (e) => { if (e && e.key === 'Enter' && bindingNewCanvasName.trim()) createCanvasAndBind(sessionId, pid, bindingNewCanvasName); },
|
|
21478
|
+
}),
|
|
21479
|
+
h('button', { type: 'button', onClick: () => createCanvasAndBind(sessionId, pid, bindingNewCanvasName) }, T('bindNewCanvas')))
|
|
21480
|
+
: row('newbtn:' + pid, Ic('plus', 14), T('bindNewCanvas'),
|
|
21481
|
+
() => update((s) => { s.bindingNewFor = pid; s.bindingMenuProject = pid; }), { indent }));
|
|
21482
|
+
const rows = [];
|
|
21483
|
+
// 旧宿主警告:绑定能力探针失败时置顶提示,所有绑定动作已被拦截
|
|
21484
|
+
if (S.hostBindingStale) rows.push(h('div', { key: '__stale__', className: 'dshic-bind-warn' }, T('bindHostStale')));
|
|
21485
|
+
// 项目列表数据源 = 客户端项目表(与画布管理器同源,老项目必现);宿主 bindableProjects 仅补充合并
|
|
21486
|
+
const localProjects = Array.isArray(S.projects) ? S.projects : [];
|
|
21487
|
+
const seenPids = new Set();
|
|
21488
|
+
const menuProjects = [];
|
|
21489
|
+
for (const p of localProjects) {
|
|
21490
|
+
if (!p || !p.id || seenPids.has(p.id)) continue;
|
|
21491
|
+
seenPids.add(p.id);
|
|
21492
|
+
menuProjects.push({ id: p.id, name: p.name || p.id, canvases: canvasesFromProject(p), updatedAt: p.updatedAt || 0 });
|
|
21493
|
+
}
|
|
21494
|
+
for (const p of (Array.isArray(S.bindableProjects) ? S.bindableProjects : [])) {
|
|
21495
|
+
if (!p || !p.id || seenPids.has(p.id)) continue;
|
|
21496
|
+
seenPids.add(p.id);
|
|
21497
|
+
menuProjects.push({ id: p.id, name: p.name || p.id, canvases: p.canvases || [], updatedAt: p.updatedAt || 0 });
|
|
21498
|
+
}
|
|
21499
|
+
menuProjects.sort((a, z) => (z.updatedAt || 0) - (a.updatedAt || 0));
|
|
21500
|
+
if (b.binding && b.project) {
|
|
21501
|
+
// —— 已绑定:项目锁定,只列本项目的子画布(宿主回读缺失时用本地项目表兜底)——
|
|
21502
|
+
rows.push(row('__open__', Ic('image', 14), T('bindOpenCanvas'), () => { close(); openBoundCanvasFromChip(); }));
|
|
21503
|
+
rows.push(sep('s1'));
|
|
21504
|
+
const boundLocal = localProjects.find((p) => p && p.id === b.project.id);
|
|
21505
|
+
const boundCanvases = (Array.isArray(b.canvases) && b.canvases.length) ? b.canvases : canvasesFromProject(boundLocal);
|
|
21506
|
+
for (const c of boundCanvases) {
|
|
21507
|
+
const cid = c.id == null ? null : c.id;
|
|
21508
|
+
const isCurrent = (b.binding.canvasId == null ? null : b.binding.canvasId) === cid;
|
|
21509
|
+
const occupiedBy = (b.occupied || {})[cid == null ? 'null' : cid] || null;
|
|
21510
|
+
rows.push(row('cv:' + String(cid) + ':' + c.name, Ic('image', 14), c.name || T('panel'),
|
|
21511
|
+
occupiedBy ? undefined : () => bindSessionToCanvas(sessionId, b.project.id, cid),
|
|
21512
|
+
{
|
|
21513
|
+
selected: isCurrent, dim: !!occupiedBy,
|
|
21514
|
+
tail: occupiedBy ? h('span', { key: 'occ', className: 'dshic-bind-occ' }, T('bindOccupied')) : null,
|
|
21515
|
+
}));
|
|
21516
|
+
}
|
|
21517
|
+
rows.push(newRow(b.project.id, false));
|
|
21518
|
+
rows.push(sep('s2'));
|
|
21519
|
+
rows.push(row('__only__', Ic('chat', 14), T('bindSessionOnly'), () => unbindSession(sessionId)));
|
|
21520
|
+
} else {
|
|
21521
|
+
// —— 未绑定:仅会话 / 创建项目 / 已有项目(项目展开二级子画布 + 新建子画布)——
|
|
21522
|
+
rows.push(row('__only__', Ic('chat', 14), T('bindSessionOnly'), close, { selected: true }));
|
|
21523
|
+
rows.push(row('__create__', Ic('plus', 14), T('bindCreateProjectAction'), () => createWorkspaceProject(sessionId)));
|
|
21524
|
+
rows.push(sep('s1'));
|
|
21525
|
+
if (!menuProjects.length && S.bindableProjects === null) {
|
|
21526
|
+
rows.push(row('__loading__', null, '…', null, { dim: true }));
|
|
21527
|
+
} else {
|
|
21528
|
+
for (const p of menuProjects) {
|
|
21529
|
+
const expanded = S.bindingMenuProject === p.id;
|
|
21530
|
+
rows.push(row('p:' + p.id, Ic('folder', 14), p.name || p.id,
|
|
21531
|
+
() => update((s) => { s.bindingMenuProject = expanded ? null : p.id; s.bindingNewFor = null; }),
|
|
21532
|
+
{ suffix: expanded ? '▾' : '▸' }));
|
|
21533
|
+
if (expanded) {
|
|
21534
|
+
for (const c of (p.canvases || [])) {
|
|
21535
|
+
const cid = c.id == null ? null : c.id;
|
|
21536
|
+
rows.push(row('pc:' + p.id + ':' + String(cid), Ic('image', 14), c.name || T('panel'),
|
|
21537
|
+
() => bindSessionToCanvas(sessionId, p.id, cid), { indent: true }));
|
|
21538
|
+
}
|
|
21539
|
+
rows.push(newRow(p.id, true));
|
|
21540
|
+
}
|
|
21541
|
+
}
|
|
21542
|
+
}
|
|
21543
|
+
}
|
|
21544
|
+
// 失败原因显示在菜单内(保持菜单打开,用户能看到为什么没生效)
|
|
21545
|
+
if (S.bindingError) rows.push(h('div', { key: '__err__', className: 'dshic-bind-err-inmenu' }, S.bindingError));
|
|
21546
|
+
return h('div', { className: 'dshic-menu dshic-bind-menu' }, rows);
|
|
21547
|
+
}
|
|
21548
|
+
/** composer 画布选择 chip。session 作用域槽位的组件:props.sessionId 由 Runner 标准属性提供。 */
|
|
21549
|
+
function SessionBindingChip(props) {
|
|
21550
|
+
useApp();
|
|
21551
|
+
const sessionId = props && props.sessionId;
|
|
21552
|
+
useEffect(() => {
|
|
21553
|
+
if (!sessionId) return undefined;
|
|
21554
|
+
update((s) => {
|
|
21555
|
+
const same = s.activeSessionId === sessionId;
|
|
21556
|
+
s.activeSessionId = sessionId;
|
|
21557
|
+
if (!same) s.sessionBinding = null; // 换会话:清旧绑定态(立即重拉)
|
|
21558
|
+
});
|
|
21559
|
+
refreshSessionBinding(sessionId);
|
|
21560
|
+
refreshBindingCapabilities();
|
|
21561
|
+
return () => { /* 保留 binding 缓存:切回会话时秒显,refresh 会覆盖 */ };
|
|
21562
|
+
}, [sessionId]);
|
|
21563
|
+
if (!sessionId) return null; // 老 Runner 不给会话身份 → chip 缺席(绑定不可用,画布走全局行为)
|
|
21564
|
+
const b = S.sessionBinding;
|
|
21565
|
+
if (!b || !b.loaded) return null; // 加载中不渲染(避免闪「建画布项目」)
|
|
21566
|
+
if (b.supported === false) return null; // 旧宿主:无工作区能力
|
|
21567
|
+
const bound = !!(b.binding && b.project);
|
|
21568
|
+
const ep = bound ? canvasEpisodeOf(b, b.binding.canvasId) : null;
|
|
21569
|
+
const openMenu = () => update((s) => { s.bindingMenuOpen = !s.bindingMenuOpen; });
|
|
21570
|
+
const chipLabel = bound
|
|
21571
|
+
? TPL(T('bindChipBound'), {
|
|
21572
|
+
project: (b.project && b.project.name) || b.project.id || '',
|
|
21573
|
+
name: ep ? ep.name : String(b.binding.canvasId || ''),
|
|
21574
|
+
})
|
|
21575
|
+
: (S.bindingCreating ? T('bindCreating') : T('bindSessionOnly'));
|
|
21576
|
+
const chip = h('button', {
|
|
21577
|
+
key: 'chip',
|
|
21578
|
+
type: 'button',
|
|
21579
|
+
className: 'dshic-bind-chip' + (bound ? ' is-bound' : ''),
|
|
21580
|
+
title: chipLabel,
|
|
21581
|
+
// 一体式下拉(与「选择工作区」选择器同构):整颗胶囊点击 = 开下拉,
|
|
21582
|
+
// 未绑定态先给「仅会话 / 创建项目 / 已有项目」选择,绝不点一下替用户决定
|
|
21583
|
+
onClick: openMenu,
|
|
21584
|
+
}, [
|
|
21585
|
+
h('span', { key: 'ico', className: 'dshic-bind-ico' }, Ic('folder', 14)),
|
|
21586
|
+
h('span', { key: 'label', className: 'dshic-bind-label' }, chipLabel),
|
|
21587
|
+
h('span', { key: 'caret', className: 'dshic-bind-caret' }, '▾'),
|
|
21588
|
+
]);
|
|
21589
|
+
return h('div', { className: 'dshic-bind' },
|
|
21590
|
+
chip,
|
|
21591
|
+
S.bindingMenuOpen ? h(BindingMenu, { key: 'menu' }) : null,
|
|
21592
|
+
S.bindingError && !S.bindingMenuOpen ? h('div', { key: 'err', className: 'dshic-bind-err' }, S.bindingError) : null,
|
|
21593
|
+
);
|
|
21594
|
+
}
|
|
21595
|
+
|
|
20826
21596
|
// ============================================================
|
|
20827
21597
|
// 插件入口
|
|
20828
21598
|
// ============================================================
|
|
@@ -20875,6 +21645,16 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20875
21645
|
label: () => T('panel'),
|
|
20876
21646
|
locale: NS,
|
|
20877
21647
|
}, PanelIcon));
|
|
21648
|
+
// —— 会话↔画布绑定:composer 画布选择 chip(session 作用域槽位,Runner 标准属性免费给 sessionId)——
|
|
21649
|
+
// 旧 runner 没有 conversation.input.left 槽位:try/catch 静默降级(无 chip,画布面板走全局行为,功能缺席不炸插件)
|
|
21650
|
+
try {
|
|
21651
|
+
ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
|
|
21652
|
+
name: 'conversation.input.left',
|
|
21653
|
+
id: 'infinite-canvas-binding',
|
|
21654
|
+
order: 40,
|
|
21655
|
+
locale: NS,
|
|
21656
|
+
}, SessionBindingChip));
|
|
21657
|
+
} catch { /* 旧 runner:绑定 chip 不可用(降级) */ }
|
|
20878
21658
|
// 面板根:包一层错误边界——任何渲染期崩溃都不再白屏,而是显示可复制的错误卡片
|
|
20879
21659
|
PanelErrorBoundary.__dshicClass = true; // 冒烟 walker 标记
|
|
20880
21660
|
function PanelRoot() {
|
|
@@ -20895,6 +21675,12 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20895
21675
|
const CANVAS_TAB_ID = '@ninkch/dsh-infinite-canvas'; // = 注册 id = 槽位 key
|
|
20896
21676
|
function CanvasHostedApp({ host }) {
|
|
20897
21677
|
useApp();
|
|
21678
|
+
const bindingRev = S.bindingRev; // 绑定刷新 → 跟随 effect 重跑(跟随守卫在 followBoundCanvas:仅 pane 自动)
|
|
21679
|
+
useEffect(() => {
|
|
21680
|
+
if (host !== 'pane') return; // 全屏面板不自动跟随(chip 显式动作走 force)
|
|
21681
|
+
followBoundCanvas();
|
|
21682
|
+
return undefined;
|
|
21683
|
+
}, [host, bindingRev]);
|
|
20898
21684
|
useEffect(() => {
|
|
20899
21685
|
// 挂载即声明宿主(后开者接管):在窄栏宿主里顺手收起画布自带的右侧栏(宽度不够)
|
|
20900
21686
|
const takeover = S.canvasHost !== host;
|