dsh-workplan 1.11.1 → 1.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workplan",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Automatic task decomposition, real department subagents, and a responsive workplan dashboard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,7 +32,8 @@
32
32
  * re-running a done subtask cannot fix a missing acceptance item, it only
33
33
  * produces duplicate work and a chance to overwrite the evidence.
34
34
  *
35
- * Default: **off**. See `AUTO_RESUME_DEFAULTS.enabled`.
35
+ * Default: **on**. `AUTO_RESUME_DEFAULTS.enabled = true`; turn it off with
36
+ * profile `autoResume: false` or `DSH_WORKPLAN_AUTO_RESUME=0`.
36
37
  */
37
38
 
38
39
  /** Tunables that are policy, not deployment config. */
@@ -100,6 +101,26 @@ export function autoResumeEnabledFrom(configValue: any, envValue: any) {
100
101
  return AUTO_RESUME_DEFAULTS.enabled === true
101
102
  }
102
103
 
104
+ /**
105
+ * [1.12.0] Count the rows that still participate in scheduling.
106
+ *
107
+ * A `closure:'replanned'` row keeps `status:'pending'` for audit. Counting it as
108
+ * pending made `armAutoResume` schedule a continuation round that could dispatch
109
+ * nothing (every live row was done) and then append a misleading
110
+ * `PHASE_NOT_PAUSED` stop line to `record.errors`.
111
+ *
112
+ * `armAutoResume` now passes these counts to `decideAutoResume`; `total` there
113
+ * still comes from `derivePlanSnapshot` (same live-row rule).
114
+ *
115
+ * @param statuses - the plan's status list.
116
+ * @returns live `done` / `pending` / `blocked` counts.
117
+ */
118
+ export function liveResumeCounts(statuses: any) {
119
+ const live = (Array.isArray(statuses) ? statuses : []).filter((item: any) => item?.closure !== 'replanned')
120
+ const count = (status: string) => live.filter((item: any) => item?.status === status).length
121
+ return { done: count('done'), pending: count('pending'), blocked: count('blocked') }
122
+ }
123
+
103
124
  /** `schedule` = arm the next round; `stop` = leave the plan to a human. */
104
125
  export type AutoResumeAction = 'schedule' | 'stop'
105
126
 
@@ -176,8 +197,8 @@ export interface AutoResumeDecision {
176
197
  * 2. user stop (`cancelled`, `superseded`) — never resurrect a decision
177
198
  * 3. already running / plan mode
178
199
  * 4. only a `paused` phase is auto-continuable
179
- * 5. nothing pending (includes "all done, evidence gap" — human work)
180
- * 6. any `blocked` row — a real failure, not a budget artifact
200
+ * 5. any `blocked` row — a real failure, not a budget artifact
201
+ * 6. nothing pending (includes "all done, evidence gap" — human work)
181
202
  * 7. attempt / progress budgets
182
203
  *
183
204
  * @param input - the frozen facts of the round that just ended.
@@ -195,7 +216,7 @@ export function decideAutoResume(input: AutoResumeInput): AutoResumeDecision {
195
216
  })
196
217
 
197
218
  if (input.enabled !== true) {
198
- return stop('AUTO_RESUME_DISABLED', '自动续跑开关未开启(默认关闭)')
219
+ return stop('AUTO_RESUME_DISABLED', '自动续跑开关未开启(已被显式关闭:profile autoResume:false 或 DSH_WORKPLAN_AUTO_RESUME=0)')
199
220
  }
