@restregular/dsh-powerup 0.17.0 → 0.19.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 CHANGED
@@ -454,17 +454,24 @@ only scopes that actually contain requirements are listed. Each record can be
454
454
  enabled/disabled, edited and deleted. When generating progress you **check the
455
455
  requirements you want** — checked ones fill an editable text box that you may
456
456
  freely modify, and generation/refresh uses the full box text verbatim. The panel
457
- also has a **New requirement** entry with a modal pinned to the session's
458
- workspace (like the prompt picker).
459
- The panel uses **tabs** below the header: **Progress**, **Requirements** and
460
- **Raw output** — requirements and the raw AI text are no longer embedded in the
461
- progress body. Stage cards (checklist steps, phases, milestones and tree nodes)
462
- are **collapsible**. The panel is wider by default, resizable from its
463
- bottom-right corner (size persisted), and its header tint shifts from blue
464
- toward warning red as the report ages. Every refresh adds a new report to a
465
- per-session history stored on disk; older reports stay browsable and are never
466
- discarded. The panel can clear the history explicitly. "Refresh progress"
467
- generates a new report without dropping the old ones.
457
+ also has a **New requirement** entry with a modal: pick the workspace (or "all
458
+ workspaces") there, and clicks inside the modal no longer close the progress
459
+ panel.
460
+ The panel uses **tabs** below the header: **Progress**, **Refresh progress**
461
+ (the requirements box) and **Raw output** — requirements and the raw AI text are
462
+ no longer embedded in the progress body. The header also carries the **same
463
+ model selector as the composer**: changing the model here changes the one used
464
+ for the next progress call. Stage cards (checklist steps, phases, milestones
465
+ and tree nodes) are **collapsible** by clicking anywhere on their row. The panel
466
+ is wider by default, resizable from its bottom-right corner (size persisted),
467
+ and its header tint shifts from blue toward warning red as the report ages.
468
+ Every refresh adds a new report to a per-session history stored on disk; older
469
+ reports stay browsable and are never discarded. The panel can clear the history
470
+ explicitly. The **Refresh** button lives in the "Refresh progress" tab beside
471
+ "New requirement"; while a call runs it becomes **Cancel**, and the panel
472
+ returns to the Progress tab when it settles. A configurable **cooldown**
473
+ (default 5 seconds, set on the Power-Up page) prevents accidental repeat
474
+ refreshes.
468
475
 
469
476
  ### Direct ask (no Agent)
470
477
 
@@ -472,9 +479,13 @@ An **icon-only** lightning button in the composer opens a floating DSH-styled
472
479
  chat window. Drag the title bar to move it and the bottom-right corner to
473
480
  resize it (position and size persist). It supports **continuous multi-turn Q&A**.
474
481
  The chat window uses two **tabs** — **Chat** and **History** — instead of
475
- embedding the history over the conversation. Your message appears in the thread
476
- immediately as a pending bubble; the answer replaces the pending state in place
477
- (and failures render there too). Continuous Q&A flattens prior turns into a
482
+ embedding the history over the conversation. History is stored per **conversation**
483
+ (not per message), each with a **title** you can edit inline. A settings toggle
484
+ can ask the model to generate the title from the first message — one tiny,
485
+ token-capped request; otherwise the first question becomes the title. Your
486
+ message appears in the thread immediately as a pending bubble; the answer
487
+ replaces the pending state in place and is **rendered as Markdown** (headings,
488
+ lists, code blocks, inline formatting); failures render there too. Continuous Q&A flattens prior turns into a
478
489
  single user message before each call, so no hand-built assistant message ever
479
490
  reaches the model adapter — this fixes the "LLM_FAILED" error on the second
480
491
  message. "+" starts a new chat. Attach text files with the "+" chip in the
package/client.js CHANGED
@@ -85,7 +85,7 @@
85
85
  const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
86
86
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
87
87
  const UNSCOPED_WORKSPACE = '__unscoped__';
88
- const VERSION = '0.17.0';
88
+ const VERSION = '0.19.0';
89
89
  const MENU_GAP = 8;
90
90
  const MENU_WIDTH = 248;
91
91
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -362,13 +362,19 @@
362
362
  'page.taskProgressTitle': '任务进度速览',
363
363
  'page.taskProgressDesc': '在会话顶部加一个「进度」按钮,点击后用当前会话的模型在后台分析会话记录,生成结构化的任务进度并用浮层展示。调用在旁路进行,不写入会话、不打断正在运行的任务;模型会按任务类型选择清单、阶段、里程碑或任务树,并可补充一段直接渲染给用户看的内容。',
364
364
  'page.taskProgressHow': '在任意会话顶部点击「进度」按钮,面板会显示最近一次结果;首次使用点「生成进度」。生成期间可继续正常操作会话。',
365
+ 'page.taskProgressCooldown': '刷新冷却(秒)',
366
+ 'page.taskProgressCooldownHint': '两次刷新之间的最短间隔,防止误触;设为 0 表示不限制。',
365
367
  'progress.title': '任务进度',
366
368
  'progress.label': '进度',
367
369
  'progress.subtitle': '由当前会话模型在后台生成',
370
+ 'progress.modelChanging': '正在切换模型…',
368
371
  'progress.hint': '还没有进度报告,点「生成进度」开始分析。',
369
372
  'progress.empty': '还没有生成过进度报告。',
370
373
  'progress.generate': '生成进度',
371
- 'progress.refresh': '刷新进度',
374
+ 'progress.refresh': '刷新',
375
+ 'progress.tabRefresh': '刷新进度',
376
+ 'progress.cancel': '取消',
377
+ 'progress.refreshCooldown': '请等待 {seconds} 秒后再刷新',
372
378
  'progress.retry': '重试',
373
379
  'progress.loading': '正在后台分析会话进度…',
374
380
  'progress.close': '关闭',
@@ -393,8 +399,7 @@
393
399
  'progress.reqHint': '每条要求可设置语言、结构、必须包含的数据、额外展示区要回答的问题等;按工作区隔离,留空工作区则对所有工作区生效。生成进度时可勾选本次要应用哪些要求。',
394
400
  'progress.reqNew': '新建要求',
395
401
  'progress.reqSelect': '本次应用的要求',
396
- 'progress.reqSelectHint': '勾选要求后内容会填入下方输入框,可自由修改;生成/刷新时会使用输入框里的完整要求。',
397
- 'progress.reqEditPlaceholder': '在这里编辑本次生成要使用的要求…',
402
+ 'progress.reqEditPlaceholder': '勾选要求后内容会填入这里,可自由修改;生成/刷新时使用此处完整要求…',
398
403
  'progress.reqTextLabel': '要求内容',
399
404
  'progress.sectionTitle': '生成要求',
400
405
  'progress.reqGlobal': '通用要求(设置页)',
@@ -412,6 +417,8 @@
412
417
  'page.directAskHow': '点底部输入区的闪电按钮,输入问题后发送;回答会显示在一个可开关的弹窗里。这个能力不是 Agent,不能调用工具或加载技能。',
413
418
  'page.directAskToggle': '启用轻量问答按钮',
414
419
  'page.directAskToggleHint': '关闭后底部输入区不再显示该按钮。',
420
+ 'page.directAskAutoTitle': '自动生成会话标题',
421
+ 'page.directAskAutoTitleHint': '开启后,新对话会用第一个问题让大模型生成简短标题(仅一条短请求,严格限制 token);关闭则用第一句问题作标题。标题都可随时手动修改。',
415
422
  'directAsk.label': '直接问答',
416
423
  'directAsk.hint': '不启动 Agent,直接问模型(无工具/技能)',
417
424
  'directAsk.title': '轻量问答',
@@ -432,6 +439,8 @@
432
439
  'directAsk.newChat': '新对话',
433
440
  'directAsk.tabChat': '问答',
434
441
  'directAsk.noAnswer': '(无回答)',
442
+ 'directAsk.editTitle': '修改标题',
443
+ 'directAsk.untitled': '未命名对话',
435
444
  'directAsk.history': '历史记录',
436
445
  'directAsk.historyEmpty': '还没有历史对话',
437
446
  'directAsk.clearHistory': '清空历史',
@@ -758,13 +767,19 @@
758
767
  'page.taskProgressTitle': 'Task progress snapshot',
759
768
  'page.taskProgressDesc': 'Adds a Progress button to the session header. Clicking it asks the current session model to analyze the session in the background and produce a structured progress report shown in a floating panel. The call is off to the side: nothing is written to the session and the running task is never interrupted. The model picks a checklist, phases, milestones, or task tree to fit the work, and may add content rendered directly in the panel.',
760
769
  'page.taskProgressHow': 'Click Progress in any session header to see the last report; on first use press Generate. You can keep working in the session while it runs.',
770
+ 'page.taskProgressCooldown': 'Refresh cooldown (seconds)',
771
+ 'page.taskProgressCooldownHint': 'Minimum gap between refreshes to avoid accidental clicks; 0 disables the limit.',
761
772
  'progress.title': 'Task progress',
762
773
  'progress.label': 'Progress',
763
774
  'progress.subtitle': 'Generated in the background by this session model',
775
+ 'progress.modelChanging': 'Switching model…',
764
776
  'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
765
777
  'progress.empty': 'No progress report generated yet.',
766
778
  'progress.generate': 'Generate progress',
767
- 'progress.refresh': 'Refresh progress',
779
+ 'progress.refresh': 'Refresh',
780
+ 'progress.tabRefresh': 'Refresh progress',
781
+ 'progress.cancel': 'Cancel',
782
+ 'progress.refreshCooldown': 'Please wait {seconds} seconds before refreshing again',
768
783
  'progress.retry': 'Retry',
769
784
  'progress.loading': 'Analyzing session progress in the background…',
770
785
  'progress.close': 'Close',
@@ -789,8 +804,7 @@
789
804
  '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.',
790
805
  'progress.reqNew': 'New requirement',
791
806
  'progress.reqSelect': 'Requirements for this run',
792
- 'progress.reqSelectHint': 'Checked requirements fill the box below; edit freely. Generation uses the full text in the box.',
793
- 'progress.reqEditPlaceholder': 'Edit the requirements to use for this generation…',
807
+ 'progress.reqEditPlaceholder': 'Checked requirements fill this box; edit freely. Generation uses the full text here…',
794
808
  'progress.reqTextLabel': 'Requirement text',
795
809
  'progress.sectionTitle': 'Generation requirements',
796
810
  'progress.reqGlobal': 'Global requirements (settings)',
@@ -808,6 +822,8 @@
808
822
  '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.',
809
823
  'page.directAskToggle': 'Enable direct-ask button',
810
824
  'page.directAskToggleHint': 'When off, the composer button is hidden.',
825
+ 'page.directAskAutoTitle': 'Generate conversation titles',
826
+ 'page.directAskAutoTitleHint': 'When on, a new chat asks the model for a short title from the first message (one small, token-capped request). When off, the first question is used. Titles are always editable.',
811
827
  'directAsk.label': 'Direct ask',
812
828
  'directAsk.hint': 'Ask the model without an Agent (no tools or skills)',
813
829
  'directAsk.title': 'Direct ask',
@@ -828,6 +844,8 @@
828
844
  'directAsk.newChat': 'New chat',
829
845
  'directAsk.tabChat': 'Chat',
830
846
  'directAsk.noAnswer': '(no answer)',
847
+ 'directAsk.editTitle': 'Edit title',
848
+ 'directAsk.untitled': 'Untitled chat',
831
849
  'directAsk.history': 'History',
832
850
  'directAsk.historyEmpty': 'No saved conversations yet',
833
851
  'directAsk.clearHistory': 'Clear history',
@@ -930,7 +948,9 @@
930
948
  dualSend: false,
931
949
  workspacePrompts: true,
932
950
  taskProgress: true,
951
+ taskProgressCooldown: 5,
933
952
  directAsk: true,
953
+ directAskAutoTitle: false,
934
954
  oneClickEnable: true,
935
955
  oneClickRestart: true,
936
956
  };
