@restregular/dsh-powerup 0.18.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.
Files changed (3) hide show
  1. package/README.md +15 -9
  2. package/client.js +203 -23
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -457,15 +457,21 @@ freely modify, and generation/refresh uses the full box text verbatim. The panel
457
457
  also has a **New requirement** entry with a modal: pick the workspace (or "all
458
458
  workspaces") there, and clicks inside the modal no longer close the progress
459
459
  panel.
460
- The panel uses **tabs** below the header: **Progress**, **Requirements** and
461
- **Raw output** — requirements and the raw AI text are no longer embedded in the
462
- progress body. Stage cards (checklist steps, phases, milestones and tree nodes)
463
- are **collapsible**. The panel is wider by default, resizable from its
464
- bottom-right corner (size persisted), and its header tint shifts from blue
465
- toward warning red as the report ages. Every refresh adds a new report to a
466
- per-session history stored on disk; older reports stay browsable and are never
467
- discarded. The panel can clear the history explicitly. "Refresh progress"
468
- generates a new report without dropping the old ones.
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.
469
475
 
470
476
  ### Direct ask (no Agent)
471
477
 
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.18.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': '关闭',
@@ -761,13 +767,19 @@
761
767
  'page.taskProgressTitle': 'Task progress snapshot',
762
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.',
763
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.',
764
772
  'progress.title': 'Task progress',
765
773
  'progress.label': 'Progress',
766
774
  'progress.subtitle': 'Generated in the background by this session model',
775
+ 'progress.modelChanging': 'Switching model…',
767
776
  'progress.hint': 'No progress report yet. Press Generate to analyze the session.',
768
777
  'progress.empty': 'No progress report generated yet.',
769
778
  'progress.generate': 'Generate progress',
770
- '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',
771
783
  'progress.retry': 'Retry',
772
784
  'progress.loading': 'Analyzing session progress in the background…',
773
785
  'progress.close': 'Close',
@@ -936,6 +948,7 @@
936
948
  dualSend: false,
937
949
  workspacePrompts: true,
938
950
  taskProgress: true,
951
+ taskProgressCooldown: 5,
939
952
  directAsk: true,
940
953
  directAskAutoTitle: false,
941
954
  oneClickEnable: true,
@@ -961,6 +974,10 @@
961
974
  dualSend: parsed.dualSend === true,
962
975
  workspacePrompts: parsed.workspacePrompts !== false,
963
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
+ })(),
964
981
  directAsk: parsed.directAsk !== false,
965
982
  directAskAutoTitle: parsed.directAskAutoTitle === true,
966
983
  oneClickEnable: parsed.oneClickEnable !== false,
@@ -4180,6 +4197,7 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
4180
4197
  .dsh-powerup-setting-label{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
4181
4198
  .dsh-powerup-setting-hint{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
4182
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}
4183
4201
  .dsh-powerup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:0;padding:0;list-style:none}
4184
4202
  .dsh-powerup-action{display:flex;align-items:flex-start;gap:8px;min-width:0;padding:7px 8px;border-radius:8px}
4185
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)}
@@ -4586,6 +4604,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4586
4604
  .dsh-powerup-progress-heading{display:flex;flex:1 1 auto;flex-direction:column;gap:2px;min-width:0}
4587
4605
  .dsh-powerup-progress-title{font-size:14px;font-weight:600;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
4588
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}
4589
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}
4590
4610
  .dsh-powerup-progress-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
4591
4611
  .dsh-powerup-progress-body{flex:1 1 auto;min-height:0;overflow-y:auto;padding:12px 16px 16px}
@@ -4602,6 +4622,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4602
4622
  .dsh-powerup-progress-items{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}
4603
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)}
4604
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))}
4605
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}
4606
4629
  .dsh-powerup-progress-item-toggle svg{transform:rotate(-90deg);transition:transform .12s ease}
4607
4630
  .dsh-powerup-progress-item:not(.is-collapsed) .dsh-powerup-progress-item-toggle svg{transform:none}
@@ -4613,6 +4636,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4613
4636
  .dsh-powerup-progress-tab.on{color:var(--dsw-alias-brand-primary);font-weight:600}
4614
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)}
4615
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}
4616
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}
4617
4642
  .dsh-powerup-progress-badge[data-status=pending]{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary)}
4618
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)}
@@ -10431,6 +10456,26 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10431
10456
  toggle(key, label),
10432
10457
  );
