@restregular/dsh-powerup 0.11.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/client.js CHANGED
@@ -310,6 +310,19 @@
310
310
  'restart.desc': '重启会关闭并重新打开 DSH,正在运行的任务会中断。',
311
311
  'restart.cancel': '取消',
312
312
  'restart.confirm': '立即重启',
313
+ 'restart.tasksTitle': '有 {count} 个任务尚未完成',
314
+ 'restart.tasksHint': '普通重启不允许中断未完成任务。可以强制停止它们后再重启。',
315
+ 'restart.forceLabel': '强制重启',
316
+ 'restart.forceCloseLabel': '强制关闭',
317
+ 'restart.resumeLabel': '重启后自动继续任务',
318
+ 'restart.resumeLabelClose': '下次打开后自动继续任务',
319
+ 'restart.resumeHint': '停止前记录这些会话,下次打开 DSH 时自动发送「继续」提示词。',
320
+ 'restart.resumePromptLabel': '继续提示词(可选)',
321
+ 'restart.resumePromptPlaceholder': '默认:继续之前未完成的任务。',
322
+ 'restart.taskLine': '会话 {id}',
323
+ 'restart.taskFallback': '未命名会话',
324
+ 'restart.forceConfirm': '强制停止并重启',
325
+ 'force.done': '已停止 {count} 个任务,将自动继续 {resumed} 个会话。',
313
326
  'update.doneTitle': '安装完成',
314
327
  'update.doneInstalled': '{name} 已安装 {version}。',
315
328
  'update.doneDisabled': '{name} 已安装 {version},尚未启用。',
@@ -353,13 +366,56 @@
353
366
  'progress.hint': '还没有进度报告,点「生成进度」开始分析。',
354
367
  'progress.empty': '还没有生成过进度报告。',
355
368
  'progress.generate': '生成进度',
356
- 'progress.refresh': '重新生成',
369
+ 'progress.refresh': '刷新进度',
357
370
  'progress.retry': '重试',
358
371
  'progress.loading': '正在后台分析会话进度…',
359
372
  'progress.close': '关闭',
360
373
  'progress.failed': '生成进度失败',
361
374
  'progress.stale': '报告已过期',
362
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': '再次点击闪电按钮可显示/隐藏弹窗',
363
419
  'page.promptsTitle': '工作区提示词',
364
420
  'page.promptsDesc': '为每个工作区保存可复用的提示词。开启后,新会话行的 Agent 预设右侧会出现一个下拉列表,选择即可把提示词填入输入框(可继续编辑),或点提示词右侧的发送按钮直接发出。',
365
421
  'page.promptsHow': '先启用本功能,再切到「工作区提示词」标签页创建提示词;提示词按工作区隔离,没有标题时显示开头几个字。',
@@ -632,6 +688,19 @@
632
688
  'restart.desc': 'Restarting closes and reopens DSH; running tasks are interrupted.',
633
689
  'restart.cancel': 'Cancel',
634
690
  'restart.confirm': 'Restart now',
691
+ 'restart.tasksTitle': '{count} unfinished task(s)',
692
+ 'restart.tasksHint': 'A normal restart cannot interrupt unfinished tasks. Force-stop them first, then restart.',
693
+ 'restart.forceLabel': 'Force restart',
694
+ 'restart.forceCloseLabel': 'Force close',
695
+ 'restart.resumeLabel': 'Resume tasks after restart',
696
+ 'restart.resumeLabelClose': 'Resume tasks on next launch',
697
+ 'restart.resumeHint': 'Record these sessions before stopping; on next launch DSH sends a "continue" prompt automatically.',
698
+ 'restart.resumePromptLabel': 'Continuation prompt (optional)',
699
+ 'restart.resumePromptPlaceholder': 'Default: Continue the previous unfinished task.',
700
+ 'restart.taskLine': 'Session {id}',
701
+ 'restart.taskFallback': 'Untitled session',
702
+ 'restart.forceConfirm': 'Force-stop and restart',
703
+ 'force.done': 'Stopped {count} task(s); {resumed} session(s) will resume automatically.',
635
704
  'update.doneTitle': 'Install complete',
