@restregular/dsh-powerup 0.14.0 → 0.16.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 (4) hide show
  1. package/README.md +16 -11
  2. package/client.js +358 -140
  3. package/index.js +18 -5
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -449,17 +449,22 @@ the running agent:
449
449
 
450
450
  Requirements are a **list of records** (just like prompts), managed in the
451
451
  Power-Up page's dedicated **Requirements** tab and in the conversation's
452
- Power-Up settings tab. Each record is scoped to a workspace (`''` = global), can
453
- be enabled/disabled, and describes language, structure, required data or
454
- questions for the display area. When generating progress you **choose which
455
- requirements to apply** in the panel — nothing is added unless you check it.
456
- The panel is wider by default, resizable from its bottom-right corner (size
457
- persisted), and its header tint shifts from blue toward warning red as the
458
- report ages. Every refresh adds a new report to a per-session history stored on
459
- disk; older reports stay browsable and are never discarded. The panel can switch
460
- between them, show the exact raw AI text, copy it, and clear the history
461
- explicitly. "Refresh progress" generates a new report without dropping the old
462
- ones.
452
+ Power-Up settings tab. On creation you pick the workspace (or "all workspaces");
453
+ only scopes that actually contain requirements are listed. Each record can be
454
+ enabled/disabled, edited and deleted. When generating progress you **check the
455
+ requirements you want** — checked ones fill an editable text box that you may
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.
463
468
 
464
469
  ### Direct ask (no Agent)
465
470
 
package/client.js CHANGED
@@ -81,9 +81,11 @@
81
81
  * of resetting it. Cleared once the prompt is actually created.
82
82
  */
83
83
  const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
84
+ /** In-progress "new requirement" dialog draft (progress panel). */
85
+ const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
84
86
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
85
87
  const UNSCOPED_WORKSPACE = '__unscoped__';
86
- const VERSION = '0.11.0';
88
+ const VERSION = '0.16.0';
87
89
  const MENU_GAP = 8;
88
90
  const MENU_WIDTH = 248;
89
91
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -375,7 +377,11 @@
375
377
  'progress.updated': '更新于 {time}',
376
378
  'progress.history': '历史进度',
377
379
  'progress.historyEmpty': '暂无历史记录',
378
- 'progress.viewRaw': '查看原始内容',
380
+ 'progress.viewRaw': '原始内容',
381
+ 'progress.tabProgress': '进度',
382
+ 'progress.rawEmpty': '本次报告没有原始文本。',
383
+ 'progress.expand': '展开',
384
+ 'progress.collapse': '折叠',
379
385
  'progress.rawTitle': 'AI 原始生成内容',
380
386
  'progress.rawHint': '这是模型返回的原始文本,未经解析处理。',
381
387
  'progress.copyRaw': '复制原文',
@@ -387,7 +393,10 @@
387
393
  'progress.reqHint': '每条要求可设置语言、结构、必须包含的数据、额外展示区要回答的问题等;按工作区隔离,留空工作区则对所有工作区生效。生成进度时可勾选本次要应用哪些要求。',
388
394
  'progress.reqNew': '新建要求',
389
395
  'progress.reqSelect': '本次应用的要求',
390
- 'progress.reqSelectHint': '勾选本次生成要使用要求;不选则不附加任何要求。',
396
+ 'progress.reqSelectHint': '勾选要求后内容会填入下方输入框,可自由修改;生成/刷新时会使用输入框里的完整要求。',
397
+ 'progress.reqEditPlaceholder': '在这里编辑本次生成要使用的要求…',
398
+ 'progress.reqTextLabel': '要求内容',
399
+ 'progress.sectionTitle': '生成要求',
391
400
  'progress.reqGlobal': '通用要求(设置页)',
392
401
  'progress.reqWorkspace': '工作区要求',
393
402
  'progress.reqSession': '会话要求',
@@ -762,7 +771,11 @@
762
771
  'progress.updated': 'Updated at {time}',
763
772
  'progress.history': 'History',
764
773
  'progress.historyEmpty': 'No history yet',
765
- 'progress.viewRaw': 'View raw output',
774
+ 'progress.viewRaw': 'Raw output',
775
+ 'progress.tabProgress': 'Progress',
776
+ 'progress.rawEmpty': 'No raw text for this report.',
777
+ 'progress.expand': 'Expand',
778
+ 'progress.collapse': 'Collapse',
766
779
  'progress.rawTitle': 'Raw AI output',
767
780
  'progress.rawHint': 'This is the exact text returned by the model, before parsing.',
768
781
  'progress.copyRaw': 'Copy raw',
@@ -774,7 +787,10 @@
774
787
  'progress.reqHint': 'Each requirement sets language, structure, required data, questions for the display area, etc. Scoped per workspace; a blank workspace applies everywhere. Choose which ones to apply when generating progress.',
775
788
  'progress.reqNew': 'New requirement',
776
789
  'progress.reqSelect': 'Requirements for this run',
777
- 'progress.reqSelectHint': 'Check the requirements to apply this time; none selected means no extra requirements.',
790
+ 'progress.reqSelectHint': 'Checked requirements fill the box below; edit freely. Generation uses the full text in the box.',
791
+ 'progress.reqEditPlaceholder': 'Edit the requirements to use for this generation…',
792
+ 'progress.reqTextLabel': 'Requirement text',
793
+ 'progress.sectionTitle': 'Generation requirements',
778
794
  'progress.reqGlobal': 'Global requirements (settings)',
779
795
  'progress.reqWorkspace': 'Workspace requirements',
780
796
  'progress.reqSession': 'Session requirements',
@@ -4571,7 +4587,19 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4571
4587
  .dsh-powerup-progress-fill{height:100%;border-radius:999px;background:var(--dsw-alias-brand-primary);transition:width .3s ease}
4572
4588
  .dsh-powerup-progress-section{margin:12px 0 6px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase}
4573
4589
  .dsh-powerup-progress-items{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none}