10433
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
+
10434
10479
  const actionsDetail = h('div', { className: 'dsh-powerup-card-detail' },
10435
10480
  h('h3', { className: 'dsh-powerup-section-title' }, t('page.actions')),
10436
10481
  h('ul', { className: 'dsh-powerup-actions' },
@@ -10498,7 +10543,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10498
10543
  featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
10499
10544
  featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
10500
10545
  featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
10501
- 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
+ ),
10502
10551
  featureCard('directAsk', TagIcon, 'page.directAskTitle', 'page.directAskDesc', 'page.directAskHow',
10503
10552
  h('div', { className: 'dsh-powerup-card-detail' },
10504
10553
  settingRow('directAsk', settings.directAsk !== false, t('page.directAskToggle'), t('page.directAskToggleHint')),
@@ -10930,17 +10979,25 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10930
10979
  function ProgressItem({ title, status, detail, children, nodeKey, t: translate }) {
10931
10980
  const [collapsed, setCollapsed] = useState(false);
10932
10981
  const hasBody = Boolean(detail) || (Array.isArray(children) && children.length > 0);
10982
+ const toggle = () => { if (hasBody) setCollapsed((v) => !v); };
10933
10983
  return h('li', { key: nodeKey, className: 'dsh-powerup-progress-item' + (collapsed ? ' is-collapsed' : '') },
10934
- 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
+ },
10935
10997
  hasBody
10936
- ? h('button', {
10937
- type: 'button',
10938
- className: 'dsh-powerup-progress-item-toggle',
10939
- 'aria-expanded': collapsed ? 'false' : 'true',
10940
- 'aria-label': collapsed ? (translate?.('progress.expand') ?? 'Expand') : (translate?.('progress.collapse') ?? 'Collapse'),
10941
- onClick: () => setCollapsed((v) => !v),
10942
- }, h('svg', { width: 10, height: 10, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
10943
- 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' })))
10944
11001
  : h('span', { className: 'dsh-powerup-progress-item-toggle-spacer' }),
10945
11002
  ProgressBadge(status),
10946
11003
  h('span', { className: 'dsh-powerup-progress-item-title' }, title),
@@ -11061,6 +11118,75 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11061
11118
  * - the raw AI text is viewable and copyable;
11062
11119
  * - one-off requirements can be added in the panel for the next refresh.
11063
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
+
11064
11190
  function ProgressControl({ sessionId }) {
11065
11191
  const settings = useSettings();
11066
11192
  const [open, setOpen] = useState(false);
@@ -11068,6 +11194,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11068
11194
  const [busy, setBusy] = useState(false);
11069
11195
  const [historyIndex, setHistoryIndex] = useState(0);
11070
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);
11071
11200
  // Selected requirement ids + the free-editable combined text.
11072
11201
  const [selectedReqIds, setSelectedReqIds] = useState([]);
11073
11202
  const [reqText, setReqText] = useState('');
@@ -11132,6 +11261,28 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11132
11261
  }
11133
11262
  }, []);
11134
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
+
11135
11286
  // While the panel is open, keep polling until the side call settles.
11136
11287
  useEffect(() => {
11137
11288
  if (!open) return undefined;
@@ -11156,6 +11307,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11156
11307
  const run = useCallback(async () => {
11157
11308
  const id = sessionRef.current;
11158
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);
11159
11319
  setBusy(true);
11160
11320
  try {
11161
11321
  // Send the full, possibly user-edited text verbatim.
@@ -11166,9 +11326,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11166
11326
  setView({ status: 'error', error: error?.message ?? String(error) });
11167
11327
  } finally {
11168
11328
  setBusy(false);
11329
+ // Once the refresh settles, show the result on the progress tab.
11330
+ setActiveTab('progress');
11169
11331
  if (!open) setOpen(true);
11170
11332
  }
11171
- }, [open, reqText]);
11333
+ }, [open, reqText, settings.taskProgressCooldown]);
11172
11334
 
11173
11335
  const clearHistory = useCallback(async () => {
11174
11336
  const id = sessionRef.current;
@@ -11286,9 +11448,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11286
11448
  })();
11287
11449
 
11288
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 "新建要求".
11289
11454
  const tabs = [
11290
11455
  { id: 'progress', label: t('progress.tabProgress') },
11291
- { id: 'requirements', label: t('progress.requirements') },
11456
+ { id: 'requirements', label: t('progress.tabRefresh') },
11292
11457
  { id: 'raw', label: t('progress.viewRaw') },
11293
11458
  ];
11294
11459
  const tabBar = h('div', { className: 'dsh-powerup-progress-tabs', role: 'tablist' },
@@ -11340,6 +11505,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11340
11505
  );
11341
11506
  })();
11342
11507
 
11508
+ const cooldownActive = cooldownLeft > 0 && !running;
11509
+ const refreshLabel = cooldownActive
11510
+ ? t('progress.refreshCooldown', { seconds: cooldownLeft })
11511
+ : t('progress.refresh');
11343
11512
  const requirementsBody = h('div', { className: 'dsh-powerup-progress-req-tab' },
11344
11513
  h(RequirementPicker, {
11345
11514
  reqs: visibleReqs,
@@ -11349,10 +11518,22 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11349
11518
  onToggle: toggleReq,
11350
11519
  onTextChange: setReqText,
11351
11520
  }),
11352
- h('button', {
11353
- type: 'button', className: 'dsh-powerup-prompt-new dsh-powerup-req-create',
11354
- onClick: () => setCreatingReq(true),
11355
- }, 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
+ ),
11356
11537
  );
11357
11538
 
11358
11539
  const rawBody = h('div', null,
@@ -11396,6 +11577,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11396
11577
  t('progress.subtitle'),
11397
11578
  ),
11398
11579
  ),
11580
+ h(ProgressModelSelect, { sessionId, ctx: ctxRef.current, t }),
11399
11581
  h('button', {
11400
11582
  type: 'button', className: 'dsh-powerup-progress-close',
11401
11583
  'aria-label': t('progress.close'), onClick: close,
@@ -11411,10 +11593,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11411
11593
  type: 'button', className: 'dsh-powerup-progress-mini',
11412
11594
  onClick: () => void clearHistory(),
11413
11595
  }, t('progress.clearHistory')) : null,
11414
- h('button', {
11415
- type: 'button', className: 'dsh-powerup-progress-refresh',
11416
- disabled: busy || running, onClick: () => void run(),
11417
- }, t('progress.refresh')),
11418
11596
  ),
11419
11597
  h('div', {
11420
11598
  className: 'dsh-powerup-progress-resizer',
@@ -11605,6 +11783,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11605
11783
  PROGRESS_CSS,
11606
11784
  ProgressControl,
11607
11785
  ProgressItem,
11786
+ ProgressModelSelect,
11787
+ findModelSelectEntry,
11608
11788
  ProgressStructure,
11609
11789
  ProgressDisplay,
11610
11790
  RequirementManager,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.18.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",