@@ -954,7 +974,12 @@
954
974
  dualSend: parsed.dualSend === true,
955
975
  workspacePrompts: parsed.workspacePrompts !== false,
956
976
  taskProgress: parsed.taskProgress !== false,
977
+ taskProgressCooldown: (() => {
978
+ const value = Number(parsed.taskProgressCooldown);
979
+ return Number.isFinite(value) && value >= 0 ? Math.min(300, Math.max(0, Math.floor(value))) : DEFAULT_SETTINGS.taskProgressCooldown;
980
+ })(),
957
981
  directAsk: parsed.directAsk !== false,
982
+ directAskAutoTitle: parsed.directAskAutoTitle === true,
958
983
  oneClickEnable: parsed.oneClickEnable !== false,
959
984
  oneClickRestart: parsed.oneClickRestart !== false,
960
985
  };
@@ -4172,6 +4197,7 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
4172
4197
  .dsh-powerup-setting-label{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
4173
4198
  .dsh-powerup-setting-hint{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
4174
4199
  .dsh-powerup-setting .dsh-powerup-switch{margin-left:auto}
4200
+ .dsh-powerup-number-input{flex:none;width:64px;height:28px;margin-left:auto;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:6px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;text-align:center}
4175
4201
  .dsh-powerup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:0;padding:0;list-style:none}
4176
4202
  .dsh-powerup-action{display:flex;align-items:flex-start;gap:8px;min-width:0;padding:7px 8px;border-radius:8px}
4177
4203
  .dsh-powerup-action-icon{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;margin-top:1px;color:var(--dsw-alias-label-tertiary)}
@@ -4578,6 +4604,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4578
4604
  .dsh-powerup-progress-heading{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}
4579
4605
  .dsh-powerup-progress-title{font-size:14px;font-weight:600;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
4580
4606
  .dsh-powerup-progress-sub{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:1.4}
4607
+ .dsh-powerup-progress-model-seat{flex:none;display:inline-flex;align-items:center;max-width:150px;overflow:hidden}
4608
+ .dsh-powerup-progress-model-loading{flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:18px;color:var(--dsw-alias-label-tertiary);font-size:13px}
4581
4609
  .dsh-powerup-progress-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-2px -2px 0 0;padding:0;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:17px;line-height:1;cursor:pointer}
4582
4610
  .dsh-powerup-progress-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
4583
4611
  .dsh-powerup-progress-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:12px 16px 16px}
@@ -4594,6 +4622,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4594
4622
  .dsh-powerup-progress-items{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}
4595
4623
  .dsh-powerup-progress-item{display:flex;flex-direction:column;gap:4px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1)}
4596
4624
  .dsh-powerup-progress-item-head{display:flex;align-items:center;gap:7px;min-width:0}
4625
+ .dsh-powerup-progress-item-head.is-clickable{cursor:pointer;border-radius:6px;outline:none}
4626
+ .dsh-powerup-progress-item-head.is-clickable:hover{background:var(--dsw-alias-interactive-bg-hover)}
4627
+ .dsh-powerup-progress-item-head.is-clickable:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}
4597
4628
  .dsh-powerup-progress-item-toggle{flex:none;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:0;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;transition:transform .12s ease}
4598
4629
  .dsh-powerup-progress-item-toggle svg{transform:rotate(-90deg);transition:transform .12s ease}
4599
4630
  .dsh-powerup-progress-item:not(.is-collapsed) .dsh-powerup-progress-item-toggle svg{transform:none}
@@ -4605,6 +4636,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4605
4636
  .dsh-powerup-progress-tab.on{color:var(--dsw-alias-brand-primary);font-weight:600}
4606
4637
  .dsh-powerup-progress-tab.on:after{content:"";position:absolute;left:8px;right:8px;bottom:-1px;height:2px;border-radius:2px;background:var(--dsw-alias-brand-primary)}
4607
4638
  .dsh-powerup-progress-req-tab{display:flex;flex-direction:column;gap:6px}
4639
+ .dsh-powerup-progress-req-actions{display:flex;justify-content:flex-end;align-items:center;gap:8px;margin-top:8px}
4640
+ .dsh-powerup-progress-req-actions .dsh-powerup-req-create{margin-top:0}
4608
4641
  .dsh-powerup-progress-badge{flex:none;display:inline-flex;align-items:center;justify-content:center;min-width:16px;height:16px;padding:0 5px;border-radius:8px;font-size:9.5px;font-weight:700;letter-spacing:.02em}
4609
4642
  .dsh-powerup-progress-badge[data-status=pending]{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary)}
4610
4643
  .dsh-powerup-progress-badge[data-status=in-progress]{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 14%,transparent);color:var(--dsw-alias-state-business-primary)}
@@ -4667,7 +4700,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4667
4700
  .dsh-powerup-directask-btn:hover,.dsh-powerup-directask-btn.on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
4668
4701
  .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}
4669
4702
  .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}
4670
- .dsh-powerup-directask-title{font-size:13px;font-weight:600;white-space:nowrap}
4703
+ .dsh-powerup-directask-title{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px}
4704
+ .dsh-powerup-directask-title-input{flex:1 1 auto;min-width:0;height:24px;padding:0 8px;border:.5px solid var(--dsw-alias-brand-primary);border-radius:6px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:0}
4705
+ .dsh-powerup-directask-history-list button{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11.5px;text-align:left;cursor:pointer}
4706
+ .dsh-powerup-directask-history-title{color:var(--dsw-alias-label-primary);font-size:12px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
4707
+ .dsh-powerup-directask-history-meta{color:var(--dsw-alias-label-tertiary);font-size:10px}
4671
4708
  .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}
4672
4709
  .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}
4673
4710
  .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)}
@@ -4679,7 +4716,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4679
4716
  .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)}