4574
- .dsh-powerup-progress-item{display:flex;align-items:flex-start;gap:8px;padding:6px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1)}
4590
+ .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)}
4591
+ .dsh-powerup-progress-item-head{display:flex;align-items:center;gap:7px;min-width:0}
4592
+ .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}
4593
+ .dsh-powerup-progress-item-toggle svg{transform:rotate(-90deg);transition:transform .12s ease}
4594
+ .dsh-powerup-progress-item:not(.is-collapsed) .dsh-powerup-progress-item-toggle svg{transform:none}
4595
+ .dsh-powerup-progress-item-toggle-spacer{flex:none;width:16px;height:16px}
4596
+ .dsh-powerup-progress-item-detail{margin-left:23px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:1.5;overflow-wrap:anywhere}
4597
+ .dsh-powerup-progress-tabs{display:flex;flex:none;gap:2px;padding:0 12px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
4598
+ .dsh-powerup-progress-tab{position:relative;padding:8px 12px;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11.5px;line-height:1.5;cursor:pointer}
4599
+ .dsh-powerup-progress-tab:hover{color:var(--dsw-alias-label-primary)}
4600
+ .dsh-powerup-progress-tab.on{color:var(--dsw-alias-brand-primary);font-weight:600}
4601
+ .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)}
4602
+ .dsh-powerup-progress-req-tab{display:flex;flex-direction:column;gap:6px}
4575
4603
  .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}
4576
4604
  .dsh-powerup-progress-badge[data-status=pending]{background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary)}
4577
4605
  .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)}
@@ -4614,6 +4642,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4614
4642
  .dsh-powerup-req-option{display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:6px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font-size:11.5px;cursor:pointer}
4615
4643
  .dsh-powerup-req-option:hover{background:var(--dsw-alias-interactive-bg-hover)}
4616
4644
  .dsh-powerup-req-option input{flex:none;accent-color:var(--dsw-alias-brand-primary)}
4645
+ .dsh-powerup-req-textarea{min-height:96px;margin-top:6px}
4646
+ .dsh-powerup-req-create{margin-top:8px}
4647
+ .dsh-powerup-prompt-scope-options{display:flex;flex-wrap:wrap;gap:8px}
4617
4648
  .dsh-powerup-req-manager{display:flex;flex-direction:column;gap:16px}
4618
4649
  .dsh-powerup-req-list{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}
4619
4650
  .dsh-powerup-req-item{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
@@ -9625,7 +9656,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9625
9656
  ),
9626
9657
  ),
9627
9658
  h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
9628
- h(RequirementManager, { ctx, workspaceOnly: true, workspaceId }),
9659
+ h(RequirementManager, { ctx }),
9629
9660
  ),
9630
9661
  );
9631
9662
  }
@@ -10326,31 +10357,56 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10326
10357
  .filter((r) => r.workspaceId === '' || r.workspaceId === id);
10327
10358
  }
10328
10359
 
10329
- /** Textarea field for one requirements layer. */
10330
- function RequirementField({ label, hint, value, placeholder, onChange }) {
10331
- return h('label', { className: 'dsh-powerup-prompt-field' },
10332
- h('span', { className: 'dsh-powerup-prompt-field-label' }, label),
10333
- hint ? h('span', { className: 'dsh-powerup-setting-hint' }, hint) : null,
10334
- h('textarea', {
10335
- className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
10336
- value: value ?? '',
10337
- placeholder: placeholder ?? '',
10338
- onChange: (event) => onChange(event.target.value),
10360
+ /**
10361
+ * Create/edit form for one requirement record. On creation the workspace
10362
+ * is chosen here (any workspace, or global) — exactly like the prompt form.
10363
+ */
10364
+ function RequirementForm({ draft, setDraft, workspaces, t, save, cancel }) {
10365
+ const field = (key, placeholder, className) => h('label', { className: 'dsh-powerup-prompt-field' },
10366
+ h('input', {
10367
+ className: 'dsh-powerup-prompt-input' + (className ? ' ' + className : ''),
10368
+ type: 'text', value: draft?.[key] ?? '', placeholder,
10369
+ onChange: (event) => setDraft({ ...draft, [key]: event.target.value }),
10339
10370
  }),
10340
10371
  );
10372
+ return h('div', { className: 'dsh-powerup-req-form' },
10373
+ field('title', t('prompts.titlePlaceholder')),
10374
+ h('label', { className: 'dsh-powerup-prompt-field' },
10375
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
10376
+ h(WorkspaceSelect, {
10377
+ value: draft?.workspaceId ?? '',
10378
+ options: [
10379
+ { value: '', label: t('prompts.anyWorkspace') },
10380
+ ...workspaces.map((ws) => ({ value: ws.workspaceId, label: ws.title || ws.workspaceId, hint: ws.title ? ws.workspaceId : undefined })),
10381
+ ],
10382
+ onChange: (value) => setDraft({ ...draft, workspaceId: value }),
10383
+ t,
10384
+ }),
10385
+ ),
10386
+ h('label', { className: 'dsh-powerup-prompt-field' },
10387
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
10388
+ h('textarea', {
10389
+ className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
10390
+ value: draft?.text ?? '', placeholder: t('progress.reqPlaceholder'),
10391
+ onChange: (event) => setDraft({ ...draft, text: event.target.value }),
10392
+ }),
10393
+ ),
10394
+ h('div', { className: 'dsh-powerup-prompt-form-actions' },
10395
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: cancel }, t('prompts.cancel')),
10396
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: save }, t('prompts.save')),
10397
+ ),
10398
+ );
10341
10399
  }
10342
10400
 
10343
10401
  /**
10344
- * Multi-record requirement manager, modelled on PromptManager: records are
10345
- * scoped to a workspace ('' = global) and can be enabled/disabled, edited
10346
- * and deleted. Used in the Power-Up page's new "Requirements" tab and as
10347
- * the workspace-scoped editor in the conversation settings tab.
10402
+ * Settings-page manager, modelled on PromptManager: "New requirement"
10403
+ * opens the form where the workspace is picked; only scopes that actually
10404
+ * contain requirements are listed (global first, then each such workspace).
10348
10405
  */
