@restregular/dsh-powerup 0.12.0 → 0.13.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 +28 -1
- package/client.js +580 -45
- package/index.js +213 -7
- package/lib/direct-ask.js +115 -0
- package/lib/progress-manager.js +49 -7
- package/lib/progress-tool.js +13 -4
- package/lib/task-resume.js +20 -5
- package/package.json +3 -2
package/client.js
CHANGED
|
@@ -320,6 +320,7 @@
|
|
|
320
320
|
'restart.resumePromptLabel': '继续提示词(可选)',
|
|
321
321
|
'restart.resumePromptPlaceholder': '默认:继续之前未完成的任务。',
|
|
322
322
|
'restart.taskLine': '会话 {id}',
|
|
323
|
+
'restart.taskFallback': '未命名会话',
|
|
323
324
|
'restart.forceConfirm': '强制停止并重启',
|
|
324
325
|
'force.done': '已停止 {count} 个任务,将自动继续 {resumed} 个会话。',
|
|
325
326
|
'update.doneTitle': '安装完成',
|
|
@@ -365,13 +366,56 @@
|
|
|
365
366
|
'progress.hint': '还没有进度报告,点「生成进度」开始分析。',
|
|
366
367
|
'progress.empty': '还没有生成过进度报告。',
|
|
367
368
|
'progress.generate': '生成进度',
|
|
368
|
-
'progress.refresh': '
|
|
369
|
+
'progress.refresh': '刷新进度',
|
|
369
370
|
'progress.retry': '重试',
|
|
370
371
|
'progress.loading': '正在后台分析会话进度…',
|
|
371
372
|
'progress.close': '关闭',
|
|
372
373
|
'progress.failed': '生成进度失败',
|
|
373
374
|
'progress.stale': '报告已过期',
|
|
374
375
|
'progress.updated': '更新于 {time}',
|
|
376
|
+
'progress.history': '历史进度',
|
|
377
|
+
'progress.historyEmpty': '暂无历史记录',
|
|
378
|
+
'progress.viewRaw': '查看原始内容',
|
|
379
|
+
'progress.rawTitle': 'AI 原始生成内容',
|
|
380
|
+
'progress.rawHint': '这是模型返回的原始文本,未经解析处理。',
|
|
381
|
+
'progress.copyRaw': '复制原文',
|
|
382
|
+
'progress.clearHistory': '清空历史',
|
|
383
|
+
'progress.clearHistoryConfirm': '确定清空全部历史进度?此操作不可撤销。',
|
|
384
|
+
'progress.cleared': '历史已清空',
|
|
385
|
+
'progress.requirements': '生成要求',
|
|
386
|
+
'progress.reqHint': '设置语言、结构、必须包含的数据、额外展示区要回答的问题等;设置后会作为后续生成的默认要求。',
|
|
387
|
+
'progress.reqGlobal': '通用要求(设置页)',
|
|
388
|
+
'progress.reqWorkspace': '工作区要求',
|
|
389
|
+
'progress.reqSession': '会话要求',
|
|
390
|
+
'progress.reqTemporary': '本次临时要求',
|
|
391
|
+
'progress.reqTemporaryHint': '仅本次生成生效,不会保存。',
|
|
392
|
+
'progress.reqPlaceholder': '例如:用中文回答,包含每步耗时,展示区回答「下一步做什么」',
|
|
393
|
+
'progress.reqSaved': '要求已保存',
|
|
394
|
+
'progress.reqEmpty': '还没有设置任何要求',
|
|
395
|
+
'progress.ageWarning': '已过去 {minutes} 分钟',
|
|
396
|
+
'progress.resizeHint': '拖动右下角调整窗口大小',
|
|
397
|
+
'page.directAskTitle': '轻量问答按钮',
|
|
398
|
+
'page.directAskDesc': '在底部输入区新增一个按钮,直接把问题发给模型。不启动 Agent,不加载系统提示词、工具和技能,仅用于简单问答,回答更快、更省 token。可在弹窗里附带文件作为上下文。',
|
|
399
|
+
'page.directAskHow': '点底部输入区的闪电按钮,输入问题后发送;回答会显示在一个可开关的弹窗里。这个能力不是 Agent,不能调用工具或加载技能。',
|
|
400
|
+
'page.directAskToggle': '启用轻量问答按钮',
|
|
401
|
+
'page.directAskToggleHint': '关闭后底部输入区不再显示该按钮。',
|
|
402
|
+
'directAsk.label': '直接问答',
|
|
403
|
+
'directAsk.hint': '不启动 Agent,直接问模型(无工具/技能)',
|
|
404
|
+
'directAsk.title': '轻量问答',
|
|
405
|
+
'directAsk.subtitle': '不加载系统提示词、工具或技能,仅回答问题',
|
|
406
|
+
'directAsk.placeholder': '输入你的问题…',
|
|
407
|
+
'directAsk.send': '发送',
|
|
408
|
+
'directAsk.sending': '正在回答…',
|
|
409
|
+
'directAsk.attach': '添加文件上下文',
|
|
410
|
+
'directAsk.attachHint': '选择文本文件,内容会作为参考附加在问题前(不会写入会话)。',
|
|
411
|
+
'directAsk.removeFile': '移除',
|
|
412
|
+
'directAsk.empty': '请输入问题',
|
|
413
|
+
'directAsk.answer': '回答',
|
|
414
|
+
'directAsk.copy': '复制回答',
|
|
415
|
+
'directAsk.copied': '已复制',
|
|
416
|
+
'directAsk.close': '关闭',
|
|
417
|
+
'directAsk.hide': '隐藏弹窗',
|
|
418
|
+
'directAsk.showHint': '再次点击闪电按钮可显示/隐藏弹窗',
|
|
375
419
|
'page.promptsTitle': '工作区提示词',
|
|
376
420
|
'page.promptsDesc': '为每个工作区保存可复用的提示词。开启后,新会话行的 Agent 预设右侧会出现一个下拉列表,选择即可把提示词填入输入框(可继续编辑),或点提示词右侧的发送按钮直接发出。',
|
|
377
421
|
'page.promptsHow': '先启用本功能,再切到「工作区提示词」标签页创建提示词;提示词按工作区隔离,没有标题时显示开头几个字。',
|
|
@@ -654,6 +698,7 @@
|
|
|
654
698
|
'restart.resumePromptLabel': 'Continuation prompt (optional)',
|
|
655
699
|
'restart.resumePromptPlaceholder': 'Default: Continue the previous unfinished task.',
|
|
656
700
|
'restart.taskLine': 'Session {id}',
|
|
701
|
+
'restart.taskFallback': 'Untitled session',
|
|
657
702
|
'restart.forceConfirm': 'Force-stop and restart',
|
|
658
703
|
'force.done': 'Stopped {count} task(s); {resumed} session(s) will resume automatically.',
|
|
659
704
|
'update.doneTitle': 'Install complete',
|
|
@@ -699,13 +744,56 @@
|
|
|
699
744
|
'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
|
|
700
745
|
'progress.empty': 'No progress report generated yet.',
|
|
701
746
|
'progress.generate': 'Generate progress',
|
|
702
|
-
'progress.refresh': '
|
|
747
|
+
'progress.refresh': 'Refresh progress',
|
|
703
748
|
'progress.retry': 'Retry',
|
|
704
749
|
'progress.loading': 'Analyzing session progress in the background…',
|
|
705
750
|
'progress.close': 'Close',
|
|
706
751
|
'progress.failed': 'Could not generate progress',
|
|
707
752
|
'progress.stale': 'Stale report',
|
|
708
753
|
'progress.updated': 'Updated at {time}',
|
|
754
|
+
'progress.history': 'History',
|
|
755
|
+
'progress.historyEmpty': 'No history yet',
|
|
756
|
+
'progress.viewRaw': 'View raw output',
|
|
757
|
+
'progress.rawTitle': 'Raw AI output',
|
|
758
|
+
'progress.rawHint': 'This is the exact text returned by the model, before parsing.',
|
|
759
|
+
'progress.copyRaw': 'Copy raw',
|
|
760
|
+
'progress.clearHistory': 'Clear history',
|
|
761
|
+
'progress.clearHistoryConfirm': 'Clear all progress history? This cannot be undone.',
|
|
762
|
+
'progress.cleared': 'History cleared',
|
|
763
|
+
'progress.requirements': 'Requirements',
|
|
764
|
+
'progress.reqHint': 'Set language, structure, required data, questions for the display area, etc. Saved requirements apply to future generations.',
|
|
765
|
+
'progress.reqGlobal': 'Global requirements (settings)',
|
|
766
|
+
'progress.reqWorkspace': 'Workspace requirements',
|
|
767
|
+
'progress.reqSession': 'Session requirements',
|
|
768
|
+
'progress.reqTemporary': 'One-off requirements',
|
|
769
|
+
'progress.reqTemporaryHint': 'Applies to this generation only; not saved.',
|
|
770
|
+
'progress.reqPlaceholder': 'e.g. Answer in Chinese, include per-step timing, answer "what is next" in the display area',
|
|
771
|
+
'progress.reqSaved': 'Requirements saved',
|
|
772
|
+
'progress.reqEmpty': 'No requirements configured',
|
|
773
|
+
'progress.ageWarning': '{minutes} minutes elapsed',
|
|
774
|
+
'progress.resizeHint': 'Drag the bottom-right corner to resize',
|
|
775
|
+
'page.directAskTitle': 'Direct-ask button',
|
|
776
|
+
'page.directAskDesc': 'Adds a button to the bottom composer that sends a question straight to the model. No Agent is started: no system prompt, tools or skills are loaded — just a fast, cheap answer. You can attach files as context in the dialog.',
|
|
777
|
+
'page.directAskHow': 'Click the lightning button in the composer, type a question and send; the answer appears in a dialog you can show or hide. This is not an Agent — it cannot call tools or load skills.',
|
|
778
|
+
'page.directAskToggle': 'Enable direct-ask button',
|
|
779
|
+
'page.directAskToggleHint': 'When off, the composer button is hidden.',
|
|
780
|
+
'directAsk.label': 'Direct ask',
|
|
781
|
+
'directAsk.hint': 'Ask the model without an Agent (no tools or skills)',
|
|
782
|
+
'directAsk.title': 'Direct ask',
|
|
783
|
+
'directAsk.subtitle': 'No system prompt, tools or skills — just an answer',
|
|
784
|
+
'directAsk.placeholder': 'Type your question…',
|
|
785
|
+
'directAsk.send': 'Send',
|
|
786
|
+
'directAsk.sending': 'Answering…',
|
|
787
|
+
'directAsk.attach': 'Add file context',
|
|
788
|
+
'directAsk.attachHint': 'Pick a text file; its content is attached before the question as reference (never written to the session).',
|
|
789
|
+
'directAsk.removeFile': 'Remove',
|
|
790
|
+
'directAsk.empty': 'Enter a question first',
|
|
791
|
+
'directAsk.answer': 'Answer',
|
|
792
|
+
'directAsk.copy': 'Copy answer',
|
|
793
|
+
'directAsk.copied': 'Copied',
|
|
794
|
+
'directAsk.close': 'Close',
|
|
795
|
+
'directAsk.hide': 'Hide dialog',
|
|
796
|
+
'directAsk.showHint': 'Click the lightning button again to show/hide the dialog',
|
|
709
797
|
'page.promptsTitle': 'Workspace prompts',
|
|
710
798
|
'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.',
|
|
711
799
|
'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.',
|
|
@@ -804,6 +892,7 @@
|
|
|
804
892
|
dualSend: false,
|
|
805
893
|
workspacePrompts: true,
|
|
806
894
|
taskProgress: true,
|
|
895
|
+
directAsk: true,
|
|
807
896
|
oneClickEnable: true,
|
|
808
897
|
oneClickRestart: true,
|
|
809
898
|
};
|
|
@@ -827,6 +916,7 @@
|
|
|
827
916
|
dualSend: parsed.dualSend === true,
|
|
828
917
|
workspacePrompts: parsed.workspacePrompts !== false,
|
|
829
918
|
taskProgress: parsed.taskProgress !== false,
|
|
919
|
+
directAsk: parsed.directAsk !== false,
|
|
830
920
|
oneClickEnable: parsed.oneClickEnable !== false,
|
|
831
921
|
oneClickRestart: parsed.oneClickRestart !== false,
|
|
832
922
|
};
|
|
@@ -4135,7 +4225,8 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
|
|
|
4135
4225
|
.dsh-powerup-update-tasks>strong{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
|
|
4136
4226
|
.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
4227
|
.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-
|
|
4228
|
+
.dsh-powerup-update-task-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-primary)}
|
|
4229
|
+
.dsh-powerup-update-task-list code{flex:none;max-width:45%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11px}
|
|
4139
4230
|
.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
4231
|
.dsh-powerup-app-check{display:flex;align-items:flex-start;gap:9px;padding:4px 0;cursor:pointer}
|
|
4141
4232
|
.dsh-powerup-app-check input{flex:none;margin:2px 0 0;accent-color:var(--dsw-alias-brand-primary)}
|
|
@@ -4493,7 +4584,31 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4493
4584
|
.dsh-powerup-progress-refresh:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4494
4585
|
.dsh-powerup-progress-refresh:disabled{opacity:.45;cursor:not-allowed}
|
|
4495
4586
|
.dsh-powerup-progress-time{color:var(--dsw-alias-label-caption);font-size:10px}
|
|
4587
|
+
.dsh-powerup-progress-mini{height:26px;padding:0 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;line-height:1.5;cursor:pointer}
|
|
4588
|
+
.dsh-powerup-progress-mini:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4589
|
+
.dsh-powerup-progress-history{margin-bottom:12px}
|
|
4590
|
+
.dsh-powerup-progress-history-list{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
|
|
4591
|
+
.dsh-powerup-progress-history-item{padding:3px 9px;border:.5px solid var(--dsw-alias-border-l2);border-radius:999px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;font-size:10.5px;line-height:1.5;cursor:pointer}
|
|
4592
|
+
.dsh-powerup-progress-history-item.on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent)}
|
|
4593
|
+
.dsh-powerup-progress-age{margin:0 0 10px;padding:6px 10px;border-radius:7px;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));font-size:11px;line-height:1.5}
|
|
4594
|
+
.dsh-powerup-progress-req-pop{padding:10px 16px 0;border-bottom:.5px solid var(--dsw-alias-border-l1)}
|
|
4595
|
+
.dsh-powerup-progress-req-pop .dsh-powerup-prompt-textarea{min-height:64px}
|
|
4596
|
+
.dsh-powerup-progress-resizer{position:absolute;right:0;bottom:0;width:16px;height:16px;cursor:nwse-resize;background:linear-gradient(135deg,transparent 50%,var(--dsw-alias-border-l3) 50%,transparent 62%,var(--dsw-alias-border-l3) 62%,var(--dsw-alias-border-l3) 72%,transparent 72%)}
|
|
4597
|
+
.dsh-powerup-progress-req-editor{display:flex;flex-direction:column;gap:10px;padding:8px 0}
|
|
4496
4598
|
@media (prefers-reduced-motion:reduce){.dsh-powerup-progress-panel,.dsh-powerup-progress-btn.is-running svg,.dsh-powerup-progress-fill{animation:none;transition:none}}
|
|
4599
|
+
/* Direct-ask button + dialog */
|
|
4600
|
+
.dsh-powerup-directask-btn{display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 8px;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}
|
|
4601
|
+
.dsh-powerup-directask-btn:hover,.dsh-powerup-directask-btn.on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4602
|
+
.dsh-powerup-directask-mask{position:fixed;z-index:1600;display:flex;box-sizing:border-box;max-height:calc(100dvh - 24px);pointer-events:none}
|
|
4603
|
+
.dsh-powerup-directask-dialog{box-sizing:border-box;display:flex;flex-direction:column;width:100%;max-height:min(80vh,760px);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);pointer-events:auto;animation:dsh-powerup-progress-in .15s ease-out}
|
|
4604
|
+
.dsh-powerup-directask-files{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
|
|
4605
|
+
.dsh-powerup-directask-file{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font-size:11px}
|
|
4606
|
+
.dsh-powerup-directask-file button{border:0;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;font-size:13px;line-height:1}
|
|
4607
|
+
.dsh-powerup-directask-label{display:block}
|
|
4608
|
+
.dsh-powerup-directask-label textarea{min-height:90px}
|
|
4609
|
+
.dsh-powerup-directask-attach{display:inline-flex;align-items:center;gap:6px;width:fit-content;margin-top:8px;color:var(--dsw-alias-label-secondary);font-size:11.5px;cursor:pointer}
|
|
4610
|
+
.dsh-powerup-directask-answer{margin-top:12px;padding-top:10px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
4611
|
+
.dsh-powerup-directask-answer-body{margin:6px 0;padding:12px;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;max-height:360px;overflow-y:auto}
|
|
4497
4612
|
`;
|
|
4498
4613
|
|
|
4499
4614
|
/** Max display length of a session option, in Unicode code points. */
|
|
@@ -8055,8 +8170,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8055
8170
|
h('ul', { className: 'dsh-powerup-update-task-list' },
|
|
8056
8171
|
appTasks.slice(0, 8).map((task, index) => h('li', { key: `${task.kind}-${task.id}-${index}` },
|
|
8057
8172
|
h('span', { className: 'dsh-powerup-update-task-dot' }),
|
|
8058
|
-
h('
|
|
8059
|
-
|
|
8173
|
+
h('span', { className: 'dsh-powerup-update-task-title' },
|
|
8174
|
+
task.title && task.title !== 'session' ? task.title : t('restart.taskFallback'),
|
|
8175
|
+
),
|
|
8176
|
+
h('code', { title: task.id }, task.id),
|
|
8060
8177
|
)),
|
|
8061
8178
|
),
|
|
8062
8179
|
h('label', { className: 'dsh-powerup-app-check' },
|
|
@@ -8993,6 +9110,164 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8993
9110
|
return behavior;
|
|
8994
9111
|
}
|
|
8995
9112
|
|
|
9113
|
+
/**
|
|
9114
|
+
* Lighting-bolt button in the composer. Opens a dialog that sends a
|
|
9115
|
+
* question straight to the model — no Agent, system prompt, tools or
|
|
9116
|
+
* skills. The dialog can be hidden/shown by clicking the button again.
|
|
9117
|
+
*/
|
|
9118
|
+
function DirectAskButton({ sessionId }) {
|
|
9119
|
+
const settings = useSettings();
|
|
9120
|
+
const [open, setOpen] = useState(false);
|
|
9121
|
+
const [question, setQuestion] = useState('');
|
|
9122
|
+
const [files, setFiles] = useState([]);
|
|
9123
|
+
const [answer, setAnswer] = useState('');
|
|
9124
|
+
const [busy, setBusy] = useState(false);
|
|
9125
|
+
const [error, setError] = useState('');
|
|
9126
|
+
const [copied, setCopied] = useState(false);
|
|
9127
|
+
const dialogRef = useRef(null);
|
|
9128
|
+
const sessionRef = useRef(sessionId);
|
|
9129
|
+
sessionRef.current = sessionId;
|
|
9130
|
+
const t = useCallback((key, params) => translateCurrent(key, params), []);
|
|
9131
|
+
|
|
9132
|
+
useEffect(() => {
|
|
9133
|
+
if (!open) return undefined;
|
|
9134
|
+
const onKey = (event) => {
|
|
9135
|
+
if (event.key === 'Escape') { event.stopPropagation(); setOpen(false); }
|
|
9136
|
+
};
|
|
9137
|
+
document.addEventListener('keydown', onKey, true);
|
|
9138
|
+
return () => document.removeEventListener('keydown', onKey, true);
|
|
9139
|
+
}, [open]);
|
|
9140
|
+
|
|
9141
|
+
const send = useCallback(async () => {
|
|
9142
|
+
const q = question.trim();
|
|
9143
|
+
if (q === '') { setError(t('directAsk.empty')); return; }
|
|
9144
|
+
setBusy(true);
|
|
9145
|
+
setError('');
|
|
9146
|
+
setAnswer('');
|
|
9147
|
+
setCopied(false);
|
|
9148
|
+
try {
|
|
9149
|
+
const response = await fetch(DIRECT_ASK_API, {
|
|
9150
|
+
method: 'POST',
|
|
9151
|
+
headers: { 'content-type': 'application/json' },
|
|
9152
|
+
body: JSON.stringify({
|
|
9153
|
+
sessionId: sessionRef.current ?? '',
|
|
9154
|
+
question: q,
|
|
9155
|
+
context: files.map((f) => ({ name: f.name, text: f.text })),
|
|
9156
|
+
}),
|
|
9157
|
+
});
|
|
9158
|
+
const body = await response.json();
|
|
9159
|
+
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
9160
|
+
setAnswer(typeof body.answer === 'string' ? body.answer : '');
|
|
9161
|
+
} catch (err) {
|
|
9162
|
+
setError(err?.message ?? String(err));
|
|
9163
|
+
} finally {
|
|
9164
|
+
setBusy(false);
|
|
9165
|
+
}
|
|
9166
|
+
}, [question, files, t]);
|
|
9167
|
+
|
|
9168
|
+
const pickFiles = useCallback(async (event) => {
|
|
9169
|
+
const picked = Array.from(event?.target?.files ?? []);
|
|
9170
|
+
const loaded = [];
|
|
9171
|
+
for (const file of picked) {
|
|
9172
|
+
try {
|
|
9173
|
+
const text = await file.text();
|
|
9174
|
+
loaded.push({ name: file.name, text: String(text).slice(0, 40_000) });
|
|
9175
|
+
} catch {
|
|
9176
|
+
/* skip unreadable files */
|
|
9177
|
+
}
|
|
9178
|
+
}
|
|
9179
|
+
setFiles((current) => [...current, ...loaded]);
|
|
9180
|
+
if (event?.target) event.target.value = '';
|
|
9181
|
+
}, []);
|
|
9182
|
+
|
|
9183
|
+
if (settings.directAsk === false) return null;
|
|
9184
|
+
|
|
9185
|
+
const lightning = h('svg', { viewBox: '0 0 16 16', width: 15, height: 15, 'aria-hidden': 'true' },
|
|
9186
|
+
h('path', { d: 'M9 1.5 3.5 9H7l-1 5.5L12.5 7H9l1-5.5Z', fill: 'currentColor' }),
|
|
9187
|
+
);
|
|
9188
|
+
|
|
9189
|
+
const button = h('button', {
|
|
9190
|
+
type: 'button',
|
|
9191
|
+
className: 'dsh-powerup-directask-btn' + (open ? ' on' : ''),
|
|
9192
|
+
title: t('directAsk.hint'),
|
|
9193
|
+
'aria-label': t('directAsk.label'),
|
|
9194
|
+
onClick: () => setOpen((v) => !v),
|
|
9195
|
+
}, lightning, h('span', null, t('directAsk.label')));
|
|
9196
|
+
|
|
9197
|
+
const dialog = !open ? null : h('div', {
|
|
9198
|
+
className: 'dsh-powerup-directask-mask',
|
|
9199
|
+
style: {
|
|
9200
|
+
bottom: '72px',
|
|
9201
|
+
right: '18px',
|
|
9202
|
+
width: 'min(600px, calc(100vw - 36px))',
|
|
9203
|
+
},
|
|
9204
|
+
},
|
|
9205
|
+
h('div', {
|
|
9206
|
+
ref: dialogRef,
|
|
9207
|
+
className: 'dsh-powerup-directask-dialog',
|
|
9208
|
+
role: 'dialog',
|
|
9209
|
+
'aria-label': t('directAsk.title'),
|
|
9210
|
+
},
|
|
9211
|
+
h('div', { className: 'dsh-powerup-update-head' },
|
|
9212
|
+
h('div', { className: 'dsh-powerup-update-heading' },
|
|
9213
|
+
h('h2', null, t('directAsk.title')),
|
|
9214
|
+
h('p', { className: 'dsh-powerup-update-note' }, t('directAsk.subtitle')),
|
|
9215
|
+
),
|
|
9216
|
+
h('button', {
|
|
9217
|
+
type: 'button', className: 'dsh-powerup-update-close',
|
|
9218
|
+
'aria-label': t('directAsk.close'), onClick: () => setOpen(false),
|
|
9219
|
+
}, '×'),
|
|
9220
|
+
),
|
|
9221
|
+
h('div', { className: 'dsh-powerup-update-body' },
|
|
9222
|
+
files.length > 0 ? h('div', { className: 'dsh-powerup-directask-files' },
|
|
9223
|
+
files.map((f, i) => h('span', { key: i, className: 'dsh-powerup-directask-file' },
|
|
9224
|
+
f.name,
|
|
9225
|
+
h('button', {
|
|
9226
|
+
type: 'button', 'aria-label': t('directAsk.removeFile'),
|
|
9227
|
+
onClick: () => setFiles((cur) => cur.filter((_, j) => j !== i)),
|
|
9228
|
+
}, '×'),
|
|
9229
|
+
)),
|
|
9230
|
+
) : null,
|
|
9231
|
+
h('label', { className: 'dsh-powerup-directask-label' },
|
|
9232
|
+
h('textarea', {
|
|
9233
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
|
|
9234
|
+
value: question,
|
|
9235
|
+
placeholder: t('directAsk.placeholder'),
|
|
9236
|
+
disabled: busy,
|
|
9237
|
+
onChange: (event) => setQuestion(event.target.value),
|
|
9238
|
+
}),
|
|
9239
|
+
),
|
|
9240
|
+
h('label', { className: 'dsh-powerup-directask-attach' },
|
|
9241
|
+
h('input', { type: 'file', multiple: true, onChange: (e) => void pickFiles(e) }),
|
|
9242
|
+
h('span', null, t('directAsk.attach')),
|
|
9243
|
+
),
|
|
9244
|
+
h('p', { className: 'dsh-powerup-setting-hint' }, t('directAsk.attachHint')),
|
|
9245
|
+
error ? h('p', { className: 'dsh-powerup-progress-error' }, error) : null,
|
|
9246
|
+
answer !== '' ? h('div', { className: 'dsh-powerup-directask-answer' },
|
|
9247
|
+
h('h4', { className: 'dsh-powerup-section' }, t('directAsk.answer')),
|
|
9248
|
+
h('div', { className: 'dsh-powerup-directask-answer-body' }, answer),
|
|
9249
|
+
h('button', {
|
|
9250
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
9251
|
+
onClick: async () => {
|
|
9252
|
+
const ok = await copyText(answer);
|
|
9253
|
+
if (ok) { setCopied(true); setTimeout(() => setCopied(false), 1500); }
|
|
9254
|
+
},
|
|
9255
|
+
}, copied ? t('directAsk.copied') : t('directAsk.copy')),
|
|
9256
|
+
) : null,
|
|
9257
|
+
),
|
|
9258
|
+
h('div', { className: 'dsh-powerup-update-foot' },
|
|
9259
|
+
h('span', { className: 'dsh-powerup-setting-hint' }, t('directAsk.showHint')),
|
|
9260
|
+
h('button', {
|
|
9261
|
+
type: 'button', className: 'dsh-powerup-update-primary',
|
|
9262
|
+
disabled: busy || question.trim() === '', onClick: () => void send(),
|
|
9263
|
+
}, busy ? t('directAsk.sending') : t('directAsk.send')),
|
|
9264
|
+
),
|
|
9265
|
+
),
|
|
9266
|
+
);
|
|
9267
|
+
|
|
9268
|
+
return h(React.Fragment, null, button, renderInBody(dialog));
|
|
9269
|
+
}
|
|
9270
|
+
|
|
8996
9271
|
function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
|
|
8997
9272
|
const settings = useSettings();
|
|
8998
9273
|
const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
|
|
@@ -9144,6 +9419,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9144
9419
|
),
|
|
9145
9420
|
),
|
|
9146
9421
|
h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
|
|
9422
|
+
h(ProgressScopeRequirements, { t, workspaceId, sessionId: ownerId }),
|
|
9147
9423
|
),
|
|
9148
9424
|
);
|
|
9149
9425
|
}
|
|
@@ -9706,7 +9982,16 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9706
9982
|
featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
|
|
9707
9983
|
featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
|
|
9708
9984
|
featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
|
|
9709
|
-
featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow'
|
|
9985
|
+
featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow',
|
|
9986
|
+
h('div', { className: 'dsh-powerup-card-detail' },
|
|
9987
|
+
h(ProgressRequirementsEditor, { t }),
|
|
9988
|
+
),
|
|
9989
|
+
),
|
|
9990
|
+
featureCard('directAsk', TagIcon, 'page.directAskTitle', 'page.directAskDesc', 'page.directAskHow',
|
|
9991
|
+
h('div', { className: 'dsh-powerup-card-detail' },
|
|
9992
|
+
settingRow('directAsk', settings.directAsk !== false, t('page.directAskToggle'), t('page.directAskToggleHint')),
|
|
9993
|
+
),
|
|
9994
|
+
),
|
|
9710
9995
|
featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
|
|
9711
9996
|
featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
|
|
9712
9997
|
featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
|
|
@@ -9764,13 +10049,125 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9764
10049
|
// Task progress: header button + body-portal panel
|
|
9765
10050
|
// ------------------------------------------------------------------
|
|
9766
10051
|
const PROGRESS_API = '/dsh-powerup/api/progress';
|
|
10052
|
+
const REQUIREMENTS_API = '/dsh-powerup/api/progress-requirements';
|
|
10053
|
+
const HISTORY_API = '/dsh-powerup/api/progress-history';
|
|
10054
|
+
const DIRECT_ASK_API = '/dsh-powerup/api/direct-ask';
|
|
10055
|
+
|
|
10056
|
+
/** Module-level requirements cache: {global, workspaces:{}, sessions:{}}. */
|
|
10057
|
+
let requirementsCache = { global: '', workspaces: {}, sessions: {} };
|
|
10058
|
+
let requirementsLoaded = false;
|
|
10059
|
+
const requirementsListeners = new Set();
|
|
10060
|
+
function emitRequirements() {
|
|
10061
|
+
for (const fn of [...requirementsListeners]) {
|
|
10062
|
+
try { fn(); } catch { /* one listener must not break the rest */ }
|
|
10063
|
+
}
|
|
10064
|
+
}
|
|
10065
|
+
async function loadRequirements() {
|
|
10066
|
+
if (requirementsLoaded) return requirementsCache;
|
|
10067
|
+
requirementsLoaded = true;
|
|
10068
|
+
try {
|
|
10069
|
+
const response = await fetch(REQUIREMENTS_API, { headers: { accept: 'application/json' } });
|
|
10070
|
+
const data = await response.json();
|
|
10071
|
+
if (data?.ok && data.requirements !== null && typeof data.requirements === 'object') {
|
|
10072
|
+
requirementsCache = {
|
|
10073
|
+
global: typeof data.requirements.global === 'string' ? data.requirements.global : '',
|
|
10074
|
+
workspaces: data.requirements.workspaces ?? {},
|
|
10075
|
+
sessions: data.requirements.sessions ?? {},
|
|
10076
|
+
};
|
|
10077
|
+
}
|
|
10078
|
+
} catch {
|
|
10079
|
+
/* Host unavailable: keep the last known value. */
|
|
10080
|
+
}
|
|
10081
|
+
emitRequirements();
|
|
10082
|
+
return requirementsCache;
|
|
10083
|
+
}
|
|
10084
|
+
function saveRequirements(next) {
|
|
10085
|
+
requirementsCache = next;
|
|
10086
|
+
emitRequirements();
|
|
10087
|
+
fetch(REQUIREMENTS_API, {
|
|
10088
|
+
method: 'POST',
|
|
10089
|
+
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
10090
|
+
body: JSON.stringify({ requirements: next }),
|
|
10091
|
+
}).catch(() => { /* in-memory copy still works this session */ });
|
|
10092
|
+
}
|
|
10093
|
+
function useRequirements() {
|
|
10094
|
+
const [, tick] = useState(0);
|
|
10095
|
+
useEffect(() => {
|
|
10096
|
+
void loadRequirements();
|
|
10097
|
+
const listener = () => tick((n) => n + 1);
|
|
10098
|
+
requirementsListeners.add(listener);
|
|
10099
|
+
return () => requirementsListeners.delete(listener);
|
|
10100
|
+
}, []);
|
|
10101
|
+
return requirementsCache;
|
|
10102
|
+
}
|
|
10103
|
+
|
|
10104
|
+
/** Textarea field for one requirements layer. */
|
|
10105
|
+
function RequirementField({ label, hint, value, placeholder, onChange }) {
|
|
10106
|
+
return h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10107
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, label),
|
|
10108
|
+
hint ? h('span', { className: 'dsh-powerup-setting-hint' }, hint) : null,
|
|
10109
|
+
h('textarea', {
|
|
10110
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
|
|
10111
|
+
value: value ?? '',
|
|
10112
|
+
placeholder: placeholder ?? '',
|
|
10113
|
+
onChange: (event) => onChange(event.target.value),
|
|
10114
|
+
}),
|
|
10115
|
+
);
|
|
10116
|
+
}
|
|
10117
|
+
|
|
10118
|
+
/** Settings-page editor: global progress requirements. */
|
|
10119
|
+
function ProgressRequirementsEditor({ t }) {
|
|
10120
|
+
const reqs = useRequirements();
|
|
10121
|
+
return h('div', { className: 'dsh-powerup-progress-req-editor' },
|
|
10122
|
+
h('p', { className: 'dsh-powerup-card-desc' }, t('progress.reqHint')),
|
|
10123
|
+
h(RequirementField, {
|
|
10124
|
+
label: t('progress.reqGlobal'),
|
|
10125
|
+
value: reqs.global,
|
|
10126
|
+
placeholder: t('progress.reqPlaceholder'),
|
|
10127
|
+
onChange: (value) => saveRequirements({ ...requirementsCache, global: value }),
|
|
10128
|
+
}),
|
|
10129
|
+
);
|
|
10130
|
+
}
|
|
10131
|
+
|
|
10132
|
+
/** Workspace/session-scoped requirements, shown in the conversation settings tab. */
|
|
10133
|
+
function ProgressScopeRequirements({ t, workspaceId, sessionId }) {
|
|
10134
|
+
const reqs = useRequirements();
|
|
10135
|
+
const ws = typeof workspaceId === 'string' ? workspaceId : '';
|
|
10136
|
+
const sid = typeof sessionId === 'string' ? sessionId : '';
|
|
10137
|
+
const setWorkspace = (value) => {
|
|
10138
|
+
const workspaces = { ...(requirementsCache.workspaces ?? {}) };
|
|
10139
|
+
workspaces[ws] = value;
|
|
10140
|
+
saveRequirements({ ...requirementsCache, workspaces });
|
|
10141
|
+
};
|
|
10142
|
+
const setSession = (value) => {
|
|
10143
|
+
const sessions = { ...(requirementsCache.sessions ?? {}) };
|
|
10144
|
+
sessions[sid] = value;
|
|
10145
|
+
saveRequirements({ ...requirementsCache, sessions });
|
|
10146
|
+
};
|
|
10147
|
+
return h('div', { className: 'dsh-powerup-progress-req-editor' },
|
|
10148
|
+
h('h3', { className: 'dsh-powerup-section-title' }, t('progress.requirements')),
|
|
10149
|
+
h('p', { className: 'dsh-powerup-card-desc' }, t('progress.reqHint')),
|
|
10150
|
+
h(RequirementField, {
|
|
10151
|
+
label: t('progress.reqWorkspace'),
|
|
10152
|
+
value: reqs.workspaces?.[ws] ?? '',
|
|
10153
|
+
placeholder: t('progress.reqPlaceholder'),
|
|
10154
|
+
onChange: setWorkspace,
|
|
10155
|
+
}),
|
|
10156
|
+
sid !== '' ? h(RequirementField, {
|
|
10157
|
+
label: t('progress.reqSession'),
|
|
10158
|
+
value: reqs.sessions?.[sid] ?? '',
|
|
10159
|
+
placeholder: t('progress.reqPlaceholder'),
|
|
10160
|
+
onChange: setSession,
|
|
10161
|
+
}) : null,
|
|
10162
|
+
);
|
|
10163
|
+
}
|
|
9767
10164
|
|
|
9768
10165
|
/** POST to the progress route; returns the parsed body. */
|
|
9769
|
-
async function progressRequest(sessionId, action) {
|
|
10166
|
+
async function progressRequest(sessionId, action, extra = {}) {
|
|
9770
10167
|
const response = await fetch(PROGRESS_API, {
|
|
9771
10168
|
method: 'POST',
|
|
9772
10169
|
headers: { 'content-type': 'application/json' },
|
|
9773
|
-
body: JSON.stringify({ sessionId, action }),
|
|
10170
|
+
body: JSON.stringify({ sessionId, action, ...extra }),
|
|
9774
10171
|
});
|
|
9775
10172
|
const body = await response.json();
|
|
9776
10173
|
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
@@ -9902,18 +10299,38 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9902
10299
|
}
|
|
9903
10300
|
|
|
9904
10301
|
/**
|
|
9905
|
-
* Header utility: a
|
|
9906
|
-
*
|
|
9907
|
-
*
|
|
9908
|
-
*
|
|
10302
|
+
* Header utility: a resizable, body-portal progress panel.
|
|
10303
|
+
*
|
|
10304
|
+
* Enhancements over the original:
|
|
10305
|
+
* - wider default panel, user-resizable via a bottom-right drag handle
|
|
10306
|
+
* (size persisted in localStorage);
|
|
10307
|
+
* - header background shifts from blue to warning red as the report ages;
|
|
10308
|
+
* - a per-session history is kept on the Host and can be browsed/cleared;
|
|
10309
|
+
* - the raw AI text is viewable and copyable;
|
|
10310
|
+
* - one-off requirements can be added in the panel for the next refresh.
|
|
9909
10311
|
*/
|
|
9910
10312
|
function ProgressControl({ sessionId }) {
|
|
9911
10313
|
const settings = useSettings();
|
|
9912
10314
|
const [open, setOpen] = useState(false);
|
|
9913
10315
|
const [view, setView] = useState(null);
|
|
9914
10316
|
const [busy, setBusy] = useState(false);
|
|
10317
|
+
const [historyIndex, setHistoryIndex] = useState(0);
|
|
10318
|
+
const [showRaw, setShowRaw] = useState(false);
|
|
10319
|
+
const [showReq, setShowReq] = useState(false);
|
|
10320
|
+
const [tempReq, setTempReq] = useState('');
|
|
10321
|
+
const [size, setSize] = useState(() => {
|
|
10322
|
+
try {
|
|
10323
|
+
const saved = JSON.parse(localStorage.getItem('dsh-powerup:progress:size:v1') || 'null');
|
|
10324
|
+
if (saved !== null && Number.isFinite(saved.w) && Number.isFinite(saved.h)) {
|
|
10325
|
+
return { w: Math.max(320, Math.min(900, saved.w)), h: Math.max(240, Math.min(900, saved.h)) };
|
|
10326
|
+
}
|
|
10327
|
+
} catch { /* fall through */ }
|
|
10328
|
+
return { w: 520, h: 560 };
|
|
10329
|
+
});
|
|
10330
|
+
const [ageTick, setAgeTick] = useState(0);
|
|
9915
10331
|
const panelRef = useRef(null);
|
|
9916
10332
|
const buttonRef = useRef(null);
|
|
10333
|
+
const dragRef = useRef(null);
|
|
9917
10334
|
const sessionRef = useRef(sessionId);
|
|
9918
10335
|
sessionRef.current = sessionId;
|
|
9919
10336
|
const t = useCallback((key, params) => translateCurrent(key, params), []);
|
|
@@ -9938,29 +10355,45 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9938
10355
|
if (disposed) return;
|
|
9939
10356
|
const body = await refresh();
|
|
9940
10357
|
if (disposed) return;
|
|
9941
|
-
if (body?.status === 'running')
|
|
9942
|
-
window.setTimeout(tick, 900);
|
|
9943
|
-
}
|
|
10358
|
+
if (body?.status === 'running') window.setTimeout(tick, 900);
|
|
9944
10359
|
};
|
|
9945
10360
|
void tick();
|
|
9946
10361
|
return () => { disposed = true; };
|
|
9947
10362
|
}, [open, refresh]);
|
|
9948
10363
|
|
|
10364
|
+
// Repaint the time-based header colour once a minute.
|
|
10365
|
+
useEffect(() => {
|
|
10366
|
+
if (!open) return undefined;
|
|
10367
|
+
const timer = window.setInterval(() => setAgeTick((n) => n + 1), 60_000);
|
|
10368
|
+
return () => window.clearInterval(timer);
|
|
10369
|
+
}, [open]);
|
|
10370
|
+
|
|
9949
10371
|
const run = useCallback(async () => {
|
|
9950
10372
|
const id = sessionRef.current;
|
|
9951
10373
|
if (typeof id !== 'string' || id === '') return;
|
|
9952
10374
|
setBusy(true);
|
|
9953
10375
|
try {
|
|
9954
|
-
const body = await progressRequest(id, 'start');
|
|
10376
|
+
const body = await progressRequest(id, 'start', { requirements: tempReq });
|
|
9955
10377
|
setView(body);
|
|
10378
|
+
setHistoryIndex(0);
|
|
9956
10379
|
} catch (error) {
|
|
9957
10380
|
setView({ status: 'error', error: error?.message ?? String(error) });
|
|
9958
10381
|
} finally {
|
|
9959
10382
|
setBusy(false);
|
|
9960
|
-
// Kick the polling loop even if it was already mounted.
|
|
9961
10383
|
if (!open) setOpen(true);
|
|
9962
10384
|
}
|
|
9963
|
-
}, [open]);
|
|
10385
|
+
}, [open, tempReq]);
|
|
10386
|
+
|
|
10387
|
+
const clearHistory = useCallback(async () => {
|
|
10388
|
+
const id = sessionRef.current;
|
|
10389
|
+
if (typeof id !== 'string' || id === '') return;
|
|
10390
|
+
if (window.confirm(t('progress.clearHistoryConfirm')) !== true) return;
|
|
10391
|
+
try {
|
|
10392
|
+
const body = await progressRequest(id, 'clear');
|
|
10393
|
+
setView(body);
|
|
10394
|
+
setHistoryIndex(0);
|
|
10395
|
+
} catch { /* keep the current view */ }
|
|
10396
|
+
}, [t]);
|
|
9964
10397
|
|
|
9965
10398
|
const close = useCallback(() => setOpen(false), []);
|
|
9966
10399
|
|
|
@@ -9985,9 +10418,48 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9985
10418
|
};
|
|
9986
10419
|
}, [open, close]);
|
|
9987
10420
|
|
|
10421
|
+
// Bottom-right resize handle: ordinary pointer events on the panel node.
|
|
10422
|
+
useEffect(() => {
|
|
10423
|
+
if (!open) return undefined;
|
|
10424
|
+
const onMove = (event) => {
|
|
10425
|
+
const drag = dragRef.current;
|
|
10426
|
+
if (drag === null) return;
|
|
10427
|
+
const w = Math.max(320, Math.min(900, drag.w + drag.x - event.clientX));
|
|
10428
|
+
const h = Math.max(240, Math.min(900, drag.h + drag.y - event.clientY));
|
|
10429
|
+
setSize({ w, h });
|
|
10430
|
+
};
|
|
10431
|
+
const onUp = () => {
|
|
10432
|
+
if (dragRef.current === null) return;
|
|
10433
|
+
dragRef.current = null;
|
|
10434
|
+
try { localStorage.setItem('dsh-powerup:progress:size:v1', JSON.stringify(size)); } catch { /* ignore */ }
|
|
10435
|
+
};
|
|
10436
|
+
document.addEventListener('pointermove', onMove);
|
|
10437
|
+
document.addEventListener('pointerup', onUp);
|
|
10438
|
+
return () => {
|
|
10439
|
+
document.removeEventListener('pointermove', onMove);
|
|
10440
|
+
document.removeEventListener('pointerup', onUp);
|
|
10441
|
+
};
|
|
10442
|
+
}, [open, size]);
|
|
10443
|
+
|
|
9988
10444
|
if (settings.taskProgress === false) return null;
|
|
9989
10445
|
const running = view?.status === 'running' || busy;
|
|
9990
|
-
const
|
|
10446
|
+
const history = Array.isArray(view?.history) ? view.history : [];
|
|
10447
|
+
// The selected history entry is the displayed report; index 0 = latest.
|
|
10448
|
+
const selected = history.length > 0
|
|
10449
|
+
? history[Math.min(historyIndex, history.length - 1)]
|
|
10450
|
+
: null;
|
|
10451
|
+
const report = selected?.report ?? selected ?? view?.report;
|
|
10452
|
+
|
|
10453
|
+
// Age of the displayed report, used for the blue → red header gradient.
|
|
10454
|
+
// `ageTick` forces this recomputation once a minute while open.
|
|
10455
|
+
void ageTick;
|
|
10456
|
+
const reportAt = selected?.updatedAt ?? view?.updatedAt ?? 0;
|
|
10457
|
+
const ageMinutes = reportAt > 0 ? (Date.now() - reportAt) / 60_000 : 0;
|
|
10458
|
+
// 0 min → blue (210), 60+ min → red (0). Keep a hint of blue until 15 min.
|
|
10459
|
+
const hue = Math.max(0, 210 - Math.min(60, ageMinutes) * 3.5);
|
|
10460
|
+
const headerStyle = reportAt > 0
|
|
10461
|
+
? { background: `linear-gradient(90deg, hsl(${hue} 70% 42% / 0.22), hsl(${hue} 70% 42% / 0.06))` }
|
|
10462
|
+
: undefined;
|
|
9991
10463
|
|
|
9992
10464
|
const button = h('button', {
|
|
9993
10465
|
ref: buttonRef,
|
|
@@ -10006,56 +10478,90 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10006
10478
|
running ? h('span', { className: 'dsh-powerup-progress-btn-dot' }) : null,
|
|
10007
10479
|
);
|
|
10008
10480
|
|
|
10481
|
+
const reportBody = (() => {
|
|
10482
|
+
if (report === null || report === undefined) return null;
|
|
10483
|
+
return h('div', null,
|
|
10484
|
+
h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
|
|
10485
|
+
h('div', { className: 'dsh-powerup-progress-meter' },
|
|
10486
|
+
h('div', { className: 'dsh-powerup-progress-meter-head' },
|
|
10487
|
+
h('span', null, MODE_LABEL[report.mode] ?? report.mode),
|
|
10488
|
+
h('strong', null, `${report.percent}%`),
|
|
10489
|
+
),
|
|
10490
|
+
h('div', { className: 'dsh-powerup-progress-track' },
|
|
10491
|
+
h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${report.percent}%` } }),
|
|
10492
|
+
),
|
|
10493
|
+
),
|
|
10494
|
+
ProgressStructure(report),
|
|
10495
|
+
ProgressDisplay(report),
|
|
10496
|
+
);
|
|
10497
|
+
})();
|
|
10498
|
+
|
|
10009
10499
|
const body = (() => {
|
|
10010
10500
|
if (view === null) return h('div', { className: 'dsh-powerup-progress-empty' }, t('progress.hint'));
|
|
10011
10501
|
if (view.status === 'error') return h('p', { className: 'dsh-powerup-progress-error' }, view.error ?? t('progress.failed'));
|
|
10012
|
-
if (
|
|
10502
|
+
if (running) {
|
|
10013
10503
|
return h('div', null,
|
|
10014
|
-
h('
|
|
10015
|
-
|
|
10016
|
-
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10017
|
-
disabled: busy, onClick: () => void run(),
|
|
10018
|
-
}, t('progress.generate')),
|
|
10504
|
+
h('div', { className: 'dsh-powerup-progress-loading' }, t('progress.loading')),
|
|
10505
|
+
reportBody,
|
|
10019
10506
|
);
|
|
10020
10507
|
}
|
|
10021
|
-
if (
|
|
10508
|
+
if (showRaw) {
|
|
10509
|
+
const raw = typeof report?.raw === 'string' ? report.raw : '';
|
|
10022
10510
|
return h('div', null,
|
|
10023
|
-
h('
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10511
|
+
h('h4', { className: 'dsh-powerup-progress-section' }, t('progress.rawTitle')),
|
|
10512
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.rawHint')),
|
|
10513
|
+
h('pre', { className: 'dsh-powerup-progress-code' }, raw || '(empty)'),
|
|
10514
|
+
h('button', {
|
|
10515
|
+
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10516
|
+
onClick: () => void copyText(raw),
|
|
10517
|
+
}, t('progress.copyRaw')),
|
|
10028
10518
|
);
|
|
10029
10519
|
}
|
|
10030
10520
|
if (report === null || report === undefined) {
|
|
10031
10521
|
return h('div', null,
|
|
10032
|
-
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.
|
|
10522
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
|
|
10033
10523
|
h('button', {
|
|
10034
10524
|
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10035
10525
|
disabled: busy, onClick: () => void run(),
|
|
10036
|
-
}, t('progress.
|
|
10526
|
+
}, t('progress.generate')),
|
|
10037
10527
|
);
|
|
10038
10528
|
}
|
|
10039
10529
|
return h('div', null,
|
|
10040
|
-
|
|
10041
|
-
h('div', { className: 'dsh-powerup-progress-
|
|
10042
|
-
h('
|
|
10043
|
-
|
|
10044
|
-
h('
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10530
|
+
// History switcher — browsing an older report never discards it.
|
|
10531
|
+
history.length > 1 ? h('div', { className: 'dsh-powerup-progress-history' },
|
|
10532
|
+
h('span', { className: 'dsh-powerup-progress-section' }, t('progress.history')),
|
|
10533
|
+
h('div', { className: 'dsh-powerup-progress-history-list' },
|
|
10534
|
+
history.map((entry, index) => h('button', {
|
|
10535
|
+
key: entry.updatedAt ?? index,
|
|
10536
|
+
type: 'button',
|
|
10537
|
+
className: 'dsh-powerup-progress-history-item' + (index === historyIndex ? ' on' : ''),
|
|
10538
|
+
onClick: () => setHistoryIndex(index),
|
|
10539
|
+
}, new Date(entry.updatedAt ?? Date.now()).toLocaleTimeString())),
|
|
10048
10540
|
),
|
|
10049
|
-
),
|
|
10050
|
-
|
|
10051
|
-
|
|
10541
|
+
) : null,
|
|
10542
|
+
ageMinutes > 15 ? h('p', { className: 'dsh-powerup-progress-age' },
|
|
10543
|
+
t('progress.ageWarning', { minutes: Math.round(ageMinutes) }),
|
|
10544
|
+
) : null,
|
|
10545
|
+
reportBody,
|
|
10052
10546
|
);
|
|
10053
10547
|
})();
|
|
10054
10548
|
|
|
10549
|
+
const requirementsEditor = showReq ? h('div', { className: 'dsh-powerup-progress-req-pop' },
|
|
10550
|
+
h(RequirementField, {
|
|
10551
|
+
label: t('progress.reqTemporary'),
|
|
10552
|
+
hint: t('progress.reqTemporaryHint'),
|
|
10553
|
+
value: tempReq,
|
|
10554
|
+
placeholder: t('progress.reqPlaceholder'),
|
|
10555
|
+
onChange: setTempReq,
|
|
10556
|
+
}),
|
|
10557
|
+
) : null;
|
|
10558
|
+
|
|
10055
10559
|
const panel = !open ? null : h('div', {
|
|
10056
10560
|
ref: panelRef,
|
|
10057
10561
|
className: 'dsh-powerup-progress-panel',
|
|
10058
10562
|
style: {
|
|
10563
|
+
width: `${size.w}px`,
|
|
10564
|
+
maxHeight: `${size.h}px`,
|
|
10059
10565
|
top: (() => {
|
|
10060
10566
|
const rect = buttonRef.current?.getBoundingClientRect?.();
|
|
10061
10567
|
return `${Math.round((rect?.bottom ?? 44) + 6)}px`;
|
|
@@ -10066,7 +10572,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10066
10572
|
})(),
|
|
10067
10573
|
},
|
|
10068
10574
|
},
|
|
10069
|
-
h('div', { className: 'dsh-powerup-progress-head' },
|
|
10575
|
+
h('div', { className: 'dsh-powerup-progress-head', style: headerStyle },
|
|
10070
10576
|
h('div', { className: 'dsh-powerup-progress-heading' },
|
|
10071
10577
|
h('span', { className: 'dsh-powerup-progress-title' }, report?.title ?? t('progress.title')),
|
|
10072
10578
|
h('span', { className: 'dsh-powerup-progress-sub' },
|
|
@@ -10079,16 +10585,37 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10079
10585
|
'aria-label': t('progress.close'), onClick: close,
|
|
10080
10586
|
}, '×'),
|
|
10081
10587
|
),
|
|
10588
|
+
requirementsEditor,
|
|
10082
10589
|
h('div', { className: 'dsh-powerup-progress-body' }, body),
|
|
10083
10590
|
h('div', { className: 'dsh-powerup-progress-foot' },
|
|
10084
10591
|
h('span', { className: 'dsh-powerup-progress-time' },
|
|
10085
10592
|
view?.updatedAt ? format(t('progress.updated'), { time: new Date(view.updatedAt).toLocaleTimeString() }) : '',
|
|
10086
10593
|
),
|
|
10594
|
+
h('button', {
|
|
10595
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10596
|
+
onClick: () => setShowReq((v) => !v),
|
|
10597
|
+
}, t('progress.requirements')),
|
|
10598
|
+
report?.raw ? h('button', {
|
|
10599
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10600
|
+
onClick: () => setShowRaw((v) => !v),
|
|
10601
|
+
}, t('progress.viewRaw')) : null,
|
|
10602
|
+
history.length > 0 ? h('button', {
|
|
10603
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10604
|
+
onClick: () => void clearHistory(),
|
|
10605
|
+
}, t('progress.clearHistory')) : null,
|
|
10087
10606
|
h('button', {
|
|
10088
10607
|
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10089
10608
|
disabled: busy || running, onClick: () => void run(),
|
|
10090
10609
|
}, t('progress.refresh')),
|
|
10091
10610
|
),
|
|
10611
|
+
h('div', {
|
|
10612
|
+
className: 'dsh-powerup-progress-resizer',
|
|
10613
|
+
title: t('progress.resizeHint'),
|
|
10614
|
+
onPointerDown: (event) => {
|
|
10615
|
+
event.preventDefault();
|
|
10616
|
+
dragRef.current = { x: event.clientX, y: event.clientY, w: size.w, h: size.h };
|
|
10617
|
+
},
|
|
10618
|
+
}),
|
|
10092
10619
|
);
|
|
10093
10620
|
|
|
10094
10621
|
return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
|
|
@@ -10170,6 +10697,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10170
10697
|
t: (key, params) => translateCurrent(key, params),
|
|
10171
10698
|
}), 'dsh-powerup: dual send buttons');
|
|
10172
10699
|
|
|
10700
|
+
register('conversation.input.right', {
|
|
10701
|
+
id: 'powerup-direct-ask',
|
|
10702
|
+
order: 82,
|
|
10703
|
+
}, (props) => h(DirectAskButton, { sessionId: props?.sessionId }), 'dsh-powerup: direct ask');
|
|
10704
|
+
|
|
10173
10705
|
// In an ongoing session, place the prompt picker in the bottom tool row
|
|
10174
10706
|
// just after the host's permission / plan dropdowns; its popover opens
|
|
10175
10707
|
// upward so it is not clipped by the screen bottom.
|
|
@@ -10252,6 +10784,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10252
10784
|
PROMPTS_CSS,
|
|
10253
10785
|
PROGRESS_CSS,
|
|
10254
10786
|
ProgressControl,
|
|
10787
|
+
ProgressRequirementsEditor,
|
|
10788
|
+
ProgressScopeRequirements,
|
|
10789
|
+
DirectAskButton,
|
|
10255
10790
|
ProgressStructure,
|
|
10256
10791
|
ProgressDisplay,
|
|
10257
10792
|
progressRequest,
|