4680
4717
  .dsh-powerup-directask-history-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;font-size:11.5px}
4681
4718
  .dsh-powerup-directask-history-list{margin:0;padding:0;list-style:none}
4682
- .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}
4683
4719
  .dsh-powerup-directask-history-list button:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
4684
4720
  .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)}
4685
4721
  .dsh-powerup-directask-welcome{margin:auto;color:var(--dsw-alias-label-tertiary);font-size:12px;text-align:center}
@@ -4692,6 +4728,16 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4692
4728
  .dsh-powerup-directask-msg.assistant .dsh-powerup-directask-msg-body{border-bottom-left-radius:3px}
4693
4729
  .dsh-powerup-directask-msg.assistant.is-pending .dsh-powerup-directask-msg-body{color:var(--dsw-alias-label-tertiary);font-style:italic}
4694
4730
  .dsh-powerup-directask-msg.assistant.is-error .dsh-powerup-directask-msg-body{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,transparent);color:var(--dsw-alias-state-error-primary)}
4731
+ .dsh-powerup-md-p{margin:0 0 8px}
4732
+ .dsh-powerup-md-p:last-child{margin-bottom:0}
4733
+ .dsh-powerup-md-heading{margin:10px 0 6px;font-size:13px;line-height:1.5}
4734
+ .dsh-powerup-md-heading:first-child{margin-top:0}
4735
+ .dsh-powerup-md-ul,.dsh-powerup-md-ol{margin:6px 0;padding-left:22px}
4736
+ .dsh-powerup-md-ul li,.dsh-powerup-md-ol li{margin:2px 0}
4737
+ .dsh-powerup-md-code{margin:6px 0;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px;line-height:1.6;overflow-x:auto;white-space:pre-wrap;overflow-wrap:anywhere}
4738
+ .dsh-powerup-md-inline-code{padding:1px 5px;border-radius:4px;background:var(--dsw-alias-bg-layer-3);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px}
4739
+ .dsh-powerup-md-quote{margin:6px 0;padding:4px 10px;border-left:2px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary)}
4740
+ .dsh-powerup-md-hr{margin:8px 0;border:0;border-top:.5px solid var(--dsw-alias-border-l2)}
4695
4741
  .dsh-powerup-directask-ctx{display:flex;flex-wrap:wrap;gap:4px;align-self:flex-end}
4696
4742
  .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}
4697
4743
  .dsh-powerup-directask-files{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 6px}
@@ -9210,6 +9256,139 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9210
9256
  return behavior;
9211
9257
  }
9212
9258
 
9259
+ /**
9260
+ * Minimal, self-contained Markdown renderer for short model answers.
9261
+ * The host exposes no markdown service, so this handles the common subset:
9262
+ * fenced code, headings, lists, blockquotes, rules, inline code/bold/italic
9263
+ * and plain paragraphs (line breaks preserved). Returns React nodes.
9264
+ */
9265
+ function renderInlineMarkdown(text, keyPrefix) {
9266
+ if (typeof text !== 'string' || text === '') return null;
9267
+ // Split out inline code first so its contents are never formatted.
9268
+ const segments = [];
9269
+ const codeRe = /`([^`]+)`/gu;
9270
+ let last = 0;
9271
+ let match;
9272
+ let i = 0;
9273
+ while ((match = codeRe.exec(text)) !== null) {
9274
+ if (match.index > last) segments.push({ kind: 'text', value: text.slice(last, match.index) });
9275
+ segments.push({ kind: 'code', value: match[1] });
9276
+ last = match.index + match[0].length;
9277
+ }
9278
+ if (last < text.length) segments.push({ kind: 'text', value: text.slice(last) });
9279
+ const nodes = [];
9280
+ for (const seg of segments) {
9281
+ if (seg.kind === 'code') {
9282
+ nodes.push(h('code', { key: `${keyPrefix}-c${i++}`, className: 'dsh-powerup-md-inline-code' }, seg.value));
9283
+ continue;
9284
+ }
9285
+ // Bold/italic within a plain segment.
9286
+ const parts = [];
9287
+ const re = /(\*\*[^*]+\*\*|\*[^*]+\*|__[^_]+__|_[^_]+_)/gu;
9288
+ let cursor = 0;
9289
+ let m;
9290
+ while ((m = re.exec(seg.value)) !== null) {
9291
+ if (m.index > cursor) parts.push(seg.value.slice(cursor, m.index));
9292
+ const token = m[0];
9293
+ const strong = (token.startsWith('**') && token.endsWith('**')) || (token.startsWith('__') && token.endsWith('__'));
9294
+ const inner = strong ? token.slice(2, -2) : token.slice(1, -1);
9295
+ parts.push(strong
9296
+ ? h('strong', { key: `${keyPrefix}-b${i++}` }, inner)
9297
+ : h('em', { key: `${keyPrefix}-i${i++}` }, inner));
9298
+ cursor = m.index + token.length;
9299
+ }
9300
+ if (cursor < seg.value.length) parts.push(seg.value.slice(cursor));
9301
+ nodes.push(...parts);
9302
+ }
9303
+ return nodes.length === 1 && typeof nodes[0] === 'string' ? nodes[0] : nodes;
9304
+ }
9305
+
9306
+ function renderMarkdown(text) {
9307
+ if (typeof text !== 'string' || text.trim() === '') return null;
9308
+ const lines = text.replace(/\r\n?/gu, '\n').split('\n');
9309
+ const out = [];
9310
+ let i = 0;
9311
+ let key = 0;
9312
+ const k = () => `md-${key++}`;
9313
+ while (i < lines.length) {
9314
+ const line = lines[i];
9315
+ // Fenced code block.
9316
+ if (/^\s*```/u.test(line)) {
9317
+ const lang = line.trim().slice(3).trim();
9318
+ const code = [];
9319
+ i += 1;
9320
+ while (i < lines.length && !/^\s*```/u.test(lines[i])) {
9321
+ code.push(lines[i]);
9322
+ i += 1;
9323
+ }
9324
+ if (i < lines.length) i += 1; // closing fence
9325
+ out.push(h('pre', { key: k(), className: 'dsh-powerup-md-code' + (lang ? ` lang-${lang}` : '') },
9326
+ h('code', null, code.join('\n'))));
9327
+ continue;
9328
+ }
9329
+ // Horizontal rule.
9330
+ if (/^\s*(---+|\*\*\*+|___+)\s*$/u.test(line)) {
9331
+ out.push(h('hr', { key: k(), className: 'dsh-powerup-md-hr' }));
9332
+ i += 1;
9333
+ continue;
9334
+ }
9335
+ // Heading.
9336
+ const heading = /^\s*(#{1,6})\s+(.*)$/u.exec(line);
9337
+ if (heading !== null) {
9338
+ const level = Math.min(6, heading[1].length);
9339
+ const Tag = `h${level + 2}`;
9340
+ out.push(h(Tag, { key: k(), className: 'dsh-powerup-md-heading' }, renderInlineMarkdown(heading[2], k())));
9341
+ i += 1;
9342
+ continue;
9343
+ }
9344
+ // Blockquote (consecutive > lines).
9345
+ if (/^\s*>\s?/u.test(line)) {
9346
+ const quote = [];
9347
+ while (i < lines.length && /^\s*>\s?/u.test(lines[i])) {
9348
+ quote.push(lines[i].replace(/^\s*>\s?/u, ''));
9349
+ i += 1;
9350
+ }
9351
+ out.push(h('blockquote', { key: k(), className: 'dsh-powerup-md-quote' }, quote.map((q, j) => h('div', { key: j }, renderInlineMarkdown(q, k())))));
9352
+ continue;
9353
+ }
9354
+ // Unordered / ordered list.
9355
+ const ul = /^\s*[-*+]\s+(.*)$/u.exec(line);
9356
+ const ol = /^\s*\d+[.)]\s+(.*)$/u.exec(line);
9357
+ if (ul !== null || ol !== null) {
9358
+ const ordered = ol !== null;
9359
+ const items = [];
9360
+ const itemRe = ordered ? /^\s*\d+[.)]\s+(.*)$/u : /^\s*[-*+]\s+(.*)$/u;
9361
+ while (i < lines.length) {
9362
+ const m = itemRe.exec(lines[i]);
9363
+ if (m === null) break;
9364
+ items.push(h('li', { key: k() }, renderInlineMarkdown(m[1], k())));
9365
+ i += 1;
9366
+ }
9367
+ out.push(h(ordered ? 'ol' : 'ul', {
9368
+ key: k(), className: ordered ? 'dsh-powerup-md-ol' : 'dsh-powerup-md-ul',
9369
+ }, items));
9370
+ continue;
9371
+ }
9372
+ // Blank line: skip.
9373
+ if (line.trim() === '') { i += 1; continue; }
9374
+ // Paragraph: gather consecutive plain lines until a block starter.
9375
+ const para = [];
9376
+ while (i < lines.length && lines[i].trim() !== ''
9377
+ && !/^\s*```/u.test(lines[i]) && !/^\s*>/u.test(lines[i])
9378
+ && !/^\s*(#{1,6})\s/u.test(lines[i])
9379
+ && !/^\s*[-*+]\s/u.test(lines[i]) && !/^\s*\d+[.)]\s/u.test(lines[i])
9380
+ && !/^\s*(---+|\*\*\*+|___+)\s*$/u.test(lines[i])) {
9381
+ para.push(lines[i]);
9382
+ i += 1;
9383
+ }
9384
+ if (para.length > 0) {
9385
+ out.push(h('p', { key: k(), className: 'dsh-powerup-md-p' },
9386
+ para.map((p, j) => h(React.Fragment, { key: j }, renderInlineMarkdown(p, k()), j < para.length - 1 ? h('br') : null))));
9387
+ }
9388
+ }
9389
+ return out.length === 1 ? out[0] : h('div', { className: 'dsh-powerup-md' }, out);
9390
+ }
9391
+
9213
9392
  /**
9214
9393
  * Lightning-bolt button in the composer (icon only). Opens a floating,
9215
9394
  * draggable + resizable DSH-styled Q&A window that talks straight to the
@@ -9224,13 +9403,28 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9224
9403
  const [busy, setBusy] = useState(false);
9225
9404
  const [error, setError] = useState('');
9226
9405
  const [copied, setCopied] = useState(false);
9227
- /** Current conversation: [{question, answer, context, at}]. */
9228
- const [turns, setTurns] = useState([]);
9229
- /** Archived conversations, newest first: [{id, at, turns}]. */
9406
+ /** Current conversation: {id, title, turns, at}. */
9407
+ const [conversation, setConversation] = useState(() => ({
9408
+ id: `c-${Date.now()}`,
9409
+ title: '',
9410
+ turns: [],
9411
+ at: Date.now(),
9412
+ }));
9413
+ /** Archived conversations, newest first: [{id, title, at, turns}]. */
9230
9414
  const [history, setHistory] = useState(() => {
9231
- try { return JSON.parse(localStorage.getItem('dsh-powerup:directask:history:v1') || '[]'); }
9232
- catch { return []; }
9415
+ try {
9416
+ const parsed = JSON.parse(localStorage.getItem('dsh-powerup:directask:history:v1') || '[]');
9417
+ return (Array.isArray(parsed) ? parsed : []).map((h) => ({
9418
+ id: h.id ?? `c-${Math.random().toString(36).slice(2)}`,
9419
+ title: typeof h.title === 'string' ? h.title : String(h.turns?.[0]?.question ?? '').slice(0, 40),
9420
+ at: h.at ?? Date.now(),
9421
+ turns: Array.isArray(h.turns) ? h.turns : [],
9422
+ }));
9423
+ } catch { return []; }
9233
9424
  });