636
705
  'update.doneInstalled': '{name} installed {version}.',
637
706
  'update.doneDisabled': '{name} {version} is installed but not enabled.',
@@ -675,13 +744,56 @@
675
744
  'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
676
745
  'progress.empty': 'No progress report generated yet.',
677
746
  'progress.generate': 'Generate progress',
678
- 'progress.refresh': 'Regenerate',
747
+ 'progress.refresh': 'Refresh progress',
679
748
  'progress.retry': 'Retry',
680
749
  'progress.loading': 'Analyzing session progress in the background…',
681
750
  'progress.close': 'Close',
682
751
  'progress.failed': 'Could not generate progress',
683
752
  'progress.stale': 'Stale report',
684
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',
685
797
  'page.promptsTitle': 'Workspace prompts',
686
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.',
687
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.',
@@ -780,6 +892,7 @@
780
892
  dualSend: false,
781
893
  workspacePrompts: true,
782
894
  taskProgress: true,
895
+ directAsk: true,
783
896
  oneClickEnable: true,
784
897
  oneClickRestart: true,
785
898
  };
@@ -803,6 +916,7 @@
803
916
  dualSend: parsed.dualSend === true,
804
917
  workspacePrompts: parsed.workspacePrompts !== false,
805
918
  taskProgress: parsed.taskProgress !== false,
919
+ directAsk: parsed.directAsk !== false,
806
920
  oneClickEnable: parsed.oneClickEnable !== false,
807
921
  oneClickRestart: parsed.oneClickRestart !== false,
808
922
  };
@@ -1237,11 +1351,21 @@
1237
1351
  window.alert(t(options.unsupportedKey, { reason: capability?.reason ?? '' }));
1238
1352
  return;
1239
1353
  }
1354
+ const tasks = Array.isArray(capability?.runningTasks) ? capability.runningTasks : [];
1240
1355
  if (window.confirm(t(options.titleKey) + ' ' + t(options.descKey)) !== true) return;
1356
+ // With unfinished tasks, the last-resort path offers the forced
1357
+ // variant through a second confirmation and resumes by default.
1358
+ let force = false;
1359
+ let resume = false;
1360
+ if (tasks.length > 0) {
1361
+ if (window.confirm(t('restart.tasksTitle', { count: tasks.length }) + '\n' + t('restart.tasksHint')) !== true) return;
1362
+ force = true;
1363
+ resume = window.confirm(t(options.action === 'close' ? 'restart.resumeLabelClose' : 'restart.resumeLabel') + '\n' + t('restart.resumeHint')) === true;
1364
+ }
1241
1365
  const response = await fetch(options.api, {
1242
1366
  method: 'POST',
1243
1367
  headers: { 'content-type': 'application/json' },
1244
- body: JSON.stringify({ action: options.action }),
1368
+ body: JSON.stringify({ action: options.action, force, resume }),
1245
1369
  });
1246
1370
  const data = await response.json().catch(() => null);
1247
1371
  if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? 'HTTP ' + response.status);
@@ -4097,6 +4221,18 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
4097
4221
  .dsh-powerup-update-field{display:flex;flex-direction:column;gap:8px;min-width:0}
4098
4222
  .dsh-powerup-update-label{display:block;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;font-weight:500}
4099
4223
  .dsh-powerup-update-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