10349
- function RequirementManager({ ctx, workspaceOnly, workspaceId }) {
10406
+ function RequirementManager({ ctx }) {
10350
10407
  const reqs = useRequirements();
10351
10408
  const [, forceLocale] = useState(0);
10352
10409
  const [draft, setDraft] = useState(null);
10353
- const [expanded, setExpanded] = useState(null);
10354
10410
  const t = (key, params) => translateCurrent(key, params);
10355
10411
  useEffect(() => {
10356
10412
  const locale = ctx?.get?.('locale');
@@ -10363,22 +10419,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10363
10419
  return Array.isArray(snapshot?.items) ? snapshot.items : [];
10364
10420
  } catch { return []; }
10365
10421
  })();
10366
- const visible = workspaceOnly
10367
- ? reqs.filter((r) => r.workspaceId === (typeof workspaceId === 'string' ? workspaceId : ''))
10368
- : reqs;
10369
-
10370
- const sections = workspaceOnly
10371
- ? [{ id: workspaceId ?? '', label: t('progress.reqWorkspace'), items: visible }]
10372
- : [
10373
- { id: '', label: t('prompts.scopeGlobal'), items: reqs.filter((r) => r.workspaceId === '') },
10374
- ...workspaces.map((ws) => ({
10375
- id: ws.workspaceId,
10376
- label: ws.title ?? ws.workspaceId,
10377
- items: reqs.filter((r) => r.workspaceId === ws.workspaceId),
10378
- })),
10379
- ];
10422
+ const titleOf = (id) => id === '' ? t('prompts.anyWorkspace') : (workspaces.find((ws) => ws.workspaceId === id)?.title || id);
10380
10423
 
10381
- const cancel = () => { setDraft(null); setExpanded(null); };
10424
+ const cancel = () => setDraft(null);
10382
10425
  const save = () => {
10383
10426
  if (draft === null) return;
10384
10427
  const text = typeof draft.text === 'string' ? draft.text.trim() : '';
@@ -10404,12 +10447,41 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10404
10447
  saveRequirements(reqs.map((r) => (r.id === record.id ? { ...r, enabled: r.enabled === false } : r)));
10405
10448
  };
10406
10449
 
10407
- return h('div', { className: 'dsh-powerup-req-manager' },
10408
- h('p', { className: 'dsh-powerup-card-desc' }, t('progress.reqHint')),
10409
- ...sections.map((section) => h('div', { key: `sec-${section.id}` },
10410
- h('h3', { className: 'dsh-powerup-section-title' }, section.label),
10411
- h('ul', { className: 'dsh-powerup-req-list' },
10412
- section.items.map((r) => h('li', { key: r.id, className: 'dsh-powerup-req-item' + (r.enabled === false ? ' off' : '') },
10450
+ // Only show scopes that have requirements (plus orphaned ids).
10451
+ const scopeIds = [];
10452
+ if (reqs.some((r) => r.workspaceId === '')) scopeIds.push('');
10453
+ for (const ws of workspaces) {
10454
+ if (reqs.some((r) => r.workspaceId === ws.workspaceId)) scopeIds.push(ws.workspaceId);
10455
+ }
10456
+ for (const r of reqs) {
10457
+ if (!scopeIds.includes(r.workspaceId)) scopeIds.push(r.workspaceId);
10458
+ }
10459
+
10460
+ return h('div', null,
10461
+ h('div', { className: 'dsh-powerup-prompt-head' },
10462
+ h('div', null,
10463
+ h('div', { className: 'dsh-powerup-prompt-head-title' }, t('progress.sectionTitle')),
10464
+ h('div', { className: 'dsh-powerup-prompt-head-sub' }, t('progress.reqHint')),
10465
+ ),
10466
+ h('button', {
10467
+ type: 'button', className: 'dsh-powerup-prompt-new',
10468
+ onClick: () => setDraft({ id: '', title: '', text: '', workspaceId: '', enabled: true }),
10469
+ }, t('progress.reqNew')),
10470
+ ),
10471
+ draft !== null ? h('section', { className: 'dsh-powerup-prompt-card' },
10472
+ h(RequirementForm, { draft, setDraft, workspaces, t, save, cancel }),
10473
+ ) : null,
10474
+ scopeIds.length === 0
10475
+ ? h('div', { className: 'dsh-powerup-prompt-empty' }, t('progress.reqEmpty'))
10476
+ : h('div', { className: 'dsh-powerup-prompt-scopes' }, scopeIds.map((scopeId) => h('section', {
10477
+ key: 'scope:' + scopeId, className: 'dsh-powerup-prompt-scope',
10478
+ },
10479
+ h('div', { className: 'dsh-powerup-prompt-scope-head' },
10480
+ h('span', { className: 'dsh-powerup-prompt-scope-title' }, titleOf(scopeId)),
10481
+ ),
10482
+ h('div', { className: 'dsh-powerup-req-list' }, reqs.filter((r) => r.workspaceId === scopeId).map((r) => h('div', {
10483
+ key: r.id, className: 'dsh-powerup-req-item' + (r.enabled === false ? ' off' : ''),
10484
+ },
10413
10485
  h('button', {
10414
10486
  type: 'button', role: 'switch', 'aria-checked': r.enabled !== false ? 'true' : 'false',
10415
10487
  className: 'dsh-powerup-switch', title: t('page.enabled'),
@@ -10420,61 +10492,131 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10420
10492
  h('span', { className: 'dsh-powerup-req-text' }, r.text),
10421
10493
  ),
10422
10494
  h('button', {
10423
- type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => { setDraft({ ...r }); setExpanded(r.id); },
10495
+ type: 'button', className: 'dsh-powerup-linkbtn',
10496
+ onClick: () => setDraft({ ...r }),
10424
10497
  }, t('prompts.edit')),
10425
10498
  h('button', {
10426
- type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => remove(r),
10499
+ type: 'button', className: 'dsh-powerup-linkbtn danger',
10500
+ onClick: () => remove(r),
10427
10501
  }, t('prompts.delete')),
10428
- )),
10429
- ),
10430
- expanded === `new-${section.id}` && draft !== null
10431
- ? h(RequirementForm, { draft, setDraft, workspaces, workspaceOnly, scopeId: section.id, t, save, cancel })
10432
- : null,
10433
- h('button', {
10434
- type: 'button', className: 'dsh-powerup-prompt-new',
10435
- onClick: () => { setDraft({ id: '', title: '', text: '', workspaceId: section.id, enabled: true }); setExpanded(`new-${section.id}`); },
10436
- }, t('progress.reqNew')),
10437
- )),
10502
+ ))),
10503
+ ))),
10438
10504
  );
10439
10505
  }
10440
10506
 
10441
- /** Inline create/edit form for one requirement record. */
10442
- function RequirementForm({ draft, setDraft, workspaces, workspaceOnly, scopeId, t, save, cancel }) {
10443
- return h('div', { className: 'dsh-powerup-req-form' },
10444
- h('input', {
10445
- className: 'dsh-powerup-prompt-input', type: 'text',
10446
- value: draft.title ?? '', placeholder: t('prompts.titlePlaceholder'),
10447
- onChange: (e) => setDraft({ ...draft, title: e.target.value }),
10448
- }),
10449
- h('textarea', {
10450
- className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
10451
- value: draft.text ?? '', placeholder: t('progress.reqPlaceholder'),
10452
- onChange: (e) => setDraft({ ...draft, text: e.target.value }),
10453
- }),
10454
- !workspaceOnly ? h(WorkspaceSelect, {
10455
- value: draft.workspaceId ?? '',
10456
- options: [{ value: '', label: t('prompts.anyWorkspace') }, ...workspaces.map((ws) => ({ value: ws.workspaceId, label: ws.title ?? ws.workspaceId }))],
10457
- onChange: (value) => setDraft({ ...draft, workspaceId: value }),
10458
- t,
10459
- }) : null,
10460
- h('div', { className: 'dsh-powerup-req-form-foot' },
10461
- h('button', { type: 'button', className: 'dsh-powerup-update-ghost', onClick: cancel }, t('prompts.cancel')),
10462
- h('button', { type: 'button', className: 'dsh-powerup-update-primary', onClick: save }, t('prompts.save')),
10507
+ /**
10508
+ * Create-requirement modal for the session progress panel, mirroring
10509
+ * PromptCreateModal: pinned to the session's workspace, choose keep or
10510
+ * "all workspaces", with an in-memory draft that survives reopening.
10511
+ */
10512
+ function RequirementCreateModal({ workspaceId, workspaceTitle, onClose, onCreated }) {
10513
+ const t = (key, params) => translateCurrent(key, params);
10514
+ const fixedScope = typeof workspaceId !== 'string' || workspaceId === '';
10515
+ const key = fixedScope ? '' : workspaceId;
10516
+ if (requirementCreateDraft.workspaceId !== key) {
10517
+ requirementCreateDraft.workspaceId = key;
10518
+ requirementCreateDraft.title = '';
10519
+ requirementCreateDraft.text = '';
10520
+ requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
10521
+ }
10522
+ const [title, setTitle] = useState(requirementCreateDraft.title);
10523
+ const [text, setText] = useState(requirementCreateDraft.text);
10524
+ const [scope, setScope] = useState(requirementCreateDraft.scope);
10525
+ const [closing, setClosing] = useState(false);
10526
+ const closingRef = useRef(false);
10527
+ const requestClose = () => {
10528
+ if (closingRef.current) return;
10529
+ closingRef.current = true;
10530
+ setClosing(true);
10531
+ setTimeout(() => { try { onClose(); } catch { /* parent owns unmount */ } }, 140);
10532
+ };
10533
+ useEffect(() => {
10534
+ requirementCreateDraft.title = title;
10535
+ requirementCreateDraft.text = text;
10536
+ requirementCreateDraft.scope = scope;
10537
+ }, [title, text, scope]);
10538
+ useEffect(() => {
10539
+ const onKey = (event) => { if (event.key === 'Escape') { event.preventDefault(); requestClose(); } };
10540
+ document.addEventListener('keydown', onKey, true);
10541
+ return () => document.removeEventListener('keydown', onKey, true);
10542
+ }, []);
10543
+ const save = () => {
10544
+ const body = typeof text === 'string' ? text.trim() : '';
10545
+ if (body === '') return;
10546
+ const record = {
10547
+ id: newId(),
10548
+ title: typeof title === 'string' ? title.trim() : '',
10549
+ text: body,
10550
+ workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
10551
+ enabled: true,
10552
+ };
10553
+ saveRequirements([...requirementsCache, record]);
10554
+ requirementCreateDraft.title = '';
10555
+ requirementCreateDraft.text = '';
10556
+ requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
10557
+ if (!closingRef.current) { closingRef.current = true; setClosing(true); }
10558
+ setTimeout(() => { try { onCreated(record); } catch { /* ignore */ } }, 140);
10559
+ };
10560
+ return renderInBody(h('div', {
10561
+ className: 'dsh-powerup-prompt-modal-mask' + (closing ? ' is-closing' : ''),
10562
+ onPointerDown: (event) => { if (event.target === event.currentTarget) requestClose(); },
10563
+ },
10564
+ h('div', { className: 'dsh-powerup-prompt-modal' + (closing ? ' is-closing' : ''), role: 'dialog', 'aria-modal': 'true' },
10565
+ h('div', { className: 'dsh-powerup-prompt-modal-head' },
10566
+ h('div', null,
10567
+ h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t('progress.reqNew')),
10568
+ h('p', { className: 'dsh-powerup-prompt-modal-sub' }, t('prompts.createScopeHint')),
10569
+ ),
10570
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-modal-close', 'aria-label': t('prompts.cancel'), onClick: requestClose }, '×'),
10571
+ ),
10572
+ h('div', { className: 'dsh-powerup-prompt-modal-body' },
10573
+ h('label', { className: 'dsh-powerup-prompt-field' },
10574
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.titleLabel')),
10575
+ h('input', { className: 'dsh-powerup-prompt-input', type: 'text', value: title, placeholder: t('prompts.titlePlaceholder'), onChange: (e) => setTitle(e.target.value) }),
10576
+ ),
10577
+ h('label', { className: 'dsh-powerup-prompt-field' },
10578
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
10579
+ h('div', { className: 'dsh-powerup-prompt-scope-options' },
10580
+ h('button', {
10581
+ type: 'button', role: 'switch', 'aria-checked': scope === 'all' ? 'true' : 'false',
10582
+ className: 'dsh-powerup-switch', onClick: () => setScope('all'),
10583
+ }, t('prompts.anyWorkspace')),
10584
+ fixedScope ? null : h('button', {
10585
+ type: 'button', role: 'switch', 'aria-checked': scope === 'current' ? 'true' : 'false',
10586
+ className: 'dsh-powerup-switch', onClick: () => setScope('current'),
10587
+ }, workspaceTitle || t('prompts.workspaceCurrent')),
10588
+ ),
10589
+ ),
10590
+ h('label', { className: 'dsh-powerup-prompt-field' },
10591
+ h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
10592
+ h('textarea', { className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea', value: text, placeholder: t('progress.reqPlaceholder'), onChange: (e) => setText(e.target.value) }),
10593
+ ),
10594
+ ),
10595
+ h('div', { className: 'dsh-powerup-prompt-modal-foot' },
10596
+ h('button', { type: 'button', className: 'dsh-powerup-update-ghost', onClick: requestClose }, t('prompts.cancel')),
10597
+ h('button', { type: 'button', className: 'dsh-powerup-update-primary', disabled: text.trim() === '', onClick: save }, t('prompts.create')),
10598
+ ),
10463
10599
  ),
10464
- );
10600
+ ));
10465
10601
  }
10466
10602
 
10467
- /** Panel picker: choose which visible requirements to apply for this generation. */
10468
- function RequirementPicker({ reqs, selectedIds, onToggle, t }) {
10469
- if (reqs.length === 0) return h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.reqEmpty'));
10603
+ /**
10604
+ * Panel editor: check requirements to fill the text box, then freely edit
10605
+ * the combined text. On generate/refresh the full text is sent verbatim.
10606
+ */
10607
+ function RequirementPicker({ reqs, selectedIds, text, onToggle, onTextChange, t }) {
10470
10608
  return h('div', { className: 'dsh-powerup-req-picker' },
10471
- reqs.map((r) => h('label', { key: r.id, className: 'dsh-powerup-req-option' },
10472
- h('input', {
10473
- type: 'checkbox', checked: selectedIds.includes(r.id),
10474
- onChange: () => onToggle(r.id),
10475
- }),
10476
- h('span', null, r.title || (r.text.slice(0, 50) + (r.text.length > 50 ? '…' : ''))),
10477
- )),
10609
+ reqs.length === 0
10610
+ ? h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.reqEmpty'))
10611
+ : reqs.map((r) => h('label', { key: r.id, className: 'dsh-powerup-req-option' },
10612
+ h('input', { type: 'checkbox', checked: selectedIds.includes(r.id), onChange: () => onToggle(r.id) }),
10613
+ h('span', null, r.title || (r.text.slice(0, 50) + (r.text.length > 50 ? '…' : ''))),
10614
+ )),
10615
+ h('textarea', {
10616
+ className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea dsh-powerup-req-textarea',
10617
+ value: text ?? '', placeholder: t('progress.reqEditPlaceholder'),
10618
+ onChange: (event) => onTextChange(event.target.value),
10619
+ }),
10478
10620
  );
10479
10621
  }
10480
10622
 
@@ -10505,32 +10647,50 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10505
10647
  }, STATUS_LABEL[status] ?? status);
10506
10648
  }
10507
10649
 
10508
- /** Render one node (checklist step / phase / milestone / tree node). */
10509
- function ProgressItem(title, status, detail, children, key) {
10510
- return h('li', { key, className: 'dsh-powerup-progress-item' },
10511
- ProgressBadge(status),
10512
- h('div', { className: 'dsh-powerup-progress-item-copy' },
10650
+ /**
10651
+ * One collapsible node (checklist step / phase / milestone / tree node).
10652
+ * Rendered via h(ProgressItem, …) so each card owns its own collapse state.
10653
+ */
10654
+ function ProgressItem({ title, status, detail, children, nodeKey, t: translate }) {
10655
+ const [collapsed, setCollapsed] = useState(false);
10656
+ const hasBody = Boolean(detail) || (Array.isArray(children) && children.length > 0);
10657
+ return h('li', { key: nodeKey, className: 'dsh-powerup-progress-item' + (collapsed ? ' is-collapsed' : '') },
10658
+ h('div', { className: 'dsh-powerup-progress-item-head' },
10659
+ hasBody
10660
+ ? h('button', {
10661
+ type: 'button',
10662
+ className: 'dsh-powerup-progress-item-toggle',
10663
+ 'aria-expanded': collapsed ? 'false' : 'true',
10664
+ 'aria-label': collapsed ? (translate?.('progress.expand') ?? 'Expand') : (translate?.('progress.collapse') ?? 'Collapse'),
10665
+ onClick: () => setCollapsed((v) => !v),
10666
+ }, h('svg', { width: 10, height: 10, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
10667
+ h('path', { d: 'm4 6 4 4 4-4', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' })))
10668
+ : h('span', { className: 'dsh-powerup-progress-item-toggle-spacer' }),
10669
+ ProgressBadge(status),
10513
10670
  h('span', { className: 'dsh-powerup-progress-item-title' }, title),
10514
- detail ? h('span', { className: 'dsh-powerup-progress-item-detail' }, detail) : null,
10515
- Array.isArray(children) && children.length > 0
10516
- ? h('ul', { className: 'dsh-powerup-progress-children' }, children)
10517
- : null,
10518
10671
  ),
10672
+ !collapsed && detail ? h('span', { className: 'dsh-powerup-progress-item-detail' }, detail) : null,
10673
+ !collapsed && Array.isArray(children) && children.length > 0
10674
+ ? h('ul', { className: 'dsh-powerup-progress-children' }, children)
10675
+ : null,
10519
10676
  );
10520
10677
  }
10521
10678
 
10522
10679
  /** Render the model-chosen structured body. */
10523
- function ProgressStructure(report) {
10680
+ function ProgressStructure(report, t) {
10524
10681
  if (report === null || typeof report !== 'object') return null;
10525
10682
  const sections = [];
10683
+ const item = (title, status, detail, children, nodeKey) => h(ProgressItem, {
10684
+ key: nodeKey, title, status, detail, children, nodeKey, t,
10685
+ });
10526
10686
  const mode = report.mode ?? 'checklist';
10527
10687
  if (mode === 'phases' && Array.isArray(report.phases) && report.phases.length > 0) {
10528
10688
  sections.push(h('div', { key: 'phases' },
10529
10689
  h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.phases),
10530
- h('ul', { className: 'dsh-powerup-progress-items' }, report.phases.map((phase, i) => ProgressItem(
10690
+ h('ul', { className: 'dsh-powerup-progress-items' }, report.phases.map((phase, i) => item(
10531
10691
  phase.name, phase.status, phase.detail,
10532
10692
  Array.isArray(phase.steps) && phase.steps.length > 0
10533
- ? phase.steps.map((s, j) => ProgressItem(s.title, s.status, '', null, `p${i}-s${j}`))
10693
+ ? phase.steps.map((s, j) => item(s.title, s.status, '', null, `p${i}-s${j}`))
10534
10694
  : null,
10535
10695
  `phase-${i}`,
10536
10696
  ))),
@@ -10538,13 +10698,13 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10538
10698
  } else if (mode === 'milestones' && Array.isArray(report.milestones) && report.milestones.length > 0) {
10539
10699
  sections.push(h('div', { key: 'milestones' },
10540
10700
  h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.milestones),
10541
- h('ul', { className: 'dsh-powerup-progress-items' }, report.milestones.map((m, i) => ProgressItem(
10701
+ h('ul', { className: 'dsh-powerup-progress-items' }, report.milestones.map((m, i) => item(
10542
10702
  m.name, m.status, m.criteria ? `${m.detail ?? ''} · ${m.criteria}`.trim() : m.detail,
10543
10703
  null, `m-${i}`,
10544
10704
  ))),
10545
10705
  ));
10546
10706
  } else if (mode === 'tree' && report.tree !== null && report.tree !== undefined) {
10547
- const node = (n, key) => ProgressItem(
10707
+ const node = (n, key) => item(
10548
10708
  n.title, n.status, n.detail,
10549
10709
  Array.isArray(n.children) && n.children.length > 0 ? n.children.map((c, i) => node(c, `${key}-${i}`)) : null,
10550
10710
  key,
@@ -10556,7 +10716,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10556
10716
  } else if (Array.isArray(report.steps) && report.steps.length > 0) {
10557
10717
  sections.push(h('div', { key: 'steps' },
10558
10718
  h('div', { className: 'dsh-powerup-progress-section' }, MODE_LABEL.checklist),
10559
- h('ul', { className: 'dsh-powerup-progress-items' }, report.steps.map((s, i) => ProgressItem(
10719
+ h('ul', { className: 'dsh-powerup-progress-items' }, report.steps.map((s, i) => item(
10560
10720
  s.title, s.status, s.detail, null, `step-${i}`,
10561
10721
  ))),
10562
10722
  ));
@@ -10631,19 +10791,42 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10631
10791
  const [view, setView] = useState(null);
10632
10792
  const [busy, setBusy] = useState(false);
10633
10793
  const [historyIndex, setHistoryIndex] = useState(0);
10634
- const [showRaw, setShowRaw] = useState(false);
10635
- const [showReq, setShowReq] = useState(false);
10636
- // Ids of requirement records selected for the next generation.
10794
+ const [activeTab, setActiveTab] = useState('progress');
10795
+ // Selected requirement ids + the free-editable combined text.
10637
10796
  const [selectedReqIds, setSelectedReqIds] = useState([]);
10797
+ const [reqText, setReqText] = useState('');
10798
+ const [creatingReq, setCreatingReq] = useState(false);
10638
10799
  const reqs = useRequirements();
10639
- // Resolve the owning workspace for requirement filtering.
10800
+ // Resolve the owning workspace for requirement filtering + create modal.
10640
10801
  const workspaceId = useMemo(() => {
10641
10802
  try {
10642
10803
  const snapshot = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.();
10643
10804
  return resolveWorkspaceIdFromSnapshot(snapshot, sessionRef.current) ?? '';
10644
10805
  } catch { return ''; }
10645
10806
  }, [sessionId, open]);
10807
+ const workspaceTitle = useMemo(() => {
10808
+ try {
10809
+ const items = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.()?.items ?? [];
10810
+ const found = items.find((ws) => ws?.workspaceId === workspaceId);
10811
+ return found?.title ?? '';
10812
+ } catch { return ''; }
10813
+ }, [workspaceId, open]);
10646
10814
  const visibleReqs = requirementsForWorkspace(reqs, workspaceId);
10815
+ /** Concatenate the enabled+selected requirements into editable text. */
10816
+ const composeReqText = useCallback((ids) => {
10817
+ return visibleReqs
10818
+ .filter((r) => ids.includes(r.id) && r.enabled !== false && typeof r.text === 'string' && r.text.trim() !== '')
10819
+ .map((r) => r.text.trim())
10820
+ .join('\n\n');
10821
+ }, [visibleReqs]);
10822
+ /** Toggle one requirement: rebuild the box from the current selection. */
10823
+ const toggleReq = useCallback((id) => {
10824
+ setSelectedReqIds((cur) => {
10825
+ const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id];
10826
+ setReqText(composeReqText(next));
10827
+ return next;
10828
+ });
10829
+ }, [composeReqText]);
10647
10830
  const [size, setSize] = useState(() => {
10648
10831
  try {
10649
10832
  const saved = JSON.parse(localStorage.getItem('dsh-powerup:progress:size:v1') || 'null');
@@ -10699,7 +10882,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10699
10882
  if (typeof id !== 'string' || id === '') return;
10700
10883
  setBusy(true);
10701
10884
  try {
10702
- const body = await progressRequest(id, 'start', { requirementIds: selectedReqIds });
10885
+ // Send the full, possibly user-edited text verbatim.
10886
+ const body = await progressRequest(id, 'start', { requirements: reqText });
10703
10887
  setView(body);
10704
10888
  setHistoryIndex(0);
10705
10889
  } catch (error) {
@@ -10708,7 +10892,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10708
10892
  setBusy(false);
10709
10893
  if (!open) setOpen(true);
10710
10894
  }
10711
- }, [open, selectedReqIds]);
10895
+ }, [open, reqText]);
10712
10896
 
10713
10897
  const clearHistory = useCallback(async () => {
10714
10898
  const id = sessionRef.current;
@@ -10817,12 +11001,29 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10817
11001
  h('div', { className: 'dsh-powerup-progress-fill', style: { width: `${report.percent}%` } }),
10818
11002
  ),
10819
11003
  ),
10820
- ProgressStructure(report),
11004
+ ProgressStructure(report, t),
10821
11005
  ProgressDisplay(report),
10822
11006
  );
10823
11007
  })();
10824
11008
 
10825
- const body = (() => {
11009
+ // Three tabs below the header: progress / requirements / raw output.
11010
+ const tabs = [
11011
+ { id: 'progress', label: t('progress.tabProgress') },
11012
+ { id: 'requirements', label: t('progress.requirements') },
11013
+ { id: 'raw', label: t('progress.viewRaw') },
11014
+ ];
11015
+ const tabBar = h('div', { className: 'dsh-powerup-progress-tabs', role: 'tablist' },
11016
+ tabs.map((tab) => h('button', {
11017
+ key: tab.id,
11018
+ type: 'button',
11019
+ role: 'tab',
11020
+ 'aria-selected': activeTab === tab.id ? 'true' : 'false',
11021
+ className: 'dsh-powerup-progress-tab' + (activeTab === tab.id ? ' on' : ''),
11022
+ onClick: () => setActiveTab(tab.id),
11023
+ }, tab.label)),
11024
+ );
11025
+
11026
+ const progressBody = (() => {
10826
11027
  if (view === null) return h('div', { className: 'dsh-powerup-progress-empty' }, t('progress.hint'));
10827
11028
  if (view.status === 'error') return h('p', { className: 'dsh-powerup-progress-error' }, view.error ?? t('progress.failed'));
10828
11029
  if (running) {
@@ -10831,18 +11032,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10831
11032
  reportBody,
10832
11033
  );
10833
11034
  }
10834
- if (showRaw) {
10835
- const raw = typeof report?.raw === 'string' ? report.raw : '';
10836
- return h('div', null,
10837
- h('h4', { className: 'dsh-powerup-progress-section' }, t('progress.rawTitle')),
10838
- h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.rawHint')),
10839
- h('pre', { className: 'dsh-powerup-progress-code' }, raw || '(empty)'),
10840
- h('button', {
10841
- type: 'button', className: 'dsh-powerup-progress-refresh',
10842
- onClick: () => void copyText(raw),
10843
- }, t('progress.copyRaw')),
10844
- );
10845
- }
10846
11035
  if (report === null || report === undefined) {
10847
11036
  return h('div', null,
10848
11037
  h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.empty')),
@@ -10872,16 +11061,38 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10872
11061
  );
10873
11062
  })();
10874
11063
 
10875
- const requirementsEditor = showReq ? h('div', { className: 'dsh-powerup-progress-req-pop' },
10876
- h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqSelect')),
11064
+ const requirementsBody = h('div', { className: 'dsh-powerup-progress-req-tab' },
10877
11065
  h('p', { className: 'dsh-powerup-setting-hint' }, t('progress.reqSelectHint')),
10878
11066
  h(RequirementPicker, {
10879
11067
  reqs: visibleReqs,
10880
11068
  selectedIds: selectedReqIds,
11069
+ text: reqText,
10881
11070
  t,
10882
- onToggle: (id) => setSelectedReqIds((cur) => cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id]),
11071
+ onToggle: toggleReq,
11072
+ onTextChange: setReqText,
10883
11073
  }),
10884
- ) : null;
11074
+ h('button', {
11075
+ type: 'button', className: 'dsh-powerup-prompt-new dsh-powerup-req-create',
11076
+ onClick: () => setCreatingReq(true),
11077
+ }, t('progress.reqNew')),
11078
+ );
11079
+
11080
+ const rawBody = h('div', null,
11081
+ h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.rawHint')),
11082
+ h('pre', { className: 'dsh-powerup-progress-code' },
11083
+ (typeof report?.raw === 'string' ? report.raw : '') || t('progress.rawEmpty')),
11084
+ h('button', {
11085
+ type: 'button', className: 'dsh-powerup-progress-refresh',
11086
+ disabled: typeof report?.raw !== 'string' || report.raw === '',
11087
+ onClick: () => void copyText(typeof report?.raw === 'string' ? report.raw : ''),
11088
+ }, t('progress.copyRaw')),
11089
+ );
11090
+
11091
+ const activeBody = activeTab === 'requirements'
11092
+ ? requirementsBody
11093
+ : activeTab === 'raw'
11094
+ ? rawBody
11095
+ : progressBody;
10885
11096
 
10886
11097
  const panel = !open ? null : h('div', {
10887
11098
  ref: panelRef,
@@ -10912,20 +11123,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10912
11123
  'aria-label': t('progress.close'), onClick: close,
10913
11124
  }, '×'),
10914
11125
  ),
10915
- requirementsEditor,
10916
- h('div', { className: 'dsh-powerup-progress-body' }, body),
11126
+ tabBar,
11127
+ h('div', { className: 'dsh-powerup-progress-body' }, activeBody),
10917
11128
  h('div', { className: 'dsh-powerup-progress-foot' },
10918
11129
  h('span', { className: 'dsh-powerup-progress-time' },
10919
11130
  view?.updatedAt ? format(t('progress.updated'), { time: new Date(view.updatedAt).toLocaleTimeString() }) : '',
10920
11131
  ),
10921
- h('button', {
10922
- type: 'button', className: 'dsh-powerup-progress-mini',
10923
- onClick: () => setShowReq((v) => !v),
10924
- }, t('progress.requirements')),
10925
- report?.raw ? h('button', {
10926
- type: 'button', className: 'dsh-powerup-progress-mini',
10927
- onClick: () => setShowRaw((v) => !v),
10928
- }, t('progress.viewRaw')) : null,
10929
11132
  history.length > 0 ? h('button', {
10930
11133
  type: 'button', className: 'dsh-powerup-progress-mini',
10931
11134
  onClick: () => void clearHistory(),
@@ -10948,6 +11151,18 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
10948
11151
  return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
10949
11152
  button,
10950
11153
  renderInBody(panel),
11154
+ creatingReq ? h(RequirementCreateModal, {
11155
+ workspaceId,
11156
+ workspaceTitle,
11157
+ onClose: () => setCreatingReq(false),
11158
+ onCreated: (record) => {
11159
+ setCreatingReq(false);
11160
+ // Auto-select the freshly created requirement and append its text
11161
+ // to the editable box (the cache may not have re-rendered yet).
11162
+ setSelectedReqIds((cur) => cur.includes(record.id) ? cur : [...cur, record.id]);
11163
+ setReqText((cur) => record.text ? (cur ? `${cur}\n\n${record.text.trim()}` : record.text.trim()) : cur);
11164
+ },
11165
+ }) : null,
10951
11166
  );
10952
11167
  }
10953
11168
 
@@ -11111,12 +11326,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11111
11326
  PROMPTS_CSS,
11112
11327
  PROGRESS_CSS,
11113
11328
  ProgressControl,
11329
+ ProgressItem,
11330
+ ProgressStructure,
11331
+ ProgressDisplay,
11114
11332
  RequirementManager,
11333
+ RequirementCreateModal,
11334
+ RequirementForm,
11115
11335
  RequirementPicker,
11116
11336
  requirementForWorkspace: requirementsForWorkspace,
11117
11337
  DirectAskButton,
11118
- ProgressStructure,
11119
- ProgressDisplay,
11120
11338
  progressRequest,
11121
11339
  PROMPTS_LAST_KEY,
11122
11340
  promptCreateDraft,
package/index.js CHANGED
@@ -627,9 +627,13 @@ async function handle(req, res, ctx) {
627
627
  return;
628
628
  }
629
629
  try {
630
- // A one-off requirements selection from the progress panel is kept for
631
- // the next start; it does not modify the persisted records.
632
- if (Array.isArray(body?.requirementIds)) {
630
+ // The panel sends the full (possibly user-edited) requirements text in
631
+ // `requirements`. It is used verbatim. The older `requirementIds`
632
+ // selection remains as a fallback for clients that send it.
633
+ if (typeof body?.requirements === 'string') {
634
+ ctx.__powerupProgressText = ctx.__powerupProgressText ?? {};
635
+ ctx.__powerupProgressText[sessionId] = body.requirements;
636
+ } else if (Array.isArray(body?.requirementIds)) {
633
637
  ctx.__powerupProgressSelection = ctx.__powerupProgressSelection ?? {};
634
638
  ctx.__powerupProgressSelection[sessionId] = body.requirementIds.map(String);
635
639
  }
@@ -922,7 +926,11 @@ export function apply(ctx) {
922
926
  // Requirements are a flat list of records: {id,title,text,workspaceId,enabled}.
923
927
  // workspaceId '' = global. The panel sends the ids it wants; the Host only
924
928
  // includes records visible to the session's workspace and explicitly picked.
925
- const requirementsFor = (sessionId, selectedIds) => {
929
+ const requirementsFor = (sessionId, selectedIds, editedText) => {
930
+ // A panel-edited full text wins verbatim (the user may freely modify the
931
+ // concatenated requirements before generating).
932
+ if (typeof editedText === 'string' && editedText.trim() !== '') return editedText;
933
+ if (editedText === '') return ''; // user cleared everything on purpose
926
934
  const file = storePath(PROGRESS_REQUIREMENTS_FILE);
927
935
  let raw;
928
936
  try {
@@ -986,7 +994,11 @@ export function apply(ctx) {
986
994
  ? selection
987
995
  : undefined;
988
996
  },
989
- getRequirements: (sessionId) => requirementsFor(sessionId, ctx.__powerupProgressSelection?.[sessionId]),
997
+ getRequirements: (sessionId) => requirementsFor(
998
+ sessionId,
999
+ ctx.__powerupProgressSelection?.[sessionId],
1000
+ ctx.__powerupProgressText?.[sessionId],
1001
+ ),
990
1002
  onHistoryChange: (sessionId, history) => {
991
1003
  try {
992
1004
  const all = readJsonObject(historyPath);
@@ -1015,6 +1027,7 @@ export function apply(ctx) {
1015
1027
  };
1016
1028
  ctx.__powerupProgress = manager;
1017
1029
  ctx.__powerupProgressSelection = ctx.__powerupProgressSelection ?? {};
1030
+ ctx.__powerupProgressText = ctx.__powerupProgressText ?? {};
1018
1031
  scope.effect(() => () => {
1019
1032
  if (ctx.__powerupProgress === manager) ctx.__powerupProgress = undefined;
1020
1033
  }, 'dsh-powerup: progress manager');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.14.0",
3
+ "version": "0.16.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",