9425
+ const [editingTitle, setEditingTitle] = useState(false);
9426
+ const [titleDraft, setTitleDraft] = useState('');
9427
+ const turns = conversation.turns;
9234
9428
  const [activeTab, setActiveTab] = useState('chat');
9235
9429
  const [pos, setPos] = useState(() => {
9236
9430
  try {
@@ -9259,6 +9453,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9259
9453
  setHistory(next);
9260
9454
  try { localStorage.setItem('dsh-powerup:directask:history:v1', JSON.stringify(next.slice(0, 30))); } catch { /* ignore */ }
9261
9455
  }, []);
9456
+ /** Update the current conversation's turns immutably. */
9457
+ const updateTurns = useCallback((fn) => {
9458
+ setConversation((cur) => ({ ...cur, turns: typeof fn === 'function' ? fn(cur.turns) : fn }));
9459
+ }, []);
9262
9460
 
9263
9461
  useEffect(() => {
9264
9462
  if (!open) return undefined;
@@ -9327,8 +9525,24 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9327
9525
  setQuestion('');
9328
9526
  setFiles([]);
9329
9527
  setCopied(false);
9330
- setTurns((cur) => [...cur, pending]);
9528
+ updateTurns((cur) => [...cur, pending]);
9331
9529
  setActiveTab('chat');
9530
+ // Title: first message wins if empty. Auto-generate via LLM only when
9531
+ // the user opted in — one tiny, token-capped request.
9532
+ if (!conversation.title) {
9533
+ const fallback = q.slice(0, 40);
9534
+ setConversation((cur) => ({ ...cur, title: fallback }));
9535
+ if (settings.directAskAutoTitle) {
9536
+ void fetch(ASK_TITLE_API, {
9537
+ method: 'POST', headers: { 'content-type': 'application/json' },
9538
+ body: JSON.stringify({ firstMessage: q }),
9539
+ }).then((r) => r.json()).then((body) => {
9540
+ if (body?.ok && typeof body.title === 'string' && body.title.trim() !== '') {
9541
+ setConversation((cur) => ({ ...cur, title: body.title.trim().slice(0, 60) }));
9542
+ }
9543
+ }).catch(() => { /* keep the fallback title */ });
9544
+ }
9545
+ }
9332
9546
  try {
9333
9547
  const response = await fetch(DIRECT_ASK_API, {
9334
9548
  method: 'POST',
@@ -9342,32 +9556,60 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9342
9556
  });
9343
9557
  const body = await response.json();
9344
9558
  if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
9345
- setTurns((cur) => cur.map((t) => (t.id === pendingId
9559
+ updateTurns((cur) => cur.map((t) => (t.id === pendingId
9346
9560
  ? { ...t, answer: typeof body.answer === 'string' ? body.answer : '', pending: false }
9347
9561
  : t)));
9348
9562
  } catch (err) {
9349
9563
  // Render the failure in the thread like a normal assistant reply.
9350
- setTurns((cur) => cur.map((t) => (t.id === pendingId
9564
+ updateTurns((cur) => cur.map((t) => (t.id === pendingId
9351
9565
  ? { ...t, answer: String(err?.message ?? err), pending: false, error: true }
9352
9566
  : t)));
9353
9567
  } finally {
9354
9568
  setBusy(false);
9355
9569
  }
9356
- }, [question, files, turns, t]);
9570
+ }, [question, files, turns, t, conversation.title, settings.directAskAutoTitle, updateTurns]);
9571
+
9572
+ const archiveCurrent = useCallback(() => {
9573
+ if (conversation.turns.length === 0) return history;
9574
+ const record = {
9575
+ id: conversation.id,
9576
+ title: conversation.title || String(conversation.turns[0]?.question ?? '').slice(0, 40),
9577
+ at: conversation.at,
9578
+ turns: conversation.turns,
9579
+ };
9580
+ return [record, ...history.filter((h) => h.id !== record.id)];
9581
+ }, [conversation, history]);
9357
9582
 
9358
9583
  const newChat = useCallback(() => {
9359
- if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history]);
9360
- setTurns([]);
9584
+ persistHistory(archiveCurrent());
9585
+ setConversation({ id: `c-${Date.now()}`, title: '', turns: [], at: Date.now() });
9586
+ setEditingTitle(false);
9361
9587
  setError('');
9362
9588
  setActiveTab('chat');
9363
- }, [turns, history, persistHistory]);
9589
+ }, [archiveCurrent, persistHistory]);
9364
9590
 
9365
9591
  const openArchived = useCallback((entry) => {
9366
- if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history.filter((h) => h.id !== entry.id)]);
9367
- else persistHistory(history.filter((h) => h.id !== entry.id));
9368
- setTurns(Array.isArray(entry.turns) ? entry.turns : []);
9592
+ persistHistory(archiveCurrent().filter((h) => h.id !== entry.id));
9593
+ setConversation({
9594
+ id: entry.id,
9595
+ title: entry.title || String(entry.turns?.[0]?.question ?? '').slice(0, 40),
9596
+ turns: Array.isArray(entry.turns) ? entry.turns : [],
9597
+ at: entry.at ?? Date.now(),
9598
+ });
9599
+ setEditingTitle(false);
9369
9600
  setActiveTab('chat');
9370
- }, [turns, history, persistHistory]);
9601
+ }, [archiveCurrent, persistHistory]);
9602
+
9603
+ const saveTitle = useCallback(() => {
9604
+ const next = titleDraft.trim().slice(0, 60);
9605
+ if (next !== '') {
9606
+ setConversation((cur) => ({ ...cur, title: next }));
9607
+ // Also update the archived copy if this conversation is in history.
9608
+ setHistory((cur) => cur.map((h) => (h.id === conversation.id ? { ...h, title: next } : h)));
9609
+ try { localStorage.setItem('dsh-powerup:directask:history:v1', JSON.stringify(history.map((h) => (h.id === conversation.id ? { ...h, title: next } : h)).slice(0, 30))); } catch { /* ignore */ }
9610
+ }
9611
+ setEditingTitle(false);
9612
+ }, [titleDraft, conversation.id, history]);
9371
9613
 