200
221
  if (input.degraded === true || Number(input.total) <= 0) {
201
222
  return stop('NO_PLAN', '没有可续跑的计划(自动分解降级或子任务数为 0)')
@@ -215,6 +236,17 @@ export function decideAutoResume(input: AutoResumeInput): AutoResumeDecision {
215
236
  if (input.phase !== 'paused') {
216
237
  return stop('PHASE_NOT_PAUSED', `计划阶段是 ${String(input.phase ?? 'unknown')},只有 paused(预算到点)才自动续跑`)
217
238
  }
239
+ /*
240
+ * [1.12.0] 「有 blocked」先于「没有 pending」(T11)。
241
+ *
242
+ * 旧顺序把 `done=N, blocked=1, pending=0` 判成 NOTHING_PENDING(证据缺口),
243
+ * 而真正要处理的是那条 blocked 行。1.12 起预算到点会保留等指示行并把阶段写成
244
+ * blocked(PHASE_NOT_PAUSED 先命中),但历史会话回放仍可能出现 paused + blocked,
245
+ * 所以这里按可执行的优先序回答。
246
+ */
247
+ if (Number(input.blocked) > 0) {
248
+ return stop('HAS_BLOCKED', `存在 ${input.blocked} 个 blocked 子任务:那是真实失败,需人工改判或显式续跑,不自动修复`)
249
+ }
218
250
  if (Number(input.pending) <= 0) {
219
251
  /*
220
252
  * Also the evidence-gap case: all rows done but deliveryReady=false.
@@ -223,9 +255,6 @@ export function decideAutoResume(input: AutoResumeInput): AutoResumeDecision {
223
255
  */
224
256
  return stop('NOTHING_PENDING', '没有 pending 项:若仍未就绪,那是证据缺口,需主 Agent 复核,不能靠重跑 done 项解决')
225
257
  }
226
- if (Number(input.blocked) > 0) {
227
- return stop('HAS_BLOCKED', `存在 ${input.blocked} 个 blocked 子任务:那是真实失败,需人工改判或显式续跑,不自动修复`)
228
- }
229
258
  if (attempt >= maxAttempts) {
230
259
  return stop('BUDGET_EXHAUSTED', `自动续跑已用满 ${maxAttempts} 轮,交给主 Agent 决定`)
231
260
  }
package/src/client.ts CHANGED
@@ -15,6 +15,7 @@ window.__ModuleLoader__.load({
15
15
  const NS = 'dsh-workplan'
16
16
  const { useState, useEffect, useCallback, useMemo } = React
17
17
 
18
+ // [D-11] 面板统一称「执行角色」:role 仍是自由文本字段,只消除「负责人」与「角色」的口径冲突。
18
19
  const LOCALE = {
19
20
  "zh": {
20
21
  "panel": "任务进度",
@@ -64,7 +65,7 @@ window.__ModuleLoader__.load({
64
65
  "refresh": "刷新",
65
66
  "updatedAt": "更新于",
66
67
  "empty": "还没有任务进度",
67
- "emptyHint": "先发一句话说明你要做什么,系统会自动安排步骤和负责人。",
68
+ "emptyHint": "先发一句话说明你要做什么,系统会自动安排步骤和执行角色。",
68
69
  "error": "读取失败",
69
70
  "retry": "重试",
70
71
  "phase": {
@@ -105,7 +106,8 @@ window.__ModuleLoader__.load({
105
106
  "writing": "文档写作",
106
107
  "operations": "运营",
107
108
  "legal": "法务合规",
108
- "finance": "财务"
109
+ "finance": "财务",
110
+ "unknown": "未知部门"
109
111
  },
110
112
  "stats": {
111
113
  "done": "做好了",
@@ -119,7 +121,7 @@ window.__ModuleLoader__.load({
119
121
  "stepSuffix": "步",
120
122
  "workPrefix": "具体工作",
121
123
  "who": "负责团队",
122
- "person": "负责人",
124
+ "person": "执行角色",
123
125
  "what": "要做出什么",
124
126
  "how": "怎么做",
125
127
  "doneWhen": "怎样算做好",
@@ -165,7 +167,7 @@ window.__ModuleLoader__.load({
165
167
  "transformation": "什么情况下会变化",
166
168
  "checkpoint": "这一步做完先检查",
167
169
  "subtasks": "具体工作",
168
- "role": "负责人",
170
+ "role": "执行角色",
169
171
  "objective": "要做出什么",
170
172
  "method": "怎么做",
171
173
  "inputs": "开始前需要",
@@ -300,7 +302,8 @@ window.__ModuleLoader__.load({
300
302
  "writing": "Writing",
301
303
  "operations": "Operations",
302
304
  "legal": "Legal",
303
- "finance": "Finance"
305
+ "finance": "Finance",
306
+ "unknown": "Unknown department"
304
307
  },
305
308
  "stats": {
306
309
  "done": "Done",
@@ -314,7 +317,7 @@ window.__ModuleLoader__.load({
314
317
  "stepSuffix": "",
315
318
  "workPrefix": "Work item",
316
319
  "who": "Team",
317
- "person": "Owner",
320
+ "person": "Execution role",
318
321
  "what": "What to make",
319
322
  "how": "How",
320
323
  "doneWhen": "How we know it is good",
@@ -360,7 +363,7 @@ window.__ModuleLoader__.load({
360
363
  "transformation": "What could change it",
361
364
  "checkpoint": "Check before moving on",
362
365
  "subtasks": "Work items",
363
- "role": "Owner role",
366
+ "role": "Execution role",
364
367
  "objective": "What to make",
365
368
  "method": "How",
366
369
  "inputs": "Needed first",
@@ -809,9 +812,45 @@ window.__ModuleLoader__.load({
809
812
  .dsh-wp-planoverview-title { font-size: 12px; font-weight: 650; letter-spacing: .2px; }
810
813
  .dsh-wp-planoverview-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); font-variant-numeric: tabular-nums; }
811
814
  .dsh-wp-planrows { display: grid; }
812
- .dsh-wp-planrow { display: grid; grid-template-columns: 7px minmax(0, 1fr) 48px auto auto; align-items: center; gap: 8px; min-height: 28px; padding: 4px 0; border-top: 1px solid var(--dsw-alias-border-l1); }
815
+ /*
816
+ * [1.12.0] 「分步进度」每一行都是一个可点击的 disclosure(默认收起)。
817
+ *
818
+ * 收起态必须与改造前逐项一致:状态点、第 N 步:名称、进度条、done/total、
819
+ * 状态词;只多一个折叠指示箭头。展开按钮本身是原生 <button>,44px 触控高度,
820
+ * aria-expanded/aria-controls 由组件绑定,不复用 Collapse 的外层卡片留白。
821
+ */
822
+ .dsh-wp-planrow { display: block; min-width: 0; border-top: 1px solid var(--dsw-alias-border-l1); }
813
823
  .dsh-wp-planrow:first-child { border-top: 0; }
814
824
  .dsh-wp-planrow[data-current="true"] { background: rgba(249,115,22,.06); border-radius: 8px; }
825
+ .dsh-wp-planrow-toggle {
826
+ display: grid;
827
+ grid-template-columns: 9px 7px minmax(0, 1fr) 48px auto auto;
828
+ align-items: center;
829
+ gap: 8px;
830
+ width: 100%;
831
+ min-height: 44px;
832
+ padding: 4px 6px;
833
+ border: 0;
834
+ border-radius: 8px;
835
+ background: transparent;
836
+ color: inherit;
837
+ font: inherit;
838
+ text-align: left;
839
+ cursor: pointer;
840
+ touch-action: manipulation;
841
+ }
842
+ .dsh-wp-planrow-toggle:hover { background: rgba(148,163,184,.10); }
843
+ .dsh-wp-planrow-toggle:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
844
+ .dsh-wp-planrow-chevron {
845
+ justify-self: center;
846
+ width: 8px;
847
+ height: 8px;
848
+ border-right: 2px solid var(--dsw-alias-label-secondary, #475569);
849
+ border-bottom: 2px solid var(--dsw-alias-label-secondary, #475569);
850
+ transform: rotate(-45deg);
851
+ transition: transform 160ms ease;
852
+ }
853
+ .dsh-wp-planrow[data-open="true"] .dsh-wp-planrow-chevron { transform: rotate(45deg); }
815
854
  .dsh-wp-planrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-state-idle-primary); }
816
855
  .dsh-wp-planrow[data-tone="done"] .dsh-wp-planrow-dot { background: var(--dsh-wp-done); }
817
856
  .dsh-wp-planrow[data-tone="active"] .dsh-wp-planrow-dot { background: var(--dsh-wp-active); }
@@ -823,6 +862,21 @@ window.__ModuleLoader__.load({
823
862
  .dsh-wp-planrow[data-tone="blocked"] .dsh-wp-planrow-fill { background: var(--dsw-alias-state-error-primary); }
824
863
  .dsh-wp-planrow-count { font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); font-variant-numeric: tabular-nums; }
825
864
  .dsh-wp-planrow-state { font-size: 11px; color: var(--dsw-alias-label-secondary, #475569); white-space: nowrap; }
865
+ .dsh-wp-planrow-panel { padding: 0 6px 10px 30px; min-width: 0; }
866
+ .dsh-wp-planrow-panel[hidden] { display: none; }
867
+ .dsh-wp-planrow-detail { display: grid; gap: 4px; font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); overflow-wrap: anywhere; }
868
+ .dsh-wp-planrow-goal, .dsh-wp-planrow-checkpoint { line-height: 1.5; }
869
+ .dsh-wp-planrow-goal strong, .dsh-wp-planrow-checkpoint strong { color: var(--dsw-alias-label-primary, #0f172a); font-weight: 600; }
870
+ .dsh-wp-planrow-tasks { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
871
+ .dsh-wp-planrow-task { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
872
+ .dsh-wp-planrow-task-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-state-idle-primary); }
873
+ .dsh-wp-planrow-task[data-status="done"] .dsh-wp-planrow-task-dot { background: var(--dsh-wp-done); }
874
+ .dsh-wp-planrow-task[data-status="in_progress"] .dsh-wp-planrow-task-dot { background: var(--dsh-wp-active); }
875
+ .dsh-wp-planrow-task[data-status="blocked"] .dsh-wp-planrow-task-dot { background: var(--dsw-alias-state-error-primary); }
876
+ .dsh-wp-planrow-task-title { min-width: 0; color: var(--dsw-alias-label-primary, #0f172a); }
877
+ .dsh-wp-planrow-task-dept { color: var(--dsw-alias-label-secondary, #475569); }
878
+ .dsh-wp-planrow-task-state { margin-left: auto; white-space: nowrap; }
879
+ @media (prefers-reduced-motion: reduce) { .dsh-wp-planrow-chevron { transition: none; } }
826
880
  .dsh-wp-sessions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; align-items: start; }
827
881
  .dsh-wp-session {
828
882
  min-width: 0;
@@ -1124,7 +1178,14 @@ window.__ModuleLoader__.load({
1124
1178
  function deptName(t: any, id: any) {
1125
1179
  const key = `dept.${id}`
1126
1180
  const value = t(key)
1127
- return value === key ? String(id || '') : value
1181
+ /*
1182
+ * [1.12.0][D-09] 未知部门不再回显原文。
1183
+ *
1184
+ * 计划/回放里的非法值(拼错、旧版本、注入文本)不能成为面板分组标题
1185
+ * 或任务行文案。语言表缺键时统一显示「未知部门 / Unknown」,原文只
1186
+ * 留在服务端记录里供审计。
1187
+ */
1188
+ return value === key ? t('dept.unknown') : value
1128
1189
  }
1129
1190
 
1130
1191
  /*
@@ -2067,11 +2128,171 @@ window.__ModuleLoader__.load({
2067
2128
  )
2068
2129
  }
2069
2130
 
2070
- // 展开后的「分步进度」:逐阶段行 + 总体进度(与环/组头同一个计数口径)。
2071
- function PlanOverview({ t, stats, counts, rows }: { t: (key: string) => string; stats: any; counts: PlanCounts; rows: PlanStageRow[] }) {
2072
- const stateOf = (tone: PlanTone): string => (tone === 'done'
2131
+ /*
2132
+ * [1.12.0] 「分步进度」每一步的展开状态。
2133
+ *
2134
+ * 默认不展开;只有用户亲手点开/收起的步骤才写进 localStorage
2135
+ * (存的是「已展开的步骤 id」集合,而不是布尔值数组,新增步骤天然收起)。
2136
+ * 读不到 localStorage(隐私模式、旧 WebView、测试环境)时退回纯内存状态,
2137
+ * 不让存储失败影响交互。轮询刷新、重渲染、状态回放都不会改动这份状态。
2138
+ */
2139
+ const PLANROW_STORAGE_PREFIX = 'dsh-workplan:planrow-open:v1'
2140
+
2141
+ function planRowStorageKey(sessionId: any): string {
2142
+ return `${PLANROW_STORAGE_PREFIX}:${String(sessionId ?? '')}`
2143
+ }
2144
+
2145
+ function readPlanRowOpen(sessionId: any): string[] {
2146
+ try {
2147
+ const storage = typeof window !== 'undefined' ? window.localStorage : undefined
2148
+ if (!storage || typeof storage.getItem !== 'function') return []
2149
+ const raw = storage.getItem(planRowStorageKey(sessionId))
2150
+ if (!raw) return []
2151
+ const parsed = JSON.parse(raw)
2152
+ if (!Array.isArray(parsed)) return []
2153
+ return Array.from(new Set(parsed.filter((id: any) => typeof id === 'string' && id !== '')))
2154
+ } catch {
2155
+ return []
2156
+ }
2157
+ }
2158
+
2159
+ function writePlanRowOpen(sessionId: any, ids: string[]): void {
2160
+ try {
2161
+ const storage = typeof window !== 'undefined' ? window.localStorage : undefined
2162
+ if (!storage || typeof storage.setItem !== 'function') return
2163
+ storage.setItem(planRowStorageKey(sessionId), JSON.stringify(ids))
2164
+ } catch {
2165
+ // 配额已满或存储被禁用:保留内存状态,不影响本次交互。
2166
+ }
2167
+ }
2168
+
2169
+ function planRowDomId(sessionId: any, rowId: any): string {
2170
+ const safe = `${String(sessionId ?? '')}-${String(rowId ?? '')}`.replace(/[^A-Za-z0-9_-]+/g, '-')
2171
+ return `dsh-wp-planrow-${safe}`
2172
+ }
2173
+
2174
+ function planStepStateText(t: (key: string) => string, tone: PlanTone): string {
2175
+ return tone === 'done'
2073
2176
  ? t('stats.done')
2074
- : tone === 'active' ? t('stats.inProgress') : tone === 'blocked' ? t('stats.blocked') : t('stats.pending'))
2177
+ : tone === 'active' ? t('stats.inProgress') : tone === 'blocked' ? t('stats.blocked') : t('stats.pending')
2178
+ }
2179
+
2180
+ function planTaskStatus(value: any): string {
2181
+ return value === 'done' || value === 'in_progress' || value === 'blocked' ? value : 'pending'
2182
+ }
2183
+
2184
+ /*
2185
+ * 收起态与截图逐项一致:状态点、第 N 步:名称、进度条、done/total、状态词,
2186
+ * 只多一个折叠箭头。展开态放「该步摘要」(目标、检查点、子任务状态);
2187
+ * 完整明细仍由下方的阶段卡承担,避免 D-6 未拍板时出现两份完全相同的详情。
2188
+ */
2189
+ function PlanStepRow({
2190
+ t, row, stage, statuses, open, onToggle, panelId,
2191
+ }: {
2192
+ t: (key: string) => string
2193
+ row: PlanStageRow
2194
+ stage: any
2195
+ statuses: any
2196
+ open: boolean
2197
+ onToggle: (next: boolean) => void
2198
+ panelId: string
2199
+ }) {
2200
+ const width = row.total > 0 ? (row.done / row.total) * 100 : 0
2201
+ const stop = (event: any) => {
2202
+ if (event && typeof event.stopPropagation === 'function') event.stopPropagation()
2203
+ }
2204
+ const handleClick = (event: any) => {
2205
+ stop(event)
2206
+ onToggle(!open)
2207
+ }
2208
+ const handleKeyDown = (event: any) => {
2209
+ const key = event?.key
2210
+ // 原生 button 已经把 Enter/Space 变成 click;这里只阻止按键冒泡到外层卡片。
2211
+ if (key === 'Enter' || key === ' ' || key === 'Spacebar') stop(event)
2212
+ }
2213
+ const byId = new Map<string, any>()
2214
+ for (const item of Array.isArray(statuses) ? statuses : []) {
2215
+ if (item && item.subtaskId != null) byId.set(String(item.subtaskId), item)
2216
+ }
2217
+ const subtasks = (Array.isArray(stage?.subtasks) ? stage.subtasks : [])
2218
+ .filter((subtask: any) => !subtask?.supersededAt)
2219
+ return h('section', {
2220
+ className: 'dsh-wp-planrow',
2221
+ 'data-tone': row.tone,
2222
+ 'data-current': row.current ? 'true' : 'false',
2223
+ 'data-open': open ? 'true' : 'false',
2224
+ },
2225
+ h('button', {
2226
+ type: 'button',
2227
+ className: 'dsh-wp-planrow-toggle',
2228
+ 'aria-expanded': open,
2229
+ 'aria-controls': panelId,
2230
+ onClick: handleClick,
2231
+ onKeyDown: handleKeyDown,
2232
+ },
2233
+ h('span', { className: 'dsh-wp-planrow-chevron', 'aria-hidden': 'true' }),
2234
+ h('span', { className: 'dsh-wp-planrow-dot', 'aria-hidden': 'true' }),
2235
+ h('span', { className: 'dsh-wp-planrow-name' }, `${stageLabel(t, row.index)}:${row.name}`),
2236
+ h('span', { className: 'dsh-wp-planrow-bar' },
2237
+ h('span', {
2238
+ className: 'dsh-wp-planrow-fill',
2239
+ 'data-width': String(Math.round(width)),
2240
+ style: { width: `${width}%` },
2241
+ }),
2242
+ ),
2243
+ h('span', { className: 'dsh-wp-planrow-count' }, `${row.done}/${row.total}`),
2244
+ h('span', { className: 'dsh-wp-planrow-state' }, planStepStateText(t, row.tone)),
2245
+ ),
2246
+ h('div', { id: panelId, className: 'dsh-wp-planrow-panel', hidden: !open },
2247
+ h('div', { className: 'dsh-wp-planrow-detail' },
2248
+ stage?.goal
2249
+ ? h('div', { className: 'dsh-wp-planrow-goal' },
2250
+ h('strong', null, `${t('what')}:`), String(stage.goal))
2251
+ : null,
2252
+ stage?.checkpoint
2253
+ ? h('div', { className: 'dsh-wp-planrow-checkpoint' },
2254
+ h('strong', null, `${t('checkpoint')}:`), String(stage.checkpoint))
2255
+ : null,
2256
+ subtasks.length
2257
+ ? h('ul', { className: 'dsh-wp-planrow-tasks' },
2258
+ subtasks.map((subtask: any, index: number) => {
2259
+ const status = planTaskStatus(byId.get(String(subtask?.id))?.status)
2260
+ return h('li', {
2261
+ key: String(subtask?.id ?? index),
2262
+ className: 'dsh-wp-planrow-task',
2263
+ 'data-status': status,
2264
+ },
2265
+ h('span', { className: 'dsh-wp-planrow-task-dot', 'aria-hidden': 'true' }),
2266
+ h('span', { className: 'dsh-wp-planrow-task-title' }, `${t('workPrefix')} ${index + 1}:${String(subtask?.title ?? '')}`),
2267
+ h('span', { className: 'dsh-wp-planrow-task-dept' }, deptName(t, subtask?.department)),
2268
+ h('span', { className: 'dsh-wp-planrow-task-state' }, t(`status.${status}`)),
2269
+ )
2270
+ }),
2271
+ )
2272
+ : null,
2273
+ ),
2274
+ ),
2275
+ )
2276
+ }
2277
+
2278
+ // 展开后的「分步进度」:逐阶段行 + 总体进度(与环/组头同一个计数口径)。
2279
+ function PlanOverview({
2280
+ t, stats, counts, rows, stages, statuses, sessionId, openRows, onToggleRow,
2281
+ }: {
2282
+ t: (key: string) => string
2283
+ stats: any
2284
+ counts: PlanCounts
2285
+ rows: PlanStageRow[]
2286
+ stages: any
2287
+ statuses: any
2288
+ sessionId: any
2289
+ openRows: string[]
2290
+ onToggleRow: (rowId: string, next: boolean) => void
2291
+ }) {
2292
+ const stagesById = new Map<string, any>()
2293
+ for (const stage of Array.isArray(stages) ? stages : []) {
2294
+ if (stage?.id != null) stagesById.set(String(stage.id), stage)
2295
+ }
2075
2296
  return h('div', {
2076
2297
  className: 'dsh-wp-planoverview',
2077
2298
  'data-plan-total': String(counts.total),
@@ -2097,25 +2318,17 @@ window.__ModuleLoader__.load({
2097
2318
  rows.length
2098
2319
  ? h('div', { className: 'dsh-wp-planrows' },
2099
2320
  rows.map((row) => {
2100
- const width = row.total > 0 ? (row.done / row.total) * 100 : 0
2101
- return h('div', {
2321
+ const panelId = `${planRowDomId(sessionId, row.id)}-panel`
2322
+ return h(PlanStepRow, {
2102
2323
  key: row.id,
2103
- className: 'dsh-wp-planrow',
2104
- 'data-tone': row.tone,
2105
- 'data-current': row.current ? 'true' : 'false',
2106
- },
2107
- h('span', { className: 'dsh-wp-planrow-dot', 'aria-hidden': 'true' }),
2108
- h('span', { className: 'dsh-wp-planrow-name' }, `${stageLabel(t, row.index)}:${row.name}`),
2109
- h('span', { className: 'dsh-wp-planrow-bar' },
2110
- h('span', {
2111
- className: 'dsh-wp-planrow-fill',
2112
- 'data-width': String(Math.round(width)),
2113
- style: { width: `${width}%` },
2114
- }),
2115
- ),
2116
- h('span', { className: 'dsh-wp-planrow-count' }, `${row.done}/${row.total}`),
2117
- h('span', { className: 'dsh-wp-planrow-state' }, stateOf(row.tone)),
2118
- )
2324
+ t,
2325
+ row,
2326
+ stage: stagesById.get(String(row.id)),
2327
+ statuses,
2328
+ open: openRows.includes(row.id),
2329
+ onToggle: (next: boolean) => onToggleRow(row.id, next),
2330
+ panelId,
2331
+ })
2119
2332
  }),
2120
2333
  )
2121
2334
  : null,
@@ -2124,6 +2337,19 @@ window.__ModuleLoader__.load({
2124
2337
 
2125
2338
  function SessionCard({ session, t, open, onToggle }: any) {
2126
2339
  const domId = `dsh-wp-session-${session.sessionId}`
2340
+ /*
2341
+ * [1.12.0] 受控状态:展开哪几步只由这里决定,初始值只来自 localStorage
2342
+ * (默认空集)。不按「当前步骤」或进度自动展开,也不在数据更新时重置;
2343
+ * 卡片收起再展开时,PlanOverview 重新挂载也拿得到同一份选择。
2344
+ */
2345
+ const [openPlanRows, setOpenPlanRows] = useState(() => readPlanRowOpen(session.sessionId))
2346
+ const togglePlanRow = (rowId: string, next: boolean) => {
2347
+ const nextOpen = next
2348
+ ? [...openPlanRows.filter((id: string) => id !== rowId), rowId]
2349
+ : openPlanRows.filter((id: string) => id !== rowId)
2350
+ setOpenPlanRows(nextOpen)
2351
+ writePlanRowOpen(session.sessionId, nextOpen)
2352
+ }
2127
2353
  const stats = session.stats || {}
2128
2354
  // 1.5.0:折叠卡摘要=图表(环 + 百分比 + 四段构成条 + 图例 + 阶段步进条);
2129
2355
  // 数字仍只来自 session.stats,与旧头部的口径完全一致,不引入第二套统计。
@@ -2153,7 +2379,17 @@ window.__ModuleLoader__.load({
2153
2379
  session.updatedAt
2154
2380
  ? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
2155
2381
  : null,
2156
- open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null,
2382
+ open === true ? h(PlanOverview, {
2383
+ t,
2384
+ stats,
2385
+ counts,
2386
+ rows: stageRows,
2387
+ stages: session.stages,
2388
+ statuses,
2389
+ sessionId: session.sessionId,
2390
+ openRows: openPlanRows,
2391
+ onToggleRow: togglePlanRow,
2392
+ }) : null,
2157
2393
  session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' },
2158
2394
  h('strong', null, t('degraded')),
2159
2395
  h('div', null, plainError(session.error || '')),