@restregular/dsh-powerup 0.12.0 → 0.14.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 +32 -1
- package/client.js +908 -45
- package/index.js +250 -7
- package/lib/direct-ask.js +126 -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,65 @@
|
|
|
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.tabRequirements': '要求',
|
|
387
|
+
'progress.reqHint': '每条要求可设置语言、结构、必须包含的数据、额外展示区要回答的问题等;按工作区隔离,留空工作区则对所有工作区生效。生成进度时可勾选本次要应用哪些要求。',
|
|
388
|
+
'progress.reqNew': '新建要求',
|
|
389
|
+
'progress.reqSelect': '本次应用的要求',
|
|
390
|
+
'progress.reqSelectHint': '勾选本次生成要使用要求;不选则不附加任何要求。',
|
|
391
|
+
'progress.reqGlobal': '通用要求(设置页)',
|
|
392
|
+
'progress.reqWorkspace': '工作区要求',
|
|
393
|
+
'progress.reqSession': '会话要求',
|
|
394
|
+
'progress.reqTemporary': '本次临时要求',
|
|
395
|
+
'progress.reqTemporaryHint': '仅本次生成生效,不会保存。',
|
|
396
|
+
'progress.reqPlaceholder': '例如:用中文回答,包含每步耗时,展示区回答「下一步做什么」',
|
|
397
|
+
'progress.reqSaved': '要求已保存',
|
|
398
|
+
'progress.reqEmpty': '还没有设置任何要求',
|
|
399
|
+
'progress.ageWarning': '已过去 {minutes} 分钟',
|
|
400
|
+
'progress.resizeHint': '拖动右下角调整窗口大小',
|
|
401
|
+
'page.directAskTitle': '轻量问答按钮',
|
|
402
|
+
'page.directAskDesc': '在底部输入区新增一个按钮,直接把问题发给模型。不启动 Agent,不加载系统提示词、工具和技能,仅用于简单问答,回答更快、更省 token。可在弹窗里附带文件作为上下文。',
|
|
403
|
+
'page.directAskHow': '点底部输入区的闪电按钮,输入问题后发送;回答会显示在一个可开关的弹窗里。这个能力不是 Agent,不能调用工具或加载技能。',
|
|
404
|
+
'page.directAskToggle': '启用轻量问答按钮',
|
|
405
|
+
'page.directAskToggleHint': '关闭后底部输入区不再显示该按钮。',
|
|
406
|
+
'directAsk.label': '直接问答',
|
|
407
|
+
'directAsk.hint': '不启动 Agent,直接问模型(无工具/技能)',
|
|
408
|
+
'directAsk.title': '轻量问答',
|
|
409
|
+
'directAsk.subtitle': '不加载系统提示词、工具或技能,仅回答问题',
|
|
410
|
+
'directAsk.placeholder': '输入你的问题…',
|
|
411
|
+
'directAsk.send': '发送',
|
|
412
|
+
'directAsk.sending': '正在回答…',
|
|
413
|
+
'directAsk.attach': '添加文件上下文',
|
|
414
|
+
'directAsk.attachHint': '选择文本文件,内容会作为参考附加在问题前(不会写入会话)。',
|
|
415
|
+
'directAsk.removeFile': '移除',
|
|
416
|
+
'directAsk.empty': '请输入问题',
|
|
417
|
+
'directAsk.answer': '回答',
|
|
418
|
+
'directAsk.copy': '复制回答',
|
|
419
|
+
'directAsk.copied': '已复制',
|
|
420
|
+
'directAsk.close': '关闭',
|
|
421
|
+
'directAsk.hide': '隐藏弹窗',
|
|
422
|
+
'directAsk.showHint': '输入问题开始对话;可继续追问,点「+」开启新对话,点「◷」查看历史。拖动标题栏移动窗口。',
|
|
423
|
+
'directAsk.newChat': '新对话',
|
|
424
|
+
'directAsk.history': '历史记录',
|
|
425
|
+
'directAsk.historyEmpty': '还没有历史对话',
|
|
426
|
+
'directAsk.clearHistory': '清空历史',
|
|
427
|
+
'directAsk.clearHistoryConfirm': '确定清空全部问答历史?此操作不可撤销。',
|
|
375
428
|
'page.promptsTitle': '工作区提示词',
|
|
376
429
|
'page.promptsDesc': '为每个工作区保存可复用的提示词。开启后,新会话行的 Agent 预设右侧会出现一个下拉列表,选择即可把提示词填入输入框(可继续编辑),或点提示词右侧的发送按钮直接发出。',
|
|
377
430
|
'page.promptsHow': '先启用本功能,再切到「工作区提示词」标签页创建提示词;提示词按工作区隔离,没有标题时显示开头几个字。',
|
|
@@ -654,6 +707,7 @@
|
|
|
654
707
|
'restart.resumePromptLabel': 'Continuation prompt (optional)',
|
|
655
708
|
'restart.resumePromptPlaceholder': 'Default: Continue the previous unfinished task.',
|
|
656
709
|
'restart.taskLine': 'Session {id}',
|
|
710
|
+
'restart.taskFallback': 'Untitled session',
|
|
657
711
|
'restart.forceConfirm': 'Force-stop and restart',
|
|
658
712
|
'force.done': 'Stopped {count} task(s); {resumed} session(s) will resume automatically.',
|
|
659
713
|
'update.doneTitle': 'Install complete',
|
|
@@ -699,13 +753,65 @@
|
|
|
699
753
|
'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
|
|
700
754
|
'progress.empty': 'No progress report generated yet.',
|
|
701
755
|
'progress.generate': 'Generate progress',
|
|
702
|
-
'progress.refresh': '
|
|
756
|
+
'progress.refresh': 'Refresh progress',
|
|
703
757
|
'progress.retry': 'Retry',
|
|
704
758
|
'progress.loading': 'Analyzing session progress in the background…',
|
|
705
759
|
'progress.close': 'Close',
|
|
706
760
|
'progress.failed': 'Could not generate progress',
|
|
707
761
|
'progress.stale': 'Stale report',
|
|
708
762
|
'progress.updated': 'Updated at {time}',
|
|
763
|
+
'progress.history': 'History',
|
|
764
|
+
'progress.historyEmpty': 'No history yet',
|
|
765
|
+
'progress.viewRaw': 'View raw output',
|
|
766
|
+
'progress.rawTitle': 'Raw AI output',
|
|
767
|
+
'progress.rawHint': 'This is the exact text returned by the model, before parsing.',
|
|
768
|
+
'progress.copyRaw': 'Copy raw',
|
|
769
|
+
'progress.clearHistory': 'Clear history',
|
|
770
|
+
'progress.clearHistoryConfirm': 'Clear all progress history? This cannot be undone.',
|
|
771
|
+
'progress.cleared': 'History cleared',
|
|
772
|
+
'progress.requirements': 'Requirements',
|
|
773
|
+
'progress.tabRequirements': 'Requirements',
|
|
774
|
+
'progress.reqHint': 'Each requirement sets language, structure, required data, questions for the display area, etc. Scoped per workspace; a blank workspace applies everywhere. Choose which ones to apply when generating progress.',
|
|
775
|
+
'progress.reqNew': 'New requirement',
|
|
776
|
+
'progress.reqSelect': 'Requirements for this run',
|
|
777
|
+
'progress.reqSelectHint': 'Check the requirements to apply this time; none selected means no extra requirements.',
|
|
778
|
+
'progress.reqGlobal': 'Global requirements (settings)',
|
|
779
|
+
'progress.reqWorkspace': 'Workspace requirements',
|
|
780
|
+
'progress.reqSession': 'Session requirements',
|
|
781
|
+
'progress.reqTemporary': 'One-off requirements',
|
|
782
|
+
'progress.reqTemporaryHint': 'Applies to this generation only; not saved.',
|
|
783
|
+
'progress.reqPlaceholder': 'e.g. Answer in Chinese, include per-step timing, answer "what is next" in the display area',
|
|
784
|
+
'progress.reqSaved': 'Requirements saved',
|
|
785
|
+
'progress.reqEmpty': 'No requirements configured',
|
|
786
|
+
'progress.ageWarning': '{minutes} minutes elapsed',
|
|
787
|
+
'progress.resizeHint': 'Drag the bottom-right corner to resize',
|
|
788
|
+
'page.directAskTitle': 'Direct-ask button',
|
|
789
|
+
'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.',
|
|
790
|
+
'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.',
|
|
791
|
+
'page.directAskToggle': 'Enable direct-ask button',
|
|
792
|
+
'page.directAskToggleHint': 'When off, the composer button is hidden.',
|
|
793
|
+
'directAsk.label': 'Direct ask',
|
|
794
|
+
'directAsk.hint': 'Ask the model without an Agent (no tools or skills)',
|
|
795
|
+
'directAsk.title': 'Direct ask',
|
|
796
|
+
'directAsk.subtitle': 'No system prompt, tools or skills — just an answer',
|
|
797
|
+
'directAsk.placeholder': 'Type your question…',
|
|
798
|
+
'directAsk.send': 'Send',
|
|
799
|
+
'directAsk.sending': 'Answering…',
|
|
800
|
+
'directAsk.attach': 'Add file context',
|
|
801
|
+
'directAsk.attachHint': 'Pick a text file; its content is attached before the question as reference (never written to the session).',
|
|
802
|
+
'directAsk.removeFile': 'Remove',
|
|
803
|
+
'directAsk.empty': 'Enter a question first',
|
|
804
|
+
'directAsk.answer': 'Answer',
|
|
805
|
+
'directAsk.copy': 'Copy answer',
|
|
806
|
+
'directAsk.copied': 'Copied',
|
|
807
|
+
'directAsk.close': 'Close',
|
|
808
|
+
'directAsk.hide': 'Hide dialog',
|
|
809
|
+
'directAsk.showHint': 'Type a question to start; follow up anytime, "+" starts a new chat, "◷" shows history. Drag the title bar to move.',
|
|
810
|
+
'directAsk.newChat': 'New chat',
|
|
811
|
+
'directAsk.history': 'History',
|
|
812
|
+
'directAsk.historyEmpty': 'No saved conversations yet',
|
|
813
|
+
'directAsk.clearHistory': 'Clear history',
|
|
814
|
+
'directAsk.clearHistoryConfirm': 'Clear all Q&A history? This cannot be undone.',
|
|
709
815
|
'page.promptsTitle': 'Workspace prompts',
|
|
710
816
|
'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
817
|
'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 +910,7 @@
|
|
|
804
910
|
dualSend: false,
|
|
805
911
|
workspacePrompts: true,
|
|
806
912
|
taskProgress: true,
|
|
913
|
+
directAsk: true,
|
|
807
914
|
oneClickEnable: true,
|
|
808
915
|
oneClickRestart: true,
|
|
809
916
|
};
|
|
@@ -827,6 +934,7 @@
|
|
|
827
934
|
dualSend: parsed.dualSend === true,
|
|
828
935
|
workspacePrompts: parsed.workspacePrompts !== false,
|
|
829
936
|
taskProgress: parsed.taskProgress !== false,
|
|
937
|
+
directAsk: parsed.directAsk !== false,
|
|
830
938
|
oneClickEnable: parsed.oneClickEnable !== false,
|
|
831
939
|
oneClickRestart: parsed.oneClickRestart !== false,
|
|
832
940
|
};
|
|
@@ -4135,7 +4243,8 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
|
|
|
4135
4243
|
.dsh-powerup-update-tasks>strong{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
|
|
4136
4244
|
.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
4245
|
.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-
|
|
4246
|
+
.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)}
|
|
4247
|
+
.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
4248
|
.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
4249
|
.dsh-powerup-app-check{display:flex;align-items:flex-start;gap:9px;padding:4px 0;cursor:pointer}
|
|
4141
4250
|
.dsh-powerup-app-check input{flex:none;margin:2px 0 0;accent-color:var(--dsw-alias-brand-primary)}
|
|
@@ -4493,7 +4602,70 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4493
4602
|
.dsh-powerup-progress-refresh:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4494
4603
|
.dsh-powerup-progress-refresh:disabled{opacity:.45;cursor:not-allowed}
|
|
4495
4604
|
.dsh-powerup-progress-time{color:var(--dsw-alias-label-caption);font-size:10px}
|
|
4605
|
+
.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}
|
|
4606
|
+
.dsh-powerup-progress-mini:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4607
|
+
.dsh-powerup-progress-history{margin-bottom:12px}
|
|
4608
|
+
.dsh-powerup-progress-history-list{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
|
|
4609
|
+
.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}
|
|
4610
|
+
.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)}
|
|
4611
|
+
.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}
|
|
4612
|
+
.dsh-powerup-progress-req-pop{padding:10px 16px 0;border-bottom:.5px solid var(--dsw-alias-border-l1);max-height:160px;overflow-y:auto}
|
|
4613
|
+
.dsh-powerup-req-picker{display:flex;flex-direction:column;gap:4px;padding:4px 0}
|
|
4614
|
+
.dsh-powerup-req-option{display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:6px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font-size:11.5px;cursor:pointer}
|
|
4615
|
+
.dsh-powerup-req-option:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
4616
|
+
.dsh-powerup-req-option input{flex:none;accent-color:var(--dsw-alias-brand-primary)}
|
|
4617
|
+
.dsh-powerup-req-manager{display:flex;flex-direction:column;gap:16px}
|
|
4618
|
+
.dsh-powerup-req-list{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}
|
|
4619
|
+
.dsh-powerup-req-item{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
|
|
4620
|
+
.dsh-powerup-req-item.off{opacity:.55}
|
|
4621
|
+
.dsh-powerup-req-copy{display:flex;flex:1 1 auto;flex-direction:column;gap:3px;min-width:0}
|
|
4622
|
+
.dsh-powerup-req-title{font-size:12.5px;font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
4623
|
+
.dsh-powerup-req-text{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:1.5;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
|
4624
|
+
.dsh-powerup-req-form{display:flex;flex-direction:column;gap:8px;margin-top:8px;padding:10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2)}
|
|
4625
|
+
.dsh-powerup-req-form-foot{display:flex;justify-content:flex-end;gap:8px}
|
|
4626
|
+
.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%)}
|
|
4627
|
+
.dsh-powerup-progress-req-editor{display:flex;flex-direction:column;gap:10px;padding:8px 0}
|
|
4496
4628
|
@media (prefers-reduced-motion:reduce){.dsh-powerup-progress-panel,.dsh-powerup-progress-btn.is-running svg,.dsh-powerup-progress-fill{animation:none;transition:none}}
|
|
4629
|
+
/* Direct-ask button + dialog */
|
|
4630
|
+
.dsh-powerup-directask-btn{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;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;line-height:1;cursor:pointer}
|
|
4631
|
+
.dsh-powerup-directask-btn:hover,.dsh-powerup-directask-btn.on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4632
|
+
.dsh-powerup-directask-window{position:fixed;z-index:1600;box-sizing:border-box;display:flex;flex-direction:column;min-width:360px;min-height:280px;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:13px;line-height:1.6;overflow:hidden;animation:dsh-powerup-progress-in .15s ease-out}
|
|
4633
|
+
.dsh-powerup-directask-titlebar{display:flex;align-items:center;gap:8px;flex:none;padding:10px 12px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-3);cursor:move;user-select:none}
|
|
4634
|
+
.dsh-powerup-directask-title{font-size:13px;font-weight:600;white-space:nowrap}
|
|
4635
|
+
.dsh-powerup-directask-subtitle{flex:1 1 auto;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:10.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
4636
|
+
.dsh-powerup-directask-titlebtn,.dsh-powerup-directask-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:15px;line-height:1;cursor:pointer}
|
|
4637
|
+
.dsh-powerup-directask-titlebtn:hover,.dsh-powerup-directask-titlebtn.on,.dsh-powerup-directask-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4638
|
+
.dsh-powerup-directask-history{flex:none;max-height:180px;overflow-y:auto;padding:10px 14px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
|
|
4639
|
+
.dsh-powerup-directask-history-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;font-size:11.5px}
|
|
4640
|
+
.dsh-powerup-directask-history-list{margin:0;padding:0;list-style:none}
|
|
4641
|
+
.dsh-powerup-directask-history-list button{width:100%;padding:5px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;text-align:left;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
4642
|
+
.dsh-powerup-directask-history-list button:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4643
|
+
.dsh-powerup-directask-thread{flex:1 1 auto;min-height:0;overflow-y:auto;padding:14px 16px;display:flex;flex-direction:column;gap:12px;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2)}
|
|
4644
|
+
.dsh-powerup-directask-welcome{margin:auto;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center}
|
|
4645
|
+
.dsh-powerup-directask-turn{display:flex;flex-direction:column;gap:6px}
|
|
4646
|
+
.dsh-powerup-directask-msg{display:flex;flex-direction:column;gap:4px;max-width:88%}
|
|
4647
|
+
.dsh-powerup-directask-msg.user{align-self:flex-end;align-items:flex-end}
|
|
4648
|
+
.dsh-powerup-directask-msg.assistant{align-self:flex-start;align-items:flex-start}
|
|
4649
|
+
.dsh-powerup-directask-msg-body{padding:8px 12px;border-radius:12px;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}
|
|
4650
|
+
.dsh-powerup-directask-msg.user .dsh-powerup-directask-msg-body{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-1));border-bottom-right-radius:3px}
|
|
4651
|
+
.dsh-powerup-directask-msg.assistant .dsh-powerup-directask-msg-body{border-bottom-left-radius:3px}
|
|
4652
|
+
.dsh-powerup-directask-ctx{display:flex;flex-wrap:wrap;gap:4px;align-self:flex-end}
|
|
4653
|
+
.dsh-powerup-directask-ctx span{padding:2px 7px;border-radius:999px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary);font-size:10px}
|
|
4654
|
+
.dsh-powerup-directask-files{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 6px}
|
|
4655
|
+
.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}
|
|
4656
|
+
.dsh-powerup-directask-file button{border:0;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;font-size:13px;line-height:1}
|
|
4657
|
+
.dsh-powerup-directask-composer{flex:none;padding:10px 14px 12px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
4658
|
+
.dsh-powerup-directask-inputrow{display:flex;align-items:flex-end;gap:8px;padding:6px 6px 6px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-layer-3)}
|
|
4659
|
+
.dsh-powerup-directask-inputrow:focus-within{border-color:var(--dsw-alias-brand-primary)}
|
|
4660
|
+
/* Native file input is hidden; only the custom '+' chip is shown. */
|
|
4661
|
+
.dsh-powerup-directask-attach{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:26px;height:26px;border-radius:7px;color:var(--dsw-alias-label-secondary);font-size:18px;line-height:1;cursor:pointer;overflow:hidden}
|
|
4662
|
+
.dsh-powerup-directask-attach:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4663
|
+
.dsh-powerup-directask-attach input[type=file]{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
|
|
4664
|
+
.dsh-powerup-directask-input{flex:1 1 auto;min-width:0;max-height:140px;border:0;outline:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;line-height:1.6;resize:none}
|
|
4665
|
+
.dsh-powerup-directask-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
4666
|
+
.dsh-powerup-directask-send{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:8px;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-1));cursor:pointer}
|
|
4667
|
+
.dsh-powerup-directask-send:disabled{opacity:.4;cursor:not-allowed}
|
|
4668
|
+
.dsh-powerup-directask-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%)}
|
|
4497
4669
|
`;
|
|
4498
4670
|
|
|
4499
4671
|
/** Max display length of a session option, in Unicode code points. */
|
|
@@ -8055,8 +8227,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8055
8227
|
h('ul', { className: 'dsh-powerup-update-task-list' },
|
|
8056
8228
|
appTasks.slice(0, 8).map((task, index) => h('li', { key: `${task.kind}-${task.id}-${index}` },
|
|
8057
8229
|
h('span', { className: 'dsh-powerup-update-task-dot' }),
|
|
8058
|
-
h('
|
|
8059
|
-
|
|
8230
|
+
h('span', { className: 'dsh-powerup-update-task-title' },
|
|
8231
|
+
task.title && task.title !== 'session' ? task.title : t('restart.taskFallback'),
|
|
8232
|
+
),
|
|
8233
|
+
h('code', { title: task.id }, task.id),
|
|
8060
8234
|
)),
|
|
8061
8235
|
),
|
|
8062
8236
|
h('label', { className: 'dsh-powerup-app-check' },
|
|
@@ -8993,6 +9167,313 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8993
9167
|
return behavior;
|
|
8994
9168
|
}
|
|
8995
9169
|
|
|
9170
|
+
/**
|
|
9171
|
+
* Lightning-bolt button in the composer (icon only). Opens a floating,
|
|
9172
|
+
* draggable + resizable DSH-styled Q&A window that talks straight to the
|
|
9173
|
+
* model — no Agent, system prompt, tools or skills. Supports continuous
|
|
9174
|
+
* multi-turn Q&A and a browsable/clearable history of past exchanges.
|
|
9175
|
+
*/
|
|
9176
|
+
function DirectAskButton({ sessionId }) {
|
|
9177
|
+
const settings = useSettings();
|
|
9178
|
+
const [open, setOpen] = useState(false);
|
|
9179
|
+
const [question, setQuestion] = useState('');
|
|
9180
|
+
const [files, setFiles] = useState([]);
|
|
9181
|
+
const [busy, setBusy] = useState(false);
|
|
9182
|
+
const [error, setError] = useState('');
|
|
9183
|
+
const [copied, setCopied] = useState(false);
|
|
9184
|
+
/** Current conversation: [{question, answer, context, at}]. */
|
|
9185
|
+
const [turns, setTurns] = useState([]);
|
|
9186
|
+
/** Archived conversations, newest first: [{id, at, turns}]. */
|
|
9187
|
+
const [history, setHistory] = useState(() => {
|
|
9188
|
+
try { return JSON.parse(localStorage.getItem('dsh-powerup:directask:history:v1') || '[]'); }
|
|
9189
|
+
catch { return []; }
|
|
9190
|
+
});
|
|
9191
|
+
const [showHistory, setShowHistory] = useState(false);
|
|
9192
|
+
const [pos, setPos] = useState(() => {
|
|
9193
|
+
try {
|
|
9194
|
+
const saved = JSON.parse(localStorage.getItem('dsh-powerup:directask:pos:v1') || 'null');
|
|
9195
|
+
if (saved !== null && Number.isFinite(saved.x) && Number.isFinite(saved.y)) return { x: saved.x, y: saved.y };
|
|
9196
|
+
} catch { /* fall through */ }
|
|
9197
|
+
return { x: 24, y: 96 };
|
|
9198
|
+
});
|
|
9199
|
+
const [size, setSize] = useState(() => {
|
|
9200
|
+
try {
|
|
9201
|
+
const saved = JSON.parse(localStorage.getItem('dsh-powerup:directask:size:v1') || 'null');
|
|
9202
|
+
if (saved !== null && Number.isFinite(saved.w) && Number.isFinite(saved.h)) {
|
|
9203
|
+
return { w: Math.max(360, Math.min(1100, saved.w)), h: Math.max(280, Math.min(900, saved.h)) };
|
|
9204
|
+
}
|
|
9205
|
+
} catch { /* fall through */ }
|
|
9206
|
+
return { w: 620, h: 560 };
|
|
9207
|
+
});
|
|
9208
|
+
const dialogRef = useRef(null);
|
|
9209
|
+
const dragRef = useRef(null);
|
|
9210
|
+
const bottomRef = useRef(null);
|
|
9211
|
+
const sessionRef = useRef(sessionId);
|
|
9212
|
+
sessionRef.current = sessionId;
|
|
9213
|
+
const t = useCallback((key, params) => translateCurrent(key, params), []);
|
|
9214
|
+
|
|
9215
|
+
const persistHistory = useCallback((next) => {
|
|
9216
|
+
setHistory(next);
|
|
9217
|
+
try { localStorage.setItem('dsh-powerup:directask:history:v1', JSON.stringify(next.slice(0, 30))); } catch { /* ignore */ }
|
|
9218
|
+
}, []);
|
|
9219
|
+
|
|
9220
|
+
useEffect(() => {
|
|
9221
|
+
if (!open) return undefined;
|
|
9222
|
+
const onKey = (event) => {
|
|
9223
|
+
if (event.key === 'Escape') { event.stopPropagation(); setOpen(false); }
|
|
9224
|
+
};
|
|
9225
|
+
document.addEventListener('keydown', onKey, true);
|
|
9226
|
+
return () => document.removeEventListener('keydown', onKey, true);
|
|
9227
|
+
}, [open]);
|
|
9228
|
+
|
|
9229
|
+
// Drag (title bar) and resize (bottom-right handle) with native pointers.
|
|
9230
|
+
useEffect(() => {
|
|
9231
|
+
if (!open) return undefined;
|
|
9232
|
+
const onMove = (event) => {
|
|
9233
|
+
const drag = dragRef.current;
|
|
9234
|
+
if (drag === null) return;
|
|
9235
|
+
if (drag.kind === 'move') {
|
|
9236
|
+
setPos({
|
|
9237
|
+
x: Math.max(0, Math.min(window.innerWidth - 120, drag.px + event.clientX - drag.x)),
|
|
9238
|
+
y: Math.max(0, Math.min(window.innerHeight - 60, drag.py + event.clientY - drag.y)),
|
|
9239
|
+
});
|
|
9240
|
+
} else if (drag.kind === 'resize') {
|
|
9241
|
+
setSize({
|
|
9242
|
+
w: Math.max(360, Math.min(1100, drag.w + event.clientX - drag.x)),
|
|
9243
|
+
h: Math.max(280, Math.min(900, drag.h + event.clientY - drag.y)),
|
|
9244
|
+
});
|
|
9245
|
+
}
|
|
9246
|
+
};
|
|
9247
|
+
const onUp = () => {
|
|
9248
|
+
if (dragRef.current === null) return;
|
|
9249
|
+
dragRef.current = null;
|
|
9250
|
+
try {
|
|
9251
|
+
localStorage.setItem('dsh-powerup:directask:pos:v1', JSON.stringify(pos));
|
|
9252
|
+
localStorage.setItem('dsh-powerup:directask:size:v1', JSON.stringify(size));
|
|
9253
|
+
} catch { /* ignore */ }
|
|
9254
|
+
};
|
|
9255
|
+
document.addEventListener('pointermove', onMove);
|
|
9256
|
+
document.addEventListener('pointerup', onUp);
|
|
9257
|
+
return () => {
|
|
9258
|
+
document.removeEventListener('pointermove', onMove);
|
|
9259
|
+
document.removeEventListener('pointerup', onUp);
|
|
9260
|
+
};
|
|
9261
|
+
}, [open, pos, size]);
|
|
9262
|
+
|
|
9263
|
+
useEffect(() => {
|
|
9264
|
+
if (bottomRef.current !== null) bottomRef.current.scrollIntoView?.({ block: 'nearest' });
|
|
9265
|
+
}, [turns, busy]);
|
|
9266
|
+
|
|
9267
|
+
const send = useCallback(async () => {
|
|
9268
|
+
const q = question.trim();
|
|
9269
|
+
if (q === '') { setError(t('directAsk.empty')); return; }
|
|
9270
|
+
const priorContext = files.map((f) => ({ name: f.name, text: f.text }));
|
|
9271
|
+
// Continuous Q&A: send the current turns as prior messages.
|
|
9272
|
+
const historyMsgs = [];
|
|
9273
|
+
for (const turn of turns) {
|
|
9274
|
+
historyMsgs.push({ role: 'user', text: turn.question });
|
|
9275
|
+
if (turn.answer) historyMsgs.push({ role: 'assistant', text: turn.answer });
|
|
9276
|
+
}
|
|
9277
|
+
setBusy(true);
|
|
9278
|
+
setError('');
|
|
9279
|
+
setQuestion('');
|
|
9280
|
+
setFiles([]);
|
|
9281
|
+
setCopied(false);
|
|
9282
|
+
try {
|
|
9283
|
+
const response = await fetch(DIRECT_ASK_API, {
|
|
9284
|
+
method: 'POST',
|
|
9285
|
+
headers: { 'content-type': 'application/json' },
|
|
9286
|
+
body: JSON.stringify({
|
|
9287
|
+
sessionId: sessionRef.current ?? '',
|
|
9288
|
+
question: q,
|
|
9289
|
+
context: priorContext,
|
|
9290
|
+
history: historyMsgs,
|
|
9291
|
+
}),
|
|
9292
|
+
});
|
|
9293
|
+
const body = await response.json();
|
|
9294
|
+
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
9295
|
+
setTurns((cur) => [...cur, {
|
|
9296
|
+
question: q, answer: typeof body.answer === 'string' ? body.answer : '',
|
|
9297
|
+
context: priorContext, at: Date.now(),
|
|
9298
|
+
}]);
|
|
9299
|
+
} catch (err) {
|
|
9300
|
+
setError(err?.message ?? String(err));
|
|
9301
|
+
setQuestion(q);
|
|
9302
|
+
} finally {
|
|
9303
|
+
setBusy(false);
|
|
9304
|
+
}
|
|
9305
|
+
}, [question, files, turns, t]);
|
|
9306
|
+
|
|
9307
|
+
const newChat = useCallback(() => {
|
|
9308
|
+
if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history]);
|
|
9309
|
+
setTurns([]);
|
|
9310
|
+
setError('');
|
|
9311
|
+
setShowHistory(false);
|
|
9312
|
+
}, [turns, history, persistHistory]);
|
|
9313
|
+
|
|
9314
|
+
const openArchived = useCallback((entry) => {
|
|
9315
|
+
if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history.filter((h) => h.id !== entry.id)]);
|
|
9316
|
+
else persistHistory(history.filter((h) => h.id !== entry.id));
|
|
9317
|
+
setTurns(Array.isArray(entry.turns) ? entry.turns : []);
|
|
9318
|
+
setShowHistory(false);
|
|
9319
|
+
}, [turns, history, persistHistory]);
|
|
9320
|
+
|
|
9321
|
+
const clearHistory = useCallback(() => {
|
|
9322
|
+
if (typeof window !== 'undefined' && typeof window.confirm === 'function'
|
|
9323
|
+
&& !window.confirm(t('directAsk.clearHistoryConfirm'))) return;
|
|
9324
|
+
persistHistory([]);
|
|
9325
|
+
}, [t, persistHistory]);
|
|
9326
|
+
|
|
9327
|
+
const pickFiles = useCallback(async (event) => {
|
|
9328
|
+
const picked = Array.from(event?.target?.files ?? []);
|
|
9329
|
+
const loaded = [];
|
|
9330
|
+
for (const file of picked) {
|
|
9331
|
+
try {
|
|
9332
|
+
const text = await file.text();
|
|
9333
|
+
loaded.push({ name: file.name, text: String(text).slice(0, 40_000) });
|
|
9334
|
+
} catch {
|
|
9335
|
+
/* skip unreadable files */
|
|
9336
|
+
}
|
|
9337
|
+
}
|
|
9338
|
+
setFiles((current) => [...current, ...loaded]);
|
|
9339
|
+
if (event?.target) event.target.value = '';
|
|
9340
|
+
}, []);
|
|
9341
|
+
|
|
9342
|
+
if (settings.directAsk === false) return null;
|
|
9343
|
+
|
|
9344
|
+
const lightning = h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
|
|
9345
|
+
h('path', { d: 'M9 1.5 3.5 9H7l-1 5.5L12.5 7H9l1-5.5Z', fill: 'currentColor' }),
|
|
9346
|
+
);
|
|
9347
|
+
|
|
9348
|
+
// Icon-only composer button.
|
|
9349
|
+
const button = h('button', {
|
|
9350
|
+
type: 'button',
|
|
9351
|
+
className: 'dsh-powerup-directask-btn' + (open ? ' on' : ''),
|
|
9352
|
+
title: t('directAsk.hint'),
|
|
9353
|
+
'aria-label': t('directAsk.label'),
|
|
9354
|
+
onClick: () => setOpen((v) => !v),
|
|
9355
|
+
}, lightning);
|
|
9356
|
+
|
|
9357
|
+
const dialog = !open ? null : h('div', {
|
|
9358
|
+
className: 'dsh-powerup-directask-window',
|
|
9359
|
+
style: { left: `${pos.x}px`, top: `${pos.y}px`, width: `${size.w}px`, height: `${size.h}px` },
|
|
9360
|
+
},
|
|
9361
|
+
h('div', {
|
|
9362
|
+
className: 'dsh-powerup-directask-titlebar',
|
|
9363
|
+
onPointerDown: (event) => {
|
|
9364
|
+
const target = event.target;
|
|
9365
|
+
if (target instanceof Element && target.closest('button')) return;
|
|
9366
|
+
dragRef.current = { kind: 'move', x: event.clientX, y: event.clientY, px: pos.x, py: pos.y };
|
|
9367
|
+
},
|
|
9368
|
+
},
|
|
9369
|
+
h('span', { className: 'dsh-powerup-directask-title' }, t('directAsk.title')),
|
|
9370
|
+
h('span', { className: 'dsh-powerup-directask-subtitle' }, t('directAsk.subtitle')),
|
|
9371
|
+
h('button', {
|
|
9372
|
+
type: 'button', className: 'dsh-powerup-directask-titlebtn',
|
|
9373
|
+
title: t('directAsk.newChat'), onClick: newChat,
|
|
9374
|
+
}, '+'),
|
|
9375
|
+
h('button', {
|
|
9376
|
+
type: 'button', className: 'dsh-powerup-directask-titlebtn' + (showHistory ? ' on' : ''),
|
|
9377
|
+
title: t('directAsk.history'), onClick: () => setShowHistory((v) => !v),
|
|
9378
|
+
}, '◷'),
|
|
9379
|
+
h('button', {
|
|
9380
|
+
type: 'button', className: 'dsh-powerup-directask-close',
|
|
9381
|
+
'aria-label': t('directAsk.close'), onClick: () => setOpen(false),
|
|
9382
|
+
}, '×'),
|
|
9383
|
+
),
|
|
9384
|
+
showHistory ? h('div', { className: 'dsh-powerup-directask-history' },
|
|
9385
|
+
h('div', { className: 'dsh-powerup-directask-history-head' },
|
|
9386
|
+
h('strong', null, t('directAsk.history')),
|
|
9387
|
+
h('button', { type: 'button', className: 'dsh-powerup-progress-mini', onClick: clearHistory }, t('directAsk.clearHistory')),
|
|
9388
|
+
),
|
|
9389
|
+
history.length === 0
|
|
9390
|
+
? h('p', { className: 'dsh-powerup-progress-empty' }, t('directAsk.historyEmpty'))
|
|
9391
|
+
: h('ul', { className: 'dsh-powerup-directask-history-list' },
|
|
9392
|
+
history.map((entry) => h('li', { key: entry.id },
|
|
9393
|
+
h('button', { type: 'button', onClick: () => openArchived(entry) },
|
|
9394
|
+
new Date(entry.at ?? Date.now()).toLocaleString(),
|
|
9395
|
+
' · ', String(entry.turns?.[0]?.question ?? '').slice(0, 40),
|
|
9396
|
+
),
|
|
9397
|
+
)),
|
|
9398
|
+
),
|
|
9399
|
+
) : null,
|
|
9400
|
+
h('div', { className: 'dsh-powerup-directask-thread' },
|
|
9401
|
+
turns.length === 0 && !busy
|
|
9402
|
+
? h('p', { className: 'dsh-powerup-directask-welcome' }, t('directAsk.showHint'))
|
|
9403
|
+
: null,
|
|
9404
|
+
turns.map((turn, i) => h('div', { key: i, className: 'dsh-powerup-directask-turn' },
|
|
9405
|
+
h('div', { className: 'dsh-powerup-directask-msg user' },
|
|
9406
|
+
h('div', { className: 'dsh-powerup-directask-msg-body' }, turn.question),
|
|
9407
|
+
),
|
|
9408
|
+
turn.context?.length ? h('div', { className: 'dsh-powerup-directask-ctx' },
|
|
9409
|
+
turn.context.map((f, j) => h('span', { key: j }, f.name)),
|
|
9410
|
+
) : null,
|
|
9411
|
+
h('div', { className: 'dsh-powerup-directask-msg assistant' },
|
|
9412
|
+
h('div', { className: 'dsh-powerup-directask-msg-body' }, turn.answer || '…'),
|
|
9413
|
+
h('button', {
|
|
9414
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
9415
|
+
onClick: async () => {
|
|
9416
|
+
const ok = await copyText(turn.answer);
|
|
9417
|
+
if (ok) { setCopied(true); setTimeout(() => setCopied(false), 1500); }
|
|
9418
|
+
},
|
|
9419
|
+
}, copied ? t('directAsk.copied') : t('directAsk.copy')),
|
|
9420
|
+
),
|
|
9421
|
+
)),
|
|
9422
|
+
busy ? h('div', { className: 'dsh-powerup-directask-msg assistant' },
|
|
9423
|
+
h('div', { className: 'dsh-powerup-directask-msg-body' }, t('directAsk.sending')),
|
|
9424
|
+
) : null,
|
|
9425
|
+
h('div', { ref: bottomRef }),
|
|
9426
|
+
),
|
|
9427
|
+
error ? h('p', { className: 'dsh-powerup-progress-error' }, error) : null,
|
|
9428
|
+
h('div', { className: 'dsh-powerup-directask-composer' },
|
|
9429
|
+
files.length > 0 ? h('div', { className: 'dsh-powerup-directask-files' },
|
|
9430
|
+
files.map((f, i) => h('span', { key: i, className: 'dsh-powerup-directask-file' },
|
|
9431
|
+
f.name,
|
|
9432
|
+
h('button', {
|
|
9433
|
+
type: 'button', 'aria-label': t('directAsk.removeFile'),
|
|
9434
|
+
onClick: () => setFiles((cur) => cur.filter((_, j) => j !== i)),
|
|
9435
|
+
}, '×'),
|
|
9436
|
+
)),
|
|
9437
|
+
) : null,
|
|
9438
|
+
h('div', { className: 'dsh-powerup-directask-inputrow' },
|
|
9439
|
+
h('label', { className: 'dsh-powerup-directask-attach', title: t('directAsk.attachHint') },
|
|
9440
|
+
h('input', { type: 'file', multiple: true, onChange: (e) => void pickFiles(e) }),
|
|
9441
|
+
h('span', null, '+'),
|
|
9442
|
+
),
|
|
9443
|
+
h('textarea', {
|
|
9444
|
+
className: 'dsh-powerup-directask-input',
|
|
9445
|
+
value: question,
|
|
9446
|
+
placeholder: t('directAsk.placeholder'),
|
|
9447
|
+
disabled: busy,
|
|
9448
|
+
rows: 1,
|
|
9449
|
+
onChange: (event) => setQuestion(event.target.value),
|
|
9450
|
+
onKeyDown: (event) => {
|
|
9451
|
+
if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {
|
|
9452
|
+
event.preventDefault();
|
|
9453
|
+
void send();
|
|
9454
|
+
}
|
|
9455
|
+
},
|
|
9456
|
+
}),
|
|
9457
|
+
h('button', {
|
|
9458
|
+
type: 'button', className: 'dsh-powerup-directask-send',
|
|
9459
|
+
disabled: busy || question.trim() === '', onClick: () => void send(),
|
|
9460
|
+
title: t('directAsk.send'),
|
|
9461
|
+
}, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
|
|
9462
|
+
h('path', { d: 'M3 8h9M8.5 4.5 12 8l-3.5 3.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
|
|
9463
|
+
),
|
|
9464
|
+
),
|
|
9465
|
+
h('div', {
|
|
9466
|
+
className: 'dsh-powerup-directask-resizer',
|
|
9467
|
+
onPointerDown: (event) => {
|
|
9468
|
+
event.preventDefault();
|
|
9469
|
+
dragRef.current = { kind: 'resize', x: event.clientX, y: event.clientY, w: size.w, h: size.h };
|
|
9470
|
+
},
|
|
9471
|
+
}),
|
|
9472
|
+
);
|
|
9473
|
+
|
|
9474
|
+
return h(React.Fragment, null, button, renderInBody(dialog));
|
|
9475
|
+
}
|
|
9476
|
+
|
|
8996
9477
|
function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
|
|
8997
9478
|
const settings = useSettings();
|
|
8998
9479
|
const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
|
|
@@ -9144,6 +9625,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9144
9625
|
),
|
|
9145
9626
|
),
|
|
9146
9627
|
h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
|
|
9628
|
+
h(RequirementManager, { ctx, workspaceOnly: true, workspaceId }),
|
|
9147
9629
|
),
|
|
9148
9630
|
);
|
|
9149
9631
|
}
|
|
@@ -9692,6 +10174,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9692
10174
|
onClick: () => setTab('prompts'),
|
|
9693
10175
|
}, t('prompts.tabManage'))
|
|
9694
10176
|
: null,
|
|
10177
|
+
settings.taskProgress !== false
|
|
10178
|
+
? h('button', {
|
|
10179
|
+
type: 'button',
|
|
10180
|
+
role: 'tab',
|
|
10181
|
+
'aria-selected': tab === 'requirements' ? 'true' : 'false',
|
|
10182
|
+
className: 'dsh-powerup-tab' + (tab === 'requirements' ? ' on' : ''),
|
|
10183
|
+
onClick: () => setTab('requirements'),
|
|
10184
|
+
}, t('progress.tabRequirements'))
|
|
10185
|
+
: null,
|
|
9695
10186
|
);
|
|
9696
10187
|
|
|
9697
10188
|
const featuresContent = h('div', null,
|
|
@@ -9707,6 +10198,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9707
10198
|
featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
|
|
9708
10199
|
featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
|
|
9709
10200
|
featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow'),
|
|
10201
|
+
featureCard('directAsk', TagIcon, 'page.directAskTitle', 'page.directAskDesc', 'page.directAskHow',
|
|
10202
|
+
h('div', { className: 'dsh-powerup-card-detail' },
|
|
10203
|
+
settingRow('directAsk', settings.directAsk !== false, t('page.directAskToggle'), t('page.directAskToggleHint')),
|
|
10204
|
+
),
|
|
10205
|
+
),
|
|
9710
10206
|
featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
|
|
9711
10207
|
featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
|
|
9712
10208
|
featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
|
|
@@ -9726,7 +10222,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9726
10222
|
? h(MaskRuleEditor, { scope: 'global', t })
|
|
9727
10223
|
: tab === 'prompts' && settings.workspacePrompts !== false
|
|
9728
10224
|
? h(PromptManager, { ctx })
|
|
9729
|
-
:
|
|
10225
|
+
: tab === 'requirements' && settings.taskProgress !== false
|
|
10226
|
+
? h(RequirementManager, { ctx })
|
|
10227
|
+
: featuresContent,
|
|
9730
10228
|
h('footer', { className: 'dsh-powerup-foot' },
|
|
9731
10229
|
h('span', null, format(t('page.footer'), { version: VERSION })),
|
|
9732
10230
|
h('span', { className: 'dsh-powerup-dot' }),
|
|
@@ -9764,13 +10262,228 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9764
10262
|
// Task progress: header button + body-portal panel
|
|
9765
10263
|
// ------------------------------------------------------------------
|
|
9766
10264
|
const PROGRESS_API = '/dsh-powerup/api/progress';
|
|
10265
|
+
const REQUIREMENTS_API = '/dsh-powerup/api/progress-requirements';
|
|
10266
|
+
const HISTORY_API = '/dsh-powerup/api/progress-history';
|
|
10267
|
+
const DIRECT_ASK_API = '/dsh-powerup/api/direct-ask';
|
|
10268
|
+
|
|
10269
|
+
/** Module-level requirements cache: flat records [{id,title,text,workspaceId,enabled}]. */
|
|
10270
|
+
let requirementsCache = [];
|
|
10271
|
+
let requirementsLoaded = false;
|
|
10272
|
+
const requirementsListeners = new Set();
|
|
10273
|
+
function emitRequirements() {
|
|
10274
|
+
for (const fn of [...requirementsListeners]) {
|
|
10275
|
+
try { fn(); } catch { /* one listener must not break the rest */ }
|
|
10276
|
+
}
|
|
10277
|
+
}
|
|
10278
|
+
function normalizeRequirement(item) {
|
|
10279
|
+
if (item === null || typeof item !== 'object') return null;
|
|
10280
|
+
return {
|
|
10281
|
+
id: typeof item.id === 'string' && item.id !== '' ? item.id : newId(),
|
|
10282
|
+
title: typeof item.title === 'string' ? item.title : '',
|
|
10283
|
+
text: typeof item.text === 'string' ? item.text : '',
|
|
10284
|
+
workspaceId: typeof item.workspaceId === 'string' ? item.workspaceId : '',
|
|
10285
|
+
enabled: item.enabled !== false,
|
|
10286
|
+
};
|
|
10287
|
+
}
|
|
10288
|
+
async function loadRequirements() {
|
|
10289
|
+
if (requirementsLoaded) return requirementsCache;
|
|
10290
|
+
requirementsLoaded = true;
|
|
10291
|
+
try {
|
|
10292
|
+
const response = await fetch(REQUIREMENTS_API, { headers: { accept: 'application/json' } });
|
|
10293
|
+
const data = await response.json();
|
|
10294
|
+
if (data?.ok && Array.isArray(data.requirements)) {
|
|
10295
|
+
requirementsCache = data.requirements.map(normalizeRequirement).filter(Boolean);
|
|
10296
|
+
}
|
|
10297
|
+
} catch {
|
|
10298
|
+
/* Host unavailable: keep the last known value. */
|
|
10299
|
+
}
|
|
10300
|
+
emitRequirements();
|
|
10301
|
+
return requirementsCache;
|
|
10302
|
+
}
|
|
10303
|
+
function saveRequirements(next) {
|
|
10304
|
+
requirementsCache = (Array.isArray(next) ? next : []).map(normalizeRequirement).filter(Boolean);
|
|
10305
|
+
emitRequirements();
|
|
10306
|
+
fetch(REQUIREMENTS_API, {
|
|
10307
|
+
method: 'POST',
|
|
10308
|
+
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
10309
|
+
body: JSON.stringify({ requirements: requirementsCache }),
|
|
10310
|
+
}).catch(() => { /* in-memory copy still works this session */ });
|
|
10311
|
+
}
|
|
10312
|
+
function useRequirements() {
|
|
10313
|
+
const [, tick] = useState(0);
|
|
10314
|
+
useEffect(() => {
|
|
10315
|
+
void loadRequirements();
|
|
10316
|
+
const listener = () => tick((n) => n + 1);
|
|
10317
|
+
requirementsListeners.add(listener);
|
|
10318
|
+
return () => requirementsListeners.delete(listener);
|
|
10319
|
+
}, []);
|
|
10320
|
+
return requirementsCache;
|
|
10321
|
+
}
|
|
10322
|
+
/** Requirements visible to one workspace: global (''), plus that workspace. */
|
|
10323
|
+
function requirementsForWorkspace(list, workspaceId) {
|
|
10324
|
+
const id = typeof workspaceId === 'string' ? workspaceId : '';
|
|
10325
|
+
return (Array.isArray(list) ? list : [])
|
|
10326
|
+
.filter((r) => r.workspaceId === '' || r.workspaceId === id);
|
|
10327
|
+
}
|
|
10328
|
+
|
|
10329
|
+
/** Textarea field for one requirements layer. */
|
|
10330
|
+
function RequirementField({ label, hint, value, placeholder, onChange }) {
|
|
10331
|
+
return h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10332
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, label),
|
|
10333
|
+
hint ? h('span', { className: 'dsh-powerup-setting-hint' }, hint) : null,
|
|
10334
|
+
h('textarea', {
|
|
10335
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
|
|
10336
|
+
value: value ?? '',
|
|
10337
|
+
placeholder: placeholder ?? '',
|
|
10338
|
+
onChange: (event) => onChange(event.target.value),
|
|
10339
|
+
}),
|
|
10340
|
+
);
|
|
10341
|
+
}
|
|
10342
|
+
|
|
10343
|
+
/**
|
|
10344
|
+
* Multi-record requirement manager, modelled on PromptManager: records are
|
|
10345
|
+
* scoped to a workspace ('' = global) and can be enabled/disabled, edited
|
|
10346
|
+
* and deleted. Used in the Power-Up page's new "Requirements" tab and as
|
|
10347
|
+
* the workspace-scoped editor in the conversation settings tab.
|
|
10348
|
+
*/
|
|
10349
|
+
function RequirementManager({ ctx, workspaceOnly, workspaceId }) {
|
|
10350
|
+
const reqs = useRequirements();
|
|
10351
|
+
const [, forceLocale] = useState(0);
|
|
10352
|
+
const [draft, setDraft] = useState(null);
|
|
10353
|
+
const [expanded, setExpanded] = useState(null);
|
|
10354
|
+
const t = (key, params) => translateCurrent(key, params);
|
|
10355
|
+
useEffect(() => {
|
|
10356
|
+
const locale = ctx?.get?.('locale');
|
|
10357
|
+
if (locale === undefined || typeof locale.subscribe !== 'function') return undefined;
|
|
10358
|
+
return locale.subscribe(() => forceLocale((v) => v + 1));
|
|
10359
|
+
}, [ctx]);
|
|
10360
|
+
const workspaces = (() => {
|
|
10361
|
+
try {
|
|
10362
|
+
const snapshot = ctx?.get?.('workspaces')?.list?.getSnapshot?.();
|
|
10363
|
+
return Array.isArray(snapshot?.items) ? snapshot.items : [];
|
|
10364
|
+
} catch { return []; }
|
|
10365
|
+
})();
|
|
10366
|
+
const visible = workspaceOnly
|
|
10367
|
+
? reqs.filter((r) => r.workspaceId === (typeof workspaceId === 'string' ? workspaceId : ''))
|
|
10368
|
+
: reqs;
|
|
10369
|
+
|
|
10370
|
+
const sections = workspaceOnly
|
|
10371
|
+
? [{ id: workspaceId ?? '', label: t('progress.reqWorkspace'), items: visible }]
|
|
10372
|
+
: [
|
|
10373
|
+
{ id: '', label: t('prompts.scopeGlobal'), items: reqs.filter((r) => r.workspaceId === '') },
|
|
10374
|
+
...workspaces.map((ws) => ({
|
|
10375
|
+
id: ws.workspaceId,
|
|
10376
|
+
label: ws.title ?? ws.workspaceId,
|
|
10377
|
+
items: reqs.filter((r) => r.workspaceId === ws.workspaceId),
|
|
10378
|
+
})),
|
|
10379
|
+
];
|
|
10380
|
+
|
|
10381
|
+
const cancel = () => { setDraft(null); setExpanded(null); };
|
|
10382
|
+
const save = () => {
|
|
10383
|
+
if (draft === null) return;
|
|
10384
|
+
const text = typeof draft.text === 'string' ? draft.text.trim() : '';
|
|
10385
|
+
if (text === '') return;
|
|
10386
|
+
const record = {
|
|
10387
|
+
id: draft.id || newId(),
|
|
10388
|
+
title: typeof draft.title === 'string' ? draft.title.trim() : '',
|
|
10389
|
+
text,
|
|
10390
|
+
workspaceId: typeof draft.workspaceId === 'string' ? draft.workspaceId : '',
|
|
10391
|
+
enabled: draft.enabled !== false,
|
|
10392
|
+
};
|
|
10393
|
+
const next = reqs.filter((r) => r.id !== record.id);
|
|
10394
|
+
next.push(record);
|
|
10395
|
+
saveRequirements(next);
|
|
10396
|
+
cancel();
|
|
10397
|
+
};
|
|
10398
|
+
const remove = (record) => {
|
|
10399
|
+
if (typeof window !== 'undefined' && typeof window.confirm === 'function'
|
|
10400
|
+
&& !window.confirm(t('prompts.confirmDelete'))) return;
|
|
10401
|
+
saveRequirements(reqs.filter((r) => r.id !== record.id));
|
|
10402
|
+
};
|
|
10403
|
+
const toggleEnabled = (record) => {
|
|
10404
|
+
saveRequirements(reqs.map((r) => (r.id === record.id ? { ...r, enabled: r.enabled === false } : r)));
|
|
10405
|
+
};
|
|
10406
|
+
|
|
10407
|
+
return h('div', { className: 'dsh-powerup-req-manager' },
|
|
10408
|
+
h('p', { className: 'dsh-powerup-card-desc' }, t('progress.reqHint')),
|
|
10409
|
+
...sections.map((section) => h('div', { key: `sec-${section.id}` },
|
|
10410
|
+
h('h3', { className: 'dsh-powerup-section-title' }, section.label),
|
|
10411
|
+
h('ul', { className: 'dsh-powerup-req-list' },
|
|
10412
|
+
section.items.map((r) => h('li', { key: r.id, className: 'dsh-powerup-req-item' + (r.enabled === false ? ' off' : '') },
|
|
10413
|
+
h('button', {
|
|
10414
|
+
type: 'button', role: 'switch', 'aria-checked': r.enabled !== false ? 'true' : 'false',
|
|
10415
|
+
className: 'dsh-powerup-switch', title: t('page.enabled'),
|
|
10416
|
+
onClick: () => toggleEnabled(r),
|
|
10417
|
+
}, r.enabled !== false ? t('page.enabled') : t('page.disabled')),
|
|
10418
|
+
h('div', { className: 'dsh-powerup-req-copy' },
|
|
10419
|
+
h('span', { className: 'dsh-powerup-req-title' }, r.title || (r.text.slice(0, 40) + (r.text.length > 40 ? '…' : ''))),
|
|
10420
|
+
h('span', { className: 'dsh-powerup-req-text' }, r.text),
|
|
10421
|
+
),
|
|
10422
|
+
h('button', {
|
|
10423
|
+
type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => { setDraft({ ...r }); setExpanded(r.id); },
|
|
10424
|
+
}, t('prompts.edit')),
|
|
10425
|
+
h('button', {
|
|
10426
|
+
type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => remove(r),
|
|
10427
|
+
}, t('prompts.delete')),
|
|
10428
|
+
)),
|
|
10429
|
+
),
|
|
10430
|
+
expanded === `new-${section.id}` && draft !== null
|
|
10431
|
+
? h(RequirementForm, { draft, setDraft, workspaces, workspaceOnly, scopeId: section.id, t, save, cancel })
|
|
10432
|
+
: null,
|
|
10433
|
+
h('button', {
|
|
10434
|
+
type: 'button', className: 'dsh-powerup-prompt-new',
|
|
10435
|
+
onClick: () => { setDraft({ id: '', title: '', text: '', workspaceId: section.id, enabled: true }); setExpanded(`new-${section.id}`); },
|
|
10436
|
+
}, t('progress.reqNew')),
|
|
10437
|
+
)),
|
|
10438
|
+
);
|
|
10439
|
+
}
|
|
10440
|
+
|
|
10441
|
+
/** Inline create/edit form for one requirement record. */
|
|
10442
|
+
function RequirementForm({ draft, setDraft, workspaces, workspaceOnly, scopeId, t, save, cancel }) {
|
|
10443
|
+
return h('div', { className: 'dsh-powerup-req-form' },
|
|
10444
|
+
h('input', {
|
|
10445
|
+
className: 'dsh-powerup-prompt-input', type: 'text',
|
|
10446
|
+
value: draft.title ?? '', placeholder: t('prompts.titlePlaceholder'),
|
|
10447
|
+
onChange: (e) => setDraft({ ...draft, title: e.target.value }),
|
|
10448
|
+
}),
|
|
10449
|
+
h('textarea', {
|
|
10450
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
|
|
10451
|
+
value: draft.text ?? '', placeholder: t('progress.reqPlaceholder'),
|
|
10452
|
+
onChange: (e) => setDraft({ ...draft, text: e.target.value }),
|
|
10453
|
+
}),
|
|
10454
|
+
!workspaceOnly ? h(WorkspaceSelect, {
|
|
10455
|
+
value: draft.workspaceId ?? '',
|
|
10456
|
+
options: [{ value: '', label: t('prompts.anyWorkspace') }, ...workspaces.map((ws) => ({ value: ws.workspaceId, label: ws.title ?? ws.workspaceId }))],
|
|
10457
|
+
onChange: (value) => setDraft({ ...draft, workspaceId: value }),
|
|
10458
|
+
t,
|
|
10459
|
+
}) : null,
|
|
10460
|
+
h('div', { className: 'dsh-powerup-req-form-foot' },
|
|
10461
|
+
h('button', { type: 'button', className: 'dsh-powerup-update-ghost', onClick: cancel }, t('prompts.cancel')),
|
|
10462
|
+
h('button', { type: 'button', className: 'dsh-powerup-update-primary', onClick: save }, t('prompts.save')),
|
|
10463
|
+
),
|
|
10464
|
+
);
|
|
10465
|
+
}
|
|
10466
|
+
|
|
10467
|
+
/** Panel picker: choose which visible requirements to apply for this generation. */
|
|
10468
|
+
function RequirementPicker({ reqs, selectedIds, onToggle, t }) {
|
|
10469
|
+
if (reqs.length === 0) return h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.reqEmpty'));
|
|
10470
|
+
return h('div', { className: 'dsh-powerup-req-picker' },
|
|
10471
|
+
reqs.map((r) => h('label', { key: r.id, className: 'dsh-powerup-req-option' },
|
|
10472
|
+
h('input', {
|
|
10473
|
+
type: 'checkbox', checked: selectedIds.includes(r.id),
|
|
10474
|
+
onChange: () => onToggle(r.id),
|
|
10475
|
+
}),
|
|
10476
|
+
h('span', null, r.title || (r.text.slice(0, 50) + (r.text.length > 50 ? '…' : ''))),
|
|
10477
|
+
)),
|
|
10478
|
+
);
|
|
10479
|
+
}
|
|
9767
10480
|
|
|
9768
10481
|
/** POST to the progress route; returns the parsed body. */
|
|
9769
|
-
async function progressRequest(sessionId, action) {
|
|
10482
|
+
async function progressRequest(sessionId, action, extra = {}) {
|
|
9770
10483
|
const response = await fetch(PROGRESS_API, {
|
|
9771
10484
|
method: 'POST',
|
|
9772
10485
|
headers: { 'content-type': 'application/json' },
|
|
9773
|
-
body: JSON.stringify({ sessionId, action }),
|
|
10486
|
+
body: JSON.stringify({ sessionId, action, ...extra }),
|
|
9774
10487
|
});
|
|
9775
10488
|
const body = await response.json();
|
|
9776
10489
|
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
@@ -9902,18 +10615,48 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9902
10615
|
}
|
|
9903
10616
|
|
|
9904
10617
|
/**
|
|
9905
|
-
* Header utility: a
|
|
9906
|
-
*
|
|
9907
|
-
*
|
|
9908
|
-
*
|
|
10618
|
+
* Header utility: a resizable, body-portal progress panel.
|
|
10619
|
+
*
|
|
10620
|
+
* Enhancements over the original:
|
|
10621
|
+
* - wider default panel, user-resizable via a bottom-right drag handle
|
|
10622
|
+
* (size persisted in localStorage);
|
|
10623
|
+
* - header background shifts from blue to warning red as the report ages;
|
|
10624
|
+
* - a per-session history is kept on the Host and can be browsed/cleared;
|
|
10625
|
+
* - the raw AI text is viewable and copyable;
|
|
10626
|
+
* - one-off requirements can be added in the panel for the next refresh.
|
|
9909
10627
|
*/
|
|
9910
10628
|
function ProgressControl({ sessionId }) {
|
|
9911
10629
|
const settings = useSettings();
|
|
9912
10630
|
const [open, setOpen] = useState(false);
|
|
9913
10631
|
const [view, setView] = useState(null);
|
|
9914
10632
|
const [busy, setBusy] = useState(false);
|
|
10633
|
+
const [historyIndex, setHistoryIndex] = useState(0);
|
|
10634
|
+
const [showRaw, setShowRaw] = useState(false);
|
|
10635
|
+
const [showReq, setShowReq] = useState(false);
|
|
10636
|
+
// Ids of requirement records selected for the next generation.
|
|
10637
|
+
const [selectedReqIds, setSelectedReqIds] = useState([]);
|
|
10638
|
+
const reqs = useRequirements();
|
|
10639
|
+
// Resolve the owning workspace for requirement filtering.
|
|
10640
|
+
const workspaceId = useMemo(() => {
|
|
10641
|
+
try {
|
|
10642
|
+
const snapshot = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.();
|
|
10643
|
+
return resolveWorkspaceIdFromSnapshot(snapshot, sessionRef.current) ?? '';
|
|
10644
|
+
} catch { return ''; }
|
|
10645
|
+
}, [sessionId, open]);
|
|
10646
|
+
const visibleReqs = requirementsForWorkspace(reqs, workspaceId);
|
|
10647
|
+
const [size, setSize] = useState(() => {
|
|
10648
|
+
try {
|
|
10649
|
+
const saved = JSON.parse(localStorage.getItem('dsh-powerup:progress:size:v1') || 'null');
|
|
10650
|
+
if (saved !== null && Number.isFinite(saved.w) && Number.isFinite(saved.h)) {
|
|
10651
|
+
return { w: Math.max(320, Math.min(900, saved.w)), h: Math.max(240, Math.min(900, saved.h)) };
|
|
10652
|
+
}
|
|
10653
|
+
} catch { /* fall through */ }
|
|
10654
|
+
return { w: 520, h: 560 };
|
|
10655
|
+
});
|
|
10656
|
+
const [ageTick, setAgeTick] = useState(0);
|
|
9915
10657
|
const panelRef = useRef(null);
|
|
9916
10658
|
const buttonRef = useRef(null);
|
|
10659
|
+
const dragRef = useRef(null);
|
|
9917
10660
|
const sessionRef = useRef(sessionId);
|
|
9918
10661
|
sessionRef.current = sessionId;
|
|
9919
10662
|
const t = useCallback((key, params) => translateCurrent(key, params), []);
|
|
@@ -9938,29 +10681,45 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9938
10681
|
if (disposed) return;
|
|
9939
10682
|
const body = await refresh();
|
|
9940
10683
|
if (disposed) return;
|
|
9941
|
-
if (body?.status === 'running')
|
|
9942
|
-
window.setTimeout(tick, 900);
|
|
9943
|
-
}
|
|
10684
|
+
if (body?.status === 'running') window.setTimeout(tick, 900);
|
|
9944
10685
|
};
|
|
9945
10686
|
void tick();
|
|
9946
10687
|
return () => { disposed = true; };
|
|
9947
10688
|
}, [open, refresh]);
|
|
9948
10689
|
|
|
10690
|
+
// Repaint the time-based header colour once a minute.
|
|
10691
|
+
useEffect(() => {
|
|
10692
|
+
if (!open) return undefined;
|
|
10693
|
+
const timer = window.setInterval(() => setAgeTick((n) => n + 1), 60_000);
|
|
10694
|
+
return () => window.clearInterval(timer);
|
|
10695
|
+
}, [open]);
|
|
10696
|
+
|
|
9949
10697
|
const run = useCallback(async () => {
|
|
9950
10698
|
const id = sessionRef.current;
|
|
9951
10699
|
if (typeof id !== 'string' || id === '') return;
|
|
9952
10700
|
setBusy(true);
|
|
9953
10701
|
try {
|
|
9954
|
-
const body = await progressRequest(id, 'start');
|
|
10702
|
+
const body = await progressRequest(id, 'start', { requirementIds: selectedReqIds });
|
|
9955
10703
|
setView(body);
|
|
10704
|
+
setHistoryIndex(0);
|
|
9956
10705
|
} catch (error) {
|
|
9957
10706
|
setView({ status: 'error', error: error?.message ?? String(error) });
|
|
9958
10707
|
} finally {
|
|
9959
10708
|
setBusy(false);
|
|
9960
|
-
// Kick the polling loop even if it was already mounted.
|
|
9961
10709
|
if (!open) setOpen(true);
|
|
9962
10710
|
}
|
|
9963
|
-
}, [open]);
|
|
10711
|
+
}, [open, selectedReqIds]);
|
|
10712
|
+
|
|
10713
|
+
const clearHistory = useCallback(async () => {
|
|
10714
|
+
const id = sessionRef.current;
|
|
10715
|
+
if (typeof id !== 'string' || id === '') return;
|
|
10716
|
+
if (window.confirm(t('progress.clearHistoryConfirm')) !== true) return;
|
|
10717
|
+
try {
|
|
10718
|
+
const body = await progressRequest(id, 'clear');
|
|
10719
|
+
setView(body);
|
|
10720
|
+
setHistoryIndex(0);
|
|
10721
|
+
} catch { /* keep the current view */ }
|
|
10722
|
+
}, [t]);
|
|
9964
10723
|
|
|
9965
10724
|
const close = useCallback(() => setOpen(false), []);
|
|
9966
10725
|
|
|
@@ -9985,9 +10744,48 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9985
10744
|
};
|
|
9986
10745
|
}, [open, close]);
|
|
9987
10746
|
|
|
10747
|
+
// Bottom-right resize handle: ordinary pointer events on the panel node.
|
|
10748
|
+
useEffect(() => {
|
|
10749
|
+
if (!open) return undefined;
|
|
10750
|
+
const onMove = (event) => {
|
|
10751
|
+
const drag = dragRef.current;
|
|
10752
|
+
if (drag === null) return;
|
|
10753
|
+
const w = Math.max(320, Math.min(900, drag.w + drag.x - event.clientX));
|
|
10754
|
+
const h = Math.max(240, Math.min(900, drag.h + event.clientY - drag.y));
|
|
10755
|
+
setSize({ w, h });
|
|
10756
|
+
};
|
|
10757
|
+
const onUp = () => {
|
|
10758
|
+
if (dragRef.current === null) return;
|
|
10759
|
+
dragRef.current = null;
|
|
10760
|
+
try { localStorage.setItem('dsh-powerup:progress:size:v1', JSON.stringify(size)); } catch { /* ignore */ }
|
|
10761
|
+
};
|
|
10762
|
+
document.addEventListener('pointermove', onMove);
|
|
10763
|
+
document.addEventListener('pointerup', onUp);
|
|
10764
|
+
return () => {
|
|
10765
|
+
document.removeEventListener('pointermove', onMove);
|
|
10766
|
+
document.removeEventListener('pointerup', onUp);
|
|
10767
|
+
};
|
|
10768
|
+
}, [open, size]);
|
|
10769
|
+
|
|
9988
10770
|
if (settings.taskProgress === false) return null;
|
|
9989
10771
|
const running = view?.status === 'running' || busy;
|
|
9990
|
-
const
|
|
10772
|
+
const history = Array.isArray(view?.history) ? view.history : [];
|
|
10773
|
+
// The selected history entry is the displayed report; index 0 = latest.
|
|
10774
|
+
const selected = history.length > 0
|
|
10775
|
+
? history[Math.min(historyIndex, history.length - 1)]
|
|
10776
|
+
: null;
|
|
10777
|
+
const report = selected?.report ?? selected ?? view?.report;
|
|
10778
|
+
|
|
10779
|
+
// Age of the displayed report, used for the blue → red header gradient.
|
|
10780
|
+
// `ageTick` forces this recomputation once a minute while open.
|
|
10781
|
+
void ageTick;
|
|
10782
|
+
const reportAt = selected?.updatedAt ?? view?.updatedAt ?? 0;
|
|
10783
|
+
const ageMinutes = reportAt > 0 ? (Date.now() - reportAt) / 60_000 : 0;
|
|
10784
|
+
// 0 min → blue (210), 60+ min → red (0). Keep a hint of blue until 15 min.
|
|
10785
|
+
const hue = Math.max(0, 210 - Math.min(60, ageMinutes) * 3.5);
|
|
10786
|
+
const headerStyle = reportAt > 0
|
|
10787
|
+
? { background: `linear-gradient(90deg, hsl(${hue} 70% 42% / 0.22), hsl(${hue} 70% 42% / 0.06))` }
|
|
10788
|
+
: undefined;
|
|
9991
10789
|
|
|
9992
10790
|
const button = h('button', {
|
|
9993
10791
|
ref: buttonRef,
|
|
@@ -10006,56 +10804,91 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10006
10804
|
running ? h('span', { className: 'dsh-powerup-progress-btn-dot' }) : null,
|
|
10007
10805
|
);
|
|
10008
10806
|
|
|
10807
|
+
const reportBody = (() => {
|
|
10808
|
+
if (report === null || report === undefined) return null;
|
|
10809
|
+
return h('div', null,
|
|
10810
|
+
h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
|
|
10811
|
+
h('div', { className: 'dsh-powerup-progress-meter' },
|
|
10812
|
+
h('div', { className: 'dsh-powerup-progress-meter-head' },
|
|
10813
|
+
h('span', null, MODE_LABEL[report.mode] ?? report.mode),
|
|
10814
|
+
h('strong', null, `${report.percent}%`),
|
|
10815
|
+
),
|
|
10816
|
+
h('div', { className: 'dsh-powerup-progress-track' },
|
|
10817
|
+
h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${report.percent}%` } }),
|
|
10818
|
+
),
|
|
10819
|
+
),
|
|
10820
|
+
ProgressStructure(report),
|
|
10821
|
+
ProgressDisplay(report),
|
|
10822
|
+
);
|
|
10823
|
+
})();
|
|
10824
|
+
|
|
10009
10825
|
const body = (() => {
|
|
10010
10826
|
if (view === null) return h('div', { className: 'dsh-powerup-progress-empty' }, t('progress.hint'));
|
|
10011
10827
|
if (view.status === 'error') return h('p', { className: 'dsh-powerup-progress-error' }, view.error ?? t('progress.failed'));
|
|
10012
|
-
if (
|
|
10828
|
+
if (running) {
|
|
10013
10829
|
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')),
|
|
10830
|
+
h('div', { className: 'dsh-powerup-progress-loading' }, t('progress.loading')),
|
|
10831
|
+
reportBody,
|
|
10019
10832
|
);
|
|
10020
10833
|
}
|
|
10021
|
-
if (
|
|
10834
|
+
if (showRaw) {
|
|
10835
|
+
const raw = typeof report?.raw === 'string' ? report.raw : '';
|
|
10022
10836
|
return h('div', null,
|
|
10023
|
-
h('
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10837
|
+
h('h4', { className: 'dsh-powerup-progress-section' }, t('progress.rawTitle')),
|
|
10838
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.rawHint')),
|
|
10839
|
+
h('pre', { className: 'dsh-powerup-progress-code' }, raw || '(empty)'),
|
|
10840
|
+
h('button', {
|
|
10841
|
+
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10842
|
+
onClick: () => void copyText(raw),
|
|
10843
|
+
}, t('progress.copyRaw')),
|
|
10028
10844
|
);
|
|
10029
10845
|
}
|
|
10030
10846
|
if (report === null || report === undefined) {
|
|
10031
10847
|
return h('div', null,
|
|
10032
|
-
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.
|
|
10848
|
+
h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
|
|
10033
10849
|
h('button', {
|
|
10034
10850
|
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10035
10851
|
disabled: busy, onClick: () => void run(),
|
|
10036
|
-
}, t('progress.
|
|
10852
|
+
}, t('progress.generate')),
|
|
10037
10853
|
);
|
|
10038
10854
|
}
|
|
10039
10855
|
return h('div', null,
|
|
10040
|
-
|
|
10041
|
-
h('div', { className: 'dsh-powerup-progress-
|
|
10042
|
-
h('
|
|
10043
|
-
|
|
10044
|
-
h('
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10856
|
+
// History switcher — browsing an older report never discards it.
|
|
10857
|
+
history.length > 1 ? h('div', { className: 'dsh-powerup-progress-history' },
|
|
10858
|
+
h('span', { className: 'dsh-powerup-progress-section' }, t('progress.history')),
|
|
10859
|
+
h('div', { className: 'dsh-powerup-progress-history-list' },
|
|
10860
|
+
history.map((entry, index) => h('button', {
|
|
10861
|
+
key: entry.updatedAt ?? index,
|
|
10862
|
+
type: 'button',
|
|
10863
|
+
className: 'dsh-powerup-progress-history-item' + (index === historyIndex ? ' on' : ''),
|
|
10864
|
+
onClick: () => setHistoryIndex(index),
|
|
10865
|
+
}, new Date(entry.updatedAt ?? Date.now()).toLocaleTimeString())),
|
|
10048
10866
|
),
|
|
10049
|
-
),
|
|
10050
|
-
|
|
10051
|
-
|
|
10867
|
+
) : null,
|
|
10868
|
+
ageMinutes > 15 ? h('p', { className: 'dsh-powerup-progress-age' },
|
|
10869
|
+
t('progress.ageWarning', { minutes: Math.round(ageMinutes) }),
|
|
10870
|
+
) : null,
|
|
10871
|
+
reportBody,
|
|
10052
10872
|
);
|
|
10053
10873
|
})();
|
|
10054
10874
|
|
|
10875
|
+
const requirementsEditor = showReq ? h('div', { className: 'dsh-powerup-progress-req-pop' },
|
|
10876
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqSelect')),
|
|
10877
|
+
h('p', { className: 'dsh-powerup-setting-hint' }, t('progress.reqSelectHint')),
|
|
10878
|
+
h(RequirementPicker, {
|
|
10879
|
+
reqs: visibleReqs,
|
|
10880
|
+
selectedIds: selectedReqIds,
|
|
10881
|
+
t,
|
|
10882
|
+
onToggle: (id) => setSelectedReqIds((cur) => cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id]),
|
|
10883
|
+
}),
|
|
10884
|
+
) : null;
|
|
10885
|
+
|
|
10055
10886
|
const panel = !open ? null : h('div', {
|
|
10056
10887
|
ref: panelRef,
|
|
10057
10888
|
className: 'dsh-powerup-progress-panel',
|
|
10058
10889
|
style: {
|
|
10890
|
+
width: `${size.w}px`,
|
|
10891
|
+
maxHeight: `${size.h}px`,
|
|
10059
10892
|
top: (() => {
|
|
10060
10893
|
const rect = buttonRef.current?.getBoundingClientRect?.();
|
|
10061
10894
|
return `${Math.round((rect?.bottom ?? 44) + 6)}px`;
|
|
@@ -10066,7 +10899,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10066
10899
|
})(),
|
|
10067
10900
|
},
|
|
10068
10901
|
},
|
|
10069
|
-
h('div', { className: 'dsh-powerup-progress-head' },
|
|
10902
|
+
h('div', { className: 'dsh-powerup-progress-head', style: headerStyle },
|
|
10070
10903
|
h('div', { className: 'dsh-powerup-progress-heading' },
|
|
10071
10904
|
h('span', { className: 'dsh-powerup-progress-title' }, report?.title ?? t('progress.title')),
|
|
10072
10905
|
h('span', { className: 'dsh-powerup-progress-sub' },
|
|
@@ -10079,16 +10912,37 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10079
10912
|
'aria-label': t('progress.close'), onClick: close,
|
|
10080
10913
|
}, '×'),
|
|
10081
10914
|
),
|
|
10915
|
+
requirementsEditor,
|
|
10082
10916
|
h('div', { className: 'dsh-powerup-progress-body' }, body),
|
|
10083
10917
|
h('div', { className: 'dsh-powerup-progress-foot' },
|
|
10084
10918
|
h('span', { className: 'dsh-powerup-progress-time' },
|
|
10085
10919
|
view?.updatedAt ? format(t('progress.updated'), { time: new Date(view.updatedAt).toLocaleTimeString() }) : '',
|
|
10086
10920
|
),
|
|
10921
|
+
h('button', {
|
|
10922
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10923
|
+
onClick: () => setShowReq((v) => !v),
|
|
10924
|
+
}, t('progress.requirements')),
|
|
10925
|
+
report?.raw ? h('button', {
|
|
10926
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10927
|
+
onClick: () => setShowRaw((v) => !v),
|
|
10928
|
+
}, t('progress.viewRaw')) : null,
|
|
10929
|
+
history.length > 0 ? h('button', {
|
|
10930
|
+
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
10931
|
+
onClick: () => void clearHistory(),
|
|
10932
|
+
}, t('progress.clearHistory')) : null,
|
|
10087
10933
|
h('button', {
|
|
10088
10934
|
type: 'button', className: 'dsh-powerup-progress-refresh',
|
|
10089
10935
|
disabled: busy || running, onClick: () => void run(),
|
|
10090
10936
|
}, t('progress.refresh')),
|
|
10091
10937
|
),
|
|
10938
|
+
h('div', {
|
|
10939
|
+
className: 'dsh-powerup-progress-resizer',
|
|
10940
|
+
title: t('progress.resizeHint'),
|
|
10941
|
+
onPointerDown: (event) => {
|
|
10942
|
+
event.preventDefault();
|
|
10943
|
+
dragRef.current = { x: event.clientX, y: event.clientY, w: size.w, h: size.h };
|
|
10944
|
+
},
|
|
10945
|
+
}),
|
|
10092
10946
|
);
|
|
10093
10947
|
|
|
10094
10948
|
return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
|
|
@@ -10170,6 +11024,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10170
11024
|
t: (key, params) => translateCurrent(key, params),
|
|
10171
11025
|
}), 'dsh-powerup: dual send buttons');
|
|
10172
11026
|
|
|
11027
|
+
register('conversation.input.right', {
|
|
11028
|
+
id: 'powerup-direct-ask',
|
|
11029
|
+
order: 82,
|
|
11030
|
+
}, (props) => h(DirectAskButton, { sessionId: props?.sessionId }), 'dsh-powerup: direct ask');
|
|
11031
|
+
|
|
10173
11032
|
// In an ongoing session, place the prompt picker in the bottom tool row
|
|
10174
11033
|
// just after the host's permission / plan dropdowns; its popover opens
|
|
10175
11034
|
// upward so it is not clipped by the screen bottom.
|
|
@@ -10252,6 +11111,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10252
11111
|
PROMPTS_CSS,
|
|
10253
11112
|
PROGRESS_CSS,
|
|
10254
11113
|
ProgressControl,
|
|
11114
|
+
RequirementManager,
|
|
11115
|
+
RequirementPicker,
|
|
11116
|
+
requirementForWorkspace: requirementsForWorkspace,
|
|
11117
|
+
DirectAskButton,
|
|
10255
11118
|
ProgressStructure,
|
|
10256
11119
|
ProgressDisplay,
|
|
10257
11120
|
progressRequest,
|