9372
9614
  const clearHistory = useCallback(() => {
9373
9615
  if (typeof window !== 'undefined' && typeof window.confirm === 'function'
@@ -9417,7 +9659,27 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9417
9659
  dragRef.current = { kind: 'move', x: event.clientX, y: event.clientY, px: pos.x, py: pos.y };
9418
9660
  },
9419
9661
  },
9420
- h('span', { className: 'dsh-powerup-directask-title' }, t('directAsk.title')),
9662
+ editingTitle
9663
+ ? h('input', {
9664
+ className: 'dsh-powerup-directask-title-input',
9665
+ value: titleDraft,
9666
+ autoFocus: true,
9667
+ maxLength: 60,
9668
+ onChange: (event) => setTitleDraft(event.target.value),
9669
+ onKeyDown: (event) => {
9670
+ if (event.key === 'Enter') { event.preventDefault(); saveTitle(); }
9671
+ else if (event.key === 'Escape') { event.preventDefault(); setEditingTitle(false); }
9672
+ },
9673
+ onBlur: saveTitle,
9674
+ onPointerDown: (event) => event.stopPropagation(),
9675
+ })
9676
+ : h('span', { className: 'dsh-powerup-directask-title', title: conversation.title || t('directAsk.title') },
9677
+ conversation.title || t('directAsk.title')),
9678
+ h('button', {
9679
+ type: 'button', className: 'dsh-powerup-directask-titlebtn',
9680
+ title: t('directAsk.editTitle'),
9681
+ onClick: () => { setTitleDraft(conversation.title || ''); setEditingTitle(true); },
9682
+ }, '✎'),
9421
9683
  h('span', { className: 'dsh-powerup-directask-subtitle' }, t('directAsk.subtitle')),
9422
9684
  h('button', {
9423
9685
  type: 'button', className: 'dsh-powerup-directask-titlebtn',
@@ -9451,8 +9713,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9451
9713
  : h('ul', { className: 'dsh-powerup-directask-history-list' },
9452
9714
  history.map((entry) => h('li', { key: entry.id },
9453
9715
  h('button', { type: 'button', onClick: () => openArchived(entry) },
9454
- new Date(entry.at ?? Date.now()).toLocaleString(),
9455
- ' · ', String(entry.turns?.[0]?.question ?? '').slice(0, 40),
9716
+ h('span', { className: 'dsh-powerup-directask-history-title' }, entry.title || t('directAsk.untitled')),
9717
+ h('span', { className: 'dsh-powerup-directask-history-meta' },
9718
+ new Date(entry.at ?? Date.now()).toLocaleString(),
9719
+ ),
9456
9720
  ),
9457
9721
  )),
9458
9722
  ),
@@ -9472,7 +9736,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9472
9736
  + (turn.pending ? ' is-pending' : '') + (turn.error ? ' is-error' : ''),
9473
9737
  },
9474
9738
  h('div', { className: 'dsh-powerup-directask-msg-body' },
9475
- turn.pending ? t('directAsk.sending') : (turn.answer || t('directAsk.noAnswer')),
9739
+ turn.pending ? t('directAsk.sending')
9740
+ : (turn.answer ? renderMarkdown(turn.answer) : t('directAsk.noAnswer')),
9476
9741
  ),
9477
9742
  !turn.pending && turn.answer ? h('button', {
9478
9743
  type: 'button', className: 'dsh-powerup-progress-mini',
@@ -9486,7 +9751,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9486
9751
  h('div', { ref: bottomRef }),
9487
9752
  ),
9488
9753
  error ? h('p', { className: 'dsh-powerup-progress-error' }, error) : null,
9489
- h('div', { className: 'dsh-powerup-directask-composer' },
9754
+ activeTab === 'chat' ? h('div', { className: 'dsh-powerup-directask-composer' },
9490
9755
  files.length > 0 ? h('div', { className: 'dsh-powerup-directask-files' },
9491
9756
  files.map((f, i) => h('span', { key: i, className: 'dsh-powerup-directask-file' },
9492
9757
  f.name,
@@ -9522,7 +9787,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9522
9787
  }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
9523
9788
  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' }))),
9524
9789
  ),
9525
- ),
9790
+ ) : null,
9526
9791
  h('div', {
9527
9792
  className: 'dsh-powerup-directask-resizer',
9528
9793
  onPointerDown: (event) => {
@@ -10191,6 +10456,26 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10191
10456
  toggle(key, label),
10192
10457
  );
10193
10458
 
10459
+ /** A numeric sub-row inside a card (clamped, persisted on change). */
10460
+ const numberRow = (key, value, label, hint, min = 0, max = 300) => h('div', { key, className: 'dsh-powerup-setting' },
10461
+ h('div', { className: 'dsh-powerup-setting-copy' },
10462
+ h('span', { className: 'dsh-powerup-setting-label' }, label),
10463
+ h('span', { className: 'dsh-powerup-setting-hint' }, hint),
10464
+ ),
10465
+ h('input', {
10466
+ type: 'number',
10467
+ className: 'dsh-powerup-number-input',
10468
+ min, max, step: 1,
10469
+ value: value,
10470
+ 'aria-label': label,
10471
+ onChange: (event) => {
10472
+ const parsed = Number(event.target.value);
10473
+ const next = Number.isFinite(parsed) ? Math.min(max, Math.max(min, Math.floor(parsed))) : min;
10474
+ setSettings({ [key]: next });
10475
+ },
10476
+ }),
10477
+ );
10478
+
10194
10479
  const actionsDetail = h('div', { className: 'dsh-powerup-card-detail' },
10195
10480
  h('h3', { className: 'dsh-powerup-section-title' }, t('page.actions')),
10196
10481
  h('ul', { className: 'dsh-powerup-actions' },
@@ -10258,10 +10543,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10258
10543
  featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
10259
10544
  featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
10260
10545
  featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
10261
- featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow'),
10546
+ featureCard('taskProgress', ProgressIcon, 'page.taskProgressTitle', 'page.taskProgressDesc', 'page.taskProgressHow',
10547
+ h('div', { className: 'dsh-powerup-card-detail' },
10548
+ numberRow('taskProgressCooldown', settings.taskProgressCooldown, t('page.taskProgressCooldown'), t('page.taskProgressCooldownHint')),
10549
+ ),
10550
+ ),
10262
10551
  featureCard('directAsk', TagIcon, 'page.directAskTitle', 'page.directAskDesc', 'page.directAskHow',
10263
10552
  h('div', { className: 'dsh-powerup-card-detail' },
10264
10553
  settingRow('directAsk', settings.directAsk !== false, t('page.directAskToggle'), t('page.directAskToggleHint')),
10554
+ settingRow('directAskAutoTitle', settings.directAskAutoTitle === true, t('page.directAskAutoTitle'), t('page.directAskAutoTitleHint')),
10265
10555
  ),
10266
10556
  ),
10267
10557
  featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
@@ -10326,6 +10616,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10326
10616
  const REQUIREMENTS_API = '/dsh-powerup/api/progress-requirements';
10327
10617
  const HISTORY_API = '/dsh-powerup/api/progress-history';
10328
10618
  const DIRECT_ASK_API = '/dsh-powerup/api/direct-ask';
10619
+ const ASK_TITLE_API = '/dsh-powerup/api/ask-title';
10329
10620
 
10330
10621
  /** Module-level requirements cache: flat records [{id,title,text,workspaceId,enabled}]. */
10331
10622
  let requirementsCache = [];
@@ -10543,17 +10834,21 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10543
10834
  const t = (key, params) => translateCurrent(key, params);
10544
10835
  const fixedScope = typeof workspaceId !== 'string' || workspaceId === '';
10545
10836
  const key = fixedScope ? '' : workspaceId;
10546
- if (requirementCreateDraft.workspaceId !== key) {
10547
- requirementCreateDraft.workspaceId = key;
10548
- requirementCreateDraft.title = '';
10549
- requirementCreateDraft.text = '';
10550
- requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
10551
- }
10837
+ // Reset the draft to this session's workspace whenever the modal opens.
10838
+ requirementCreateDraft.workspaceId = key;
10839
+ requirementCreateDraft.title = '';
10840
+ requirementCreateDraft.text = '';
10552
10841
  const [title, setTitle] = useState(requirementCreateDraft.title);
10553
10842
  const [text, setText] = useState(requirementCreateDraft.text);
10554
- const [scope, setScope] = useState(requirementCreateDraft.scope);
10843
+ const [targetWorkspace, setTargetWorkspace] = useState(requirementCreateDraft.workspaceId ?? key);
10555
10844
  const [closing, setClosing] = useState(false);
10556
10845
  const closingRef = useRef(false);
10846
+ const workspaces = (() => {
10847
+ try {
10848
+ const snapshot = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.();
10849
+ return Array.isArray(snapshot?.items) ? snapshot.items : [];
10850
+ } catch { return []; }
10851
+ })();
10557
10852
  const requestClose = () => {
10558
10853
  if (closingRef.current) return;
10559
10854
  closingRef.current = true;
@@ -10563,8 +10858,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10563
10858
  useEffect(() => {
10564
10859
  requirementCreateDraft.title = title;
10565
10860
  requirementCreateDraft.text = text;
10566
- requirementCreateDraft.scope = scope;
10567
- }, [title, text, scope]);
10861
+ requirementCreateDraft.workspaceId = targetWorkspace;
10862
+ }, [title, text, targetWorkspace]);
10568
10863
  useEffect(() => {
10569
10864
  const onKey = (event) => { if (event.key === 'Escape') { event.preventDefault(); requestClose(); } };
10570
10865
  document.addEventListener('keydown', onKey, true);
@@ -10577,18 +10872,19 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10577
10872
  id: newId(),
10578
10873
  title: typeof title === 'string' ? title.trim() : '',
10579
10874
  text: body,
10580
- workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
10875
+ workspaceId: typeof targetWorkspace === 'string' ? targetWorkspace : '',
10581
10876
  enabled: true,
10582
10877
  };
10583
10878
  saveRequirements([...requirementsCache, record]);
10584
10879
  requirementCreateDraft.title = '';
10585
10880
  requirementCreateDraft.text = '';
10586
- requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
10881
+ requirementCreateDraft.workspaceId = key;
10587
10882
  if (!closingRef.current) { closingRef.current = true; setClosing(true); }
10588
10883
  setTimeout(() => { try { onCreated(record); } catch { /* ignore */ } }, 140);
10589
10884
  };
10590
10885
  return renderInBody(h('div', {
10591
10886
  className: 'dsh-powerup-prompt-modal-mask' + (closing ? ' is-closing' : ''),
10887
+ 'data-powerup-req-modal': '',
10592
10888
  onPointerDown: (event) => { if (event.target === event.currentTarget) requestClose(); },
10593
10889
  },
10594
10890
  h('div', { className: 'dsh-powerup-prompt-modal' + (closing ? ' is-closing' : ''), role: 'dialog', 'aria-modal': 'true' },
@@ -10604,20 +10900,18 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10604
10900
  h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.titleLabel')),
10605
10901
  h('input', { className: 'dsh-powerup-prompt-input', type: 'text', value: title, placeholder: t('prompts.titlePlaceholder'), onChange: (e) => setTitle(e.target.value) }),
10606
10902
  ),
10607
- !fixedScope
10608
- ? h('label', { className: 'dsh-powerup-prompt-field' },
10609
- h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
10610
- h(WorkspaceSelect, {
10611
- value: scope,
10612
- options: [
10613
- { value: 'current', label: t('prompts.workspaceCurrent'), hint: workspaceTitle },
10614
- { value: 'all', label: t('prompts.anyWorkspace') },
10615
- ],
10616
- onChange: setScope,
10617
- t,
10618
- }),
10619
- )
10620
- : null,
10903
+ h('label', { className: 'dsh-powerup-prompt-field' },
10904
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
10905
+ h(WorkspaceSelect, {
10906
+ value: targetWorkspace,
10907
+ options: [
10908
+ { value: '', label: t('prompts.anyWorkspace') },
10909
+ ...workspaces.map((ws) => ({ value: ws.workspaceId, label: ws.title || ws.workspaceId, hint: ws.title ? ws.workspaceId : undefined })),
10910
+ ],
10911
+ onChange: setTargetWorkspace,
10912
+ t,
10913
+ }),
10914
+ ),
10621
10915
  h('label', { className: 'dsh-powerup-prompt-field' },
10622
10916
  h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
10623
10917
  h('textarea', { className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea', value: text, placeholder: t('progress.reqPlaceholder'), onChange: (e) => setText(e.target.value) }),
@@ -10685,17 +10979,25 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10685
10979
  function ProgressItem({ title, status, detail, children, nodeKey, t: translate }) {
10686
10980
  const [collapsed, setCollapsed] = useState(false);
10687
10981
  const hasBody = Boolean(detail) || (Array.isArray(children) && children.length > 0);
10982
+ const toggle = () => { if (hasBody) setCollapsed((v) => !v); };
10688
10983
  return h('li', { key: nodeKey, className: 'dsh-powerup-progress-item' + (collapsed ? ' is-collapsed' : '') },
10689
- h('div', { className: 'dsh-powerup-progress-item-head' },
10984
+ h('div', {
10985
+ className: 'dsh-powerup-progress-item-head' + (hasBody ? ' is-clickable' : ''),
10986
+ ...(hasBody ? {
10987
+ role: 'button',
10988
+ tabIndex: 0,
10989
+ 'aria-expanded': collapsed ? 'false' : 'true',
10990
+ 'aria-label': collapsed ? (translate?.('progress.expand') ?? 'Expand') : (translate?.('progress.collapse') ?? 'Collapse'),
10991
+ onClick: toggle,
10992
+ onKeyDown: (event) => {
10993
+ if (event?.key === 'Enter' || event?.key === ' ') { event.preventDefault?.(); toggle(); }
10994
+ },
10995
+ } : {}),
10996
+ },
10690
10997
  hasBody
10691
- ? h('button', {
10692
- type: 'button',
10693
- className: 'dsh-powerup-progress-item-toggle',
10694
- 'aria-expanded': collapsed ? 'false' : 'true',
10695
- 'aria-label': collapsed ? (translate?.('progress.expand') ?? 'Expand') : (translate?.('progress.collapse') ?? 'Collapse'),
10696
- onClick: () => setCollapsed((v) => !v),
10697
- }, h('svg', { width: 10, height: 10, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
10698
- h('path', { d: 'm4 6 4 4 4-4', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' })))
10998
+ ? h('span', { className: 'dsh-powerup-progress-item-toggle', 'aria-hidden': 'true' },
10999
+ h('svg', { width: 10, height: 10, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
11000
+ h('path', { d: 'm4 6 4 4 4-4', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' })))
10699
11001
  : h('span', { className: 'dsh-powerup-progress-item-toggle-spacer' }),
10700
11002
  ProgressBadge(status),
10701
11003
  h('span', { className: 'dsh-powerup-progress-item-title' }, title),
@@ -10816,6 +11118,75 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10816
11118
  * - the raw AI text is viewable and copyable;
10817
11119
  * - one-off requirements can be added in the panel for the next refresh.
10818
11120
  */
11121
+ /**
11122
+ * Find the host's composer model-seat entry. `conversation.input.model`
11123
+ * is a `single` session slot whose occupant is the built-in ModelSelect
11124
+ * component; the entry carries both the component and the injected face
11125
+ * (directory / load / select / resolveText) that the composer uses.
11126
+ * Reading it (never registering a competitor) lets the progress header
11127
+ * render the very same dropdown, and both seats stay in lockstep because
11128
+ * they share the per-session ModelDirectory.
11129
+ */
11130
+ function findModelSelectEntry(slots) {
11131
+ try {
11132
+ if (slots === undefined || typeof slots.entriesOfSlot !== 'function') return null;
11133
+ const entries = slots.entriesOfSlot('conversation.input.model');
11134
+ if (!Array.isArray(entries)) return null;
11135
+ for (const entry of entries) {
11136
+ if (entry !== null && typeof entry === 'object'
11137
+ && typeof entry.component === 'function' && typeof entry.inject === 'function') return entry;
11138
+ }
11139
+ } catch { /* older host without this slot */ }
11140
+ return null;
11141
+ }
11142
+
11143
+ /** Render the host's exact composer model dropdown inside the progress header. */
11144
+ function ProgressModelSelect({ sessionId, ctx, t: translate }) {
11145
+ const slots = ctx?.get?.('slots');
11146
+ const [entry, setEntry] = useState(() => findModelSelectEntry(slots));
11147
+ useEffect(() => {
11148
+ if (entry !== null || slots === undefined) return undefined;
11149
+ const update = () => {
11150
+ const found = findModelSelectEntry(slots);
11151
+ if (found !== null) setEntry(() => found);
11152
+ };
11153
+ update();
11154
+ const off = typeof ctx?.on === 'function'
11155
+ ? ctx.on('slots/changed', (key) => { if (key === 'conversation.input.model') update(); })
11156
+ : null;
11157
+ const timer = window.setInterval(update, 800);
11158
+ return () => { if (typeof off === 'function') off(); window.clearInterval(timer); };
11159
+ }, [entry, slots, ctx]);
11160
+
11161
+ // The injected face is cached per [entry, session] so the directory
11162
+ // store identity stays stable across re-renders (ModelSelect subscribes
11163
+ // to it with useSyncExternalStore).
11164
+ const face = useMemo(() => {
11165
+ if (entry === null || typeof sessionId !== 'string' || sessionId === '') return null;
11166
+ try { return entry.inject(sessionId, {}) ?? null; } catch { return null; }
11167
+ }, [entry, sessionId]);
11168
+ const seatT = useMemo(() => {
11169
+ try {
11170
+ const bound = ctx?.locale?.bind?.('model');
11171
+ return typeof bound === 'function' ? (key, params) => bound(key, params) : null;
11172
+ } catch { return null; }
11173
+ }, [ctx]);
11174
+ // ModelSelect renders two child slots (label + options) with fallbacks;
11175
+ // the label fallback is everything we need here, and options are empty
11176
+ // because no other plugin contributes extra model actions.
11177
+ const seatRenderSlot = useCallback((key, owner, opts) => opts?.fallback ?? null, []);
11178
+
11179
+ if (entry === null || face === null || seatT === null) {
11180
+ return h('span', {
11181
+ className: 'dsh-powerup-progress-model-loading',
11182
+ title: translate?.('progress.modelChanging') ?? '',
11183
+ }, '…');
11184
+ }
11185
+ return h('span', { className: 'dsh-powerup-progress-model-seat' },
11186
+ h(entry.component, { ...face, t: seatT, renderSlot: seatRenderSlot, locked: false }),
11187
+ );
11188
+ }
11189
+
10819
11190
  function ProgressControl({ sessionId }) {
10820
11191
  const settings = useSettings();
10821
11192
  const [open, setOpen] = useState(false);
@@ -10823,6 +11194,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10823
11194
  const [busy, setBusy] = useState(false);
10824
11195
  const [historyIndex, setHistoryIndex] = useState(0);
10825
11196
  const [activeTab, setActiveTab] = useState('progress');
11197
+ // Cooldown state: last refresh timestamp + a ticking clock for the label.
11198
+ const lastRefreshRef = useRef(0);
11199
+ const [cooldownLeft, setCooldownLeft] = useState(0);
10826
11200
  // Selected requirement ids + the free-editable combined text.
10827
11201
  const [selectedReqIds, setSelectedReqIds] = useState([]);
10828
11202
  const [reqText, setReqText] = useState('');
@@ -10887,6 +11261,28 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10887
11261
  }
10888
11262
  }, []);
10889
11263
 
11264
+ // Cooldown clock: decrement the remaining seconds once a second while open.
11265
+ useEffect(() => {
11266
+ if (!open || cooldownLeft <= 0) return undefined;
11267
+ const timer = window.setTimeout(() => setCooldownLeft((n) => Math.max(0, n - 1)), 1000);
11268
+ return () => window.clearTimeout(timer);
11269
+ }, [open, cooldownLeft]);
11270
+
11271
+ /** Cancel the in-flight side call, then refresh the settled view. */
11272
+ const cancel = useCallback(async () => {
11273
+ const id = sessionRef.current;
11274
+ if (typeof id !== 'string' || id === '') return;
11275
+ setBusy(true);
11276
+ try {
11277
+ const body = await progressRequest(id, 'cancel');
11278
+ setView(body);
11279
+ setHistoryIndex(0);
11280
+ } catch { /* keep the current view */ } finally {
11281
+ setBusy(false);
11282
+ setActiveTab('progress');
11283
+ }
11284
+ }, []);
11285
+
10890
11286
  // While the panel is open, keep polling until the side call settles.
10891
11287
  useEffect(() => {
10892
11288
  if (!open) return undefined;
@@ -10911,6 +11307,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10911
11307
  const run = useCallback(async () => {
10912
11308
  const id = sessionRef.current;
10913
11309
  if (typeof id !== 'string' || id === '') return;
11310
+ // Cooldown guard: refuse a refresh started too soon after the last one.
11311
+ const cooldown = Math.max(0, Math.floor(Number(settings.taskProgressCooldown) || 0));
11312
+ const elapsed = Date.now() - lastRefreshRef.current;
11313
+ if (lastRefreshRef.current > 0 && elapsed < cooldown * 1000) {
11314
+ setCooldownLeft(Math.ceil((cooldown * 1000 - elapsed) / 1000));
11315
+ return;
11316
+ }
11317
+ lastRefreshRef.current = Date.now();
11318
+ if (cooldown > 0) setCooldownLeft(cooldown);
10914
11319
  setBusy(true);
10915
11320
  try {
10916
11321
  // Send the full, possibly user-edited text verbatim.
@@ -10921,9 +11326,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10921
11326
  setView({ status: 'error', error: error?.message ?? String(error) });
10922
11327
  } finally {
10923
11328
  setBusy(false);
11329
+ // Once the refresh settles, show the result on the progress tab.
11330
+ setActiveTab('progress');
10924
11331
  if (!open) setOpen(true);
10925
11332
  }
10926
- }, [open, reqText]);
11333
+ }, [open, reqText, settings.taskProgressCooldown]);
10927
11334
 
10928
11335
  const clearHistory = useCallback(async () => {
10929
11336
  const id = sessionRef.current;
@@ -10938,7 +11345,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10938
11345
 
10939
11346
  const close = useCallback(() => setOpen(false), []);
10940
11347
 
10941
- // Esc and outside click close the panel.
11348
+ // Esc and outside click close the panel. The create-requirement modal is
11349
+ // a body portal, so treat its nodes as "inside" while it is open —
11350
+ // otherwise every click in the modal closes the progress panel.
10942
11351
  useEffect(() => {
10943
11352
  if (!open) return undefined;
10944
11353
  const onKey = (event) => {
@@ -10949,6 +11358,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10949
11358
  const button = buttonRef.current;
10950
11359
  if (panel !== null && event.target instanceof Node && panel.contains(event.target)) return;
10951
11360
  if (button !== null && event.target instanceof Node && button.contains(event.target)) return;
11361
+ if (creatingReq && event.target instanceof Element && event.target.closest('[data-powerup-req-modal]')) return;
10952
11362
  close();
10953
11363
  };
10954
11364
  document.addEventListener('keydown', onKey, true);
@@ -10957,7 +11367,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10957
11367
  document.removeEventListener('keydown', onKey, true);
10958
11368
  document.removeEventListener('pointerdown', onPointer, true);
10959
11369
  };
10960
- }, [open, close]);
11370
+ }, [open, close, creatingReq]);
10961
11371
 
10962
11372
  // Bottom-right resize handle: ordinary pointer events on the panel node.
10963
11373
  useEffect(() => {
@@ -11038,9 +11448,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11038
11448
  })();
11039
11449
 
11040
11450
  // Three tabs below the header: progress / requirements / raw output.
11451
+ // The requirements tab is labelled "刷新进度": it holds the generation
11452
+ // requirements and the refresh action that consumes them. The refresh
11453
+ // button lives here only (not in the footer), beside "新建要求".
11041
11454
  const tabs = [
11042
11455
  { id: 'progress', label: t('progress.tabProgress') },
11043
- { id: 'requirements', label: t('progress.requirements') },
11456
+ { id: 'requirements', label: t('progress.tabRefresh') },
11044
11457
  { id: 'raw', label: t('progress.viewRaw') },
11045
11458
  ];
11046
11459
  const tabBar = h('div', { className: 'dsh-powerup-progress-tabs', role: 'tablist' },
@@ -11092,8 +11505,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11092
11505
  );
11093
11506
  })();
11094
11507
 
11508
+ const cooldownActive = cooldownLeft > 0 && !running;
11509
+ const refreshLabel = cooldownActive
11510
+ ? t('progress.refreshCooldown', { seconds: cooldownLeft })
11511
+ : t('progress.refresh');
11095
11512
  const requirementsBody = h('div', { className: 'dsh-powerup-progress-req-tab' },
11096
- h('p', { className: 'dsh-powerup-setting-hint' }, t('progress.reqSelectHint')),
11097
11513
  h(RequirementPicker, {
11098
11514
  reqs: visibleReqs,
11099
11515
  selectedIds: selectedReqIds,
@@ -11102,10 +11518,22 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11102
11518
  onToggle: toggleReq,
11103
11519
  onTextChange: setReqText,
11104
11520
  }),
11105
- h('button', {
11106
- type: 'button', className: 'dsh-powerup-prompt-new dsh-powerup-req-create',
11107
- onClick: () => setCreatingReq(true),
11108
- }, t('progress.reqNew')),
11521
+ h('div', { className: 'dsh-powerup-progress-req-actions' },
11522
+ running
11523
+ ? h('button', {
11524
+ type: 'button', className: 'dsh-powerup-progress-refresh',
11525
+ onClick: () => void cancel(),
11526
+ }, t('progress.cancel'))
11527
+ : h('button', {
11528
+ type: 'button', className: 'dsh-powerup-progress-refresh',
11529
+ disabled: busy || cooldownActive, title: cooldownActive ? refreshLabel : undefined,
11530
+ onClick: () => void run(),
11531
+ }, refreshLabel),
11532
+ h('button', {
11533
+ type: 'button', className: 'dsh-powerup-prompt-new dsh-powerup-req-create',
11534
+ onClick: () => setCreatingReq(true),
11535
+ }, t('progress.reqNew')),
11536
+ ),
11109
11537
  );
11110
11538
 
11111
11539
  const rawBody = h('div', null,
@@ -11149,6 +11577,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11149
11577
  t('progress.subtitle'),
11150
11578
  ),
11151
11579
  ),
11580
+ h(ProgressModelSelect, { sessionId, ctx: ctxRef.current, t }),
11152
11581
  h('button', {
11153
11582
  type: 'button', className: 'dsh-powerup-progress-close',
11154
11583
  'aria-label': t('progress.close'), onClick: close,
@@ -11164,10 +11593,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11164
11593
  type: 'button', className: 'dsh-powerup-progress-mini',
11165
11594
  onClick: () => void clearHistory(),
11166
11595
  }, t('progress.clearHistory')) : null,
11167
- h('button', {
11168
- type: 'button', className: 'dsh-powerup-progress-refresh',
11169
- disabled: busy || running, onClick: () => void run(),
11170
- }, t('progress.refresh')),
11171
11596
  ),
11172
11597
  h('div', {
11173
11598
  className: 'dsh-powerup-progress-resizer',
@@ -11358,6 +11783,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11358
11783
  PROGRESS_CSS,
11359
11784
  ProgressControl,
11360
11785
  ProgressItem,
11786
+ ProgressModelSelect,
11787
+ findModelSelectEntry,
11361
11788
  ProgressStructure,
11362
11789
  ProgressDisplay,
11363
11790
  RequirementManager,
@@ -11366,6 +11793,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11366
11793
  RequirementPicker,
11367
11794
  requirementForWorkspace: requirementsForWorkspace,
11368
11795
  DirectAskButton,
11796
+ renderMarkdown,
11797
+ renderInlineMarkdown,
11369
11798
  progressRequest,
11370
11799
  PROMPTS_LAST_KEY,
11371
11800
  promptCreateDraft,
package/index.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  } from './lib/task-resume.js';
51
51
  import { createStepReadTool } from './lib/step-tool.js';
52
52
  import { createProgressManager } from './lib/progress-manager.js';
53
- import { buildAskPrompt, cleanAskText, directAsk } from './lib/direct-ask.js';
53
+ import { buildAskPrompt, cleanAskText, directAsk, generateTitle } from './lib/direct-ask.js';
54
54
 
55
55
  /** Prefix owned by this plugin. */
56
56
  const ROUTE = '/dsh-powerup/api';
@@ -473,7 +473,7 @@ async function handle(req, res, ctx) {
473
473
 
474
474
  const url = new URL(req.url ?? ROUTE, 'http://localhost');
475
475
  const op = url.pathname.slice(ROUTE.length).replace(/^\/+/u, '') || url.searchParams.get('op') || '';
476
- if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts' && op !== 'mask-rules' && op !== 'progress' && op !== 'progress-requirements' && op !== 'progress-history' && op !== 'direct-ask') {
476
+ if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts' && op !== 'mask-rules' && op !== 'progress' && op !== 'progress-requirements' && op !== 'progress-history' && op !== 'direct-ask' && op !== 'ask-title') {
477
477
  sendJson(res, { ok: false, error: 'not-found' }, 404);
478
478
  return;
479
479
  }
@@ -603,6 +603,46 @@ async function handle(req, res, ctx) {
603
603
  return;
604
604
  }
605
605
 
606
+ if (op === 'ask-title') {
607
+ if (req.method !== 'POST') {
608
+ sendJson(res, { ok: false, error: 'method-not-allowed' }, 405);
609
+ return;
610
+ }
611
+ let body;
612
+ try {
613
+ body = await readJsonBody(req);
614
+ } catch (error) {
615
+ sendJson(res, { ok: false, error: String(error?.message ?? error) }, 400);
616
+ return;
617
+ }
618
+ const firstMessage = cleanAskText(body?.firstMessage);
619
+ if (firstMessage === '') {
620
+ sendJson(res, { ok: false, code: 'invalid-request', error: 'firstMessage is required' }, 400);
621
+ return;
622
+ }
623
+ const llm = ctx?.get?.('llm');
624
+ if (llm === null || typeof llm?.prepareCall !== 'function') {
625
+ sendJson(res, { ok: false, code: 'llm-unavailable', error: 'the llm service is unavailable' }, 503);
626
+ return;
627
+ }
628
+ const defaults = ctx?.get?.('agentDefaultModel');
629
+ const selection = typeof defaults?.currentSelection === 'function' ? defaults.currentSelection() : undefined;
630
+ const route = selection !== null && typeof selection === 'object' && typeof selection.provider === 'string'
631
+ ? selection : undefined;
632
+ const controller = new AbortController();
633
+ const timer = setTimeout(() => controller.abort(), 20_000);
634
+ timer.unref?.();
635
+ try {
636
+ const result = await generateTitle({ llm, route, firstMessage, signal: controller.signal });
637
+ sendJson(res, { ok: true, title: result.title });
638
+ } catch (error) {
639
+ sendJson(res, { ok: false, code: error?.code ?? 'title-failed', error: String(error?.message ?? error) }, 500);
640
+ } finally {
641
+ clearTimeout(timer);
642
+ }
643
+ return;
644
+ }
645
+
606
646
  if (op === 'progress') {
607
647
  if (req.method !== 'POST') {
608
648
  sendJson(res, { ok: false, error: 'method-not-allowed' }, 405);
package/lib/direct-ask.js CHANGED
@@ -24,6 +24,55 @@ export const DIRECT_ASK_INPUT_LIMIT = 24_000;
24
24
  /** Default output cap for a one-shot answer. */
25
25
  export const DIRECT_ASK_MAX_TOKENS = 2048;
26
26
 
27
+ /** Max characters of the first question used to generate a title. */
28
+ export const TITLE_INPUT_LIMIT = 800;
29
+ /** Hard cap for title generation tokens. */
30
+ export const TITLE_MAX_TOKENS = 64;
31
+ /** Max characters kept for a generated/edited title. */
32
+ export const TITLE_LIMIT = 60;
33
+
34
+ /**
35
+ * Generate a short conversation title from its first message, with a strict
36
+ * token cap. Returns a plain string (never throws to the caller UI).
37
+ */
38
+ export async function generateTitle({ llm, route, firstMessage, signal }) {
39
+ if (llm === null || typeof llm !== 'object' || typeof llm.prepareCall !== 'function') {
40
+ throw new DirectAskError('LLM_UNAVAILABLE', 'the llm service is unavailable');
41
+ }
42
+ if (route === null || typeof route !== 'object' || typeof route.provider !== 'string' || typeof route.model !== 'string') {
43
+ throw new DirectAskError('NO_ROUTE', 'no provider/model route is available');
44
+ }
45
+ const text = cleanAskText(firstMessage, TITLE_INPUT_LIMIT);
46
+ if (text === '') throw new DirectAskError('EMPTY', 'the first message is empty');
47
+ const config = {
48
+ provider: route.provider,
49
+ model: route.model,
50
+ maxTokens: TITLE_MAX_TOKENS,
51
+ };
52
+ const call = await llm.prepareCall(config, signal);
53
+ const options = {
54
+ ...call.config,
55
+ messages: [{ role: 'user', content: [{ type: 'text', text: `给下面这条用户消息起一个简短标题(不超过 ${TITLE_LIMIT} 个字符),只输出标题本身,不要引号或解释:\n\n${text}` }] }],
56
+ system: 'You write very short conversation titles. Output only the title, no quotes, no punctuation wrapper.',
57
+ purpose: 'powerup-direct-ask-title',
58
+ ...(signal === undefined ? {} : { signal }),
59
+ };
60
+ let raw = '';
61
+ let finish;
62
+ for await (const chunk of call.stream(options)) {
63
+ if (signal?.aborted) throw new DirectAskError('ABORTED', 'title generation cancelled');
64
+ if (chunk === null || typeof chunk !== 'object') continue;
65
+ if (chunk.type === 'text-delta' && typeof chunk.text === 'string') raw += chunk.text;
66
+ else if (chunk.type === 'finish') finish = chunk.reason;
67
+ }
68
+ if (finish?.kind === 'error' || finish?.kind === 'aborted') {
69
+ throw new DirectAskError('LLM_FAILED', `the title call ${finish.kind ?? 'failed'}`);
70
+ }
71
+ // Normalize: strip quotes, collapse whitespace, cap length.
72
+ const title = raw.trim().replace(/^["'「『]|["'」』]$/gu, '').replace(/\s+/gu, ' ').trim().slice(0, TITLE_LIMIT);
73
+ return { title: title || text.slice(0, TITLE_LIMIT), finish };
74
+ }
75
+
27
76
  /** Error with a stable machine code. */
28
77
  export class DirectAskError extends Error {
29
78
  constructor(code, message, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词、旁路模型生成的结构化任务进度;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, workspace prompts, and non-blocking model-generated structured task progress — each toggled independently on the Power-Up page.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",