4224
+ .dsh-powerup-update-tasks{display:flex;flex-direction:column;gap:8px;padding:12px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2)}
4225
+ .dsh-powerup-update-tasks>strong{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
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}
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}
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}
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))}
4231
+ .dsh-powerup-app-check{display:flex;align-items:flex-start;gap:9px;padding:4px 0;cursor:pointer}
4232
+ .dsh-powerup-app-check input{flex:none;margin:2px 0 0;accent-color:var(--dsw-alias-brand-primary)}
4233
+ .dsh-powerup-app-check span{display:flex;flex-direction:column;gap:1px;min-width:0}
4234
+ .dsh-powerup-app-check strong{color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px;font-weight:500}
4235
+ .dsh-powerup-app-check small{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
4100
4236
  .dsh-powerup-update-name{color:var(--dsw-alias-label-tertiary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px;line-height:18px;overflow-wrap:anywhere}
4101
4237
  .dsh-powerup-update-summary{display:flex;flex-direction:column;gap:2px;min-width:0}
4102
4238
  .dsh-powerup-update-list-state{display:flex;flex-direction:column;gap:10px;padding:12px}
@@ -4448,7 +4584,31 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4448
4584
  .dsh-powerup-progress-refresh:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
4449
4585
  .dsh-powerup-progress-refresh:disabled{opacity:.45;cursor:not-allowed}
4450
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}
4451
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}
4452
4612
  `;
4453
4613
 
4454
4614
  /** Max display length of a session option, in Unicode code points. */
@@ -7137,6 +7297,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7137
7297
  const [appCapability, setAppCapability] = useState(null);
7138
7298
  const [appBusy, setAppBusy] = useState(false);
7139
7299
  const [appError, setAppError] = useState(null);
7300
+ /** Running tasks reported by the Host for the app action dialog. */
7301
+ const [appTasks, setAppTasks] = useState([]);
7302
+ /** Checkbox: force-stopped tasks are resumed on next launch. */
7303
+ const [appResume, setAppResume] = useState(true);
7304
+ /** Optional custom continuation prompt. */
7305
+ const [appResumePrompt, setAppResumePrompt] = useState('');
7140
7306
  const tokenRef = useRef(null);
7141
7307
  const abortRef = useRef(null);
7142
7308
  const buttonsRef = useRef(new Set());
@@ -7822,15 +7988,31 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7822
7988
  const readRestartCapability = () => readAppCapability(UPDATE_API);
7823
7989
 
7824
7990
  /** POST one app-control command; throws when the Host refuses. */
7825
- const requestAppAction = async (action) => {
7991
+ const requestAppAction = async (action, options = {}) => {
7826
7992
  const api = action === 'close' ? CLOSE_API : UPDATE_API;
7993
+ // Sending a body opts into the task-aware path. The plugin self-update
7994
+ // flow calls requestAppRestart() with no options and keeps its old
7995
+ // behaviour (no task gate) by not sending a body.
7996
+ const aware = options.aware === true;
7997
+ const body = aware ? JSON.stringify({
7998
+ action,
7999
+ force: options.force === true,
8000
+ resume: options.resume === true,
8001
+ resumePrompt: typeof options.resumePrompt === 'string' ? options.resumePrompt : '',
8002
+ }) : undefined;
7827
8003
  const response = await fetch(api, {
7828
8004
  method: 'POST',
7829
- headers: { 'content-type': 'application/json' },
7830
- body: JSON.stringify({ action }),
8005
+ headers: body === undefined ? undefined : { 'content-type': 'application/json' },
8006
+ ...(body === undefined ? {} : { body }),
7831
8007
  });
7832
8008
  const data = await response.json().catch(() => null);
7833
- if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? `HTTP ${response.status}`);
8009
+ if (!response.ok || data?.ok !== true) {
8010
+ if (data?.code === 'tasks-running' && Array.isArray(data.runningTasks)) {
8011
+ setAppTasks(data.runningTasks);
8012
+ }
8013
+ throw new Error(data?.error ?? `HTTP ${response.status}`);
8014
+ }
8015
+ return data;
7834
8016
  };
7835
8017
 
7836
8018
  /** The restart command, as the install flow spells it. */
@@ -7842,8 +8024,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7842
8024
  setAppCapability(null);
7843
8025
  setAppError(null);
7844
8026
  setAppBusy(false);
7845
- void readAppCapability(action === 'close' ? CLOSE_API : UPDATE_API)
7846
- .then((capability) => setAppCapability(capability));
8027
+ setAppTasks([]);
8028
+ setAppResume(true);
8029
+ setAppResumePrompt('');
8030
+ const api = action === 'close' ? CLOSE_API : UPDATE_API;
8031
+ void fetch(api, { headers: { accept: 'application/json' } })
8032
+ .then((response) => response.json())
8033
+ .then((data) => {
8034
+ setAppCapability({
8035
+ supported: data?.ok === true && data.supported === true,
8036
+ reason: typeof data?.reason === 'string' ? data.reason : '',
8037
+ });
8038
+ if (Array.isArray(data?.runningTasks)) setAppTasks(data.runningTasks);
8039
+ })
8040
+ .catch((error) => setAppCapability({ supported: false, reason: errorText(error) }));
7847
8041
  };
7848
8042
  const openAppActionRef = useRef(() => {});
7849
8043
  openAppActionRef.current = openAppAction;
@@ -7863,12 +8057,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7863
8057
  }, []);
7864
8058
 
7865
8059
  /** Confirm the app-level action (restart or close). */
7866
- const confirmAppAction = async () => {
8060
+ const confirmAppAction = async (forced = false) => {
7867
8061
  if (appBusy) return;
8062
+ if (!forced && appTasks.length > 0) return;
7868
8063
  setAppBusy(true);
7869
8064
  setAppError(null);
7870
8065
  try {
7871
- await requestAppAction(appAsk === 'close' ? 'close' : 'restart');
8066
+ const data = await requestAppAction(appAsk === 'close' ? 'close' : 'restart', {
8067
+ aware: true,
8068
+ force: forced,
8069
+ resume: forced && appResume,
8070
+ resumePrompt: appResumePrompt,
8071
+ });
8072
+ // The app is about to exit; nothing more to render.
8073
+ void data;
7872
8074
  } catch (error) {
7873
8075
  setAppBusy(false);
7874
8076
  setAppError(errorText(error) || tRef.current('update.unknown'));
@@ -7961,6 +8163,43 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7961
8163
  ),
7962
8164
  h('div', { className: 'dsh-powerup-update-body' },
7963
8165
  h('p', { className: 'dsh-powerup-update-note' }, t(appAction === 'close' ? 'close.desc' : 'restart.desc')),
8166
+ appTasks.length > 0
8167
+ ? h('div', { className: 'dsh-powerup-update-tasks' },
8168
+ h('strong', null, t('restart.tasksTitle', { count: appTasks.length })),
8169
+ h('p', { className: 'dsh-powerup-update-note' }, t('restart.tasksHint')),
8170
+ h('ul', { className: 'dsh-powerup-update-task-list' },
8171
+ appTasks.slice(0, 8).map((task, index) => h('li', { key: `${task.kind}-${task.id}-${index}` },
8172
+ h('span', { className: 'dsh-powerup-update-task-dot' }),
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),
8177
+ )),
8178
+ ),
8179
+ h('label', { className: 'dsh-powerup-app-check' },
8180
+ h('input', {
8181
+ type: 'checkbox',
8182
+ checked: appResume,
8183
+ onChange: (event) => setAppResume(event.target.checked === true),
8184
+ disabled: appBusy,
8185
+ }),
8186
+ h('span', null,
8187
+ h('strong', null, t(appAction === 'close' ? 'restart.resumeLabelClose' : 'restart.resumeLabel')),
8188
+ h('small', null, t('restart.resumeHint')),
8189
+ ),
8190
+ ),
8191
+ appResume
8192
+ ? h('input', {
8193
+ className: 'dsh-powerup-prompt-input',
8194
+ type: 'text',
8195
+ value: appResumePrompt,
8196
+ placeholder: t('restart.resumePromptPlaceholder'),
8197
+ disabled: appBusy,
8198
+ onChange: (event) => setAppResumePrompt(event.target.value),
8199
+ })
8200
+ : null,
8201
+ )
8202
+ : null,
7964
8203
  appCapability !== null && appCapability.supported !== true
7965
8204
  ? notice('warn', h(WarnIcon, { size: 14 }), null, t(appAction === 'close' ? 'close.unsupported' : 'update.restartUnsupported', { reason: appCapability.reason ?? '' }))
7966
8205
  : null,
@@ -7974,12 +8213,19 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7974
8213
  ),
7975
8214
  h('div', { className: 'dsh-powerup-update-foot' },
7976
8215
  h('button', { type: 'button', className: 'dsh-powerup-update-ghost', disabled: appBusy, onClick: () => setAppAsk(null) }, t(appAction === 'close' ? 'close.cancel' : 'restart.cancel')),
7977
- h('button', {
7978
- type: 'button',
7979
- className: 'dsh-powerup-update-primary',
7980
- disabled: appBusy || appCapability?.supported !== true,
7981
- onClick: confirmAppAction,
7982
- }, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'close.confirm' : 'restart.confirm')),
8216
+ appTasks.length > 0
8217
+ ? h('button', {
8218
+ type: 'button',
8219
+ className: 'dsh-powerup-update-primary',
8220
+ disabled: appBusy || appCapability?.supported !== true,
8221
+ onClick: () => void confirmAppAction(true),
8222
+ }, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'restart.forceCloseLabel' : 'restart.forceLabel'))
8223
+ : h('button', {
8224
+ type: 'button',
8225
+ className: 'dsh-powerup-update-primary',
8226
+ disabled: appBusy || appCapability?.supported !== true,
8227
+ onClick: () => void confirmAppAction(false),
8228
+ }, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'close.confirm' : 'restart.confirm')),
7983
8229
  ),
7984
8230
  ),
7985
8231
  );
@@ -8864,6 +9110,164 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8864
9110
  return behavior;
8865
9111
  }
8866
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
+
8867
9271
  function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
8868
9272
  const settings = useSettings();
8869
9273
  const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
@@ -9015,6 +9419,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9015
9419
  ),
9016
9420
  ),
9017
9421
  h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
9422
+ h(ProgressScopeRequirements, { t, workspaceId, sessionId: ownerId }),
9018
9423
  ),
9019
9424
  );
9020
9425
  }
@@ -9577,7 +9982,16 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9577
9982
  featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
9578
9983
  featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
9579
9984
  featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
9580
- 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
+ ),
9581
9995
  featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
9582
9996
  featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
9583
9997
  featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
@@ -9635,13 +10049,125 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9635
10049
  // Task progress: header button + body-portal panel
9636
10050
  // ------------------------------------------------------------------
9637
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
+ }
9638
10164
 
9639
10165
  /** POST to the progress route; returns the parsed body. */
9640
- async function progressRequest(sessionId, action) {
10166
+ async function progressRequest(sessionId, action, extra = {}) {
9641
10167
  const response = await fetch(PROGRESS_API, {
9642
10168
  method: 'POST',
9643
10169
  headers: { 'content-type': 'application/json' },
9644
- body: JSON.stringify({ sessionId, action }),
10170
+ body: JSON.stringify({ sessionId, action, ...extra }),
9645
10171
  });
9646
10172
  const body = await response.json();
9647
10173
  if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
@@ -9773,18 +10299,38 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9773
10299
  }
9774
10300
 
9775
10301
  /**
9776
- * Header utility: a button that opens a body-portal panel. The panel polls
9777
- * the Host route while a side call runs, and reuses the last report after
9778
- * it finishes. All work is fire-and-forget on the Host, so the running
9779
- * task is never blocked or interrupted.
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.
9780
10311
  */
9781
10312
  function ProgressControl({ sessionId }) {
9782
10313
  const settings = useSettings();
9783
10314
  const [open, setOpen] = useState(false);
9784
10315
  const [view, setView] = useState(null);
9785
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);
9786
10331
  const panelRef = useRef(null);
9787
10332
  const buttonRef = useRef(null);
10333
+ const dragRef = useRef(null);
9788
10334
  const sessionRef = useRef(sessionId);
9789
10335
  sessionRef.current = sessionId;
9790
10336
  const t = useCallback((key, params) => translateCurrent(key, params), []);
@@ -9809,29 +10355,45 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9809
10355
  if (disposed) return;
9810
10356
  const body = await refresh();
9811
10357
  if (disposed) return;
9812
- if (body?.status === 'running') {
9813
- window.setTimeout(tick, 900);
9814
- }
10358
+ if (body?.status === 'running') window.setTimeout(tick, 900);
9815
10359
  };
9816
10360
  void tick();
9817
10361
  return () => { disposed = true; };
9818
10362
  }, [open, refresh]);
9819
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
+
9820
10371
  const run = useCallback(async () => {
9821
10372
  const id = sessionRef.current;
9822
10373
  if (typeof id !== 'string' || id === '') return;
9823
10374
  setBusy(true);
9824
10375
  try {
9825
- const body = await progressRequest(id, 'start');
10376
+ const body = await progressRequest(id, 'start', { requirements: tempReq });
9826
10377
  setView(body);
10378
+ setHistoryIndex(0);
9827
10379
  } catch (error) {
9828
10380
  setView({ status: 'error', error: error?.message ?? String(error) });
9829
10381
  } finally {
9830
10382
  setBusy(false);
9831
- // Kick the polling loop even if it was already mounted.
9832
10383
  if (!open) setOpen(true);
9833
10384
  }
9834
- }, [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]);
9835
10397
 
9836
10398
  const close = useCallback(() => setOpen(false), []);
9837
10399
 
@@ -9856,9 +10418,48 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9856
10418
  };
9857
10419
  }, [open, close]);
9858
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
+
9859
10444
  if (settings.taskProgress === false) return null;
9860
10445
  const running = view?.status === 'running' || busy;
9861
- const report = view?.report;
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;
9862
10463
 
9863
10464
  const button = h('button', {
9864
10465
  ref: buttonRef,
@@ -9877,56 +10478,90 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9877
10478
  running ? h('span', { className: 'dsh-powerup-progress-btn-dot' }) : null,
9878
10479
  );
9879
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
+
9880
10499
  const body = (() => {
9881
10500
  if (view === null) return h('div', { className: 'dsh-powerup-progress-empty' }, t('progress.hint'));
9882
10501
  if (view.status === 'error') return h('p', { className: 'dsh-powerup-progress-error' }, view.error ?? t('progress.failed'));
9883
- if (view.status === 'idle' || view.status === 'expired') {
10502
+ if (running) {
9884
10503
  return h('div', null,
9885
- h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
9886
- h('button', {
9887
- type: 'button', className: 'dsh-powerup-progress-refresh',
9888
- disabled: busy, onClick: () => void run(),
9889
- }, t('progress.generate')),
10504
+ h('div', { className: 'dsh-powerup-progress-loading' }, t('progress.loading')),
10505
+ reportBody,
9890
10506
  );
9891
10507
  }
9892
- if (view.status === 'running') {
10508
+ if (showRaw) {
10509
+ const raw = typeof report?.raw === 'string' ? report.raw : '';
9893
10510
  return h('div', null,
9894
- h('div', { className: 'dsh-powerup-progress-loading' }, t('progress.loading')),
9895
- report ? h('div', null,
9896
- h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
9897
- ProgressStructure(report),
9898
- ) : null,
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')),
9899
10518
  );
9900
10519
  }
9901
10520
  if (report === null || report === undefined) {
9902
10521
  return h('div', null,
9903
- h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.failed')),
10522
+ h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
9904
10523
  h('button', {
9905
10524
  type: 'button', className: 'dsh-powerup-progress-refresh',
9906
10525
  disabled: busy, onClick: () => void run(),
9907
- }, t('progress.retry')),
10526
+ }, t('progress.generate')),
9908
10527
  );
9909
10528
  }
9910
10529
  return h('div', null,
9911
- h('p', { className: 'dsh-powerup-progress-summary' }, report.summary),
9912
- h('div', { className: 'dsh-powerup-progress-meter' },
9913
- h('div', { className: 'dsh-powerup-progress-meter-head' },
9914
- h('span', null, MODE_LABEL[report.mode] ?? report.mode),
9915
- h('strong', null, `${report.percent}%`),
9916
- ),
9917
- h('div', { className: 'dsh-powerup-progress-track' },
9918
- h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${report.percent}%` } }),
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())),
9919
10540
  ),
