@v587d/capital-generation 2.16.1 → 2.17.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.
@@ -80,12 +80,121 @@ const TITLE_MAX_LENGTH = 12
80
80
  const DESCRIPTION_MAX_LENGTH = 100
81
81
  const INSTRUCTION_MAX_LENGTH = 12_000
82
82
  const AUTOSAVE_DELAY_MS = 600
83
+ const BOARD_UI_KEY = 'capital-automation:board-ui:v3'
84
+ const BOARD_PANEL_KEYS = ['todo', 'stocks', 'gaps', 'health']
85
+ const BOARD_TODO_PERIODS = ['today', 'tomorrow', 'week', 'later', 'nodate', 'expired']
86
+ const BOARD_PANEL_IDS = {
87
+ 'capital-automation-todo': 'todo',
88
+ 'capital-automation-stocks': 'stocks',
89
+ 'capital-automation-gaps': 'gaps',
90
+ 'capital-automation-health': 'health',
91
+ }
83
92
 
84
93
  const zh = {
85
94
  panel: 'CapGen 投研自动化',
86
95
  title: 'CapGen 投研自动化',
87
96
  subtitle: '定时投研,自动执行,结果可追溯',
88
- tabs: { tasks: '任务', runs: '运行' },
97
+ tabs: { board: '看板', tasks: '任务', runs: '运行' },
98
+ board: {
99
+ emptyTitle: '还没有任务简报',
100
+ emptyHint: '在任务页点任务右侧的「运行」,跑完回来看板。',
101
+ goTasks: '去任务页运行',
102
+ goEnable: '去启用任务',
103
+ newTask: '新建任务',
104
+ statsBriefs: '本期简报',
105
+ statsTodos: 'TODO',
106
+ statsStocks: '标的',
107
+ statsGaps: '缺口',
108
+ statsIssues: '近 7 天异常',
109
+ refresh: '刷新',
110
+ range: '时间范围',
111
+ range7: '最近 7 天',
112
+ range14: '最近 14 天',
113
+ range30: '最近 30 天',
114
+ rangeAll: '全部',
115
+ category: '分类',
116
+ allCategories: '全部',
117
+ briefTitle: '任务简报',
118
+ todoTitle: 'TODO',
119
+ hideRail: '收起右侧',
120
+ showRail: '展开右侧',
121
+ collapse: '收起',
122
+ expand: '展开',
123
+ briefPending: '正在生成任务简报…',
124
+ briefFailed: '任务简报生成失败',
125
+ briefSkipped: '这次运行没有可简报的结论',
126
+ retry: '重试',
127
+ retryQueued: '已重新提交任务简报',
128
+ aiBadge: 'AI 简报',
129
+ partial: '原文过长,已取头尾',
130
+ stocksCount: '{n} 个标的',
131
+ gapsCount: '{n} 个缺口',
132
+ todoConfirm: '待确认',
133
+ todoVerify: '待验证',
134
+ todoTrack: '跟踪',
135
+ todoEmpty: '最近运行没有明确提出待验证项',
136
+ todoEmptyGroup: '「{label}」没有待办',
137
+ todoFilterAll: '全部',
138
+ todoFilterLabel: '按日期筛选',
139
+ dueToday: '今天',
140
+ dueTomorrow: '明天',
141
+ dueThisWeek: '本周',
142
+ dueLater: '以后',
143
+ dueNoDate: '未定',
144
+ dueExpired: '已过期',
145
+ showBasis: '查看依据',
146
+ hideBasis: '收起依据',
147
+ seenCount: '{n} 次运行提到',
148
+ sourceRun: '来源',
149
+ stockEmpty: '最近运行没有提到自选股',
150
+ stockOther: '其他事件 {n} 只',
151
+ stockTodoCount: '{n} 项待办',
152
+ roleHolding: '持仓',
153
+ roleWatch: '关注',
154
+ roleEvent: '事件',
155
+ roleRisk: '风险',
156
+ gapEmpty: '最近运行没有报告数据缺口',
157
+ gapCapability: '能力缺口',
158
+ gapTransient: '本次未取到',
159
+ gapConflict: '口径冲突',
160
+ gapQuality: '数据质量',
161
+ gapSeen: '{n} 次运行',
162
+ gapAll: '查看全部',
163
+ healthTitle: '运行健康',
164
+ healthWindow: '最近 7 天',
165
+ healthRuns: '运行',
166
+ healthBriefs: '简报状态',
167
+ healthScheduler: '调度器',
168
+ healthSchedulerOk: '正常',
169
+ healthSchedulerStandby: '本窗口待命',
170
+ healthSchedulerBad: '不可用',
171
+ healthCalendar: '交易日历',
172
+ healthIssues: '异常',
173
+ healthNoIssues: '最近 7 天没有异常运行',
174
+ healthViewRuns: '查看运行',
175
+ healthSucceeded: '成功',
176
+ healthFailed: '失败',
177
+ healthTimeout: '超时',
178
+ healthMissed: '错过',
179
+ healthUnknown: '中断/未知',
180
+ healthBlocked: '需确认',
181
+ healthActive: '进行中',
182
+ healthBriefReady: '完成',
183
+ healthBriefPending: '生成中',
184
+ healthBriefFailed: '失败',
185
+ healthBriefSkipped: '跳过',
186
+ healthNoBrief: '没有已入队简报',
187
+ healthRecovered: '已补跑',
188
+ healthOpen: '打开 session',
189
+ healthCalendarOk: '正常',
190
+ healthCalendarBad: '不可用',
191
+ loadError: '看板暂时不可用',
192
+ rangeEmpty: '最近 14 天没有任务简报',
193
+ viewAll: '查看全部时间',
194
+ loadMore: '加载更早的简报',
195
+ clearFilter: '清除筛选',
196
+ categoryEmpty: '没有符合筛选的任务简报',
197
+ },
89
198
  storageUnavailable: '存储不可用,页面只读',
90
199
  standbyBanner: '本窗口的定时任务已暂停:定时触发与手动运行不可用;若另一个 CapGen 窗口在运行,定时任务仍会由它执行。',
91
200
  storageBanner: '投研自动化存储暂时不可用:页面只读,调度器不会启动。',
@@ -609,6 +718,7 @@ function installStyles() {
609
718
  .capital-automation-panelhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
610
719
  .capital-automation-panelhead h3 { margin: 0; font-size: 13.5px; line-height: 20px; font-weight: 600; }
611
720
  .capital-automation-panelhead .capital-automation-btn { margin-left: auto; }
721
+ .capital-automation-panelhead .capital-automation-select { margin-left: auto; }
612
722
  .capital-automation-panelhead .capital-automation-btn[data-variant="ghost"] { padding-right: 0; }
613
723
  .capital-automation-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
614
724
  .capital-automation-kvitem { min-width: 0; }
@@ -837,6 +947,125 @@ function installStyles() {
837
947
  .capital-automation-heroactions { padding-left: 0; }
838
948
  .capital-automation-modal-content { max-height: calc(100dvh - 112px); }
839
949
  }
950
+
951
+ .capital-automation-board { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
952
+ .capital-automation-boardtoolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
953
+ .capital-automation-boardtools { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
954
+ .capital-automation-boardactions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-left: auto; }
955
+ .capital-automation-boardstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
956
+ .capital-automation-boardstat { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 62px; padding: 10px 12px; border: .5px solid var(--ca-line); border-radius: 12px; background: var(--ca-card); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background .15s, border-color .15s; }
957
+ .capital-automation-boardstat:hover { background: color-mix(in srgb, var(--ca-hover) 58%, var(--ca-card)); border-color: color-mix(in srgb, var(--ca-business) 24%, var(--ca-line)); }
958
+ .capital-automation-boardstat:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 1px; }
959
+ .capital-automation-boardstatlabel { color: var(--ca-muted); font-size: 11.5px; line-height: 17px; }
960
+ .capital-automation-boardstat strong { color: var(--dsw-alias-label-primary); font-size: 18px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
961
+ .capital-automation-boardgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); align-items: start; gap: 20px; min-width: 0; }
962
+ .capital-automation-boardgrid[data-rail="closed"] { grid-template-columns: minmax(0, 1fr); }
963
+ .capital-automation-boardmain { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
964
+ .capital-automation-briefcard { box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 13px; border: .5px solid var(--ca-line); border-radius: 16px; background: var(--ca-card); min-width: 0; }
965
+ .capital-automation-briefhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px 14px; }
966
+ .capital-automation-brieftitle { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; min-width: 0; }
967
+ .capital-automation-brieftitle h3 { margin: 0; color: var(--dsw-alias-label-primary); font-size: 13.5px; line-height: 20px; font-weight: 600; overflow-wrap: anywhere; }
968
+ .capital-automation-brieftime { color: var(--ca-caption); font-size: 11.5px; line-height: 18px; font-variant-numeric: tabular-nums; }
969
+ .capital-automation-briefcard h4 { margin: 0; color: var(--dsw-alias-label-primary); font-size: 18px; line-height: 27px; font-weight: 600; letter-spacing: .1px; overflow-wrap: anywhere; }
970
+ .capital-automation-brieftext { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 14px; line-height: 1.68; overflow-wrap: anywhere; }
971
+ .capital-automation-briefmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; color: var(--ca-caption); font-size: 11.5px; line-height: 18px; }
972
+ .capital-automation-briefpartial { color: var(--ca-warn-text); }
973
+ .capital-automation-briefai { color: var(--ca-business-text); font-weight: 500; }
974
+ .capital-automation-briefstate { display: flex; flex-direction: column; gap: 7px; color: var(--ca-muted); font-size: 12.5px; line-height: 19px; }
975
+ .capital-automation-briefstate[data-tone="error"] { color: var(--ca-error-text); }
976
+ .capital-automation-briefstate p { margin: 0; }
977
+ .capital-automation-briefactions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 2px; }
978
+ .capital-automation-boardrail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
979
+ .capital-automation-boardrail[hidden] { display: none; }
980
+ .capital-automation-boardrail .capital-automation-panel { min-width: 0; }
981
+ .capital-automation-boardrail .capital-automation-panelhead { margin-bottom: 8px; }
982
+ .capital-automation-boardrail .capital-automation-panel[data-collapsed="true"] { padding-bottom: 13px; }
983
+ .capital-automation-boardrail .capital-automation-panel[data-collapsed="true"] .capital-automation-panelhead { margin-bottom: 0; }
984
+ .capital-automation-paneltoggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
985
+ .capital-automation-paneltoggle:hover { color: var(--dsw-alias-label-primary); }
986
+ .capital-automation-paneltoggle:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 3px; border-radius: 4px; }
987
+ .capital-automation-panelchevron { flex: none; color: var(--ca-caption); transition: transform .15s; }
988
+ .capital-automation-panelchevron[data-open="false"] { transform: rotate(-90deg); }
989
+ .capital-automation-panelbody[hidden] { display: none; }
990
+ .capital-automation-boardempty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; min-height: min(440px, calc(100dvh - 260px)); padding: 44px 24px; border: .5px dashed var(--ca-line); border-radius: 20px; background: var(--ca-card); color: var(--ca-muted); text-align: center; }
991
+ .capital-automation-boardemptyicon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--ca-business) 12%, var(--ca-card)); color: var(--ca-business-text); }
992
+ .capital-automation-boardempty h2 { margin: 3px 0 0; color: var(--dsw-alias-label-primary); font-size: 20px; line-height: 28px; font-weight: 600; }
993
+ .capital-automation-boardempty p { max-width: 520px; margin: 0; font-size: 13px; line-height: 20px; }
994
+ .capital-automation-boardemptyhint { color: var(--ca-caption); font-size: 11.5px !important; line-height: 18px !important; }
995
+ .capital-automation-boardemptyactions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
996
+ .capital-automation-todolist, .capital-automation-stocktodos, .capital-automation-gaplist, .capital-automation-gaprow { list-style: none; margin: 0; padding: 0; }
997
+ .capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); }
998
+ .capital-automation-todoitem:first-child { border-top: 0; }
999
+ .capital-automation-todoline { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
1000
+ .capital-automation-todokind { display: inline-flex; flex: none; align-items: center; justify-content: center; min-height: 20px; padding: 0 5px; border-radius: 5px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10px; line-height: 20px; white-space: nowrap; }
1001
+ .capital-automation-todokind[data-kind="confirm"] { color: var(--ca-warn-text); }
1002
+ .capital-automation-todokind[data-kind="verify"] { color: var(--ca-business-text); }
1003
+ .capital-automation-todokind[data-kind="track"] { color: var(--ca-success-text); }
1004
+ .capital-automation-todotitle { flex: 1 1 auto; min-width: 0; padding: 0; border: 0; background: transparent; font: inherit; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
1005
+ .capital-automation-todotitle:hover, .capital-automation-gaptitle:hover { color: var(--ca-business-text); }
1006
+ .capital-automation-todotitle:focus-visible, .capital-automation-gaptitle:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; border-radius: 4px; }
1007
+ .capital-automation-basiscaret { display: inline-flex; align-items: center; margin-left: 4px; color: var(--ca-muted); vertical-align: -2px; transform: rotate(-90deg); transition: transform .16s ease; }
1008
+ .capital-automation-todotitle[aria-expanded="true"] .capital-automation-basiscaret, .capital-automation-gaptitle[aria-expanded="true"] .capital-automation-basiscaret { transform: rotate(0deg); }
1009
+ .capital-automation-tododesc { margin: 3px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
1010
+ .capital-automation-todometa { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; color: var(--ca-caption); font-size: 11px; line-height: 17px; }
1011
+ .capital-automation-tododetail { margin: 6px 0 0; padding: 7px 9px; border-left: 2px solid var(--ca-line); background: var(--ca-field); border-radius: 0 7px 7px 0; }
1012
+ .capital-automation-tododetail blockquote { margin: 0; color: var(--ca-muted); font-size: 11.5px; line-height: 19px; overflow-wrap: anywhere; }
1013
+ .capital-automation-todosource { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 8px; margin-top: 5px; color: var(--ca-caption); font-size: 11px; line-height: 17px; }
1014
+ .capital-automation-stockrow { border-top: .5px solid var(--ca-line); }
1015
+ .capital-automation-stockrow:first-of-type { border-top: 0; }
1016
+ .capital-automation-stockmain { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 7px; width: 100%; padding: 8px 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
1017
+ .capital-automation-stockmain:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: -2px; }
1018
+ .capital-automation-stockname { color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 19px; font-weight: 600; }
1019
+ .capital-automation-stockcode { color: var(--ca-caption); font-size: 11px; line-height: 17px; }
1020
+ .capital-automation-stockroles { display: inline-flex; flex-wrap: wrap; gap: 3px; }
1021
+ .capital-automation-stockrole { display: inline-flex; align-items: center; padding: 0 5px; border-radius: 4px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10px; line-height: 17px; }
1022
+ .capital-automation-stockrole[data-role="holding"] { color: var(--ca-success-text); }
1023
+ .capital-automation-stockrole[data-role="risk"] { color: var(--ca-error-text); }
1024
+ .capital-automation-stockrole[data-role="event"] { color: var(--ca-warn-text); }
1025
+ .capital-automation-stocknote { flex: 1 1 100%; color: var(--ca-muted); font-size: 12px; line-height: 19px; overflow-wrap: anywhere; }
1026
+ .capital-automation-stockmeta { display: flex; flex-wrap: wrap; gap: 4px 9px; color: var(--ca-caption); font-size: 11px; line-height: 17px; }
1027
+ .capital-automation-stocktodos { margin: 0 0 7px; padding: 0 0 0 8px; border-left: 2px solid var(--ca-line); }
1028
+ .capital-automation-stocktodos li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 3px 0; color: var(--ca-muted); font-size: 11.5px; line-height: 18px; }
1029
+ .capital-automation-gaprow { padding: 8px 0; border-top: .5px solid var(--ca-line); }
1030
+ .capital-automation-gaprow:first-child { border-top: 0; }
1031
+ .capital-automation-gaphead { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
1032
+ .capital-automation-gapkind { display: inline-flex; flex: none; align-items: center; justify-content: center; min-height: 20px; padding: 0 5px; border-radius: 5px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10px; line-height: 20px; white-space: nowrap; }
1033
+ .capital-automation-gapkind[data-kind="capability"] { color: var(--ca-warn-text); }
1034
+ .capital-automation-gapkind[data-kind="conflict"] { color: var(--ca-error-text); }
1035
+ .capital-automation-gapkind[data-kind="quality"] { color: var(--ca-warn-text); }
1036
+ .capital-automation-gaptitle { flex: 1 1 auto; min-width: 0; padding: 0; border: 0; background: transparent; font: inherit; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px; font-weight: 600; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
1037
+ .capital-automation-gapdesc { margin: 3px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
1038
+ .capital-automation-healthgrid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
1039
+ .capital-automation-healthkey { color: var(--ca-caption); font-size: 11.5px; line-height: 19px; }
1040
+ .capital-automation-healthval { color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 19px; overflow-wrap: anywhere; }
1041
+ .capital-automation-healthval[data-tone="warn"] { color: var(--ca-warn-text); }
1042
+ .capital-automation-healthval[data-tone="bad"] { color: var(--ca-error-text); }
1043
+ .capital-automation-healthempty { margin: 9px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 19px; }
1044
+ .capital-automation-healthissues { list-style: none; margin: 10px 0 0; padding: 0; border-top: .5px solid var(--ca-line); }
1045
+ .capital-automation-healthissues li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 7px 0; border-bottom: .5px solid var(--ca-line); color: var(--ca-muted); font-size: 12px; line-height: 19px; }
1046
+ .capital-automation-healthissues li:last-child { border-bottom: 0; }
1047
+ .capital-automation-healthissue { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
1048
+ .capital-automation-healthissuetitle { color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 19px; font-weight: 600; }
1049
+ .capital-automation-healthissuestatus { font-size: 11px; line-height: 17px; }
1050
+ .capital-automation-healthissuestatus[data-tone="bad"], .capital-automation-statusdot[data-tone="bad"] { color: var(--ca-error-text); }
1051
+ .capital-automation-healthissuestatus[data-tone="warn"], .capital-automation-statusdot[data-tone="warn"] { color: var(--ca-warn-text); }
1052
+ .capital-automation-healthrecovered { color: var(--ca-success-text); font-size: 11px; line-height: 17px; }
1053
+ .capital-automation-board .capital-automation-tag { font-size: 10px; line-height: 16px; }
1054
+ .capital-automation-boardmore { align-self: center; margin: 2px 0 6px; }
1055
+ @media (max-width: 860px) {
1056
+ .capital-automation-boardgrid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
1057
+ .capital-automation-boardrail { order: 2; }
1058
+ .capital-automation-boardstats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
1059
+ }
1060
+ @media (max-width: 560px) {
1061
+ .capital-automation-boardtoolbar { align-items: flex-start; }
1062
+ .capital-automation-boardstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1063
+ .capital-automation-boardempty { min-height: 320px; padding: 32px 16px; }
1064
+ .capital-automation-briefcard { padding: 14px 14px 12px; }
1065
+ .capital-automation-briefcard h4 { font-size: 17px; line-height: 25px; }
1066
+ .capital-automation-briefhead { grid-template-columns: minmax(0, 1fr); }
1067
+ .capital-automation-briefhead > .capital-automation-btn { justify-self: start; }
1068
+ }
840
1069
  `
841
1070
  document.head.appendChild(style)
842
1071
  return () => style.remove()
@@ -884,6 +1113,8 @@ function createApi() {
884
1113
  cancel: (id) => request(`/runs/${encodeURIComponent(id)}/cancel`, { method: 'POST' }),
885
1114
  runs: (query = '') => request(`/runs${query}`),
886
1115
  history: (query = '') => request(`/runs/history${query}`),
1116
+ board: (query = '') => request(`/board${query}`),
1117
+ retryBrief: (runId) => request(`/board/briefs/${encodeURIComponent(runId)}/retry`, { method: 'POST' }),
887
1118
  notifications: () => request('/notifications'),
888
1119
  markRead: (body) => request('/notifications/read', { method: 'POST', body }),
889
1120
  }
@@ -1825,7 +2056,7 @@ function Header(props) {
1825
2056
  h('span', { className: 'capital-automation-brandmark', 'aria-hidden': 'true' }, h(IconChecklistOutlineRegular, { size: 16 })),
1826
2057
  h('h1', null, zh.title)),
1827
2058
  h('div', { className: 'capital-automation-tabs', role: 'tablist', 'aria-label': zh.title },
1828
- ['tasks', 'runs'].map((value) => h('button', {
2059
+ ['board', 'tasks', 'runs'].map((value) => h('button', {
1829
2060
  key: value,
1830
2061
  type: 'button',
1831
2062
  role: 'tab',
@@ -3609,6 +3840,727 @@ function browserTimeZone() {
3609
3840
  }
3610
3841
  }
3611
3842
 
3843
+ function boardRelativeTime(value, now = Date.now()) {
3844
+ const date = new Date(value)
3845
+ if (Number.isNaN(date.getTime())) return ''
3846
+ const diff = Math.max(0, now - date.getTime())
3847
+ const minute = 60_000
3848
+ const hour = 60 * minute
3849
+ const day = 24 * hour
3850
+ const week = 7 * day
3851
+ const month = 30 * day
3852
+ const year = 365 * day
3853
+ if (diff < minute) return zh.relativeNow
3854
+ if (diff < hour) return `${Math.floor(diff / minute)}分钟前`
3855
+ if (diff < day) return `${Math.floor(diff / hour)}小时前`
3856
+ if (diff < week) return `${Math.floor(diff / day)}天前`
3857
+ if (diff < month) return `${Math.floor(diff / week)}周前`
3858
+ if (diff < year) return `${Math.floor(diff / month)}个月前`
3859
+ return `${Math.floor(diff / year)}年前`
3860
+ }
3861
+
3862
+ function boardTodoPeriod(item) {
3863
+ if (typeof item.dueAt !== 'string' || item.dueAt.length === 0) return 'nodate'
3864
+ const today = localDateKey(new Date())
3865
+ if (item.dueAt < today) return 'expired'
3866
+ if (item.dueAt === today) return 'today'
3867
+ const tomorrow = localDateKey(addLocalDays(new Date(), 1))
3868
+ if (item.dueAt === tomorrow) return 'tomorrow'
3869
+ const week = localDateKey(addLocalDays(new Date(), 7))
3870
+ return item.dueAt <= week ? 'week' : 'later'
3871
+ }
3872
+
3873
+ function boardTodoGroupLabel(period) {
3874
+ if (period === 'all') return zh.board.todoFilterAll
3875
+ if (period === 'today') return zh.board.dueToday
3876
+ if (period === 'tomorrow') return zh.board.dueTomorrow
3877
+ if (period === 'week') return zh.board.dueThisWeek
3878
+ if (period === 'later') return zh.board.dueLater
3879
+ if (period === 'expired') return zh.board.dueExpired
3880
+ return zh.board.dueNoDate
3881
+ }
3882
+
3883
+ function boardTodoFilterOptions() {
3884
+ return ['all'].concat(BOARD_TODO_PERIODS).map((period) => ({ value: period, label: boardTodoGroupLabel(period) }))
3885
+ }
3886
+
3887
+ function boardTodoDueLabel(item, period) {
3888
+ const note = typeof item.dueAt === 'string' && item.dueAt.length >= 10 ? item.dueAt.slice(5) : (item.dueLabel ?? '')
3889
+ if (period === 'today') return zh.board.dueToday
3890
+ if (period === 'tomorrow') return zh.board.dueTomorrow
3891
+ if (period === 'expired') return note ? `${zh.board.dueExpired} · ${note}` : zh.board.dueExpired
3892
+ if (period === 'nodate') return note || zh.board.dueNoDate
3893
+ return note
3894
+ }
3895
+
3896
+ function boardTodoKindLabel(kind) {
3897
+ if (kind === 'confirm') return zh.board.todoConfirm
3898
+ if (kind === 'verify') return zh.board.todoVerify
3899
+ return zh.board.todoTrack
3900
+ }
3901
+
3902
+ function boardCategoryOptions() {
3903
+ return [{ value: 'all', label: zh.board.allCategories }].concat(
3904
+ Object.entries(zh.category).map(([value, label]) => ({ value, label })),
3905
+ )
3906
+ }
3907
+
3908
+ function boardRangeOptions() {
3909
+ return [
3910
+ { value: '7', label: zh.board.range7 },
3911
+ { value: '14', label: zh.board.range14 },
3912
+ { value: '30', label: zh.board.range30 },
3913
+ { value: 'all', label: zh.board.rangeAll },
3914
+ ]
3915
+ }
3916
+
3917
+ function boardQueryOf(range, category, before) {
3918
+ const params = new URLSearchParams()
3919
+ params.set('days', range)
3920
+ params.set('tz', browserTimeZone())
3921
+ params.set('limit', '30')
3922
+ if (category !== 'all') params.set('category', category)
3923
+ if (typeof before === 'string' && before.length > 0) params.set('before', before)
3924
+ return `?${params.toString()}`
3925
+ }
3926
+
3927
+ function readBoardUi() {
3928
+ if (typeof localStorage === 'undefined') return {}
3929
+ try {
3930
+ const parsed = JSON.parse(localStorage.getItem(BOARD_UI_KEY) ?? '{}')
3931
+ return parsed !== null && typeof parsed === 'object' ? parsed : {}
3932
+ } catch {
3933
+ return {}
3934
+ }
3935
+ }
3936
+
3937
+ function saveBoardUi(patch) {
3938
+ if (typeof localStorage === 'undefined') return
3939
+ try {
3940
+ localStorage.setItem(BOARD_UI_KEY, JSON.stringify({ ...readBoardUi(), ...patch }))
3941
+ } catch {
3942
+ // A blocked localStorage must not break the board.
3943
+ }
3944
+ }
3945
+
3946
+ function boardPanelFlags(value) {
3947
+ const saved = value !== null && typeof value === 'object' ? value : null
3948
+ const flags = { todo: true, stocks: true, gaps: false, health: false }
3949
+ if (saved === null) return flags
3950
+ for (const key of BOARD_PANEL_KEYS) flags[key] = saved[key] === true
3951
+ return flags
3952
+ }
3953
+
3954
+ function boardPanelKey(id) {
3955
+ return BOARD_PANEL_IDS[id] ?? null
3956
+ }
3957
+
3958
+ function BoardEmpty(props) {
3959
+ const { hasActiveTasks, storageReady, onGoTasks, onNewTask } = props
3960
+ return h('section', { className: 'capital-automation-boardempty', 'aria-labelledby': 'capital-automation-boardempty-title' },
3961
+ h('span', { className: 'capital-automation-boardemptyicon', 'aria-hidden': 'true' }, h(IconSparkleRegular, { size: 22 })),
3962
+ h('h2', { id: 'capital-automation-boardempty-title' }, zh.board.emptyTitle),
3963
+ storageReady === false ? h('p', null, zh.storageBanner) : null,
3964
+ h('div', { className: 'capital-automation-boardemptyactions' },
3965
+ h('button', {
3966
+ type: 'button',
3967
+ className: 'capital-automation-btn',
3968
+ 'data-variant': 'primary',
3969
+ disabled: storageReady === false,
3970
+ onClick: onGoTasks,
3971
+ }, hasActiveTasks ? zh.board.goTasks : zh.board.goEnable),
3972
+ h('button', {
3973
+ type: 'button',
3974
+ className: 'capital-automation-btn',
3975
+ disabled: storageReady === false,
3976
+ onClick: onNewTask,
3977
+ }, zh.board.newTask)),
3978
+ h('p', { className: 'capital-automation-boardemptyhint' }, zh.board.emptyHint))
3979
+ }
3980
+
3981
+ function BoardStats(props) {
3982
+ const { stats, onJump } = props
3983
+ const items = [
3984
+ { id: 'capital-automation-briefs', label: zh.board.statsBriefs, value: stats?.briefs ?? 0 },
3985
+ { id: 'capital-automation-todo', label: zh.board.statsTodos, value: stats?.todos ?? 0 },
3986
+ { id: 'capital-automation-stocks', label: zh.board.statsStocks, value: stats?.stocks ?? 0 },
3987
+ { id: 'capital-automation-gaps', label: zh.board.statsGaps, value: stats?.gaps ?? 0 },
3988
+ { id: 'capital-automation-health', label: zh.board.statsIssues, value: stats?.issues7d ?? 0 },
3989
+ ]
3990
+ const jump = (id) => {
3991
+ if (typeof document === 'undefined') return
3992
+ const node = document.getElementById(id)
3993
+ if (node !== null && typeof node.scrollIntoView === 'function') node.scrollIntoView({ block: 'start', behavior: 'smooth' })
3994
+ }
3995
+ const activate = typeof onJump === 'function' ? onJump : jump
3996
+ return h('div', { className: 'capital-automation-boardstats', role: 'group', 'aria-label': zh.board.title },
3997
+ items.map((item) => h('button', {
3998
+ key: item.id,
3999
+ type: 'button',
4000
+ className: 'capital-automation-boardstat',
4001
+ onClick: () => activate(item.id),
4002
+ }, h('span', { className: 'capital-automation-boardstatlabel' }, item.label), h('strong', null, String(item.value)))))
4003
+ }
4004
+
4005
+ function BoardToolbar(props) {
4006
+ const { range, category, loading, onRange, onCategory, onRefresh, railOpen, onToggleRail } = props
4007
+ return h('div', { className: 'capital-automation-boardtoolbar' },
4008
+ h('div', { className: 'capital-automation-boardtools' },
4009
+ h(Select, {
4010
+ value: range,
4011
+ options: boardRangeOptions(),
4012
+ onChange: onRange,
4013
+ label: zh.board.range,
4014
+ size: 'sm',
4015
+ }),
4016
+ h(Select, {
4017
+ value: category,
4018
+ options: boardCategoryOptions(),
4019
+ onChange: onCategory,
4020
+ label: zh.board.category,
4021
+ size: 'sm',
4022
+ })),
4023
+ h('div', { className: 'capital-automation-boardactions' },
4024
+ h('button', {
4025
+ type: 'button',
4026
+ className: 'capital-automation-btn',
4027
+ 'data-size': 'sm',
4028
+ disabled: loading === true,
4029
+ onClick: onRefresh,
4030
+ title: zh.board.refresh,
4031
+ 'aria-label': zh.board.refresh,
4032
+ }, h(IconRefreshOutlineRegular, { size: 13 }), h('span', { className: 'capital-automation-btnlabel' }, zh.board.refresh)),
4033
+ h('button', {
4034
+ type: 'button',
4035
+ className: 'capital-automation-btn',
4036
+ 'data-size': 'sm',
4037
+ 'aria-expanded': railOpen === true ? 'true' : 'false',
4038
+ 'aria-controls': 'capital-automation-boardrail',
4039
+ onClick: onToggleRail,
4040
+ },
4041
+ h(railOpen === true ? IconChevronRightOutlineRegular : IconChevronLeftOutlineRegular, { size: 13 }),
4042
+ h('span', { className: 'capital-automation-btnlabel' }, railOpen === true ? zh.board.hideRail : zh.board.showRail))))
4043
+ }
4044
+
4045
+ function BriefCard(props) {
4046
+ const { card, onOpenSession, onRetry, retrying } = props
4047
+ const brief = card.brief
4048
+ const status = brief?.status ?? 'pending'
4049
+ const titleId = `capital-automation-brief-${card.runId}`
4050
+ const sessionId = card.sessionId
4051
+ const open = sessionId
4052
+ ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenSession(sessionId) }, zh.openSession)
4053
+ : null
4054
+ const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
4055
+ const relativeTime = boardRelativeTime(card.finishedAt)
4056
+ const exactTime = formatTime(card.finishedAt)
4057
+ let body
4058
+ if (status === 'ready') {
4059
+ body = h('div', null,
4060
+ h('h4', null, brief.headline),
4061
+ h('p', { className: 'capital-automation-brieftext' }, brief.plain),
4062
+ h('div', { className: 'capital-automation-briefmeta' },
4063
+ brief.coverage === 'partial' ? h('span', { className: 'capital-automation-briefpartial' }, zh.board.partial) : null,
4064
+ h('span', { className: 'capital-automation-briefai' }, zh.board.aiBadge)))
4065
+ } else if (status === 'failed') {
4066
+ body = h('div', { className: 'capital-automation-briefstate', 'data-tone': 'error' },
4067
+ h('p', null, zh.board.briefFailed),
4068
+ h('p', { className: 'capital-automation-hint' }, brief?.error ?? zh.errorGeneric),
4069
+ h('div', { className: 'capital-automation-briefactions' },
4070
+ h('button', {
4071
+ type: 'button',
4072
+ className: 'capital-automation-btn',
4073
+ 'data-size': 'sm',
4074
+ disabled: retrying === true,
4075
+ onClick: () => onRetry(card.runId),
4076
+ }, retrying === true ? zh.processing : zh.board.retry),
4077
+ open))
4078
+ } else if (status === 'skipped') {
4079
+ body = h('div', { className: 'capital-automation-briefstate' },
4080
+ h('p', null, zh.board.briefSkipped),
4081
+ h('div', { className: 'capital-automation-briefactions' }, open))
4082
+ } else {
4083
+ body = h('div', { className: 'capital-automation-briefstate' },
4084
+ h(SkeletonBlock, { width: '72%', height: 14 }),
4085
+ h(SkeletonBlock, { width: '100%', height: 10 }),
4086
+ h(SkeletonBlock, { width: '88%', height: 10 }),
4087
+ h('p', { className: 'capital-automation-hint' }, zh.board.briefPending))
4088
+ }
4089
+ return h('article', { className: 'capital-automation-briefcard', 'data-status': status, 'aria-labelledby': titleId },
4090
+ h('div', { className: 'capital-automation-briefhead' },
4091
+ h('div', { className: 'capital-automation-brieftitle' },
4092
+ h('h3', { id: titleId }, card.taskTitle),
4093
+ h('span', { className: 'capital-automation-tag', 'data-tone': card.category }, categoryLabel(card.category)),
4094
+ h('span', { className: 'capital-automation-tag' }, trigger),
4095
+ h('time', {
4096
+ className: 'capital-automation-brieftime',
4097
+ dateTime: card.finishedAt,
4098
+ title: exactTime,
4099
+ }, relativeTime)),
4100
+ open),
4101
+ body)
4102
+ }
4103
+
4104
+ function BoardSkeleton(props) {
4105
+ const { railOpen = false } = props
4106
+ return h('div', { className: 'capital-automation-loading', 'aria-busy': 'true' },
4107
+ h('span', { className: 'capital-automation-skeletonlabel', role: 'status', 'aria-live': 'polite' }, zh.loading),
4108
+ h('div', { className: 'capital-automation-board' },
4109
+ h('div', { className: 'capital-automation-boardtoolbar' },
4110
+ h('div', { className: 'capital-automation-boardtools' }, h(SkeletonBlock, { width: 82, height: 28, radius: 999 }), h(SkeletonBlock, { width: 72, height: 28, radius: 999 })),
4111
+ h('div', { className: 'capital-automation-boardactions' }, h(SkeletonBlock, { width: 58, height: 28, radius: 999 }), h(SkeletonBlock, { width: 84, height: 28, radius: 999 }))),
4112
+ h('div', { className: 'capital-automation-boardstats' },
4113
+ Array.from({ length: 5 }, (_, index) => h('div', { key: index, className: 'capital-automation-boardstat' }, h(SkeletonBlock, { width: 46, height: 9 }), h(SkeletonBlock, { width: 24, height: 16 })))),
4114
+ h('div', { className: 'capital-automation-boardgrid', 'data-rail': railOpen === true ? 'open' : 'closed' },
4115
+ h('section', { className: 'capital-automation-boardmain' },
4116
+ [0, 1].map((index) => h('div', { key: index, className: 'capital-automation-briefcard' },
4117
+ h(SkeletonBlock, { width: '48%', height: 12 }),
4118
+ h(SkeletonBlock, { width: '80%', height: 16 }),
4119
+ h(SkeletonBlock, { width: '100%', height: 10 }),
4120
+ h(SkeletonBlock, { width: '92%', height: 10 })))),
4121
+ railOpen === true
4122
+ ? h('aside', { className: 'capital-automation-boardrail' },
4123
+ h('div', { className: 'capital-automation-card capital-automation-panel' },
4124
+ h(SkeletonBlock, { width: 68, height: 14 }),
4125
+ h(SkeletonBlock, { width: '100%', height: 10 }),
4126
+ h(SkeletonBlock, { width: '86%', height: 10 })))
4127
+ : null)))
4128
+ }
4129
+
4130
+ function BriefFeed(props) {
4131
+ const { cards, loading, error, onOpenSession, onRetry, retryingRunId, onViewAll, onClearFilter, onLoadMore, hasMore, loadingMore, railOpen } = props
4132
+ if (loading === true) return h(BoardSkeleton, { railOpen })
4133
+ if (typeof error === 'string' && error.length > 0) {
4134
+ return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs' },
4135
+ h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error))
4136
+ }
4137
+ if (cards.length === 0) {
4138
+ return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs' },
4139
+ h('div', { className: 'capital-automation-empty' },
4140
+ h('span', { className: 'capital-automation-emptyicon' }, h(IconChecklistOutlineRegular, { size: 19 })),
4141
+ h('h3', null, zh.board.rangeEmpty),
4142
+ h('p', null, zh.board.emptyHint),
4143
+ h('div', { className: 'capital-automation-boardemptyactions' },
4144
+ onViewAll ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: onViewAll }, zh.board.viewAll) : null,
4145
+ onClearFilter ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: onClearFilter }, zh.board.clearFilter) : null)))
4146
+ }
4147
+ return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs', 'aria-label': zh.board.briefTitle },
4148
+ cards.map((card) => h(BriefCard, {
4149
+ key: card.runId,
4150
+ card,
4151
+ onOpenSession,
4152
+ onRetry,
4153
+ retrying: retryingRunId === card.runId,
4154
+ })),
4155
+ hasMore
4156
+ ? h('button', {
4157
+ type: 'button',
4158
+ className: 'capital-automation-btn capital-automation-boardmore',
4159
+ disabled: loadingMore === true,
4160
+ onClick: onLoadMore,
4161
+ }, loadingMore === true ? zh.loading : zh.board.loadMore)
4162
+ : null)
4163
+ }
4164
+
4165
+ function TodoRow(props) {
4166
+ const { item, period, showDue = true, onOpenSession } = props
4167
+ const [open, setOpen] = useState(false)
4168
+ const quote = item.sourceQuote ?? item.sources?.[0]?.sourceQuote
4169
+ const due = showDue === true ? boardTodoDueLabel(item, period) : ''
4170
+ const source = {
4171
+ taskTitle: item.taskTitle,
4172
+ finishedAt: item.finishedAt,
4173
+ sessionId: item.sessionId ?? item.sources?.[0]?.sessionId,
4174
+ }
4175
+ const meta = []
4176
+ if (due) meta.push(h('span', { key: 'due' }, due))
4177
+ if (item.seenCount > 1) meta.push(h('span', { key: 'seen' }, zh.board.seenCount.replace('{n}', String(item.seenCount))))
4178
+ const basisAction = open ? zh.board.hideBasis : zh.board.showBasis
4179
+ const basisCaret = h('span', { className: 'capital-automation-basiscaret', 'aria-hidden': 'true' }, h(IconChevronDownOutlineRegular, { size: 12 }))
4180
+ return h('li', { className: 'capital-automation-todoitem' },
4181
+ h('div', { className: 'capital-automation-todoline' },
4182
+ h('span', { className: 'capital-automation-todokind', 'data-kind': item.kind }, boardTodoKindLabel(item.kind)),
4183
+ h('button', {
4184
+ type: 'button',
4185
+ className: 'capital-automation-todotitle',
4186
+ 'aria-expanded': open ? 'true' : 'false',
4187
+ 'aria-label': `${item.title},${basisAction}`,
4188
+ title: basisAction,
4189
+ onClick: () => setOpen((value) => !value),
4190
+ }, item.title, basisCaret)),
4191
+ item.detail ? h('p', { className: 'capital-automation-tododesc' }, item.detail) : null,
4192
+ meta.length > 0 ? h('div', { className: 'capital-automation-todometa' }, meta) : null,
4193
+ open
4194
+ ? h('div', { className: 'capital-automation-tododetail' },
4195
+ h('blockquote', null, quote),
4196
+ source
4197
+ ? h('div', { className: 'capital-automation-todosource' },
4198
+ h('span', null, `${zh.board.sourceRun}:${source.taskTitle} · ${formatShortTime(source.finishedAt)}`),
4199
+ source.sessionId ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenSession(source.sessionId) }, zh.openSession) : null)
4200
+ : null)
4201
+ : null)
4202
+ }
4203
+
4204
+ function BoardPanelHead(props) {
4205
+ const { id, title, open, onToggle, meta, action } = props
4206
+ return h('div', { className: 'capital-automation-panelhead' },
4207
+ h('h3', null,
4208
+ h('button', {
4209
+ type: 'button',
4210
+ className: 'capital-automation-paneltoggle',
4211
+ 'aria-expanded': open === true ? 'true' : 'false',
4212
+ 'aria-controls': `${id}-body`,
4213
+ 'aria-label': `${title}(${open === true ? zh.board.collapse : zh.board.expand})`,
4214
+ title: open === true ? zh.board.collapse : zh.board.expand,
4215
+ onClick: onToggle,
4216
+ },
4217
+ h('span', null, title),
4218
+ h(IconChevronDownOutlineRegular, {
4219
+ size: 14,
4220
+ className: 'capital-automation-panelchevron',
4221
+ 'data-open': open === true ? 'true' : 'false',
4222
+ }))),
4223
+ meta ?? null,
4224
+ action ?? null)
4225
+ }
4226
+
4227
+ function BoardPanel(props) {
4228
+ const { id, title, open, onToggle, meta, action, children } = props
4229
+ return h('section', {
4230
+ className: 'capital-automation-card capital-automation-panel',
4231
+ id,
4232
+ 'data-collapsed': open === true ? 'false' : 'true',
4233
+ },
4234
+ h(BoardPanelHead, { id, title, open, onToggle, meta, action }),
4235
+ h('div', {
4236
+ id: `${id}-body`,
4237
+ className: 'capital-automation-panelbody',
4238
+ hidden: open !== true,
4239
+ }, children))
4240
+ }
4241
+
4242
+ function TodoPanel(props) {
4243
+ const { todos, onOpenSession, open, onToggle } = props
4244
+ const [filter, setFilter] = useState('all')
4245
+ const entries = todos.map((item) => ({ item, period: boardTodoPeriod(item) }))
4246
+ entries.sort((left, right) => BOARD_TODO_PERIODS.indexOf(left.period) - BOARD_TODO_PERIODS.indexOf(right.period))
4247
+ const visible = filter === 'all' ? entries : entries.filter((entry) => entry.period === filter)
4248
+ const emptyText = filter === 'all'
4249
+ ? zh.board.todoEmpty
4250
+ : zh.board.todoEmptyGroup.replace('{label}', boardTodoGroupLabel(filter))
4251
+ return h(BoardPanel, {
4252
+ id: 'capital-automation-todo',
4253
+ title: zh.board.todoTitle,
4254
+ open,
4255
+ onToggle,
4256
+ action: h(Select, {
4257
+ value: filter,
4258
+ options: boardTodoFilterOptions(),
4259
+ onChange: setFilter,
4260
+ size: 'sm',
4261
+ label: zh.board.todoFilterLabel,
4262
+ align: 'end',
4263
+ }),
4264
+ },
4265
+ visible.length === 0
4266
+ ? h('p', { className: 'capital-automation-hint' }, emptyText)
4267
+ : h('ul', { className: 'capital-automation-todolist' }, visible.map((entry) => h(TodoRow, {
4268
+ key: entry.item.id,
4269
+ item: entry.item,
4270
+ period: entry.period,
4271
+ showDue: filter === 'all',
4272
+ onOpenSession,
4273
+ }))))
4274
+ }
4275
+
4276
+ function boardRoleLabel(role) {
4277
+ if (role === 'holding') return zh.board.roleHolding
4278
+ if (role === 'watch') return zh.board.roleWatch
4279
+ if (role === 'event') return zh.board.roleEvent
4280
+ return zh.board.roleRisk
4281
+ }
4282
+
4283
+ function StockRow(props) {
4284
+ const { stock, todos, onOpenSession } = props
4285
+ const [open, setOpen] = useState(false)
4286
+ const related = todos.filter((item) => item.symbol === stock.symbol)
4287
+ return h('div', { className: 'capital-automation-stockrow' },
4288
+ h('button', {
4289
+ type: 'button',
4290
+ className: 'capital-automation-stockmain',
4291
+ 'aria-expanded': open ? 'true' : 'false',
4292
+ onClick: () => setOpen((value) => !value),
4293
+ },
4294
+ h('span', { className: 'capital-automation-stockname' }, stock.name),
4295
+ h('span', { className: 'capital-automation-stockcode' }, stock.symbol),
4296
+ h('span', { className: 'capital-automation-stockroles' },
4297
+ stock.roles.map((role) => h('span', { key: role, className: 'capital-automation-stockrole', 'data-role': role }, boardRoleLabel(role)))),
4298
+ stock.note ? h('span', { className: 'capital-automation-stocknote' }, stock.note) : null,
4299
+ h('span', { className: 'capital-automation-stockmeta' },
4300
+ stock.nextAt ? h('span', null, stock.nextAt) : null,
4301
+ stock.todoCount > 0 ? h('span', null, zh.board.stockTodoCount.replace('{n}', String(stock.todoCount))) : null)),
4302
+ open && related.length > 0
4303
+ ? h('ul', { className: 'capital-automation-stocktodos' }, related.map((item) => h('li', { key: item.id },
4304
+ h('span', null, item.title),
4305
+ item.sessionId ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenSession(item.sessionId) }, zh.openSession) : null)))
4306
+ : null)
4307
+ }
4308
+
4309
+ function StockRadar(props) {
4310
+ const { stocks, todos, total, onOpenSession, open, onToggle } = props
4311
+ const hidden = Math.max(0, (total ?? stocks.length) - stocks.length)
4312
+ return h(BoardPanel, {
4313
+ id: 'capital-automation-stocks',
4314
+ title: zh.board.statsStocks,
4315
+ open,
4316
+ onToggle,
4317
+ meta: stocks.length === 0 ? null : h('span', { className: 'capital-automation-hint' }, zh.board.stocksCount.replace('{n}', String(total ?? stocks.length))),
4318
+ },
4319
+ stocks.length === 0
4320
+ ? h('p', { className: 'capital-automation-hint' }, zh.board.stockEmpty)
4321
+ : stocks.map((stock) => h(StockRow, { key: stock.symbol, stock, todos, onOpenSession })),
4322
+ hidden > 0 ? h('p', { className: 'capital-automation-hint' }, zh.board.stockOther.replace('{n}', String(hidden))) : null)
4323
+ }
4324
+
4325
+ function boardGapLabel(kind) {
4326
+ if (kind === 'capability') return zh.board.gapCapability
4327
+ if (kind === 'conflict') return zh.board.gapConflict
4328
+ if (kind === 'quality') return zh.board.gapQuality
4329
+ return zh.board.gapTransient
4330
+ }
4331
+
4332
+ function GapRow(props) {
4333
+ const { gap, onOpenSession } = props
4334
+ const [open, setOpen] = useState(false)
4335
+ const source = gap.sources?.[0]
4336
+ const basisAction = open ? zh.board.hideBasis : zh.board.showBasis
4337
+ return h('li', { className: 'capital-automation-gaprow' },
4338
+ h('div', { className: 'capital-automation-gaphead' },
4339
+ h('span', { className: 'capital-automation-gapkind', 'data-kind': gap.kind }, boardGapLabel(gap.kind)),
4340
+ h('button', {
4341
+ type: 'button',
4342
+ className: 'capital-automation-gaptitle',
4343
+ 'aria-expanded': open ? 'true' : 'false',
4344
+ 'aria-label': `${gap.topic},${basisAction}`,
4345
+ title: basisAction,
4346
+ onClick: () => setOpen((value) => !value),
4347
+ }, gap.topic, h('span', { className: 'capital-automation-basiscaret', 'aria-hidden': 'true' }, h(IconChevronDownOutlineRegular, { size: 12 })))),
4348
+ h('p', { className: 'capital-automation-gapdesc' }, gap.detail),
4349
+ open
4350
+ ? h('div', { className: 'capital-automation-tododetail' },
4351
+ h('blockquote', null, source?.sourceQuote ?? gap.sourceQuote),
4352
+ source ? h('p', { className: 'capital-automation-hint' }, `${source.taskTitle} · ${formatShortTime(source.finishedAt)}`) : null,
4353
+ source?.sessionId ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenSession(source.sessionId) }, zh.openSession) : null)
4354
+ : null)
4355
+ }
4356
+
4357
+ function DataHealthPanel(props) {
4358
+ const { gaps, total, onOpenSession, open, onToggle } = props
4359
+ const [showAll, setShowAll] = useState(false)
4360
+ const visible = showAll ? gaps : gaps.slice(0, 5)
4361
+ return h(BoardPanel, {
4362
+ id: 'capital-automation-gaps',
4363
+ title: zh.board.statsGaps,
4364
+ open,
4365
+ onToggle,
4366
+ },
4367
+ gaps.length === 0
4368
+ ? h('p', { className: 'capital-automation-hint' }, zh.board.gapEmpty)
4369
+ : h('ul', { className: 'capital-automation-gaplist' }, visible.map((gap) => h(GapRow, { key: gap.id, gap, onOpenSession }))),
4370
+ (total ?? gaps.length) > visible.length
4371
+ ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => setShowAll(true) }, zh.board.gapAll)
4372
+ : null)
4373
+ }
4374
+
4375
+ function healthIssueTone(status) {
4376
+ if (status === 'failed' || status === 'timed_out' || status === 'unknown_after_restart') return 'bad'
4377
+ if (status === 'missed' || status === 'blocked_requires_user') return 'warn'
4378
+ return null
4379
+ }
4380
+
4381
+ function RunHealthPanel(props) {
4382
+ const { health, onGoRuns, onOpenSession, open, onToggle } = props
4383
+ const runs = health?.runs ?? {}
4384
+ const briefs = health?.briefs ?? {}
4385
+ const runParts = [
4386
+ ['healthSucceeded', runs.succeeded ?? 0],
4387
+ ['healthFailed', runs.failed ?? 0],
4388
+ ['healthTimeout', runs.timedOut ?? 0],
4389
+ ['healthMissed', runs.missed ?? 0],
4390
+ ['healthUnknown', runs.unknown ?? 0],
4391
+ ['healthBlocked', runs.blocked ?? 0],
4392
+ ['healthActive', runs.active ?? 0],
4393
+ ].filter(([, value]) => value > 0)
4394
+ const briefParts = [
4395
+ ['healthBriefReady', briefs.ready ?? 0],
4396
+ ['healthBriefPending', briefs.pending ?? 0],
4397
+ ['healthBriefFailed', briefs.failed ?? 0],
4398
+ ['healthBriefSkipped', briefs.skipped ?? 0],
4399
+ ].filter(([, value]) => value > 0)
4400
+ const countText = (parts) => parts.length === 0 ? '0' : parts.map(([key, value]) => `${zh.board[key]} ${value}`).join(' · ')
4401
+ const schedulerState = health?.scheduler?.state
4402
+ const scheduler = schedulerState === 'active' ? zh.board.healthSchedulerOk : schedulerState === 'standby' ? zh.board.healthSchedulerStandby : zh.board.healthSchedulerBad
4403
+ const schedulerHint = schedulerState === 'active' ? zh.systemActive : schedulerState === 'standby' ? zh.systemStandby : zh.systemUnavailable
4404
+ const schedulerTone = schedulerState === 'active' ? null : schedulerState === 'standby' ? 'warn' : 'bad'
4405
+ const calendar = health?.calendar?.available === false ? zh.board.healthCalendarBad : zh.board.healthCalendarOk
4406
+ const calendarTone = health?.calendar?.available === false ? 'bad' : null
4407
+ return h(BoardPanel, {
4408
+ id: 'capital-automation-health',
4409
+ title: zh.board.healthTitle,
4410
+ open,
4411
+ onToggle,
4412
+ meta: h('span', { className: 'capital-automation-hint' }, zh.board.healthWindow),
4413
+ action: h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: onGoRuns }, zh.board.healthViewRuns),
4414
+ },
4415
+ h('div', { className: 'capital-automation-healthgrid' },
4416
+ h('span', { className: 'capital-automation-healthkey' }, zh.board.healthRuns),
4417
+ h('span', { className: 'capital-automation-healthval' }, countText(runParts)),
4418
+ h('span', { className: 'capital-automation-healthkey' }, zh.board.healthBriefs),
4419
+ h('span', { className: 'capital-automation-healthval' }, countText(briefParts)),
4420
+ h('span', { className: 'capital-automation-healthkey' }, zh.board.healthScheduler),
4421
+ h('span', { className: 'capital-automation-healthval', 'data-tone': schedulerTone ?? undefined, title: schedulerHint }, scheduler),
4422
+ h('span', { className: 'capital-automation-healthkey' }, zh.board.healthCalendar),
4423
+ h('span', { className: 'capital-automation-healthval', 'data-tone': calendarTone ?? undefined }, calendar)),
4424
+ health?.issueCount > 0
4425
+ ? h('ul', { className: 'capital-automation-healthissues' }, (health.recentIssues ?? []).map((issue) => {
4426
+ const tone = healthIssueTone(issue.status)
4427
+ return h('li', { key: issue.runId },
4428
+ h('span', { className: 'capital-automation-healthissue', title: issue.message || undefined },
4429
+ h('span', { className: 'capital-automation-statusdot', 'data-tone': tone ?? undefined }),
4430
+ h('span', { className: 'capital-automation-healthissuetitle' }, issue.taskTitle),
4431
+ h('span', { className: 'capital-automation-healthissuestatus', 'data-tone': tone ?? undefined }, statusLabel(issue.status)),
4432
+ issue.recoveredByRunId ? h('span', { className: 'capital-automation-healthrecovered' }, zh.board.healthRecovered) : null),
4433
+ issue.sessionId ? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenSession(issue.sessionId) }, zh.board.healthOpen) : null)
4434
+ }))
4435
+ : h('p', { className: 'capital-automation-healthempty' }, zh.board.healthNoIssues))
4436
+ }
4437
+
4438
+ function BoardPage(props) {
4439
+ const {
4440
+ board, loading, error, range, category, onRange, onCategory, onRefresh,
4441
+ onOpenSession, onRetryBrief, retryingRunId, onLoadMore, loadingMore, onGoTasks, onNewTask, onGoRuns,
4442
+ hasActiveTasks, storageReady,
4443
+ } = props
4444
+ const [railOpen, setRailOpen] = useState(() => readBoardUi().rail !== false)
4445
+ const [openPanels, setOpenPanels] = useState(() => boardPanelFlags(readBoardUi().panels))
4446
+ const [pendingJump, setPendingJump] = useState(null)
4447
+
4448
+ useEffect(() => {
4449
+ if (typeof pendingJump !== 'string') return undefined
4450
+ const timer = setTimeout(() => {
4451
+ if (typeof document !== 'undefined') {
4452
+ const node = document.getElementById(pendingJump)
4453
+ if (node !== null && typeof node.scrollIntoView === 'function') node.scrollIntoView({ block: 'start', behavior: 'smooth' })
4454
+ }
4455
+ setPendingJump(null)
4456
+ }, 0)
4457
+ return () => clearTimeout(timer)
4458
+ }, [pendingJump])
4459
+
4460
+ const togglePanel = (key) => {
4461
+ setOpenPanels((current) => {
4462
+ const next = { ...current, [key]: current[key] !== true }
4463
+ saveBoardUi({ panels: next })
4464
+ return next
4465
+ })
4466
+ }
4467
+
4468
+ const toggleRail = () => {
4469
+ setRailOpen((value) => {
4470
+ const next = value !== true
4471
+ saveBoardUi({ rail: next })
4472
+ return next
4473
+ })
4474
+ }
4475
+
4476
+ const jumpTo = (id) => {
4477
+ const key = boardPanelKey(id)
4478
+ if (key !== null) {
4479
+ setRailOpen(true)
4480
+ saveBoardUi({ rail: true })
4481
+ setOpenPanels((current) => {
4482
+ if (current[key] === true) return current
4483
+ const next = { ...current, [key]: true }
4484
+ saveBoardUi({ panels: next })
4485
+ return next
4486
+ })
4487
+ }
4488
+ setPendingJump(id)
4489
+ }
4490
+
4491
+ if (loading === true && board === null) return h(BoardSkeleton, { railOpen })
4492
+ if (error.length > 0 && board === null) {
4493
+ return h('div', { className: 'capital-automation-board' },
4494
+ h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' },
4495
+ `${zh.board.loadError}:${error}`,
4496
+ h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: onRefresh }, zh.loadRetry)))
4497
+ }
4498
+ if (board?.empty === true) {
4499
+ return h('div', { className: 'capital-automation-board' },
4500
+ error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
4501
+ h(BoardEmpty, { hasActiveTasks, storageReady, onGoTasks, onNewTask }))
4502
+ }
4503
+ return h('div', { className: 'capital-automation-board' },
4504
+ h(BoardToolbar, {
4505
+ range,
4506
+ category,
4507
+ loading,
4508
+ onRange,
4509
+ onCategory,
4510
+ onRefresh,
4511
+ railOpen,
4512
+ onToggleRail: toggleRail,
4513
+ }),
4514
+ error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
4515
+ h(BoardStats, { stats: board?.stats, onJump: jumpTo }),
4516
+ h('div', {
4517
+ className: 'capital-automation-boardgrid',
4518
+ 'data-rail': railOpen === true ? 'open' : 'closed',
4519
+ },
4520
+ h(BriefFeed, {
4521
+ cards: board?.cards ?? [],
4522
+ loading: loading === true && board === null,
4523
+ error: '',
4524
+ onOpenSession,
4525
+ onRetry: onRetryBrief,
4526
+ retryingRunId,
4527
+ onViewAll: range === 'all' ? undefined : () => onRange('all'),
4528
+ onClearFilter: category === 'all' ? undefined : () => onCategory('all'),
4529
+ onLoadMore,
4530
+ hasMore: board?.nextBefore !== null && board?.nextBefore !== undefined,
4531
+ loadingMore,
4532
+ railOpen,
4533
+ }),
4534
+ h('aside', {
4535
+ id: 'capital-automation-boardrail',
4536
+ className: 'capital-automation-boardrail',
4537
+ hidden: railOpen !== true,
4538
+ },
4539
+ h(TodoPanel, { todos: board?.todos ?? [], onOpenSession, open: openPanels.todo, onToggle: () => togglePanel('todo') }),
4540
+ h(StockRadar, {
4541
+ stocks: board?.stocks ?? [],
4542
+ todos: board?.todos ?? [],
4543
+ total: board?.stats?.stocks,
4544
+ onOpenSession,
4545
+ open: openPanels.stocks,
4546
+ onToggle: () => togglePanel('stocks'),
4547
+ }),
4548
+ h(DataHealthPanel, {
4549
+ gaps: board?.gaps ?? [],
4550
+ total: board?.stats?.gaps,
4551
+ onOpenSession,
4552
+ open: openPanels.gaps,
4553
+ onToggle: () => togglePanel('gaps'),
4554
+ }),
4555
+ h(RunHealthPanel, {
4556
+ health: board?.health,
4557
+ onGoRuns,
4558
+ onOpenSession,
4559
+ open: openPanels.health,
4560
+ onToggle: () => togglePanel('health'),
4561
+ }))))
4562
+ }
4563
+
3612
4564
  function AutomationPage(props) {
3613
4565
  const { api, openSession } = props
3614
4566
  const [meta, setMeta] = useState(null)
@@ -3616,10 +4568,17 @@ function AutomationPage(props) {
3616
4568
  const [runs, setRuns] = useState([])
3617
4569
  const [history, setHistory] = useState(null)
3618
4570
  const [notifications, setNotifications] = useState([])
4571
+ const [board, setBoard] = useState(null)
4572
+ const [boardLoading, setBoardLoading] = useState(true)
4573
+ const [boardError, setBoardError] = useState('')
4574
+ const [boardRange, setBoardRange] = useState('14')
4575
+ const [boardCategory, setBoardCategory] = useState('all')
4576
+ const [retryingBriefId, setRetryingBriefId] = useState(null)
4577
+ const [boardLoadingMore, setBoardLoadingMore] = useState(false)
3619
4578
  const [unread, setUnread] = useState(0)
3620
4579
  const [selectedId, setSelectedId] = useState(null)
3621
4580
  const [detail, setDetail] = useState(null)
3622
- const [tab, setTab] = useState('tasks')
4581
+ const [tab, setTab] = useState('board')
3623
4582
  const [detailTab, setDetailTab] = useState('overview')
3624
4583
  const [wizard, setWizard] = useState(false)
3625
4584
  const [inbox, setInbox] = useState(false)
@@ -3636,6 +4595,7 @@ function AutomationPage(props) {
3636
4595
  const refreshInFlightRef = useRef(null)
3637
4596
  const refreshSequenceRef = useRef(0)
3638
4597
  const detailSequenceRef = useRef(0)
4598
+ const boardSequenceRef = useRef(0)
3639
4599
  const scrollRef = useRef(null)
3640
4600
 
3641
4601
  useEffect(() => {
@@ -3690,6 +4650,52 @@ function AutomationPage(props) {
3690
4650
  }
3691
4651
  }
3692
4652
 
4653
+ async function loadBoard(nextRange = boardRange, nextCategory = boardCategory, before = null) {
4654
+ const requestSequence = boardSequenceRef.current + 1
4655
+ boardSequenceRef.current = requestSequence
4656
+ if (before === null) setBoardLoading(true)
4657
+ try {
4658
+ const value = await api.board(boardQueryOf(nextRange, nextCategory, before))
4659
+ if (!mountedRef.current || requestSequence !== boardSequenceRef.current) return
4660
+ if (before === null) setBoard(value)
4661
+ else setBoard((current) => current === null
4662
+ ? value
4663
+ : { ...value, cards: [...current.cards, ...value.cards] })
4664
+ setBoardError('')
4665
+ } catch (error) {
4666
+ if (mountedRef.current && requestSequence === boardSequenceRef.current) {
4667
+ setBoardError(error.message ?? zh.board.loadError)
4668
+ }
4669
+ } finally {
4670
+ if (mountedRef.current && requestSequence === boardSequenceRef.current) setBoardLoading(false)
4671
+ }
4672
+ }
4673
+
4674
+ async function loadMoreBoard() {
4675
+ if (board?.nextBefore === null || board?.nextBefore === undefined || boardLoadingMore) return
4676
+ setBoardLoadingMore(true)
4677
+ try {
4678
+ await loadBoard(boardRange, boardCategory, board.nextBefore)
4679
+ } finally {
4680
+ setBoardLoadingMore(false)
4681
+ }
4682
+ }
4683
+
4684
+ async function retryBrief(runId) {
4685
+ if (retryingBriefId !== null) return
4686
+ setRetryingBriefId(runId)
4687
+ setBoardError('')
4688
+ try {
4689
+ await api.retryBrief(runId)
4690
+ setNotice(zh.board.retryQueued)
4691
+ await loadBoard(boardRange, boardCategory)
4692
+ } catch (error) {
4693
+ setBoardError(error.message ?? zh.errorGeneric)
4694
+ } finally {
4695
+ setRetryingBriefId(null)
4696
+ }
4697
+ }
4698
+
3693
4699
  async function loadDetail(id) {
3694
4700
  const requestSequence = detailSequenceRef.current + 1
3695
4701
  detailSequenceRef.current = requestSequence
@@ -3730,7 +4736,7 @@ function AutomationPage(props) {
3730
4736
 
3731
4737
  function switchTab(nextTab) {
3732
4738
  if (nextTab === tab && nextTab === 'tasks' && selectedIdRef.current !== null) return
3733
- if (nextTab === 'runs' && selectedIdRef.current !== null) {
4739
+ if ((nextTab === 'board' || nextTab === 'runs') && selectedIdRef.current !== null) {
3734
4740
  selectedIdRef.current = null
3735
4741
  detailSequenceRef.current += 1
3736
4742
  setDetail(null)
@@ -3849,6 +4855,23 @@ function AutomationPage(props) {
3849
4855
  }
3850
4856
  }, [])
3851
4857
 
4858
+ useEffect(() => {
4859
+ if (tab !== 'board') return undefined
4860
+ void loadBoard(boardRange, boardCategory)
4861
+ const timer = setInterval(() => {
4862
+ if (document.visibilityState !== 'hidden') void loadBoard(boardRange, boardCategory)
4863
+ }, 30_000)
4864
+ const onVisibilityChange = () => {
4865
+ if (document.visibilityState === 'visible') void loadBoard(boardRange, boardCategory)
4866
+ }
4867
+ document.addEventListener?.('visibilitychange', onVisibilityChange)
4868
+ return () => {
4869
+ boardSequenceRef.current += 1
4870
+ clearInterval(timer)
4871
+ document.removeEventListener?.('visibilitychange', onVisibilityChange)
4872
+ }
4873
+ }, [tab, boardRange, boardCategory])
4874
+
3852
4875
  useEffect(() => {
3853
4876
  if (selectedId === null) {
3854
4877
  setDetail(null)
@@ -3881,8 +4904,29 @@ function AutomationPage(props) {
3881
4904
  h(PageBanners, { meta, loadError, onRetry: () => { void refresh() } }),
3882
4905
  h('div', { className: 'capital-automation-scroll', ref: scrollRef },
3883
4906
  h('div', { className: 'capital-automation-container' },
3884
- tab === 'tasks'
3885
- ? selectedId !== null
4907
+ tab === 'board'
4908
+ ? h(BoardPage, {
4909
+ board,
4910
+ loading: boardLoading,
4911
+ error: boardError,
4912
+ range: boardRange,
4913
+ category: boardCategory,
4914
+ onRange: setBoardRange,
4915
+ onCategory: setBoardCategory,
4916
+ onRefresh: () => { void loadBoard(boardRange, boardCategory) },
4917
+ onOpenSession: openSession,
4918
+ onRetryBrief: (runId) => { void retryBrief(runId) },
4919
+ retryingRunId: retryingBriefId,
4920
+ onLoadMore: () => { void loadMoreBoard() },
4921
+ loadingMore: boardLoadingMore,
4922
+ onGoTasks: () => switchTab('tasks'),
4923
+ onNewTask: () => setWizard(true),
4924
+ onGoRuns: () => switchTab('runs'),
4925
+ hasActiveTasks: tasks.some((task) => task.state === 'active'),
4926
+ storageReady,
4927
+ })
4928
+ : tab === 'tasks'
4929
+ ? selectedId !== null
3886
4930
  ? h('div', null,
3887
4931
  h(DetailBar, { onBack: backToTasks }),
3888
4932
  detail === null
@@ -3933,7 +4977,7 @@ function AutomationPage(props) {
3933
4977
  onGoTasks: () => switchTab('tasks'),
3934
4978
  onNewTask: () => setWizard(true),
3935
4979
  busy: confirmBusy,
3936
- }), detailOpen ? null : h(SystemStatus, { meta }))),
4980
+ }), detailOpen || tab === 'board' ? null : h(SystemStatus, { meta }))),
3937
4981
  h(NewTaskModal, {
3938
4982
  open: wizard,
3939
4983
  onClose: () => setWizard(false),