@v587d/capital-generation 2.19.3 → 2.21.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/CHANGELOG.md +69 -0
- package/README.md +7 -21
- package/automation/ask.js +8 -1
- package/automation/board.js +303 -32
- package/automation/brief.js +92 -35
- package/automation/builtins.js +17 -0
- package/automation/client.js +62 -25
- package/automation/client.src.cjs +971 -197
- package/automation/defaults.js +1 -0
- package/automation/index.js +34 -7
- package/automation/package.json +2 -1
- package/automation/route.js +8 -0
- package/automation/runner.js +48 -4
- package/automation/scheduler.js +12 -0
- package/automation/schema.js +66 -3
- package/automation/service.js +27 -0
- package/automation/store.js +65 -3
- package/automation/task-icons.js +1 -0
- package/automation/watch.js +585 -0
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/chart/delivery.js +8 -6
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +1 -1
- package/plugin-page/README.en.md +1 -1
- package/plugin-page/README.zh.md +1 -1
- package/watchlist/package.json +1 -1
|
@@ -85,6 +85,9 @@ const AUTOSAVE_DELAY_MS = 600
|
|
|
85
85
|
const BOARD_UI_KEY = 'capital-automation:board-ui:v3'
|
|
86
86
|
const BOARD_PANEL_KEYS = ['todo', 'stocks', 'gaps', 'health']
|
|
87
87
|
const BOARD_TODO_PERIODS = ['today', 'future', 'expired']
|
|
88
|
+
const BOARD_STOCK_PAGE_SIZE = 12
|
|
89
|
+
const BOARD_STOCK_ROLES = ['holding', 'risk', 'event', 'watch']
|
|
90
|
+
const BOARD_BRIEF_HIGHLIGHT_MS = 3_000
|
|
88
91
|
const BOARD_PANEL_IDS = {
|
|
89
92
|
'capital-automation-todo': 'todo',
|
|
90
93
|
'capital-automation-stocks': 'stocks',
|
|
@@ -103,11 +106,23 @@ const zh = {
|
|
|
103
106
|
goTasks: '去任务页运行',
|
|
104
107
|
goEnable: '去启用任务',
|
|
105
108
|
newTask: '新建任务',
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
statsBriefsToday: '今天简报',
|
|
110
|
+
statsBriefsTotal: '总简报',
|
|
111
|
+
statsTodos: '今天 TODO',
|
|
112
|
+
statsTodoManual: '人工',
|
|
113
|
+
statsTodoAuto: '自动',
|
|
114
|
+
statsStocks: '个股动态',
|
|
115
|
+
statsStocksNew: '新增',
|
|
116
|
+
statsGaps: '数据能力缺口',
|
|
117
|
+
statsGapsNew: '新增',
|
|
118
|
+
statsIssuesToday: '今天运行异常',
|
|
119
|
+
statsBriefsTodayHint: '点击高亮今天的简报卡片',
|
|
120
|
+
statsTodoHint: '点击查看今天的 TODO',
|
|
121
|
+
statsTodoManualHint: '需要你处理或跟踪的 TODO',
|
|
122
|
+
statsTodoAutoHint: '自动核验中的 TODO',
|
|
123
|
+
statsStockHint: '点击查看个股动态',
|
|
124
|
+
statsGapHint: '点击查看数据能力缺口',
|
|
125
|
+
statsIssuesTodayHint: '点击查看今天的运行异常',
|
|
111
126
|
refresh: '刷新',
|
|
112
127
|
range: '时间范围',
|
|
113
128
|
range7: '最近 7 天',
|
|
@@ -136,14 +151,35 @@ const zh = {
|
|
|
136
151
|
askPending: '正在回答…',
|
|
137
152
|
askFailed: '回答失败',
|
|
138
153
|
askMore: '查看更多',
|
|
139
|
-
|
|
154
|
+
stockTitle: '个股动态',
|
|
155
|
+
stocksCount: '共 {n} 只',
|
|
156
|
+
stockFilteredCount: '{shown} / {total} 只',
|
|
157
|
+
stockFilterLabel: '按标签筛选',
|
|
158
|
+
stockFilterAll: '全部',
|
|
159
|
+
stockFilterEmpty: '没有符合该标签的个股',
|
|
160
|
+
stockShowAll: '展开全部 {n} 只',
|
|
161
|
+
stockShowLess: '收起',
|
|
140
162
|
gapsCount: '{n} 个缺口',
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
163
|
+
todoAcked: '已确认',
|
|
164
|
+
todoMoreTitle: '更多操作',
|
|
165
|
+
todoActionConfirm: '已确认',
|
|
166
|
+
todoActionAuto: '转入自动校验',
|
|
167
|
+
todoActionDefer: '忽略',
|
|
168
|
+
todoAutoQueued: '已转入自动校验,下一次收盘核验',
|
|
169
|
+
todoDeferred: '已忽略当前版本',
|
|
170
|
+
watchWatching: '自动核验中',
|
|
171
|
+
watchTriggered: '已触发',
|
|
172
|
+
watchNeedsHuman: '待人工处理',
|
|
173
|
+
watchResolved: '已确认',
|
|
174
|
+
watchDeferred: '忽略',
|
|
175
|
+
watchExpired: '已过期',
|
|
176
|
+
watchTracking: '跟踪',
|
|
177
|
+
watchEvidence: '核验依据',
|
|
178
|
+
watchSource: '来源',
|
|
179
|
+
watchDeferredHint: '已忽略当前版本;后续新版本会重新出现',
|
|
180
|
+
watchChecked: '核验于 {time}',
|
|
181
|
+
notificationFallbackTodoTriggered: '条件已触发,查看 TODO 详情。',
|
|
182
|
+
notificationFallbackTodoNeedsHuman: '自动核验无法完成,需要你处理。',
|
|
147
183
|
todoEmptyToday: '今天暂无待办',
|
|
148
184
|
todoEmptyGroup: '暂无「{label}」待办',
|
|
149
185
|
todoFilterLabel: '按日期筛选',
|
|
@@ -156,18 +192,19 @@ const zh = {
|
|
|
156
192
|
hideBasis: '收起依据',
|
|
157
193
|
seenCount: '{n} 次运行提到',
|
|
158
194
|
sourceRun: '来源',
|
|
159
|
-
stockEmpty: '
|
|
160
|
-
stockOther: '
|
|
161
|
-
stockTodoCount: '{n}
|
|
195
|
+
stockEmpty: '最近运行没有提到个股',
|
|
196
|
+
stockOther: '另有 {n} 只未显示',
|
|
197
|
+
stockTodoCount: '{n} 条待跟进',
|
|
198
|
+
stockTodoCountHint: '与这只个股相关的待确认、待验证或待跟踪事项;展开后可直接打开来源 session',
|
|
162
199
|
roleHolding: '持仓',
|
|
163
200
|
roleWatch: '关注',
|
|
164
201
|
roleEvent: '事件',
|
|
165
202
|
roleRisk: '风险',
|
|
203
|
+
roleHoldingHint: '自选清单里标记为持仓',
|
|
204
|
+
roleWatchHint: '在自选清单里关注,未标记持仓',
|
|
205
|
+
roleEventHint: '近期运行提到需要跟踪的事件或催化',
|
|
206
|
+
roleRiskHint: '近期运行提示存在风险',
|
|
166
207
|
gapEmpty: '最近运行没有报告数据缺口',
|
|
167
|
-
gapCapability: '能力缺口',
|
|
168
|
-
gapTransient: '本次未取到',
|
|
169
|
-
gapConflict: '口径冲突',
|
|
170
|
-
gapQuality: '数据质量',
|
|
171
208
|
gapSeen: '{n} 次运行',
|
|
172
209
|
gapAll: '查看全部',
|
|
173
210
|
healthTitle: '运行健康',
|
|
@@ -195,7 +232,6 @@ const zh = {
|
|
|
195
232
|
healthBriefSkipped: '跳过',
|
|
196
233
|
healthNoBrief: '没有已入队简报',
|
|
197
234
|
healthRecovered: '已补跑',
|
|
198
|
-
healthOpen: '打开 session',
|
|
199
235
|
healthCalendarOk: '正常',
|
|
200
236
|
healthCalendarBad: '不可用',
|
|
201
237
|
loadError: '看板暂时不可用',
|
|
@@ -419,6 +455,7 @@ const zh = {
|
|
|
419
455
|
allRead: '全部已读',
|
|
420
456
|
noNotifications: '没有未读或历史任务通知。',
|
|
421
457
|
notificationOpenTask: '查看任务',
|
|
458
|
+
notificationOpenTodo: '查看 TODO',
|
|
422
459
|
systemStatus: '系统状态',
|
|
423
460
|
systemActive: '定时调度正常',
|
|
424
461
|
systemStandby: '本窗口待命,不启动新的定时运行',
|
|
@@ -963,15 +1000,20 @@ function installStyles() {
|
|
|
963
1000
|
.capital-automation-boardtools { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
|
|
964
1001
|
.capital-automation-boardactions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-left: auto; }
|
|
965
1002
|
.capital-automation-boardstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
|
|
966
|
-
.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;
|
|
967
|
-
.capital-automation-
|
|
968
|
-
.capital-automation-
|
|
969
|
-
.capital-automation-
|
|
970
|
-
.capital-automation-
|
|
1003
|
+
.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; text-align: left; }
|
|
1004
|
+
.capital-automation-boardstatlabel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 3px; color: var(--ca-muted); font-size: 11.5px; line-height: 17px; }
|
|
1005
|
+
.capital-automation-boardstatvalue { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; color: var(--dsw-alias-label-primary); font-size: 18px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
1006
|
+
.capital-automation-boardstatnum { margin: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-variant-numeric: inherit; line-height: inherit; }
|
|
1007
|
+
.capital-automation-boardstatnum[data-clickable="true"] { border-radius: 4px; cursor: pointer; transition: color .15s; }
|
|
1008
|
+
.capital-automation-boardstatnum[data-clickable="true"]:hover { color: var(--ca-business-text); text-decoration: underline; text-underline-offset: 2px; }
|
|
1009
|
+
.capital-automation-boardstatnum[data-clickable="true"]:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 1px; }
|
|
1010
|
+
.capital-automation-boardstatsep { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
1011
|
+
.capital-automation-boardstatvalue .capital-automation-boardstatsep { padding: 0 3px; }
|
|
971
1012
|
.capital-automation-boardgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); align-items: start; gap: 20px; min-width: 0; }
|
|
972
1013
|
.capital-automation-boardgrid[data-rail="closed"] { grid-template-columns: minmax(0, 1fr); }
|
|
973
1014
|
.capital-automation-boardmain { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
|
|
974
|
-
.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; }
|
|
1015
|
+
.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; transition: border-color .2s ease, box-shadow .2s ease; }
|
|
1016
|
+
.capital-automation-briefcard[data-highlight="true"] { border-color: var(--ca-business); box-shadow: 0 0 0 1px var(--ca-business); }
|
|
975
1017
|
.capital-automation-briefhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px 14px; }
|
|
976
1018
|
.capital-automation-brieftitle { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; min-width: 0; }
|
|
977
1019
|
.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; }
|
|
@@ -1012,6 +1054,7 @@ function installStyles() {
|
|
|
1012
1054
|
.capital-automation-chatcontext h3 { margin: 5px 0 0; color: var(--dsw-alias-label-primary); font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .1px; overflow-wrap: anywhere; }
|
|
1013
1055
|
.capital-automation-chatcontexttext { margin: 5px 0 0; color: var(--dsw-alias-label-secondary); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1014
1056
|
.capital-automation-chatthread { margin-left: 18px; padding: 12px 0 4px 30px; border-left: 2px solid var(--ca-line); }
|
|
1057
|
+
.capital-automation-chatexchange + .capital-automation-chatexchange { margin-top: 18px; padding-top: 16px; border-top: .5px solid var(--ca-line); }
|
|
1015
1058
|
.capital-automation-chatempty { margin-left: 18px; padding: 12px 0 4px 30px; border-left: 2px solid var(--ca-line); }
|
|
1016
1059
|
.capital-automation-chatempty p { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 13px; line-height: 20px; }
|
|
1017
1060
|
.capital-automation-chatcomposer { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; border-top: .5px solid var(--ca-line); }
|
|
@@ -1040,14 +1083,21 @@ function installStyles() {
|
|
|
1040
1083
|
.capital-automation-boardemptyhint { color: var(--ca-caption); font-size: 11.5px !important; line-height: 18px !important; }
|
|
1041
1084
|
.capital-automation-boardemptyactions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
|
|
1042
1085
|
.capital-automation-todolist, .capital-automation-stocktodos, .capital-automation-gaplist, .capital-automation-gaprow { list-style: none; margin: 0; padding: 0; }
|
|
1043
|
-
.capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); }
|
|
1086
|
+
.capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); transition: opacity .16s ease, padding .18s ease; }
|
|
1044
1087
|
.capital-automation-todoitem:first-child { border-top: 0; }
|
|
1088
|
+
.capital-automation-todoitem[data-decided="true"], .capital-automation-todoitem[data-archived="true"] { padding: 7px 0; opacity: .72; border-top: 0; }
|
|
1089
|
+
.capital-automation-todoitem:not([data-decided="true"]) + .capital-automation-todoitem[data-decided="true"] { border-top: .5px solid var(--ca-line); }
|
|
1090
|
+
.capital-automation-todoitem[data-decided="true"]:hover, .capital-automation-todoitem[data-archived="true"]:hover { opacity: 1; }
|
|
1091
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todoline, .capital-automation-todoitem[data-archived="true"] .capital-automation-todoline { gap: 0; }
|
|
1092
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotop, .capital-automation-todoitem[data-archived="true"] .capital-automation-todotop { justify-content: flex-start; gap: 10px; }
|
|
1093
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotitle, .capital-automation-todoitem[data-archived="true"] .capital-automation-todotitle { flex: 1 1 auto; width: auto; min-width: 0; color: var(--ca-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1094
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotitle { cursor: default; }
|
|
1095
|
+
.capital-automation-todoitem[data-archived="true"] .capital-automation-todotitle { cursor: pointer; }
|
|
1096
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotitle:hover { color: var(--ca-muted); }
|
|
1097
|
+
.capital-automation-todoitem[data-archived="true"] .capital-automation-todotitle:hover { color: var(--ca-business-text); }
|
|
1045
1098
|
.capital-automation-todoline { display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-width: 0; }
|
|
1046
1099
|
.capital-automation-todotop { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
|
|
1047
|
-
.capital-automation-
|
|
1048
|
-
.capital-automation-todokind[data-kind="confirm"] { color: var(--ca-warn-text); }
|
|
1049
|
-
.capital-automation-todokind[data-kind="verify"] { color: var(--ca-business-text); }
|
|
1050
|
-
.capital-automation-todokind[data-kind="track"] { color: var(--ca-success-text); }
|
|
1100
|
+
.capital-automation-todotags { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 4px 5px; min-width: 0; }
|
|
1051
1101
|
.capital-automation-todotitle { flex: none; width: 100%; 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; }
|
|
1052
1102
|
.capital-automation-todotitle:hover, .capital-automation-gaptitle:hover { color: var(--ca-business-text); }
|
|
1053
1103
|
.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; }
|
|
@@ -1055,31 +1105,55 @@ function installStyles() {
|
|
|
1055
1105
|
.capital-automation-todotitle[aria-expanded="true"] .capital-automation-basiscaret, .capital-automation-gaptitle[aria-expanded="true"] .capital-automation-basiscaret { transform: rotate(0deg); }
|
|
1056
1106
|
.capital-automation-tododesc { margin: 3px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
|
|
1057
1107
|
.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; }
|
|
1108
|
+
.capital-automation-todooutcome { color: var(--ca-muted); font-weight: 500; }
|
|
1109
|
+
.capital-automation-todowatch { display: inline-flex; flex: none; align-items: center; min-height: 20px; padding: 0 6px; border-radius: 999px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10px; line-height: 20px; white-space: nowrap; }
|
|
1110
|
+
.capital-automation-todowatch[data-status="triggered"] { background: color-mix(in srgb, var(--ca-error) 12%, var(--ca-card)); color: var(--ca-error-text); }
|
|
1111
|
+
.capital-automation-todowatch[data-status="needs_human"] { background: color-mix(in srgb, var(--ca-warn) 14%, var(--ca-card)); color: var(--ca-warn-text); }
|
|
1112
|
+
.capital-automation-todowatch[data-status="watching"] { color: var(--ca-business-text); }
|
|
1113
|
+
.capital-automation-todowatch[data-status="resolved"] { background: color-mix(in srgb, var(--ca-success) 14%, var(--ca-card)); color: var(--ca-success-text); }
|
|
1114
|
+
.capital-automation-todowatch[data-status="deferred"] { background: color-mix(in srgb, var(--ca-muted) 12%, var(--ca-card)); color: var(--ca-muted); }
|
|
1115
|
+
.capital-automation-todowatch[data-status="tracking"] { color: var(--ca-muted); }
|
|
1116
|
+
.capital-automation-todowatch[data-status="expired"] { color: var(--ca-caption); }
|
|
1117
|
+
.capital-automation-todomenu { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--ca-muted); cursor: pointer; transition: background .15s ease, color .15s ease; }
|
|
1118
|
+
.capital-automation-todomenu:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
1119
|
+
.capital-automation-todomenu:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; }
|
|
1120
|
+
.capital-automation-todomenu:disabled { opacity: .4; cursor: default; }
|
|
1121
|
+
.capital-automation-todowatchmsg { margin: 1px 0 0; padding: 6px 9px; border-left: 2px solid var(--ca-line); border-radius: 0 7px 7px 0; background: var(--ca-field); color: var(--ca-muted); font-size: 11.5px; line-height: 18px; overflow-wrap: anywhere; }
|
|
1122
|
+
.capital-automation-todowatchmsg[data-status="triggered"] { border-left-color: var(--ca-error); color: var(--ca-error-text); }
|
|
1058
1123
|
.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; }
|
|
1059
1124
|
.capital-automation-tododetail blockquote { margin: 0; color: var(--ca-muted); font-size: 11.5px; line-height: 19px; overflow-wrap: anywhere; }
|
|
1060
1125
|
.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; }
|
|
1126
|
+
.capital-automation-stockfilters { display: flex; align-items: center; gap: 8px; margin-left: auto; }
|
|
1127
|
+
.capital-automation-stockfilters .capital-automation-select { margin-left: 0; }
|
|
1061
1128
|
.capital-automation-stockrow { border-top: .5px solid var(--ca-line); }
|
|
1062
1129
|
.capital-automation-stockrow:first-of-type { border-top: 0; }
|
|
1063
1130
|
.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; }
|
|
1131
|
+
.capital-automation-stockmain:hover .capital-automation-stockname, .capital-automation-stockmain:hover .capital-automation-stockcode { color: var(--ca-business-text); }
|
|
1064
1132
|
.capital-automation-stockmain:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: -2px; }
|
|
1065
1133
|
.capital-automation-stockname { color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 19px; font-weight: 600; }
|
|
1066
1134
|
.capital-automation-stockcode { color: var(--ca-caption); font-size: 11px; line-height: 17px; }
|
|
1067
1135
|
.capital-automation-stockroles { display: inline-flex; flex-wrap: wrap; gap: 3px; }
|
|
1068
|
-
.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; }
|
|
1136
|
+
.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; cursor: help; }
|
|
1069
1137
|
.capital-automation-stockrole[data-role="holding"] { color: var(--ca-success-text); }
|
|
1070
1138
|
.capital-automation-stockrole[data-role="risk"] { color: var(--ca-error-text); }
|
|
1071
1139
|
.capital-automation-stockrole[data-role="event"] { color: var(--ca-warn-text); }
|
|
1072
1140
|
.capital-automation-stocknote { flex: 1 1 100%; color: var(--ca-muted); font-size: 12px; line-height: 19px; overflow-wrap: anywhere; }
|
|
1073
1141
|
.capital-automation-stockmeta { display: flex; flex-wrap: wrap; gap: 4px 9px; color: var(--ca-caption); font-size: 11px; line-height: 17px; }
|
|
1074
1142
|
.capital-automation-stocktodos { margin: 0 0 7px; padding: 0 0 0 8px; border-left: 2px solid var(--ca-line); }
|
|
1075
|
-
.capital-automation-stocktodos li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px;
|
|
1143
|
+
.capital-automation-stocktodos li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; color: var(--ca-muted); font-size: 11.5px; line-height: 18px; }
|
|
1144
|
+
.capital-automation-stocktodo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; width: 100%; padding: 4px 6px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color .15s ease, color .15s ease; }
|
|
1145
|
+
.capital-automation-stocktodo:hover { background: color-mix(in srgb, var(--ca-business) 8%, transparent); color: var(--ca-business-text); }
|
|
1146
|
+
.capital-automation-stocktodo:hover .capital-automation-stocktodotitle { color: var(--ca-business-text); }
|
|
1147
|
+
.capital-automation-stocktodo:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: -2px; }
|
|
1148
|
+
.capital-automation-stocktodo[data-static="true"] { cursor: default; }
|
|
1149
|
+
.capital-automation-stocktodo[data-static="true"]:hover { background: transparent; color: inherit; }
|
|
1150
|
+
.capital-automation-stocktodo svg { flex: none; color: var(--ca-caption); opacity: .65; }
|
|
1151
|
+
.capital-automation-stocktodo:hover svg { color: var(--ca-business-text); opacity: 1; }
|
|
1152
|
+
.capital-automation-stocktodotitle { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
|
|
1153
|
+
.capital-automation-stockmore { align-self: center; margin: 6px 0 2px; }
|
|
1076
1154
|
.capital-automation-gaprow { padding: 8px 0; border-top: .5px solid var(--ca-line); }
|
|
1077
1155
|
.capital-automation-gaprow:first-child { border-top: 0; }
|
|
1078
|
-
.capital-automation-gaphead { display: flex; align-items: flex-start;
|
|
1079
|
-
.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; }
|
|
1080
|
-
.capital-automation-gapkind[data-kind="capability"] { color: var(--ca-warn-text); }
|
|
1081
|
-
.capital-automation-gapkind[data-kind="conflict"] { color: var(--ca-error-text); }
|
|
1082
|
-
.capital-automation-gapkind[data-kind="quality"] { color: var(--ca-warn-text); }
|
|
1156
|
+
.capital-automation-gaphead { display: flex; align-items: flex-start; min-width: 0; }
|
|
1083
1157
|
.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; }
|
|
1084
1158
|
.capital-automation-gapdesc { margin: 3px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
|
|
1085
1159
|
.capital-automation-healthgrid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
|
|
@@ -1208,6 +1282,7 @@ function createApi() {
|
|
|
1208
1282
|
},
|
|
1209
1283
|
warm,
|
|
1210
1284
|
confirmTodo: (id) => request('/board/todos/confirm', { method: 'POST', body: { id } }),
|
|
1285
|
+
decideTodo: (id, action) => request('/board/todos/decision', { method: 'POST', body: { id, action } }),
|
|
1211
1286
|
retryBrief: (runId) => request(`/board/briefs/${encodeURIComponent(runId)}/retry`, { method: 'POST' }),
|
|
1212
1287
|
askBrief: (runId, question, timeZone) => request(`/board/briefs/${encodeURIComponent(runId)}/ask`, {
|
|
1213
1288
|
method: 'POST',
|
|
@@ -1215,6 +1290,7 @@ function createApi() {
|
|
|
1215
1290
|
timeoutMs: 60_000,
|
|
1216
1291
|
}),
|
|
1217
1292
|
askStatus: (askId) => request(`/board/asks/${encodeURIComponent(askId)}`),
|
|
1293
|
+
askHistory: (runId) => request(`/board/briefs/${encodeURIComponent(runId)}/asks`),
|
|
1218
1294
|
askAnswer: (askId) => request(`/board/asks/${encodeURIComponent(askId)}/answer`),
|
|
1219
1295
|
notifications: () => request('/notifications'),
|
|
1220
1296
|
markRead: (body) => request('/notifications/read', { method: 'POST', body }),
|
|
@@ -1826,7 +1902,7 @@ function heatDayMeta(day) {
|
|
|
1826
1902
|
|
|
1827
1903
|
function eventTone(kind) {
|
|
1828
1904
|
if (kind === 'run_failed' || kind === 'run_timeout') return 'error'
|
|
1829
|
-
if (kind === 'scheduler_standby' || kind === 'calendar_unavailable') return 'warn'
|
|
1905
|
+
if (kind === 'scheduler_standby' || kind === 'calendar_unavailable' || kind === 'todo_triggered' || kind === 'todo_needs_human') return 'warn'
|
|
1830
1906
|
return 'neutral'
|
|
1831
1907
|
}
|
|
1832
1908
|
|
|
@@ -1838,6 +1914,8 @@ function notificationMessage(item) {
|
|
|
1838
1914
|
if (item.kind === 'scheduler_standby') return zh.notificationFallbackStandby
|
|
1839
1915
|
if (item.kind === 'calendar_unavailable') return zh.notificationFallbackCalendar
|
|
1840
1916
|
if (item.kind === 'skipped') return zh.notificationFallbackSkipped
|
|
1917
|
+
if (item.kind === 'todo_triggered') return zh.notificationFallbackTodoTriggered
|
|
1918
|
+
if (item.kind === 'todo_needs_human') return zh.notificationFallbackTodoNeedsHuman
|
|
1841
1919
|
return ''
|
|
1842
1920
|
}
|
|
1843
1921
|
|
|
@@ -3324,7 +3402,7 @@ function NotificationsTab(props) {
|
|
|
3324
3402
|
|
|
3325
3403
|
function NotificationItem(props) {
|
|
3326
3404
|
const { item, onClick, onOpenTask } = props
|
|
3327
|
-
const clickable = typeof onClick === 'function' && item.taskId !== undefined
|
|
3405
|
+
const clickable = typeof onClick === 'function' && (item.taskId !== undefined || item.todoId !== undefined)
|
|
3328
3406
|
const tag = clickable ? 'button' : 'div'
|
|
3329
3407
|
return h(tag, {
|
|
3330
3408
|
type: clickable ? 'button' : undefined,
|
|
@@ -3340,8 +3418,8 @@ function NotificationItem(props) {
|
|
|
3340
3418
|
item.readAt === undefined ? h('span', { className: 'capital-automation-count' }, zh.unread) : null),
|
|
3341
3419
|
h('span', { className: 'capital-automation-notificationmessage' }, notificationMessage(item)),
|
|
3342
3420
|
h('span', { className: 'capital-automation-notificationtime' }, formatShortTime(item.createdAt))),
|
|
3343
|
-
onOpenTask !== undefined && item.taskId !== undefined
|
|
3344
|
-
? h('span', { className: 'capital-automation-hint' }, zh.notificationOpenTask)
|
|
3421
|
+
onOpenTask !== undefined && (item.taskId !== undefined || item.todoId !== undefined)
|
|
3422
|
+
? h('span', { className: 'capital-automation-hint' }, item.todoId !== undefined ? zh.notificationOpenTodo : zh.notificationOpenTask)
|
|
3345
3423
|
: null)
|
|
3346
3424
|
}
|
|
3347
3425
|
|
|
@@ -3905,7 +3983,7 @@ function ConfirmModal(props) {
|
|
|
3905
3983
|
}
|
|
3906
3984
|
|
|
3907
3985
|
function InboxModal(props) {
|
|
3908
|
-
const { open, onClose, notifications, onMarkAllRead, onOpenTask, busy } = props
|
|
3986
|
+
const { open, onClose, notifications, onMarkAllRead, onOpenTask, onOpenTodo, busy } = props
|
|
3909
3987
|
const unread = notifications.filter((item) => item.readAt === undefined).length
|
|
3910
3988
|
return h(Modal, {
|
|
3911
3989
|
open,
|
|
@@ -3931,7 +4009,11 @@ function InboxModal(props) {
|
|
|
3931
4009
|
key: item.id,
|
|
3932
4010
|
item,
|
|
3933
4011
|
onOpenTask: onOpenTask,
|
|
3934
|
-
onClick: item.
|
|
4012
|
+
onClick: item.todoId !== undefined
|
|
4013
|
+
? () => onOpenTodo(item)
|
|
4014
|
+
: item.taskId === undefined
|
|
4015
|
+
? undefined
|
|
4016
|
+
: () => onOpenTask(item.taskId),
|
|
3935
4017
|
}))))
|
|
3936
4018
|
}
|
|
3937
4019
|
|
|
@@ -3963,8 +4045,23 @@ function boardRelativeTime(value, now = Date.now()) {
|
|
|
3963
4045
|
return `${Math.floor(diff / year)}年前`
|
|
3964
4046
|
}
|
|
3965
4047
|
|
|
4048
|
+
function boardCardIsToday(card, today = localDateKey(new Date())) {
|
|
4049
|
+
if (typeof card?.finishedAt !== 'string') return false
|
|
4050
|
+
const date = new Date(card.finishedAt)
|
|
4051
|
+
return !Number.isNaN(date.getTime()) && localDateKey(date) === today
|
|
4052
|
+
}
|
|
4053
|
+
|
|
3966
4054
|
function boardTodoPeriod(item, now = new Date()) {
|
|
3967
4055
|
const today = localDateKey(now)
|
|
4056
|
+
const watchedStatus = item.watch?.resolvedFrom ?? item.watch?.status
|
|
4057
|
+
const decidedAt = typeof item.ackedAt === 'string' ? item.ackedAt : item.deferredAt
|
|
4058
|
+
const decidedToday = typeof decidedAt === 'string' && localDateKey(new Date(decidedAt)) === today
|
|
4059
|
+
// A decision is feedback for the rest of today, then it belongs to the archive.
|
|
4060
|
+
if (decidedAt !== undefined) return decidedToday ? 'today' : 'expired'
|
|
4061
|
+
// A triggered condition is a fact: keep it actionable until the user decides.
|
|
4062
|
+
if (watchedStatus === 'triggered') return 'today'
|
|
4063
|
+
// A stopped watch has reached its lifecycle end, including date-less "尽快" items.
|
|
4064
|
+
if (item.watch?.status === 'expired') return 'expired'
|
|
3968
4065
|
if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) {
|
|
3969
4066
|
if (item.dueAt < today) return 'expired'
|
|
3970
4067
|
if (item.dueAt === today) return 'today'
|
|
@@ -3974,13 +4071,29 @@ function boardTodoPeriod(item, now = new Date()) {
|
|
|
3974
4071
|
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
3975
4072
|
const seen = typeof item.finishedAt === 'string' ? new Date(item.finishedAt) : null
|
|
3976
4073
|
const seenToday = seen !== null && !Number.isNaN(seen.getTime()) && localDateKey(seen) === today
|
|
3977
|
-
if (['尽快', '马上', '现在'].includes(label))
|
|
4074
|
+
if (['尽快', '马上', '现在'].includes(label)) {
|
|
4075
|
+
// A tracked "尽快" item stays actionable through its 72-hour watch window.
|
|
4076
|
+
if (item.watch !== null && item.watch !== undefined) return 'today'
|
|
4077
|
+
return seenToday ? 'today' : 'future'
|
|
4078
|
+
}
|
|
3978
4079
|
if (['今天', '今日'].includes(label)) return seenToday ? 'today' : 'expired'
|
|
3979
4080
|
return 'future'
|
|
3980
4081
|
}
|
|
3981
4082
|
|
|
3982
|
-
|
|
3983
|
-
|
|
4083
|
+
/**
|
|
4084
|
+
* Human / automatic is the watch axis, not the run trigger: `watching` items are checked by the
|
|
4085
|
+
* service, everything else (confirmation, triggered, passive tracking, stopped checks) needs the user.
|
|
4086
|
+
*/
|
|
4087
|
+
function boardTodoTodaySplit(todos, now = new Date()) {
|
|
4088
|
+
const split = { total: 0, manual: 0, auto: 0 }
|
|
4089
|
+
for (const item of todos) {
|
|
4090
|
+
const status = boardTodoStatus(item)
|
|
4091
|
+
if (status === 'resolved' || status === 'deferred' || boardTodoPeriod(item, now) !== 'today') continue
|
|
4092
|
+
split.total += 1
|
|
4093
|
+
if (status === 'watching') split.auto += 1
|
|
4094
|
+
else split.manual += 1
|
|
4095
|
+
}
|
|
4096
|
+
return split
|
|
3984
4097
|
}
|
|
3985
4098
|
|
|
3986
4099
|
function boardTodoGroupLabel(period) {
|
|
@@ -3989,6 +4102,162 @@ function boardTodoGroupLabel(period) {
|
|
|
3989
4102
|
return zh.board.dueFuture
|
|
3990
4103
|
}
|
|
3991
4104
|
|
|
4105
|
+
/**
|
|
4106
|
+
* Today's pending rows stay on top; acknowledged rows collapse to a single line at the bottom so
|
|
4107
|
+
* the next item visibly moves up. The newest confirmation is the last row of the day.
|
|
4108
|
+
*/
|
|
4109
|
+
function boardTodoEntries(todos, now = new Date()) {
|
|
4110
|
+
const entries = todos.map((item) => {
|
|
4111
|
+
const decidedAt = typeof item.ackedAt === 'string' ? item.ackedAt : item.deferredAt
|
|
4112
|
+
return {
|
|
4113
|
+
item,
|
|
4114
|
+
period: boardTodoPeriod(item, now),
|
|
4115
|
+
decided: typeof decidedAt === 'string' && decidedAt.length > 0,
|
|
4116
|
+
decidedAt,
|
|
4117
|
+
}
|
|
4118
|
+
})
|
|
4119
|
+
entries.sort((left, right) => {
|
|
4120
|
+
const period = BOARD_TODO_PERIODS.indexOf(left.period) - BOARD_TODO_PERIODS.indexOf(right.period)
|
|
4121
|
+
if (period !== 0) return period
|
|
4122
|
+
if (left.period === 'expired') {
|
|
4123
|
+
// Archive order is newest expiry first; undated rows fall to the end.
|
|
4124
|
+
return String(right.item.dueAt ?? '').localeCompare(String(left.item.dueAt ?? ''))
|
|
4125
|
+
|| String(right.item.lastSeenAt ?? '').localeCompare(String(left.item.lastSeenAt ?? ''))
|
|
4126
|
+
|| String(left.item.id).localeCompare(String(right.item.id))
|
|
4127
|
+
}
|
|
4128
|
+
if (left.period !== 'today') return 0
|
|
4129
|
+
if (left.decided !== right.decided) return left.decided ? 1 : -1
|
|
4130
|
+
if (left.decided && right.decided) return String(left.decidedAt).localeCompare(String(right.decidedAt))
|
|
4131
|
+
return 0
|
|
4132
|
+
})
|
|
4133
|
+
return entries
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
function boardTodoIsOpen(item) {
|
|
4137
|
+
return typeof item.ackedAt !== 'string' && typeof item.deferredAt !== 'string'
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
function closeBoardWatch(watch) {
|
|
4141
|
+
if (watch === null || watch === undefined) return watch
|
|
4142
|
+
return {
|
|
4143
|
+
...watch,
|
|
4144
|
+
status: 'resolved',
|
|
4145
|
+
resolvedFrom: watch.resolvedFrom ?? (watch.status === 'resolved' ? null : watch.status),
|
|
4146
|
+
autoRequestedAt: null,
|
|
4147
|
+
handoffReason: null,
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
function reopenBoardWatch(watch, at) {
|
|
4152
|
+
if (watch === null || watch === undefined) return watch
|
|
4153
|
+
return {
|
|
4154
|
+
...watch,
|
|
4155
|
+
status: 'watching',
|
|
4156
|
+
resolvedFrom: null,
|
|
4157
|
+
autoRequestedAt: at,
|
|
4158
|
+
handoffReason: null,
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
/** Applied before the server remembers the decision, and to every board refresh in flight. */
|
|
4163
|
+
function applyTodoDecision(current, todoId, action, at) {
|
|
4164
|
+
if (current === null) return current
|
|
4165
|
+
const target = (current.todos ?? []).find((entry) => entry.id === todoId)
|
|
4166
|
+
if (target === undefined) return current
|
|
4167
|
+
const wasOpen = boardTodoIsOpen(target)
|
|
4168
|
+
let next
|
|
4169
|
+
if (action === 'auto') {
|
|
4170
|
+
if (target.watch === null || target.watch === undefined) return current
|
|
4171
|
+
next = {
|
|
4172
|
+
...target,
|
|
4173
|
+
ackedAt: undefined,
|
|
4174
|
+
deferredAt: undefined,
|
|
4175
|
+
decision: undefined,
|
|
4176
|
+
watch: reopenBoardWatch(target.watch, at),
|
|
4177
|
+
}
|
|
4178
|
+
} else {
|
|
4179
|
+
const decision = action === 'defer' ? 'deferred' : 'confirmed'
|
|
4180
|
+
if (target.decision === decision) return current
|
|
4181
|
+
next = {
|
|
4182
|
+
...target,
|
|
4183
|
+
ackedAt: decision === 'confirmed' ? at : undefined,
|
|
4184
|
+
deferredAt: decision === 'deferred' ? at : undefined,
|
|
4185
|
+
decision,
|
|
4186
|
+
watch: closeBoardWatch(target.watch),
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
const isOpen = boardTodoIsOpen(next)
|
|
4190
|
+
const todos = current.todos.map((entry) => entry.id === todoId ? next : entry)
|
|
4191
|
+
const targetKey = target.symbol === undefined ? undefined : boardEntrySymbolKey(target)
|
|
4192
|
+
let stockDelta = 0
|
|
4193
|
+
if (wasOpen && !isOpen) stockDelta = -1
|
|
4194
|
+
if (!wasOpen && isOpen) stockDelta = 1
|
|
4195
|
+
const stocks = stockDelta === 0
|
|
4196
|
+
? current.stocks
|
|
4197
|
+
: (current.stocks ?? []).map((stock) => {
|
|
4198
|
+
if (targetKey === undefined || boardEntrySymbolKey(stock) !== targetKey) return stock
|
|
4199
|
+
if (!Array.isArray(stock.items)) {
|
|
4200
|
+
return { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) + stockDelta) }
|
|
4201
|
+
}
|
|
4202
|
+
if (stockDelta < 0) {
|
|
4203
|
+
const items = stock.items.filter((entry) => entry.id !== target.id)
|
|
4204
|
+
return { ...stock, items, todoCount: items.length }
|
|
4205
|
+
}
|
|
4206
|
+
if (stock.items.some((entry) => entry.id === todoId)) return stock
|
|
4207
|
+
const items = [...stock.items, { id: target.id, title: target.title, sessionId: target.sessionId ?? null }]
|
|
4208
|
+
return { ...stock, items, todoCount: items.length }
|
|
4209
|
+
})
|
|
4210
|
+
return {
|
|
4211
|
+
...current,
|
|
4212
|
+
todos,
|
|
4213
|
+
stocks,
|
|
4214
|
+
stats: current.stats === undefined || stockDelta === 0
|
|
4215
|
+
? current.stats
|
|
4216
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) + stockDelta) },
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
function restoreBoardTodoState(current, todoId, previous) {
|
|
4221
|
+
if (current === null) return current
|
|
4222
|
+
const target = (current.todos ?? []).find((entry) => entry.id === todoId)
|
|
4223
|
+
if (target === undefined) return current
|
|
4224
|
+
const next = {
|
|
4225
|
+
...target,
|
|
4226
|
+
ackedAt: previous.ackedAt,
|
|
4227
|
+
deferredAt: previous.deferredAt,
|
|
4228
|
+
decision: previous.decision,
|
|
4229
|
+
watch: previous.watch ?? null,
|
|
4230
|
+
}
|
|
4231
|
+
const wasOpen = boardTodoIsOpen(target)
|
|
4232
|
+
const isOpen = boardTodoIsOpen(next)
|
|
4233
|
+
const stockDelta = wasOpen === isOpen ? 0 : isOpen ? 1 : -1
|
|
4234
|
+
const todos = current.todos.map((entry) => entry.id === todoId ? next : entry)
|
|
4235
|
+
const targetKey = target.symbol === undefined ? undefined : boardEntrySymbolKey(target)
|
|
4236
|
+
const stocks = stockDelta === 0
|
|
4237
|
+
? current.stocks
|
|
4238
|
+
: (current.stocks ?? []).map((stock) => {
|
|
4239
|
+
if (targetKey === undefined || boardEntrySymbolKey(stock) !== targetKey) return stock
|
|
4240
|
+
if (!Array.isArray(stock.items)) {
|
|
4241
|
+
return { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) + stockDelta) }
|
|
4242
|
+
}
|
|
4243
|
+
if (stockDelta < 0) {
|
|
4244
|
+
const items = stock.items.filter((entry) => entry.id !== todoId)
|
|
4245
|
+
return { ...stock, items, todoCount: items.length }
|
|
4246
|
+
}
|
|
4247
|
+
if (stock.items.some((entry) => entry.id === todoId)) return stock
|
|
4248
|
+
const items = [...stock.items, { id: target.id, title: target.title, sessionId: target.sessionId ?? null }]
|
|
4249
|
+
return { ...stock, items, todoCount: items.length }
|
|
4250
|
+
})
|
|
4251
|
+
return {
|
|
4252
|
+
...current,
|
|
4253
|
+
todos,
|
|
4254
|
+
stocks,
|
|
4255
|
+
stats: current.stats === undefined || stockDelta === 0
|
|
4256
|
+
? current.stats
|
|
4257
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) + stockDelta) },
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
|
|
3992
4261
|
function boardTodoFilterOptions() {
|
|
3993
4262
|
return BOARD_TODO_PERIODS.map((period) => ({ value: period, label: boardTodoGroupLabel(period) }))
|
|
3994
4263
|
}
|
|
@@ -4003,10 +4272,95 @@ function boardTodoDueLabel(item, period) {
|
|
|
4003
4272
|
return date || zh.board.dueNoDate
|
|
4004
4273
|
}
|
|
4005
4274
|
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
return
|
|
4275
|
+
const TODO_VERIFIER_IDS = new Set(['todo-verifier-close'])
|
|
4276
|
+
|
|
4277
|
+
function boardTodoDecision(item) {
|
|
4278
|
+
if (item.decision === 'confirmed' || item.decision === 'deferred') return item.decision
|
|
4279
|
+
if (typeof item.ackedAt === 'string' && item.ackedAt.length > 0) return 'confirmed'
|
|
4280
|
+
if (typeof item.deferredAt === 'string' && item.deferredAt.length > 0) return 'deferred'
|
|
4281
|
+
return undefined
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
/** Archived outcome shown after the primary "已过期" label. */
|
|
4285
|
+
function boardTodoOutcome(item) {
|
|
4286
|
+
const decision = boardTodoDecision(item)
|
|
4287
|
+
if (decision === 'confirmed') return '已确认'
|
|
4288
|
+
if (decision === 'deferred') return '忽略'
|
|
4289
|
+
const reason = item.watch?.expiredReason
|
|
4290
|
+
if (reason === 'not_triggered') return '到期未触发'
|
|
4291
|
+
if (reason === 'no_data') return '数据不足'
|
|
4292
|
+
if (reason === 'not_verified') return '未完成核验'
|
|
4293
|
+
if (reason === 'not_confirmed') return '未确认'
|
|
4294
|
+
if (reason === 'stale') return '已停止跟踪'
|
|
4295
|
+
if (item.watch?.status === 'needs_human') return '数据不足'
|
|
4296
|
+
if (item.watch?.status === 'watching') return '未完成核验'
|
|
4297
|
+
if (item.kind === 'confirm') return '未确认'
|
|
4298
|
+
if (item.kind === 'verify') return '未完成核验'
|
|
4299
|
+
if (item.kind === 'track') return '跟踪结束'
|
|
4300
|
+
return ''
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4303
|
+
function boardTodoStatus(item) {
|
|
4304
|
+
if (typeof item.deferredAt === 'string' && item.deferredAt.length > 0) return 'deferred'
|
|
4305
|
+
if (typeof item.ackedAt === 'string' && item.ackedAt.length > 0) return 'resolved'
|
|
4306
|
+
if (item.watch !== null && item.watch !== undefined && typeof item.watch.status === 'string') return item.watch.status
|
|
4307
|
+
// Track items are passive; everything else without a watch is waiting for the user.
|
|
4308
|
+
return item.kind === 'track' ? 'tracking' : 'needs_human'
|
|
4309
|
+
}
|
|
4310
|
+
|
|
4311
|
+
function boardTodoWatchLabel(status) {
|
|
4312
|
+
if (status === 'triggered') return zh.board.watchTriggered
|
|
4313
|
+
if (status === 'needs_human') return zh.board.watchNeedsHuman
|
|
4314
|
+
if (status === 'resolved') return zh.board.watchResolved
|
|
4315
|
+
if (status === 'deferred') return zh.board.watchDeferred
|
|
4316
|
+
if (status === 'expired') return zh.board.watchExpired
|
|
4317
|
+
if (status === 'tracking') return zh.board.watchTracking
|
|
4318
|
+
if (status === 'watching') return zh.board.watchWatching
|
|
4319
|
+
return ''
|
|
4320
|
+
}
|
|
4321
|
+
|
|
4322
|
+
function boardTodoWatchHint(status, checkpointHint) {
|
|
4323
|
+
if (status === 'watching') return checkpointHint
|
|
4324
|
+
if (status === 'triggered') return '自动核验已确认条件成立'
|
|
4325
|
+
if (status === 'needs_human') return '需要你处理'
|
|
4326
|
+
if (status === 'resolved') return '已确认'
|
|
4327
|
+
if (status === 'deferred') return zh.board.watchDeferredHint
|
|
4328
|
+
if (status === 'tracking') return '仅展示,不自动核验'
|
|
4329
|
+
if (status === 'expired') return '已过期;不再核验、提醒或计入待办'
|
|
4330
|
+
return ''
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4333
|
+
function boardTodoVerifierHint(tasks) {
|
|
4334
|
+
const names = []
|
|
4335
|
+
for (const task of Array.isArray(tasks) ? tasks : []) {
|
|
4336
|
+
if (task?.origin !== 'builtin' || task.state !== 'active' || !TODO_VERIFIER_IDS.has(task.sourceBuiltinId)) continue
|
|
4337
|
+
if (typeof task.title === 'string' && task.title.length > 0 && !names.includes(task.title)) names.push(task.title)
|
|
4338
|
+
}
|
|
4339
|
+
if (names.length > 0) return `自动核验由「${names.join('、')}」执行(A/H 收盘)`
|
|
4340
|
+
if (!Array.isArray(tasks) || tasks.length === 0) return '自动核验由「TODO 核验」执行(A/H 收盘)'
|
|
4341
|
+
return 'TODO 核验任务未启用'
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
function boardTodoCheckable(status) {
|
|
4345
|
+
return status === 'needs_human' || status === 'triggered' || status === 'tracking'
|
|
4346
|
+
|| status === 'watching' || status === 'resolved' || status === 'deferred'
|
|
4347
|
+
}
|
|
4348
|
+
|
|
4349
|
+
function boardTodoAutoAvailable(item, status) {
|
|
4350
|
+
if (item.kind !== 'confirm' && item.kind !== 'verify') return false
|
|
4351
|
+
if (item.watch === null || item.watch === undefined) return false
|
|
4352
|
+
if (item.watch.autoEligible !== true) return false
|
|
4353
|
+
return status === 'needs_human' || status === 'resolved' || status === 'deferred'
|
|
4354
|
+
}
|
|
4355
|
+
|
|
4356
|
+
function boardTodoAutoReason(item, status) {
|
|
4357
|
+
if (item.kind === 'track') return ''
|
|
4358
|
+
if (item.watch === null || item.watch === undefined) return ''
|
|
4359
|
+
if (item.watch.autoEligible === true) return ''
|
|
4360
|
+
if (item.watch.autoIneligibleReason === 'triggered' || status === 'triggered') return '条件已触发'
|
|
4361
|
+
if (item.watch.autoIneligibleReason === 'expired') return '已过期'
|
|
4362
|
+
if (item.watch.autoIneligibleReason === 'us_symbol') return '美股暂不支持'
|
|
4363
|
+
return '暂不支持'
|
|
4010
4364
|
}
|
|
4011
4365
|
|
|
4012
4366
|
function boardCategoryOptions() {
|
|
@@ -4089,27 +4443,129 @@ function BoardEmpty(props) {
|
|
|
4089
4443
|
}
|
|
4090
4444
|
|
|
4091
4445
|
function BoardStats(props) {
|
|
4092
|
-
const { stats, onJump } = props
|
|
4093
|
-
const items = [
|
|
4094
|
-
{ id: 'capital-automation-briefs', label: zh.board.statsBriefs, value: stats?.briefs ?? 0 },
|
|
4095
|
-
{ id: 'capital-automation-todo', label: zh.board.statsTodos, value: stats?.todos ?? 0 },
|
|
4096
|
-
{ id: 'capital-automation-stocks', label: zh.board.statsStocks, value: stats?.stocks ?? 0 },
|
|
4097
|
-
{ id: 'capital-automation-gaps', label: zh.board.statsGaps, value: stats?.gaps ?? 0 },
|
|
4098
|
-
{ id: 'capital-automation-health', label: zh.board.statsIssues, value: stats?.issues7d ?? 0 },
|
|
4099
|
-
]
|
|
4446
|
+
const { stats, onJump, onHighlightTodayBriefs } = props
|
|
4100
4447
|
const jump = (id) => {
|
|
4101
4448
|
if (typeof document === 'undefined') return
|
|
4102
4449
|
const node = document.getElementById(id)
|
|
4103
4450
|
if (node !== null && typeof node.scrollIntoView === 'function') node.scrollIntoView({ block: 'start', behavior: 'smooth' })
|
|
4104
4451
|
}
|
|
4105
4452
|
const activate = typeof onJump === 'function' ? onJump : jump
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4453
|
+
const open = (id) => () => activate(id)
|
|
4454
|
+
const labelParts = (parts) => parts.map((part, index) => h('span', {
|
|
4455
|
+
key: `label-${index}`,
|
|
4456
|
+
className: typeof part === 'string' && /^\s*[\/:]\s*$/.test(part) ? 'capital-automation-boardstatsep' : undefined,
|
|
4457
|
+
}, part))
|
|
4458
|
+
const valueParts = (parts) => parts.map((part, index) => {
|
|
4459
|
+
if (typeof part === 'string') return h('span', { key: `sep-${index}`, className: 'capital-automation-boardstatsep' }, part)
|
|
4460
|
+
if (typeof part.onClick !== 'function') {
|
|
4461
|
+
return h('span', { key: `value-${index}`, className: 'capital-automation-boardstatnum' }, String(part.value))
|
|
4462
|
+
}
|
|
4463
|
+
return h('button', {
|
|
4464
|
+
key: `value-${index}`,
|
|
4109
4465
|
type: 'button',
|
|
4110
|
-
className: 'capital-automation-
|
|
4111
|
-
|
|
4112
|
-
|
|
4466
|
+
className: 'capital-automation-boardstatnum',
|
|
4467
|
+
'data-clickable': 'true',
|
|
4468
|
+
title: part.title,
|
|
4469
|
+
'aria-label': part.ariaLabel,
|
|
4470
|
+
onClick: part.onClick,
|
|
4471
|
+
}, String(part.value))
|
|
4472
|
+
})
|
|
4473
|
+
const items = [
|
|
4474
|
+
{
|
|
4475
|
+
key: 'briefs',
|
|
4476
|
+
label: [zh.board.statsBriefsToday, ' / ', zh.board.statsBriefsTotal],
|
|
4477
|
+
values: [
|
|
4478
|
+
{
|
|
4479
|
+
value: stats?.briefsToday ?? 0,
|
|
4480
|
+
title: zh.board.statsBriefsTodayHint,
|
|
4481
|
+
ariaLabel: `${zh.board.statsBriefsToday} ${stats?.briefsToday ?? 0},${zh.board.statsBriefsTodayHint}`,
|
|
4482
|
+
onClick: typeof onHighlightTodayBriefs === 'function' ? onHighlightTodayBriefs : undefined,
|
|
4483
|
+
},
|
|
4484
|
+
' / ',
|
|
4485
|
+
{ value: stats?.briefs ?? 0 },
|
|
4486
|
+
],
|
|
4487
|
+
},
|
|
4488
|
+
{
|
|
4489
|
+
key: 'todos',
|
|
4490
|
+
label: [zh.board.statsTodos, ' : ', zh.board.statsTodoManual, ' / ', zh.board.statsTodoAuto],
|
|
4491
|
+
values: [
|
|
4492
|
+
{
|
|
4493
|
+
value: stats?.todos ?? 0,
|
|
4494
|
+
title: zh.board.statsTodoHint,
|
|
4495
|
+
ariaLabel: `${zh.board.statsTodos} ${stats?.todos ?? 0},${zh.board.statsTodoHint}`,
|
|
4496
|
+
onClick: open('capital-automation-todo'),
|
|
4497
|
+
},
|
|
4498
|
+
' : ',
|
|
4499
|
+
{
|
|
4500
|
+
value: stats?.todosManual ?? 0,
|
|
4501
|
+
title: zh.board.statsTodoManualHint,
|
|
4502
|
+
ariaLabel: `${zh.board.statsTodoManual} ${stats?.todosManual ?? 0},${zh.board.statsTodoManualHint}`,
|
|
4503
|
+
onClick: open('capital-automation-todo'),
|
|
4504
|
+
},
|
|
4505
|
+
' / ',
|
|
4506
|
+
{
|
|
4507
|
+
value: stats?.todosAuto ?? 0,
|
|
4508
|
+
title: zh.board.statsTodoAutoHint,
|
|
4509
|
+
ariaLabel: `${zh.board.statsTodoAuto} ${stats?.todosAuto ?? 0},${zh.board.statsTodoAutoHint}`,
|
|
4510
|
+
onClick: open('capital-automation-todo'),
|
|
4511
|
+
},
|
|
4512
|
+
],
|
|
4513
|
+
},
|
|
4514
|
+
{
|
|
4515
|
+
key: 'stocks',
|
|
4516
|
+
label: [zh.board.statsStocks, ' / ', zh.board.statsStocksNew],
|
|
4517
|
+
values: [
|
|
4518
|
+
{
|
|
4519
|
+
value: stats?.stocks ?? 0,
|
|
4520
|
+
title: zh.board.statsStockHint,
|
|
4521
|
+
ariaLabel: `${zh.board.statsStocks} ${stats?.stocks ?? 0},${zh.board.statsStockHint}`,
|
|
4522
|
+
onClick: open('capital-automation-stocks'),
|
|
4523
|
+
},
|
|
4524
|
+
' / ',
|
|
4525
|
+
{
|
|
4526
|
+
value: stats?.stocksNewToday ?? 0,
|
|
4527
|
+
title: zh.board.statsStockHint,
|
|
4528
|
+
ariaLabel: `${zh.board.statsStocksNew} ${stats?.stocksNewToday ?? 0},${zh.board.statsStockHint}`,
|
|
4529
|
+
onClick: open('capital-automation-stocks'),
|
|
4530
|
+
},
|
|
4531
|
+
],
|
|
4532
|
+
},
|
|
4533
|
+
{
|
|
4534
|
+
key: 'gaps',
|
|
4535
|
+
label: [zh.board.statsGaps, ' / ', zh.board.statsGapsNew],
|
|
4536
|
+
values: [
|
|
4537
|
+
{
|
|
4538
|
+
value: stats?.gaps ?? 0,
|
|
4539
|
+
title: zh.board.statsGapHint,
|
|
4540
|
+
ariaLabel: `${zh.board.statsGaps} ${stats?.gaps ?? 0},${zh.board.statsGapHint}`,
|
|
4541
|
+
onClick: open('capital-automation-gaps'),
|
|
4542
|
+
},
|
|
4543
|
+
' / ',
|
|
4544
|
+
{
|
|
4545
|
+
value: stats?.gapsNewToday ?? 0,
|
|
4546
|
+
title: zh.board.statsGapHint,
|
|
4547
|
+
ariaLabel: `${zh.board.statsGapsNew} ${stats?.gapsNewToday ?? 0},${zh.board.statsGapHint}`,
|
|
4548
|
+
onClick: open('capital-automation-gaps'),
|
|
4549
|
+
},
|
|
4550
|
+
],
|
|
4551
|
+
},
|
|
4552
|
+
{
|
|
4553
|
+
key: 'issues',
|
|
4554
|
+
label: [zh.board.statsIssuesToday],
|
|
4555
|
+
values: [
|
|
4556
|
+
{
|
|
4557
|
+
value: stats?.issuesToday ?? 0,
|
|
4558
|
+
title: zh.board.statsIssuesTodayHint,
|
|
4559
|
+
ariaLabel: `${zh.board.statsIssuesToday} ${stats?.issuesToday ?? 0},${zh.board.statsIssuesTodayHint}`,
|
|
4560
|
+
onClick: open('capital-automation-health'),
|
|
4561
|
+
},
|
|
4562
|
+
],
|
|
4563
|
+
},
|
|
4564
|
+
]
|
|
4565
|
+
return h('div', { className: 'capital-automation-boardstats', role: 'group', 'aria-label': zh.board.title },
|
|
4566
|
+
items.map((item) => h('div', { key: item.key, className: 'capital-automation-boardstat' },
|
|
4567
|
+
h('span', { className: 'capital-automation-boardstatlabel' }, labelParts(item.label)),
|
|
4568
|
+
h('span', { className: 'capital-automation-boardstatvalue' }, valueParts(item.values)))))
|
|
4113
4569
|
}
|
|
4114
4570
|
|
|
4115
4571
|
function BoardToolbar(props) {
|
|
@@ -4229,13 +4685,22 @@ function AskExchange(props) {
|
|
|
4229
4685
|
}
|
|
4230
4686
|
|
|
4231
4687
|
function AskDialog(props) {
|
|
4232
|
-
const { open, onClose, card, identity,
|
|
4688
|
+
const { open, onClose, card, identity, asks = [], api, question, onQuestionChange, onSubmit, busy, error, historyError = '', onOpenSession } = props
|
|
4233
4689
|
const inputRef = useRef(null)
|
|
4690
|
+
const scrollRef = useRef(null)
|
|
4234
4691
|
useEffect(() => {
|
|
4235
4692
|
if (!open) return undefined
|
|
4236
4693
|
const timer = setTimeout(() => inputRef.current?.focus?.(), 0)
|
|
4237
4694
|
return () => clearTimeout(timer)
|
|
4238
4695
|
}, [open])
|
|
4696
|
+
useEffect(() => {
|
|
4697
|
+
if (!open) return undefined
|
|
4698
|
+
const timer = setTimeout(() => {
|
|
4699
|
+
const node = scrollRef.current
|
|
4700
|
+
if (node !== null) node.scrollTop = node.scrollHeight
|
|
4701
|
+
}, 0)
|
|
4702
|
+
return () => clearTimeout(timer)
|
|
4703
|
+
}, [open, asks.length])
|
|
4239
4704
|
if (!open) return null
|
|
4240
4705
|
const brief = card.brief
|
|
4241
4706
|
const status = brief?.status ?? 'pending'
|
|
@@ -4246,7 +4711,7 @@ function AskDialog(props) {
|
|
|
4246
4711
|
const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
|
|
4247
4712
|
const relativeTime = boardRelativeTime(card.finishedAt)
|
|
4248
4713
|
const exactTime = formatTime(card.finishedAt)
|
|
4249
|
-
const running =
|
|
4714
|
+
const running = asks.some((item) => item.status === 'running')
|
|
4250
4715
|
let context
|
|
4251
4716
|
if (status === 'ready') {
|
|
4252
4717
|
context = h('div', null,
|
|
@@ -4287,7 +4752,7 @@ function AskDialog(props) {
|
|
|
4287
4752
|
onClick: openSession,
|
|
4288
4753
|
}, h(IconRightUpOutlineRegular, { size: 18 }))
|
|
4289
4754
|
: null),
|
|
4290
|
-
h('div', { className: 'capital-automation-chatscroll' },
|
|
4755
|
+
h('div', { ref: scrollRef, className: 'capital-automation-chatscroll' },
|
|
4291
4756
|
h('div', { className: 'capital-automation-chatcontext' },
|
|
4292
4757
|
h(Glyph, { task: identity ?? card, size: 38, radius: 999, glyphSize: 18 }),
|
|
4293
4758
|
h('div', { className: 'capital-automation-chatcontextbody' },
|
|
@@ -4297,8 +4762,13 @@ function AskDialog(props) {
|
|
|
4297
4762
|
`${categoryLabel(card.category)} · ${trigger} · `,
|
|
4298
4763
|
h('time', { dateTime: card.finishedAt, title: exactTime }, relativeTime))),
|
|
4299
4764
|
context)),
|
|
4300
|
-
|
|
4301
|
-
? h('
|
|
4765
|
+
historyError.length > 0
|
|
4766
|
+
? h('p', { className: 'capital-automation-askerror', role: 'alert' }, historyError)
|
|
4767
|
+
: null,
|
|
4768
|
+
asks.length > 0
|
|
4769
|
+
? h('div', { className: 'capital-automation-chatthread' },
|
|
4770
|
+
asks.map((item) => h('div', { key: item.id, className: 'capital-automation-chatexchange' },
|
|
4771
|
+
h(AskExchange, { ask: item, api }))))
|
|
4302
4772
|
: h('div', { className: 'capital-automation-chatempty' },
|
|
4303
4773
|
h('p', null, zh.board.askEmptyTitle)),
|
|
4304
4774
|
error.length > 0 ? h('p', { className: 'capital-automation-askerror', role: 'alert' }, error) : null),
|
|
@@ -4326,39 +4796,75 @@ function AskDialog(props) {
|
|
|
4326
4796
|
}, busy ? zh.processing : zh.board.askSubmit))))
|
|
4327
4797
|
}
|
|
4328
4798
|
|
|
4799
|
+
function compareAsks(left, right) {
|
|
4800
|
+
const time = String(left?.createdAt ?? '').localeCompare(String(right?.createdAt ?? ''))
|
|
4801
|
+
if (time !== 0) return time
|
|
4802
|
+
return String(left?.id ?? '').localeCompare(String(right?.id ?? ''))
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4805
|
+
function mergeAsks(current, incoming) {
|
|
4806
|
+
const byId = new Map()
|
|
4807
|
+
for (const ask of Array.isArray(current) ? current : []) {
|
|
4808
|
+
if (ask !== null && typeof ask === 'object' && typeof ask.id === 'string') byId.set(ask.id, ask)
|
|
4809
|
+
}
|
|
4810
|
+
for (const ask of Array.isArray(incoming) ? incoming : []) {
|
|
4811
|
+
if (ask === null || typeof ask !== 'object' || typeof ask.id !== 'string') continue
|
|
4812
|
+
const existing = byId.get(ask.id)
|
|
4813
|
+
if (existing !== undefined) {
|
|
4814
|
+
// A board refresh can trail a resolved local ask; never roll a terminal state back to running.
|
|
4815
|
+
if (existing.status !== 'running' && ask.status === 'running') continue
|
|
4816
|
+
if (existing.status === ask.status
|
|
4817
|
+
&& typeof existing.preview === 'string' && typeof ask.preview === 'string'
|
|
4818
|
+
&& Array.from(existing.preview).length > Array.from(ask.preview).length) continue
|
|
4819
|
+
}
|
|
4820
|
+
byId.set(ask.id, ask)
|
|
4821
|
+
}
|
|
4822
|
+
return Array.from(byId.values()).sort(compareAsks)
|
|
4823
|
+
}
|
|
4824
|
+
|
|
4329
4825
|
function AskDock(props) {
|
|
4330
4826
|
const { card, identity, api, onOpenSession, open, onClose } = props
|
|
4331
|
-
const [
|
|
4827
|
+
const [thread, setThread] = useState(() => (card.ask ? [card.ask] : []))
|
|
4332
4828
|
const [question, setQuestion] = useState('')
|
|
4333
4829
|
const [busy, setBusy] = useState(false)
|
|
4334
4830
|
const [error, setError] = useState('')
|
|
4831
|
+
const [historyError, setHistoryError] = useState('')
|
|
4335
4832
|
const incoming = card.ask ?? null
|
|
4833
|
+
const latest = thread.length > 0 ? thread[thread.length - 1] : null
|
|
4336
4834
|
|
|
4337
4835
|
useEffect(() => {
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
if (incoming === null) return current
|
|
4341
|
-
if (current === null || current.id !== incoming.id) {
|
|
4342
|
-
if (current !== null && String(current.createdAt ?? '') > String(incoming.createdAt ?? '')) return current
|
|
4343
|
-
return incoming
|
|
4344
|
-
}
|
|
4345
|
-
if (current.status !== 'running' && incoming.status === 'running') return current
|
|
4346
|
-
return incoming
|
|
4347
|
-
})
|
|
4836
|
+
if (incoming === null) return
|
|
4837
|
+
setThread((current) => mergeAsks(current, [incoming]))
|
|
4348
4838
|
}, [incoming?.id, incoming?.status, incoming?.preview, incoming?.error])
|
|
4349
4839
|
|
|
4350
4840
|
useEffect(() => {
|
|
4351
4841
|
if (!open) return
|
|
4352
4842
|
setQuestion('')
|
|
4353
4843
|
setError('')
|
|
4844
|
+
setHistoryError('')
|
|
4354
4845
|
}, [open])
|
|
4355
4846
|
|
|
4847
|
+
useEffect(() => {
|
|
4848
|
+
if (!open || typeof api?.askHistory !== 'function') return undefined
|
|
4849
|
+
let cancelled = false
|
|
4850
|
+
api.askHistory(card.runId).then((payload) => {
|
|
4851
|
+
if (cancelled) return
|
|
4852
|
+
setThread((current) => mergeAsks(current, Array.isArray(payload?.asks) ? payload.asks : []))
|
|
4853
|
+
setHistoryError('')
|
|
4854
|
+
}).catch((failure) => {
|
|
4855
|
+
if (!cancelled) setHistoryError(failure?.message ?? zh.errorGeneric)
|
|
4856
|
+
})
|
|
4857
|
+
return () => {
|
|
4858
|
+
cancelled = true
|
|
4859
|
+
}
|
|
4860
|
+
}, [open, card.runId, api])
|
|
4861
|
+
|
|
4356
4862
|
useEffect(() => {
|
|
4357
4863
|
if (latest === null || latest.status !== 'ready' || typeof api?.askStatus !== 'function') return undefined
|
|
4358
4864
|
if (typeof latest.preview !== 'string' || !latest.preview.endsWith('…') || Array.from(latest.preview).length > 80) return undefined
|
|
4359
4865
|
let cancelled = false
|
|
4360
4866
|
api.askStatus(latest.id).then((payload) => {
|
|
4361
|
-
if (!cancelled && payload?.ask)
|
|
4867
|
+
if (!cancelled && payload?.ask) setThread((current) => mergeAsks(current, [payload.ask]))
|
|
4362
4868
|
}).catch(() => {})
|
|
4363
4869
|
return () => {
|
|
4364
4870
|
cancelled = true
|
|
@@ -4373,7 +4879,7 @@ function AskDock(props) {
|
|
|
4373
4879
|
try {
|
|
4374
4880
|
const payload = await api.askStatus(latest.id)
|
|
4375
4881
|
if (cancelled) return
|
|
4376
|
-
if (payload?.ask)
|
|
4882
|
+
if (payload?.ask) setThread((current) => mergeAsks(current, [payload.ask]))
|
|
4377
4883
|
} catch {
|
|
4378
4884
|
// The dialog shows the actionable error; the card preview keeps its last known state.
|
|
4379
4885
|
} finally {
|
|
@@ -4401,7 +4907,7 @@ function AskDock(props) {
|
|
|
4401
4907
|
try {
|
|
4402
4908
|
const payload = await api.askBrief(card.runId, text, browserTimeZone())
|
|
4403
4909
|
if (payload?.ask) {
|
|
4404
|
-
|
|
4910
|
+
setThread((current) => mergeAsks(current, [payload.ask]))
|
|
4405
4911
|
setQuestion('')
|
|
4406
4912
|
} else {
|
|
4407
4913
|
setError(zh.errorGeneric)
|
|
@@ -4421,13 +4927,14 @@ function AskDock(props) {
|
|
|
4421
4927
|
onClose: requestClose,
|
|
4422
4928
|
card,
|
|
4423
4929
|
identity,
|
|
4424
|
-
|
|
4930
|
+
asks: thread,
|
|
4425
4931
|
api,
|
|
4426
4932
|
question,
|
|
4427
4933
|
onQuestionChange: setQuestion,
|
|
4428
4934
|
onSubmit: submit,
|
|
4429
4935
|
busy,
|
|
4430
4936
|
error,
|
|
4937
|
+
historyError,
|
|
4431
4938
|
onOpenSession,
|
|
4432
4939
|
})
|
|
4433
4940
|
if (latest === null) return dialog
|
|
@@ -4437,7 +4944,7 @@ function AskDock(props) {
|
|
|
4437
4944
|
}
|
|
4438
4945
|
|
|
4439
4946
|
function BriefCard(props) {
|
|
4440
|
-
const { card, task, api, onOpenSession, onRetry, retrying } = props
|
|
4947
|
+
const { card, task, api, onOpenSession, onRetry, retrying, highlighted = false } = props
|
|
4441
4948
|
const [askOpen, setAskOpen] = useState(false)
|
|
4442
4949
|
// Older /board payloads omit icon/origin; the task list carries the same identity.
|
|
4443
4950
|
const identity = typeof card.icon === 'string' ? card : (task ?? card)
|
|
@@ -4466,9 +4973,6 @@ function BriefCard(props) {
|
|
|
4466
4973
|
onClick: () => setAskOpen(true),
|
|
4467
4974
|
}, h(IconNewChatOutlineRegular, { size: 14 }))
|
|
4468
4975
|
: null
|
|
4469
|
-
const openLink = openSession
|
|
4470
|
-
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: openSession }, zh.openSession)
|
|
4471
|
-
: null
|
|
4472
4976
|
const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
|
|
4473
4977
|
const relativeTime = boardRelativeTime(card.finishedAt)
|
|
4474
4978
|
const exactTime = formatTime(card.finishedAt)
|
|
@@ -4488,12 +4992,10 @@ function BriefCard(props) {
|
|
|
4488
4992
|
'data-size': 'sm',
|
|
4489
4993
|
disabled: retrying === true,
|
|
4490
4994
|
onClick: () => onRetry(card.runId),
|
|
4491
|
-
}, retrying === true ? zh.processing : zh.board.retry)
|
|
4492
|
-
openLink))
|
|
4995
|
+
}, retrying === true ? zh.processing : zh.board.retry)))
|
|
4493
4996
|
} else if (status === 'skipped') {
|
|
4494
4997
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4495
|
-
h('p', null, zh.board.briefSkipped)
|
|
4496
|
-
h('div', { className: 'capital-automation-briefactions' }, openLink))
|
|
4998
|
+
h('p', null, zh.board.briefSkipped))
|
|
4497
4999
|
} else {
|
|
4498
5000
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4499
5001
|
h(SkeletonBlock, { width: '72%', height: 14 }),
|
|
@@ -4501,7 +5003,12 @@ function BriefCard(props) {
|
|
|
4501
5003
|
h(SkeletonBlock, { width: '88%', height: 10 }),
|
|
4502
5004
|
h('p', { className: 'capital-automation-hint' }, zh.board.briefPending))
|
|
4503
5005
|
}
|
|
4504
|
-
return h('article', {
|
|
5006
|
+
return h('article', {
|
|
5007
|
+
className: 'capital-automation-briefcard',
|
|
5008
|
+
'data-status': status,
|
|
5009
|
+
'data-highlight': highlighted === true ? 'true' : undefined,
|
|
5010
|
+
'aria-labelledby': titleId,
|
|
5011
|
+
},
|
|
4505
5012
|
h('div', { className: 'capital-automation-briefhead' },
|
|
4506
5013
|
h('div', { className: 'capital-automation-brieftitle' },
|
|
4507
5014
|
h(Glyph, { task: identity, size: 24, radius: 8, glyphSize: 14 }),
|
|
@@ -4554,7 +5061,7 @@ function BoardSkeleton(props) {
|
|
|
4554
5061
|
}
|
|
4555
5062
|
|
|
4556
5063
|
function BriefFeed(props) {
|
|
4557
|
-
const { cards, tasks, api, loading, error, onOpenSession, onRetry, retryingRunId, onViewAll, onClearFilter, onLoadMore, hasMore, loadingMore, railOpen } = props
|
|
5064
|
+
const { cards, tasks, api, loading, error, onOpenSession, onRetry, retryingRunId, onViewAll, onClearFilter, onLoadMore, hasMore, loadingMore, railOpen, highlightToken = 0 } = props
|
|
4558
5065
|
if (loading === true) return h(BoardSkeleton, { railOpen })
|
|
4559
5066
|
if (typeof error === 'string' && error.length > 0) {
|
|
4560
5067
|
return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs' },
|
|
@@ -4571,6 +5078,7 @@ function BriefFeed(props) {
|
|
|
4571
5078
|
onClearFilter ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: onClearFilter }, zh.board.clearFilter) : null)))
|
|
4572
5079
|
}
|
|
4573
5080
|
const taskById = new Map((Array.isArray(tasks) ? tasks : []).map((task) => [task.id, task]))
|
|
5081
|
+
const today = localDateKey(new Date())
|
|
4574
5082
|
return h('section', { className: 'capital-automation-boardmain', id: 'capital-automation-briefs', 'aria-label': zh.board.briefTitle },
|
|
4575
5083
|
cards.map((card) => h(BriefCard, {
|
|
4576
5084
|
key: card.runId,
|
|
@@ -4580,6 +5088,7 @@ function BriefFeed(props) {
|
|
|
4580
5088
|
onOpenSession,
|
|
4581
5089
|
onRetry,
|
|
4582
5090
|
retrying: retryingRunId === card.runId,
|
|
5091
|
+
highlighted: highlightToken > 0 && boardCardIsToday(card, today),
|
|
4583
5092
|
})),
|
|
4584
5093
|
hasMore
|
|
4585
5094
|
? h('button', {
|
|
@@ -4592,8 +5101,9 @@ function BriefFeed(props) {
|
|
|
4592
5101
|
}
|
|
4593
5102
|
|
|
4594
5103
|
function TodoRow(props) {
|
|
4595
|
-
const { item, period, showDue = true, onOpenSession,
|
|
5104
|
+
const { item, period, showDue = true, onOpenSession, onDecide, checkpointHint = '', pending = false } = props
|
|
4596
5105
|
const [open, setOpen] = useState(false)
|
|
5106
|
+
const [menuOpen, setMenuOpen] = useState(false)
|
|
4597
5107
|
const quote = item.sourceQuote ?? item.sources?.[0]?.sourceQuote
|
|
4598
5108
|
const due = showDue === true ? boardTodoDueLabel(item, period) : ''
|
|
4599
5109
|
const source = {
|
|
@@ -4602,23 +5112,118 @@ function TodoRow(props) {
|
|
|
4602
5112
|
sessionId: item.sessionId ?? item.sources?.[0]?.sessionId,
|
|
4603
5113
|
}
|
|
4604
5114
|
const meta = []
|
|
5115
|
+
const watch = item.watch && typeof item.watch === 'object' ? item.watch : null
|
|
5116
|
+
const archived = period === 'expired'
|
|
5117
|
+
const status = archived ? 'expired' : boardTodoStatus(item)
|
|
5118
|
+
const decision = boardTodoDecision(item)
|
|
5119
|
+
const decided = decision !== undefined
|
|
5120
|
+
const compact = decided || archived
|
|
5121
|
+
const watchLabel = boardTodoWatchLabel(status)
|
|
4605
5122
|
if (due) meta.push(h('span', { key: 'due' }, due))
|
|
5123
|
+
if (archived) {
|
|
5124
|
+
const outcome = boardTodoOutcome(item)
|
|
5125
|
+
if (outcome.length > 0) meta.push(h('span', { key: 'outcome', className: 'capital-automation-todooutcome' }, outcome))
|
|
5126
|
+
}
|
|
4606
5127
|
if (item.seenCount > 1) meta.push(h('span', { key: 'seen' }, zh.board.seenCount.replace('{n}', String(item.seenCount))))
|
|
5128
|
+
if (watch?.checkedAt && status !== 'resolved' && status !== 'deferred' && status !== 'tracking') {
|
|
5129
|
+
meta.push(h('span', { key: 'checked' }, zh.board.watchChecked.replace('{time}', formatShortTime(watch.checkedAt))))
|
|
5130
|
+
}
|
|
5131
|
+
const watchMessage = status === 'triggered'
|
|
5132
|
+
? `${zh.board.watchEvidence}:${watch?.evidence ?? ''}${watch?.source ? ` · ${zh.board.watchSource}:${watch.source}` : ''}`
|
|
5133
|
+
: ''
|
|
5134
|
+
const actionable = !archived && boardTodoCheckable(status)
|
|
5135
|
+
const pastDue = typeof item.dueAt === 'string' && item.dueAt < localDateKey(new Date())
|
|
5136
|
+
const autoAvailable = !archived && !pastDue && boardTodoAutoAvailable(item, status)
|
|
4607
5137
|
const basisAction = open ? zh.board.hideBasis : zh.board.showBasis
|
|
4608
5138
|
const basisCaret = h('span', { className: 'capital-automation-basiscaret', 'aria-hidden': 'true' }, h(IconChevronDownOutlineRegular, { size: 12 }))
|
|
4609
|
-
|
|
4610
|
-
h('div', { className: 'capital-automation-
|
|
5139
|
+
const tags = watchLabel.length > 0
|
|
5140
|
+
? h('div', { className: 'capital-automation-todotags' },
|
|
5141
|
+
h('span', {
|
|
5142
|
+
className: 'capital-automation-todowatch',
|
|
5143
|
+
'data-status': status,
|
|
5144
|
+
title: boardTodoWatchHint(status, checkpointHint),
|
|
5145
|
+
},
|
|
5146
|
+
watchLabel))
|
|
5147
|
+
: null
|
|
5148
|
+
const menuItems = []
|
|
5149
|
+
if (actionable) {
|
|
5150
|
+
menuItems.push({
|
|
5151
|
+
id: 'confirm',
|
|
5152
|
+
label: decision === 'confirmed' ? `${zh.board.todoActionConfirm}(当前)` : zh.board.todoActionConfirm,
|
|
5153
|
+
icon: h(IconChecklistOutlineRegular, { size: 14 }),
|
|
5154
|
+
disabled: pending || decision === 'confirmed',
|
|
5155
|
+
})
|
|
5156
|
+
if (autoAvailable) {
|
|
5157
|
+
menuItems.push({
|
|
5158
|
+
id: 'auto',
|
|
5159
|
+
label: zh.board.todoActionAuto,
|
|
5160
|
+
icon: h(IconSparkleRegular, { size: 14 }),
|
|
5161
|
+
disabled: pending,
|
|
5162
|
+
})
|
|
5163
|
+
} else if (actionable && status !== 'watching') {
|
|
5164
|
+
const autoReason = pastDue && status !== 'triggered' && item.kind !== 'track' ? '已过期' : boardTodoAutoReason(item, status)
|
|
5165
|
+
if (autoReason.length > 0) {
|
|
5166
|
+
menuItems.push({
|
|
5167
|
+
id: 'auto-unavailable',
|
|
5168
|
+
label: `${zh.board.todoActionAuto}(${autoReason})`,
|
|
5169
|
+
icon: h(IconSparkleRegular, { size: 14 }),
|
|
5170
|
+
disabled: true,
|
|
5171
|
+
})
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
menuItems.push({
|
|
5175
|
+
id: 'defer',
|
|
5176
|
+
label: decision === 'deferred' ? `${zh.board.todoActionDefer}(当前)` : zh.board.todoActionDefer,
|
|
5177
|
+
icon: h(IconClockOutlineRegular, { size: 14 }),
|
|
5178
|
+
disabled: pending || decision === 'deferred',
|
|
5179
|
+
})
|
|
5180
|
+
}
|
|
5181
|
+
const menu = actionable
|
|
5182
|
+
? h(Menu, {
|
|
5183
|
+
open: menuOpen,
|
|
5184
|
+
anchor: h('button', {
|
|
5185
|
+
type: 'button',
|
|
5186
|
+
className: 'capital-automation-todomenu',
|
|
5187
|
+
title: zh.board.todoMoreTitle,
|
|
5188
|
+
'aria-label': `${zh.board.todoMoreTitle}:${item.title}`,
|
|
5189
|
+
'aria-haspopup': 'menu',
|
|
5190
|
+
'aria-expanded': menuOpen ? 'true' : 'false',
|
|
5191
|
+
disabled: pending === true,
|
|
5192
|
+
onClick: () => setMenuOpen((value) => !value),
|
|
5193
|
+
}, h(IconEllipsisOutlineRegular, { size: 16 })),
|
|
5194
|
+
items: menuItems,
|
|
5195
|
+
onSelect: (id) => {
|
|
5196
|
+
setMenuOpen(false)
|
|
5197
|
+
if (id === 'confirm' || id === 'auto' || id === 'defer') onDecide(item, id)
|
|
5198
|
+
},
|
|
5199
|
+
onClose: () => setMenuOpen(false),
|
|
5200
|
+
align: 'end',
|
|
5201
|
+
portal: true,
|
|
5202
|
+
})
|
|
5203
|
+
: null
|
|
5204
|
+
return h('li', {
|
|
5205
|
+
className: 'capital-automation-todoitem',
|
|
5206
|
+
'data-decided': decided ? 'true' : undefined,
|
|
5207
|
+
'data-archived': archived ? 'true' : undefined,
|
|
5208
|
+
'data-decision': decision,
|
|
5209
|
+
},
|
|
5210
|
+
compact
|
|
5211
|
+
? h('div', { className: 'capital-automation-todoline' },
|
|
4611
5212
|
h('div', { className: 'capital-automation-todotop' },
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
5213
|
+
tags,
|
|
5214
|
+
archived
|
|
5215
|
+
? h('button', {
|
|
5216
|
+
type: 'button',
|
|
5217
|
+
className: 'capital-automation-todotitle',
|
|
5218
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
5219
|
+
'aria-label': `${item.title},${basisAction}`,
|
|
5220
|
+
title: basisAction,
|
|
5221
|
+
onClick: () => setOpen((value) => !value),
|
|
5222
|
+
}, item.title, basisCaret)
|
|
5223
|
+
: h('span', { className: 'capital-automation-todotitle', title: item.title }, item.title),
|
|
5224
|
+
menu))
|
|
5225
|
+
: h('div', { className: 'capital-automation-todoline' },
|
|
5226
|
+
h('div', { className: 'capital-automation-todotop' }, tags, menu),
|
|
4622
5227
|
h('button', {
|
|
4623
5228
|
type: 'button',
|
|
4624
5229
|
className: 'capital-automation-todotitle',
|
|
@@ -4627,26 +5232,34 @@ function TodoRow(props) {
|
|
|
4627
5232
|
title: basisAction,
|
|
4628
5233
|
onClick: () => setOpen((value) => !value),
|
|
4629
5234
|
}, item.title, basisCaret)),
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
5235
|
+
!compact && item.detail ? h('p', { className: 'capital-automation-tododesc' }, item.detail) : null,
|
|
5236
|
+
!compact && watchMessage.length > 0
|
|
5237
|
+
? h('p', { className: 'capital-automation-todowatchmsg', 'data-status': status }, watchMessage)
|
|
5238
|
+
: null,
|
|
5239
|
+
(archived || !decided) && meta.length > 0 ? h('div', { className: 'capital-automation-todometa' }, meta) : null,
|
|
5240
|
+
(archived || !decided) && open
|
|
5241
|
+
? h('div', { className: 'capital-automation-tododetail' },
|
|
5242
|
+
archived && item.detail ? h('p', { className: 'capital-automation-tododesc' }, item.detail) : null,
|
|
5243
|
+
archived && watch?.evidence
|
|
5244
|
+
? h('p', { className: 'capital-automation-todowatchmsg', 'data-status': status },
|
|
5245
|
+
`${zh.board.watchEvidence}:${watch.evidence}${watch.source ? ` · ${zh.board.watchSource}:${watch.source}` : ''}`)
|
|
5246
|
+
: null,
|
|
5247
|
+
h('blockquote', null, quote),
|
|
5248
|
+
source
|
|
5249
|
+
? h('div', { className: 'capital-automation-todosource' },
|
|
5250
|
+
h('span', null, `${zh.board.sourceRun}:${source.taskTitle} · ${formatShortTime(source.finishedAt)}`),
|
|
5251
|
+
source.sessionId
|
|
5252
|
+
? h('button', {
|
|
5253
|
+
type: 'button',
|
|
5254
|
+
className: 'capital-automation-btn',
|
|
5255
|
+
'data-size': 'icon',
|
|
5256
|
+
title: zh.openSession,
|
|
5257
|
+
'aria-label': zh.openSession,
|
|
5258
|
+
onClick: () => onOpenSession(source.sessionId),
|
|
5259
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
5260
|
+
: null)
|
|
5261
|
+
: null)
|
|
5262
|
+
: null)
|
|
4650
5263
|
}
|
|
4651
5264
|
|
|
4652
5265
|
function BoardPanelHead(props) {
|
|
@@ -4688,12 +5301,11 @@ function BoardPanel(props) {
|
|
|
4688
5301
|
}
|
|
4689
5302
|
|
|
4690
5303
|
function TodoPanel(props) {
|
|
4691
|
-
const { todos, onOpenSession,
|
|
5304
|
+
const { todos, tasks, onOpenSession, onDecideTodo, pendingTodoIds = new Set(), open, onToggle } = props
|
|
4692
5305
|
const [filter, setFilter] = useState('today')
|
|
4693
|
-
const
|
|
4694
|
-
const entries = todos.map((item) => ({ item, period: boardTodoPeriod(item, now) }))
|
|
4695
|
-
entries.sort((left, right) => BOARD_TODO_PERIODS.indexOf(left.period) - BOARD_TODO_PERIODS.indexOf(right.period))
|
|
5306
|
+
const entries = boardTodoEntries(todos, new Date())
|
|
4696
5307
|
const visible = entries.filter((entry) => entry.period === filter)
|
|
5308
|
+
const checkpointHint = boardTodoVerifierHint(tasks)
|
|
4697
5309
|
const emptyText = filter === 'today'
|
|
4698
5310
|
? zh.board.todoEmptyToday
|
|
4699
5311
|
: zh.board.todoEmptyGroup.replace('{label}', boardTodoGroupLabel(filter))
|
|
@@ -4719,9 +5331,9 @@ function TodoPanel(props) {
|
|
|
4719
5331
|
period: entry.period,
|
|
4720
5332
|
showDue: true,
|
|
4721
5333
|
onOpenSession,
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
5334
|
+
onDecide: onDecideTodo,
|
|
5335
|
+
checkpointHint,
|
|
5336
|
+
pending: pendingTodoIds.has(entry.item.id),
|
|
4725
5337
|
}))))
|
|
4726
5338
|
}
|
|
4727
5339
|
|
|
@@ -4732,53 +5344,136 @@ function boardRoleLabel(role) {
|
|
|
4732
5344
|
return zh.board.roleRisk
|
|
4733
5345
|
}
|
|
4734
5346
|
|
|
5347
|
+
function boardRoleHint(role) {
|
|
5348
|
+
if (role === 'holding') return zh.board.roleHoldingHint
|
|
5349
|
+
if (role === 'watch') return zh.board.roleWatchHint
|
|
5350
|
+
if (role === 'event') return zh.board.roleEventHint
|
|
5351
|
+
return zh.board.roleRiskHint
|
|
5352
|
+
}
|
|
5353
|
+
|
|
5354
|
+
function boardRoleTitle(role) {
|
|
5355
|
+
return `${boardRoleLabel(role)}:${boardRoleHint(role)}`
|
|
5356
|
+
}
|
|
5357
|
+
|
|
5358
|
+
function boardStockFilterOptions() {
|
|
5359
|
+
return [{ value: 'all', label: zh.board.stockFilterAll }].concat(
|
|
5360
|
+
BOARD_STOCK_ROLES.map((role) => ({ value: role, label: boardRoleLabel(role) })),
|
|
5361
|
+
)
|
|
5362
|
+
}
|
|
5363
|
+
|
|
5364
|
+
function boardEntrySymbolKey(entry) {
|
|
5365
|
+
return typeof entry.symbolKey === 'string' ? entry.symbolKey : entry.symbol
|
|
5366
|
+
}
|
|
5367
|
+
|
|
4735
5368
|
function StockRow(props) {
|
|
4736
5369
|
const { stock, todos, onOpenSession } = props
|
|
4737
5370
|
const [open, setOpen] = useState(false)
|
|
4738
|
-
const
|
|
5371
|
+
const stockKey = boardEntrySymbolKey(stock)
|
|
5372
|
+
const related = Array.isArray(stock.items)
|
|
5373
|
+
? stock.items
|
|
5374
|
+
: todos.filter((item) => item.ackedAt === undefined && item.deferredAt === undefined
|
|
5375
|
+
&& boardTodoPeriod(item) !== 'expired'
|
|
5376
|
+
&& boardEntrySymbolKey(item) === stockKey)
|
|
5377
|
+
const followUpCount = Array.isArray(stock.items) ? stock.items.length : (stock.todoCount ?? 0)
|
|
5378
|
+
const roleSummary = stock.roles.map((role) => boardRoleTitle(role)).join(';')
|
|
4739
5379
|
return h('div', { className: 'capital-automation-stockrow' },
|
|
4740
5380
|
h('button', {
|
|
4741
5381
|
type: 'button',
|
|
4742
5382
|
className: 'capital-automation-stockmain',
|
|
4743
5383
|
'aria-expanded': open ? 'true' : 'false',
|
|
5384
|
+
'aria-label': `${stock.name} ${stock.symbol}${roleSummary.length > 0 ? `,${roleSummary}` : ''}`,
|
|
4744
5385
|
onClick: () => setOpen((value) => !value),
|
|
4745
5386
|
},
|
|
4746
5387
|
h('span', { className: 'capital-automation-stockname' }, stock.name),
|
|
4747
5388
|
h('span', { className: 'capital-automation-stockcode' }, stock.symbol),
|
|
4748
5389
|
h('span', { className: 'capital-automation-stockroles' },
|
|
4749
|
-
stock.roles.map((role) => h('span', {
|
|
5390
|
+
stock.roles.map((role) => h('span', {
|
|
5391
|
+
key: role,
|
|
5392
|
+
className: 'capital-automation-stockrole',
|
|
5393
|
+
'data-role': role,
|
|
5394
|
+
title: boardRoleTitle(role),
|
|
5395
|
+
}, boardRoleLabel(role)))),
|
|
4750
5396
|
stock.note ? h('span', { className: 'capital-automation-stocknote' }, stock.note) : null,
|
|
4751
5397
|
h('span', { className: 'capital-automation-stockmeta' },
|
|
4752
5398
|
stock.nextAt ? h('span', null, stock.nextAt) : null,
|
|
4753
|
-
|
|
5399
|
+
followUpCount > 0
|
|
5400
|
+
? h('span', { title: zh.board.stockTodoCountHint }, zh.board.stockTodoCount.replace('{n}', String(followUpCount)))
|
|
5401
|
+
: null)),
|
|
4754
5402
|
open && related.length > 0
|
|
4755
5403
|
? h('ul', { className: 'capital-automation-stocktodos' }, related.map((item) => h('li', { key: item.id },
|
|
4756
|
-
|
|
4757
|
-
|
|
5404
|
+
item.sessionId
|
|
5405
|
+
? h('button', {
|
|
5406
|
+
type: 'button',
|
|
5407
|
+
className: 'capital-automation-stocktodo',
|
|
5408
|
+
title: zh.openSession,
|
|
5409
|
+
'aria-label': `${item.title},${zh.openSession}`,
|
|
5410
|
+
onClick: () => onOpenSession(item.sessionId),
|
|
5411
|
+
},
|
|
5412
|
+
h('span', { className: 'capital-automation-stocktodotitle' }, item.title),
|
|
5413
|
+
h(IconRightUpOutlineRegular, { size: 12, 'aria-hidden': 'true' }))
|
|
5414
|
+
: h('span', { className: 'capital-automation-stocktodo', 'data-static': 'true' }, item.title))))
|
|
4758
5415
|
: null)
|
|
4759
5416
|
}
|
|
4760
5417
|
|
|
4761
5418
|
function StockRadar(props) {
|
|
4762
5419
|
const { stocks, todos, total, onOpenSession, open, onToggle } = props
|
|
4763
|
-
const
|
|
5420
|
+
const [filter, setFilter] = useState('all')
|
|
5421
|
+
const [showAll, setShowAll] = useState(false)
|
|
5422
|
+
const totalCount = total ?? stocks.length
|
|
5423
|
+
const filtered = filter === 'all'
|
|
5424
|
+
? stocks
|
|
5425
|
+
: stocks.filter((stock) => Array.isArray(stock.roles) && stock.roles.includes(filter))
|
|
5426
|
+
const visible = showAll ? filtered : filtered.slice(0, BOARD_STOCK_PAGE_SIZE)
|
|
5427
|
+
const hidden = Math.max(0, filtered.length - visible.length)
|
|
5428
|
+
const capped = Math.max(0, totalCount - stocks.length)
|
|
5429
|
+
const countText = filter === 'all'
|
|
5430
|
+
? zh.board.stocksCount.replace('{n}', String(totalCount))
|
|
5431
|
+
: zh.board.stockFilteredCount.replace('{shown}', String(filtered.length)).replace('{total}', String(totalCount))
|
|
4764
5432
|
return h(BoardPanel, {
|
|
4765
5433
|
id: 'capital-automation-stocks',
|
|
4766
|
-
title: zh.board.
|
|
5434
|
+
title: zh.board.stockTitle,
|
|
4767
5435
|
open,
|
|
4768
5436
|
onToggle,
|
|
4769
|
-
|
|
5437
|
+
action: stocks.length === 0
|
|
5438
|
+
? null
|
|
5439
|
+
: h('div', { className: 'capital-automation-stockfilters' },
|
|
5440
|
+
h('span', { className: 'capital-automation-hint' }, countText),
|
|
5441
|
+
h(Select, {
|
|
5442
|
+
value: filter,
|
|
5443
|
+
options: boardStockFilterOptions(),
|
|
5444
|
+
onChange: (value) => { setFilter(value); setShowAll(false) },
|
|
5445
|
+
size: 'sm',
|
|
5446
|
+
label: zh.board.stockFilterLabel,
|
|
5447
|
+
align: 'end',
|
|
5448
|
+
})),
|
|
4770
5449
|
},
|
|
4771
5450
|
stocks.length === 0
|
|
4772
5451
|
? h('p', { className: 'capital-automation-hint' }, zh.board.stockEmpty)
|
|
4773
|
-
:
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
5452
|
+
: filtered.length === 0
|
|
5453
|
+
? h('p', { className: 'capital-automation-hint' }, zh.board.stockFilterEmpty)
|
|
5454
|
+
: [
|
|
5455
|
+
...visible.map((stock) => h(StockRow, { key: boardEntrySymbolKey(stock), stock, todos, onOpenSession })),
|
|
5456
|
+
hidden > 0
|
|
5457
|
+
? h('button', {
|
|
5458
|
+
key: 'stock-more',
|
|
5459
|
+
type: 'button',
|
|
5460
|
+
className: 'capital-automation-btn capital-automation-stockmore',
|
|
5461
|
+
'data-size': 'sm',
|
|
5462
|
+
onClick: () => setShowAll(true),
|
|
5463
|
+
}, zh.board.stockShowAll.replace('{n}', String(hidden)))
|
|
5464
|
+
: showAll && filtered.length > BOARD_STOCK_PAGE_SIZE
|
|
5465
|
+
? h('button', {
|
|
5466
|
+
key: 'stock-less',
|
|
5467
|
+
type: 'button',
|
|
5468
|
+
className: 'capital-automation-btn capital-automation-stockmore',
|
|
5469
|
+
'data-size': 'sm',
|
|
5470
|
+
onClick: () => setShowAll(false),
|
|
5471
|
+
}, zh.board.stockShowLess)
|
|
5472
|
+
: null,
|
|
5473
|
+
capped > 0
|
|
5474
|
+
? h('p', { key: 'stock-capped', className: 'capital-automation-hint' }, zh.board.stockOther.replace('{n}', String(capped)))
|
|
5475
|
+
: null,
|
|
5476
|
+
])
|
|
4782
5477
|
}
|
|
4783
5478
|
|
|
4784
5479
|
function GapRow(props) {
|
|
@@ -4788,7 +5483,6 @@ function GapRow(props) {
|
|
|
4788
5483
|
const basisAction = open ? zh.board.hideBasis : zh.board.showBasis
|
|
4789
5484
|
return h('li', { className: 'capital-automation-gaprow' },
|
|
4790
5485
|
h('div', { className: 'capital-automation-gaphead' },
|
|
4791
|
-
h('span', { className: 'capital-automation-gapkind', 'data-kind': gap.kind }, boardGapLabel(gap.kind)),
|
|
4792
5486
|
h('button', {
|
|
4793
5487
|
type: 'button',
|
|
4794
5488
|
className: 'capital-automation-gaptitle',
|
|
@@ -4801,8 +5495,20 @@ function GapRow(props) {
|
|
|
4801
5495
|
open
|
|
4802
5496
|
? h('div', { className: 'capital-automation-tododetail' },
|
|
4803
5497
|
h('blockquote', null, source?.sourceQuote ?? gap.sourceQuote),
|
|
4804
|
-
source
|
|
4805
|
-
|
|
5498
|
+
source
|
|
5499
|
+
? h('div', { className: 'capital-automation-todosource' },
|
|
5500
|
+
h('span', null, `${source.taskTitle} · ${formatShortTime(source.finishedAt)}`),
|
|
5501
|
+
source.sessionId
|
|
5502
|
+
? h('button', {
|
|
5503
|
+
type: 'button',
|
|
5504
|
+
className: 'capital-automation-btn',
|
|
5505
|
+
'data-size': 'icon',
|
|
5506
|
+
title: zh.openSession,
|
|
5507
|
+
'aria-label': zh.openSession,
|
|
5508
|
+
onClick: () => onOpenSession(source.sessionId),
|
|
5509
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
5510
|
+
: null)
|
|
5511
|
+
: null)
|
|
4806
5512
|
: null)
|
|
4807
5513
|
}
|
|
4808
5514
|
|
|
@@ -4882,7 +5588,16 @@ function RunHealthPanel(props) {
|
|
|
4882
5588
|
h('span', { className: 'capital-automation-healthissuetitle' }, issue.taskTitle),
|
|
4883
5589
|
h('span', { className: 'capital-automation-healthissuestatus', 'data-tone': tone ?? undefined }, statusLabel(issue.status)),
|
|
4884
5590
|
issue.recoveredByRunId ? h('span', { className: 'capital-automation-healthrecovered' }, zh.board.healthRecovered) : null),
|
|
4885
|
-
issue.sessionId
|
|
5591
|
+
issue.sessionId
|
|
5592
|
+
? h('button', {
|
|
5593
|
+
type: 'button',
|
|
5594
|
+
className: 'capital-automation-btn',
|
|
5595
|
+
'data-size': 'icon',
|
|
5596
|
+
title: zh.openSession,
|
|
5597
|
+
'aria-label': zh.openSession,
|
|
5598
|
+
onClick: () => onOpenSession(issue.sessionId),
|
|
5599
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
5600
|
+
: null)
|
|
4886
5601
|
}))
|
|
4887
5602
|
: h('p', { className: 'capital-automation-healthempty' }, zh.board.healthNoIssues))
|
|
4888
5603
|
}
|
|
@@ -4891,11 +5606,18 @@ function BoardPage(props) {
|
|
|
4891
5606
|
const {
|
|
4892
5607
|
board, tasks, api, loading, error, range, category, onRange, onCategory, onRefresh,
|
|
4893
5608
|
onOpenSession, onRetryBrief, retryingRunId, onLoadMore, loadingMore, onGoTasks, onNewTask, onGoRuns,
|
|
4894
|
-
|
|
5609
|
+
onDecideTodo, pendingTodoIds, hasActiveTasks, storageReady,
|
|
4895
5610
|
} = props
|
|
4896
5611
|
const [railOpen, setRailOpen] = useState(() => readBoardUi().rail !== false)
|
|
4897
5612
|
const [openPanels, setOpenPanels] = useState(() => boardPanelFlags(readBoardUi().panels))
|
|
4898
5613
|
const [pendingJump, setPendingJump] = useState(null)
|
|
5614
|
+
const [briefHighlight, setBriefHighlight] = useState(0)
|
|
5615
|
+
|
|
5616
|
+
useEffect(() => {
|
|
5617
|
+
if (briefHighlight === 0) return undefined
|
|
5618
|
+
const timer = setTimeout(() => setBriefHighlight(0), BOARD_BRIEF_HIGHLIGHT_MS)
|
|
5619
|
+
return () => clearTimeout(timer)
|
|
5620
|
+
}, [briefHighlight])
|
|
4899
5621
|
|
|
4900
5622
|
useEffect(() => {
|
|
4901
5623
|
if (typeof pendingJump !== 'string') return undefined
|
|
@@ -4952,9 +5674,10 @@ function BoardPage(props) {
|
|
|
4952
5674
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4953
5675
|
h(BoardEmpty, { hasActiveTasks, storageReady, onGoTasks, onNewTask }))
|
|
4954
5676
|
}
|
|
5677
|
+
const todoToday = boardTodoTodaySplit(board?.todos ?? [])
|
|
4955
5678
|
const boardStats = board?.stats === undefined
|
|
4956
5679
|
? undefined
|
|
4957
|
-
: { ...board.stats, todos:
|
|
5680
|
+
: { ...board.stats, todos: todoToday.total, todosManual: todoToday.manual, todosAuto: todoToday.auto }
|
|
4958
5681
|
return h('div', { className: 'capital-automation-board' },
|
|
4959
5682
|
h(BoardToolbar, {
|
|
4960
5683
|
range,
|
|
@@ -4967,7 +5690,11 @@ function BoardPage(props) {
|
|
|
4967
5690
|
onToggleRail: toggleRail,
|
|
4968
5691
|
}),
|
|
4969
5692
|
error.length > 0 ? h('div', { className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' }, error) : null,
|
|
4970
|
-
h(BoardStats, {
|
|
5693
|
+
h(BoardStats, {
|
|
5694
|
+
stats: boardStats,
|
|
5695
|
+
onJump: jumpTo,
|
|
5696
|
+
onHighlightTodayBriefs: () => setBriefHighlight((value) => value + 1),
|
|
5697
|
+
}),
|
|
4971
5698
|
h('div', {
|
|
4972
5699
|
className: 'capital-automation-boardgrid',
|
|
4973
5700
|
'data-rail': railOpen === true ? 'open' : 'closed',
|
|
@@ -4987,6 +5714,7 @@ function BoardPage(props) {
|
|
|
4987
5714
|
hasMore: board?.nextBefore !== null && board?.nextBefore !== undefined,
|
|
4988
5715
|
loadingMore,
|
|
4989
5716
|
railOpen,
|
|
5717
|
+
highlightToken: briefHighlight,
|
|
4990
5718
|
}),
|
|
4991
5719
|
h('aside', {
|
|
4992
5720
|
id: 'capital-automation-boardrail',
|
|
@@ -4995,9 +5723,10 @@ function BoardPage(props) {
|
|
|
4995
5723
|
},
|
|
4996
5724
|
h(TodoPanel, {
|
|
4997
5725
|
todos: board?.todos ?? [],
|
|
5726
|
+
tasks,
|
|
4998
5727
|
onOpenSession,
|
|
4999
|
-
|
|
5000
|
-
|
|
5728
|
+
onDecideTodo,
|
|
5729
|
+
pendingTodoIds,
|
|
5001
5730
|
open: openPanels.todo,
|
|
5002
5731
|
onToggle: () => togglePanel('todo'),
|
|
5003
5732
|
}),
|
|
@@ -5038,7 +5767,6 @@ function AutomationPage(props) {
|
|
|
5038
5767
|
const [boardRange, setBoardRange] = useState('14')
|
|
5039
5768
|
const [boardCategory, setBoardCategory] = useState('all')
|
|
5040
5769
|
const [retryingBriefId, setRetryingBriefId] = useState(null)
|
|
5041
|
-
const [ackingTodoId, setAckingTodoId] = useState(null)
|
|
5042
5770
|
const [boardLoadingMore, setBoardLoadingMore] = useState(false)
|
|
5043
5771
|
const [unread, setUnread] = useState(0)
|
|
5044
5772
|
const [tasksReady, setTasksReady] = useState(false)
|
|
@@ -5055,6 +5783,7 @@ function AutomationPage(props) {
|
|
|
5055
5783
|
const [busyTaskId, setBusyTaskId] = useState(null)
|
|
5056
5784
|
const [inboxBusy, setInboxBusy] = useState(false)
|
|
5057
5785
|
const [notice, setNotice] = useState('')
|
|
5786
|
+
const [pendingTodoIds, setPendingTodoIds] = useState(() => new Set())
|
|
5058
5787
|
const [loadError, setLoadError] = useState('')
|
|
5059
5788
|
const mountedRef = useRef(false)
|
|
5060
5789
|
const tasksRef = useRef([])
|
|
@@ -5069,6 +5798,7 @@ function AutomationPage(props) {
|
|
|
5069
5798
|
const refreshSequenceRef = useRef(0)
|
|
5070
5799
|
const detailSequenceRef = useRef(0)
|
|
5071
5800
|
const boardSequenceRef = useRef(0)
|
|
5801
|
+
const optimisticDecisionRef = useRef(new Map())
|
|
5072
5802
|
const scrollRef = useRef(null)
|
|
5073
5803
|
const mountedAtRef = useRef(typeof performance === 'undefined' ? 0 : performance.now())
|
|
5074
5804
|
const timingRecordedRef = useRef(false)
|
|
@@ -5210,6 +5940,16 @@ function AutomationPage(props) {
|
|
|
5210
5940
|
}
|
|
5211
5941
|
}
|
|
5212
5942
|
|
|
5943
|
+
// A decision request and a board poll can cross: keep the optimistic state on every response
|
|
5944
|
+
// until the request settles, then let the next poll read the server truth.
|
|
5945
|
+
function applyOptimisticDecisions(value) {
|
|
5946
|
+
let next = value
|
|
5947
|
+
for (const [id, entry] of optimisticDecisionRef.current) {
|
|
5948
|
+
next = applyTodoDecision(next, id, entry.action, entry.at)
|
|
5949
|
+
}
|
|
5950
|
+
return next
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5213
5953
|
async function loadBoard(nextRange = boardRange, nextCategory = boardCategory, before = null) {
|
|
5214
5954
|
const query = boardQueryOf(nextRange, nextCategory, before)
|
|
5215
5955
|
const snapshot = before === null ? readBoardSnapshot(query) : null
|
|
@@ -5219,7 +5959,7 @@ function AutomationPage(props) {
|
|
|
5219
5959
|
// A cached board paints immediately; the request below still revalidates it.
|
|
5220
5960
|
if (snapshot === null) setBoardLoading(true)
|
|
5221
5961
|
else {
|
|
5222
|
-
setBoard(snapshot)
|
|
5962
|
+
setBoard(applyOptimisticDecisions(snapshot))
|
|
5223
5963
|
setBoardLoading(false)
|
|
5224
5964
|
}
|
|
5225
5965
|
}
|
|
@@ -5227,11 +5967,11 @@ function AutomationPage(props) {
|
|
|
5227
5967
|
const value = await api.board(query)
|
|
5228
5968
|
if (!mountedRef.current || requestSequence !== boardSequenceRef.current) return
|
|
5229
5969
|
if (before === null) {
|
|
5230
|
-
setBoard(value)
|
|
5970
|
+
setBoard(applyOptimisticDecisions(value))
|
|
5231
5971
|
writeBoardSnapshot(query, value)
|
|
5232
|
-
} else setBoard((current) => current === null
|
|
5972
|
+
} else setBoard((current) => applyOptimisticDecisions(current === null
|
|
5233
5973
|
? value
|
|
5234
|
-
: { ...value, cards: [...current.cards, ...value.cards] })
|
|
5974
|
+
: { ...value, cards: [...current.cards, ...value.cards] }))
|
|
5235
5975
|
setBoardError('')
|
|
5236
5976
|
} catch (error) {
|
|
5237
5977
|
if (mountedRef.current && requestSequence === boardSequenceRef.current) {
|
|
@@ -5267,37 +6007,51 @@ function AutomationPage(props) {
|
|
|
5267
6007
|
}
|
|
5268
6008
|
}
|
|
5269
6009
|
|
|
5270
|
-
|
|
5271
|
-
if (
|
|
5272
|
-
|
|
6010
|
+
function decideTodo(item, action) {
|
|
6011
|
+
if (typeof item?.id !== 'string') return
|
|
6012
|
+
if (action !== 'confirm' && action !== 'auto' && action !== 'defer') return
|
|
6013
|
+
if (pendingTodoIds.has(item.id) || optimisticDecisionRef.current.has(item.id)) return
|
|
6014
|
+
// Paint the decision first; the write travels in the background and a crossing board poll is
|
|
6015
|
+
// overlaid with the same state.
|
|
6016
|
+
const at = new Date().toISOString()
|
|
6017
|
+
const previous = {
|
|
6018
|
+
ackedAt: item.ackedAt,
|
|
6019
|
+
deferredAt: item.deferredAt,
|
|
6020
|
+
decision: item.decision,
|
|
6021
|
+
watch: item.watch,
|
|
6022
|
+
}
|
|
6023
|
+
optimisticDecisionRef.current.set(item.id, { action, at })
|
|
6024
|
+
setPendingTodoIds((current) => {
|
|
6025
|
+
const next = new Set(current)
|
|
6026
|
+
next.add(item.id)
|
|
6027
|
+
return next
|
|
6028
|
+
})
|
|
6029
|
+
setBoard((current) => applyTodoDecision(current, item.id, action, at))
|
|
6030
|
+
setNotice(action === 'confirm'
|
|
6031
|
+
? zh.board.todoAcked
|
|
6032
|
+
: action === 'defer' ? zh.board.todoDeferred : zh.board.todoAutoQueued)
|
|
5273
6033
|
setBoardError('')
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
6034
|
+
void api.decideTodo(item.id, action).then(() => {
|
|
6035
|
+
optimisticDecisionRef.current.delete(item.id)
|
|
6036
|
+
// Ignore a poll that started before the server write; the next poll reads the truth.
|
|
6037
|
+
boardSequenceRef.current += 1
|
|
6038
|
+
if (mountedRef.current) setBoardLoading(false)
|
|
6039
|
+
}).catch((error) => {
|
|
6040
|
+
optimisticDecisionRef.current.delete(item.id)
|
|
6041
|
+
boardSequenceRef.current += 1
|
|
6042
|
+
if (!mountedRef.current) return
|
|
6043
|
+
setBoardLoading(false)
|
|
6044
|
+
setBoard((current) => restoreBoardTodoState(current, item.id, previous))
|
|
6045
|
+
setNotice('')
|
|
6046
|
+
setBoardError(error?.message ?? zh.errorGeneric)
|
|
6047
|
+
}).finally(() => {
|
|
6048
|
+
if (!mountedRef.current) return
|
|
6049
|
+
setPendingTodoIds((current) => {
|
|
6050
|
+
const next = new Set(current)
|
|
6051
|
+
next.delete(item.id)
|
|
6052
|
+
return next
|
|
5293
6053
|
})
|
|
5294
|
-
|
|
5295
|
-
void loadBoard(boardRange, boardCategory)
|
|
5296
|
-
} catch (error) {
|
|
5297
|
-
setBoardError(error.message ?? zh.errorGeneric)
|
|
5298
|
-
} finally {
|
|
5299
|
-
setAckingTodoId(null)
|
|
5300
|
-
}
|
|
6054
|
+
})
|
|
5301
6055
|
}
|
|
5302
6056
|
|
|
5303
6057
|
async function loadDetail(id) {
|
|
@@ -5440,6 +6194,25 @@ function AutomationPage(props) {
|
|
|
5440
6194
|
await openTaskById(taskId)
|
|
5441
6195
|
}
|
|
5442
6196
|
|
|
6197
|
+
async function openTodoFromNotification(item) {
|
|
6198
|
+
setInbox(false)
|
|
6199
|
+
const wasUnread = item.readAt === undefined
|
|
6200
|
+
setNotifications((current) => current.map((entry) => entry.id === item.id && entry.readAt === undefined
|
|
6201
|
+
? { ...entry, readAt: new Date().toISOString() }
|
|
6202
|
+
: entry))
|
|
6203
|
+
if (wasUnread) setUnread((current) => Math.max(0, current - 1))
|
|
6204
|
+
try {
|
|
6205
|
+
await api.markRead({ ids: [item.id] })
|
|
6206
|
+
} catch {
|
|
6207
|
+
// Navigation still works when the read receipt fails; the next poll reconciles the badge.
|
|
6208
|
+
}
|
|
6209
|
+
switchTab('board')
|
|
6210
|
+
void loadBoard(boardRange, boardCategory)
|
|
6211
|
+
requestAnimationFrame(() => {
|
|
6212
|
+
document.getElementById('capital-automation-todo')?.scrollIntoView?.({ block: 'start', behavior: 'smooth' })
|
|
6213
|
+
})
|
|
6214
|
+
}
|
|
6215
|
+
|
|
5443
6216
|
useEffect(() => {
|
|
5444
6217
|
mountedRef.current = true
|
|
5445
6218
|
void refresh()
|
|
@@ -5573,8 +6346,8 @@ function AutomationPage(props) {
|
|
|
5573
6346
|
onOpenSession: openSession,
|
|
5574
6347
|
onRetryBrief: (runId) => { void retryBrief(runId) },
|
|
5575
6348
|
retryingRunId: retryingBriefId,
|
|
5576
|
-
|
|
5577
|
-
|
|
6349
|
+
onDecideTodo: (item, action) => { decideTodo(item, action) },
|
|
6350
|
+
pendingTodoIds,
|
|
5578
6351
|
onLoadMore: () => { void loadMoreBoard() },
|
|
5579
6352
|
loadingMore: boardLoadingMore,
|
|
5580
6353
|
onGoTasks: () => switchTab('tasks'),
|
|
@@ -5654,6 +6427,7 @@ function AutomationPage(props) {
|
|
|
5654
6427
|
notifications,
|
|
5655
6428
|
onMarkAllRead: () => { void markAllRead() },
|
|
5656
6429
|
onOpenTask: (taskId) => { void openTaskFromNotification(taskId) },
|
|
6430
|
+
onOpenTodo: (item) => { void openTodoFromNotification(item) },
|
|
5657
6431
|
busy: inboxBusy,
|
|
5658
6432
|
}),
|
|
5659
6433
|
h(ConfirmModal, {
|