@v587d/capital-generation 2.20.0 → 2.21.1
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 +52 -0
- package/README.md +7 -21
- package/automation/board.js +125 -15
- package/automation/brief.js +189 -26
- package/automation/builtins.js +17 -0
- package/automation/client.js +45 -14
- package/automation/client.src.cjs +680 -182
- package/automation/index.js +25 -5
- package/automation/package.json +1 -1
- package/automation/route.js +3 -0
- package/automation/runner.js +48 -4
- package/automation/scheduler.js +12 -0
- package/automation/schema.js +22 -4
- package/automation/service.js +15 -0
- package/automation/store.js +16 -3
- package/automation/task-icons.js +1 -0
- package/automation/watch.js +341 -167
- 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
|
@@ -118,7 +118,7 @@ const zh = {
|
|
|
118
118
|
statsIssuesToday: '今天运行异常',
|
|
119
119
|
statsBriefsTodayHint: '点击高亮今天的简报卡片',
|
|
120
120
|
statsTodoHint: '点击查看今天的 TODO',
|
|
121
|
-
statsTodoManualHint: '
|
|
121
|
+
statsTodoManualHint: '需要你处理或跟踪的 TODO',
|
|
122
122
|
statsTodoAutoHint: '自动核验中的 TODO',
|
|
123
123
|
statsStockHint: '点击查看个股动态',
|
|
124
124
|
statsGapHint: '点击查看数据能力缺口',
|
|
@@ -160,26 +160,46 @@ const zh = {
|
|
|
160
160
|
stockShowAll: '展开全部 {n} 只',
|
|
161
161
|
stockShowLess: '收起',
|
|
162
162
|
gapsCount: '{n} 个缺口',
|
|
163
|
-
todoAckTitle: '标记为已确认',
|
|
164
163
|
todoAcked: '已确认',
|
|
164
|
+
todoMoreTitle: '更多操作',
|
|
165
|
+
todoActionConfirm: '已确认',
|
|
166
|
+
todoActionAuto: '转入自动校验',
|
|
167
|
+
todoActionDefer: '忽略',
|
|
168
|
+
todoAutoQueued: '已转入自动校验,下一次收盘核验',
|
|
169
|
+
todoDeferred: '已忽略当前版本',
|
|
165
170
|
watchWatching: '自动核验中',
|
|
166
171
|
watchTriggered: '已触发',
|
|
167
|
-
watchNeedsHuman: '
|
|
172
|
+
watchNeedsHuman: '待人工处理',
|
|
168
173
|
watchResolved: '已确认',
|
|
169
|
-
|
|
174
|
+
watchDeferred: '已忽略',
|
|
175
|
+
watchExpired: '已过期',
|
|
170
176
|
watchTracking: '跟踪',
|
|
171
177
|
watchEvidence: '核验依据',
|
|
172
|
-
|
|
178
|
+
watchSource: '来源',
|
|
179
|
+
watchDeferredHint: '已忽略当前版本;后续新版本会重新出现',
|
|
180
|
+
watchChecked: '自动核验于 {time}',
|
|
173
181
|
notificationFallbackTodoTriggered: '条件已触发,查看 TODO 详情。',
|
|
174
|
-
notificationFallbackTodoNeedsHuman: '
|
|
182
|
+
notificationFallbackTodoNeedsHuman: '自动核验无法完成,需要你处理。',
|
|
175
183
|
todoEmptyToday: '今天暂无待办',
|
|
176
184
|
todoEmptyGroup: '暂无「{label}」待办',
|
|
185
|
+
todoEmptyHistory: '{date} 暂无历史 TODO',
|
|
177
186
|
todoFilterLabel: '按日期筛选',
|
|
187
|
+
todoDateLabel: '选择历史日期',
|
|
178
188
|
dueToday: '今天',
|
|
179
189
|
dueAsap: '尽快',
|
|
180
190
|
dueNoDate: '未定',
|
|
181
191
|
dueFuture: '将来',
|
|
182
|
-
|
|
192
|
+
historyTodo: '历史 TODO',
|
|
193
|
+
historyExpired: '已过期',
|
|
194
|
+
todoManualConfirm: '手动确认',
|
|
195
|
+
todoManualDefer: '手动忽略',
|
|
196
|
+
todoNotTriggered: '未触发',
|
|
197
|
+
todoInsufficient: '证据不足',
|
|
198
|
+
todoUnverified: '未完成核验',
|
|
199
|
+
todoTrackEnded: '跟踪结束',
|
|
200
|
+
todoStale: '已停止跟踪',
|
|
201
|
+
todoCheckedAt: '自动核验于 {date}',
|
|
202
|
+
todoManualAt: '人工处理于 {date}',
|
|
183
203
|
showBasis: '查看依据',
|
|
184
204
|
hideBasis: '收起依据',
|
|
185
205
|
seenCount: '{n} 次运行提到',
|
|
@@ -758,6 +778,8 @@ function installStyles() {
|
|
|
758
778
|
.capital-automation-panelhead h3 { margin: 0; font-size: 13.5px; line-height: 20px; font-weight: 600; }
|
|
759
779
|
.capital-automation-panelhead .capital-automation-btn { margin-left: auto; }
|
|
760
780
|
.capital-automation-panelhead .capital-automation-select { margin-left: auto; }
|
|
781
|
+
.capital-automation-panelhead .capital-automation-todofilters { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
|
|
782
|
+
.capital-automation-panelhead .capital-automation-todofilters .capital-automation-select { margin-left: 0; }
|
|
761
783
|
.capital-automation-panelhead .capital-automation-btn[data-variant="ghost"] { padding-right: 0; }
|
|
762
784
|
.capital-automation-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
|
|
763
785
|
.capital-automation-kvitem { min-width: 0; }
|
|
@@ -1075,32 +1097,61 @@ function installStyles() {
|
|
|
1075
1097
|
.capital-automation-boardemptyhint { color: var(--ca-caption); font-size: 11.5px !important; line-height: 18px !important; }
|
|
1076
1098
|
.capital-automation-boardemptyactions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
|
|
1077
1099
|
.capital-automation-todolist, .capital-automation-stocktodos, .capital-automation-gaplist, .capital-automation-gaprow { list-style: none; margin: 0; padding: 0; }
|
|
1078
|
-
.capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); }
|
|
1100
|
+
.capital-automation-todoitem { padding: 8px 0; border-top: .5px solid var(--ca-line); transition: opacity .16s ease, padding .18s ease; }
|
|
1079
1101
|
.capital-automation-todoitem:first-child { border-top: 0; }
|
|
1102
|
+
.capital-automation-todoitem[data-decided="true"], .capital-automation-todoitem[data-archived="true"] { padding: 7px 0; opacity: .72; border-top: 0; }
|
|
1103
|
+
.capital-automation-todoitem:not([data-decided="true"]):not([data-archived="true"]) + .capital-automation-todoitem[data-decided="true"] { border-top: .5px solid var(--ca-line); }
|
|
1104
|
+
.capital-automation-todoitem[data-decided="true"]:hover, .capital-automation-todoitem[data-archived="true"]:hover { opacity: 1; }
|
|
1105
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todoline, .capital-automation-todoitem[data-archived="true"] .capital-automation-todoline { gap: 0; }
|
|
1106
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotop, .capital-automation-todoitem[data-archived="true"] .capital-automation-todotop { justify-content: flex-start; gap: 10px; }
|
|
1107
|
+
.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; }
|
|
1108
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotitle { cursor: default; }
|
|
1109
|
+
.capital-automation-todoitem[data-archived="true"] .capital-automation-todotitle { cursor: pointer; }
|
|
1110
|
+
.capital-automation-todoitem[data-decided="true"] .capital-automation-todotitle:hover { color: var(--ca-muted); }
|
|
1111
|
+
.capital-automation-todoitem[data-archived="true"] .capital-automation-todotitle:hover { color: var(--ca-business-text); }
|
|
1080
1112
|
.capital-automation-todoline { display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-width: 0; }
|
|
1081
1113
|
.capital-automation-todotop { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
|
|
1082
|
-
.capital-automation-todotags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; min-width: 0; }
|
|
1114
|
+
.capital-automation-todotags { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 4px 5px; min-width: 0; }
|
|
1083
1115
|
.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; }
|
|
1084
1116
|
.capital-automation-todotitle:hover, .capital-automation-gaptitle:hover { color: var(--ca-business-text); }
|
|
1085
1117
|
.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; }
|
|
1086
|
-
.capital-automation-basiscaret { display: inline-flex; align-items: center; margin-left: 4px; color: var(--ca-muted); vertical-align: -2px; transform: rotate(-90deg); transition: transform .16s ease; }
|
|
1087
|
-
.capital-automation-todotitle[aria-expanded="true"] .capital-automation-basiscaret, .capital-automation-gaptitle[aria-expanded="true"] .capital-automation-basiscaret { transform: rotate(0deg); }
|
|
1088
1118
|
.capital-automation-tododesc { margin: 3px 0 0; color: var(--ca-muted); font-size: 12px; line-height: 20px; overflow-wrap: anywhere; }
|
|
1089
1119
|
.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; }
|
|
1120
|
+
.capital-automation-todolist[data-period="expired"] > .capital-automation-todoitem { border-top: 0; }
|
|
1121
|
+
.capital-automation-historytitle { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
|
|
1122
|
+
.capital-automation-historytitle:hover { color: var(--ca-business-text); }
|
|
1123
|
+
.capital-automation-historytitle:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; border-radius: 4px; }
|
|
1124
|
+
.capital-automation-historymeta { margin-top: 4px; }
|
|
1125
|
+
.capital-automation-historyconclusion { display: inline-flex; flex: none; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 999px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 10.5px; line-height: 20px; font-weight: 500; white-space: nowrap; }
|
|
1126
|
+
.capital-automation-historyconclusion[data-tone="success"] { background: color-mix(in srgb, var(--ca-success) 14%, var(--ca-card)); color: var(--ca-success-text); }
|
|
1127
|
+
.capital-automation-historyconclusion[data-tone="warn"] { background: color-mix(in srgb, var(--ca-warn) 14%, var(--ca-card)); color: var(--ca-warn-text); }
|
|
1128
|
+
.capital-automation-historyconclusion[data-tone="error"] { background: color-mix(in srgb, var(--ca-error) 12%, var(--ca-card)); color: var(--ca-error-text); }
|
|
1129
|
+
.capital-automation-datepick-menu { box-sizing: border-box; width: 236px; max-width: calc(100vw - 24px); padding: 10px; }
|
|
1130
|
+
.capital-automation-datepick-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
|
|
1131
|
+
.capital-automation-datepick-month { color: var(--dsw-alias-label-primary); font-size: 12px; line-height: 18px; }
|
|
1132
|
+
.capital-automation-datepick-nav { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ca-muted); cursor: pointer; }
|
|
1133
|
+
.capital-automation-datepick-nav:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
1134
|
+
.capital-automation-datepick-nav:disabled { opacity: .35; cursor: default; }
|
|
1135
|
+
.capital-automation-datepick-nav:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 0; }
|
|
1136
|
+
.capital-automation-datepick-week, .capital-automation-datepick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
|
|
1137
|
+
.capital-automation-datepick-weekday { padding: 2px 0; color: var(--ca-caption); font-size: 10px; line-height: 16px; text-align: center; }
|
|
1138
|
+
.capital-automation-datepick-day { height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 11.5px; line-height: 28px; cursor: pointer; }
|
|
1139
|
+
.capital-automation-datepick-day:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
1140
|
+
.capital-automation-datepick-day[data-selected="true"] { background: var(--ca-business); color: #fff; }
|
|
1141
|
+
.capital-automation-datepick-day:disabled { opacity: .3; cursor: default; }
|
|
1142
|
+
.capital-automation-datepick-day:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 0; }
|
|
1090
1143
|
.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; }
|
|
1091
1144
|
.capital-automation-todowatch[data-status="triggered"] { background: color-mix(in srgb, var(--ca-error) 12%, var(--ca-card)); color: var(--ca-error-text); }
|
|
1092
1145
|
.capital-automation-todowatch[data-status="needs_human"] { background: color-mix(in srgb, var(--ca-warn) 14%, var(--ca-card)); color: var(--ca-warn-text); }
|
|
1093
1146
|
.capital-automation-todowatch[data-status="watching"] { color: var(--ca-business-text); }
|
|
1094
1147
|
.capital-automation-todowatch[data-status="resolved"] { background: color-mix(in srgb, var(--ca-success) 14%, var(--ca-card)); color: var(--ca-success-text); }
|
|
1148
|
+
.capital-automation-todowatch[data-status="deferred"] { background: color-mix(in srgb, var(--ca-muted) 12%, var(--ca-card)); color: var(--ca-muted); }
|
|
1095
1149
|
.capital-automation-todowatch[data-status="tracking"] { color: var(--ca-muted); }
|
|
1096
1150
|
.capital-automation-todowatch[data-status="expired"] { color: var(--ca-caption); }
|
|
1097
|
-
.capital-automation-
|
|
1098
|
-
.capital-automation-
|
|
1099
|
-
.capital-automation-
|
|
1100
|
-
.capital-automation-
|
|
1101
|
-
.capital-automation-todocheck[disabled] { opacity: .55; cursor: default; }
|
|
1102
|
-
.capital-automation-todocheckspin { width: 10px; height: 10px; border: 2px solid var(--ca-line); border-top-color: var(--ca-business); border-radius: 50%; animation: capital-automation-todospin .7s linear infinite; }
|
|
1103
|
-
@keyframes capital-automation-todospin { to { transform: rotate(360deg); } }
|
|
1151
|
+
.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; }
|
|
1152
|
+
.capital-automation-todomenu:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
1153
|
+
.capital-automation-todomenu:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; }
|
|
1154
|
+
.capital-automation-todomenu:disabled { opacity: .4; cursor: default; }
|
|
1104
1155
|
.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; }
|
|
1105
1156
|
.capital-automation-todowatchmsg[data-status="triggered"] { border-left-color: var(--ca-error); color: var(--ca-error-text); }
|
|
1106
1157
|
.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; }
|
|
@@ -1265,6 +1316,7 @@ function createApi() {
|
|
|
1265
1316
|
},
|
|
1266
1317
|
warm,
|
|
1267
1318
|
confirmTodo: (id) => request('/board/todos/confirm', { method: 'POST', body: { id } }),
|
|
1319
|
+
decideTodo: (id, action) => request('/board/todos/decision', { method: 'POST', body: { id, action } }),
|
|
1268
1320
|
retryBrief: (runId) => request(`/board/briefs/${encodeURIComponent(runId)}/retry`, { method: 'POST' }),
|
|
1269
1321
|
askBrief: (runId, question, timeZone) => request(`/board/briefs/${encodeURIComponent(runId)}/ask`, {
|
|
1270
1322
|
method: 'POST',
|
|
@@ -4035,11 +4087,15 @@ function boardCardIsToday(card, today = localDateKey(new Date())) {
|
|
|
4035
4087
|
|
|
4036
4088
|
function boardTodoPeriod(item, now = new Date()) {
|
|
4037
4089
|
const today = localDateKey(now)
|
|
4038
|
-
// Triggered or handed-off items stay in today's action list even when dueAt has passed; a
|
|
4039
|
-
// confirmed one only stays there through the day it was acknowledged.
|
|
4040
4090
|
const watchedStatus = item.watch?.resolvedFrom ?? item.watch?.status
|
|
4041
|
-
const
|
|
4042
|
-
|
|
4091
|
+
const decidedAt = typeof item.ackedAt === 'string' ? item.ackedAt : item.deferredAt
|
|
4092
|
+
const decidedToday = typeof decidedAt === 'string' && localDateKey(new Date(decidedAt)) === today
|
|
4093
|
+
// A decision is feedback for the rest of today, then it belongs to the archive.
|
|
4094
|
+
if (decidedAt !== undefined) return decidedToday ? 'today' : 'expired'
|
|
4095
|
+
// A triggered condition is a fact: keep it actionable until the user decides.
|
|
4096
|
+
if (watchedStatus === 'triggered') return 'today'
|
|
4097
|
+
// A stopped watch has reached its lifecycle end, including date-less "尽快" items.
|
|
4098
|
+
if (item.watch?.status === 'expired') return 'expired'
|
|
4043
4099
|
if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) {
|
|
4044
4100
|
if (item.dueAt < today) return 'expired'
|
|
4045
4101
|
if (item.dueAt === today) return 'today'
|
|
@@ -4049,7 +4105,11 @@ function boardTodoPeriod(item, now = new Date()) {
|
|
|
4049
4105
|
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
4050
4106
|
const seen = typeof item.finishedAt === 'string' ? new Date(item.finishedAt) : null
|
|
4051
4107
|
const seenToday = seen !== null && !Number.isNaN(seen.getTime()) && localDateKey(seen) === today
|
|
4052
|
-
if (['尽快', '马上', '现在'].includes(label))
|
|
4108
|
+
if (['尽快', '马上', '现在'].includes(label)) {
|
|
4109
|
+
// A tracked "尽快" item stays actionable through its 72-hour watch window.
|
|
4110
|
+
if (item.watch !== null && item.watch !== undefined) return 'today'
|
|
4111
|
+
return seenToday ? 'today' : 'future'
|
|
4112
|
+
}
|
|
4053
4113
|
if (['今天', '今日'].includes(label)) return seenToday ? 'today' : 'expired'
|
|
4054
4114
|
return 'future'
|
|
4055
4115
|
}
|
|
@@ -4062,7 +4122,7 @@ function boardTodoTodaySplit(todos, now = new Date()) {
|
|
|
4062
4122
|
const split = { total: 0, manual: 0, auto: 0 }
|
|
4063
4123
|
for (const item of todos) {
|
|
4064
4124
|
const status = boardTodoStatus(item)
|
|
4065
|
-
if (status === 'resolved' || boardTodoPeriod(item, now) !== 'today') continue
|
|
4125
|
+
if (status === 'resolved' || status === 'deferred' || boardTodoPeriod(item, now) !== 'today') continue
|
|
4066
4126
|
split.total += 1
|
|
4067
4127
|
if (status === 'watching') split.auto += 1
|
|
4068
4128
|
else split.manual += 1
|
|
@@ -4072,27 +4132,232 @@ function boardTodoTodaySplit(todos, now = new Date()) {
|
|
|
4072
4132
|
|
|
4073
4133
|
function boardTodoGroupLabel(period) {
|
|
4074
4134
|
if (period === 'today') return zh.board.dueToday
|
|
4075
|
-
if (period === 'expired') return zh.board.
|
|
4135
|
+
if (period === 'expired') return zh.board.historyTodo
|
|
4076
4136
|
return zh.board.dueFuture
|
|
4077
4137
|
}
|
|
4078
4138
|
|
|
4139
|
+
/**
|
|
4140
|
+
* Today's pending rows stay on top; acknowledged rows collapse to a single line at the bottom so
|
|
4141
|
+
* the next item visibly moves up. The newest confirmation is the last row of the day.
|
|
4142
|
+
*/
|
|
4143
|
+
function boardTodoEntries(todos, now = new Date()) {
|
|
4144
|
+
const entries = todos.map((item) => {
|
|
4145
|
+
const decidedAt = typeof item.ackedAt === 'string' ? item.ackedAt : item.deferredAt
|
|
4146
|
+
return {
|
|
4147
|
+
item,
|
|
4148
|
+
period: boardTodoPeriod(item, now),
|
|
4149
|
+
decided: typeof decidedAt === 'string' && decidedAt.length > 0,
|
|
4150
|
+
decidedAt,
|
|
4151
|
+
}
|
|
4152
|
+
})
|
|
4153
|
+
entries.sort((left, right) => {
|
|
4154
|
+
const period = BOARD_TODO_PERIODS.indexOf(left.period) - BOARD_TODO_PERIODS.indexOf(right.period)
|
|
4155
|
+
if (period !== 0) return period
|
|
4156
|
+
if (left.period === 'expired') {
|
|
4157
|
+
// Archive order is newest expiry first; undated rows fall to the end.
|
|
4158
|
+
return String(right.item.dueAt ?? '').localeCompare(String(left.item.dueAt ?? ''))
|
|
4159
|
+
|| String(right.item.lastSeenAt ?? '').localeCompare(String(left.item.lastSeenAt ?? ''))
|
|
4160
|
+
|| String(left.item.id).localeCompare(String(right.item.id))
|
|
4161
|
+
}
|
|
4162
|
+
if (left.period !== 'today') return 0
|
|
4163
|
+
if (left.decided !== right.decided) return left.decided ? 1 : -1
|
|
4164
|
+
if (left.decided && right.decided) return String(left.decidedAt).localeCompare(String(right.decidedAt))
|
|
4165
|
+
return 0
|
|
4166
|
+
})
|
|
4167
|
+
return entries
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
function boardTodoIsOpen(item) {
|
|
4171
|
+
return typeof item.ackedAt !== 'string' && typeof item.deferredAt !== 'string'
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
function closeBoardWatch(watch) {
|
|
4175
|
+
if (watch === null || watch === undefined) return watch
|
|
4176
|
+
return {
|
|
4177
|
+
...watch,
|
|
4178
|
+
status: 'resolved',
|
|
4179
|
+
resolvedFrom: watch.resolvedFrom ?? (watch.status === 'resolved' ? null : watch.status),
|
|
4180
|
+
autoRequestedAt: null,
|
|
4181
|
+
handoffReason: null,
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
function reopenBoardWatch(watch, at) {
|
|
4186
|
+
if (watch === null || watch === undefined) return watch
|
|
4187
|
+
return {
|
|
4188
|
+
...watch,
|
|
4189
|
+
status: 'watching',
|
|
4190
|
+
resolvedFrom: null,
|
|
4191
|
+
autoRequestedAt: at,
|
|
4192
|
+
handoffReason: null,
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
/** Applied before the server remembers the decision, and to every board refresh in flight. */
|
|
4197
|
+
function applyTodoDecision(current, todoId, action, at) {
|
|
4198
|
+
if (current === null) return current
|
|
4199
|
+
const target = (current.todos ?? []).find((entry) => entry.id === todoId)
|
|
4200
|
+
if (target === undefined) return current
|
|
4201
|
+
const wasOpen = boardTodoIsOpen(target)
|
|
4202
|
+
let next
|
|
4203
|
+
if (action === 'auto') {
|
|
4204
|
+
if (target.watch === null || target.watch === undefined) return current
|
|
4205
|
+
next = {
|
|
4206
|
+
...target,
|
|
4207
|
+
ackedAt: undefined,
|
|
4208
|
+
deferredAt: undefined,
|
|
4209
|
+
decision: undefined,
|
|
4210
|
+
watch: reopenBoardWatch(target.watch, at),
|
|
4211
|
+
}
|
|
4212
|
+
} else {
|
|
4213
|
+
const decision = action === 'defer' ? 'deferred' : 'confirmed'
|
|
4214
|
+
if (target.decision === decision) return current
|
|
4215
|
+
next = {
|
|
4216
|
+
...target,
|
|
4217
|
+
ackedAt: decision === 'confirmed' ? at : undefined,
|
|
4218
|
+
deferredAt: decision === 'deferred' ? at : undefined,
|
|
4219
|
+
decision,
|
|
4220
|
+
watch: closeBoardWatch(target.watch),
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
const isOpen = boardTodoIsOpen(next)
|
|
4224
|
+
const todos = current.todos.map((entry) => entry.id === todoId ? next : entry)
|
|
4225
|
+
const targetKey = target.symbol === undefined ? undefined : boardEntrySymbolKey(target)
|
|
4226
|
+
let stockDelta = 0
|
|
4227
|
+
if (wasOpen && !isOpen) stockDelta = -1
|
|
4228
|
+
if (!wasOpen && isOpen) stockDelta = 1
|
|
4229
|
+
const stocks = stockDelta === 0
|
|
4230
|
+
? current.stocks
|
|
4231
|
+
: (current.stocks ?? []).map((stock) => {
|
|
4232
|
+
if (targetKey === undefined || boardEntrySymbolKey(stock) !== targetKey) return stock
|
|
4233
|
+
if (!Array.isArray(stock.items)) {
|
|
4234
|
+
return { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) + stockDelta) }
|
|
4235
|
+
}
|
|
4236
|
+
if (stockDelta < 0) {
|
|
4237
|
+
const items = stock.items.filter((entry) => entry.id !== target.id)
|
|
4238
|
+
return { ...stock, items, todoCount: items.length }
|
|
4239
|
+
}
|
|
4240
|
+
if (stock.items.some((entry) => entry.id === todoId)) return stock
|
|
4241
|
+
const items = [...stock.items, { id: target.id, title: target.title, sessionId: target.sessionId ?? null }]
|
|
4242
|
+
return { ...stock, items, todoCount: items.length }
|
|
4243
|
+
})
|
|
4244
|
+
return {
|
|
4245
|
+
...current,
|
|
4246
|
+
todos,
|
|
4247
|
+
stocks,
|
|
4248
|
+
stats: current.stats === undefined || stockDelta === 0
|
|
4249
|
+
? current.stats
|
|
4250
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) + stockDelta) },
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
function restoreBoardTodoState(current, todoId, previous) {
|
|
4255
|
+
if (current === null) return current
|
|
4256
|
+
const target = (current.todos ?? []).find((entry) => entry.id === todoId)
|
|
4257
|
+
if (target === undefined) return current
|
|
4258
|
+
const next = {
|
|
4259
|
+
...target,
|
|
4260
|
+
ackedAt: previous.ackedAt,
|
|
4261
|
+
deferredAt: previous.deferredAt,
|
|
4262
|
+
decision: previous.decision,
|
|
4263
|
+
watch: previous.watch ?? null,
|
|
4264
|
+
}
|
|
4265
|
+
const wasOpen = boardTodoIsOpen(target)
|
|
4266
|
+
const isOpen = boardTodoIsOpen(next)
|
|
4267
|
+
const stockDelta = wasOpen === isOpen ? 0 : isOpen ? 1 : -1
|
|
4268
|
+
const todos = current.todos.map((entry) => entry.id === todoId ? next : entry)
|
|
4269
|
+
const targetKey = target.symbol === undefined ? undefined : boardEntrySymbolKey(target)
|
|
4270
|
+
const stocks = stockDelta === 0
|
|
4271
|
+
? current.stocks
|
|
4272
|
+
: (current.stocks ?? []).map((stock) => {
|
|
4273
|
+
if (targetKey === undefined || boardEntrySymbolKey(stock) !== targetKey) return stock
|
|
4274
|
+
if (!Array.isArray(stock.items)) {
|
|
4275
|
+
return { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) + stockDelta) }
|
|
4276
|
+
}
|
|
4277
|
+
if (stockDelta < 0) {
|
|
4278
|
+
const items = stock.items.filter((entry) => entry.id !== todoId)
|
|
4279
|
+
return { ...stock, items, todoCount: items.length }
|
|
4280
|
+
}
|
|
4281
|
+
if (stock.items.some((entry) => entry.id === todoId)) return stock
|
|
4282
|
+
const items = [...stock.items, { id: target.id, title: target.title, sessionId: target.sessionId ?? null }]
|
|
4283
|
+
return { ...stock, items, todoCount: items.length }
|
|
4284
|
+
})
|
|
4285
|
+
return {
|
|
4286
|
+
...current,
|
|
4287
|
+
todos,
|
|
4288
|
+
stocks,
|
|
4289
|
+
stats: current.stats === undefined || stockDelta === 0
|
|
4290
|
+
? current.stats
|
|
4291
|
+
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) + stockDelta) },
|
|
4292
|
+
}
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4079
4295
|
function boardTodoFilterOptions() {
|
|
4080
4296
|
return BOARD_TODO_PERIODS.map((period) => ({ value: period, label: boardTodoGroupLabel(period) }))
|
|
4081
4297
|
}
|
|
4082
4298
|
|
|
4083
4299
|
function boardTodoDueLabel(item, period) {
|
|
4300
|
+
if (period === 'expired') return ''
|
|
4084
4301
|
const date = typeof item.dueAt === 'string' && item.dueAt.length >= 10 ? item.dueAt.slice(5) : ''
|
|
4085
4302
|
if (period === 'today') {
|
|
4086
4303
|
const label = typeof item.dueLabel === 'string' ? item.dueLabel.trim() : ''
|
|
4087
4304
|
return ['尽快', '马上', '现在'].includes(label) && date.length === 0 ? zh.board.dueAsap : zh.board.dueToday
|
|
4088
4305
|
}
|
|
4089
|
-
if (period === 'expired') return date ? `${zh.board.dueExpired} · ${date}` : zh.board.dueExpired
|
|
4090
4306
|
return date || zh.board.dueNoDate
|
|
4091
4307
|
}
|
|
4092
4308
|
|
|
4093
|
-
const
|
|
4309
|
+
const TODO_VERIFIER_IDS = new Set(['todo-verifier-close'])
|
|
4310
|
+
|
|
4311
|
+
function boardTodoDecision(item) {
|
|
4312
|
+
if (item.decision === 'confirmed' || item.decision === 'deferred') return item.decision
|
|
4313
|
+
if (typeof item.ackedAt === 'string' && item.ackedAt.length > 0) return 'confirmed'
|
|
4314
|
+
if (typeof item.deferredAt === 'string' && item.deferredAt.length > 0) return 'deferred'
|
|
4315
|
+
return undefined
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4318
|
+
/** Local YYYY-MM-DD for a timestamp; empty when the value cannot be parsed. */
|
|
4319
|
+
function dateKeyOfValue(value) {
|
|
4320
|
+
const at = Date.parse(value)
|
|
4321
|
+
return Number.isFinite(at) ? localDateKey(new Date(at)) : ''
|
|
4322
|
+
}
|
|
4323
|
+
|
|
4324
|
+
function formatMonthDay(value) {
|
|
4325
|
+
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value)) return value.slice(5)
|
|
4326
|
+
const key = dateKeyOfValue(value)
|
|
4327
|
+
return key.length > 0 ? key.slice(5) : ''
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
/**
|
|
4331
|
+
* History is filed by the day the TODO was due; undated items fall back to the decision, the
|
|
4332
|
+
* verification, then the last mention so nothing disappears from the day view.
|
|
4333
|
+
*/
|
|
4334
|
+
function boardTodoHistoryDate(item) {
|
|
4335
|
+
if (typeof item.dueAt === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(item.dueAt)) return item.dueAt
|
|
4336
|
+
const decidedAt = typeof item.ackedAt === 'string' ? item.ackedAt : item.deferredAt
|
|
4337
|
+
const decisionKey = dateKeyOfValue(decidedAt)
|
|
4338
|
+
if (decisionKey.length > 0) return decisionKey
|
|
4339
|
+
const checkedKey = dateKeyOfValue(item.watch?.checkedAt)
|
|
4340
|
+
if (checkedKey.length > 0) return checkedKey
|
|
4341
|
+
return dateKeyOfValue(item.lastSeenAt)
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
/** One conclusion per history row: verifier verdict, human decision, or the deadline. */
|
|
4345
|
+
function boardTodoConclusion(item) {
|
|
4346
|
+
const decision = boardTodoDecision(item)
|
|
4347
|
+
if (decision === 'confirmed') return { label: zh.board.todoManualConfirm, at: item.ackedAt, kind: 'manual', tone: 'success' }
|
|
4348
|
+
if (decision === 'deferred') return { label: zh.board.todoManualDefer, at: item.deferredAt, kind: 'manual', tone: 'muted' }
|
|
4349
|
+
if (item.kind === 'track') return { label: zh.board.todoTrackEnded, at: undefined, kind: 'track', tone: 'muted' }
|
|
4350
|
+
if (item.watch?.status === 'triggered') return { label: zh.board.watchTriggered, at: item.watch?.checkedAt, kind: 'auto', tone: 'error' }
|
|
4351
|
+
const reason = item.watch?.expiredReason
|
|
4352
|
+
if (reason === 'not_triggered') return { label: zh.board.todoNotTriggered, at: item.watch?.checkedAt, kind: 'auto', tone: 'muted' }
|
|
4353
|
+
if (reason === 'no_data') return { label: zh.board.todoInsufficient, at: item.watch?.checkedAt, kind: 'auto', tone: 'warn' }
|
|
4354
|
+
if (reason === 'not_verified') return { label: zh.board.todoUnverified, at: undefined, kind: 'auto', tone: 'muted' }
|
|
4355
|
+
if (reason === 'stale') return { label: zh.board.todoStale, at: undefined, kind: 'auto', tone: 'muted' }
|
|
4356
|
+
return { label: zh.board.historyExpired, at: undefined, kind: 'expired', tone: 'muted' }
|
|
4357
|
+
}
|
|
4094
4358
|
|
|
4095
4359
|
function boardTodoStatus(item) {
|
|
4360
|
+
if (typeof item.deferredAt === 'string' && item.deferredAt.length > 0) return 'deferred'
|
|
4096
4361
|
if (typeof item.ackedAt === 'string' && item.ackedAt.length > 0) return 'resolved'
|
|
4097
4362
|
if (item.watch !== null && item.watch !== undefined && typeof item.watch.status === 'string') return item.watch.status
|
|
4098
4363
|
// Track items are passive; everything else without a watch is waiting for the user.
|
|
@@ -4103,6 +4368,7 @@ function boardTodoWatchLabel(status) {
|
|
|
4103
4368
|
if (status === 'triggered') return zh.board.watchTriggered
|
|
4104
4369
|
if (status === 'needs_human') return zh.board.watchNeedsHuman
|
|
4105
4370
|
if (status === 'resolved') return zh.board.watchResolved
|
|
4371
|
+
if (status === 'deferred') return zh.board.watchDeferred
|
|
4106
4372
|
if (status === 'expired') return zh.board.watchExpired
|
|
4107
4373
|
if (status === 'tracking') return zh.board.watchTracking
|
|
4108
4374
|
if (status === 'watching') return zh.board.watchWatching
|
|
@@ -4112,26 +4378,45 @@ function boardTodoWatchLabel(status) {
|
|
|
4112
4378
|
function boardTodoWatchHint(status, checkpointHint) {
|
|
4113
4379
|
if (status === 'watching') return checkpointHint
|
|
4114
4380
|
if (status === 'triggered') return '自动核验已确认条件成立'
|
|
4115
|
-
if (status === 'needs_human') return '
|
|
4381
|
+
if (status === 'needs_human') return '需要你处理'
|
|
4116
4382
|
if (status === 'resolved') return '已确认'
|
|
4383
|
+
if (status === 'deferred') return zh.board.watchDeferredHint
|
|
4117
4384
|
if (status === 'tracking') return '仅展示,不自动核验'
|
|
4118
|
-
if (status === 'expired') return '
|
|
4385
|
+
if (status === 'expired') return '已过期;不再核验、提醒或计入待办'
|
|
4119
4386
|
return ''
|
|
4120
4387
|
}
|
|
4121
4388
|
|
|
4122
|
-
function
|
|
4389
|
+
function boardTodoVerifierHint(tasks) {
|
|
4123
4390
|
const names = []
|
|
4124
4391
|
for (const task of Array.isArray(tasks) ? tasks : []) {
|
|
4125
|
-
if (task?.origin !== 'builtin' || task.state !== 'active' || !
|
|
4392
|
+
if (task?.origin !== 'builtin' || task.state !== 'active' || !TODO_VERIFIER_IDS.has(task.sourceBuiltinId)) continue
|
|
4126
4393
|
if (typeof task.title === 'string' && task.title.length > 0 && !names.includes(task.title)) names.push(task.title)
|
|
4127
4394
|
}
|
|
4128
|
-
if (names.length > 0) return
|
|
4129
|
-
if (!Array.isArray(tasks) || tasks.length === 0) return '
|
|
4130
|
-
return '
|
|
4395
|
+
if (names.length > 0) return `自动核验由「${names.join('、')}」执行(A/H 收盘)`
|
|
4396
|
+
if (!Array.isArray(tasks) || tasks.length === 0) return '自动核验由「TODO 核验」执行(A/H 收盘)'
|
|
4397
|
+
return 'TODO 核验任务未启用'
|
|
4131
4398
|
}
|
|
4132
4399
|
|
|
4133
4400
|
function boardTodoCheckable(status) {
|
|
4134
4401
|
return status === 'needs_human' || status === 'triggered' || status === 'tracking'
|
|
4402
|
+
|| status === 'watching' || status === 'resolved' || status === 'deferred'
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
function boardTodoAutoAvailable(item, status) {
|
|
4406
|
+
if (item.kind !== 'confirm' && item.kind !== 'verify') return false
|
|
4407
|
+
if (item.watch === null || item.watch === undefined) return false
|
|
4408
|
+
if (item.watch.autoEligible !== true) return false
|
|
4409
|
+
return status === 'needs_human' || status === 'resolved' || status === 'deferred'
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4412
|
+
function boardTodoAutoReason(item, status) {
|
|
4413
|
+
if (item.kind === 'track') return ''
|
|
4414
|
+
if (item.watch === null || item.watch === undefined) return ''
|
|
4415
|
+
if (item.watch.autoEligible === true) return ''
|
|
4416
|
+
if (item.watch.autoIneligibleReason === 'triggered' || status === 'triggered') return '条件已触发'
|
|
4417
|
+
if (item.watch.autoIneligibleReason === 'expired') return '已过期'
|
|
4418
|
+
if (item.watch.autoIneligibleReason === 'us_symbol') return '美股暂不支持'
|
|
4419
|
+
return '暂不支持'
|
|
4135
4420
|
}
|
|
4136
4421
|
|
|
4137
4422
|
function boardCategoryOptions() {
|
|
@@ -4744,9 +5029,6 @@ function BriefCard(props) {
|
|
|
4744
5029
|
onClick: () => setAskOpen(true),
|
|
4745
5030
|
}, h(IconNewChatOutlineRegular, { size: 14 }))
|
|
4746
5031
|
: null
|
|
4747
|
-
const openLink = openSession
|
|
4748
|
-
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: openSession }, zh.openSession)
|
|
4749
|
-
: null
|
|
4750
5032
|
const trigger = card.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled
|
|
4751
5033
|
const relativeTime = boardRelativeTime(card.finishedAt)
|
|
4752
5034
|
const exactTime = formatTime(card.finishedAt)
|
|
@@ -4766,12 +5048,10 @@ function BriefCard(props) {
|
|
|
4766
5048
|
'data-size': 'sm',
|
|
4767
5049
|
disabled: retrying === true,
|
|
4768
5050
|
onClick: () => onRetry(card.runId),
|
|
4769
|
-
}, retrying === true ? zh.processing : zh.board.retry)
|
|
4770
|
-
openLink))
|
|
5051
|
+
}, retrying === true ? zh.processing : zh.board.retry)))
|
|
4771
5052
|
} else if (status === 'skipped') {
|
|
4772
5053
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4773
|
-
h('p', null, zh.board.briefSkipped)
|
|
4774
|
-
h('div', { className: 'capital-automation-briefactions' }, openLink))
|
|
5054
|
+
h('p', null, zh.board.briefSkipped))
|
|
4775
5055
|
} else {
|
|
4776
5056
|
body = h('div', { className: 'capital-automation-briefstate' },
|
|
4777
5057
|
h(SkeletonBlock, { width: '72%', height: 14 }),
|
|
@@ -4877,56 +5157,172 @@ function BriefFeed(props) {
|
|
|
4877
5157
|
}
|
|
4878
5158
|
|
|
4879
5159
|
function TodoRow(props) {
|
|
4880
|
-
const { item, period, showDue = true, onOpenSession,
|
|
5160
|
+
const { item, period, showDue = true, onOpenSession, onDecide, checkpointHint = '', pending = false } = props
|
|
4881
5161
|
const [open, setOpen] = useState(false)
|
|
4882
|
-
const
|
|
5162
|
+
const [menuOpen, setMenuOpen] = useState(false)
|
|
5163
|
+
const sources = Array.isArray(item.sources) && item.sources.length > 0
|
|
5164
|
+
? item.sources
|
|
5165
|
+
: [{ taskTitle: item.taskTitle, finishedAt: item.finishedAt, sessionId: item.sessionId ?? null }]
|
|
5166
|
+
const quote = item.sourceQuote ?? sources[0]?.sourceQuote
|
|
4883
5167
|
const due = showDue === true ? boardTodoDueLabel(item, period) : ''
|
|
4884
|
-
const source = {
|
|
4885
|
-
taskTitle: item.taskTitle,
|
|
4886
|
-
finishedAt: item.finishedAt,
|
|
4887
|
-
sessionId: item.sessionId ?? item.sources?.[0]?.sessionId,
|
|
4888
|
-
}
|
|
4889
5168
|
const meta = []
|
|
4890
|
-
if (due) meta.push(h('span', { key: 'due' }, due))
|
|
4891
|
-
if (item.seenCount > 1) meta.push(h('span', { key: 'seen' }, zh.board.seenCount.replace('{n}', String(item.seenCount))))
|
|
4892
5169
|
const watch = item.watch && typeof item.watch === 'object' ? item.watch : null
|
|
4893
|
-
const
|
|
5170
|
+
const archived = period === 'expired'
|
|
5171
|
+
const status = archived ? 'expired' : boardTodoStatus(item)
|
|
5172
|
+
const decision = boardTodoDecision(item)
|
|
5173
|
+
const decided = decision !== undefined
|
|
5174
|
+
const compact = decided
|
|
4894
5175
|
const watchLabel = boardTodoWatchLabel(status)
|
|
4895
|
-
if (
|
|
4896
|
-
meta.push(h('span', { key: '
|
|
5176
|
+
if (!archived) {
|
|
5177
|
+
if (due) meta.push(h('span', { key: 'due' }, due))
|
|
5178
|
+
if (item.seenCount > 1) meta.push(h('span', { key: 'seen' }, zh.board.seenCount.replace('{n}', String(item.seenCount))))
|
|
5179
|
+
if (watch?.checkedAt && status !== 'resolved' && status !== 'deferred' && status !== 'tracking') {
|
|
5180
|
+
meta.push(h('span', { key: 'checked' }, zh.board.watchChecked.replace('{time}', formatShortTime(watch.checkedAt))))
|
|
5181
|
+
}
|
|
4897
5182
|
}
|
|
4898
5183
|
const watchMessage = status === 'triggered'
|
|
4899
|
-
? `${zh.board.watchEvidence}:${watch?.evidence ?? ''}`
|
|
5184
|
+
? `${zh.board.watchEvidence}:${watch?.evidence ?? ''}${watch?.source ? ` · ${zh.board.watchSource}:${watch.source}` : ''}`
|
|
4900
5185
|
: ''
|
|
4901
|
-
const
|
|
5186
|
+
const actionable = !archived && boardTodoCheckable(status)
|
|
5187
|
+
const pastDue = typeof item.dueAt === 'string' && item.dueAt < localDateKey(new Date())
|
|
5188
|
+
const autoAvailable = !archived && !pastDue && boardTodoAutoAvailable(item, status)
|
|
4902
5189
|
const basisAction = open ? zh.board.hideBasis : zh.board.showBasis
|
|
4903
|
-
const
|
|
4904
|
-
|
|
5190
|
+
const tags = !archived && watchLabel.length > 0
|
|
5191
|
+
? h('div', { className: 'capital-automation-todotags' },
|
|
5192
|
+
h('span', {
|
|
5193
|
+
className: 'capital-automation-todowatch',
|
|
5194
|
+
'data-status': status,
|
|
5195
|
+
title: boardTodoWatchHint(status, checkpointHint),
|
|
5196
|
+
},
|
|
5197
|
+
watchLabel))
|
|
5198
|
+
: null
|
|
5199
|
+
const menuItems = []
|
|
5200
|
+
if (actionable) {
|
|
5201
|
+
menuItems.push({
|
|
5202
|
+
id: 'confirm',
|
|
5203
|
+
label: decision === 'confirmed' ? `${zh.board.todoActionConfirm}(当前)` : zh.board.todoActionConfirm,
|
|
5204
|
+
icon: h(IconChecklistOutlineRegular, { size: 14 }),
|
|
5205
|
+
disabled: pending || decision === 'confirmed',
|
|
5206
|
+
})
|
|
5207
|
+
if (autoAvailable) {
|
|
5208
|
+
menuItems.push({
|
|
5209
|
+
id: 'auto',
|
|
5210
|
+
label: zh.board.todoActionAuto,
|
|
5211
|
+
icon: h(IconSparkleRegular, { size: 14 }),
|
|
5212
|
+
disabled: pending,
|
|
5213
|
+
})
|
|
5214
|
+
} else if (actionable && status !== 'watching') {
|
|
5215
|
+
const autoReason = pastDue && status !== 'triggered' && item.kind !== 'track' ? '已过期' : boardTodoAutoReason(item, status)
|
|
5216
|
+
if (autoReason.length > 0) {
|
|
5217
|
+
menuItems.push({
|
|
5218
|
+
id: 'auto-unavailable',
|
|
5219
|
+
label: `${zh.board.todoActionAuto}(${autoReason})`,
|
|
5220
|
+
icon: h(IconSparkleRegular, { size: 14 }),
|
|
5221
|
+
disabled: true,
|
|
5222
|
+
})
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
menuItems.push({
|
|
5226
|
+
id: 'defer',
|
|
5227
|
+
label: decision === 'deferred' ? `${zh.board.watchDeferred}(当前)` : zh.board.todoActionDefer,
|
|
5228
|
+
icon: h(IconClockOutlineRegular, { size: 14 }),
|
|
5229
|
+
disabled: pending || decision === 'deferred',
|
|
5230
|
+
})
|
|
5231
|
+
}
|
|
5232
|
+
const menu = actionable
|
|
5233
|
+
? h(Menu, {
|
|
5234
|
+
open: menuOpen,
|
|
5235
|
+
anchor: h('button', {
|
|
5236
|
+
type: 'button',
|
|
5237
|
+
className: 'capital-automation-todomenu',
|
|
5238
|
+
title: zh.board.todoMoreTitle,
|
|
5239
|
+
'aria-label': `${zh.board.todoMoreTitle}:${item.title}`,
|
|
5240
|
+
'aria-haspopup': 'menu',
|
|
5241
|
+
'aria-expanded': menuOpen ? 'true' : 'false',
|
|
5242
|
+
disabled: pending === true,
|
|
5243
|
+
onClick: () => setMenuOpen((value) => !value),
|
|
5244
|
+
}, h(IconEllipsisOutlineRegular, { size: 16 })),
|
|
5245
|
+
items: menuItems,
|
|
5246
|
+
onSelect: (id) => {
|
|
5247
|
+
setMenuOpen(false)
|
|
5248
|
+
if (id === 'confirm' || id === 'auto' || id === 'defer') onDecide(item, id)
|
|
5249
|
+
},
|
|
5250
|
+
onClose: () => setMenuOpen(false),
|
|
5251
|
+
align: 'end',
|
|
5252
|
+
portal: true,
|
|
5253
|
+
})
|
|
5254
|
+
: null
|
|
5255
|
+
const detailNode = open
|
|
5256
|
+
? h('div', { className: 'capital-automation-tododetail' },
|
|
5257
|
+
archived && item.detail ? h('p', { className: 'capital-automation-tododesc' }, item.detail) : null,
|
|
5258
|
+
archived && watch?.evidence
|
|
5259
|
+
? h('p', { className: 'capital-automation-todowatchmsg', 'data-status': status },
|
|
5260
|
+
`${zh.board.watchEvidence}:${watch.evidence}${watch.source ? ` · ${zh.board.watchSource}:${watch.source}` : ''}`)
|
|
5261
|
+
: null,
|
|
5262
|
+
h('blockquote', null, quote),
|
|
5263
|
+
sources.map((entry, index) => h('div', {
|
|
5264
|
+
key: entry.runId ?? `source-${index}`,
|
|
5265
|
+
className: 'capital-automation-todosource',
|
|
5266
|
+
},
|
|
5267
|
+
h('span', null, `${zh.board.sourceRun}:${entry.taskTitle} · ${formatShortTime(entry.finishedAt)}`),
|
|
5268
|
+
entry.sessionId
|
|
5269
|
+
? h('button', {
|
|
5270
|
+
type: 'button',
|
|
5271
|
+
className: 'capital-automation-btn',
|
|
5272
|
+
'data-size': 'icon',
|
|
5273
|
+
title: zh.openSession,
|
|
5274
|
+
'aria-label': zh.openSession,
|
|
5275
|
+
onClick: () => onOpenSession(entry.sessionId),
|
|
5276
|
+
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
5277
|
+
: null)))
|
|
5278
|
+
: null
|
|
5279
|
+
if (archived) {
|
|
5280
|
+
const conclusion = boardTodoConclusion(item)
|
|
5281
|
+
const historyMeta = [
|
|
5282
|
+
h('span', {
|
|
5283
|
+
key: 'conclusion',
|
|
5284
|
+
className: 'capital-automation-historyconclusion',
|
|
5285
|
+
'data-tone': conclusion.tone,
|
|
5286
|
+
}, conclusion.label),
|
|
5287
|
+
conclusion.at
|
|
5288
|
+
? h('span', { key: 'at' },
|
|
5289
|
+
(conclusion.kind === 'manual' ? zh.board.todoManualAt : zh.board.todoCheckedAt)
|
|
5290
|
+
.replace('{date}', formatMonthDay(conclusion.at)))
|
|
5291
|
+
: null,
|
|
5292
|
+
item.seenCount > 1 ? h('span', { key: 'seen' }, zh.board.seenCount.replace('{n}', String(item.seenCount))) : null,
|
|
5293
|
+
].filter((node) => node !== null)
|
|
5294
|
+
return h('li', {
|
|
5295
|
+
className: 'capital-automation-todoitem',
|
|
5296
|
+
'data-archived': 'true',
|
|
5297
|
+
'data-decision': decision,
|
|
5298
|
+
},
|
|
4905
5299
|
h('div', { className: 'capital-automation-todoline' },
|
|
5300
|
+
h('button', {
|
|
5301
|
+
type: 'button',
|
|
5302
|
+
className: 'capital-automation-historytitle',
|
|
5303
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
5304
|
+
'aria-label': `${item.title},${basisAction}`,
|
|
5305
|
+
title: basisAction,
|
|
5306
|
+
onClick: () => setOpen((value) => !value),
|
|
5307
|
+
}, item.title),
|
|
5308
|
+
historyMeta.length > 0
|
|
5309
|
+
? h('div', { className: 'capital-automation-todometa capital-automation-historymeta' }, historyMeta)
|
|
5310
|
+
: null),
|
|
5311
|
+
detailNode)
|
|
5312
|
+
}
|
|
5313
|
+
return h('li', {
|
|
5314
|
+
className: 'capital-automation-todoitem',
|
|
5315
|
+
'data-decided': decided ? 'true' : undefined,
|
|
5316
|
+
'data-decision': decision,
|
|
5317
|
+
},
|
|
5318
|
+
compact
|
|
5319
|
+
? h('div', { className: 'capital-automation-todoline' },
|
|
4906
5320
|
h('div', { className: 'capital-automation-todotop' },
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
title: boardTodoWatchHint(status, checkpointHint),
|
|
4913
|
-
},
|
|
4914
|
-
watchLabel,
|
|
4915
|
-
status === 'resolved' ? h('span', { className: 'capital-automation-todowatchcheck', 'aria-hidden': 'true' }, '✓') : null)
|
|
4916
|
-
: null),
|
|
4917
|
-
checkable
|
|
4918
|
-
? h('button', {
|
|
4919
|
-
type: 'button',
|
|
4920
|
-
className: 'capital-automation-todocheck',
|
|
4921
|
-
role: 'checkbox',
|
|
4922
|
-
'aria-checked': 'false',
|
|
4923
|
-
title: zh.board.todoAckTitle,
|
|
4924
|
-
'aria-label': `${zh.board.todoAckTitle}:${item.title}`,
|
|
4925
|
-
'data-busy': acking === true ? 'true' : undefined,
|
|
4926
|
-
disabled: ackDisabled === true,
|
|
4927
|
-
onClick: () => onAck(item),
|
|
4928
|
-
}, acking === true ? h('span', { className: 'capital-automation-todocheckspin', 'aria-hidden': 'true' }) : null)
|
|
4929
|
-
: null),
|
|
5321
|
+
tags,
|
|
5322
|
+
h('span', { className: 'capital-automation-todotitle', title: item.title }, item.title),
|
|
5323
|
+
menu))
|
|
5324
|
+
: h('div', { className: 'capital-automation-todoline' },
|
|
5325
|
+
h('div', { className: 'capital-automation-todotop' }, tags, menu),
|
|
4930
5326
|
h('button', {
|
|
4931
5327
|
type: 'button',
|
|
4932
5328
|
className: 'capital-automation-todotitle',
|
|
@@ -4934,30 +5330,13 @@ function TodoRow(props) {
|
|
|
4934
5330
|
'aria-label': `${item.title},${basisAction}`,
|
|
4935
5331
|
title: basisAction,
|
|
4936
5332
|
onClick: () => setOpen((value) => !value),
|
|
4937
|
-
}, item.title
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
? h('div', { className: 'capital-automation-tododetail' },
|
|
4945
|
-
h('blockquote', null, quote),
|
|
4946
|
-
source
|
|
4947
|
-
? h('div', { className: 'capital-automation-todosource' },
|
|
4948
|
-
h('span', null, `${zh.board.sourceRun}:${source.taskTitle} · ${formatShortTime(source.finishedAt)}`),
|
|
4949
|
-
source.sessionId
|
|
4950
|
-
? h('button', {
|
|
4951
|
-
type: 'button',
|
|
4952
|
-
className: 'capital-automation-btn',
|
|
4953
|
-
'data-size': 'icon',
|
|
4954
|
-
title: zh.openSession,
|
|
4955
|
-
'aria-label': zh.openSession,
|
|
4956
|
-
onClick: () => onOpenSession(source.sessionId),
|
|
4957
|
-
}, h(IconRightUpOutlineRegular, { size: 14 }))
|
|
4958
|
-
: null)
|
|
4959
|
-
: null)
|
|
4960
|
-
: null)
|
|
5333
|
+
}, item.title)),
|
|
5334
|
+
!compact && item.detail ? h('p', { className: 'capital-automation-tododesc' }, item.detail) : null,
|
|
5335
|
+
!compact && watchMessage.length > 0
|
|
5336
|
+
? h('p', { className: 'capital-automation-todowatchmsg', 'data-status': status }, watchMessage)
|
|
5337
|
+
: null,
|
|
5338
|
+
!decided && meta.length > 0 ? h('div', { className: 'capital-automation-todometa' }, meta) : null,
|
|
5339
|
+
!decided ? detailNode : null)
|
|
4961
5340
|
}
|
|
4962
5341
|
|
|
4963
5342
|
function BoardPanelHead(props) {
|
|
@@ -4998,43 +5377,152 @@ function BoardPanel(props) {
|
|
|
4998
5377
|
}, children))
|
|
4999
5378
|
}
|
|
5000
5379
|
|
|
5380
|
+
function yesterdayDateKey() {
|
|
5381
|
+
return localDateKey(addLocalDays(new Date(), -1))
|
|
5382
|
+
}
|
|
5383
|
+
|
|
5384
|
+
function monthKeyOf(dateKey) {
|
|
5385
|
+
return typeof dateKey === 'string' && /^\d{4}-\d{2}/.test(dateKey)
|
|
5386
|
+
? dateKey.slice(0, 7)
|
|
5387
|
+
: localDateKey(new Date()).slice(0, 7)
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
function shiftMonthKey(monthKey, delta) {
|
|
5391
|
+
const [year, month] = monthKey.split('-').map(Number)
|
|
5392
|
+
const date = new Date(year, month - 1 + delta, 1)
|
|
5393
|
+
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}`
|
|
5394
|
+
}
|
|
5395
|
+
|
|
5396
|
+
/** Host-Menu month grid; only days before today are selectable. */
|
|
5397
|
+
function HistoryDatePicker(props) {
|
|
5398
|
+
const { value, min, max, onChange } = props
|
|
5399
|
+
const [open, setOpen] = useState(false)
|
|
5400
|
+
const [month, setMonth] = useState(() => monthKeyOf(value))
|
|
5401
|
+
useEffect(() => {
|
|
5402
|
+
if (open) setMonth(monthKeyOf(value))
|
|
5403
|
+
}, [open, value])
|
|
5404
|
+
const [year, monthNumber] = month.split('-').map(Number)
|
|
5405
|
+
const lead = new Date(year, monthNumber - 1, 1).getDay()
|
|
5406
|
+
const total = new Date(year, monthNumber, 0).getDate()
|
|
5407
|
+
const cells = [
|
|
5408
|
+
...Array.from({ length: lead }, (_, index) => ({ key: `lead-${index}`, day: null })),
|
|
5409
|
+
...Array.from({ length: total }, (_, index) => ({ key: dateStringFromParts(year, monthNumber, index + 1), day: index + 1 })),
|
|
5410
|
+
]
|
|
5411
|
+
const nextDisabled = month >= monthKeyOf(max)
|
|
5412
|
+
const prevDisabled = typeof min === 'string' && min.length > 0 && month <= monthKeyOf(min)
|
|
5413
|
+
const trigger = h('button', {
|
|
5414
|
+
type: 'button',
|
|
5415
|
+
className: 'capital-automation-select capital-automation-datepick',
|
|
5416
|
+
'data-size': 'sm',
|
|
5417
|
+
'aria-label': `${zh.board.todoDateLabel}:${formatMonthDay(value)}`,
|
|
5418
|
+
'aria-haspopup': 'menu',
|
|
5419
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
5420
|
+
title: zh.board.todoDateLabel,
|
|
5421
|
+
onClick: () => setOpen((current) => !current),
|
|
5422
|
+
},
|
|
5423
|
+
h('span', { className: 'capital-automation-selectvalue' }, formatMonthDay(value)),
|
|
5424
|
+
h(IconChevronDownOutlineRegular, { size: 12 }))
|
|
5425
|
+
return h(Menu, {
|
|
5426
|
+
open,
|
|
5427
|
+
anchor: trigger,
|
|
5428
|
+
items: [],
|
|
5429
|
+
onClose: () => setOpen(false),
|
|
5430
|
+
align: 'end',
|
|
5431
|
+
portal: true,
|
|
5432
|
+
listClassName: 'capital-automation-datepick-menu',
|
|
5433
|
+
},
|
|
5434
|
+
h('div', { className: 'capital-automation-datepick-head' },
|
|
5435
|
+
h('button', {
|
|
5436
|
+
type: 'button',
|
|
5437
|
+
className: 'capital-automation-datepick-nav',
|
|
5438
|
+
'aria-label': '上个月',
|
|
5439
|
+
disabled: prevDisabled,
|
|
5440
|
+
onClick: () => { if (!prevDisabled) setMonth((current) => shiftMonthKey(current, -1)) },
|
|
5441
|
+
}, h(IconChevronLeftOutlineRegular, { size: 14 })),
|
|
5442
|
+
h('span', { className: 'capital-automation-datepick-month' }, `${year} 年 ${monthNumber} 月`),
|
|
5443
|
+
h('button', {
|
|
5444
|
+
type: 'button',
|
|
5445
|
+
className: 'capital-automation-datepick-nav',
|
|
5446
|
+
'aria-label': '下个月',
|
|
5447
|
+
disabled: nextDisabled,
|
|
5448
|
+
onClick: () => { if (!nextDisabled) setMonth((current) => shiftMonthKey(current, 1)) },
|
|
5449
|
+
}, h(IconChevronRightOutlineRegular, { size: 14 }))),
|
|
5450
|
+
h('div', { className: 'capital-automation-datepick-week' },
|
|
5451
|
+
['日', '一', '二', '三', '四', '五', '六'].map((label) => h('span', {
|
|
5452
|
+
key: label,
|
|
5453
|
+
className: 'capital-automation-datepick-weekday',
|
|
5454
|
+
}, label))),
|
|
5455
|
+
h('div', { className: 'capital-automation-datepick-grid' },
|
|
5456
|
+
cells.map((cell) => cell.day === null
|
|
5457
|
+
? h('span', { key: cell.key })
|
|
5458
|
+
: h('button', {
|
|
5459
|
+
key: cell.key,
|
|
5460
|
+
type: 'button',
|
|
5461
|
+
className: 'capital-automation-datepick-day',
|
|
5462
|
+
'data-selected': cell.key === value ? 'true' : undefined,
|
|
5463
|
+
disabled: cell.key > max || (typeof min === 'string' && min.length > 0 && cell.key < min),
|
|
5464
|
+
'aria-label': cell.key,
|
|
5465
|
+
'aria-pressed': cell.key === value ? 'true' : 'false',
|
|
5466
|
+
onClick: () => {
|
|
5467
|
+
onChange(cell.key)
|
|
5468
|
+
setOpen(false)
|
|
5469
|
+
},
|
|
5470
|
+
}, String(cell.day)))))
|
|
5471
|
+
}
|
|
5472
|
+
|
|
5001
5473
|
function TodoPanel(props) {
|
|
5002
|
-
const { todos, tasks, onOpenSession,
|
|
5474
|
+
const { todos, tasks, minDate = null, onOpenSession, onDecideTodo, pendingTodoIds = new Set(), open, onToggle } = props
|
|
5003
5475
|
const [filter, setFilter] = useState('today')
|
|
5004
|
-
const
|
|
5005
|
-
const
|
|
5006
|
-
entries
|
|
5007
|
-
const visible = entries.filter((entry) => entry.period === filter
|
|
5008
|
-
|
|
5476
|
+
const [historyDate, setHistoryDate] = useState(yesterdayDateKey)
|
|
5477
|
+
const historyDay = typeof minDate === 'string' && minDate.length > 0 && historyDate < minDate ? minDate : historyDate
|
|
5478
|
+
const entries = boardTodoEntries(todos, new Date())
|
|
5479
|
+
const visible = entries.filter((entry) => entry.period === filter
|
|
5480
|
+
&& (filter !== 'expired' || boardTodoHistoryDate(entry.item) === historyDay))
|
|
5481
|
+
if (filter === 'expired') {
|
|
5482
|
+
visible.sort((left, right) => {
|
|
5483
|
+
const leftAt = Date.parse(boardTodoConclusion(left.item).at)
|
|
5484
|
+
const rightAt = Date.parse(boardTodoConclusion(right.item).at)
|
|
5485
|
+
const delta = (Number.isFinite(rightAt) ? rightAt : 0) - (Number.isFinite(leftAt) ? leftAt : 0)
|
|
5486
|
+
if (delta !== 0) return delta
|
|
5487
|
+
return String(right.item.lastSeenAt ?? '').localeCompare(String(left.item.lastSeenAt ?? ''))
|
|
5488
|
+
|| String(left.item.title).localeCompare(String(right.item.title))
|
|
5489
|
+
})
|
|
5490
|
+
}
|
|
5491
|
+
const checkpointHint = boardTodoVerifierHint(tasks)
|
|
5009
5492
|
const emptyText = filter === 'today'
|
|
5010
5493
|
? zh.board.todoEmptyToday
|
|
5011
|
-
:
|
|
5494
|
+
: filter === 'expired'
|
|
5495
|
+
? zh.board.todoEmptyHistory.replace('{date}', formatMonthDay(historyDay))
|
|
5496
|
+
: zh.board.todoEmptyGroup.replace('{label}', boardTodoGroupLabel(filter))
|
|
5012
5497
|
return h(BoardPanel, {
|
|
5013
5498
|
id: 'capital-automation-todo',
|
|
5014
5499
|
title: zh.board.todoTitle,
|
|
5015
5500
|
open,
|
|
5016
5501
|
onToggle,
|
|
5017
|
-
action: h(
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5502
|
+
action: h('div', { className: 'capital-automation-todofilters' },
|
|
5503
|
+
filter === 'expired'
|
|
5504
|
+
? h(HistoryDatePicker, { value: historyDay, min: minDate, max: yesterdayDateKey(), onChange: setHistoryDate })
|
|
5505
|
+
: null,
|
|
5506
|
+
h(Select, {
|
|
5507
|
+
value: filter,
|
|
5508
|
+
options: boardTodoFilterOptions(),
|
|
5509
|
+
onChange: setFilter,
|
|
5510
|
+
size: 'sm',
|
|
5511
|
+
label: zh.board.todoFilterLabel,
|
|
5512
|
+
align: 'end',
|
|
5513
|
+
})),
|
|
5025
5514
|
},
|
|
5026
5515
|
visible.length === 0
|
|
5027
5516
|
? h('p', { className: 'capital-automation-hint' }, emptyText)
|
|
5028
|
-
: h('ul', { className: 'capital-automation-todolist' }, visible.map((entry) => h(TodoRow, {
|
|
5517
|
+
: h('ul', { className: 'capital-automation-todolist', 'data-period': filter }, visible.map((entry) => h(TodoRow, {
|
|
5029
5518
|
key: entry.item.id,
|
|
5030
5519
|
item: entry.item,
|
|
5031
5520
|
period: entry.period,
|
|
5032
5521
|
showDue: true,
|
|
5033
5522
|
onOpenSession,
|
|
5034
|
-
|
|
5035
|
-
acking: ackingTodoId === entry.item.id,
|
|
5036
|
-
ackDisabled: ackingTodoId !== null && ackingTodoId !== undefined,
|
|
5523
|
+
onDecide: onDecideTodo,
|
|
5037
5524
|
checkpointHint,
|
|
5525
|
+
pending: pendingTodoIds.has(entry.item.id),
|
|
5038
5526
|
}))))
|
|
5039
5527
|
}
|
|
5040
5528
|
|
|
@@ -5072,7 +5560,9 @@ function StockRow(props) {
|
|
|
5072
5560
|
const stockKey = boardEntrySymbolKey(stock)
|
|
5073
5561
|
const related = Array.isArray(stock.items)
|
|
5074
5562
|
? stock.items
|
|
5075
|
-
: todos.filter((item) => item.ackedAt === undefined &&
|
|
5563
|
+
: todos.filter((item) => item.ackedAt === undefined && item.deferredAt === undefined
|
|
5564
|
+
&& boardTodoPeriod(item) !== 'expired'
|
|
5565
|
+
&& boardEntrySymbolKey(item) === stockKey)
|
|
5076
5566
|
const followUpCount = Array.isArray(stock.items) ? stock.items.length : (stock.todoCount ?? 0)
|
|
5077
5567
|
const roleSummary = stock.roles.map((role) => boardRoleTitle(role)).join(';')
|
|
5078
5568
|
return h('div', { className: 'capital-automation-stockrow' },
|
|
@@ -5189,7 +5679,7 @@ function GapRow(props) {
|
|
|
5189
5679
|
'aria-label': `${gap.topic},${basisAction}`,
|
|
5190
5680
|
title: basisAction,
|
|
5191
5681
|
onClick: () => setOpen((value) => !value),
|
|
5192
|
-
}, gap.topic
|
|
5682
|
+
}, gap.topic)),
|
|
5193
5683
|
h('p', { className: 'capital-automation-gapdesc' }, gap.detail),
|
|
5194
5684
|
open
|
|
5195
5685
|
? h('div', { className: 'capital-automation-tododetail' },
|
|
@@ -5305,7 +5795,7 @@ function BoardPage(props) {
|
|
|
5305
5795
|
const {
|
|
5306
5796
|
board, tasks, api, loading, error, range, category, onRange, onCategory, onRefresh,
|
|
5307
5797
|
onOpenSession, onRetryBrief, retryingRunId, onLoadMore, loadingMore, onGoTasks, onNewTask, onGoRuns,
|
|
5308
|
-
|
|
5798
|
+
onDecideTodo, pendingTodoIds, hasActiveTasks, storageReady,
|
|
5309
5799
|
} = props
|
|
5310
5800
|
const [railOpen, setRailOpen] = useState(() => readBoardUi().rail !== false)
|
|
5311
5801
|
const [openPanels, setOpenPanels] = useState(() => boardPanelFlags(readBoardUi().panels))
|
|
@@ -5423,9 +5913,10 @@ function BoardPage(props) {
|
|
|
5423
5913
|
h(TodoPanel, {
|
|
5424
5914
|
todos: board?.todos ?? [],
|
|
5425
5915
|
tasks,
|
|
5916
|
+
minDate: board?.range?.from ?? null,
|
|
5426
5917
|
onOpenSession,
|
|
5427
|
-
|
|
5428
|
-
|
|
5918
|
+
onDecideTodo,
|
|
5919
|
+
pendingTodoIds,
|
|
5429
5920
|
open: openPanels.todo,
|
|
5430
5921
|
onToggle: () => togglePanel('todo'),
|
|
5431
5922
|
}),
|
|
@@ -5466,7 +5957,6 @@ function AutomationPage(props) {
|
|
|
5466
5957
|
const [boardRange, setBoardRange] = useState('14')
|
|
5467
5958
|
const [boardCategory, setBoardCategory] = useState('all')
|
|
5468
5959
|
const [retryingBriefId, setRetryingBriefId] = useState(null)
|
|
5469
|
-
const [ackingTodoId, setAckingTodoId] = useState(null)
|
|
5470
5960
|
const [boardLoadingMore, setBoardLoadingMore] = useState(false)
|
|
5471
5961
|
const [unread, setUnread] = useState(0)
|
|
5472
5962
|
const [tasksReady, setTasksReady] = useState(false)
|
|
@@ -5483,6 +5973,7 @@ function AutomationPage(props) {
|
|
|
5483
5973
|
const [busyTaskId, setBusyTaskId] = useState(null)
|
|
5484
5974
|
const [inboxBusy, setInboxBusy] = useState(false)
|
|
5485
5975
|
const [notice, setNotice] = useState('')
|
|
5976
|
+
const [pendingTodoIds, setPendingTodoIds] = useState(() => new Set())
|
|
5486
5977
|
const [loadError, setLoadError] = useState('')
|
|
5487
5978
|
const mountedRef = useRef(false)
|
|
5488
5979
|
const tasksRef = useRef([])
|
|
@@ -5497,6 +5988,7 @@ function AutomationPage(props) {
|
|
|
5497
5988
|
const refreshSequenceRef = useRef(0)
|
|
5498
5989
|
const detailSequenceRef = useRef(0)
|
|
5499
5990
|
const boardSequenceRef = useRef(0)
|
|
5991
|
+
const optimisticDecisionRef = useRef(new Map())
|
|
5500
5992
|
const scrollRef = useRef(null)
|
|
5501
5993
|
const mountedAtRef = useRef(typeof performance === 'undefined' ? 0 : performance.now())
|
|
5502
5994
|
const timingRecordedRef = useRef(false)
|
|
@@ -5638,6 +6130,16 @@ function AutomationPage(props) {
|
|
|
5638
6130
|
}
|
|
5639
6131
|
}
|
|
5640
6132
|
|
|
6133
|
+
// A decision request and a board poll can cross: keep the optimistic state on every response
|
|
6134
|
+
// until the request settles, then let the next poll read the server truth.
|
|
6135
|
+
function applyOptimisticDecisions(value) {
|
|
6136
|
+
let next = value
|
|
6137
|
+
for (const [id, entry] of optimisticDecisionRef.current) {
|
|
6138
|
+
next = applyTodoDecision(next, id, entry.action, entry.at)
|
|
6139
|
+
}
|
|
6140
|
+
return next
|
|
6141
|
+
}
|
|
6142
|
+
|
|
5641
6143
|
async function loadBoard(nextRange = boardRange, nextCategory = boardCategory, before = null) {
|
|
5642
6144
|
const query = boardQueryOf(nextRange, nextCategory, before)
|
|
5643
6145
|
const snapshot = before === null ? readBoardSnapshot(query) : null
|
|
@@ -5647,7 +6149,7 @@ function AutomationPage(props) {
|
|
|
5647
6149
|
// A cached board paints immediately; the request below still revalidates it.
|
|
5648
6150
|
if (snapshot === null) setBoardLoading(true)
|
|
5649
6151
|
else {
|
|
5650
|
-
setBoard(snapshot)
|
|
6152
|
+
setBoard(applyOptimisticDecisions(snapshot))
|
|
5651
6153
|
setBoardLoading(false)
|
|
5652
6154
|
}
|
|
5653
6155
|
}
|
|
@@ -5655,11 +6157,11 @@ function AutomationPage(props) {
|
|
|
5655
6157
|
const value = await api.board(query)
|
|
5656
6158
|
if (!mountedRef.current || requestSequence !== boardSequenceRef.current) return
|
|
5657
6159
|
if (before === null) {
|
|
5658
|
-
setBoard(value)
|
|
6160
|
+
setBoard(applyOptimisticDecisions(value))
|
|
5659
6161
|
writeBoardSnapshot(query, value)
|
|
5660
|
-
} else setBoard((current) => current === null
|
|
6162
|
+
} else setBoard((current) => applyOptimisticDecisions(current === null
|
|
5661
6163
|
? value
|
|
5662
|
-
: { ...value, cards: [...current.cards, ...value.cards] })
|
|
6164
|
+
: { ...value, cards: [...current.cards, ...value.cards] }))
|
|
5663
6165
|
setBoardError('')
|
|
5664
6166
|
} catch (error) {
|
|
5665
6167
|
if (mountedRef.current && requestSequence === boardSequenceRef.current) {
|
|
@@ -5695,55 +6197,51 @@ function AutomationPage(props) {
|
|
|
5695
6197
|
}
|
|
5696
6198
|
}
|
|
5697
6199
|
|
|
5698
|
-
|
|
5699
|
-
if (
|
|
5700
|
-
|
|
6200
|
+
function decideTodo(item, action) {
|
|
6201
|
+
if (typeof item?.id !== 'string') return
|
|
6202
|
+
if (action !== 'confirm' && action !== 'auto' && action !== 'defer') return
|
|
6203
|
+
if (pendingTodoIds.has(item.id) || optimisticDecisionRef.current.has(item.id)) return
|
|
6204
|
+
// Paint the decision first; the write travels in the background and a crossing board poll is
|
|
6205
|
+
// overlaid with the same state.
|
|
6206
|
+
const at = new Date().toISOString()
|
|
6207
|
+
const previous = {
|
|
6208
|
+
ackedAt: item.ackedAt,
|
|
6209
|
+
deferredAt: item.deferredAt,
|
|
6210
|
+
decision: item.decision,
|
|
6211
|
+
watch: item.watch,
|
|
6212
|
+
}
|
|
6213
|
+
optimisticDecisionRef.current.set(item.id, { action, at })
|
|
6214
|
+
setPendingTodoIds((current) => {
|
|
6215
|
+
const next = new Set(current)
|
|
6216
|
+
next.add(item.id)
|
|
6217
|
+
return next
|
|
6218
|
+
})
|
|
6219
|
+
setBoard((current) => applyTodoDecision(current, item.id, action, at))
|
|
6220
|
+
setNotice(action === 'confirm'
|
|
6221
|
+
? zh.board.todoAcked
|
|
6222
|
+
: action === 'defer' ? zh.board.todoDeferred : zh.board.todoAutoQueued)
|
|
5701
6223
|
setBoardError('')
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
}),
|
|
5722
|
-
}
|
|
5723
|
-
: entry)
|
|
5724
|
-
const targetKey = target.symbol === undefined ? undefined : boardEntrySymbolKey(target)
|
|
5725
|
-
const stocks = (current.stocks ?? []).map((stock) => {
|
|
5726
|
-
if (targetKey === undefined || boardEntrySymbolKey(stock) !== targetKey) return stock
|
|
5727
|
-
if (!Array.isArray(stock.items)) return { ...stock, todoCount: Math.max(0, (stock.todoCount ?? 0) - 1) }
|
|
5728
|
-
const items = stock.items.filter((entry) => entry.id !== target.id)
|
|
5729
|
-
return { ...stock, items, todoCount: items.length }
|
|
5730
|
-
})
|
|
5731
|
-
return {
|
|
5732
|
-
...current,
|
|
5733
|
-
todos,
|
|
5734
|
-
stocks,
|
|
5735
|
-
stats: current.stats === undefined
|
|
5736
|
-
? current.stats
|
|
5737
|
-
: { ...current.stats, todos: Math.max(0, (current.stats.todos ?? 0) - 1) },
|
|
5738
|
-
}
|
|
6224
|
+
void api.decideTodo(item.id, action).then(() => {
|
|
6225
|
+
optimisticDecisionRef.current.delete(item.id)
|
|
6226
|
+
// Ignore a poll that started before the server write; the next poll reads the truth.
|
|
6227
|
+
boardSequenceRef.current += 1
|
|
6228
|
+
if (mountedRef.current) setBoardLoading(false)
|
|
6229
|
+
}).catch((error) => {
|
|
6230
|
+
optimisticDecisionRef.current.delete(item.id)
|
|
6231
|
+
boardSequenceRef.current += 1
|
|
6232
|
+
if (!mountedRef.current) return
|
|
6233
|
+
setBoardLoading(false)
|
|
6234
|
+
setBoard((current) => restoreBoardTodoState(current, item.id, previous))
|
|
6235
|
+
setNotice('')
|
|
6236
|
+
setBoardError(error?.message ?? zh.errorGeneric)
|
|
6237
|
+
}).finally(() => {
|
|
6238
|
+
if (!mountedRef.current) return
|
|
6239
|
+
setPendingTodoIds((current) => {
|
|
6240
|
+
const next = new Set(current)
|
|
6241
|
+
next.delete(item.id)
|
|
6242
|
+
return next
|
|
5739
6243
|
})
|
|
5740
|
-
|
|
5741
|
-
void loadBoard(boardRange, boardCategory)
|
|
5742
|
-
} catch (error) {
|
|
5743
|
-
setBoardError(error.message ?? zh.errorGeneric)
|
|
5744
|
-
} finally {
|
|
5745
|
-
setAckingTodoId(null)
|
|
5746
|
-
}
|
|
6244
|
+
})
|
|
5747
6245
|
}
|
|
5748
6246
|
|
|
5749
6247
|
async function loadDetail(id) {
|
|
@@ -6038,8 +6536,8 @@ function AutomationPage(props) {
|
|
|
6038
6536
|
onOpenSession: openSession,
|
|
6039
6537
|
onRetryBrief: (runId) => { void retryBrief(runId) },
|
|
6040
6538
|
retryingRunId: retryingBriefId,
|
|
6041
|
-
|
|
6042
|
-
|
|
6539
|
+
onDecideTodo: (item, action) => { decideTodo(item, action) },
|
|
6540
|
+
pendingTodoIds,
|
|
6043
6541
|
onLoadMore: () => { void loadMoreBoard() },
|
|
6044
6542
|
loadingMore: boardLoadingMore,
|
|
6045
6543
|
onGoTasks: () => switchTab('tasks'),
|