9920
- ),
9921
- ProgressStructure(report),
9922
- ProgressDisplay(report),
10541
+ ) : null,
10542
+ ageMinutes > 15 ? h('p', { className: 'dsh-powerup-progress-age' },
10543
+ t('progress.ageWarning', { minutes: Math.round(ageMinutes) }),
10544
+ ) : null,
10545
+ reportBody,
9923
10546
  );
9924
10547
  })();
9925
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
+
9926
10559
  const panel = !open ? null : h('div', {
9927
10560
  ref: panelRef,
9928
10561
  className: 'dsh-powerup-progress-panel',
9929
10562
  style: {
10563
+ width: `${size.w}px`,
10564
+ maxHeight: `${size.h}px`,
9930
10565
  top: (() => {
9931
10566
  const rect = buttonRef.current?.getBoundingClientRect?.();
9932
10567
  return `${Math.round((rect?.bottom ?? 44) + 6)}px`;
@@ -9937,7 +10572,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9937
10572
  })(),
9938
10573
  },
9939
10574
  },
9940
- h('div', { className: 'dsh-powerup-progress-head' },
10575
+ h('div', { className: 'dsh-powerup-progress-head', style: headerStyle },
9941
10576
  h('div', { className: 'dsh-powerup-progress-heading' },
9942
10577
  h('span', { className: 'dsh-powerup-progress-title' }, report?.title ?? t('progress.title')),
9943
10578
  h('span', { className: 'dsh-powerup-progress-sub' },
@@ -9950,16 +10585,37 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9950
10585
  'aria-label': t('progress.close'), onClick: close,
9951
10586
  }, '×'),
9952
10587
  ),
10588
+ requirementsEditor,
9953
10589
  h('div', { className: 'dsh-powerup-progress-body' }, body),
9954
10590
  h('div', { className: 'dsh-powerup-progress-foot' },
9955
10591
  h('span', { className: 'dsh-powerup-progress-time' },
9956
10592
  view?.updatedAt ? format(t('progress.updated'), { time: new Date(view.updatedAt).toLocaleTimeString() }) : '',
9957
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,
9958
10606
  h('button', {
9959
10607
  type: 'button', className: 'dsh-powerup-progress-refresh',
9960
10608
  disabled: busy || running, onClick: () => void run(),
9961
10609
  }, t('progress.refresh')),
9962
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
+ }),
9963
10619
  );
9964
10620
 
9965
10621
  return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
@@ -10041,6 +10697,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10041
10697
  t: (key, params) => translateCurrent(key, params),
10042
10698
  }), 'dsh-powerup: dual send buttons');
10043
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
+
10044
10705
  // In an ongoing session, place the prompt picker in the bottom tool row
10045
10706
  // just after the host's permission / plan dropdowns; its popover opens
10046
10707
  // upward so it is not clipped by the screen bottom.
@@ -10123,6 +10784,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10123
10784
  PROMPTS_CSS,
10124
10785
  PROGRESS_CSS,
10125
10786
  ProgressControl,
10787
+ ProgressRequirementsEditor,
10788
+ ProgressScopeRequirements,
10789
+ DirectAskButton,
10126
10790
  ProgressStructure,
10127
10791
  ProgressDisplay,
10128
10792
  progressRequest,