@restregular/dsh-powerup 0.10.7 → 0.12.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 +35 -0
- package/client.js +601 -17
- package/index.js +179 -3
- package/lib/progress-manager.js +147 -0
- package/lib/progress-tool.js +308 -0
- package/lib/task-resume.js +256 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +10 -4
package/client.js
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
|
|
84
84
|
/** Fallback bucket when the hero cannot resolve an owning workspace yet. */
|
|
85
85
|
const UNSCOPED_WORKSPACE = '__unscoped__';
|
|
86
|
-
const VERSION = '0.
|
|
86
|
+
const VERSION = '0.11.0';
|
|
87
87
|
const MENU_GAP = 8;
|
|
88
88
|
const MENU_WIDTH = 248;
|
|
89
89
|
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
@@ -310,6 +310,18 @@
|
|
|
310
310
|
'restart.desc': '重启会关闭并重新打开 DSH,正在运行的任务会中断。',
|
|
311
311
|
'restart.cancel': '取消',
|
|
312
312
|
'restart.confirm': '立即重启',
|
|
313
|
+
'restart.tasksTitle': '有 {count} 个任务尚未完成',
|
|
314
|
+
'restart.tasksHint': '普通重启不允许中断未完成任务。可以强制停止它们后再重启。',
|
|
315
|
+
'restart.forceLabel': '强制重启',
|
|
316
|
+
'restart.forceCloseLabel': '强制关闭',
|
|
317
|
+
'restart.resumeLabel': '重启后自动继续任务',
|
|
318
|
+
'restart.resumeLabelClose': '下次打开后自动继续任务',
|
|
319
|
+
'restart.resumeHint': '停止前记录这些会话,下次打开 DSH 时自动发送「继续」提示词。',
|
|
320
|
+
'restart.resumePromptLabel': '继续提示词(可选)',
|
|
321
|
+
'restart.resumePromptPlaceholder': '默认:继续之前未完成的任务。',
|
|
322
|
+
'restart.taskLine': '会话 {id}',
|
|
323
|
+
'restart.forceConfirm': '强制停止并重启',
|
|
324
|
+
'force.done': '已停止 {count} 个任务,将自动继续 {resumed} 个会话。',
|
|
313
325
|
'update.doneTitle': '安装完成',
|
|
314
326
|
'update.doneInstalled': '{name} 已安装 {version}。',
|
|
315
327
|
'update.doneDisabled': '{name} 已安装 {version},尚未启用。',
|
|
@@ -344,6 +356,22 @@
|
|
|
344
356
|
'update.invalidVersion': '请输入有效版本号(例如 1.2.3)',
|
|
345
357
|
'update.stopProfile': '当前 profile 不能热卸载该插件,请重启 DSH 后再试。',
|
|
346
358
|
'update.unsupportedTitle': '无法自动安装',
|
|
359
|
+
'page.taskProgressTitle': '任务进度速览',
|
|
360
|
+
'page.taskProgressDesc': '在会话顶部加一个「进度」按钮,点击后用当前会话的模型在后台分析会话记录,生成结构化的任务进度并用浮层展示。调用在旁路进行,不写入会话、不打断正在运行的任务;模型会按任务类型选择清单、阶段、里程碑或任务树,并可补充一段直接渲染给用户看的内容。',
|
|
361
|
+
'page.taskProgressHow': '在任意会话顶部点击「进度」按钮,面板会显示最近一次结果;首次使用点「生成进度」。生成期间可继续正常操作会话。',
|
|
362
|
+
'progress.title': '任务进度',
|
|
363
|
+
'progress.label': '进度',
|
|
364
|
+
'progress.subtitle': '由当前会话模型在后台生成',
|
|
365
|
+
'progress.hint': '还没有进度报告,点「生成进度」开始分析。',
|
|
366
|
+
'progress.empty': '还没有生成过进度报告。',
|
|
367
|
+
'progress.generate': '生成进度',
|
|
368
|
+
'progress.refresh': '重新生成',
|
|
369
|
+
'progress.retry': '重试',
|
|
370
|
+
'progress.loading': '正在后台分析会话进度…',
|
|
371
|
+
'progress.close': '关闭',
|
|
372
|
+
'progress.failed': '生成进度失败',
|
|
373
|
+
'progress.stale': '报告已过期',
|
|
374
|
+
'progress.updated': '更新于 {time}',
|
|
347
375
|
'page.promptsTitle': '工作区提示词',
|
|
348
376
|
'page.promptsDesc': '为每个工作区保存可复用的提示词。开启后,新会话行的 Agent 预设右侧会出现一个下拉列表,选择即可把提示词填入输入框(可继续编辑),或点提示词右侧的发送按钮直接发出。',
|
|
349
377
|
'page.promptsHow': '先启用本功能,再切到「工作区提示词」标签页创建提示词;提示词按工作区隔离,没有标题时显示开头几个字。',
|
|
@@ -616,6 +644,18 @@
|
|
|
616
644
|
'restart.desc': 'Restarting closes and reopens DSH; running tasks are interrupted.',
|
|
617
645
|
'restart.cancel': 'Cancel',
|
|
618
646
|
'restart.confirm': 'Restart now',
|
|
647
|
+
'restart.tasksTitle': '{count} unfinished task(s)',
|
|
648
|
+
'restart.tasksHint': 'A normal restart cannot interrupt unfinished tasks. Force-stop them first, then restart.',
|
|
649
|
+
'restart.forceLabel': 'Force restart',
|
|
650
|
+
'restart.forceCloseLabel': 'Force close',
|
|
651
|
+
'restart.resumeLabel': 'Resume tasks after restart',
|
|
652
|
+
'restart.resumeLabelClose': 'Resume tasks on next launch',
|
|
653
|
+
'restart.resumeHint': 'Record these sessions before stopping; on next launch DSH sends a "continue" prompt automatically.',
|
|
654
|
+
'restart.resumePromptLabel': 'Continuation prompt (optional)',
|
|
655
|
+
'restart.resumePromptPlaceholder': 'Default: Continue the previous unfinished task.',
|
|
656
|
+
'restart.taskLine': 'Session {id}',
|
|
657
|
+
'restart.forceConfirm': 'Force-stop and restart',
|
|
658
|
+
'force.done': 'Stopped {count} task(s); {resumed} session(s) will resume automatically.',
|
|
619
659
|
'update.doneTitle': 'Install complete',
|
|
620
660
|
'update.doneInstalled': '{name} installed {version}.',
|
|
621
661
|
'update.doneDisabled': '{name} {version} is installed but not enabled.',
|
|
@@ -650,6 +690,22 @@
|
|
|
650
690
|
'update.invalidVersion': 'Enter a valid version, for example 1.2.3.',
|
|
651
691
|
'update.stopProfile': 'This profile cannot hot-remove the plugin; restart DSH and try again.',
|
|
652
692
|
'update.unsupportedTitle': 'Cannot install automatically',
|
|
693
|
+
'page.taskProgressTitle': 'Task progress snapshot',
|
|
694
|
+
'page.taskProgressDesc': 'Adds a Progress button to the session header. Clicking it asks the current session model to analyze the session in the background and produce a structured progress report shown in a floating panel. The call is off to the side: nothing is written to the session and the running task is never interrupted. The model picks a checklist, phases, milestones, or task tree to fit the work, and may add content rendered directly in the panel.',
|
|
695
|
+
'page.taskProgressHow': 'Click Progress in any session header to see the last report; on first use press Generate. You can keep working in the session while it runs.',
|
|
696
|
+
'progress.title': 'Task progress',
|
|
697
|
+
'progress.label': 'Progress',
|
|
698
|
+
'progress.subtitle': 'Generated in the background by this session model',
|
|
699
|
+
'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
|
|
700
|
+
'progress.empty': 'No progress report generated yet.',
|
|
701
|
+
'progress.generate': 'Generate progress',
|
|
702
|
+
'progress.refresh': 'Regenerate',
|
|
703
|
+
'progress.retry': 'Retry',
|
|
704
|
+
'progress.loading': 'Analyzing session progress in the background…',
|
|
705
|
+
'progress.close': 'Close',
|
|
706
|
+
'progress.failed': 'Could not generate progress',
|
|
707
|
+
'progress.stale': 'Stale report',
|
|
708
|
+
'progress.updated': 'Updated at {time}',
|
|
653
709
|
'page.promptsTitle': 'Workspace prompts',
|
|
654
710
|
'page.promptsDesc': 'Save reusable prompts per workspace. When enabled, a dropdown appears next to the Agent preset in the New Session row: pick a prompt to fill the composer (still editable), or click its send button to send it right away.',
|
|
655
711
|
'page.promptsHow': 'Enable this feature, then open the "Workspace prompts" tab to create prompts. Prompts are scoped per workspace; without a title the first few characters are shown.',
|
|
@@ -747,6 +803,7 @@
|
|
|
747
803
|
contentRendering: true,
|
|
748
804
|
dualSend: false,
|
|
749
805
|
workspacePrompts: true,
|
|
806
|
+
taskProgress: true,
|
|
750
807
|
oneClickEnable: true,
|
|
751
808
|
oneClickRestart: true,
|
|
752
809
|
};
|
|
@@ -769,6 +826,7 @@
|
|
|
769
826
|
contentRendering: parsed.contentRendering !== false,
|
|
770
827
|
dualSend: parsed.dualSend === true,
|
|
771
828
|
workspacePrompts: parsed.workspacePrompts !== false,
|
|
829
|
+
taskProgress: parsed.taskProgress !== false,
|
|
772
830
|
oneClickEnable: parsed.oneClickEnable !== false,
|
|
773
831
|
oneClickRestart: parsed.oneClickRestart !== false,
|
|
774
832
|
};
|
|
@@ -1203,11 +1261,21 @@
|
|
|
1203
1261
|
window.alert(t(options.unsupportedKey, { reason: capability?.reason ?? '' }));
|
|
1204
1262
|
return;
|
|
1205
1263
|
}
|
|
1264
|
+
const tasks = Array.isArray(capability?.runningTasks) ? capability.runningTasks : [];
|
|
1206
1265
|
if (window.confirm(t(options.titleKey) + ' ' + t(options.descKey)) !== true) return;
|
|
1266
|
+
// With unfinished tasks, the last-resort path offers the forced
|
|
1267
|
+
// variant through a second confirmation and resumes by default.
|
|
1268
|
+
let force = false;
|
|
1269
|
+
let resume = false;
|
|
1270
|
+
if (tasks.length > 0) {
|
|
1271
|
+
if (window.confirm(t('restart.tasksTitle', { count: tasks.length }) + '\n' + t('restart.tasksHint')) !== true) return;
|
|
1272
|
+
force = true;
|
|
1273
|
+
resume = window.confirm(t(options.action === 'close' ? 'restart.resumeLabelClose' : 'restart.resumeLabel') + '\n' + t('restart.resumeHint')) === true;
|
|
1274
|
+
}
|
|
1207
1275
|
const response = await fetch(options.api, {
|
|
1208
1276
|
method: 'POST',
|
|
1209
1277
|
headers: { 'content-type': 'application/json' },
|
|
1210
|
-
body: JSON.stringify({ action: options.action }),
|
|
1278
|
+
body: JSON.stringify({ action: options.action, force, resume }),
|
|
1211
1279
|
});
|
|
1212
1280
|
const data = await response.json().catch(() => null);
|
|
1213
1281
|
if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? 'HTTP ' + response.status);
|
|
@@ -3816,6 +3884,16 @@
|
|
|
3816
3884
|
);
|
|
3817
3885
|
}
|
|
3818
3886
|
|
|
3887
|
+
/** A radar/target glyph for the task-progress side call. */
|
|
3888
|
+
function ProgressIcon({ size = 16 }) {
|
|
3889
|
+
return h(Icon, { size },
|
|
3890
|
+
h('circle', { cx: '8', cy: '8', r: '5.8', fill: 'none', stroke: 'currentColor', strokeWidth: '1.2' }),
|
|
3891
|
+
h('circle', { cx: '8', cy: '8', r: '2.6', fill: 'none', stroke: 'currentColor', strokeWidth: '1.2' }),
|
|
3892
|
+
h('path', { d: 'M8 8 12.4 3.6', stroke: 'currentColor', strokeWidth: '1.2', strokeLinecap: 'round' }),
|
|
3893
|
+
h('circle', { cx: '8', cy: '8', r: '.9', fill: 'currentColor' }),
|
|
3894
|
+
);
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3819
3897
|
function ChevronDownIcon({ size = 12 }) {
|
|
3820
3898
|
return h(Icon, { size },
|
|
3821
3899
|
h('path', {
|
|
@@ -4053,6 +4131,17 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
|
|
|
4053
4131
|
.dsh-powerup-update-field{display:flex;flex-direction:column;gap:8px;min-width:0}
|
|
4054
4132
|
.dsh-powerup-update-label{display:block;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;font-weight:500}
|
|
4055
4133
|
.dsh-powerup-update-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
|
4134
|
+
.dsh-powerup-update-tasks{display:flex;flex-direction:column;gap:8px;padding:12px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2)}
|
|
4135
|
+
.dsh-powerup-update-tasks>strong{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
|
|
4136
|
+
.dsh-powerup-update-task-list{display:flex;flex-direction:column;gap:4px;max-height:150px;overflow-y:auto;margin:2px 0;padding:0;list-style:none}
|
|
4137
|
+
.dsh-powerup-update-task-list li{display:flex;align-items:center;gap:7px;min-width:0;padding:4px 8px;border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:16px}
|
|
4138
|
+
.dsh-powerup-update-task-list code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11px}
|
|
4139
|
+
.dsh-powerup-update-task-dot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-warning-foreground,var(--dsw-alias-brand-primary))}
|
|
4140
|
+
.dsh-powerup-app-check{display:flex;align-items:flex-start;gap:9px;padding:4px 0;cursor:pointer}
|
|
4141
|
+
.dsh-powerup-app-check input{flex:none;margin:2px 0 0;accent-color:var(--dsw-alias-brand-primary)}
|
|
4142
|
+
.dsh-powerup-app-check span{display:flex;flex-direction:column;gap:1px;min-width:0}
|
|
4143
|
+
.dsh-powerup-app-check strong{color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px;font-weight:500}
|
|
4144
|
+
.dsh-powerup-app-check small{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
4056
4145
|
.dsh-powerup-update-name{color:var(--dsw-alias-label-tertiary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px;line-height:18px;overflow-wrap:anywhere}
|
|
4057
4146
|
.dsh-powerup-update-summary{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
4058
4147
|
.dsh-powerup-update-list-state{display:flex;flex-direction:column;gap:10px;padding:12px}
|
|
@@ -4342,6 +4431,69 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4342
4431
|
.dsh-powerup-prompt-modal-close:focus-visible,.dsh-powerup-prompt-modal-cancel:focus-visible,.dsh-powerup-prompt-modal-save:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
4343
4432
|
@media (max-width:560px){.dsh-powerup-prompt-modal-mask{padding:12px}.dsh-powerup-prompt-modal-head{padding:16px 12px 8px 16px}.dsh-powerup-prompt-modal-body{padding:0 16px 4px}.dsh-powerup-prompt-modal-foot{padding:12px 16px 16px}}
|
|
4344
4433
|
@media (prefers-reduced-motion:reduce){.dsh-powerup-prompt-pop,.dsh-powerup-prompt-trigger-chevron,.dsh-powerup-prompt-modal-mask,.dsh-powerup-prompt-modal,.dsh-powerup-prompt-modal-mask.is-closing,.dsh-powerup-prompt-modal.is-closing{transition:none;animation:none}}
|
|
4434
|
+
`;
|
|
4435
|
+
|
|
4436
|
+
const PROGRESS_CSS = `
|
|
4437
|
+
/* Task-progress header button + floating panel. */
|
|
4438
|
+
.dsh-powerup-progress-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:26px;height:26px;padding:0 7px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;line-height:1;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
|
|
4439
|
+
.dsh-powerup-progress-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3)}
|
|
4440
|
+
.dsh-powerup-progress-btn:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
4441
|
+
.dsh-powerup-progress-btn.is-running{color:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}
|
|
4442
|
+
.dsh-powerup-progress-btn.is-running svg{animation:dsh-powerup-progress-spin 1.4s linear infinite}
|
|
4443
|
+
@keyframes dsh-powerup-progress-spin{to{transform:rotate(360deg)}}
|
|
4444
|
+
.dsh-powerup-progress-btn-dot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary)}
|
|
4445
|
+
.dsh-powerup-progress-panel{position:fixed;z-index:1500;box-sizing:border-box;display:flex;flex-direction:column;width:360px;max-width:calc(100vw - 24px);max-height:min(72vh,620px);border:0;border-radius:var(--dsw-radius-panel,14px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:1.55;pointer-events:auto;overflow:hidden;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);animation:dsh-powerup-progress-in .15s ease-out}
|
|
4446
|
+
@keyframes dsh-powerup-progress-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
4447
|
+
.dsh-powerup-progress-head{display:flex;align-items:flex-start;gap:8px;padding:14px 14px 10px 16px;border-bottom:.5px solid var(--dsw-alias-border-l1)}
|
|
4448
|
+
.dsh-powerup-progress-heading{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}
|
|
4449
|
+
.dsh-powerup-progress-title{font-size:14px;font-weight:600;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
4450
|
+
.dsh-powerup-progress-sub{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:1.4}
|
|
4451
|
+
.dsh-powerup-progress-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-2px -2px 0 0;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:17px;line-height:1;cursor:pointer}
|
|
4452
|
+
.dsh-powerup-progress-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4453
|
+
.dsh-powerup-progress-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:12px 16px 16px}
|
|
4454
|
+
.dsh-powerup-progress-loading{display:flex;align-items:center;gap:9px;color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
4455
|
+
.dsh-powerup-progress-error{margin:0;color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:1.6;overflow-wrap:anywhere}
|
|
4456
|
+
.dsh-powerup-progress-empty{color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:1.6}
|
|
4457
|
+
.dsh-powerup-progress-summary{margin:0 0 12px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.6;overflow-wrap:anywhere}
|
|
4458
|
+
.dsh-powerup-progress-meter{display:flex;flex-direction:column;gap:5px;margin:0 0 14px}
|
|
4459
|
+
.dsh-powerup-progress-meter-head{display:flex;align-items:center;justify-content:space-between;color:var(--dsw-alias-label-tertiary);font-size:10.5px}
|
|
4460
|
+
.dsh-powerup-progress-meter-head strong{color:var(--dsw-alias-brand-primary);font-size:12px;font-variant-numeric:tabular-nums}
|
|
4461
|
+
.dsh-powerup-progress-track{height:6px;border-radius:999px;background:var(--dsw-alias-border-l2);overflow:hidden}
|
|
4462
|
+
.dsh-powerup-progress-fill{height:100%;border-radius:999px;background:var(--dsw-alias-brand-primary);transition:width .3s ease}
|
|
4463
|
+
.dsh-powerup-progress-section{margin:12px 0 6px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase}
|
|
4464
|
+
.dsh-powerup-progress-items{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}
|
|
4465
|
+
.dsh-powerup-progress-item{display:flex;align-items:flex-start;gap:8px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1)}
|
|
4466
|
+
.dsh-powerup-progress-badge{flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 5px;border-radius:8px;font-size:9.5px;font-weight:700;letter-spacing:.02em}
|
|
4467
|
+
.dsh-powerup-progress-badge[data-status=pending]{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary)}
|
|
4468
|
+
.dsh-powerup-progress-badge[data-status=in-progress]{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 14%,transparent);color:var(--dsw-alias-state-business-primary)}
|
|
4469
|
+
.dsh-powerup-progress-badge[data-status=done]{background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 14%,transparent);color:var(--dsw-alias-state-success-primary)}
|
|
4470
|
+
.dsh-powerup-progress-badge[data-status=blocked]{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 14%,transparent);color:var(--dsw-alias-state-error-primary)}
|
|
4471
|
+
.dsh-powerup-progress-item-copy{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}
|
|
4472
|
+
.dsh-powerup-progress-item-title{color:var(--dsw-alias-label-primary);font-size:11.5px;line-height:1.5;overflow-wrap:anywhere}
|
|
4473
|
+
.dsh-powerup-progress-item-detail{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:1.5;overflow-wrap:anywhere}
|
|
4474
|
+
.dsh-powerup-progress-children{margin:4px 0 0 6px;padding-left:10px;border-left:1px solid var(--dsw-alias-border-l2)}
|
|
4475
|
+
.dsh-powerup-progress-blockers{margin:12px 0 0;padding:8px 10px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 30%,transparent);border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 7%,transparent);color:var(--dsw-alias-state-error-primary);font-size:11px;line-height:1.55}
|
|
4476
|
+
.dsh-powerup-progress-blockers ul{margin:4px 0 0;padding-left:16px}
|
|
4477
|
+
.dsh-powerup-progress-display{display:flex;flex-direction:column;gap:10px;margin-top:14px;padding-top:12px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
4478
|
+
.dsh-powerup-progress-display-head{color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase}
|
|
4479
|
+
.dsh-powerup-progress-display-text{color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:1.65;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
4480
|
+
.dsh-powerup-progress-kv{display:flex;flex-direction:column;gap:4px}
|
|
4481
|
+
.dsh-powerup-progress-kv-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
|
|
4482
|
+
.dsh-powerup-progress-kv-row dt{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px}
|
|
4483
|
+
.dsh-powerup-progress-kv-row dd{margin:0;min-width:0;text-align:right;color:var(--dsw-alias-label-primary);font-size:11.5px;overflow-wrap:anywhere}
|
|
4484
|
+
.dsh-powerup-progress-callout{padding:8px 10px;border-radius:8px;font-size:11.5px;line-height:1.6;overflow-wrap:anywhere}
|
|
4485
|
+
.dsh-powerup-progress-callout[data-tone=info]{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary)}
|
|
4486
|
+
.dsh-powerup-progress-callout[data-tone=warn]{background:color-mix(in srgb,var(--dsw-alias-state-warning-primary,var(--dsw-alias-state-error-primary)) 10%,transparent);color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-state-error-primary))}
|
|
4487
|
+
.dsh-powerup-progress-callout[data-tone=success]{background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary)}
|
|
4488
|
+
.dsh-powerup-progress-bar{display:flex;flex-direction:column;gap:3px;margin-bottom:6px}
|
|
4489
|
+
.dsh-powerup-progress-bar-head{display:flex;justify-content:space-between;color:var(--dsw-alias-label-secondary);font-size:10.5px}
|
|
4490
|
+
.dsh-powerup-progress-code{margin:0;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11px;line-height:1.5;overflow-x:auto;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
4491
|
+
.dsh-powerup-progress-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 16px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
4492
|
+
.dsh-powerup-progress-refresh{height:28px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:11.5px;line-height:1.5;cursor:pointer}
|
|
4493
|
+
.dsh-powerup-progress-refresh:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4494
|
+
.dsh-powerup-progress-refresh:disabled{opacity:.45;cursor:not-allowed}
|
|
4495
|
+
.dsh-powerup-progress-time{color:var(--dsw-alias-label-caption);font-size:10px}
|
|
4496
|
+
@media (prefers-reduced-motion:reduce){.dsh-powerup-progress-panel,.dsh-powerup-progress-btn.is-running svg,.dsh-powerup-progress-fill{animation:none;transition:none}}
|
|
4345
4497
|
`;
|
|
4346
4498
|
|
|
4347
4499
|
/** Max display length of a session option, in Unicode code points. */
|
|
@@ -5558,7 +5710,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
5558
5710
|
try {
|
|
5559
5711
|
const style = document.createElement('style');
|
|
5560
5712
|
style.setAttribute('data-dsh-powerup', '');
|
|
5561
|
-
style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + SCROLL_TOP_CSS + '\n' + RENDERING_CSS + '\n' + PROMPTS_CSS;
|
|
5713
|
+
style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + SCROLL_TOP_CSS + '\n' + RENDERING_CSS + '\n' + PROMPTS_CSS + '\n' + PROGRESS_CSS;
|
|
5562
5714
|
document.head.appendChild(style);
|
|
5563
5715
|
ctx.effect(() => () => style.remove(), 'dsh-powerup: styles');
|
|
5564
5716
|
} catch (error) {
|
|
@@ -7030,6 +7182,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7030
7182
|
const [appCapability, setAppCapability] = useState(null);
|
|
7031
7183
|
const [appBusy, setAppBusy] = useState(false);
|
|
7032
7184
|
const [appError, setAppError] = useState(null);
|
|
7185
|
+
/** Running tasks reported by the Host for the app action dialog. */
|
|
7186
|
+
const [appTasks, setAppTasks] = useState([]);
|
|
7187
|
+
/** Checkbox: force-stopped tasks are resumed on next launch. */
|
|
7188
|
+
const [appResume, setAppResume] = useState(true);
|
|
7189
|
+
/** Optional custom continuation prompt. */
|
|
7190
|
+
const [appResumePrompt, setAppResumePrompt] = useState('');
|
|
7033
7191
|
const tokenRef = useRef(null);
|
|
7034
7192
|
const abortRef = useRef(null);
|
|
7035
7193
|
const buttonsRef = useRef(new Set());
|
|
@@ -7715,15 +7873,31 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7715
7873
|
const readRestartCapability = () => readAppCapability(UPDATE_API);
|
|
7716
7874
|
|
|
7717
7875
|
/** POST one app-control command; throws when the Host refuses. */
|
|
7718
|
-
const requestAppAction = async (action) => {
|
|
7876
|
+
const requestAppAction = async (action, options = {}) => {
|
|
7719
7877
|
const api = action === 'close' ? CLOSE_API : UPDATE_API;
|
|
7878
|
+
// Sending a body opts into the task-aware path. The plugin self-update
|
|
7879
|
+
// flow calls requestAppRestart() with no options and keeps its old
|
|
7880
|
+
// behaviour (no task gate) by not sending a body.
|
|
7881
|
+
const aware = options.aware === true;
|
|
7882
|
+
const body = aware ? JSON.stringify({
|
|
7883
|
+
action,
|
|
7884
|
+
force: options.force === true,
|
|
7885
|
+
resume: options.resume === true,
|
|
7886
|
+
resumePrompt: typeof options.resumePrompt === 'string' ? options.resumePrompt : '',
|
|
7887
|
+
}) : undefined;
|
|
7720
7888
|
const response = await fetch(api, {
|
|
7721
7889
|
method: 'POST',
|
|
7722
|
-
headers: { 'content-type': 'application/json' },
|
|
7723
|
-
body:
|
|
7890
|
+
headers: body === undefined ? undefined : { 'content-type': 'application/json' },
|
|
7891
|
+
...(body === undefined ? {} : { body }),
|
|
7724
7892
|
});
|
|
7725
7893
|
const data = await response.json().catch(() => null);
|
|
7726
|
-
if (!response.ok || data?.ok !== true)
|
|
7894
|
+
if (!response.ok || data?.ok !== true) {
|
|
7895
|
+
if (data?.code === 'tasks-running' && Array.isArray(data.runningTasks)) {
|
|
7896
|
+
setAppTasks(data.runningTasks);
|
|
7897
|
+
}
|
|
7898
|
+
throw new Error(data?.error ?? `HTTP ${response.status}`);
|
|
7899
|
+
}
|
|
7900
|
+
return data;
|
|
7727
7901
|
};
|
|
7728
7902
|
|
|
7729
7903
|
/** The restart command, as the install flow spells it. */
|
|
@@ -7735,8 +7909,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7735
7909
|
setAppCapability(null);
|
|
7736
7910
|
setAppError(null);
|
|
7737
7911
|
setAppBusy(false);
|
|
7738
|
-
|
|
7739
|
-
|
|
7912
|
+
setAppTasks([]);
|
|
7913
|
+
setAppResume(true);
|
|
7914
|
+
setAppResumePrompt('');
|
|
7915
|
+
const api = action === 'close' ? CLOSE_API : UPDATE_API;
|
|
7916
|
+
void fetch(api, { headers: { accept: 'application/json' } })
|
|
7917
|
+
.then((response) => response.json())
|
|
7918
|
+
.then((data) => {
|
|
7919
|
+
setAppCapability({
|
|
7920
|
+
supported: data?.ok === true && data.supported === true,
|
|
7921
|
+
reason: typeof data?.reason === 'string' ? data.reason : '',
|
|
7922
|
+
});
|
|
7923
|
+
if (Array.isArray(data?.runningTasks)) setAppTasks(data.runningTasks);
|
|
7924
|
+
})
|
|
7925
|
+
.catch((error) => setAppCapability({ supported: false, reason: errorText(error) }));
|
|
7740
7926
|
};
|
|
7741
7927
|
const openAppActionRef = useRef(() => {});
|
|
7742
7928
|
openAppActionRef.current = openAppAction;
|
|
@@ -7756,12 +7942,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7756
7942
|
}, []);
|
|
7757
7943
|
|
|
7758
7944
|
/** Confirm the app-level action (restart or close). */
|
|
7759
|
-
const confirmAppAction = async () => {
|
|
7945
|
+
const confirmAppAction = async (forced = false) => {
|
|
7760
7946
|
if (appBusy) return;
|
|
7947
|
+
if (!forced && appTasks.length > 0) return;
|
|
7761
7948
|
setAppBusy(true);
|
|
7762
7949
|
setAppError(null);
|
|
7763
7950
|
try {
|
|
7764
|
-
await requestAppAction(appAsk === 'close' ? 'close' : 'restart'
|
|
7951
|
+
const data = await requestAppAction(appAsk === 'close' ? 'close' : 'restart', {
|
|
7952
|
+
aware: true,
|
|
7953
|
+
force: forced,
|
|
7954
|
+
resume: forced && appResume,
|
|
7955
|
+
resumePrompt: appResumePrompt,
|
|
7956
|
+
});
|
|
7957
|
+
// The app is about to exit; nothing more to render.
|
|
7958
|
+
void data;
|
|
7765
7959
|
} catch (error) {
|
|
7766
7960
|
setAppBusy(false);
|
|
7767
7961
|
setAppError(errorText(error) || tRef.current('update.unknown'));
|
|
@@ -7854,6 +8048,41 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7854
8048
|
),
|
|
7855
8049
|
h('div', { className: 'dsh-powerup-update-body' },
|
|
7856
8050
|
h('p', { className: 'dsh-powerup-update-note' }, t(appAction === 'close' ? 'close.desc' : 'restart.desc')),
|
|
8051
|
+
appTasks.length > 0
|
|
8052
|
+
? h('div', { className: 'dsh-powerup-update-tasks' },
|
|
8053
|
+
h('strong', null, t('restart.tasksTitle', { count: appTasks.length })),
|
|
8054
|
+
h('p', { className: 'dsh-powerup-update-note' }, t('restart.tasksHint')),
|
|
8055
|
+
h('ul', { className: 'dsh-powerup-update-task-list' },
|
|
8056
|
+
appTasks.slice(0, 8).map((task, index) => h('li', { key: `${task.kind}-${task.id}-${index}` },
|
|
8057
|
+
h('span', { className: 'dsh-powerup-update-task-dot' }),
|
|
8058
|
+
h('code', null, t('restart.taskLine', { id: task.id })),
|
|
8059
|
+
task.title && task.title !== 'session' ? h('span', null, ` — ${task.title}`) : null,
|
|
8060
|
+
)),
|
|
8061
|
+
),
|
|
8062
|
+
h('label', { className: 'dsh-powerup-app-check' },
|
|
8063
|
+
h('input', {
|
|
8064
|
+
type: 'checkbox',
|
|
8065
|
+
checked: appResume,
|
|
8066
|
+
onChange: (event) => setAppResume(event.target.checked === true),
|
|
8067
|
+
disabled: appBusy,
|
|
8068
|
+
}),
|
|
8069
|
+
h('span', null,
|
|
8070
|
+
h('strong', null, t(appAction === 'close' ? 'restart.resumeLabelClose' : 'restart.resumeLabel')),
|
|
8071
|
+
h('small', null, t('restart.resumeHint')),
|
|
8072
|
+
),
|
|
8073
|
+
),
|
|
8074
|
+
appResume
|
|
8075
|
+
? h('input', {
|
|
8076
|
+
className: 'dsh-powerup-prompt-input',
|
|
8077
|
+
type: 'text',
|
|
8078
|
+
value: appResumePrompt,
|
|
8079
|
+
placeholder: t('restart.resumePromptPlaceholder'),
|
|
8080
|
+
disabled: appBusy,
|
|
8081
|
+
onChange: (event) => setAppResumePrompt(event.target.value),
|
|
8082
|
+
})
|
|
8083
|
+
: null,
|
|
8084
|
+
)
|
|
8085
|
+
: null,
|
|
7857
8086
|
appCapability !== null && appCapability.supported !== true
|
|
7858
8087
|
? notice('warn', h(WarnIcon, { size: 14 }), null, t(appAction === 'close' ? 'close.unsupported' : 'update.restartUnsupported', { reason: appCapability.reason ?? '' }))
|
|
7859
8088
|
: null,
|
|
@@ -7867,12 +8096,19 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
7867
8096
|
),
|
|
7868
8097
|
h('div', { className: 'dsh-powerup-update-foot' },
|
|
7869
8098
|
h('button', { type: 'button', className: 'dsh-powerup-update-ghost', disabled: appBusy, onClick: () => setAppAsk(null) }, t(appAction === 'close' ? 'close.cancel' : 'restart.cancel')),
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
8099
|
+
appTasks.length > 0
|
|
8100
|
+
? h('button', {
|
|
8101
|
+
type: 'button',
|
|
8102
|
+
className: 'dsh-powerup-update-primary',
|
|
8103
|
+
disabled: appBusy || appCapability?.supported !== true,
|
|
8104
|
+
onClick: () => void confirmAppAction(true),
|
|
8105
|
+
}, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'restart.forceCloseLabel' : 'restart.forceLabel'))
|
|
8106
|
+
: h('button', {
|
|
8107
|
+
type: 'button',
|
|
8108
|
+
className: 'dsh-powerup-update-primary',
|
|
8109
|
+
disabled: appBusy || appCapability?.supported !== true,
|
|
8110
|
+
onClick: () => void confirmAppAction(false),
|
|
8111
|
+
}, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'close.confirm' : 'restart.confirm')),
|
|
7876
8112
|
),
|
|
7877
8113
|
),
|
|
7878
8114
|
);
|
|
@@ -9470,6 +9706,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9470
9706
|
featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
|
|
9471
9707
|
featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
|
|
9472
9708
|
featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
|
|
9709
|
+
featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow'),
|
|
9473
9710
|
featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
|
|
9474
9711
|
featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
|
|
9475
9712
|
featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
|
|
@@ -9523,6 +9760,343 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9523
9760
|
}
|
|
9524
9761
|
}
|
|
9525
9762
|
|
|
9763
|
+
// ------------------------------------------------------------------
|
|
9764
|
+
// Task progress: header button + body-portal panel
|
|
9765
|
+
// ------------------------------------------------------------------
|
|
9766
|
+
const PROGRESS_API = '/dsh-powerup/api/progress';
|
|
9767
|
+
|
|
9768
|
+
/** POST to the progress route; returns the parsed body. */
|
|
9769
|
+
async function progressRequest(sessionId, action) {
|
|
9770
|
+
const response = await fetch(PROGRESS_API, {
|
|
9771
|
+
method: 'POST',
|
|
9772
|
+
headers: { 'content-type': 'application/json' },
|
|
9773
|
+
body: JSON.stringify({ sessionId, action }),
|
|
9774
|
+
});
|
|
9775
|
+
const body = await response.json();
|
|
9776
|
+
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
9777
|
+
return body;
|
|
9778
|
+
}
|
|
9779
|
+
|
|
9780
|
+
const STATUS_LABEL = {
|
|
9781
|
+
pending: '待办', 'in-progress': '进行中', done: '完成', blocked: '受阻',
|
|
9782
|
+
};
|
|
9783
|
+
const MODE_LABEL = {
|
|
9784
|
+
checklist: '任务清单', phases: '阶段', milestones: '里程碑', tree: '任务树',
|
|
9785
|
+
};
|
|
9786
|
+
|
|
9787
|
+
/** One status badge. */
|
|
9788
|
+
function ProgressBadge(status) {
|
|
9789
|
+
return h('span', {
|
|
9790
|
+
className: 'dsh-powerup-progress-badge',
|
|
9791
|
+
'data-status': status,
|
|
9792
|
+
}, STATUS_LABEL[status] ?? status);
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9795
|
+
/** Render one node (checklist step / phase / milestone / tree node). */
|
|
9796
|
+
function ProgressItem(title, status, detail, children, key) {
|
|
9797
|
+
return h('li', { key, className: 'dsh-powerup-progress-item' },
|
|
9798
|
+
ProgressBadge(status),
|
|
9799
|
+
h('div', { className: 'dsh-powerup-progress-item-copy' },
|
|
9800
|
+
h('span', { className: 'dsh-powerup-progress-item-title' }, title),
|
|
9801
|
+
detail ? h('span', { className: 'dsh-powerup-progress-item-detail' }, detail) : null,
|
|
9802
|
+
Array.isArray(children) && children.length > 0
|
|
9803
|
+
? h('ul', { className: 'dsh-powerup-progress-children' }, children)
|
|
9804
|
+
: null,
|
|
9805
|
+
),
|
|
9806
|
+
);
|
|
9807
|
+
}
|
|
9808
|
+
|
|
9809
|
+
/** Render the model-chosen structured body. */
|
|
9810
|
+
function ProgressStructure(report) {
|
|
9811
|
+
if (report === null || typeof report !== 'object') return null;
|
|
9812
|
+
const sections = [];
|
|
9813
|
+
const mode = report.mode ?? 'checklist';
|
|
9814
|
+
if (mode === 'phases' && Array.isArray(report.phases) && report.phases.length > 0) {
|
|
9815
|
+
sections.push(h('div', { key: 'phases' },
|
|
9816
|
+
h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.phases),
|
|
9817
|
+
h('ul', { className: 'dsh-powerup-progress-items' }, report.phases.map((phase, i) => ProgressItem(
|
|
9818
|
+
phase.name, phase.status, phase.detail,
|
|
9819
|
+
Array.isArray(phase.steps) && phase.steps.length > 0
|
|
9820
|
+
? phase.steps.map((s, j) => ProgressItem(s.title, s.status, '', null, `p${i}-s${j}`))
|
|
9821
|
+
: null,
|
|
9822
|
+
`phase-${i}`,
|
|
9823
|
+
))),
|
|
9824
|
+
));
|
|
9825
|
+
} else if (mode === 'milestones' && Array.isArray(report.milestones) && report.milestones.length > 0) {
|
|
9826
|
+
sections.push(h('div', { key: 'milestones' },
|
|
9827
|
+
h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.milestones),
|
|
9828
|
+
h('ul', { className: 'dsh-powerup-progress-items' }, report.milestones.map((m, i) => ProgressItem(
|
|
9829
|
+
m.name, m.status, m.criteria ? `${m.detail ?? ''} · ${m.criteria}`.trim() : m.detail,
|
|
9830
|
+
null, `m-${i}`,
|
|
9831
|
+
))),
|
|
9832
|
+
));
|
|
9833
|
+
} else if (mode === 'tree' && report.tree !== null && report.tree !== undefined) {
|
|
9834
|
+
const node = (n, key) => ProgressItem(
|
|
9835
|
+
n.title, n.status, n.detail,
|
|
9836
|
+
Array.isArray(n.children) && n.children.length > 0 ? n.children.map((c, i) => node(c, `${key}-${i}`)) : null,
|
|
9837
|
+
key,
|
|
9838
|
+
);
|
|
9839
|
+
sections.push(h('div', { key: 'tree' },
|
|
9840
|
+
h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.tree),
|
|
9841
|
+
h('ul', { className: 'dsh-powerup-progress-items' }, [node(report.tree, 'root')]),
|
|
9842
|
+
));
|
|
9843
|
+
} else if (Array.isArray(report.steps) && report.steps.length > 0) {
|
|
9844
|
+
sections.push(h('div', { key: 'steps' },
|
|
9845
|
+
h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.checklist),
|
|
9846
|
+
h('ul', { className: 'dsh-powerup-progress-items' }, report.steps.map((s, i) => ProgressItem(
|
|
9847
|
+
s.title, s.status, s.detail, null, `step-${i}`,
|
|
9848
|
+
))),
|
|
9849
|
+
));
|
|
9850
|
+
}
|
|
9851
|
+
if (Array.isArray(report.blockers) && report.blockers.length > 0) {
|
|
9852
|
+
sections.push(h('div', { key: 'blockers', className: 'dsh-powerup-progress-blockers' },
|
|
9853
|
+
h('strong', null, '阻碍'),
|
|
9854
|
+
h('ul', null, report.blockers.map((b, i) => h('li', { key: i }, b))),
|
|
9855
|
+
));
|
|
9856
|
+
}
|
|
9857
|
+
return sections.length > 0 ? h('div', null, sections) : null;
|
|
9858
|
+
}
|
|
9859
|
+
|
|
9860
|
+
/** Render the model-authored free-form display blocks verbatim. */
|
|
9861
|
+
function ProgressDisplay(report) {
|
|
9862
|
+
const blocks = Array.isArray(report?.display) ? report.display : [];
|
|
9863
|
+
if (blocks.length === 0) return null;
|
|
9864
|
+
const rendered = blocks.map((block, i) => {
|
|
9865
|
+
if (block.kind === 'text') {
|
|
9866
|
+
return h('div', { key: i, className: 'dsh-powerup-progress-display-text' }, block.text);
|
|
9867
|
+
}
|
|
9868
|
+
if (block.kind === 'kv') {
|
|
9869
|
+
return h('dl', { key: i, className: 'dsh-powerup-progress-kv' },
|
|
9870
|
+
block.items.map((item, j) => h('div', { key: j, className: 'dsh-powerup-progress-kv-row' },
|
|
9871
|
+
h('dt', null, item.label),
|
|
9872
|
+
h('dd', null, item.value),
|
|
9873
|
+
)),
|
|
9874
|
+
);
|
|
9875
|
+
}
|
|
9876
|
+
if (block.kind === 'callout') {
|
|
9877
|
+
return h('div', { key: i, className: 'dsh-powerup-progress-callout', 'data-tone': block.tone }, block.text);
|
|
9878
|
+
}
|
|
9879
|
+
if (block.kind === 'bars') {
|
|
9880
|
+
return h('div', { key: i },
|
|
9881
|
+
block.items.map((item, j) => h('div', { key: j, className: 'dsh-powerup-progress-bar' },
|
|
9882
|
+
h('div', { className: 'dsh-powerup-progress-bar-head' },
|
|
9883
|
+
h('span', null, item.label),
|
|
9884
|
+
h('span', null, `${item.value}%`),
|
|
9885
|
+
),
|
|
9886
|
+
h('div', { className: 'dsh-powerup-progress-track' },
|
|
9887
|
+
h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${item.value}%` } }),
|
|
9888
|
+
),
|
|
9889
|
+
)),
|
|
9890
|
+
);
|
|
9891
|
+
}
|
|
9892
|
+
if (block.kind === 'code') {
|
|
9893
|
+
return h('pre', { key: i, className: 'dsh-powerup-progress-code' }, block.text);
|
|
9894
|
+
}
|
|
9895
|
+
return null;
|
|
9896
|
+
}).filter(Boolean);
|
|
9897
|
+
if (rendered.length === 0) return null;
|
|
9898
|
+
return h('div', { className: 'dsh-powerup-progress-display' },
|
|
9899
|
+
h('div', { className: 'dsh-powerup-progress-display-head' }, '模型补充'),
|
|
9900
|
+
rendered,
|
|
9901
|
+
);
|
|
9902
|
+
}
|
|
9903
|
+
|
|
9904
|
+
/**
|
|
9905
|
+
* Header utility: a button that opens a body-portal panel. The panel polls
|
|
9906
|
+
* the Host route while a side call runs, and reuses the last report after
|
|
9907
|
+
* it finishes. All work is fire-and-forget on the Host, so the running
|
|
9908
|
+
* task is never blocked or interrupted.
|
|
9909
|
+
*/
|
|
9910
|
+
function ProgressControl({ sessionId }) {
|
|
9911
|
+
const settings = useSettings();
|
|
9912
|
+
const [open, setOpen] = useState(false);
|
|
9913
|
+
const [view, setView] = useState(null);
|
|
9914
|
+
const [busy, setBusy] = useState(false);
|
|
9915
|
+
const panelRef = useRef(null);
|
|
9916
|
+
const buttonRef = useRef(null);
|
|
9917
|
+
const sessionRef = useRef(sessionId);
|
|
9918
|
+
sessionRef.current = sessionId;
|
|
9919
|
+
const t = useCallback((key, params) => translateCurrent(key, params), []);
|
|
9920
|
+
|
|
9921
|
+
const refresh = useCallback(async () => {
|
|
9922
|
+
const id = sessionRef.current;
|
|
9923
|
+
if (typeof id !== 'string' || id === '') return null;
|
|
9924
|
+
try {
|
|
9925
|
+
const body = await progressRequest(id, 'poll');
|
|
9926
|
+
setView(body);
|
|
9927
|
+
return body;
|
|
9928
|
+
} catch {
|
|
9929
|
+
return null;
|
|
9930
|
+
}
|
|
9931
|
+
}, []);
|
|
9932
|
+
|
|
9933
|
+
// While the panel is open, keep polling until the side call settles.
|
|
9934
|
+
useEffect(() => {
|
|
9935
|
+
if (!open) return undefined;
|
|
9936
|
+
let disposed = false;
|
|
9937
|
+
const tick = async () => {
|
|
9938
|
+
if (disposed) return;
|
|
9939
|
+
const body = await refresh();
|
|
9940
|
+
if (disposed) return;
|
|
9941
|
+
if (body?.status === 'running') {
|
|
9942
|
+
window.setTimeout(tick, 900);
|
|
9943
|
+
}
|
|
9944
|
+
};
|
|
9945
|
+
void tick();
|
|
9946
|
+
return () => { disposed = true; };
|
|
9947
|
+
}, [open, refresh]);
|
|
9948
|
+
|
|
9949
|
+
const run = useCallback(async () => {
|
|
9950
|
+
const id = sessionRef.current;
|
|
9951
|
+
if (typeof id !== 'string' || id === '') return;
|
|
9952
|
+
setBusy(true);
|
|
9953
|
+
try {
|
|
9954
|
+
const body = await progressRequest(id, 'start');
|
|
9955
|
+
setView(body);
|
|
9956
|
+
} catch (error) {
|
|
9957
|
+
setView({ status: 'error', error: error?.message ?? String(error) });
|
|
9958
|
+
} finally {
|
|
9959
|
+
setBusy(false);
|
|
9960
|
+
// Kick the polling loop even if it was already mounted.
|
|
9961
|
+
if (!open) setOpen(true);
|
|
9962
|
+
}
|
|
9963
|
+
}, [open]);
|
|
9964
|
+
|
|
9965
|
+
const close = useCallback(() => setOpen(false), []);
|
|
9966
|
+
|
|
9967
|
+
// Esc and outside click close the panel.
|
|
9968
|
+
useEffect(() => {
|
|
9969
|
+
if (!open) return undefined;
|
|
9970
|
+
const onKey = (event) => {
|
|
9971
|
+
if (event.key === 'Escape') { event.stopPropagation(); close(); }
|
|
9972
|
+
};
|
|
9973
|
+
const onPointer = (event) => {
|
|
9974
|
+
const panel = panelRef.current;
|
|
9975
|
+
const button = buttonRef.current;
|
|
9976
|
+
if (panel !== null && event.target instanceof Node && panel.contains(event.target)) return;
|
|
9977
|
+
if (button !== null && event.target instanceof Node && button.contains(event.target)) return;
|
|
9978
|
+
close();
|
|
9979
|
+
};
|
|
9980
|
+
document.addEventListener('keydown', onKey, true);
|
|
9981
|
+
document.addEventListener('pointerdown', onPointer, true);
|
|
9982
|
+
return () => {
|
|
9983
|
+
document.removeEventListener('keydown', onKey, true);
|
|
9984
|
+
document.removeEventListener('pointerdown', onPointer, true);
|
|
9985
|
+
};
|
|
9986
|
+
}, [open, close]);
|
|
9987
|
+
|
|
9988
|
+
if (settings.taskProgress === false) return null;
|
|
9989
|
+
const running = view?.status === 'running' || busy;
|
|
9990
|
+
const report = view?.report;
|
|
9991
|
+
|
|
9992
|
+
const button = h('button', {
|
|
9993
|
+
ref: buttonRef,
|
|
9994
|
+
type: 'button',
|
|
9995
|
+
className: 'dsh-powerup-progress-btn' + (running ? ' is-running' : ''),
|
|
9996
|
+
title: t('progress.title'),
|
|
9997
|
+
'aria-label': t('progress.title'),
|
|
9998
|
+
onClick: () => {
|
|
9999
|
+
if (open) { close(); return; }
|
|
10000
|
+
setOpen(true);
|
|
10001
|
+
void refresh();
|
|
10002
|
+
},
|
|
10003
|
+
},
|
|
10004
|
+
h(ProgressIcon, { size: 15 }),
|
|
10005
|
+
h('span', null, t('progress.label')),
|
|
10006
|
+
running ? h('span', { className: 'dsh-powerup-progress-btn-dot' }) : null,
|
|
10007
|
+
);
|
|
10008
|
+
|
|
10009
|
+
const body = (() => {
|
|
10010
|
+
if (view === null) return h('div', { className: 'dsh-powerup-progress-empty' }, t('progress.hint'));
|
|
10011
|
+
if (view.status === 'error') return h('p', { className: 'dsh-powerup-progress-error' }, view.error ?? t('progress.failed'));
|
|
10012
|
+
if (view.status === 'idle' || view.status === 'expired') {
|
|
10013
|
+
return h('div', null,
|
|
10014
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
|
|
10015
|
+
h('button', {
|
|
10016
|
+
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10017
|
+
disabled: busy, onClick: () => void run(),
|
|
10018
|
+
}, t('progress.generate')),
|
|
10019
|
+
);
|
|
10020
|
+
}
|
|
10021
|
+
if (view.status === 'running') {
|
|
10022
|
+
return h('div', null,
|
|
10023
|
+
h('div', { className: 'dsh-powerup-progress-loading' }, t('progress.loading')),
|
|
10024
|
+
report ? h('div', null,
|
|
10025
|
+
h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
|
|
10026
|
+
ProgressStructure(report),
|
|
10027
|
+
) : null,
|
|
10028
|
+
);
|
|
10029
|
+
}
|
|
10030
|
+
if (report === null || report === undefined) {
|
|
10031
|
+
return h('div', null,
|
|
10032
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.failed')),
|
|
10033
|
+
h('button', {
|
|
10034
|
+
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10035
|
+
disabled: busy, onClick: () => void run(),
|
|
10036
|
+
}, t('progress.retry')),
|
|
10037
|
+
);
|
|
10038
|
+
}
|
|
10039
|
+
return h('div', null,
|
|
10040
|
+
h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
|
|
10041
|
+
h('div', { className: 'dsh-powerup-progress-meter' },
|
|
10042
|
+
h('div', { className: 'dsh-powerup-progress-meter-head' },
|
|
10043
|
+
h('span', null, MODE_LABEL[report.mode] ?? report.mode),
|
|
10044
|
+
h('strong', null, `${report.percent}%`),
|
|
10045
|
+
),
|
|
10046
|
+
h('div', { className: 'dsh-powerup-progress-track' },
|
|
10047
|
+
h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${report.percent}%` } }),
|
|
10048
|
+
),
|
|
10049
|
+
),
|
|
10050
|
+
ProgressStructure(report),
|
|
10051
|
+
ProgressDisplay(report),
|
|
10052
|
+
);
|
|
10053
|
+
})();
|
|
10054
|
+
|
|
10055
|
+
const panel = !open ? null : h('div', {
|
|
10056
|
+
ref: panelRef,
|
|
10057
|
+
className: 'dsh-powerup-progress-panel',
|
|
10058
|
+
style: {
|
|
10059
|
+
top: (() => {
|
|
10060
|
+
const rect = buttonRef.current?.getBoundingClientRect?.();
|
|
10061
|
+
return `${Math.round((rect?.bottom ?? 44) + 6)}px`;
|
|
10062
|
+
})(),
|
|
10063
|
+
right: (() => {
|
|
10064
|
+
const rect = buttonRef.current?.getBoundingClientRect?.();
|
|
10065
|
+
return `${Math.round(Math.max(12, window.innerWidth - (rect?.right ?? window.innerWidth - 12)))}px`;
|
|
10066
|
+
})(),
|
|
10067
|
+
},
|
|
10068
|
+
},
|
|
10069
|
+
h('div', { className: 'dsh-powerup-progress-head' },
|
|
10070
|
+
h('div', { className: 'dsh-powerup-progress-heading' },
|
|
10071
|
+
h('span', { className: 'dsh-powerup-progress-title' }, report?.title ?? t('progress.title')),
|
|
10072
|
+
h('span', { className: 'dsh-powerup-progress-sub' },
|
|
10073
|
+
view?.stale ? `${t('progress.stale')} · ` : '',
|
|
10074
|
+
t('progress.subtitle'),
|
|
10075
|
+
),
|
|
10076
|
+
),
|
|
10077
|
+
h('button', {
|
|
10078
|
+
type: 'button', className: 'dsh-powerup-progress-close',
|
|
10079
|
+
'aria-label': t('progress.close'), onClick: close,
|
|
10080
|
+
}, '×'),
|
|
10081
|
+
),
|
|
10082
|
+
h('div', { className: 'dsh-powerup-progress-body' }, body),
|
|
10083
|
+
h('div', { className: 'dsh-powerup-progress-foot' },
|
|
10084
|
+
h('span', { className: 'dsh-powerup-progress-time' },
|
|
10085
|
+
view?.updatedAt ? format(t('progress.updated'), { time: new Date(view.updatedAt).toLocaleTimeString() }) : '',
|
|
10086
|
+
),
|
|
10087
|
+
h('button', {
|
|
10088
|
+
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10089
|
+
disabled: busy || running, onClick: () => void run(),
|
|
10090
|
+
}, t('progress.refresh')),
|
|
10091
|
+
),
|
|
10092
|
+
);
|
|
10093
|
+
|
|
10094
|
+
return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
|
|
10095
|
+
button,
|
|
10096
|
+
renderInBody(panel),
|
|
10097
|
+
);
|
|
10098
|
+
}
|
|
10099
|
+
|
|
9526
10100
|
// ------------------------------------------------------------------
|
|
9527
10101
|
// Plugin body
|
|
9528
10102
|
// ------------------------------------------------------------------
|
|
@@ -9574,6 +10148,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9574
10148
|
order: 50,
|
|
9575
10149
|
}, PowerUpBridge, 'dsh-powerup: session bridge');
|
|
9576
10150
|
|
|
10151
|
+
register('conversation.session.header.utilities', {
|
|
10152
|
+
id: 'powerup-progress',
|
|
10153
|
+
order: 52,
|
|
10154
|
+
}, (props) => h(ProgressControl, { sessionId: props?.sessionId }), 'dsh-powerup: task progress');
|
|
10155
|
+
|
|
9577
10156
|
register('conversation.hero.options', {
|
|
9578
10157
|
id: 'powerup-prompts',
|
|
9579
10158
|
order: 60,
|
|
@@ -9671,6 +10250,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9671
10250
|
SCROLL_TOP_CSS,
|
|
9672
10251
|
RENDERING_CSS,
|
|
9673
10252
|
PROMPTS_CSS,
|
|
10253
|
+
PROGRESS_CSS,
|
|
10254
|
+
ProgressControl,
|
|
10255
|
+
ProgressStructure,
|
|
10256
|
+
ProgressDisplay,
|
|
10257
|
+
progressRequest,
|
|
9674
10258
|
PROMPTS_LAST_KEY,
|
|
9675
10259
|
promptCreateDraft,
|
|
9676
10260
|
readPrompts,
|