@v587d/capital-generation 2.13.0 → 2.13.2
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 +43 -0
- package/README.md +77 -78
- package/automation/calendar-source.js +361 -0
- package/automation/client.js +351 -58
- package/automation/client.src.cjs +2510 -429
- package/automation/defaults.js +4 -0
- package/automation/index.js +7 -2
- package/automation/package.json +2 -1
- package/automation/runner.js +68 -14
- package/automation/scheduler.js +20 -2
- package/automation/schema.js +16 -0
- package/automation/store.js +37 -12
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/sources/wind-mcp.js +3 -3
- 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 +2 -1
- package/watchlist/package.json +1 -1
|
@@ -1,74 +1,187 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser half of `@v587d/capital-automation`:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* only reads the one profile the server put it in and never sends a profile or owner field.
|
|
2
|
+
* Browser half of `@v587d/capital-automation`: the `capital-automation` main key plus the
|
|
3
|
+
* adjacent sidebar row. The page owns no schedule identity and reads only the profile the
|
|
4
|
+
* server put it in; `/capital-automation` is the only data source.
|
|
6
5
|
*/
|
|
7
6
|
const { createElement: h, useEffect, useRef, useState } = require('react')
|
|
8
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
IconAlarmClockOutlineRegular,
|
|
9
|
+
IconChecklistOutlineRegular,
|
|
10
|
+
IconChevronDownOutlineRegular,
|
|
11
|
+
IconChevronLeftOutlineRegular,
|
|
12
|
+
IconChevronRightOutlineRegular,
|
|
13
|
+
IconClockOutlineRegular,
|
|
14
|
+
IconCopyOutlineRegular,
|
|
15
|
+
IconEditOutlineRegular,
|
|
16
|
+
IconEllipsisOutlineRegular,
|
|
17
|
+
IconFolderOpenOutlineRegular,
|
|
18
|
+
IconGaugeOutlineRegular,
|
|
19
|
+
IconGlobeOutlineRegular,
|
|
20
|
+
IconInfoOutlineRegular,
|
|
21
|
+
IconLightOutlineMedium,
|
|
22
|
+
IconListPenOutlineRegular,
|
|
23
|
+
IconPauseOutlineRegular,
|
|
24
|
+
IconPlayOutlineRegular,
|
|
25
|
+
IconPlusOutlineRegular,
|
|
26
|
+
IconRefreshOutlineRegular,
|
|
27
|
+
IconRightUpOutlineRegular,
|
|
28
|
+
IconSearchOutlineRegular,
|
|
29
|
+
IconSparkleRegular,
|
|
30
|
+
IconTrashOutlineRegular,
|
|
31
|
+
IconWarningOutlineRegular,
|
|
32
|
+
Menu,
|
|
33
|
+
MenuItemButton,
|
|
34
|
+
Modal,
|
|
35
|
+
Switch,
|
|
36
|
+
} = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
9
37
|
|
|
10
38
|
const ENTRY_NAME = 'capital-automation'
|
|
11
39
|
const ROUTE = '/capital-automation'
|
|
12
40
|
const PANEL_ID = 'capital-automation'
|
|
13
41
|
const STYLE_TAG = 'capital-automation-css'
|
|
42
|
+
const ACTIVE_RUN_STATUSES = ['queued', 'starting', 'running']
|
|
43
|
+
const FAILURE_RUN_STATUSES = ['failed', 'timed_out', 'blocked_requires_user', 'unknown_after_restart']
|
|
44
|
+
const SKIPPED_RUN_STATUSES = ['skipped_overlap', 'skipped_calendar_unavailable', 'missed']
|
|
45
|
+
const DEFAULT_LIMITS = { runTimeoutMinutes: 30, idleTimeoutMinutes: 5, maxSteps: 300, maxToolCalls: 1200 }
|
|
46
|
+
const WEEKDAYS = [
|
|
47
|
+
{ value: 1, label: '一' },
|
|
48
|
+
{ value: 2, label: '二' },
|
|
49
|
+
{ value: 3, label: '三' },
|
|
50
|
+
{ value: 4, label: '四' },
|
|
51
|
+
{ value: 5, label: '五' },
|
|
52
|
+
{ value: 6, label: '六' },
|
|
53
|
+
{ value: 7, label: '日' },
|
|
54
|
+
]
|
|
55
|
+
const TIMEZONES = ['Asia/Shanghai', 'Asia/Hong_Kong', 'Asia/Singapore', 'Asia/Tokyo', 'UTC', 'Europe/London', 'America/New_York', 'America/Los_Angeles']
|
|
56
|
+
const HISTORY_DAYS = 30
|
|
57
|
+
const DETAIL_RECENT_RUN_LIMIT = 3
|
|
14
58
|
|
|
15
59
|
const zh = {
|
|
16
60
|
panel: 'CapGen 投研自动化',
|
|
17
61
|
title: 'CapGen 投研自动化',
|
|
18
|
-
subtitle: '
|
|
19
|
-
|
|
20
|
-
scheduler: '调度器',
|
|
21
|
-
schedulerActive: '运行权已取得',
|
|
22
|
-
schedulerStandby: '未取得运行权(只读)',
|
|
23
|
-
schedulerStarting: '启动中',
|
|
24
|
-
schedulerStopped: '已停止',
|
|
25
|
-
calendar: '交易日历',
|
|
26
|
-
calendarOk: '可用',
|
|
27
|
-
calendarMissing: '不可用(交易日任务会跳过)',
|
|
62
|
+
subtitle: '定时投研,自动执行,结果可追溯',
|
|
63
|
+
tabs: { tasks: '任务', runs: '运行' },
|
|
28
64
|
storageUnavailable: '存储不可用,页面只读',
|
|
65
|
+
standbyBanner: '调度器未取得运行权:定时触发与手动运行已暂停,任务配置仍可查看和编辑。',
|
|
66
|
+
storageBanner: '投研自动化存储暂时不可用:页面只读,调度器不会启动。',
|
|
67
|
+
calendarBanner: '交易日历暂时不可用:仅交易日的任务会跳过,其他任务仍按设定时间运行。',
|
|
68
|
+
calendarCoverageBanner: '交易日历只覆盖到 {through}:之后仅交易日的任务会按 fail-closed 跳过;交易所公布新一年安排后会自动接上。',
|
|
69
|
+
calendarField: '交易日历',
|
|
70
|
+
calendarSourceSzse: '深交所官方日历',
|
|
71
|
+
calendarSourceBundled: '内置表',
|
|
72
|
+
calendarSourceNone: '不可用',
|
|
73
|
+
calendarThrough: '覆盖至 {date}',
|
|
74
|
+
calendarUnknown: '未知',
|
|
75
|
+
loadRetry: '重新读取',
|
|
29
76
|
loading: '读取中…',
|
|
30
77
|
empty: '还没有任务。',
|
|
31
|
-
|
|
78
|
+
emptyTasksTitle: '还没有添加的任务',
|
|
79
|
+
emptyTasksBody: '从下方添加一个内置模板,或新建一个自己的投研任务。',
|
|
80
|
+
emptyNoTemplates: '还没有任务',
|
|
81
|
+
emptyNoTemplatesBody: '点击右上角「新建任务」,创建第一个定时投研任务。',
|
|
82
|
+
emptyFiltered: '没有匹配的任务。',
|
|
83
|
+
clearFilter: '清除筛选',
|
|
32
84
|
newTask: '新建任务',
|
|
33
|
-
|
|
85
|
+
newTaskTitle: '新建投研任务',
|
|
86
|
+
newTaskHint: '任务会在后台新建一个 session 执行,不需要你守在页面上。',
|
|
87
|
+
editTask: '编辑任务',
|
|
88
|
+
allTasks: '全部任务',
|
|
89
|
+
backToTasks: '所有任务',
|
|
90
|
+
taskSection: '任务',
|
|
91
|
+
taskSectionHint: '点击任务行查看详情、运行记录和配置。',
|
|
92
|
+
templateSection: '模板',
|
|
93
|
+
templateAdd: '添加',
|
|
94
|
+
templateAdding: '添加中…',
|
|
95
|
+
templateMeta: '内置模板',
|
|
96
|
+
runningSection: '正在运行',
|
|
97
|
+
runningSince: '开始于',
|
|
98
|
+
cancelRun: '取消运行',
|
|
99
|
+
searchPlaceholder: '搜索任务',
|
|
100
|
+
filterAll: '全部',
|
|
101
|
+
filterCustom: '我的任务',
|
|
102
|
+
filterNews: '资讯',
|
|
103
|
+
filterMarket: '行情',
|
|
104
|
+
filterReview: '复盘',
|
|
105
|
+
filterResearch: '研究',
|
|
106
|
+
filterLabel: '筛选任务',
|
|
107
|
+
category: { news: '资讯', market: '行情', review: '复盘', research: '研究' },
|
|
108
|
+
categoryField: '任务分类',
|
|
109
|
+
categoryFixed: '内置模板的分类固定;复制为我的任务后可以调整。',
|
|
110
|
+
modeField: '输出侧重',
|
|
111
|
+
modeHint: '只影响输出结构;所有运行固定使用自动模式。',
|
|
112
|
+
mode: { news: '资讯', market: '行情', review: '复盘', research: '研究' },
|
|
113
|
+
cadence: { daily: '每天', weekly: '每周', monthly: '每月' },
|
|
34
114
|
stateLabel: '状态',
|
|
35
|
-
state: { dormant: '
|
|
115
|
+
state: { dormant: '未添加', active: '已启用', paused: '已暂停' },
|
|
116
|
+
origin: { builtin: '内置模板', custom: '我的任务' },
|
|
36
117
|
status: {
|
|
37
118
|
queued: '排队中', starting: '启动中', running: '运行中', succeeded: '成功', failed: '失败',
|
|
38
119
|
canceled: '已取消', timed_out: '超时', blocked_requires_user: '需要用户确认',
|
|
39
120
|
unknown_after_restart: '重启后未知', skipped_overlap: '重叠跳过',
|
|
40
121
|
skipped_calendar_unavailable: '日历不可用跳过', missed: '错过',
|
|
41
122
|
},
|
|
42
|
-
|
|
43
|
-
|
|
123
|
+
runNow: '立即运行',
|
|
124
|
+
runStarted: '已提交运行',
|
|
125
|
+
pause: '暂停',
|
|
126
|
+
activate: '启用',
|
|
127
|
+
add: '添加',
|
|
128
|
+
hibernate: '休眠并恢复默认',
|
|
129
|
+
copy: '复制为我的任务',
|
|
130
|
+
remove: '删除任务',
|
|
131
|
+
edit: '编辑',
|
|
132
|
+
more: '更多操作',
|
|
133
|
+
save: '保存',
|
|
134
|
+
saving: '保存中…',
|
|
135
|
+
processing: '处理中…',
|
|
136
|
+
saved: '已保存',
|
|
137
|
+
cancel: '取消',
|
|
138
|
+
create: '创建任务',
|
|
139
|
+
creating: '创建中…',
|
|
140
|
+
required: '标题和任务指令不能为空。',
|
|
141
|
+
dirty: '有未保存的修改',
|
|
142
|
+
noDirty: '配置已同步',
|
|
44
143
|
nextRun: '下次运行',
|
|
144
|
+
nextRunDormant: '添加后开始调度',
|
|
145
|
+
nextRunPaused: '启用后恢复调度',
|
|
146
|
+
notScheduled: '当前不会自动运行',
|
|
45
147
|
lastResult: '上次结果',
|
|
46
|
-
|
|
148
|
+
lastRunEmpty: '运行后可在这里查看结果',
|
|
47
149
|
never: '暂无',
|
|
150
|
+
calendarUnavailable: '日历不可用',
|
|
151
|
+
unread: '未读',
|
|
48
152
|
overview: '概览',
|
|
49
153
|
config: '配置',
|
|
50
154
|
runs: '运行记录',
|
|
51
|
-
policy: '执行策略',
|
|
52
155
|
notifications: '通知',
|
|
53
|
-
titleField: '标题',
|
|
54
156
|
descriptionField: '说明',
|
|
157
|
+
titleField: '标题',
|
|
55
158
|
instructionField: '任务指令',
|
|
56
|
-
|
|
159
|
+
instructionPlaceholder: '例如:读取今日自选股行情、公告与相关新闻,按「结论—证据—风险」整理成一份可复核的盘后复盘。',
|
|
160
|
+
titlePlaceholder: '给这个任务起个名字',
|
|
161
|
+
descriptionPlaceholder: '一句话说明任务目标(可选)',
|
|
162
|
+
triggerField: '触发器',
|
|
163
|
+
triggerHint: '按本地墙钟时间计算;仅交易日任务由交易日历判断周末与节假日。',
|
|
164
|
+
triggerHintNatural: '按本地墙钟时间计算:每天都触发,周末与节假日也运行。',
|
|
57
165
|
timeField: '时间',
|
|
58
166
|
timezoneField: '时区',
|
|
59
|
-
weekdayField: '
|
|
60
|
-
dayField: '
|
|
167
|
+
weekdayField: '星期',
|
|
168
|
+
dayField: '日期',
|
|
61
169
|
tradingDaysField: '仅交易日',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
170
|
+
weekdayRequired: '每周至少选择一天。',
|
|
171
|
+
invalidTime: '运行时间格式不正确,请选择 HH:mm。',
|
|
172
|
+
invalidTimezone: '时区不能为空,请填写 IANA 时区。',
|
|
173
|
+
invalidTimezoneValue: '时区不被识别,请填写有效的 IANA 时区。',
|
|
174
|
+
invalidLimits: '运行上限必须是有效数字。',
|
|
175
|
+
filterNoRuns: '没有符合筛选条件的运行记录。',
|
|
176
|
+
schedulePrefix: '下次',
|
|
66
177
|
workspaceField: '工作区',
|
|
67
178
|
workspaceDefault: '跟随默认工作区',
|
|
68
179
|
workspaceMissing: '已移除的工作区(请重新选择)',
|
|
69
180
|
workspaceUnavailable: '工作区服务暂时不可用,运行会退回默认目录。',
|
|
70
181
|
limitsField: '运行上限',
|
|
71
|
-
|
|
182
|
+
advanced: '高级设置',
|
|
183
|
+
advancedHint: '预算覆盖整棵运行子树:子 Agent 与 PTC 派发都计入。',
|
|
184
|
+
runTimeout: '最长运行(分钟)',
|
|
72
185
|
idleTimeout: '空闲超时(分钟)',
|
|
73
186
|
maxSteps: '最大步骤',
|
|
74
187
|
maxToolCalls: '最大工具调用',
|
|
@@ -76,104 +189,469 @@ const zh = {
|
|
|
76
189
|
notifyInApp: '应用内通知',
|
|
77
190
|
notifyFailure: '失败时通知',
|
|
78
191
|
notifySuccess: '成功时通知',
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
192
|
+
notifyHint: '通知只记录在当前 profile;不会发送邮件或外部消息。',
|
|
193
|
+
presetLabel: '运行模式',
|
|
194
|
+
presetValue: '自动模式',
|
|
195
|
+
budgetHint: '工具调用与步骤预算覆盖整棵运行子树:子 Agent 与 PTC 派发都计入。',
|
|
196
|
+
environment: '执行环境',
|
|
197
|
+
policyField: '无人值守策略',
|
|
198
|
+
cwdKind: '工作区来源',
|
|
199
|
+
techInfo: '技术信息',
|
|
200
|
+
profileKey: 'profileKey',
|
|
201
|
+
runHistory: '运行历史',
|
|
202
|
+
last30Days: '最近 30 天',
|
|
203
|
+
runCount: '{n} 次运行',
|
|
204
|
+
successCount: '{n} 成功',
|
|
205
|
+
failureCount: '{n} 失败',
|
|
206
|
+
historyEmpty: '最近 30 天还没有运行记录。',
|
|
207
|
+
historyViewAll: '查看全部运行',
|
|
208
|
+
runFilterAll: '全部',
|
|
209
|
+
runFilterActive: '进行中',
|
|
210
|
+
runFilterSucceeded: '成功',
|
|
211
|
+
runFilterFailed: '失败',
|
|
212
|
+
runFilterLabel: '筛选运行记录',
|
|
213
|
+
runsTitle: '运行',
|
|
214
|
+
runsHint: '每次运行都使用新的 session;终态后才能打开 session。',
|
|
215
|
+
runsEmptyTitle: '尚未运行',
|
|
216
|
+
runsEmptyBody: '任务运行后,这里会显示状态、耗时与错误条数;结果与过程在 session 里。',
|
|
217
|
+
runsEmptyAction: '去添加模板',
|
|
218
|
+
runsLimitHint: '仅显示最近 {n} 条运行记录。',
|
|
219
|
+
cancelRunConfirmTitle: '取消这次运行?',
|
|
220
|
+
cancelRunConfirmBody: '取消会向当前运行发送停止信号;已经产生的中间结果会留在 session 里。',
|
|
221
|
+
cancelRunConfirm: '确认取消',
|
|
102
222
|
duration: '耗时',
|
|
103
223
|
steps: '步骤',
|
|
104
224
|
tools: '工具调用',
|
|
105
225
|
errorTitle: '错误',
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
226
|
+
errorDetailsLabel: '错误详情',
|
|
227
|
+
showErrorDetails: '查看错误详情',
|
|
228
|
+
hideErrorDetails: '收起错误详情',
|
|
229
|
+
triggerManual: '手动',
|
|
230
|
+
triggerScheduled: '定时',
|
|
231
|
+
openSession: '打开 session',
|
|
232
|
+
runSummaryFallback: '运行结束但没有摘要。',
|
|
233
|
+
notificationsEmpty: '没有通知。',
|
|
234
|
+
markRead: '全部标为已读',
|
|
235
|
+
markTaskRead: '本任务标为已读',
|
|
236
|
+
notificationsTitle: '通知',
|
|
237
|
+
notificationsHint: '运行失败、超时、调度器待命与交易日历问题会出现在这里。',
|
|
238
|
+
notificationsUnread: '{n} 条未读',
|
|
239
|
+
allRead: '全部已读',
|
|
240
|
+
noNotifications: '没有未读或历史通知。',
|
|
241
|
+
notificationOpenTask: '查看任务',
|
|
242
|
+
close: '关闭',
|
|
243
|
+
confirmDeleteTitle: '删除这个任务?',
|
|
244
|
+
confirmDeleteBody: '任务配置、运行记录与相关通知会一起删除,无法恢复。',
|
|
245
|
+
confirmHibernateTitle: '休眠并恢复默认?',
|
|
246
|
+
confirmHibernateBody: '当前对内置模板的修改会被清空,任务回到模板区;历史运行记录保留。',
|
|
247
|
+
confirmDelete: '确认删除',
|
|
248
|
+
confirmHibernate: '确认休眠',
|
|
249
|
+
actionDone: '操作完成',
|
|
250
|
+
created: '任务已创建',
|
|
251
|
+
activated: '已启用「{title}」',
|
|
252
|
+
added: '已添加「{title}」',
|
|
253
|
+
paused: '已暂停「{title}」',
|
|
254
|
+
copied: '已复制为「{title}」',
|
|
255
|
+
deleted: '已删除「{title}」',
|
|
256
|
+
hibernated: '已休眠「{title}」',
|
|
257
|
+
runSubmitted: '已提交「{title}」运行',
|
|
258
|
+
runCanceled: '已取消运行',
|
|
259
|
+
markReadDone: '已标为已读',
|
|
110
260
|
errorGeneric: '操作失败,请稍后重试。',
|
|
111
261
|
needConfirm: '需要用户确认',
|
|
262
|
+
schedulerBlocked: '调度器未取得运行权,暂时不能手动运行。',
|
|
263
|
+
runBlocked: '任务正在运行,结束或取消后才能再次运行。',
|
|
264
|
+
configWhileRunning: '任务正在运行;修改会在下一次运行时生效。',
|
|
265
|
+
configBuiltinHint: '这是内置模板;修改只覆盖当前 profile,休眠后会恢复默认。',
|
|
266
|
+
detailRecentRuns: '最近 {n} 次运行',
|
|
267
|
+
detailNoRuns: '还没有运行记录。',
|
|
268
|
+
detailAllRuns: '完整记录',
|
|
269
|
+
detailTaskNotifications: '任务通知',
|
|
270
|
+
taskRunsLimit: '这里显示当前任务最近 20 次运行;全部运行见「运行」页。',
|
|
271
|
+
runErrors: '{n} 条错误',
|
|
272
|
+
runNoErrors: '无错误',
|
|
273
|
+
notificationFallbackFailed: '运行失败;打开对应任务或 session 查看详情。',
|
|
274
|
+
notificationFallbackTimeout: '运行超时;打开对应任务或 session 查看详情。',
|
|
275
|
+
notificationFallbackSuccess: '运行完成。',
|
|
276
|
+
notificationFallbackStandby: '调度器未取得运行权,定时触发暂停。',
|
|
277
|
+
notificationFallbackCalendar: '交易日历不可用,交易日任务已跳过。',
|
|
278
|
+
notificationFallbackSkipped: '本次计划已跳过。',
|
|
279
|
+
statusLabel: '状态',
|
|
280
|
+
triggerSummary: '日程',
|
|
281
|
+
lastRun: '上次运行',
|
|
282
|
+
neverRun: '尚未运行',
|
|
283
|
+
relativeNow: '刚刚',
|
|
284
|
+
timezoneHint: 'IANA 时区,例如 Asia/Shanghai。',
|
|
285
|
+
nextRunUnavailable: '交易日历不可用,无法计算下一次运行。',
|
|
286
|
+
copyHint: '复制后会生成一个暂停状态的自定义任务。',
|
|
287
|
+
notificationTaskGone: '任务已不存在',
|
|
288
|
+
noSelection: '从列表中选择一个任务。',
|
|
289
|
+
details: '详情',
|
|
290
|
+
actions: '操作',
|
|
291
|
+
rosterCount: '{n} 个任务',
|
|
292
|
+
dayOfMonth: '{n} 日',
|
|
293
|
+
everyPrefix: '每',
|
|
294
|
+
weeklyPrefix: '每周',
|
|
295
|
+
monthlyPrefix: '每月',
|
|
296
|
+
dailyPrefix: '每天',
|
|
297
|
+
tradingSuffix: '(仅交易日)',
|
|
298
|
+
sessionMissing: '没有可打开的 session',
|
|
112
299
|
}
|
|
113
300
|
|
|
114
|
-
const STATUS_ORDER = ['queued', 'starting', 'running', 'succeeded', 'failed', 'canceled', 'timed_out', 'blocked_requires_user', 'unknown_after_restart', 'skipped_overlap', 'skipped_calendar_unavailable', 'missed']
|
|
115
|
-
|
|
116
301
|
function installStyles() {
|
|
117
302
|
if (typeof document === 'undefined' || document.querySelector(`style[data-${STYLE_TAG}]`)) return () => {}
|
|
118
303
|
const style = document.createElement('style')
|
|
119
304
|
style.setAttribute(`data-${STYLE_TAG}`, 'true')
|
|
120
305
|
style.textContent = `
|
|
121
|
-
.capital-automation-page {
|
|
122
|
-
.capital-automation-
|
|
123
|
-
.capital-automation-
|
|
124
|
-
.capital-automation-
|
|
125
|
-
.capital-automation-
|
|
126
|
-
.capital-automation-
|
|
127
|
-
.capital-automation-
|
|
128
|
-
.capital-automation-
|
|
129
|
-
.capital-automation-
|
|
130
|
-
.capital-automation-
|
|
131
|
-
.capital-automation-
|
|
132
|
-
.capital-automation-
|
|
133
|
-
.capital-automation-
|
|
134
|
-
.capital-automation-
|
|
135
|
-
.capital-automation-
|
|
136
|
-
.capital-automation-
|
|
137
|
-
.capital-automation-
|
|
138
|
-
.capital-automation-
|
|
139
|
-
.capital-automation-
|
|
140
|
-
.capital-automation-
|
|
141
|
-
.capital-automation-
|
|
142
|
-
.capital-automation-
|
|
143
|
-
.capital-automation-
|
|
144
|
-
.capital-automation-
|
|
145
|
-
.capital-automation-
|
|
146
|
-
.capital-automation-
|
|
147
|
-
.capital-automation-
|
|
148
|
-
.capital-automation-
|
|
149
|
-
.capital-automation-
|
|
150
|
-
.capital-automation-
|
|
151
|
-
.capital-automation-
|
|
152
|
-
.capital-automation-
|
|
153
|
-
.capital-automation-
|
|
154
|
-
.capital-automation-
|
|
155
|
-
.capital-automation-
|
|
156
|
-
.capital-automation-
|
|
157
|
-
.capital-automation-
|
|
158
|
-
.capital-automation-
|
|
159
|
-
.capital-automation-
|
|
160
|
-
.capital-automation-
|
|
161
|
-
.capital-automation-
|
|
162
|
-
.capital-automation-
|
|
163
|
-
.capital-automation-
|
|
164
|
-
.capital-automation-
|
|
165
|
-
.capital-automation-
|
|
166
|
-
.capital-automation-
|
|
167
|
-
.capital-automation-
|
|
168
|
-
.capital-automation-
|
|
169
|
-
.capital-automation-
|
|
170
|
-
.capital-automation-
|
|
171
|
-
.capital-automation-
|
|
172
|
-
.capital-automation-
|
|
173
|
-
.capital-automation-
|
|
174
|
-
.capital-automation-
|
|
175
|
-
.capital-automation-
|
|
176
|
-
|
|
306
|
+
.capital-automation-page, .capital-automation-modal { --ca-card: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1)); --ca-line: var(--dsw-alias-border-l3, var(--dsw-alias-border-l1)); --ca-line-soft: var(--dsw-alias-border-l2, var(--dsw-alias-border-l1)); --ca-table-line: var(--ca-line); --ca-muted: var(--dsw-alias-label-tertiary); --ca-caption: var(--dsw-alias-label-caption, var(--dsw-alias-label-tertiary)); --ca-hover: var(--dsw-alias-interactive-bg-hover); --ca-field: var(--dsw-alias-bg-module-platform); --ca-business: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary)); --ca-success: var(--dsw-alias-state-success-primary); --ca-error: var(--dsw-alias-state-error-primary); --ca-warn: var(--dsw-alias-state-warn-label); --ca-business-text: var(--ca-business); --ca-success-text: var(--ca-success); --ca-error-text: var(--ca-error); --ca-warn-text: var(--ca-warn); }
|
|
307
|
+
body:not([data-ds-dark-theme]) .capital-automation-page, body:not([data-ds-dark-theme]) .capital-automation-modal { --ca-line: #0000001f; --ca-line-soft: #0000001a; --ca-table-line: #00000026; --ca-muted: #5d626a; --ca-caption: #6a6f77; --ca-hover: #eef1f5; --ca-field: #f7f8fa; --ca-business: #2f63d6; --ca-success: #16a34a; --ca-error: #dc2626; --ca-warn: #d97706; --ca-business-text: #2f63d6; --ca-success-text: #15803d; --ca-error-text: #c81e1e; --ca-warn-text: #b45309; --ca-tag-news: #2f6fd0; --ca-tag-market: #a85a08; --ca-tag-review: #6d4ac4; --ca-tag-research: #0f766e; --ca-tag-custom: #b3246d; }
|
|
308
|
+
.capital-automation-page { display: flex; flex-direction: column; min-height: 0; height: 100%; color: var(--dsw-alias-label-primary); }
|
|
309
|
+
.capital-automation-head { flex: none; padding: 18px 0 0; }
|
|
310
|
+
.capital-automation-headinner { box-sizing: border-box; width: min(1080px, 100%); margin: 0 auto; padding: 0 clamp(20px, 3vw, 36px); }
|
|
311
|
+
.capital-automation-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px 18px; min-width: 0; }
|
|
312
|
+
.capital-automation-brand { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
|
|
313
|
+
.capital-automation-brandmark { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: linear-gradient(135deg, #4f8cff, #7c3aed); box-shadow: inset 0 1px 0 rgba(255,255,255,.24); }
|
|
314
|
+
.capital-automation-brand h1 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; }
|
|
315
|
+
.capital-automation-tabs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: .5px solid var(--ca-line-soft); border-radius: 999px; background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--ca-card)); box-shadow: inset 0 1px 2px color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent); justify-self: center; }
|
|
316
|
+
.capital-automation-tab { height: 28px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ca-muted); font: inherit; font-size: 12.5px; font-weight: 500; line-height: 28px; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
|
|
317
|
+
.capital-automation-tab:hover:not([aria-selected="true"]) { background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent); color: var(--dsw-alias-label-primary); }
|
|
318
|
+
.capital-automation-tab[aria-selected="true"] { background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 2px 8px color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent); }
|
|
319
|
+
.capital-automation-tab:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; }
|
|
320
|
+
.capital-automation-topactions { display: flex; align-items: center; gap: 8px; justify-self: end; }
|
|
321
|
+
.capital-automation-btn { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: .5px solid var(--ca-line-soft); border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 12.5px; line-height: 20px; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s, opacity .15s; }
|
|
322
|
+
.capital-automation-btn:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
323
|
+
.capital-automation-btn[data-variant="primary"] { border-color: transparent; background: var(--ca-business); color: var(--dsw-alias-bg-base); }
|
|
324
|
+
.capital-automation-btn[data-variant="primary"]:hover:not(:disabled) { background: var(--ca-business); color: var(--dsw-alias-bg-base); filter: brightness(1.08); }
|
|
325
|
+
.capital-automation-templatefoot .capital-automation-btn[data-variant="primary"] { min-width: 54px; padding: 0 12px; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 1px 2px rgba(0,0,0,.16); }
|
|
326
|
+
.capital-automation-templatefoot .capital-automation-btn[data-variant="primary"]:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 2px 8px color-mix(in srgb, var(--ca-business) 32%, transparent); }
|
|
327
|
+
.capital-automation-btn[data-variant="contrast"] { border-color: transparent; background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); }
|
|
328
|
+
.capital-automation-btn[data-variant="contrast"]:hover:not(:disabled) { background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); opacity: .88; }
|
|
329
|
+
.capital-automation-btn[data-variant="ghost"] { border-color: transparent; background: transparent; color: var(--ca-muted); }
|
|
330
|
+
.capital-automation-btn[data-variant="ghost"]:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
331
|
+
.capital-automation-btn[data-variant="danger"] { border-color: transparent; background: var(--ca-error); color: var(--dsw-alias-bg-base); }
|
|
332
|
+
.capital-automation-btn[data-variant="danger"]:hover:not(:disabled) { background: var(--ca-error); color: var(--dsw-alias-bg-base); filter: brightness(1.08); }
|
|
333
|
+
.capital-automation-btn[data-size="sm"] { height: 28px; padding: 0 10px; font-size: 12px; }
|
|
334
|
+
.capital-automation-btn[data-size="icon"] { width: 30px; height: 30px; padding: 0; border-radius: 9px; }
|
|
335
|
+
.capital-automation-btn:disabled { opacity: .42; cursor: not-allowed; }
|
|
336
|
+
.capital-automation-iconbtn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ca-muted); cursor: pointer; }
|
|
337
|
+
.capital-automation-iconbtn:hover:not(:disabled) { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
338
|
+
.capital-automation-iconbtn:disabled { opacity: .4; cursor: not-allowed; }
|
|
339
|
+
.capital-automation-count { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--ca-business); color: var(--dsw-alias-bg-base); font-size: 10px; line-height: 16px; }
|
|
340
|
+
.capital-automation-banner { box-sizing: border-box; width: min(1080px, 100%); margin: 12px auto 0; padding: 10px 13px; border: .5px solid var(--ca-line-soft); border-radius: 12px; background: var(--ca-card); color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 19px; }
|
|
341
|
+
.capital-automation-banner[data-tone="warn"] { border-color: color-mix(in srgb, var(--ca-warn) 38%, var(--ca-line-soft)); color: var(--ca-warn-text); }
|
|
342
|
+
.capital-automation-banner[data-tone="error"] { border-color: color-mix(in srgb, var(--ca-error) 38%, var(--ca-line-soft)); color: var(--ca-error-text); }
|
|
343
|
+
.capital-automation-banner .capital-automation-btn { margin-left: 8px; vertical-align: middle; }
|
|
344
|
+
.capital-automation-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
345
|
+
.capital-automation-container { box-sizing: border-box; width: min(1080px, 100%); margin: 0 auto; padding: 20px clamp(20px, 3vw, 36px) 72px; }
|
|
346
|
+
.capital-automation-card { box-sizing: border-box; border: .5px solid var(--ca-line); border-radius: 16px; background: var(--ca-card); }
|
|
347
|
+
.capital-automation-history { padding: 18px 20px 14px; }
|
|
348
|
+
.capital-automation-historyhead { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 18px; }
|
|
349
|
+
.capital-automation-historytitle { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
|
|
350
|
+
.capital-automation-historytitle h2 { margin: 0; font-size: 14px; line-height: 22px; font-weight: 600; }
|
|
351
|
+
.capital-automation-historytitle span { color: var(--ca-muted); font-size: 12px; line-height: 20px; }
|
|
352
|
+
.capital-automation-historystats { display: flex; align-items: center; gap: 14px; color: var(--ca-muted); font-size: 12px; line-height: 20px; }
|
|
353
|
+
.capital-automation-historystat { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
|
|
354
|
+
.capital-automation-historystat[data-tone="ok"] { color: var(--ca-success-text); }
|
|
355
|
+
.capital-automation-historystat[data-tone="error"] { color: var(--ca-error-text); }
|
|
356
|
+
.capital-automation-statusdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
|
|
357
|
+
.capital-automation-historylink { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 6px; border: 0; border-radius: 7px; background: transparent; color: var(--ca-muted); font: inherit; font-size: 12px; cursor: pointer; }
|
|
358
|
+
.capital-automation-historylink:hover { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
359
|
+
.capital-automation-timeline { display: grid; grid-template-columns: repeat(${HISTORY_DAYS}, minmax(0, 1fr)); align-items: end; gap: 2px; height: 28px; margin-top: 18px; border-bottom: 1px dashed var(--ca-line); }
|
|
360
|
+
.capital-automation-timeline-day { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; padding-bottom: 3px; }
|
|
361
|
+
.capital-automation-timeline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ca-caption); box-shadow: 0 0 0 2px var(--ca-card); }
|
|
362
|
+
.capital-automation-timeline-dot[data-tone="ok"] { background: var(--ca-success); }
|
|
363
|
+
.capital-automation-timeline-dot[data-tone="error"] { background: var(--ca-error); }
|
|
364
|
+
.capital-automation-timeline-dot[data-tone="active"] { background: var(--ca-business); }
|
|
365
|
+
.capital-automation-timeline-dot[data-tone="warn"] { background: var(--ca-warn); }
|
|
366
|
+
.capital-automation-timelinelabels { display: flex; justify-content: space-between; margin-top: 7px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
367
|
+
.capital-automation-historyempty { margin-top: 12px; text-align: center; color: var(--ca-muted); font-size: 12px; line-height: 18px; }
|
|
368
|
+
.capital-automation-section { margin-top: 26px; }
|
|
369
|
+
.capital-automation-sectionhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
|
|
370
|
+
.capital-automation-sectionhead h2 { margin: 0; font-size: 14px; line-height: 22px; font-weight: 600; }
|
|
371
|
+
.capital-automation-sectionhead > span { color: var(--ca-muted); font-size: 12px; line-height: 18px; }
|
|
372
|
+
.capital-automation-sectiontools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
|
|
373
|
+
.capital-automation-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
|
374
|
+
.capital-automation-filter { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--ca-muted); font: inherit; font-size: 12px; line-height: 28px; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
|
|
375
|
+
.capital-automation-filtercount { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: color-mix(in srgb, currentColor 13%, transparent); font-size: 10.5px; line-height: 17px; font-variant-numeric: tabular-nums; }
|
|
376
|
+
.capital-automation-filter[aria-pressed="true"] .capital-automation-filtercount { background: var(--ca-business); color: var(--dsw-alias-bg-base); }
|
|
377
|
+
.capital-automation-filter:hover { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
378
|
+
.capital-automation-filter[aria-pressed="true"] { background: color-mix(in srgb, var(--ca-business) 11%, var(--ca-card)); box-shadow: inset 0 0 0 .5px color-mix(in srgb, var(--ca-business) 28%, transparent); color: var(--ca-business-text); font-weight: 600; }
|
|
379
|
+
.capital-automation-filter:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 1px; }
|
|
380
|
+
.capital-automation-search { box-sizing: border-box; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border: .5px solid var(--ca-line-soft); border-radius: 999px; background: var(--ca-card); color: var(--ca-muted); }
|
|
381
|
+
.capital-automation-search:focus-within { border-color: var(--ca-business); }
|
|
382
|
+
.capital-automation-search input { width: 128px; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
|
|
383
|
+
.capital-automation-search input::placeholder { color: var(--ca-caption); }
|
|
384
|
+
.capital-automation-running { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; padding: 12px 14px; border: .5px solid color-mix(in srgb, var(--ca-business) 30%, var(--ca-line)); border-radius: 14px; background: color-mix(in srgb, var(--ca-business) 7%, var(--ca-card)); }
|
|
385
|
+
.capital-automation-runningrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; min-width: 0; }
|
|
386
|
+
.capital-automation-runningactions { display: flex; flex: none; align-items: center; gap: 8px; margin-left: auto; }
|
|
387
|
+
.capital-automation-live { display: inline-flex; align-items: center; gap: 6px; color: var(--ca-business-text); font-size: 12px; }
|
|
388
|
+
.capital-automation-livedot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: capital-automation-pulse 1.6s ease-in-out infinite; }
|
|
389
|
+
@keyframes capital-automation-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 30%, transparent); } 50% { opacity: .55; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 0%, transparent); } }
|
|
390
|
+
@media (prefers-reduced-motion: reduce) { .capital-automation-livedot { animation: none; } .capital-automation-skeleton { animation: none; } }
|
|
391
|
+
.capital-automation-table { overflow: hidden; border: .5px solid var(--ca-table-line); border-radius: 16px; background: var(--ca-card); }
|
|
392
|
+
.capital-automation-thead { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; padding-right: 18px; border-bottom: .5px solid var(--ca-table-line); background: color-mix(in srgb, var(--dsw-alias-label-primary) 3.5%, var(--ca-card)); color: var(--ca-muted); font-size: 11.5px; font-weight: 500; letter-spacing: .02em; line-height: 16px; }
|
|
393
|
+
.capital-automation-theadmain { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(110px, .85fr) minmax(128px, .95fr) 88px; gap: 14px; padding: 9px 0 9px 16px; }
|
|
394
|
+
.capital-automation-trow { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: stretch; padding-right: 18px; border-top: .5px solid var(--ca-table-line); transition: background .15s; }
|
|
395
|
+
.capital-automation-trow:first-of-type { border-top: 0; }
|
|
396
|
+
.capital-automation-trow:hover { background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, var(--ca-card)); }
|
|
397
|
+
.capital-automation-trowmain { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(110px, .85fr) minmax(128px, .95fr) 88px; align-items: center; gap: 14px; min-width: 0; padding: 11px 0 11px 16px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
398
|
+
.capital-automation-trowmain:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: -2px; }
|
|
399
|
+
.capital-automation-trowmenu { display: flex; align-items: center; justify-content: center; }
|
|
400
|
+
.capital-automation-cell { min-width: 0; }
|
|
401
|
+
.capital-automation-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
402
|
+
.capital-automation-glyph { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.22); }
|
|
403
|
+
.capital-automation-glyph[data-tone="news"] { background: linear-gradient(135deg, #5b9dff, #2563eb); }
|
|
404
|
+
.capital-automation-glyph[data-tone="market"] { background: linear-gradient(135deg, #ffbd4a, #f97316); }
|
|
405
|
+
.capital-automation-glyph[data-tone="review"] { background: linear-gradient(135deg, #b18cff, #7c3aed); }
|
|
406
|
+
.capital-automation-glyph[data-tone="research"] { background: linear-gradient(135deg, #39d7a8, #0d9488); }
|
|
407
|
+
.capital-automation-glyph[data-tone="custom"] { background: linear-gradient(135deg, #f472b6, #db2777); }
|
|
408
|
+
.capital-automation-identitytext { min-width: 0; }
|
|
409
|
+
.capital-automation-tasktitlerow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
|
|
410
|
+
.capital-automation-tasktitlerow .capital-automation-tasktags { flex: 0 1 auto; flex-wrap: wrap; max-width: 100%; margin-top: 0; }
|
|
411
|
+
.capital-automation-tasktitle { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--dsw-alias-label-primary); font-size: 13.5px; line-height: 20px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
|
|
412
|
+
.capital-automation-taskdesc { display: block; overflow: hidden; margin-top: 1px; color: var(--ca-muted); font-size: 11.5px; line-height: 17px; text-overflow: ellipsis; white-space: nowrap; }
|
|
413
|
+
.capital-automation-tasktags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
|
|
414
|
+
.capital-automation-tag { display: inline-flex; align-items: center; gap: 4px; max-width: 13em; overflow: hidden; padding: 1px 6px; border-radius: 999px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 11px; font-weight: 500; line-height: 17px; white-space: nowrap; }
|
|
415
|
+
.capital-automation-tag[data-tone="news"] { color: #6ba6ff; }
|
|
416
|
+
.capital-automation-tag[data-tone="market"] { color: #ffb45c; }
|
|
417
|
+
.capital-automation-tag[data-tone="review"] { color: #b79aff; }
|
|
418
|
+
.capital-automation-tag[data-tone="research"] { color: #56d9b4; }
|
|
419
|
+
.capital-automation-tag[data-tone="custom"] { color: #f79bc3; }
|
|
420
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag { background: color-mix(in srgb, currentColor 9%, var(--ca-card)); }
|
|
421
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag[data-tone="news"] { color: var(--ca-tag-news); }
|
|
422
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag[data-tone="market"] { color: var(--ca-tag-market); }
|
|
423
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag[data-tone="review"] { color: var(--ca-tag-review); }
|
|
424
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag[data-tone="research"] { color: var(--ca-tag-research); }
|
|
425
|
+
body:not([data-ds-dark-theme]) .capital-automation-tag[data-tone="custom"] { color: var(--ca-tag-custom); }
|
|
426
|
+
.capital-automation-schedule { display: block; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 18px; }
|
|
427
|
+
.capital-automation-schedulesub { display: block; margin-top: 1px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
428
|
+
.capital-automation-nextmain { display: block; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 18px; }
|
|
429
|
+
.capital-automation-nextsub { display: block; margin-top: 1px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
430
|
+
.capital-automation-state { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); font-size: 11px; line-height: 22px; white-space: nowrap; }
|
|
431
|
+
.capital-automation-state[data-state="active"] { color: var(--ca-success-text); }
|
|
432
|
+
.capital-automation-state[data-state="paused"] { color: var(--ca-warn-text); }
|
|
433
|
+
.capital-automation-state[data-state="running"] { color: var(--ca-business-text); }
|
|
434
|
+
.capital-automation-state[data-state="dormant"] { color: var(--ca-muted); }
|
|
435
|
+
body:not([data-ds-dark-theme]) .capital-automation-state { background: color-mix(in srgb, currentColor 9%, var(--ca-card)); }
|
|
436
|
+
.capital-automation-statedot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
|
|
437
|
+
.capital-automation-state[data-state="running"] .capital-automation-statedot, .capital-automation-runstatus[data-status="running"] .capital-automation-rundot { animation: capital-automation-pulse 1.6s ease-in-out infinite; }
|
|
438
|
+
.capital-automation-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 42px 20px; border: .5px dashed var(--ca-line); border-radius: 16px; color: var(--ca-muted); text-align: center; }
|
|
439
|
+
.capital-automation-emptyicon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 4px; border-radius: 12px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-caption); }
|
|
440
|
+
.capital-automation-empty h3 { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 13.5px; font-weight: 500; line-height: 20px; }
|
|
441
|
+
.capital-automation-empty p { max-width: 460px; margin: 0; font-size: 12px; line-height: 18px; }
|
|
442
|
+
.capital-automation-empty .capital-automation-btn { margin-top: 8px; }
|
|
443
|
+
.capital-automation-loading { display: flex; flex-direction: column; pointer-events: none; }
|
|
444
|
+
.capital-automation-skeletonlabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
445
|
+
.capital-automation-skeleton { display: block; flex: none; max-width: 100%; border-radius: 6px; background: var(--dsw-alias-bg-skeleton); animation: capital-automation-breathe 1.8s ease-in-out infinite; }
|
|
446
|
+
.capital-automation-skeletontimeline { display: flex; align-items: flex-end; gap: 2px; height: 28px; margin-top: 18px; border-bottom: 1px dashed var(--ca-line); }
|
|
447
|
+
.capital-automation-skeletontimeline > .capital-automation-skeleton { flex: 1 1 0; min-width: 0; }
|
|
448
|
+
.capital-automation-skeletonstack { display: flex; flex: 1 1 auto; flex-direction: column; gap: 6px; min-width: 0; }
|
|
449
|
+
.capital-automation-skeletonrow .capital-automation-trowmain { min-height: 57px; cursor: default; }
|
|
450
|
+
.capital-automation-skeletonrow .capital-automation-cell[data-cell] { display: flex; flex-direction: column; gap: 5px; }
|
|
451
|
+
.capital-automation-skeletonrun .capital-automation-runline { min-height: 20px; }
|
|
452
|
+
.capital-automation-skeletonrun .capital-automation-runmetaline { min-height: 17px; }
|
|
453
|
+
.capital-automation-skeletontemplatemain { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
|
|
454
|
+
@keyframes capital-automation-breathe { 0% { opacity: 1; } 40% { opacity: .55; } 80%, 100% { opacity: 1; } }
|
|
455
|
+
.capital-automation-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
|
|
456
|
+
.capital-automation-template { box-sizing: border-box; display: flex; flex-direction: column; gap: 12px; min-height: 152px; padding: 15px 16px 13px; border: .5px solid var(--ca-line); border-radius: 16px; background: var(--ca-card); transition: border-color .15s, background .15s; }
|
|
457
|
+
.capital-automation-template:hover { border-color: color-mix(in srgb, var(--ca-business) 28%, var(--ca-line)); background: color-mix(in srgb, var(--ca-hover) 55%, var(--ca-card)); }
|
|
458
|
+
.capital-automation-templatemain { display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
459
|
+
.capital-automation-templatemain:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 4px; border-radius: 8px; }
|
|
460
|
+
.capital-automation-templatebody { min-width: 0; }
|
|
461
|
+
.capital-automation-templatetitlerow { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
|
|
462
|
+
.capital-automation-templatetitlerow .capital-automation-tag { flex: none; }
|
|
463
|
+
.capital-automation-templatebody strong { display: block; min-width: 0; color: var(--dsw-alias-label-primary); font-size: 13.5px; line-height: 20px; font-weight: 500; }
|
|
464
|
+
.capital-automation-templatedesc { display: -webkit-box; overflow: hidden; margin-top: 3px; color: var(--ca-muted); font-size: 12px; line-height: 18px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
|
465
|
+
.capital-automation-templatefoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
|
|
466
|
+
.capital-automation-templatemeta { display: inline-flex; align-items: center; gap: 4px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
467
|
+
.capital-automation-detailbar { display: flex; align-items: center; min-height: 34px; margin: 0 0 6px; }
|
|
468
|
+
.capital-automation-back { display: inline-flex; align-items: center; gap: 2px; height: 30px; margin-left: -8px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ca-muted); font: inherit; font-size: 12.5px; cursor: pointer; }
|
|
469
|
+
.capital-automation-back:hover { background: var(--ca-hover); color: var(--dsw-alias-label-primary); }
|
|
470
|
+
.capital-automation-hero { display: flex; align-items: flex-start; gap: 14px; padding: 2px 0 18px; border-bottom: .5px solid var(--ca-line); }
|
|
471
|
+
.capital-automation-herobody { flex: 1 1 auto; min-width: 0; }
|
|
472
|
+
.capital-automation-herotitle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
473
|
+
.capital-automation-herotitle h2 { margin: 0; font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: .1px; overflow-wrap: anywhere; }
|
|
474
|
+
.capital-automation-herodesc { max-width: 760px; margin: 5px 0 0; color: var(--ca-muted); font-size: 12.5px; line-height: 19px; }
|
|
475
|
+
.capital-automation-heroactions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; flex: none; padding-top: 2px; }
|
|
476
|
+
.capital-automation-detailtabs { display: flex; align-items: center; gap: 26px; overflow-x: auto; overflow-y: hidden; border-bottom: .5px solid var(--ca-line); }
|
|
477
|
+
.capital-automation-detailtab { position: relative; flex: none; height: 42px; padding: 0 1px; border: 0; background: transparent; color: var(--ca-muted); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
|
|
478
|
+
.capital-automation-detailtab:hover { color: var(--dsw-alias-label-primary); }
|
|
479
|
+
.capital-automation-detailtab[aria-selected="true"] { color: var(--ca-business-text); font-weight: 600; }
|
|
480
|
+
.capital-automation-detailtab[aria-selected="true"]:after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; border-radius: 2px; background: var(--ca-business-text); }
|
|
481
|
+
.capital-automation-detailtab:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: -2px; border-radius: 4px; }
|
|
482
|
+
.capital-automation-detailbody { display: flex; flex-direction: column; gap: 16px; padding-top: 18px; }
|
|
483
|
+
.capital-automation-overview { display: flex; flex-direction: column; gap: 16px; }
|
|
484
|
+
.capital-automation-statgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
|
|
485
|
+
.capital-automation-stat { display: flex; flex-direction: column; gap: 4px; min-height: 78px; padding: 13px 14px; border: .5px solid var(--ca-line); border-radius: 14px; background: var(--ca-card); }
|
|
486
|
+
body:not([data-ds-dark-theme]) .capital-automation-card, body:not([data-ds-dark-theme]) .capital-automation-table, body:not([data-ds-dark-theme]) .capital-automation-template, body:not([data-ds-dark-theme]) .capital-automation-stat { box-shadow: 0 1px 2px rgba(15,17,21,.035), 0 10px 28px rgba(15,17,21,.025); }
|
|
487
|
+
.capital-automation-runmeta, .capital-automation-statvalue, .capital-automation-notificationtime { font-variant-numeric: tabular-nums; }
|
|
488
|
+
.capital-automation-statlabel { color: var(--ca-muted); font-size: 11px; line-height: 16px; }
|
|
489
|
+
.capital-automation-statvalue { color: var(--dsw-alias-label-primary); font-size: 15px; line-height: 22px; font-weight: 500; overflow-wrap: anywhere; }
|
|
490
|
+
.capital-automation-statvalue[data-tone="ok"] { color: var(--ca-success-text); }
|
|
491
|
+
.capital-automation-statvalue[data-tone="error"] { color: var(--ca-error-text); }
|
|
492
|
+
.capital-automation-statvalue[data-tone="running"] { color: var(--ca-business-text); }
|
|
493
|
+
.capital-automation-statvalue[data-tone="warn"] { color: var(--ca-warn-text); }
|
|
494
|
+
.capital-automation-statsub { color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
495
|
+
.capital-automation-panel { padding: 16px 18px; }
|
|
496
|
+
.capital-automation-panelhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
|
|
497
|
+
.capital-automation-panelhead h3 { margin: 0; font-size: 13.5px; line-height: 20px; font-weight: 600; }
|
|
498
|
+
.capital-automation-panelhead .capital-automation-btn { margin-left: auto; }
|
|
499
|
+
.capital-automation-panelhead .capital-automation-btn[data-variant="ghost"] { padding-right: 0; }
|
|
500
|
+
.capital-automation-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
|
|
501
|
+
.capital-automation-kvitem { min-width: 0; }
|
|
502
|
+
.capital-automation-kvlabel { display: block; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
503
|
+
.capital-automation-kvvalue { display: block; margin-top: 2px; color: var(--dsw-alias-label-secondary); font-size: 12.5px; line-height: 19px; overflow-wrap: anywhere; }
|
|
504
|
+
.capital-automation-policy { color: var(--ca-muted); font-size: 12px; line-height: 19px; }
|
|
505
|
+
.capital-automation-policy p { margin: 0; }
|
|
506
|
+
.capital-automation-policy p + p { margin-top: 5px; }
|
|
507
|
+
.capital-automation-hint { margin: 0; color: var(--ca-muted); font-size: 11.5px; line-height: 18px; }
|
|
508
|
+
.capital-automation-hint[data-tone="error"] { color: var(--ca-error-text); }
|
|
509
|
+
.capital-automation-notice { margin: 0; color: var(--ca-success-text); font-size: 12px; line-height: 18px; }
|
|
510
|
+
.capital-automation-error { margin: 0; color: var(--ca-error-text); font-size: 12px; line-height: 18px; }
|
|
511
|
+
.capital-automation-toast { position: fixed; bottom: 26px; left: 50%; z-index: 1300; max-width: min(520px, calc(100vw - 40px)); transform: translateX(-50%); padding: 8px 15px; border: .5px solid var(--ca-line-soft); border-radius: 999px; background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); box-shadow: 0 8px 26px rgba(0,0,0,.22); font-size: 12px; line-height: 18px; }
|
|
512
|
+
.capital-automation-form { display: flex; flex-direction: column; gap: 16px; }
|
|
513
|
+
.capital-automation-formnote { display: flex; align-items: flex-start; gap: 7px; padding: 9px 11px; border: .5px solid var(--ca-line); border-radius: 10px; background: var(--ca-field); color: var(--ca-muted); font-size: 11.5px; line-height: 18px; }
|
|
514
|
+
.capital-automation-formnote svg { flex: none; margin-top: 2px; }
|
|
515
|
+
.capital-automation-formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
|
|
516
|
+
.capital-automation-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
|
|
517
|
+
.capital-automation-field > span { color: var(--ca-muted); font-size: 11.5px; line-height: 17px; }
|
|
518
|
+
.capital-automation-field input, .capital-automation-field textarea { box-sizing: border-box; width: 100%; padding: 0 10px; border: .5px solid var(--ca-line-soft); border-radius: 10px; background: var(--ca-field); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12.5px; line-height: 32px; }
|
|
519
|
+
.capital-automation-field input { height: 34px; }
|
|
520
|
+
.capital-automation-field textarea { min-height: 110px; padding: 9px 10px; line-height: 19px; resize: vertical; }
|
|
521
|
+
.capital-automation-field input:hover, .capital-automation-field textarea:hover { border-color: var(--ca-line); }
|
|
522
|
+
.capital-automation-field input:focus-visible, .capital-automation-field textarea:focus-visible { border-color: var(--ca-business); outline: 2px solid color-mix(in srgb, var(--ca-business) 22%, transparent); outline-offset: 0; }
|
|
523
|
+
.capital-automation-field input:disabled, .capital-automation-field textarea:disabled { color: var(--ca-muted); opacity: .8; }
|
|
524
|
+
.capital-automation-select { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; height: 34px; padding: 0 10px 0 12px; border: 0; border-radius: 10px; background: var(--ca-field); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12.5px; line-height: 20px; text-align: left; cursor: pointer; transition: background .15s, opacity .15s; }
|
|
525
|
+
.capital-automation-select:hover:not(:disabled) { background: var(--ca-hover); }
|
|
526
|
+
.capital-automation-select[data-block="true"] { width: 100%; }
|
|
527
|
+
.capital-automation-select[data-size="sm"] { height: 28px; padding: 0 8px 0 9px; border-radius: 8px; font-size: 11.5px; }
|
|
528
|
+
.capital-automation-select:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 0; }
|
|
529
|
+
.capital-automation-select:disabled { opacity: .5; cursor: not-allowed; }
|
|
530
|
+
.capital-automation-selectvalue { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
531
|
+
.capital-automation-select > svg { flex: none; color: var(--ca-muted); }
|
|
532
|
+
.capital-automation-formactions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: .5px solid var(--ca-line); }
|
|
533
|
+
.capital-automation-formactions[data-sticky="true"] { position: sticky; bottom: -1px; z-index: 2; margin-top: 2px; padding: 12px 0 4px; background: var(--dsw-alias-bg-base); }
|
|
534
|
+
.capital-automation-formstatus { margin-right: auto; color: var(--ca-caption); font-size: 11.5px; line-height: 18px; }
|
|
535
|
+
.capital-automation-triggerbox { display: flex; flex-direction: column; gap: 12px; padding: 13px 14px; border: .5px solid var(--ca-line); border-radius: 14px; background: var(--ca-field); }
|
|
536
|
+
.capital-automation-triggerrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
537
|
+
.capital-automation-triggerclock { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #5b9dff, #2563eb); color: #fff; flex: none; }
|
|
538
|
+
.capital-automation-triggerrow label, .capital-automation-triggerfield { display: inline-flex; align-items: center; gap: 6px; color: var(--ca-muted); font-size: 12px; }
|
|
539
|
+
.capital-automation-triggerrow input { box-sizing: border-box; height: 32px; padding: 0 9px; border: .5px solid var(--ca-line-soft); border-radius: 9px; background: var(--ca-card); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
|
|
540
|
+
.capital-automation-triggerrow input[type="time"] { width: 112px; }
|
|
541
|
+
.capital-automation-triggerrow .capital-automation-select { max-width: 190px; height: 32px; background: var(--ca-card); }
|
|
542
|
+
.capital-automation-weekdays { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
543
|
+
.capital-automation-weekday { width: 30px; height: 30px; padding: 0; border: .5px solid var(--ca-line-soft); border-radius: 999px; background: transparent; color: var(--ca-muted); font: inherit; font-size: 11.5px; cursor: pointer; }
|
|
544
|
+
.capital-automation-weekday:hover:not(:disabled) { border-color: var(--ca-line); color: var(--dsw-alias-label-primary); }
|
|
545
|
+
.capital-automation-weekday[aria-pressed="true"] { border-color: transparent; background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); }
|
|
546
|
+
.capital-automation-weekday:disabled { opacity: .45; cursor: not-allowed; }
|
|
547
|
+
.capital-automation-switch { display: inline-flex; align-items: center; gap: 7px; color: var(--ca-muted); font-size: 12px; }
|
|
548
|
+
.capital-automation-triggersummary { margin: 0; color: var(--ca-caption); font-size: 11.5px; line-height: 18px; }
|
|
549
|
+
.capital-automation-advanced { border-top: .5px solid var(--ca-line); padding-top: 12px; }
|
|
550
|
+
.capital-automation-advanced summary { color: var(--ca-muted); font-size: 12px; line-height: 18px; cursor: pointer; user-select: none; }
|
|
551
|
+
.capital-automation-advanced summary:hover { color: var(--dsw-alias-label-primary); }
|
|
552
|
+
.capital-automation-advancedbody { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
|
|
553
|
+
.capital-automation-switchlist { display: flex; flex-direction: column; }
|
|
554
|
+
.capital-automation-switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 3px 0; border-bottom: .5px solid var(--ca-line); }
|
|
555
|
+
.capital-automation-switchrow:last-child { border-bottom: 0; }
|
|
556
|
+
.capital-automation-switchrow span { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 18px; }
|
|
557
|
+
.capital-automation-switchrow small { display: block; margin-top: 1px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
558
|
+
.capital-automation-runs { display: flex; flex-direction: column; }
|
|
559
|
+
.capital-automation-run { padding: 13px 0; border-bottom: .5px solid var(--ca-line); }
|
|
560
|
+
.capital-automation-run:first-child { padding-top: 0; }
|
|
561
|
+
.capital-automation-run:last-child { padding-bottom: 0; border-bottom: 0; }
|
|
562
|
+
.capital-automation-runhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; min-width: 0; }
|
|
563
|
+
.capital-automation-runmain { min-width: 0; }
|
|
564
|
+
.capital-automation-runline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
|
|
565
|
+
.capital-automation-runtitle { color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; }
|
|
566
|
+
.capital-automation-runmaintitle { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
567
|
+
.capital-automation-runmaintitle:hover { color: var(--ca-business-text); }
|
|
568
|
+
.capital-automation-runmetaline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 4px; }
|
|
569
|
+
.capital-automation-runmeta { color: var(--ca-caption); font-size: 11px; line-height: 17px; }
|
|
570
|
+
.capital-automation-runactions { display: flex; align-items: center; gap: 8px; flex: none; }
|
|
571
|
+
.capital-automation-runstatus { display: inline-flex; align-items: center; gap: 5px; color: var(--ca-muted); font-size: 11.5px; font-weight: 500; line-height: 18px; }
|
|
572
|
+
.capital-automation-runstatus[data-status="succeeded"] { color: var(--ca-success-text); }
|
|
573
|
+
.capital-automation-runstatus[data-status="failed"], .capital-automation-runstatus[data-status="timed_out"], .capital-automation-runstatus[data-status="blocked_requires_user"], .capital-automation-runstatus[data-status="unknown_after_restart"] { color: var(--ca-error-text); }
|
|
574
|
+
.capital-automation-runstatus[data-status="queued"], .capital-automation-runstatus[data-status="starting"], .capital-automation-runstatus[data-status="running"] { color: var(--ca-business-text); }
|
|
575
|
+
.capital-automation-runstatus[data-status="skipped_overlap"], .capital-automation-runstatus[data-status="skipped_calendar_unavailable"], .capital-automation-runstatus[data-status="missed"] { color: var(--ca-warn-text); }
|
|
576
|
+
.capital-automation-rundot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
|
|
577
|
+
.capital-automation-runspacer { flex: 1 1 auto; }
|
|
578
|
+
.capital-automation-runerrorbadge { box-sizing: border-box; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border: .5px solid color-mix(in srgb, currentColor 38%, var(--ca-line)); border-radius: 999px; background: color-mix(in srgb, currentColor 8%, var(--ca-card)); color: var(--ca-warn-text); font: inherit; font-size: 11px; font-weight: 500; line-height: 18px; white-space: nowrap; cursor: pointer; }
|
|
579
|
+
.capital-automation-runerrorbadge:hover { background: color-mix(in srgb, currentColor 14%, var(--ca-card)); }
|
|
580
|
+
.capital-automation-runerrorbadge[data-tone="error"] { color: var(--ca-error-text); }
|
|
581
|
+
.capital-automation-runerrorbadge svg:last-child { transition: transform .15s; }
|
|
582
|
+
.capital-automation-runerrorbadge[aria-expanded="true"] svg:last-child { transform: rotate(90deg); }
|
|
583
|
+
.capital-automation-runerrors { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 9px 11px; border: .5px solid var(--ca-line); border-radius: 10px; background: var(--ca-field); }
|
|
584
|
+
.capital-automation-runerror { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; align-items: start; gap: 8px; color: var(--ca-muted); font-size: 11.5px; line-height: 17px; }
|
|
585
|
+
.capital-automation-runerrordot { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--ca-warn); flex: none; }
|
|
586
|
+
.capital-automation-runerror[data-severity="error"] .capital-automation-runerrordot { background: var(--ca-error); }
|
|
587
|
+
.capital-automation-runerrormessage { min-width: 0; overflow-wrap: anywhere; }
|
|
588
|
+
.capital-automation-runerrorcode { max-width: 220px; overflow: hidden; color: var(--ca-caption); font-size: 10.5px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
|
|
589
|
+
.capital-automation-notification { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 11px 0; border: 0; border-bottom: .5px solid var(--ca-line); background: transparent; color: inherit; font: inherit; text-align: left; }
|
|
590
|
+
.capital-automation-notification:last-child { border-bottom: 0; }
|
|
591
|
+
.capital-automation-notification[data-clickable="true"] { cursor: pointer; }
|
|
592
|
+
.capital-automation-notification[data-clickable="true"]:hover { color: var(--dsw-alias-label-primary); }
|
|
593
|
+
.capital-automation-notificationicon { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-top: 1px; border-radius: 9px; background: var(--dsw-alias-bg-module-platform); color: var(--ca-muted); flex: none; }
|
|
594
|
+
.capital-automation-notificationicon[data-tone="error"] { color: var(--ca-error-text); }
|
|
595
|
+
.capital-automation-notificationicon[data-tone="warn"] { color: var(--ca-warn-text); }
|
|
596
|
+
.capital-automation-notificationbody { min-width: 0; }
|
|
597
|
+
.capital-automation-notificationtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--dsw-alias-label-primary); font-size: 12.5px; line-height: 19px; font-weight: 500; }
|
|
598
|
+
.capital-automation-notificationmessage { display: -webkit-box; overflow: hidden; margin-top: 2px; color: var(--ca-muted); font-size: 11.5px; line-height: 18px; overflow-wrap: anywhere; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
|
|
599
|
+
.capital-automation-notificationtime { display: block; margin-top: 3px; color: var(--ca-caption); font-size: 11px; line-height: 16px; }
|
|
600
|
+
.capital-automation-modal { width: min(720px, calc(100vw - 32px)); max-width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); }
|
|
601
|
+
.capital-automation-modal-content { max-height: calc(100dvh - 128px); overflow: auto; }
|
|
602
|
+
.capital-automation-modal-narrow { width: min(480px, calc(100vw - 32px)); max-width: min(480px, calc(100vw - 32px)); }
|
|
603
|
+
.capital-automation-wizard { display: flex; flex-direction: column; gap: 14px; }
|
|
604
|
+
.capital-automation-modalheadline { display: flex; align-items: center; gap: 10px; }
|
|
605
|
+
.capital-automation-modaltitleinput { flex: 1 1 auto; min-width: 0; height: 42px; padding: 0 12px; border: .5px solid var(--ca-line-soft); border-radius: 12px; background: var(--dsw-alias-bg-module-platform); color: var(--dsw-alias-label-primary); font: inherit; font-size: 15px; font-weight: 500; }
|
|
606
|
+
.capital-automation-modaltitleinput:focus-visible { border-color: var(--ca-business); outline: 2px solid color-mix(in srgb, var(--ca-business) 22%, transparent); outline-offset: 0; }
|
|
607
|
+
.capital-automation-formlabel { display: block; margin-bottom: 6px; color: var(--ca-muted); font-size: 11.5px; line-height: 17px; }
|
|
608
|
+
.capital-automation-promptbox { overflow: hidden; border: .5px solid var(--ca-line); border-radius: 16px; background: var(--dsw-alias-bg-module-platform); }
|
|
609
|
+
.capital-automation-promptbox textarea { box-sizing: border-box; width: 100%; min-height: 120px; max-height: 320px; padding: 13px 14px; border: 0; outline: 0; background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 21px; resize: vertical; }
|
|
610
|
+
.capital-automation-promptbox textarea::placeholder { color: var(--ca-caption); }
|
|
611
|
+
.capital-automation-prompttoolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-top: .5px solid var(--ca-line); }
|
|
612
|
+
.capital-automation-prompttoolbar label, .capital-automation-toolbarfield { display: inline-flex; align-items: center; gap: 5px; color: var(--ca-muted); font-size: 11.5px; }
|
|
613
|
+
.capital-automation-prompttoolbar .capital-automation-select { max-width: 168px; background: var(--ca-card); }
|
|
614
|
+
.capital-automation-prompttoolbar .capital-automation-presetchip { margin-left: auto; }
|
|
615
|
+
.capital-automation-presetchip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--ca-business) 12%, var(--ca-card)); color: var(--ca-business-text); font-size: 11px; font-weight: 500; white-space: nowrap; }
|
|
616
|
+
.capital-automation-checklist { display: flex; flex-direction: column; gap: 2px; }
|
|
617
|
+
.capital-automation-technical { margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--ca-line); color: var(--ca-caption); font-size: 11px; line-height: 17px; }
|
|
618
|
+
.capital-automation-technicaltitle { margin: 0 0 7px; color: var(--ca-muted); font-size: 11.5px; line-height: 17px; font-weight: 500; }
|
|
619
|
+
.capital-automation-technical dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
|
|
620
|
+
.capital-automation-technical dt { color: var(--ca-caption); }
|
|
621
|
+
.capital-automation-technical dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: var(--ca-muted); }
|
|
622
|
+
.capital-automation-page :focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--ca-business)); outline-offset: 2px; }
|
|
623
|
+
.capital-automation-trowmain:focus-visible, .capital-automation-template .capital-automation-btn:focus-visible { outline-offset: 2px; }
|
|
624
|
+
@media (max-width: 1000px) {
|
|
625
|
+
.capital-automation-theadmain, .capital-automation-trowmain { grid-template-columns: minmax(0, 1.7fr) minmax(110px, .9fr) 88px; }
|
|
626
|
+
.capital-automation-theadmain > :nth-child(3), .capital-automation-cell[data-cell="next"] { display: none; }
|
|
627
|
+
.capital-automation-statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
628
|
+
}
|
|
629
|
+
@media (max-width: 760px) {
|
|
630
|
+
.capital-automation-head { padding-top: 14px; }
|
|
631
|
+
.capital-automation-topbar { display: flex; flex-wrap: wrap; gap: 10px; }
|
|
632
|
+
.capital-automation-brand { flex: 1 1 auto; }
|
|
633
|
+
.capital-automation-tabs { order: 3; width: 100%; max-width: 320px; margin: 0 auto; justify-content: center; }
|
|
634
|
+
.capital-automation-topactions { margin-left: auto; }
|
|
635
|
+
.capital-automation-theadmain, .capital-automation-trowmain { grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; }
|
|
636
|
+
.capital-automation-theadmain > :nth-child(2), .capital-automation-theadmain > :nth-child(3), .capital-automation-cell[data-cell="schedule"], .capital-automation-cell[data-cell="next"] { display: none; }
|
|
637
|
+
.capital-automation-tasktitlerow .capital-automation-tasktags { gap: 3px; }
|
|
638
|
+
.capital-automation-tasktitlerow .capital-automation-tag { padding: 0 5px; font-size: 10px; line-height: 16px; }
|
|
639
|
+
.capital-automation-hero { flex-wrap: wrap; }
|
|
640
|
+
.capital-automation-heroactions { width: 100%; padding-left: 58px; }
|
|
641
|
+
.capital-automation-runhead { grid-template-columns: minmax(0, 1fr); }
|
|
642
|
+
.capital-automation-runactions { justify-content: flex-start; }
|
|
643
|
+
.capital-automation-templates { grid-template-columns: 1fr; }
|
|
644
|
+
.capital-automation-sectiontools { width: 100%; margin-left: 0; }
|
|
645
|
+
}
|
|
646
|
+
@media (max-width: 520px) {
|
|
647
|
+
.capital-automation-brand h1 { font-size: 16px; }
|
|
648
|
+
.capital-automation-topactions .capital-automation-btn:not([data-variant="contrast"]) { width: auto; min-width: 32px; padding: 0 8px; }
|
|
649
|
+
.capital-automation-topactions .capital-automation-btn[data-variant="contrast"] { width: 32px; padding: 0; }
|
|
650
|
+
.capital-automation-topactions .capital-automation-btn .capital-automation-btnlabel { display: none; }
|
|
651
|
+
.capital-automation-statgrid { grid-template-columns: 1fr; }
|
|
652
|
+
.capital-automation-heroactions { padding-left: 0; }
|
|
653
|
+
.capital-automation-modal-content { max-height: calc(100dvh - 112px); }
|
|
654
|
+
}
|
|
177
655
|
`
|
|
178
656
|
document.head.appendChild(style)
|
|
179
657
|
return () => style.remove()
|
|
@@ -232,6 +710,182 @@ function stateLabel(state) {
|
|
|
232
710
|
return zh.state[state] ?? state
|
|
233
711
|
}
|
|
234
712
|
|
|
713
|
+
function activationLabel(task) {
|
|
714
|
+
if (task?.state === 'active') return zh.pause
|
|
715
|
+
return task?.state === 'dormant' ? zh.add : zh.activate
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function activationIcon(task) {
|
|
719
|
+
if (task?.state === 'active') return IconPauseOutlineRegular
|
|
720
|
+
return task?.state === 'dormant' ? IconPlusOutlineRegular : IconPlayOutlineRegular
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function activationNotice(task) {
|
|
724
|
+
return (task?.state === 'dormant' ? zh.added : zh.activated).replace('{title}', task?.title ?? '')
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function categoryLabel(category) {
|
|
728
|
+
return zh.category[category] ?? category
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function clipTagLabel(label, limit = 12) {
|
|
732
|
+
const text = String(label ?? '')
|
|
733
|
+
const chars = Array.from(text)
|
|
734
|
+
return chars.length > limit ? `${chars.slice(0, limit).join('')}…` : text
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function modeLabel(mode) {
|
|
738
|
+
return zh.mode[mode] ?? mode
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function calendarLabel(calendar) {
|
|
742
|
+
if (calendar === null || calendar === undefined || calendar.available === false) return zh.calendarSourceNone
|
|
743
|
+
const source = calendar.source === 'szse'
|
|
744
|
+
? zh.calendarSourceSzse
|
|
745
|
+
: calendar.source === 'bundled' ? zh.calendarSourceBundled : zh.calendarSourceNone
|
|
746
|
+
const through = calendar.through ?? zh.calendarUnknown
|
|
747
|
+
return `${source} · ${zh.calendarThrough.replace('{date}', through)}`
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function isActiveRun(run) {
|
|
751
|
+
return run !== null && run !== undefined && ACTIVE_RUN_STATUSES.includes(run.status)
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function isFailureStatus(status) {
|
|
755
|
+
return FAILURE_RUN_STATUSES.includes(status)
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
function toneOf(task) {
|
|
759
|
+
return task?.origin === 'custom' ? 'custom' : (task?.category ?? 'news')
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function taskGlyph(task) {
|
|
763
|
+
if (task?.origin === 'custom') return IconSparkleRegular
|
|
764
|
+
if (task?.sourceBuiltinId === 'morning-brief') return IconLightOutlineMedium
|
|
765
|
+
if (task?.category === 'market') return IconGaugeOutlineRegular
|
|
766
|
+
if (task?.category === 'review') return IconListPenOutlineRegular
|
|
767
|
+
if (task?.category === 'research') return IconSearchOutlineRegular
|
|
768
|
+
return IconGlobeOutlineRegular
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function Glyph(props) {
|
|
772
|
+
const { task, size = 34, large = false } = props
|
|
773
|
+
const GlyphIcon = taskGlyph(task)
|
|
774
|
+
const edge = large ? 44 : size
|
|
775
|
+
return h('span', {
|
|
776
|
+
className: 'capital-automation-glyph',
|
|
777
|
+
'data-tone': toneOf(task),
|
|
778
|
+
style: { width: edge, height: edge, borderRadius: large ? 13 : 10 },
|
|
779
|
+
}, h(GlyphIcon, { size: large ? 22 : 17 }))
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function StateBadge(props) {
|
|
783
|
+
const { state, running } = props
|
|
784
|
+
const label = running ? zh.status.running : stateLabel(state)
|
|
785
|
+
const value = running ? 'running' : state
|
|
786
|
+
return h('span', { className: 'capital-automation-state', 'data-state': value },
|
|
787
|
+
h('span', { className: 'capital-automation-statedot' }),
|
|
788
|
+
label)
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function formatTime(value, options = {}) {
|
|
792
|
+
if (typeof value !== 'string' || value.length === 0) return zh.never
|
|
793
|
+
const date = new Date(value)
|
|
794
|
+
if (Number.isNaN(date.getTime())) return value
|
|
795
|
+
return new Intl.DateTimeFormat('zh-CN', {
|
|
796
|
+
year: options.short === true ? undefined : 'numeric',
|
|
797
|
+
month: '2-digit',
|
|
798
|
+
day: '2-digit',
|
|
799
|
+
hour: '2-digit',
|
|
800
|
+
minute: '2-digit',
|
|
801
|
+
hourCycle: 'h23',
|
|
802
|
+
...(typeof options.timeZone === 'string' && options.timeZone.length > 0 ? { timeZone: options.timeZone } : {}),
|
|
803
|
+
}).format(date)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function formatShortTime(value, timeZone) {
|
|
807
|
+
return formatTime(value, { short: true, timeZone })
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function formatDuration(ms) {
|
|
811
|
+
if (typeof ms !== 'number' || ms < 0) return zh.never
|
|
812
|
+
const seconds = Math.round(ms / 1000)
|
|
813
|
+
if (seconds < 60) return `${seconds}s`
|
|
814
|
+
const minutes = Math.floor(seconds / 60)
|
|
815
|
+
if (minutes < 60) return `${minutes}m ${seconds % 60}s`
|
|
816
|
+
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function formatRelative(value) {
|
|
820
|
+
if (typeof value !== 'string' || value.length === 0) return ''
|
|
821
|
+
const target = Date.parse(value)
|
|
822
|
+
if (Number.isNaN(target)) return ''
|
|
823
|
+
const diff = target - Date.now()
|
|
824
|
+
const abs = Math.abs(diff)
|
|
825
|
+
if (abs < 45_000) return zh.relativeNow
|
|
826
|
+
const units = [
|
|
827
|
+
[86_400_000, 'day'],
|
|
828
|
+
[3_600_000, 'hour'],
|
|
829
|
+
[60_000, 'minute'],
|
|
830
|
+
]
|
|
831
|
+
const formatter = new Intl.RelativeTimeFormat('zh-CN', { numeric: 'auto' })
|
|
832
|
+
for (const [unitMs, unit] of units) {
|
|
833
|
+
if (abs >= unitMs || unit === 'minute') return formatter.format(Math.round(diff / unitMs), unit)
|
|
834
|
+
}
|
|
835
|
+
return ''
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function formatRangeLabel(date) {
|
|
839
|
+
return new Intl.DateTimeFormat('zh-CN', { month: 'short', day: 'numeric' }).format(date)
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function scheduleSummary(trigger) {
|
|
843
|
+
if (trigger === null || trigger === undefined) return zh.never
|
|
844
|
+
const suffix = trigger.tradingDaysOnly === true ? zh.tradingSuffix : ''
|
|
845
|
+
if (trigger.cadence === 'weekly') {
|
|
846
|
+
const days = (trigger.weekdays ?? []).slice().sort((left, right) => left - right).map((day) => WEEKDAYS.find((item) => item.value === day)?.label ?? '').join('、')
|
|
847
|
+
return `${zh.weeklyPrefix}${days} ${trigger.time}${suffix}`
|
|
848
|
+
}
|
|
849
|
+
if (trigger.cadence === 'monthly') {
|
|
850
|
+
return `${zh.monthlyPrefix} ${trigger.dayOfMonth ?? 1} 日 ${trigger.time}${suffix}`
|
|
851
|
+
}
|
|
852
|
+
return `${zh.dailyPrefix} ${trigger.time}${suffix}`
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function scheduleRangeSummary(trigger) {
|
|
856
|
+
if (trigger?.cadence === 'weekly') {
|
|
857
|
+
const days = (trigger.weekdays ?? []).slice().sort((left, right) => left - right).map((day) => WEEKDAYS.find((item) => item.value === day)?.label ?? '').join('、')
|
|
858
|
+
return `每周 ${days}`
|
|
859
|
+
}
|
|
860
|
+
if (trigger?.cadence === 'monthly') return `每月 ${trigger.dayOfMonth ?? 1} 日`
|
|
861
|
+
return '每天'
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Dormant/paused tasks still carry a computed nextRunLocal, but that instant will not fire until
|
|
865
|
+
// the task is activated; don't present it as a pending schedule.
|
|
866
|
+
function nextRunView(task) {
|
|
867
|
+
if (task?.state === 'dormant') return { value: zh.nextRunDormant, sub: zh.notScheduled }
|
|
868
|
+
if (task?.state === 'paused') return { value: zh.nextRunPaused, sub: zh.notScheduled }
|
|
869
|
+
const value = task?.nextRunLocal ?? (task?.nextRunUnavailable ? zh.calendarUnavailable : zh.never)
|
|
870
|
+
const sub = task?.nextRunAt ? formatRelative(task.nextRunAt) : (task?.nextRunUnavailable ? zh.nextRunUnavailable : zh.never)
|
|
871
|
+
return { value, sub }
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function lastRunView(run, timeZone) {
|
|
875
|
+
if (run === null || run === undefined) return { value: zh.neverRun, sub: zh.lastRunEmpty }
|
|
876
|
+
const active = isActiveRun(run)
|
|
877
|
+
const parts = [formatShortTime(run.queuedAt, timeZone)]
|
|
878
|
+
if (!active && typeof run.durationMs === 'number') parts.push(formatDuration(run.durationMs))
|
|
879
|
+
const errors = Array.isArray(run.errors) ? run.errors.length : 0
|
|
880
|
+
if (errors > 0) parts.push(zh.runErrors.replace('{n}', String(errors)))
|
|
881
|
+
let tone
|
|
882
|
+
if (run.status === 'succeeded') tone = 'ok'
|
|
883
|
+
else if (isFailureStatus(run.status)) tone = 'error'
|
|
884
|
+
else if (active) tone = 'running'
|
|
885
|
+
else if (SKIPPED_RUN_STATUSES.includes(run.status)) tone = 'warn'
|
|
886
|
+
return { value: statusLabel(run.status), sub: parts.filter(Boolean).join(' · '), tone }
|
|
887
|
+
}
|
|
888
|
+
|
|
235
889
|
function workspaceOptions(meta, current) {
|
|
236
890
|
const options = [{ id: '', title: zh.workspaceDefault }]
|
|
237
891
|
const list = Array.isArray(meta?.workspaces) ? meta.workspaces : []
|
|
@@ -245,134 +899,1224 @@ function workspaceOptions(meta, current) {
|
|
|
245
899
|
return options
|
|
246
900
|
}
|
|
247
901
|
|
|
248
|
-
function
|
|
249
|
-
if (typeof
|
|
250
|
-
|
|
251
|
-
if (Number.isNaN(date.getTime())) return value
|
|
252
|
-
return new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(date)
|
|
902
|
+
function workspaceTitle(meta, id) {
|
|
903
|
+
if (typeof id !== 'string' || id.length === 0) return zh.workspaceDefault
|
|
904
|
+
return workspaceOptions(meta, id).find((item) => item.id === id)?.title ?? zh.workspaceMissing
|
|
253
905
|
}
|
|
254
906
|
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
907
|
+
function normalizeTrigger(trigger) {
|
|
908
|
+
const next = {
|
|
909
|
+
kind: 'schedule',
|
|
910
|
+
cadence: trigger?.cadence ?? 'daily',
|
|
911
|
+
time: trigger?.time ?? '09:00',
|
|
912
|
+
timezone: trigger?.timezone ?? 'Asia/Shanghai',
|
|
913
|
+
tradingDaysOnly: trigger?.tradingDaysOnly === true,
|
|
914
|
+
}
|
|
915
|
+
if (next.cadence === 'weekly') next.weekdays = (trigger?.weekdays ?? [1, 3, 5]).slice().sort((left, right) => left - right)
|
|
916
|
+
if (next.cadence === 'monthly') next.dayOfMonth = trigger?.dayOfMonth ?? 1
|
|
917
|
+
return next
|
|
261
918
|
}
|
|
262
919
|
|
|
263
|
-
function
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
920
|
+
function triggerChanged(cadence, trigger) {
|
|
921
|
+
const next = normalizeTrigger({ ...trigger, cadence })
|
|
922
|
+
if (cadence === 'weekly' && (next.weekdays ?? []).length === 0) next.weekdays = [1, 3, 5]
|
|
923
|
+
return next
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
function defaultDraft() {
|
|
927
|
+
return {
|
|
928
|
+
title: '我的投研任务',
|
|
929
|
+
description: '',
|
|
930
|
+
instruction: '',
|
|
931
|
+
category: 'research',
|
|
932
|
+
trigger: { kind: 'schedule', cadence: 'daily', time: '09:00', timezone: 'Asia/Shanghai', tradingDaysOnly: true },
|
|
933
|
+
mode: 'research',
|
|
934
|
+
workspaceId: '',
|
|
935
|
+
limits: { ...DEFAULT_LIMITS },
|
|
936
|
+
notifications: { inApp: true, onFailure: true, onSuccess: false },
|
|
274
937
|
}
|
|
275
|
-
return groups
|
|
276
938
|
}
|
|
277
939
|
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
940
|
+
function draftPayload(task) {
|
|
941
|
+
return {
|
|
942
|
+
title: String(task.title ?? '').trim(),
|
|
943
|
+
description: task.description ?? '',
|
|
944
|
+
instruction: task.instruction ?? '',
|
|
945
|
+
category: task.category,
|
|
946
|
+
trigger: normalizeTrigger(task.trigger),
|
|
947
|
+
mode: task.mode,
|
|
948
|
+
workspaceId: task.workspaceId ?? '',
|
|
949
|
+
limits: task.limits,
|
|
950
|
+
notifications: task.notifications,
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
function samePayload(left, right) {
|
|
955
|
+
return JSON.stringify(draftPayload(left)) === JSON.stringify(draftPayload(right))
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function groupRunCounts(runs) {
|
|
959
|
+
const since = new Date()
|
|
960
|
+
since.setHours(0, 0, 0, 0)
|
|
961
|
+
since.setDate(since.getDate() - (HISTORY_DAYS - 1))
|
|
962
|
+
const days = []
|
|
963
|
+
const byKey = new Map()
|
|
964
|
+
for (let index = 0; index < HISTORY_DAYS; index += 1) {
|
|
965
|
+
const date = new Date(since)
|
|
966
|
+
date.setDate(since.getDate() + index)
|
|
967
|
+
const key = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
|
|
968
|
+
const bucket = { date, key, runs: [] }
|
|
969
|
+
days.push(bucket)
|
|
970
|
+
byKey.set(key, bucket)
|
|
971
|
+
}
|
|
972
|
+
let success = 0
|
|
973
|
+
let failure = 0
|
|
974
|
+
let total = 0
|
|
975
|
+
for (const run of runs) {
|
|
976
|
+
const date = new Date(run.queuedAt)
|
|
977
|
+
if (Number.isNaN(date.getTime()) || date < since) continue
|
|
978
|
+
if (run.status === 'succeeded') success += 1
|
|
979
|
+
if (isFailureStatus(run.status)) failure += 1
|
|
980
|
+
total += 1
|
|
981
|
+
const key = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
|
|
982
|
+
const bucket = byKey.get(key)
|
|
983
|
+
if (bucket !== undefined) bucket.runs.push(run)
|
|
984
|
+
}
|
|
985
|
+
return { days, success, failure, total }
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function dayTone(bucket) {
|
|
989
|
+
if (bucket.runs.some((run) => isActiveRun(run))) return 'active'
|
|
990
|
+
if (bucket.runs.some((run) => isFailureStatus(run.status))) return 'error'
|
|
991
|
+
if (bucket.runs.some((run) => run.status === 'succeeded')) return 'ok'
|
|
992
|
+
if (bucket.runs.length > 0) return 'warn'
|
|
993
|
+
return null
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
function eventTone(kind) {
|
|
997
|
+
if (kind === 'run_failed' || kind === 'run_timeout') return 'error'
|
|
998
|
+
if (kind === 'scheduler_standby' || kind === 'calendar_unavailable') return 'warn'
|
|
999
|
+
return 'neutral'
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function notificationMessage(item) {
|
|
1003
|
+
if (typeof item.message === 'string' && item.message.length > 0) return item.message
|
|
1004
|
+
if (item.kind === 'run_failed') return zh.notificationFallbackFailed
|
|
1005
|
+
if (item.kind === 'run_timeout') return zh.notificationFallbackTimeout
|
|
1006
|
+
if (item.kind === 'run_succeeded') return zh.notificationFallbackSuccess
|
|
1007
|
+
if (item.kind === 'scheduler_standby') return zh.notificationFallbackStandby
|
|
1008
|
+
if (item.kind === 'calendar_unavailable') return zh.notificationFallbackCalendar
|
|
1009
|
+
if (item.kind === 'skipped') return zh.notificationFallbackSkipped
|
|
1010
|
+
return ''
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function draftChanged(draft, task) {
|
|
1014
|
+
return !samePayload(draft, task)
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function validateDraft(task) {
|
|
1018
|
+
if (String(task.title ?? '').trim().length === 0 || String(task.instruction ?? '').trim().length === 0) return zh.required
|
|
1019
|
+
if (!/^([01]\d|2[0-3]):[0-5]\d$/.test(task.trigger?.time ?? '')) return zh.invalidTime
|
|
1020
|
+
if (String(task.trigger?.timezone ?? '').trim().length === 0) return zh.invalidTimezone
|
|
1021
|
+
try {
|
|
1022
|
+
new Intl.DateTimeFormat('zh-CN', { timeZone: task.trigger.timezone })
|
|
1023
|
+
} catch {
|
|
1024
|
+
return zh.invalidTimezoneValue
|
|
1025
|
+
}
|
|
1026
|
+
if (task.trigger?.cadence === 'weekly' && (task.trigger.weekdays ?? []).length === 0) return zh.weekdayRequired
|
|
1027
|
+
const limits = task.limits ?? {}
|
|
1028
|
+
if (![limits.runTimeoutMinutes, limits.idleTimeoutMinutes, limits.maxSteps, limits.maxToolCalls].every((value) => Number.isFinite(value))) return zh.invalidLimits
|
|
1029
|
+
return ''
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function limitValue(meta, key, fallback) {
|
|
1033
|
+
const range = meta?.execution?.limits?.[key]
|
|
1034
|
+
return Array.isArray(range) && range.length === 2 ? range : fallback
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
function RunHistoryCard(props) {
|
|
1038
|
+
const { runs, onViewAll, showLink = true } = props
|
|
1039
|
+
const { days, success, failure, total } = groupRunCounts(runs)
|
|
1040
|
+
return h('section', { className: 'capital-automation-card capital-automation-history', 'aria-label': zh.runHistory },
|
|
1041
|
+
h('div', { className: 'capital-automation-historyhead' },
|
|
1042
|
+
h('div', { className: 'capital-automation-historytitle' },
|
|
1043
|
+
h('h2', null, zh.runHistory),
|
|
1044
|
+
h('span', null, zh.last30Days)),
|
|
1045
|
+
h('div', { className: 'capital-automation-historystats' },
|
|
1046
|
+
h('span', { className: 'capital-automation-historystat', 'data-tone': 'ok' },
|
|
1047
|
+
h('span', { className: 'capital-automation-statusdot' }),
|
|
1048
|
+
zh.successCount.replace('{n}', String(success))),
|
|
1049
|
+
h('span', { className: 'capital-automation-historystat', 'data-tone': 'error' },
|
|
1050
|
+
h('span', { className: 'capital-automation-statusdot' }),
|
|
1051
|
+
zh.failureCount.replace('{n}', String(failure))),
|
|
1052
|
+
showLink && onViewAll !== undefined
|
|
1053
|
+
? h('button', { type: 'button', className: 'capital-automation-historylink', onClick: onViewAll },
|
|
1054
|
+
zh.runCount.replace('{n}', String(total)),
|
|
1055
|
+
h(IconChevronRightOutlineRegular, { size: 13 }))
|
|
1056
|
+
: h('span', { className: 'capital-automation-historystat' }, zh.runCount.replace('{n}', String(total))))),
|
|
1057
|
+
h('div', { className: 'capital-automation-timeline', 'aria-hidden': 'true' },
|
|
1058
|
+
days.map((bucket) => {
|
|
1059
|
+
const tone = dayTone(bucket)
|
|
1060
|
+
return h('div', { key: bucket.key, className: 'capital-automation-timeline-day', title: `${formatRangeLabel(bucket.date)}:${bucket.runs.length} 次运行` },
|
|
1061
|
+
tone === null ? null : h('span', { className: 'capital-automation-timeline-dot', 'data-tone': tone }))
|
|
1062
|
+
})),
|
|
1063
|
+
h('div', { className: 'capital-automation-timelinelabels' },
|
|
1064
|
+
h('span', null, formatRangeLabel(days[0].date)),
|
|
1065
|
+
h('span', null, formatRangeLabel(days[days.length - 1].date))),
|
|
1066
|
+
total === 0 ? h('p', { className: 'capital-automation-historyempty' }, zh.historyEmpty) : null)
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function RunStatus(props) {
|
|
1070
|
+
const { status } = props
|
|
1071
|
+
return h('span', { className: 'capital-automation-runstatus', 'data-status': status },
|
|
1072
|
+
h('span', { className: 'capital-automation-rundot' }),
|
|
1073
|
+
statusLabel(status))
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function RunRow(props) {
|
|
1077
|
+
const { run, task, onCancel, onOpenSession, onOpenTask, busy } = props
|
|
1078
|
+
const active = isActiveRun(run)
|
|
1079
|
+
const errorCount = Array.isArray(run.errors) ? run.errors.length : 0
|
|
1080
|
+
const [errorsOpen, setErrorsOpen] = useState(false)
|
|
1081
|
+
const errorPanelId = `capital-automation-run-errors-${run.id}`
|
|
1082
|
+
const errorBadge = errorCount > 0
|
|
1083
|
+
? h('button', {
|
|
1084
|
+
type: 'button',
|
|
1085
|
+
className: 'capital-automation-runerrorbadge',
|
|
1086
|
+
'data-tone': isFailureStatus(run.status) ? 'error' : 'warn',
|
|
1087
|
+
'aria-expanded': errorsOpen ? 'true' : 'false',
|
|
1088
|
+
'aria-controls': errorPanelId,
|
|
1089
|
+
'aria-label': `${zh.runErrors.replace('{n}', String(errorCount))},${errorsOpen ? zh.hideErrorDetails : zh.showErrorDetails}`,
|
|
1090
|
+
title: errorsOpen ? zh.hideErrorDetails : zh.showErrorDetails,
|
|
1091
|
+
onClick: () => setErrorsOpen((current) => !current),
|
|
1092
|
+
},
|
|
1093
|
+
h(IconWarningOutlineRegular, { size: 12 }),
|
|
1094
|
+
zh.runErrors.replace('{n}', String(errorCount)),
|
|
1095
|
+
h(IconChevronRightOutlineRegular, { size: 12 }))
|
|
1096
|
+
: null
|
|
1097
|
+
return h('div', { className: 'capital-automation-run' },
|
|
1098
|
+
h('div', { className: 'capital-automation-runhead' },
|
|
1099
|
+
h('div', { className: 'capital-automation-runmain' },
|
|
1100
|
+
h('div', { className: 'capital-automation-runline' },
|
|
1101
|
+
task !== undefined && onOpenTask !== undefined
|
|
1102
|
+
? h('button', { type: 'button', className: 'capital-automation-runtitle capital-automation-runmaintitle', onClick: () => onOpenTask(task.id) }, task.title)
|
|
1103
|
+
: h('span', { className: 'capital-automation-runtitle' }, run.taskTitle),
|
|
1104
|
+
h(RunStatus, { status: run.status })),
|
|
1105
|
+
h('div', { className: 'capital-automation-runmetaline' },
|
|
1106
|
+
h('span', { className: 'capital-automation-runmeta' }, `${formatShortTime(run.queuedAt, task?.trigger?.timezone)} · ${run.trigger === 'manual' ? zh.triggerManual : zh.triggerScheduled}`),
|
|
1107
|
+
typeof run.durationMs === 'number' ? h('span', { className: 'capital-automation-runmeta' }, `${zh.duration} ${formatDuration(run.durationMs)}`) : null,
|
|
1108
|
+
h('span', { className: 'capital-automation-runmeta' }, `${zh.steps} ${run.steps} · ${zh.tools} ${run.toolCalls}`),
|
|
1109
|
+
errorBadge)),
|
|
1110
|
+
h('div', { className: 'capital-automation-runactions' },
|
|
1111
|
+
active && typeof onCancel === 'function'
|
|
1112
|
+
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', 'data-variant': 'danger', disabled: busy, onClick: () => onCancel(run) }, zh.cancelRun)
|
|
1113
|
+
: run.sessionId && onOpenSession
|
|
1114
|
+
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', 'data-variant': 'primary', onClick: () => onOpenSession(run.sessionId) },
|
|
1115
|
+
h(IconRightUpOutlineRegular, { size: 13 }),
|
|
1116
|
+
zh.openSession)
|
|
1117
|
+
: null)),
|
|
1118
|
+
errorsOpen && errorCount > 0
|
|
1119
|
+
? h('div', { id: errorPanelId, className: 'capital-automation-runerrors', role: 'region', 'aria-label': zh.errorDetailsLabel },
|
|
1120
|
+
run.errors.map((item, index) => h('div', { key: `${run.id}-error-${index}`, className: 'capital-automation-runerror', 'data-severity': item.severity },
|
|
1121
|
+
h('span', { className: 'capital-automation-runerrordot' }),
|
|
1122
|
+
h('span', { className: 'capital-automation-runerrormessage' }, item.message),
|
|
1123
|
+
item.code ? h('code', { className: 'capital-automation-runerrorcode', title: item.code }, item.code) : null)))
|
|
1124
|
+
: null)
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function RunList(props) {
|
|
1128
|
+
const { runs, tasks, onCancel, onOpenSession, onOpenTask, busy, compact } = props
|
|
1129
|
+
const taskMap = new Map(tasks.map((task) => [task.id, task]))
|
|
1130
|
+
if (runs.length === 0) {
|
|
1131
|
+
if (compact) return h('p', { className: 'capital-automation-hint' }, zh.detailNoRuns)
|
|
1132
|
+
return h('div', { className: 'capital-automation-empty' },
|
|
1133
|
+
h('span', { className: 'capital-automation-emptyicon' }, h(IconClockOutlineRegular, { size: 19 })),
|
|
1134
|
+
h('h3', null, zh.detailNoRuns),
|
|
1135
|
+
h('p', null, zh.runsEmptyBody))
|
|
1136
|
+
}
|
|
1137
|
+
return h('div', { className: 'capital-automation-runs' },
|
|
1138
|
+
runs.map((run) => h(RunRow, {
|
|
1139
|
+
key: run.id,
|
|
1140
|
+
run,
|
|
1141
|
+
task: taskMap.get(run.taskId),
|
|
1142
|
+
onCancel,
|
|
1143
|
+
onOpenSession,
|
|
1144
|
+
onOpenTask,
|
|
1145
|
+
busy,
|
|
1146
|
+
})))
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function NotificationsButton(props) {
|
|
1150
|
+
const { unread, onClick } = props
|
|
282
1151
|
return h('button', {
|
|
283
1152
|
type: 'button',
|
|
284
|
-
className: 'capital-automation-
|
|
285
|
-
'
|
|
286
|
-
onClick
|
|
1153
|
+
className: 'capital-automation-btn',
|
|
1154
|
+
'data-variant': 'ghost',
|
|
1155
|
+
onClick,
|
|
1156
|
+
title: zh.notificationsTitle,
|
|
1157
|
+
'aria-label': zh.notificationsTitle,
|
|
287
1158
|
},
|
|
288
|
-
h(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
task.unread > 0 ? h('span', { className: 'capital-automation-count' }, String(task.unread)) : null,
|
|
292
|
-
h('span', { className: 'capital-automation-task-meta' }, stateLabel(task.state))),
|
|
293
|
-
h('span', { className: 'capital-automation-task-meta' },
|
|
294
|
-
h('span', null, `${zh.nextRun}: ${task.nextRunLocal ?? (task.nextRunUnavailable ? zh.calendarMissing : zh.never)}`),
|
|
295
|
-
h('span', null, `${zh.lastResult}: ${run ? statusLabel(run.status) : zh.never}`)))
|
|
1159
|
+
h(IconAlarmClockOutlineRegular, { size: 14 }),
|
|
1160
|
+
h('span', { className: 'capital-automation-btnlabel' }, zh.notifications),
|
|
1161
|
+
unread > 0 ? h('span', { className: 'capital-automation-count' }, String(unread > 99 ? '99+' : unread)) : null)
|
|
296
1162
|
}
|
|
297
1163
|
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
h(
|
|
1164
|
+
function Header(props) {
|
|
1165
|
+
const { tab, onTab, onNewTask, unread, onOpenInbox } = props
|
|
1166
|
+
return h('header', { className: 'capital-automation-head' },
|
|
1167
|
+
h('div', { className: 'capital-automation-headinner' },
|
|
1168
|
+
h('div', { className: 'capital-automation-topbar' },
|
|
1169
|
+
h('div', { className: 'capital-automation-brand' },
|
|
1170
|
+
h('span', { className: 'capital-automation-brandmark', 'aria-hidden': 'true' }, h(IconChecklistOutlineRegular, { size: 16 })),
|
|
1171
|
+
h('h1', null, zh.title)),
|
|
1172
|
+
h('div', { className: 'capital-automation-tabs', role: 'tablist', 'aria-label': zh.title },
|
|
1173
|
+
['tasks', 'runs'].map((value) => h('button', {
|
|
1174
|
+
key: value,
|
|
1175
|
+
type: 'button',
|
|
1176
|
+
role: 'tab',
|
|
1177
|
+
className: 'capital-automation-tab',
|
|
1178
|
+
'aria-selected': tab === value ? 'true' : 'false',
|
|
1179
|
+
onClick: () => onTab(value),
|
|
1180
|
+
}, zh.tabs[value]))),
|
|
1181
|
+
h('div', { className: 'capital-automation-topactions' },
|
|
1182
|
+
h(NotificationsButton, { unread, onClick: onOpenInbox }),
|
|
1183
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-variant': 'contrast', onClick: onNewTask, title: zh.newTask, 'aria-label': zh.newTask },
|
|
1184
|
+
h(IconPlusOutlineRegular, { size: 14 }),
|
|
1185
|
+
h('span', { className: 'capital-automation-btnlabel' }, zh.newTask))))))
|
|
302
1186
|
}
|
|
303
1187
|
|
|
304
|
-
function
|
|
305
|
-
const {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
h('
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
1188
|
+
function PageBanners(props) {
|
|
1189
|
+
const { meta, loadError, onRetry } = props
|
|
1190
|
+
const banners = []
|
|
1191
|
+
if (meta?.storage?.state === 'unavailable') {
|
|
1192
|
+
banners.push(h('div', { key: 'storage', className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' },
|
|
1193
|
+
`${zh.storageBanner}${meta.storage.error ? `:${meta.storage.error}` : ''}`))
|
|
1194
|
+
}
|
|
1195
|
+
const schedulerState = meta?.scheduler?.state
|
|
1196
|
+
if (meta !== null && meta !== undefined && meta.storage?.state !== 'unavailable' && (schedulerState === 'standby' || schedulerState === 'stopped')) {
|
|
1197
|
+
banners.push(h('div', { key: 'standby', className: 'capital-automation-banner', 'data-tone': 'warn', role: 'status' }, zh.standbyBanner))
|
|
1198
|
+
}
|
|
1199
|
+
const calendarUnavailable = meta !== null && meta !== undefined && meta.calendar?.available === false
|
|
1200
|
+
if (meta !== null && meta !== undefined && meta.storage?.state !== 'unavailable' && calendarUnavailable) {
|
|
1201
|
+
banners.push(h('div', { key: 'calendar', className: 'capital-automation-banner', 'data-tone': 'warn', role: 'status' }, zh.calendarBanner))
|
|
1202
|
+
}
|
|
1203
|
+
const calendarCoverage = meta?.calendar?.coverageDays
|
|
1204
|
+
if (meta !== null && meta !== undefined && meta.storage?.state !== 'unavailable' && !calendarUnavailable
|
|
1205
|
+
&& typeof calendarCoverage === 'number' && calendarCoverage >= 0 && calendarCoverage < 30) {
|
|
1206
|
+
banners.push(h('div', { key: 'calendar-coverage', className: 'capital-automation-banner', 'data-tone': 'warn', role: 'status' },
|
|
1207
|
+
zh.calendarCoverageBanner.replace('{through}', meta.calendar.through ?? zh.calendarUnknown)))
|
|
1208
|
+
}
|
|
1209
|
+
if (loadError.length > 0) {
|
|
1210
|
+
banners.push(h('div', { key: 'load', className: 'capital-automation-banner', 'data-tone': 'error', role: 'alert' },
|
|
1211
|
+
loadError,
|
|
1212
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: onRetry }, zh.loadRetry)))
|
|
1213
|
+
}
|
|
1214
|
+
if (banners.length === 0) return null
|
|
1215
|
+
return h('div', { className: 'capital-automation-headinner', style: { paddingBottom: 0 } }, banners)
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function FilterButton(props) {
|
|
1219
|
+
const { active, count, label, onClick } = props
|
|
1220
|
+
return h('button', {
|
|
1221
|
+
type: 'button',
|
|
1222
|
+
className: 'capital-automation-filter',
|
|
1223
|
+
'aria-pressed': active ? 'true' : 'false',
|
|
1224
|
+
onClick,
|
|
1225
|
+
},
|
|
1226
|
+
h('span', { className: 'capital-automation-filterlabel' }, label),
|
|
1227
|
+
count > 0 ? h('span', { className: 'capital-automation-filtercount' }, String(count)) : null)
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function TaskTags(props) {
|
|
1231
|
+
const { task } = props
|
|
1232
|
+
const tags = [[categoryLabel(task.category), toneOf(task)]]
|
|
1233
|
+
if (task.origin === 'builtin') tags.push([zh.origin.builtin, undefined])
|
|
1234
|
+
if (task.origin === 'custom') tags.push([zh.origin.custom, undefined])
|
|
1235
|
+
return h('span', { className: 'capital-automation-tasktags' },
|
|
1236
|
+
tags.map(([label, tone]) => h('span', {
|
|
1237
|
+
key: label,
|
|
1238
|
+
className: 'capital-automation-tag',
|
|
1239
|
+
'data-tone': tone,
|
|
1240
|
+
title: label,
|
|
1241
|
+
}, clipTagLabel(label))))
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
function TaskActionsMenu(props) {
|
|
1245
|
+
const { task, open, onToggle, onClose, onEdit, onAction, onRequestConfirm, canRun, running, busy, disabled, align = 'end' } = props
|
|
1246
|
+
const toggleId = task.state === 'active' ? 'pause' : 'activate'
|
|
1247
|
+
const blocked = busy || disabled === true
|
|
1248
|
+
const items = [
|
|
1249
|
+
{ id: 'edit', label: zh.edit, icon: h(IconEditOutlineRegular, { size: 14 }), disabled: busy },
|
|
1250
|
+
{ id: toggleId, label: activationLabel(task), icon: h(activationIcon(task), { size: 14 }), disabled: blocked },
|
|
1251
|
+
{ id: 'run', label: zh.runNow, icon: h(IconPlayOutlineRegular, { size: 14 }), disabled: blocked || !canRun || running },
|
|
1252
|
+
...(task.origin === 'builtin' ? [{ id: 'copy', label: zh.copy, icon: h(IconCopyOutlineRegular, { size: 14 }), disabled: blocked }] : []),
|
|
1253
|
+
]
|
|
1254
|
+
const children = []
|
|
1255
|
+
if (task.origin === 'builtin' && task.state !== 'dormant') {
|
|
1256
|
+
children.push(h(MenuItemButton, {
|
|
1257
|
+
key: 'hibernate',
|
|
1258
|
+
separatorBefore: true,
|
|
1259
|
+
icon: h(IconRefreshOutlineRegular, { size: 14 }),
|
|
1260
|
+
disabled: blocked || running,
|
|
1261
|
+
onSelect: () => {
|
|
1262
|
+
onClose()
|
|
1263
|
+
onRequestConfirm('hibernate', task)
|
|
321
1264
|
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
1265
|
+
}, zh.hibernate))
|
|
1266
|
+
}
|
|
1267
|
+
if (task.origin === 'custom') {
|
|
1268
|
+
children.push(h(MenuItemButton, {
|
|
1269
|
+
key: 'remove',
|
|
1270
|
+
danger: true,
|
|
1271
|
+
separatorBefore: true,
|
|
1272
|
+
icon: h(IconTrashOutlineRegular, { size: 14 }),
|
|
1273
|
+
disabled: blocked || running,
|
|
1274
|
+
onSelect: () => {
|
|
1275
|
+
onClose()
|
|
1276
|
+
onRequestConfirm('delete', task)
|
|
1277
|
+
},
|
|
1278
|
+
}, zh.remove))
|
|
1279
|
+
}
|
|
1280
|
+
return h(Menu, {
|
|
1281
|
+
open,
|
|
1282
|
+
anchor: h('button', {
|
|
1283
|
+
type: 'button',
|
|
1284
|
+
className: 'capital-automation-iconbtn',
|
|
1285
|
+
disabled: busy,
|
|
1286
|
+
title: zh.more,
|
|
1287
|
+
'aria-label': `${zh.more}:${task.title}`,
|
|
1288
|
+
'aria-haspopup': 'menu',
|
|
1289
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1290
|
+
onClick: onToggle,
|
|
1291
|
+
}, h(IconEllipsisOutlineRegular, { size: 16 })),
|
|
1292
|
+
items,
|
|
1293
|
+
children,
|
|
1294
|
+
onSelect: (id) => {
|
|
1295
|
+
onClose()
|
|
1296
|
+
if (id === 'edit') {
|
|
1297
|
+
onEdit(task.id)
|
|
1298
|
+
return
|
|
1299
|
+
}
|
|
1300
|
+
onAction(task, id)
|
|
1301
|
+
},
|
|
1302
|
+
onClose,
|
|
1303
|
+
align,
|
|
1304
|
+
portal: true,
|
|
1305
|
+
})
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
function TaskRow(props) {
|
|
1309
|
+
const { task, onOpen, menuOpen, onMenuToggle, onMenuClose, onEdit, onAction, onRequestConfirm, canRun, busy, mutationsDisabled } = props
|
|
1310
|
+
const run = task.lastRun
|
|
1311
|
+
const running = isActiveRun(run)
|
|
1312
|
+
const next = nextRunView(task)
|
|
1313
|
+
return h('div', { className: 'capital-automation-trow' },
|
|
1314
|
+
h('button', { type: 'button', className: 'capital-automation-trowmain', onClick: () => onOpen(task.id) },
|
|
1315
|
+
h('span', { className: 'capital-automation-cell capital-automation-identity' },
|
|
1316
|
+
h(Glyph, { task }),
|
|
1317
|
+
h('span', { className: 'capital-automation-identitytext' },
|
|
1318
|
+
h('span', { className: 'capital-automation-tasktitlerow' },
|
|
1319
|
+
h('span', { className: 'capital-automation-tasktitle' }, task.title),
|
|
1320
|
+
h(TaskTags, { task }),
|
|
1321
|
+
(task.unread ?? 0) > 0 ? h('span', { className: 'capital-automation-count', title: zh.unread }, String(task.unread)) : null),
|
|
1322
|
+
h('span', { className: 'capital-automation-taskdesc' }, task.description || zh.subtitle))),
|
|
1323
|
+
h('span', { className: 'capital-automation-cell', 'data-cell': 'schedule' },
|
|
1324
|
+
h('span', { className: 'capital-automation-schedule' }, scheduleSummary(task.trigger)),
|
|
1325
|
+
h('span', { className: 'capital-automation-schedulesub' }, task.trigger?.timezone ?? '')),
|
|
1326
|
+
h('span', { className: 'capital-automation-cell', 'data-cell': 'next' },
|
|
1327
|
+
h('span', { className: 'capital-automation-nextmain' }, next.value),
|
|
1328
|
+
h('span', { className: 'capital-automation-nextsub' }, next.sub)),
|
|
1329
|
+
h('span', { className: 'capital-automation-cell' },
|
|
1330
|
+
h(StateBadge, { state: task.state, running }))),
|
|
1331
|
+
h('div', { className: 'capital-automation-trowmenu' },
|
|
1332
|
+
h(TaskActionsMenu, {
|
|
1333
|
+
task,
|
|
1334
|
+
open: menuOpen,
|
|
1335
|
+
onToggle: onMenuToggle,
|
|
1336
|
+
onClose: onMenuClose,
|
|
1337
|
+
onEdit,
|
|
1338
|
+
onAction,
|
|
1339
|
+
onRequestConfirm,
|
|
1340
|
+
canRun,
|
|
1341
|
+
running,
|
|
1342
|
+
busy,
|
|
1343
|
+
disabled: mutationsDisabled,
|
|
1344
|
+
})))
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
function TaskTable(props) {
|
|
1348
|
+
const { tasks, onOpen, onAction, onRequestConfirm, onEdit, schedulerActive, storageReady, busyTaskId } = props
|
|
1349
|
+
const [menuTaskId, setMenuTaskId] = useState(null)
|
|
1350
|
+
const canRun = storageReady && schedulerActive
|
|
1351
|
+
return h('div', { className: 'capital-automation-table', 'aria-label': zh.taskSection },
|
|
1352
|
+
h('div', { className: 'capital-automation-thead' },
|
|
1353
|
+
h('div', { className: 'capital-automation-theadmain' },
|
|
1354
|
+
h('span', null, zh.taskSection),
|
|
1355
|
+
h('span', null, zh.triggerSummary),
|
|
1356
|
+
h('span', null, zh.nextRun),
|
|
1357
|
+
h('span', null, zh.stateLabel)),
|
|
1358
|
+
h('span', null)),
|
|
1359
|
+
tasks.map((task) => h(TaskRow, {
|
|
1360
|
+
key: task.id,
|
|
1361
|
+
task,
|
|
1362
|
+
onOpen,
|
|
1363
|
+
menuOpen: menuTaskId === task.id,
|
|
1364
|
+
onMenuToggle: () => setMenuTaskId((current) => current === task.id ? null : task.id),
|
|
1365
|
+
onMenuClose: () => setMenuTaskId(null),
|
|
1366
|
+
onEdit,
|
|
1367
|
+
onAction,
|
|
1368
|
+
onRequestConfirm,
|
|
1369
|
+
canRun,
|
|
1370
|
+
busy: busyTaskId === task.id,
|
|
1371
|
+
mutationsDisabled: !storageReady,
|
|
1372
|
+
})))
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
function TemplateCard(props) {
|
|
1376
|
+
const { task, onOpen, onEnable, busy, disabled } = props
|
|
1377
|
+
return h('article', { className: 'capital-automation-template' },
|
|
1378
|
+
h('button', { type: 'button', className: 'capital-automation-templatemain', onClick: () => onOpen(task.id) },
|
|
1379
|
+
h(Glyph, { task, size: 38 }),
|
|
1380
|
+
h('span', { className: 'capital-automation-templatebody' },
|
|
1381
|
+
h('span', { className: 'capital-automation-templatetitlerow' },
|
|
1382
|
+
h('strong', null, task.title),
|
|
1383
|
+
h('span', {
|
|
1384
|
+
className: 'capital-automation-tag',
|
|
1385
|
+
'data-tone': toneOf(task),
|
|
1386
|
+
title: categoryLabel(task.category),
|
|
1387
|
+
}, clipTagLabel(categoryLabel(task.category)))),
|
|
1388
|
+
h('span', { className: 'capital-automation-templatedesc' }, task.description || zh.subtitle))),
|
|
1389
|
+
h('div', { className: 'capital-automation-templatefoot' },
|
|
1390
|
+
h('span', { className: 'capital-automation-templatemeta' },
|
|
1391
|
+
h(IconClockOutlineRegular, { size: 12 }),
|
|
1392
|
+
`${zh.templateMeta} · ${scheduleSummary(task.trigger)}`),
|
|
1393
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', 'data-variant': 'primary', onClick: () => onEnable(task), disabled: busy || disabled },
|
|
1394
|
+
h(IconPlusOutlineRegular, { size: 12 }),
|
|
1395
|
+
busy ? zh.templateAdding : zh.templateAdd)))
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function EmptyState(props) {
|
|
1399
|
+
const { title, body, action, actionLabel, icon } = props
|
|
1400
|
+
return h('div', { className: 'capital-automation-empty' },
|
|
1401
|
+
h('span', { className: 'capital-automation-emptyicon' }, h(icon ?? IconChecklistOutlineRegular, { size: 19 })),
|
|
1402
|
+
h('h3', null, title),
|
|
1403
|
+
h('p', null, body),
|
|
1404
|
+
action && actionLabel ? h('button', { type: 'button', className: 'capital-automation-btn', onClick: action }, actionLabel) : null)
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
// Skeleton mirrors the real dashboard/runs layout so the first paint never claims "no tasks".
|
|
1408
|
+
function SkeletonBlock(props) {
|
|
1409
|
+
const { width = '100%', height = 10, radius = 6 } = props
|
|
1410
|
+
return h('span', {
|
|
1411
|
+
className: 'capital-automation-skeleton',
|
|
1412
|
+
style: { width, height, borderRadius: radius },
|
|
1413
|
+
'aria-hidden': 'true',
|
|
1414
|
+
})
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
function SkeletonHistory() {
|
|
1418
|
+
return h('section', { className: 'capital-automation-card capital-automation-history', 'aria-hidden': 'true' },
|
|
1419
|
+
h('div', { className: 'capital-automation-historyhead' },
|
|
1420
|
+
h('div', { className: 'capital-automation-historytitle' },
|
|
1421
|
+
h(SkeletonBlock, { width: 92, height: 14 }),
|
|
1422
|
+
h(SkeletonBlock, { width: 52, height: 11 })),
|
|
1423
|
+
h('div', { className: 'capital-automation-historystats' },
|
|
1424
|
+
h(SkeletonBlock, { width: 64, height: 12 }),
|
|
1425
|
+
h(SkeletonBlock, { width: 64, height: 12 }),
|
|
1426
|
+
h(SkeletonBlock, { width: 56, height: 12 }))),
|
|
1427
|
+
h('div', { className: 'capital-automation-skeletontimeline' },
|
|
1428
|
+
Array.from({ length: HISTORY_DAYS }, (_, index) => h(SkeletonBlock, {
|
|
1429
|
+
key: index,
|
|
1430
|
+
height: 6 + ((index * 11) % 22),
|
|
1431
|
+
radius: 2,
|
|
1432
|
+
}))),
|
|
1433
|
+
h('div', { className: 'capital-automation-timelinelabels' },
|
|
1434
|
+
h(SkeletonBlock, { width: 34, height: 9 }),
|
|
1435
|
+
h(SkeletonBlock, { width: 34, height: 9 })))
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function SkeletonSectionHead(props) {
|
|
1439
|
+
const { trailing = [210, 132] } = props
|
|
1440
|
+
return h('div', { className: 'capital-automation-sectionhead' },
|
|
1441
|
+
h(SkeletonBlock, { width: 78, height: 14 }),
|
|
1442
|
+
h(SkeletonBlock, { width: 210, height: 11 }),
|
|
1443
|
+
trailing.length === 0 ? null : h('div', { className: 'capital-automation-sectiontools' },
|
|
1444
|
+
trailing.map((width, index) => h(SkeletonBlock, { key: index, width, height: index === 0 ? 28 : 30, radius: 999 }))))
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
function SkeletonTaskRow() {
|
|
1448
|
+
return h('div', { className: 'capital-automation-trow capital-automation-skeletonrow', 'aria-hidden': 'true' },
|
|
1449
|
+
h('div', { className: 'capital-automation-trowmain' },
|
|
1450
|
+
h('span', { className: 'capital-automation-cell capital-automation-identity' },
|
|
1451
|
+
h(SkeletonBlock, { width: 34, height: 34, radius: 10 }),
|
|
1452
|
+
h('span', { className: 'capital-automation-skeletonstack' },
|
|
1453
|
+
h(SkeletonBlock, { width: '52%', height: 12 }),
|
|
1454
|
+
h(SkeletonBlock, { width: '82%', height: 9 }),
|
|
1455
|
+
h(SkeletonBlock, { width: 92, height: 16, radius: 999 }))),
|
|
1456
|
+
h('span', { className: 'capital-automation-cell', 'data-cell': 'schedule' },
|
|
1457
|
+
h(SkeletonBlock, { width: '64%', height: 10 }),
|
|
1458
|
+
h(SkeletonBlock, { width: '42%', height: 8 })),
|
|
1459
|
+
h('span', { className: 'capital-automation-cell', 'data-cell': 'next' },
|
|
1460
|
+
h(SkeletonBlock, { width: '58%', height: 10 }),
|
|
1461
|
+
h(SkeletonBlock, { width: '36%', height: 8 })),
|
|
1462
|
+
h('span', { className: 'capital-automation-cell' },
|
|
1463
|
+
h(SkeletonBlock, { width: 52, height: 22, radius: 999 }))),
|
|
1464
|
+
h('div', { className: 'capital-automation-trowmenu' },
|
|
1465
|
+
h(SkeletonBlock, { width: 18, height: 18, radius: 6 })))
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function SkeletonTaskTable(props) {
|
|
1469
|
+
const { rows = 4 } = props
|
|
1470
|
+
return h('div', { className: 'capital-automation-table', 'aria-hidden': 'true' },
|
|
1471
|
+
h('div', { className: 'capital-automation-thead' },
|
|
1472
|
+
h('div', { className: 'capital-automation-theadmain' },
|
|
1473
|
+
h(SkeletonBlock, { width: '52%', height: 9 }),
|
|
1474
|
+
h(SkeletonBlock, { width: '58%', height: 9 }),
|
|
1475
|
+
h(SkeletonBlock, { width: '56%', height: 9 }),
|
|
1476
|
+
h(SkeletonBlock, { width: 44, height: 9 })),
|
|
1477
|
+
h('span', null)),
|
|
1478
|
+
Array.from({ length: rows }, (_, index) => h(SkeletonTaskRow, { key: index })))
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
function SkeletonTemplateCard() {
|
|
1482
|
+
return h('div', { className: 'capital-automation-template capital-automation-skeletontemplate', 'aria-hidden': 'true' },
|
|
1483
|
+
h('div', { className: 'capital-automation-skeletontemplatemain' },
|
|
1484
|
+
h(SkeletonBlock, { width: 38, height: 38, radius: 11 }),
|
|
1485
|
+
h('div', { className: 'capital-automation-skeletonstack' },
|
|
1486
|
+
h(SkeletonBlock, { width: '58%', height: 11 }),
|
|
1487
|
+
h(SkeletonBlock, { width: '100%', height: 9 }),
|
|
1488
|
+
h(SkeletonBlock, { width: '76%', height: 9 }))),
|
|
1489
|
+
h('div', { className: 'capital-automation-templatefoot' },
|
|
1490
|
+
h(SkeletonBlock, { width: 118, height: 11 }),
|
|
1491
|
+
h(SkeletonBlock, { width: 64, height: 28, radius: 999 })))
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
function SkeletonRunRow() {
|
|
1495
|
+
return h('div', { className: 'capital-automation-run capital-automation-skeletonrun', 'aria-hidden': 'true' },
|
|
1496
|
+
h('div', { className: 'capital-automation-runhead' },
|
|
1497
|
+
h('div', { className: 'capital-automation-runmain' },
|
|
1498
|
+
h('div', { className: 'capital-automation-runline' },
|
|
1499
|
+
h(SkeletonBlock, { width: 168, height: 11 }),
|
|
1500
|
+
h(SkeletonBlock, { width: 54, height: 10, radius: 999 })),
|
|
1501
|
+
h('div', { className: 'capital-automation-runmetaline' },
|
|
1502
|
+
h(SkeletonBlock, { width: 86, height: 9 }),
|
|
1503
|
+
h(SkeletonBlock, { width: 58, height: 9 }),
|
|
1504
|
+
h(SkeletonBlock, { width: 104, height: 9 }))),
|
|
1505
|
+
h('div', { className: 'capital-automation-runactions' },
|
|
1506
|
+
h(SkeletonBlock, { width: 64, height: 26, radius: 999 }))))
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
function LoadingSkeleton(props) {
|
|
1510
|
+
const { children } = props
|
|
1511
|
+
// aria-busy on the live region would suppress its announcement until false; it unmounts instead.
|
|
1512
|
+
return h('div', { className: 'capital-automation-loading', 'aria-busy': 'true' },
|
|
1513
|
+
h('span', {
|
|
1514
|
+
className: 'capital-automation-skeletonlabel',
|
|
1515
|
+
role: 'status',
|
|
1516
|
+
'aria-live': 'polite',
|
|
1517
|
+
}, zh.loading),
|
|
1518
|
+
children)
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
function TaskDashboardSkeleton() {
|
|
1522
|
+
return h(LoadingSkeleton, null,
|
|
1523
|
+
h(SkeletonHistory),
|
|
1524
|
+
h('section', { className: 'capital-automation-section' },
|
|
1525
|
+
h(SkeletonSectionHead),
|
|
1526
|
+
h(SkeletonTaskTable, { rows: 4 })),
|
|
1527
|
+
h('section', { className: 'capital-automation-section' },
|
|
1528
|
+
h(SkeletonSectionHead, { trailing: [64] }),
|
|
1529
|
+
h('div', { className: 'capital-automation-templates' },
|
|
1530
|
+
[0, 1, 2].map((index) => h(SkeletonTemplateCard, { key: index })))))
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function RunsSkeleton() {
|
|
1534
|
+
return h(LoadingSkeleton, null,
|
|
1535
|
+
h(SkeletonHistory),
|
|
1536
|
+
h('section', { className: 'capital-automation-section' },
|
|
1537
|
+
h(SkeletonSectionHead, { trailing: [260] }),
|
|
1538
|
+
h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
1539
|
+
h('div', { className: 'capital-automation-runs' },
|
|
1540
|
+
[0, 1, 2, 3].map((index) => h(SkeletonRunRow, { key: index }))))))
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
function TaskDashboard(props) {
|
|
1544
|
+
const { tasks, templates, runs, onOpenTask, onNewTask, onEnableTemplate, onAction, onRequestConfirm, onEdit, onGoRuns, onRequestCancelRun, schedulerActive, storageReady, busyTaskId } = props
|
|
1545
|
+
const [filter, setFilter] = useState('all')
|
|
1546
|
+
const [query, setQuery] = useState('')
|
|
1547
|
+
const runningTasks = tasks.filter((task) => isActiveRun(task.lastRun))
|
|
1548
|
+
const templatesAvailable = templates.filter((task) => !isActiveRun(task.lastRun))
|
|
1549
|
+
const roster = tasks.filter((task) => !isActiveRun(task.lastRun) && !(task.origin === 'builtin' && task.state === 'dormant'))
|
|
1550
|
+
const visible = roster.filter((task) => {
|
|
1551
|
+
if (filter === 'custom' && task.origin !== 'custom') return false
|
|
1552
|
+
if (filter !== 'all' && filter !== 'custom' && task.category !== filter) return false
|
|
1553
|
+
if (query.trim().length === 0) return true
|
|
1554
|
+
const needle = query.trim().toLowerCase()
|
|
1555
|
+
return `${task.title} ${task.description ?? ''} ${task.instruction ?? ''}`.toLowerCase().includes(needle)
|
|
1556
|
+
})
|
|
1557
|
+
const filterCounts = {
|
|
1558
|
+
all: roster.length,
|
|
1559
|
+
custom: roster.filter((task) => task.origin === 'custom').length,
|
|
1560
|
+
news: roster.filter((task) => task.category === 'news').length,
|
|
1561
|
+
market: roster.filter((task) => task.category === 'market').length,
|
|
1562
|
+
review: roster.filter((task) => task.category === 'review').length,
|
|
1563
|
+
research: roster.filter((task) => task.category === 'research').length,
|
|
1564
|
+
}
|
|
1565
|
+
const filters = ['all', 'custom', 'news', 'market', 'review', 'research']
|
|
1566
|
+
return h('div', null,
|
|
1567
|
+
h(RunHistoryCard, { runs, onViewAll: onGoRuns }),
|
|
1568
|
+
h('section', { className: 'capital-automation-section' },
|
|
1569
|
+
h('div', { className: 'capital-automation-sectionhead' },
|
|
1570
|
+
h('h2', null, zh.taskSection),
|
|
1571
|
+
h('span', null, zh.taskSectionHint),
|
|
1572
|
+
h('div', { className: 'capital-automation-sectiontools' },
|
|
1573
|
+
h('div', { className: 'capital-automation-filters', role: 'group', 'aria-label': zh.filterLabel },
|
|
1574
|
+
filters.map((value) => h(FilterButton, {
|
|
1575
|
+
key: value,
|
|
1576
|
+
label: value === 'all' ? zh.filterAll : value === 'custom' ? zh.filterCustom : categoryLabel(value),
|
|
1577
|
+
count: filterCounts[value],
|
|
1578
|
+
active: filter === value,
|
|
1579
|
+
onClick: () => setFilter(value),
|
|
1580
|
+
}))),
|
|
1581
|
+
h('label', { className: 'capital-automation-search' },
|
|
1582
|
+
h(IconSearchOutlineRegular, { size: 13 }),
|
|
1583
|
+
h('input', {
|
|
1584
|
+
type: 'search',
|
|
1585
|
+
value: query,
|
|
1586
|
+
placeholder: zh.searchPlaceholder,
|
|
1587
|
+
'aria-label': zh.searchPlaceholder,
|
|
1588
|
+
onChange: (event) => setQuery(event.target.value),
|
|
1589
|
+
})))),
|
|
1590
|
+
runningTasks.length > 0
|
|
1591
|
+
? h('div', { className: 'capital-automation-running', role: 'status' },
|
|
1592
|
+
runningTasks.map((task) => h('div', { key: task.id, className: 'capital-automation-runningrow' },
|
|
1593
|
+
h('span', { className: 'capital-automation-live' },
|
|
1594
|
+
h('span', { className: 'capital-automation-livedot' }),
|
|
1595
|
+
zh.status.running),
|
|
1596
|
+
h(Glyph, { task, size: 28 }),
|
|
1597
|
+
h('button', { type: 'button', className: 'capital-automation-tasktitle', style: { padding: 0, border: 0, background: 'transparent', cursor: 'pointer' }, onClick: () => onOpenTask(task.id) }, task.title),
|
|
1598
|
+
h('span', { className: 'capital-automation-runmeta' }, `${zh.runningSince} ${formatRelative(task.lastRun.startedAt ?? task.lastRun.queuedAt)} · ${zh.steps} ${task.lastRun.steps} · ${zh.tools} ${task.lastRun.toolCalls}`),
|
|
1599
|
+
h('span', { className: 'capital-automation-runningactions' },
|
|
1600
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', 'data-variant': 'danger', onClick: () => onRequestCancelRun(task, task.lastRun) }, zh.cancelRun),
|
|
1601
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', onClick: () => onOpenTask(task.id) }, zh.details)))))
|
|
1602
|
+
: null,
|
|
1603
|
+
visible.length > 0
|
|
1604
|
+
? h(TaskTable, {
|
|
1605
|
+
tasks: visible,
|
|
1606
|
+
onOpen: onOpenTask,
|
|
1607
|
+
onAction,
|
|
1608
|
+
onRequestConfirm,
|
|
1609
|
+
onEdit,
|
|
1610
|
+
schedulerActive,
|
|
1611
|
+
storageReady,
|
|
1612
|
+
busyTaskId,
|
|
1613
|
+
})
|
|
1614
|
+
: roster.length === 0
|
|
1615
|
+
? runningTasks.length > 0
|
|
1616
|
+
? null
|
|
1617
|
+
: h(EmptyState, {
|
|
1618
|
+
title: templatesAvailable.length > 0 ? zh.emptyTasksTitle : zh.emptyNoTemplates,
|
|
1619
|
+
body: templatesAvailable.length > 0 ? zh.emptyTasksBody : zh.emptyNoTemplatesBody,
|
|
1620
|
+
action: templatesAvailable.length === 0 ? onNewTask : undefined,
|
|
1621
|
+
actionLabel: templatesAvailable.length === 0 ? zh.newTask : undefined,
|
|
1622
|
+
})
|
|
1623
|
+
: h(EmptyState, {
|
|
1624
|
+
title: zh.emptyFiltered,
|
|
1625
|
+
body: zh.emptyTasksBody,
|
|
1626
|
+
action: () => { setFilter('all'); setQuery('') },
|
|
1627
|
+
actionLabel: zh.clearFilter,
|
|
1628
|
+
})),
|
|
1629
|
+
templatesAvailable.length > 0
|
|
1630
|
+
? h('section', { className: 'capital-automation-section' },
|
|
1631
|
+
h('div', { className: 'capital-automation-sectionhead' },
|
|
1632
|
+
h('h2', null, zh.templateSection)),
|
|
1633
|
+
h('div', { className: 'capital-automation-templates' },
|
|
1634
|
+
templatesAvailable.map((task) => h(TemplateCard, {
|
|
1635
|
+
key: task.id,
|
|
1636
|
+
task,
|
|
1637
|
+
onOpen: onOpenTask,
|
|
1638
|
+
onEnable: onEnableTemplate,
|
|
1639
|
+
busy: busyTaskId === task.id,
|
|
1640
|
+
disabled: !storageReady,
|
|
1641
|
+
}))))
|
|
1642
|
+
: null)
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
function TriggerFields(props) {
|
|
1646
|
+
const { trigger, onChange, disabled, meta } = props
|
|
1647
|
+
const update = (patch) => onChange(normalizeTrigger({ ...trigger, ...patch }))
|
|
1648
|
+
const setCadence = (cadence) => {
|
|
1649
|
+
const next = triggerChanged(cadence, trigger)
|
|
1650
|
+
onChange(next)
|
|
1651
|
+
}
|
|
1652
|
+
const toggleWeekday = (day) => {
|
|
1653
|
+
const selected = new Set(trigger.weekdays ?? [])
|
|
1654
|
+
if (selected.has(day)) {
|
|
1655
|
+
if (selected.size <= 1) return
|
|
1656
|
+
selected.delete(day)
|
|
1657
|
+
} else {
|
|
1658
|
+
selected.add(day)
|
|
1659
|
+
}
|
|
1660
|
+
update({ weekdays: [...selected].sort((left, right) => left - right) })
|
|
1661
|
+
}
|
|
1662
|
+
return h('div', { className: 'capital-automation-triggerbox' },
|
|
1663
|
+
h('div', { className: 'capital-automation-triggerrow' },
|
|
1664
|
+
h('span', { className: 'capital-automation-triggerclock', 'aria-hidden': 'true' }, h(IconAlarmClockOutlineRegular, { size: 16 })),
|
|
1665
|
+
h('div', { className: 'capital-automation-triggerfield' },
|
|
1666
|
+
h('span', null, '重复'),
|
|
1667
|
+
h(Select, {
|
|
1668
|
+
value: trigger.cadence,
|
|
1669
|
+
options: Object.entries(zh.cadence).map(([value, label]) => ({ value, label })),
|
|
1670
|
+
onChange: setCadence,
|
|
1671
|
+
disabled,
|
|
1672
|
+
label: '重复',
|
|
1673
|
+
})),
|
|
1674
|
+
h('label', { className: 'capital-automation-triggerfield' },
|
|
1675
|
+
h('span', null, zh.timeField),
|
|
1676
|
+
h('input', { type: 'time', value: trigger.time, disabled, onChange: (event) => update({ time: event.target.value }) })),
|
|
1677
|
+
h('label', { className: 'capital-automation-triggerfield' },
|
|
1678
|
+
h('span', null, zh.timezoneField),
|
|
1679
|
+
h('input', {
|
|
1680
|
+
type: 'text',
|
|
1681
|
+
list: 'capital-automation-timezones',
|
|
1682
|
+
value: trigger.timezone,
|
|
1683
|
+
disabled,
|
|
1684
|
+
onChange: (event) => update({ timezone: event.target.value }),
|
|
1685
|
+
title: zh.timezoneHint,
|
|
1686
|
+
}))),
|
|
1687
|
+
h('div', { className: 'capital-automation-triggerrow' },
|
|
1688
|
+
trigger.cadence === 'weekly'
|
|
1689
|
+
? h('div', { className: 'capital-automation-weekdays', role: 'group', 'aria-label': zh.weekdayField },
|
|
1690
|
+
WEEKDAYS.map((day) => h('button', {
|
|
1691
|
+
key: day.value,
|
|
1692
|
+
type: 'button',
|
|
1693
|
+
className: 'capital-automation-weekday',
|
|
1694
|
+
'aria-pressed': (trigger.weekdays ?? []).includes(day.value) ? 'true' : 'false',
|
|
1695
|
+
disabled,
|
|
1696
|
+
onClick: () => toggleWeekday(day.value),
|
|
1697
|
+
}, day.label)))
|
|
1698
|
+
: null,
|
|
1699
|
+
trigger.cadence === 'monthly'
|
|
1700
|
+
? h('div', { className: 'capital-automation-triggerfield' },
|
|
1701
|
+
h('span', null, zh.dayField),
|
|
1702
|
+
h(Select, {
|
|
1703
|
+
value: String(trigger.dayOfMonth ?? 1),
|
|
1704
|
+
options: Array.from({ length: 28 }, (_, index) => {
|
|
1705
|
+
const day = index + 1
|
|
1706
|
+
return { value: String(day), label: zh.dayOfMonth.replace('{n}', String(day)) }
|
|
1707
|
+
}),
|
|
1708
|
+
onChange: (day) => update({ dayOfMonth: Number(day) }),
|
|
1709
|
+
disabled,
|
|
1710
|
+
label: zh.dayField,
|
|
1711
|
+
}))
|
|
1712
|
+
: null,
|
|
1713
|
+
trigger.cadence === 'daily' ? h('span', { className: 'capital-automation-hint' }, trigger.tradingDaysOnly === true ? zh.triggerHint : zh.triggerHintNatural) : null,
|
|
1714
|
+
h('label', { className: 'capital-automation-switch', style: { marginLeft: 'auto' } },
|
|
1715
|
+
h(Switch, {
|
|
1716
|
+
checked: trigger.tradingDaysOnly === true,
|
|
1717
|
+
onChange: (value) => update({ tradingDaysOnly: value }),
|
|
1718
|
+
label: zh.tradingDaysField,
|
|
1719
|
+
disabled,
|
|
1720
|
+
}),
|
|
1721
|
+
h('span', null, zh.tradingDaysField))),
|
|
1722
|
+
h('p', { className: 'capital-automation-triggersummary' }, `${scheduleSummary(trigger)} · ${trigger.timezone}`),
|
|
1723
|
+
meta?.calendar?.available === false ? h('p', { className: 'capital-automation-hint' }, zh.nextRunUnavailable) : null)
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
function SwitchRow(props) {
|
|
1727
|
+
const { label, hint, checked, onChange, disabled } = props
|
|
1728
|
+
return h('div', { className: 'capital-automation-switchrow' },
|
|
1729
|
+
h('div', null,
|
|
1730
|
+
h('span', null, label),
|
|
1731
|
+
hint ? h('small', null, hint) : null),
|
|
1732
|
+
h(Switch, { checked: checked === true, onChange, label, disabled }))
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
function Field(props) {
|
|
1736
|
+
const { label, hint, children } = props
|
|
1737
|
+
return h('label', { className: 'capital-automation-field' },
|
|
1738
|
+
h('span', null, label),
|
|
1739
|
+
children,
|
|
1740
|
+
hint ? h('span', { className: 'capital-automation-hint' }, hint) : null)
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* DSH General-settings style selector: a filled pill plus the shared Menu surface.
|
|
1745
|
+
* Native <select> is intentionally avoided so light/dark themes follow host tokens.
|
|
1746
|
+
*/
|
|
1747
|
+
function Select(props) {
|
|
1748
|
+
const { value, options, onChange, disabled, label, block, size, align = 'start' } = props
|
|
1749
|
+
const [open, setOpen] = useState(false)
|
|
1750
|
+
const triggerRef = useRef(null)
|
|
1751
|
+
const items = options.map((option) => ({
|
|
1752
|
+
id: String(option.value),
|
|
1753
|
+
label: option.label,
|
|
1754
|
+
disabled: option.disabled === true,
|
|
1755
|
+
}))
|
|
1756
|
+
const currentValue = String(value ?? '')
|
|
1757
|
+
const current = items.find((item) => item.id === currentValue) ?? items[0]
|
|
1758
|
+
useEffect(() => {
|
|
1759
|
+
if (disabled === true && open) setOpen(false)
|
|
1760
|
+
}, [disabled, open])
|
|
1761
|
+
const closeMenu = () => setOpen(false)
|
|
1762
|
+
const selectValue = (id) => {
|
|
1763
|
+
setOpen(false)
|
|
1764
|
+
triggerRef.current?.focus?.({ preventScroll: true })
|
|
1765
|
+
if (id !== currentValue) onChange(id)
|
|
1766
|
+
}
|
|
1767
|
+
const trigger = h('button', {
|
|
1768
|
+
ref: triggerRef,
|
|
1769
|
+
type: 'button',
|
|
1770
|
+
className: 'capital-automation-select',
|
|
1771
|
+
'data-block': block === true ? 'true' : undefined,
|
|
1772
|
+
'data-size': size,
|
|
1773
|
+
disabled,
|
|
1774
|
+
'aria-label': current?.label ? `${label}:${current.label}` : label,
|
|
1775
|
+
'aria-haspopup': 'menu',
|
|
1776
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
1777
|
+
onClick: () => setOpen((currentOpen) => !currentOpen),
|
|
1778
|
+
},
|
|
1779
|
+
h('span', {
|
|
1780
|
+
className: 'capital-automation-selectvalue',
|
|
1781
|
+
title: current?.label,
|
|
1782
|
+
}, current?.label ?? ''),
|
|
1783
|
+
h(IconChevronDownOutlineRegular, { size: size === 'sm' ? 12 : 14 }))
|
|
1784
|
+
return h(Menu, {
|
|
1785
|
+
open,
|
|
1786
|
+
anchor: trigger,
|
|
1787
|
+
items,
|
|
1788
|
+
selectedId: currentValue,
|
|
1789
|
+
onSelect: selectValue,
|
|
1790
|
+
onClose: closeMenu,
|
|
1791
|
+
align,
|
|
1792
|
+
portal: true,
|
|
1793
|
+
})
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
function SelectField(props) {
|
|
1797
|
+
const { label, hint, ariaLabel, block = true, ...rest } = props
|
|
1798
|
+
return h('div', { className: 'capital-automation-field' },
|
|
1799
|
+
h('span', null, label),
|
|
1800
|
+
h(Select, { ...rest, label: ariaLabel ?? label, block }),
|
|
1801
|
+
hint ? h('span', { className: 'capital-automation-hint' }, hint) : null)
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
function NumberField(props) {
|
|
1805
|
+
const { label, value, min, max, disabled, onChange } = props
|
|
1806
|
+
return h(Field, { label },
|
|
1807
|
+
h('input', {
|
|
1808
|
+
type: 'number',
|
|
1809
|
+
min,
|
|
1810
|
+
max,
|
|
1811
|
+
value,
|
|
1812
|
+
disabled,
|
|
1813
|
+
onChange: (event) => onChange(Number(event.target.value)),
|
|
1814
|
+
}))
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
function RunFilters(props) {
|
|
1818
|
+
const { value, counts, onChange } = props
|
|
1819
|
+
const options = [
|
|
1820
|
+
['all', zh.runFilterAll],
|
|
1821
|
+
['active', zh.runFilterActive],
|
|
1822
|
+
['succeeded', zh.runFilterSucceeded],
|
|
1823
|
+
['failed', zh.runFilterFailed],
|
|
1824
|
+
]
|
|
1825
|
+
return h('div', { className: 'capital-automation-filters', role: 'group', 'aria-label': zh.runFilterLabel },
|
|
1826
|
+
options.map(([id, label]) => h(FilterButton, {
|
|
1827
|
+
key: id,
|
|
1828
|
+
label,
|
|
1829
|
+
count: counts[id],
|
|
1830
|
+
active: value === id,
|
|
1831
|
+
onClick: () => onChange(id),
|
|
1832
|
+
})))
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
function RunsPage(props) {
|
|
1836
|
+
const { runs, tasks, onCancel, onOpenSession, onOpenTask, onGoTasks, onNewTask, busy } = props
|
|
1837
|
+
const [filter, setFilter] = useState('all')
|
|
1838
|
+
const counts = {
|
|
1839
|
+
all: runs.length,
|
|
1840
|
+
active: runs.filter((run) => isActiveRun(run)).length,
|
|
1841
|
+
succeeded: runs.filter((run) => run.status === 'succeeded').length,
|
|
1842
|
+
failed: runs.filter((run) => isFailureStatus(run.status)).length,
|
|
1843
|
+
}
|
|
1844
|
+
const visible = runs.filter((run) => {
|
|
1845
|
+
if (filter === 'active') return isActiveRun(run)
|
|
1846
|
+
if (filter === 'succeeded') return run.status === 'succeeded'
|
|
1847
|
+
if (filter === 'failed') return isFailureStatus(run.status)
|
|
1848
|
+
return true
|
|
1849
|
+
})
|
|
1850
|
+
return h('div', null,
|
|
1851
|
+
h(RunHistoryCard, { runs, showLink: false }),
|
|
1852
|
+
h('section', { className: 'capital-automation-section' },
|
|
1853
|
+
h('div', { className: 'capital-automation-sectionhead' },
|
|
1854
|
+
h('h2', null, zh.runsTitle),
|
|
1855
|
+
h('span', null, zh.runsHint),
|
|
1856
|
+
h('div', { className: 'capital-automation-sectiontools' },
|
|
1857
|
+
h(RunFilters, { value: filter, counts, onChange: setFilter }))),
|
|
1858
|
+
runs.length === 0
|
|
1859
|
+
? h('div', { className: 'capital-automation-empty' },
|
|
1860
|
+
h('span', { className: 'capital-automation-emptyicon' }, h(IconClockOutlineRegular, { size: 19 })),
|
|
1861
|
+
h('h3', null, zh.runsEmptyTitle),
|
|
1862
|
+
h('p', null, zh.runsEmptyBody),
|
|
1863
|
+
h('div', { style: { display: 'flex', gap: 8, marginTop: 8 } },
|
|
1864
|
+
h('button', { type: 'button', className: 'capital-automation-btn', onClick: onGoTasks }, zh.runsEmptyAction),
|
|
1865
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-variant': 'primary', onClick: onNewTask }, zh.newTask)))
|
|
1866
|
+
: visible.length === 0
|
|
1867
|
+
? h(EmptyState, { title: zh.emptyFiltered, body: zh.filterNoRuns, action: () => setFilter('all'), actionLabel: zh.clearFilter })
|
|
1868
|
+
: h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
1869
|
+
h(RunList, { runs: visible, tasks, onCancel, onOpenSession, onOpenTask, busy }),
|
|
1870
|
+
runs.length >= 200 ? h('p', { className: 'capital-automation-hint', style: { paddingTop: 10 } }, zh.runsLimitHint.replace('{n}', '200')) : null)))
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
function OverviewTab(props) {
|
|
1874
|
+
const { detail, meta, onGoRuns, onCancelRun, onOpenSession } = props
|
|
1875
|
+
const latest = detail.runs[0]
|
|
1876
|
+
const next = nextRunView(detail.task)
|
|
1877
|
+
const last = lastRunView(latest, detail.task.trigger.timezone)
|
|
1878
|
+
const anyRunning = detail.runs.some((run) => isActiveRun(run))
|
|
1879
|
+
const stateText = anyRunning ? zh.status.running : stateLabel(detail.task.state)
|
|
1880
|
+
const originLabel = detail.task.origin === 'builtin' ? zh.origin.builtin : zh.origin.custom
|
|
1881
|
+
const scheduleText = `${scheduleRangeSummary(detail.task.trigger)}${detail.task.trigger.tradingDaysOnly === true ? ` · ${zh.tradingDaysField}` : ''}`
|
|
1882
|
+
const scheduleHint = detail.task.trigger.tradingDaysOnly === true ? zh.triggerHint : zh.triggerHintNatural
|
|
1883
|
+
return h('div', { className: 'capital-automation-overview' },
|
|
1884
|
+
h('div', { className: 'capital-automation-statgrid' },
|
|
1885
|
+
h('div', { className: 'capital-automation-stat' },
|
|
1886
|
+
h('span', { className: 'capital-automation-statlabel' }, zh.stateLabel),
|
|
1887
|
+
h('span', { className: 'capital-automation-statvalue', 'data-tone': anyRunning ? 'running' : undefined }, stateText),
|
|
1888
|
+
h('span', { className: 'capital-automation-statsub', title: detail.task.origin === 'builtin' ? zh.configBuiltinHint : undefined }, originLabel)),
|
|
1889
|
+
h('div', { className: 'capital-automation-stat' },
|
|
1890
|
+
h('span', { className: 'capital-automation-statlabel' }, zh.nextRun),
|
|
1891
|
+
h('span', { className: 'capital-automation-statvalue' }, next.value),
|
|
1892
|
+
h('span', { className: 'capital-automation-statsub' }, next.sub)),
|
|
1893
|
+
h('div', { className: 'capital-automation-stat' },
|
|
1894
|
+
h('span', { className: 'capital-automation-statlabel' }, zh.lastResult),
|
|
1895
|
+
h('span', { className: 'capital-automation-statvalue', 'data-tone': last.tone }, last.value),
|
|
1896
|
+
h('span', { className: 'capital-automation-statsub' }, last.sub)),
|
|
1897
|
+
h('div', { className: 'capital-automation-stat', title: scheduleHint },
|
|
1898
|
+
h('span', { className: 'capital-automation-statlabel' }, zh.triggerSummary),
|
|
1899
|
+
h('span', { className: 'capital-automation-statvalue' }, scheduleText),
|
|
1900
|
+
h('span', { className: 'capital-automation-statsub' }, `${detail.task.trigger.time} · ${detail.task.trigger.timezone}`))),
|
|
1901
|
+
h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
1902
|
+
h('div', { className: 'capital-automation-panelhead' },
|
|
1903
|
+
h('h3', null, zh.detailRecentRuns.replace('{n}', String(DETAIL_RECENT_RUN_LIMIT))),
|
|
1904
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', 'data-variant': 'ghost', onClick: onGoRuns },
|
|
1905
|
+
zh.detailAllRuns,
|
|
1906
|
+
h(IconChevronRightOutlineRegular, { size: 13 }))),
|
|
1907
|
+
h(RunList, {
|
|
1908
|
+
runs: detail.runs.slice(0, DETAIL_RECENT_RUN_LIMIT),
|
|
1909
|
+
tasks: [detail.task],
|
|
1910
|
+
onCancel: onCancelRun,
|
|
1911
|
+
onOpenSession,
|
|
1912
|
+
compact: true,
|
|
1913
|
+
})),
|
|
1914
|
+
h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
1915
|
+
h('div', { className: 'capital-automation-panelhead' },
|
|
1916
|
+
h('h3', null, zh.environment)),
|
|
1917
|
+
h('div', { className: 'capital-automation-kv' },
|
|
1918
|
+
h('div', { className: 'capital-automation-kvitem' },
|
|
1919
|
+
h('span', { className: 'capital-automation-kvlabel' }, zh.presetLabel),
|
|
1920
|
+
h('span', { className: 'capital-automation-kvvalue' }, zh.presetValue)),
|
|
1921
|
+
h('div', { className: 'capital-automation-kvitem' },
|
|
1922
|
+
h('span', { className: 'capital-automation-kvlabel' }, zh.workspaceField),
|
|
1923
|
+
h('span', { className: 'capital-automation-kvvalue' }, workspaceTitle(meta, detail.task.workspaceId))),
|
|
1924
|
+
h('div', { className: 'capital-automation-kvitem' },
|
|
1925
|
+
h('span', { className: 'capital-automation-kvlabel' }, zh.categoryField),
|
|
1926
|
+
h('span', { className: 'capital-automation-kvvalue' }, categoryLabel(detail.task.category))),
|
|
1927
|
+
h('div', { className: 'capital-automation-kvitem' },
|
|
1928
|
+
h('span', { className: 'capital-automation-kvlabel' }, zh.modeField),
|
|
1929
|
+
h('span', { className: 'capital-automation-kvvalue' }, modeLabel(detail.task.mode)))),
|
|
1930
|
+
h('section', { className: 'capital-automation-technical' },
|
|
1931
|
+
h('h4', { className: 'capital-automation-technicaltitle' }, zh.techInfo),
|
|
1932
|
+
h('dl', null,
|
|
1933
|
+
h('dt', null, zh.profileKey),
|
|
1934
|
+
h('dd', { title: 'profileKey 是 profile 名称的稳定哈希;与 session 标题里的 run id 无关。' }, meta?.profile?.key ?? '—'),
|
|
1935
|
+
h('dt', null, zh.presetLabel),
|
|
1936
|
+
h('dd', null, zh.presetValue),
|
|
1937
|
+
h('dt', null, zh.policyField),
|
|
1938
|
+
h('dd', null, meta?.execution?.policy ?? 'automation-v1'),
|
|
1939
|
+
h('dt', null, zh.cwdKind),
|
|
1940
|
+
h('dd', { title: '当前固定为 profile(专属自动化工作区);没有 storage 等其他来源。' }, meta?.execution?.cwdKind ?? 'profile'),
|
|
1941
|
+
h('dt', null, 'profile 名称'),
|
|
1942
|
+
h('dd', null, meta?.profile?.name ?? '—'),
|
|
1943
|
+
h('dt', null, zh.calendarField),
|
|
1944
|
+
h('dd', null, calendarLabel(meta?.calendar))))))
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
function ConfigTab(props) {
|
|
1948
|
+
const { draft, setDraft, meta, busy, dirty, save, reset, disabled } = props
|
|
1949
|
+
const task = draft
|
|
1950
|
+
const set = (patch) => setDraft((current) => ({
|
|
1951
|
+
...current,
|
|
1952
|
+
...(typeof patch === 'function' ? patch(current) : patch),
|
|
1953
|
+
}))
|
|
1954
|
+
const timeoutRange = limitValue(meta, 'runTimeoutMinutes', [5, 120])
|
|
1955
|
+
const idleRange = limitValue(meta, 'idleTimeoutMinutes', [1, 30])
|
|
1956
|
+
const stepsRange = limitValue(meta, 'maxSteps', [10, 2000])
|
|
1957
|
+
const toolsRange = limitValue(meta, 'maxToolCalls', [10, 6000])
|
|
1958
|
+
const advanced = h('details', { className: 'capital-automation-advanced' },
|
|
1959
|
+
h('summary', null, zh.advanced),
|
|
1960
|
+
h('div', { className: 'capital-automation-advancedbody' },
|
|
1961
|
+
h('div', { className: 'capital-automation-formgrid' },
|
|
1962
|
+
h(SelectField, {
|
|
1963
|
+
label: zh.workspaceField,
|
|
1964
|
+
value: task.workspaceId ?? '',
|
|
1965
|
+
options: workspaceOptions(meta, task.workspaceId).map((option) => ({ value: option.id, label: option.title })),
|
|
1966
|
+
disabled: busy || disabled,
|
|
1967
|
+
onChange: (workspaceId) => set({ workspaceId }),
|
|
1968
|
+
}),
|
|
1969
|
+
h(SelectField, {
|
|
1970
|
+
label: zh.modeField,
|
|
1971
|
+
hint: zh.modeHint,
|
|
1972
|
+
value: task.mode,
|
|
1973
|
+
options: Object.entries(zh.mode).map(([value, label]) => ({ value, label })),
|
|
1974
|
+
disabled: busy || disabled,
|
|
1975
|
+
onChange: (mode) => set({ mode }),
|
|
1976
|
+
})),
|
|
1977
|
+
h('div', { className: 'capital-automation-formgrid' },
|
|
1978
|
+
h(NumberField, { label: zh.runTimeout, value: task.limits.runTimeoutMinutes, min: timeoutRange[0], max: timeoutRange[1], disabled: busy || disabled, onChange: (value) => set((current) => ({ limits: { ...current.limits, runTimeoutMinutes: value } })) }),
|
|
1979
|
+
h(NumberField, { label: zh.idleTimeout, value: task.limits.idleTimeoutMinutes, min: idleRange[0], max: idleRange[1], disabled: busy || disabled, onChange: (value) => set((current) => ({ limits: { ...current.limits, idleTimeoutMinutes: value } })) }),
|
|
1980
|
+
h(NumberField, { label: zh.maxSteps, value: task.limits.maxSteps, min: stepsRange[0], max: stepsRange[1], disabled: busy || disabled, onChange: (value) => set((current) => ({ limits: { ...current.limits, maxSteps: value } })) }),
|
|
1981
|
+
h(NumberField, { label: zh.maxToolCalls, value: task.limits.maxToolCalls, min: toolsRange[0], max: toolsRange[1], disabled: busy || disabled, onChange: (value) => set((current) => ({ limits: { ...current.limits, maxToolCalls: value } })) })),
|
|
1982
|
+
h('p', { className: 'capital-automation-hint' }, zh.budgetHint),
|
|
1983
|
+
meta?.workspaceError ? h('p', { className: 'capital-automation-hint', 'data-tone': 'error' }, zh.workspaceUnavailable) : null))
|
|
1984
|
+
const notificationRows = h('div', null,
|
|
1985
|
+
h('span', { className: 'capital-automation-formlabel' }, zh.notifyField),
|
|
1986
|
+
h('div', { className: 'capital-automation-switchlist' },
|
|
1987
|
+
h(SwitchRow, { label: zh.notifyInApp, checked: task.notifications.inApp, disabled: busy || disabled, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, inApp: value } })) }),
|
|
1988
|
+
h(SwitchRow, { label: zh.notifyFailure, checked: task.notifications.onFailure, disabled: busy || disabled, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, onFailure: value } })) }),
|
|
1989
|
+
h(SwitchRow, { label: zh.notifySuccess, checked: task.notifications.onSuccess, disabled: busy || disabled, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, onSuccess: value } })) })),
|
|
1990
|
+
h('p', { className: 'capital-automation-hint' }, zh.notifyHint))
|
|
1991
|
+
return h('div', { className: 'capital-automation-form' },
|
|
1992
|
+
task.origin === 'builtin'
|
|
1993
|
+
? h('div', { className: 'capital-automation-formnote' },
|
|
1994
|
+
h(IconInfoOutlineRegular, { size: 13 }),
|
|
1995
|
+
h('span', null, zh.configBuiltinHint))
|
|
1996
|
+
: null,
|
|
1997
|
+
h(Field, { label: zh.titleField },
|
|
1998
|
+
h('input', { value: task.title, disabled: busy || disabled, onChange: (event) => set({ title: event.target.value }) })),
|
|
1999
|
+
h(Field, { label: zh.descriptionField },
|
|
2000
|
+
h('textarea', { value: task.description ?? '', disabled: busy || disabled, rows: 3, onChange: (event) => set({ description: event.target.value }) })),
|
|
2001
|
+
h(SelectField, {
|
|
2002
|
+
label: zh.categoryField,
|
|
2003
|
+
hint: task.origin === 'builtin' ? zh.categoryFixed : undefined,
|
|
2004
|
+
value: task.category,
|
|
2005
|
+
options: Object.entries(zh.category).map(([value, label]) => ({ value, label })),
|
|
2006
|
+
disabled: busy || disabled || task.origin === 'builtin',
|
|
2007
|
+
onChange: (category) => set({ category }),
|
|
2008
|
+
}),
|
|
2009
|
+
h(Field, { label: zh.instructionField },
|
|
2010
|
+
h('textarea', {
|
|
2011
|
+
value: task.instruction,
|
|
2012
|
+
disabled: busy || disabled,
|
|
2013
|
+
rows: 14,
|
|
2014
|
+
onChange: (event) => set({ instruction: event.target.value }),
|
|
2015
|
+
})),
|
|
2016
|
+
h('div', null,
|
|
2017
|
+
h('span', { className: 'capital-automation-formlabel' }, zh.triggerField),
|
|
2018
|
+
h(TriggerFields, { trigger: task.trigger, disabled: busy || disabled, onChange: (trigger) => set({ trigger }), meta })),
|
|
2019
|
+
advanced,
|
|
2020
|
+
notificationRows,
|
|
2021
|
+
h('div', { className: 'capital-automation-formactions', 'data-sticky': 'true' },
|
|
2022
|
+
h('span', { className: 'capital-automation-formstatus' },
|
|
2023
|
+
disabled ? zh.storageUnavailable : dirty ? zh.dirty : zh.noDirty),
|
|
2024
|
+
h('button', { type: 'button', className: 'capital-automation-btn', disabled: busy || !dirty, onClick: reset }, zh.cancel),
|
|
2025
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-variant': 'primary', disabled: busy || !dirty || disabled, onClick: save }, busy === 'save' ? zh.saving : zh.save)))
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
function NotificationsTab(props) {
|
|
2029
|
+
const { detail, busy, onMarkTaskRead } = props
|
|
2030
|
+
const items = detail.notifications
|
|
2031
|
+
const unread = items.filter((item) => item.readAt === undefined).length
|
|
2032
|
+
return h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
2033
|
+
h('div', { className: 'capital-automation-panelhead' },
|
|
2034
|
+
h('h3', null, zh.detailTaskNotifications),
|
|
2035
|
+
unread > 0
|
|
2036
|
+
? h('button', { type: 'button', className: 'capital-automation-btn', 'data-size': 'sm', disabled: busy, onClick: onMarkTaskRead }, zh.markTaskRead)
|
|
2037
|
+
: null),
|
|
2038
|
+
items.length === 0
|
|
2039
|
+
? h('p', { className: 'capital-automation-hint' }, zh.notificationsEmpty)
|
|
2040
|
+
: h('div', null, items.map((item) => h(NotificationItem, { key: item.id, item }))))
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
function NotificationItem(props) {
|
|
2044
|
+
const { item, onClick, onOpenTask } = props
|
|
2045
|
+
const clickable = typeof onClick === 'function' && item.taskId !== undefined
|
|
2046
|
+
const tag = clickable ? 'button' : 'div'
|
|
2047
|
+
return h(tag, {
|
|
2048
|
+
type: clickable ? 'button' : undefined,
|
|
2049
|
+
className: 'capital-automation-notification',
|
|
2050
|
+
'data-clickable': clickable ? 'true' : 'false',
|
|
2051
|
+
onClick: clickable ? onClick : undefined,
|
|
2052
|
+
},
|
|
2053
|
+
h('span', { className: 'capital-automation-notificationicon', 'data-tone': eventTone(item.kind) },
|
|
2054
|
+
eventTone(item.kind) === 'error' ? h(IconWarningOutlineRegular, { size: 15 }) : eventTone(item.kind) === 'warn' ? h(IconInfoOutlineRegular, { size: 15 }) : h(IconAlarmClockOutlineRegular, { size: 15 })),
|
|
2055
|
+
h('span', { className: 'capital-automation-notificationbody' },
|
|
2056
|
+
h('span', { className: 'capital-automation-notificationtitle' },
|
|
2057
|
+
item.title,
|
|
2058
|
+
item.readAt === undefined ? h('span', { className: 'capital-automation-count' }, zh.unread) : null),
|
|
2059
|
+
h('span', { className: 'capital-automation-notificationmessage' }, notificationMessage(item)),
|
|
2060
|
+
h('span', { className: 'capital-automation-notificationtime' }, formatShortTime(item.createdAt))),
|
|
2061
|
+
onOpenTask !== undefined && item.taskId !== undefined
|
|
2062
|
+
? h('span', { className: 'capital-automation-hint' }, zh.notificationOpenTask)
|
|
2063
|
+
: null)
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function DetailBar(props) {
|
|
2067
|
+
return h('div', { className: 'capital-automation-detailbar' },
|
|
2068
|
+
h('button', { type: 'button', className: 'capital-automation-back', onClick: props.onBack },
|
|
2069
|
+
h(IconChevronLeftOutlineRegular, { size: 14 }),
|
|
2070
|
+
zh.backToTasks))
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
function TaskDetailPage(props) {
|
|
2074
|
+
const { detail, meta, api, onChanged, openSession, tab, onTab, onRequestConfirm, onRequestCancelRun, schedulerActive, storageReady } = props
|
|
347
2075
|
const [draft, setDraft] = useState(null)
|
|
348
2076
|
const [busy, setBusy] = useState('')
|
|
349
2077
|
const [notice, setNotice] = useState('')
|
|
350
2078
|
const [error, setError] = useState('')
|
|
2079
|
+
const [menuOpen, setMenuOpen] = useState(false)
|
|
2080
|
+
const lastTaskIdRef = useRef(null)
|
|
2081
|
+
|
|
2082
|
+
useEffect(() => {
|
|
2083
|
+
setDraft(detail.task ? {
|
|
2084
|
+
...detail.task,
|
|
2085
|
+
trigger: normalizeTrigger(detail.task.trigger),
|
|
2086
|
+
limits: { ...detail.task.limits },
|
|
2087
|
+
notifications: { ...detail.task.notifications },
|
|
2088
|
+
} : null)
|
|
2089
|
+
}, [detail])
|
|
351
2090
|
|
|
352
2091
|
useEffect(() => {
|
|
353
|
-
|
|
2092
|
+
const id = detail.task?.id ?? null
|
|
2093
|
+
if (lastTaskIdRef.current === id) return
|
|
2094
|
+
lastTaskIdRef.current = id
|
|
354
2095
|
setNotice('')
|
|
355
2096
|
setError('')
|
|
356
2097
|
}, [detail])
|
|
357
2098
|
|
|
358
2099
|
if (draft === null) return h('p', { className: 'capital-automation-empty' }, zh.loading)
|
|
359
2100
|
const task = draft
|
|
360
|
-
const
|
|
361
|
-
const running = detail.runs.some((run) =>
|
|
2101
|
+
const storageReadyNow = storageReady !== false
|
|
2102
|
+
const running = detail.runs.some((run) => isActiveRun(run))
|
|
2103
|
+
const activeRun = detail.runs.find((run) => isActiveRun(run))
|
|
2104
|
+
const unread = detail.notifications.filter((item) => item.readAt === undefined).length
|
|
2105
|
+
const dirty = draftChanged(draft, detail.task)
|
|
2106
|
+
const canRun = storageReadyNow && schedulerActive === true && !running
|
|
362
2107
|
const set = (patch) => setDraft((current) => ({
|
|
363
2108
|
...current,
|
|
364
2109
|
...(typeof patch === 'function' ? patch(current) : patch),
|
|
365
2110
|
}))
|
|
366
2111
|
|
|
367
|
-
async function act(name, action) {
|
|
2112
|
+
async function act(name, action, success) {
|
|
368
2113
|
if (busy) return
|
|
369
2114
|
setBusy(name)
|
|
370
2115
|
setError('')
|
|
371
|
-
setNotice('')
|
|
372
2116
|
try {
|
|
373
2117
|
await action()
|
|
374
|
-
setNotice(zh.saved)
|
|
375
2118
|
await onChanged(detail.task.id)
|
|
2119
|
+
setNotice(success)
|
|
376
2120
|
} catch (failure) {
|
|
377
2121
|
setError(failure.message ?? zh.errorGeneric)
|
|
378
2122
|
} finally {
|
|
@@ -381,168 +2125,190 @@ function TaskDetail(props) {
|
|
|
381
2125
|
}
|
|
382
2126
|
|
|
383
2127
|
async function save() {
|
|
2128
|
+
const invalid = validateDraft(task)
|
|
2129
|
+
if (invalid.length > 0) {
|
|
2130
|
+
setError(invalid)
|
|
2131
|
+
return
|
|
2132
|
+
}
|
|
384
2133
|
await act('save', async () => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
2134
|
+
await api.patch(detail.task.id, draftPayload(task))
|
|
2135
|
+
}, zh.saved)
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
async function toggleState() {
|
|
2139
|
+
const next = detail.task.state === 'active' ? 'pause' : 'activate'
|
|
2140
|
+
await act(next, async () => {
|
|
2141
|
+
await api.action(detail.task.id, next)
|
|
2142
|
+
}, next === 'pause' ? zh.paused.replace('{title}', detail.task.title) : activationNotice(detail.task))
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
async function runNow() {
|
|
2146
|
+
await act('run', async () => {
|
|
2147
|
+
await api.run(detail.task.id)
|
|
2148
|
+
}, zh.runSubmitted.replace('{title}', detail.task.title))
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
async function markTaskRead() {
|
|
2152
|
+
const ids = detail.notifications.filter((item) => item.readAt === undefined).map((item) => item.id)
|
|
2153
|
+
if (ids.length === 0) return
|
|
2154
|
+
await act('read-notifications', async () => {
|
|
2155
|
+
await api.markRead({ ids })
|
|
2156
|
+
}, zh.markReadDone)
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
async function copyTask() {
|
|
2160
|
+
await act('copy', async () => {
|
|
2161
|
+
await api.action(detail.task.id, 'copy')
|
|
2162
|
+
}, zh.copied.replace('{title}', detail.task.title))
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
const runButton = running
|
|
2166
|
+
? h('button', {
|
|
2167
|
+
type: 'button',
|
|
2168
|
+
className: 'capital-automation-btn',
|
|
2169
|
+
'data-variant': 'danger',
|
|
2170
|
+
disabled: busy || !storageReadyNow || activeRun === undefined,
|
|
2171
|
+
onClick: () => { if (activeRun !== undefined) onRequestCancelRun(activeRun) },
|
|
2172
|
+
}, zh.cancelRun)
|
|
2173
|
+
: h('button', {
|
|
2174
|
+
type: 'button',
|
|
2175
|
+
className: 'capital-automation-btn',
|
|
2176
|
+
'data-variant': detail.task.state === 'active' ? 'primary' : undefined,
|
|
2177
|
+
disabled: busy || !canRun,
|
|
2178
|
+
title: schedulerActive === false ? zh.schedulerBlocked : running ? zh.runBlocked : undefined,
|
|
2179
|
+
onClick: () => { void runNow() },
|
|
2180
|
+
}, h(IconPlayOutlineRegular, { size: 14 }), zh.runNow)
|
|
2181
|
+
|
|
2182
|
+
const resetDraft = () => {
|
|
2183
|
+
setDraft({
|
|
2184
|
+
...detail.task,
|
|
2185
|
+
trigger: normalizeTrigger(detail.task.trigger),
|
|
2186
|
+
limits: { ...detail.task.limits },
|
|
2187
|
+
notifications: { ...detail.task.notifications },
|
|
398
2188
|
})
|
|
2189
|
+
setError('')
|
|
2190
|
+
setNotice('')
|
|
399
2191
|
}
|
|
400
2192
|
|
|
401
|
-
return h('div',
|
|
402
|
-
h('
|
|
403
|
-
h(
|
|
404
|
-
h('div', { className: 'capital-automation-
|
|
405
|
-
h('div', { className: 'capital-automation-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
h(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
h('
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
function NewTaskWizard(props) {
|
|
2193
|
+
return h('div', null,
|
|
2194
|
+
h('div', { className: 'capital-automation-hero' },
|
|
2195
|
+
h(Glyph, { task, large: true }),
|
|
2196
|
+
h('div', { className: 'capital-automation-herobody' },
|
|
2197
|
+
h('div', { className: 'capital-automation-herotitle' },
|
|
2198
|
+
h('h2', null, detail.task.title),
|
|
2199
|
+
h(StateBadge, { state: detail.task.state, running }),
|
|
2200
|
+
unread > 0 ? h('span', { className: 'capital-automation-count', title: zh.unread }, String(unread)) : null),
|
|
2201
|
+
h('p', { className: 'capital-automation-herodesc' }, detail.task.description || zh.subtitle)),
|
|
2202
|
+
h('div', { className: 'capital-automation-heroactions' },
|
|
2203
|
+
runButton,
|
|
2204
|
+
running
|
|
2205
|
+
? null
|
|
2206
|
+
: h('button', {
|
|
2207
|
+
type: 'button',
|
|
2208
|
+
className: 'capital-automation-btn',
|
|
2209
|
+
'data-variant': detail.task.state === 'active' ? undefined : 'primary',
|
|
2210
|
+
disabled: busy || !storageReadyNow,
|
|
2211
|
+
onClick: () => { void toggleState() },
|
|
2212
|
+
}, h(activationIcon(detail.task), { size: 14 }), activationLabel(detail.task)),
|
|
2213
|
+
h(TaskActionsMenu, {
|
|
2214
|
+
task: detail.task,
|
|
2215
|
+
open: menuOpen,
|
|
2216
|
+
onToggle: () => setMenuOpen((current) => !current),
|
|
2217
|
+
onClose: () => setMenuOpen(false),
|
|
2218
|
+
onEdit: () => { setMenuOpen(false); onTab('config') },
|
|
2219
|
+
onAction: (target, id) => {
|
|
2220
|
+
if (id === 'run') void runNow()
|
|
2221
|
+
else if (id === 'copy') void copyTask()
|
|
2222
|
+
else if (id === 'activate' || id === 'pause') void toggleState()
|
|
2223
|
+
},
|
|
2224
|
+
onRequestConfirm: (kind, target) => { setMenuOpen(false); onRequestConfirm(kind, target) },
|
|
2225
|
+
canRun,
|
|
2226
|
+
running,
|
|
2227
|
+
busy: busy.length > 0,
|
|
2228
|
+
disabled: !storageReadyNow,
|
|
2229
|
+
align: 'end',
|
|
2230
|
+
}))),
|
|
2231
|
+
h('div', { className: 'capital-automation-detailtabs', role: 'tablist', 'aria-label': zh.details },
|
|
2232
|
+
[['overview', zh.overview], ['config', zh.config], ['runs', zh.runs], ['notifications', zh.notifications]].map(([id, label]) => h('button', {
|
|
2233
|
+
key: id,
|
|
2234
|
+
type: 'button',
|
|
2235
|
+
role: 'tab',
|
|
2236
|
+
className: 'capital-automation-detailtab',
|
|
2237
|
+
'aria-selected': tab === id ? 'true' : 'false',
|
|
2238
|
+
onClick: () => onTab(id),
|
|
2239
|
+
}, label))),
|
|
2240
|
+
notice.length > 0 || error.length > 0
|
|
2241
|
+
? h('div', { style: { paddingTop: 12 } },
|
|
2242
|
+
notice.length > 0 ? h('p', { className: 'capital-automation-notice', role: 'status' }, notice) : null,
|
|
2243
|
+
error.length > 0 ? h('p', { className: 'capital-automation-error', role: 'alert' }, error) : null)
|
|
2244
|
+
: null,
|
|
2245
|
+
running ? h('p', { className: 'capital-automation-hint', style: { paddingTop: 10 } }, zh.configWhileRunning) : null,
|
|
2246
|
+
h('div', { className: 'capital-automation-detailbody' },
|
|
2247
|
+
tab === 'overview' ? h(OverviewTab, {
|
|
2248
|
+
detail,
|
|
2249
|
+
meta,
|
|
2250
|
+
onGoRuns: () => onTab('runs'),
|
|
2251
|
+
onCancelRun: onRequestCancelRun,
|
|
2252
|
+
onOpenSession: openSession,
|
|
2253
|
+
}) : null,
|
|
2254
|
+
tab === 'config' ? h(ConfigTab, {
|
|
2255
|
+
draft,
|
|
2256
|
+
setDraft,
|
|
2257
|
+
meta,
|
|
2258
|
+
busy,
|
|
2259
|
+
dirty,
|
|
2260
|
+
save,
|
|
2261
|
+
reset: resetDraft,
|
|
2262
|
+
disabled: !storageReadyNow,
|
|
2263
|
+
}) : null,
|
|
2264
|
+
tab === 'runs' ? h('section', { className: 'capital-automation-card capital-automation-panel' },
|
|
2265
|
+
h('div', { className: 'capital-automation-panelhead' },
|
|
2266
|
+
h('h3', null, zh.runs),
|
|
2267
|
+
h('span', { className: 'capital-automation-hint' }, zh.taskRunsLimit)),
|
|
2268
|
+
h(RunList, {
|
|
2269
|
+
runs: detail.runs,
|
|
2270
|
+
tasks: [detail.task],
|
|
2271
|
+
onCancel: (run) => onRequestCancelRun(run),
|
|
2272
|
+
onOpenSession: openSession,
|
|
2273
|
+
busy: busy.length > 0,
|
|
2274
|
+
})) : null,
|
|
2275
|
+
tab === 'notifications' ? h(NotificationsTab, {
|
|
2276
|
+
detail,
|
|
2277
|
+
busy: busy.length > 0,
|
|
2278
|
+
onMarkTaskRead: () => { void markTaskRead() },
|
|
2279
|
+
}) : null))
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
function NewTaskModal(props) {
|
|
493
2283
|
const { open, onClose, api, onCreated, meta } = props
|
|
494
|
-
const [
|
|
2284
|
+
const [draft, setDraft] = useState(defaultDraft)
|
|
495
2285
|
const [busy, setBusy] = useState(false)
|
|
496
2286
|
const [error, setError] = useState('')
|
|
497
|
-
const [draft, setDraft] = useState({
|
|
498
|
-
title: '',
|
|
499
|
-
description: '',
|
|
500
|
-
instruction: '',
|
|
501
|
-
category: 'research',
|
|
502
|
-
trigger: { kind: 'schedule', cadence: 'daily', time: '09:00', timezone: 'Asia/Shanghai', tradingDaysOnly: true },
|
|
503
|
-
mode: 'research',
|
|
504
|
-
workspaceId: '',
|
|
505
|
-
limits: { runTimeoutMinutes: 30, idleTimeoutMinutes: 5, maxSteps: 300, maxToolCalls: 1200 },
|
|
506
|
-
notifications: { inApp: true, onFailure: true, onSuccess: false },
|
|
507
|
-
})
|
|
508
2287
|
useEffect(() => {
|
|
509
2288
|
if (!open) return
|
|
510
|
-
|
|
511
|
-
setError('')
|
|
2289
|
+
setDraft(defaultDraft())
|
|
512
2290
|
setBusy(false)
|
|
513
|
-
|
|
514
|
-
title: '',
|
|
515
|
-
description: '',
|
|
516
|
-
instruction: '',
|
|
517
|
-
category: 'research',
|
|
518
|
-
trigger: { kind: 'schedule', cadence: 'daily', time: '09:00', timezone: 'Asia/Shanghai', tradingDaysOnly: true },
|
|
519
|
-
mode: 'research',
|
|
520
|
-
workspaceId: '',
|
|
521
|
-
limits: { runTimeoutMinutes: 30, idleTimeoutMinutes: 5, maxSteps: 300, maxToolCalls: 1200 },
|
|
522
|
-
notifications: { inApp: true, onFailure: true, onSuccess: false },
|
|
523
|
-
})
|
|
2291
|
+
setError('')
|
|
524
2292
|
}, [open])
|
|
525
2293
|
const set = (patch) => setDraft((current) => ({
|
|
526
2294
|
...current,
|
|
527
2295
|
...(typeof patch === 'function' ? patch(current) : patch),
|
|
528
2296
|
}))
|
|
2297
|
+
const timeoutRange = limitValue(meta, 'runTimeoutMinutes', [5, 120])
|
|
2298
|
+
const idleRange = limitValue(meta, 'idleTimeoutMinutes', [1, 30])
|
|
2299
|
+
const stepsRange = limitValue(meta, 'maxSteps', [10, 2000])
|
|
2300
|
+
const toolsRange = limitValue(meta, 'maxToolCalls', [10, 6000])
|
|
529
2301
|
async function create() {
|
|
530
|
-
|
|
2302
|
+
const invalid = validateDraft(draft)
|
|
2303
|
+
if (invalid.length > 0) {
|
|
2304
|
+
setError(invalid)
|
|
2305
|
+
return
|
|
2306
|
+
}
|
|
531
2307
|
setBusy(true)
|
|
532
2308
|
setError('')
|
|
533
2309
|
try {
|
|
534
|
-
await api.create(
|
|
535
|
-
|
|
536
|
-
description: draft.description,
|
|
537
|
-
instruction: draft.instruction,
|
|
538
|
-
category: draft.category,
|
|
539
|
-
trigger: draft.trigger,
|
|
540
|
-
mode: draft.mode,
|
|
541
|
-
workspaceId: draft.workspaceId ?? '',
|
|
542
|
-
limits: draft.limits,
|
|
543
|
-
notifications: draft.notifications,
|
|
544
|
-
})
|
|
545
|
-
onCreated()
|
|
2310
|
+
const payload = await api.create(draftPayload(draft))
|
|
2311
|
+
onCreated(payload?.task?.id ?? null)
|
|
546
2312
|
} catch (failure) {
|
|
547
2313
|
setError(failure.message ?? zh.errorGeneric)
|
|
548
2314
|
} finally {
|
|
@@ -552,58 +2318,193 @@ function NewTaskWizard(props) {
|
|
|
552
2318
|
if (!open) return null
|
|
553
2319
|
return h(Modal, {
|
|
554
2320
|
open,
|
|
555
|
-
onClose,
|
|
556
|
-
title: zh.
|
|
2321
|
+
onClose: () => { if (!busy) onClose() },
|
|
2322
|
+
title: zh.newTaskTitle,
|
|
557
2323
|
closeLabel: zh.close,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
2324
|
+
className: 'capital-automation-modal',
|
|
2325
|
+
contentClassName: 'capital-automation-modal-content',
|
|
2326
|
+
footer: h('div', { className: 'capital-automation-formactions', style: { borderTop: 0, paddingTop: 0 } },
|
|
2327
|
+
h('button', { type: 'button', className: 'capital-automation-btn', disabled: busy, onClick: onClose }, zh.cancel),
|
|
2328
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-variant': 'primary', disabled: busy || meta?.storage?.state === 'unavailable', onClick: create }, busy ? zh.creating : zh.create)),
|
|
563
2329
|
},
|
|
564
2330
|
h('div', { className: 'capital-automation-wizard' },
|
|
565
|
-
h('div', { className: 'capital-automation-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
h('
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
2331
|
+
h('div', { className: 'capital-automation-modalheadline' },
|
|
2332
|
+
h(Glyph, { task: draft, size: 42 }),
|
|
2333
|
+
h('input', {
|
|
2334
|
+
className: 'capital-automation-modaltitleinput',
|
|
2335
|
+
value: draft.title,
|
|
2336
|
+
placeholder: zh.titlePlaceholder,
|
|
2337
|
+
'aria-label': zh.titleField,
|
|
2338
|
+
onChange: (event) => set({ title: event.target.value }),
|
|
2339
|
+
})),
|
|
2340
|
+
h('p', { className: 'capital-automation-hint' }, zh.newTaskHint),
|
|
2341
|
+
h(Field, { label: zh.descriptionField },
|
|
2342
|
+
h('input', {
|
|
2343
|
+
value: draft.description,
|
|
2344
|
+
placeholder: zh.descriptionPlaceholder,
|
|
2345
|
+
onChange: (event) => set({ description: event.target.value }),
|
|
2346
|
+
})),
|
|
2347
|
+
h('div', null,
|
|
2348
|
+
h('span', { className: 'capital-automation-formlabel' }, zh.triggerField),
|
|
2349
|
+
h(TriggerFields, { trigger: draft.trigger, onChange: (trigger) => set({ trigger }), meta })),
|
|
2350
|
+
h('div', null,
|
|
2351
|
+
h('span', { className: 'capital-automation-formlabel' }, zh.instructionField),
|
|
2352
|
+
h('div', { className: 'capital-automation-promptbox' },
|
|
2353
|
+
h('textarea', {
|
|
2354
|
+
value: draft.instruction,
|
|
2355
|
+
placeholder: zh.instructionPlaceholder,
|
|
2356
|
+
'aria-label': zh.instructionField,
|
|
2357
|
+
onChange: (event) => set({ instruction: event.target.value }),
|
|
2358
|
+
}),
|
|
2359
|
+
h('div', { className: 'capital-automation-prompttoolbar' },
|
|
2360
|
+
h('div', { className: 'capital-automation-toolbarfield' },
|
|
2361
|
+
h(IconFolderOpenOutlineRegular, { size: 13 }),
|
|
2362
|
+
h('span', null, zh.workspaceField),
|
|
2363
|
+
h(Select, {
|
|
2364
|
+
value: draft.workspaceId ?? '',
|
|
2365
|
+
options: workspaceOptions(meta, draft.workspaceId).map((option) => ({ value: option.id, label: option.title })),
|
|
2366
|
+
onChange: (workspaceId) => set({ workspaceId }),
|
|
2367
|
+
label: zh.workspaceField,
|
|
2368
|
+
size: 'sm',
|
|
2369
|
+
align: 'end',
|
|
2370
|
+
})),
|
|
2371
|
+
h('div', { className: 'capital-automation-toolbarfield' },
|
|
2372
|
+
h('span', null, zh.categoryField),
|
|
2373
|
+
h(Select, {
|
|
2374
|
+
value: draft.category,
|
|
2375
|
+
options: Object.entries(zh.category).map(([value, label]) => ({ value, label })),
|
|
2376
|
+
onChange: (category) => set({ category }),
|
|
2377
|
+
label: zh.categoryField,
|
|
2378
|
+
size: 'sm',
|
|
2379
|
+
align: 'end',
|
|
2380
|
+
})),
|
|
2381
|
+
h('div', { className: 'capital-automation-toolbarfield' },
|
|
2382
|
+
h('span', null, zh.modeField),
|
|
2383
|
+
h(Select, {
|
|
2384
|
+
value: draft.mode,
|
|
2385
|
+
options: Object.entries(zh.mode).map(([value, label]) => ({ value, label })),
|
|
2386
|
+
onChange: (mode) => set({ mode }),
|
|
2387
|
+
label: zh.modeField,
|
|
2388
|
+
size: 'sm',
|
|
2389
|
+
align: 'end',
|
|
2390
|
+
})),
|
|
2391
|
+
h('span', { className: 'capital-automation-presetchip', title: zh.modeHint },
|
|
2392
|
+
h(IconSparkleRegular, { size: 12 }),
|
|
2393
|
+
zh.presetValue)))),
|
|
2394
|
+
h('p', { className: 'capital-automation-hint' }, zh.modeHint),
|
|
2395
|
+
meta?.workspaceError ? h('p', { className: 'capital-automation-hint', 'data-tone': 'error' }, zh.workspaceUnavailable) : null,
|
|
2396
|
+
h('details', { className: 'capital-automation-advanced' },
|
|
2397
|
+
h('summary', null, zh.advanced),
|
|
2398
|
+
h('div', { className: 'capital-automation-advancedbody' },
|
|
2399
|
+
h('div', { className: 'capital-automation-formgrid' },
|
|
2400
|
+
h(NumberField, { label: zh.runTimeout, value: draft.limits.runTimeoutMinutes, min: timeoutRange[0], max: timeoutRange[1], onChange: (value) => set((current) => ({ limits: { ...current.limits, runTimeoutMinutes: value } })) }),
|
|
2401
|
+
h(NumberField, { label: zh.idleTimeout, value: draft.limits.idleTimeoutMinutes, min: idleRange[0], max: idleRange[1], onChange: (value) => set((current) => ({ limits: { ...current.limits, idleTimeoutMinutes: value } })) }),
|
|
2402
|
+
h(NumberField, { label: zh.maxSteps, value: draft.limits.maxSteps, min: stepsRange[0], max: stepsRange[1], onChange: (value) => set((current) => ({ limits: { ...current.limits, maxSteps: value } })) }),
|
|
2403
|
+
h(NumberField, { label: zh.maxToolCalls, value: draft.limits.maxToolCalls, min: toolsRange[0], max: toolsRange[1], onChange: (value) => set((current) => ({ limits: { ...current.limits, maxToolCalls: value } })) })),
|
|
2404
|
+
h('p', { className: 'capital-automation-hint' }, zh.advancedHint))),
|
|
2405
|
+
h('div', null,
|
|
2406
|
+
h('span', { className: 'capital-automation-formlabel' }, zh.notifyField),
|
|
2407
|
+
h('div', { className: 'capital-automation-switchlist' },
|
|
2408
|
+
h(SwitchRow, { label: zh.notifyInApp, checked: draft.notifications.inApp, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, inApp: value } })) }),
|
|
2409
|
+
h(SwitchRow, { label: zh.notifyFailure, checked: draft.notifications.onFailure, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, onFailure: value } })) }),
|
|
2410
|
+
h(SwitchRow, { label: zh.notifySuccess, checked: draft.notifications.onSuccess, onChange: (value) => set((current) => ({ notifications: { ...current.notifications, onSuccess: value } })) })),
|
|
2411
|
+
h('p', { className: 'capital-automation-hint' }, zh.notifyHint)),
|
|
2412
|
+
error.length > 0 ? h('p', { className: 'capital-automation-error', role: 'alert' }, error) : null))
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
function ConfirmModal(props) {
|
|
2416
|
+
const { confirm, busy, error, onCancel, onConfirm } = props
|
|
2417
|
+
const open = confirm !== null
|
|
2418
|
+
const cancelling = confirm?.kind === 'cancel-run'
|
|
2419
|
+
const deleting = confirm?.kind === 'delete'
|
|
2420
|
+
const title = cancelling ? zh.cancelRunConfirmTitle : deleting ? zh.confirmDeleteTitle : zh.confirmHibernateTitle
|
|
2421
|
+
const body = cancelling ? zh.cancelRunConfirmBody : deleting ? zh.confirmDeleteBody : zh.confirmHibernateBody
|
|
2422
|
+
const confirmLabel = cancelling ? zh.cancelRunConfirm : deleting ? zh.confirmDelete : zh.confirmHibernate
|
|
2423
|
+
return h(Modal, {
|
|
2424
|
+
open,
|
|
2425
|
+
onClose: () => { if (!busy) onCancel() },
|
|
2426
|
+
title,
|
|
2427
|
+
closeLabel: zh.close,
|
|
2428
|
+
className: 'capital-automation-modal capital-automation-modal-narrow',
|
|
2429
|
+
footer: h('div', { className: 'capital-automation-formactions', style: { borderTop: 0, paddingTop: 0 } },
|
|
2430
|
+
h('button', { type: 'button', className: 'capital-automation-btn', disabled: busy, onClick: onCancel }, zh.cancel),
|
|
2431
|
+
h('button', {
|
|
2432
|
+
type: 'button',
|
|
2433
|
+
className: 'capital-automation-btn',
|
|
2434
|
+
'data-variant': 'danger',
|
|
2435
|
+
disabled: busy,
|
|
2436
|
+
onClick: onConfirm,
|
|
2437
|
+
}, busy ? zh.processing : confirmLabel)),
|
|
2438
|
+
},
|
|
2439
|
+
h('div', null,
|
|
2440
|
+
h('p', { className: 'capital-automation-policy' }, body),
|
|
2441
|
+
error.length > 0 ? h('p', { className: 'capital-automation-error', role: 'alert', style: { marginTop: 8 } }, error) : null))
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
function InboxModal(props) {
|
|
2445
|
+
const { open, onClose, notifications, onMarkAllRead, onOpenTask, busy } = props
|
|
2446
|
+
const unread = notifications.filter((item) => item.readAt === undefined).length
|
|
2447
|
+
return h(Modal, {
|
|
2448
|
+
open,
|
|
2449
|
+
onClose,
|
|
2450
|
+
title: zh.notificationsTitle,
|
|
2451
|
+
closeLabel: zh.close,
|
|
2452
|
+
className: 'capital-automation-modal',
|
|
2453
|
+
contentClassName: 'capital-automation-modal-content',
|
|
2454
|
+
footer: h('div', { className: 'capital-automation-formactions', style: { borderTop: 0, paddingTop: 0 } },
|
|
2455
|
+
h('span', { className: 'capital-automation-formstatus' },
|
|
2456
|
+
unread > 0 ? zh.notificationsUnread.replace('{n}', String(unread)) : notifications.length > 0 ? zh.allRead : zh.notificationsEmpty),
|
|
2457
|
+
h('button', { type: 'button', className: 'capital-automation-btn', disabled: busy || unread === 0, onClick: onMarkAllRead }, zh.markRead),
|
|
2458
|
+
h('button', { type: 'button', className: 'capital-automation-btn', 'data-variant': 'primary', onClick: onClose }, zh.close)),
|
|
2459
|
+
},
|
|
2460
|
+
notifications.length === 0
|
|
2461
|
+
? h('div', { className: 'capital-automation-empty' },
|
|
2462
|
+
h('span', { className: 'capital-automation-emptyicon' }, h(IconAlarmClockOutlineRegular, { size: 19 })),
|
|
2463
|
+
h('h3', null, zh.notificationsEmpty),
|
|
2464
|
+
h('p', null, zh.notificationsHint))
|
|
2465
|
+
: h('div', null,
|
|
2466
|
+
h('p', { className: 'capital-automation-hint', style: { marginBottom: 4 } }, zh.notificationsHint),
|
|
2467
|
+
notifications.map((item) => h(NotificationItem, {
|
|
2468
|
+
key: item.id,
|
|
2469
|
+
item,
|
|
2470
|
+
onOpenTask: onOpenTask,
|
|
2471
|
+
onClick: item.taskId === undefined ? undefined : () => onOpenTask(item.taskId),
|
|
2472
|
+
}))))
|
|
592
2473
|
}
|
|
593
2474
|
|
|
594
2475
|
function AutomationPage(props) {
|
|
595
2476
|
const { api, openSession } = props
|
|
596
2477
|
const [meta, setMeta] = useState(null)
|
|
597
2478
|
const [tasks, setTasks] = useState([])
|
|
2479
|
+
const [runs, setRuns] = useState([])
|
|
2480
|
+
const [notifications, setNotifications] = useState([])
|
|
2481
|
+
const [unread, setUnread] = useState(0)
|
|
598
2482
|
const [selectedId, setSelectedId] = useState(null)
|
|
599
2483
|
const [detail, setDetail] = useState(null)
|
|
2484
|
+
const [tab, setTab] = useState('tasks')
|
|
2485
|
+
const [detailTab, setDetailTab] = useState('overview')
|
|
600
2486
|
const [wizard, setWizard] = useState(false)
|
|
2487
|
+
const [inbox, setInbox] = useState(false)
|
|
2488
|
+
const [confirm, setConfirm] = useState(null)
|
|
2489
|
+
const [confirmBusy, setConfirmBusy] = useState(false)
|
|
2490
|
+
const [confirmError, setConfirmError] = useState('')
|
|
2491
|
+
const [busyTaskId, setBusyTaskId] = useState(null)
|
|
2492
|
+
const [inboxBusy, setInboxBusy] = useState(false)
|
|
2493
|
+
const [notice, setNotice] = useState('')
|
|
601
2494
|
const [loadError, setLoadError] = useState('')
|
|
602
2495
|
const mountedRef = useRef(false)
|
|
2496
|
+
const tasksRef = useRef([])
|
|
603
2497
|
const selectedIdRef = useRef(null)
|
|
604
2498
|
const refreshInFlightRef = useRef(null)
|
|
605
2499
|
const refreshSequenceRef = useRef(0)
|
|
606
2500
|
const detailSequenceRef = useRef(0)
|
|
2501
|
+
const scrollRef = useRef(null)
|
|
2502
|
+
|
|
2503
|
+
useEffect(() => {
|
|
2504
|
+
if (notice.length === 0) return undefined
|
|
2505
|
+
const timer = setTimeout(() => setNotice(''), 3_200)
|
|
2506
|
+
return () => clearTimeout(timer)
|
|
2507
|
+
}, [notice])
|
|
607
2508
|
|
|
608
2509
|
async function refresh() {
|
|
609
2510
|
if (refreshInFlightRef.current !== null) return refreshInFlightRef.current
|
|
@@ -611,21 +2512,29 @@ function AutomationPage(props) {
|
|
|
611
2512
|
refreshSequenceRef.current = requestSequence
|
|
612
2513
|
const request = (async () => {
|
|
613
2514
|
try {
|
|
614
|
-
const [nextMeta, nextTasks] = await Promise.all([
|
|
2515
|
+
const [nextMeta, nextTasks, nextRuns, nextNotifications] = await Promise.all([
|
|
2516
|
+
api.meta(),
|
|
2517
|
+
api.tasks(),
|
|
2518
|
+
api.runs('?limit=200'),
|
|
2519
|
+
api.notifications(),
|
|
2520
|
+
])
|
|
615
2521
|
if (!mountedRef.current || requestSequence !== refreshSequenceRef.current) return
|
|
616
2522
|
const nextTaskList = Array.isArray(nextTasks.tasks) ? nextTasks.tasks : []
|
|
617
2523
|
setMeta(nextMeta)
|
|
2524
|
+
tasksRef.current = nextTaskList
|
|
618
2525
|
setTasks(nextTaskList)
|
|
2526
|
+
setRuns(Array.isArray(nextRuns.runs) ? nextRuns.runs : [])
|
|
2527
|
+
setNotifications(Array.isArray(nextNotifications.notifications) ? nextNotifications.notifications : [])
|
|
2528
|
+
setUnread(typeof nextNotifications.unread === 'number' ? nextNotifications.unread : 0)
|
|
619
2529
|
setLoadError('')
|
|
620
2530
|
const currentId = selectedIdRef.current
|
|
621
|
-
const nextId = currentId !== null && nextTaskList.some((task) => task.id === currentId)
|
|
622
|
-
? currentId
|
|
623
|
-
: (nextTaskList[0]?.id ?? null)
|
|
2531
|
+
const nextId = currentId !== null && nextTaskList.some((task) => task.id === currentId) ? currentId : null
|
|
624
2532
|
if (nextId !== currentId) {
|
|
625
2533
|
selectedIdRef.current = nextId
|
|
626
2534
|
detailSequenceRef.current += 1
|
|
627
2535
|
setDetail(null)
|
|
628
2536
|
setSelectedId(nextId)
|
|
2537
|
+
if (nextId === null) setDetailTab('overview')
|
|
629
2538
|
}
|
|
630
2539
|
} catch (error) {
|
|
631
2540
|
if (mountedRef.current && requestSequence === refreshSequenceRef.current) {
|
|
@@ -655,12 +2564,129 @@ function AutomationPage(props) {
|
|
|
655
2564
|
}
|
|
656
2565
|
}
|
|
657
2566
|
|
|
658
|
-
function
|
|
659
|
-
|
|
2567
|
+
function scrollToTop() {
|
|
2568
|
+
const node = scrollRef.current
|
|
2569
|
+
if (node !== null && typeof node.scrollTo === 'function') node.scrollTo({ top: 0, behavior: 'auto' })
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
function selectTask(id, nextTab = 'overview') {
|
|
660
2573
|
selectedIdRef.current = id
|
|
661
2574
|
detailSequenceRef.current += 1
|
|
2575
|
+
setDetailTab(nextTab)
|
|
662
2576
|
setDetail(null)
|
|
663
2577
|
setSelectedId(id)
|
|
2578
|
+
setTab('tasks')
|
|
2579
|
+
scrollToTop()
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
function backToTasks() {
|
|
2583
|
+
selectedIdRef.current = null
|
|
2584
|
+
detailSequenceRef.current += 1
|
|
2585
|
+
setDetail(null)
|
|
2586
|
+
setSelectedId(null)
|
|
2587
|
+
setDetailTab('overview')
|
|
2588
|
+
scrollToTop()
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
function switchTab(nextTab) {
|
|
2592
|
+
if (nextTab === tab && nextTab === 'tasks' && selectedIdRef.current !== null) return
|
|
2593
|
+
if (nextTab === 'runs' && selectedIdRef.current !== null) {
|
|
2594
|
+
selectedIdRef.current = null
|
|
2595
|
+
detailSequenceRef.current += 1
|
|
2596
|
+
setDetail(null)
|
|
2597
|
+
setSelectedId(null)
|
|
2598
|
+
}
|
|
2599
|
+
setTab(nextTab)
|
|
2600
|
+
scrollToTop()
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
function requestConfirm(kind, task, run) {
|
|
2604
|
+
setConfirmError('')
|
|
2605
|
+
setConfirm({ kind, task, run })
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
async function performTaskAction(task, action) {
|
|
2609
|
+
if (busyTaskId !== null) return
|
|
2610
|
+
setBusyTaskId(task.id)
|
|
2611
|
+
setLoadError('')
|
|
2612
|
+
try {
|
|
2613
|
+
if (action === 'run') {
|
|
2614
|
+
await api.run(task.id)
|
|
2615
|
+
setNotice(zh.runSubmitted.replace('{title}', task.title))
|
|
2616
|
+
} else if (action === 'copy') {
|
|
2617
|
+
const payload = await api.action(task.id, 'copy')
|
|
2618
|
+
setNotice(zh.copied.replace('{title}', task.title))
|
|
2619
|
+
if (payload?.task?.id) {
|
|
2620
|
+
await refresh()
|
|
2621
|
+
selectTask(payload.task.id, 'config')
|
|
2622
|
+
return
|
|
2623
|
+
}
|
|
2624
|
+
} else {
|
|
2625
|
+
await api.action(task.id, action)
|
|
2626
|
+
setNotice(action === 'pause' ? zh.paused.replace('{title}', task.title) : activationNotice(task))
|
|
2627
|
+
}
|
|
2628
|
+
await refresh()
|
|
2629
|
+
if (selectedIdRef.current === task.id) await loadDetail(task.id)
|
|
2630
|
+
} catch (failure) {
|
|
2631
|
+
setLoadError(failure.message ?? zh.errorGeneric)
|
|
2632
|
+
} finally {
|
|
2633
|
+
setBusyTaskId(null)
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
async function enableTemplate(task) {
|
|
2638
|
+
await performTaskAction(task, 'activate')
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
async function confirmAction() {
|
|
2642
|
+
if (confirm === null || confirmBusy) return
|
|
2643
|
+
const { kind, task } = confirm
|
|
2644
|
+
setConfirmBusy(true)
|
|
2645
|
+
setConfirmError('')
|
|
2646
|
+
try {
|
|
2647
|
+
if (kind === 'cancel-run') {
|
|
2648
|
+
await api.cancel(confirm.run.id)
|
|
2649
|
+
setNotice(zh.runCanceled)
|
|
2650
|
+
} else if (kind === 'delete') {
|
|
2651
|
+
await api.remove(task.id)
|
|
2652
|
+
setNotice(zh.deleted.replace('{title}', task.title))
|
|
2653
|
+
} else {
|
|
2654
|
+
await api.action(task.id, 'hibernate')
|
|
2655
|
+
setNotice(zh.hibernated.replace('{title}', task.title))
|
|
2656
|
+
}
|
|
2657
|
+
setConfirm(null)
|
|
2658
|
+
setConfirmError('')
|
|
2659
|
+
await refresh()
|
|
2660
|
+
if (selectedIdRef.current === task.id) await loadDetail(task.id)
|
|
2661
|
+
} catch (failure) {
|
|
2662
|
+
setConfirmError(failure.message ?? zh.errorGeneric)
|
|
2663
|
+
} finally {
|
|
2664
|
+
setConfirmBusy(false)
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
async function markAllRead() {
|
|
2669
|
+
if (inboxBusy) return
|
|
2670
|
+
setInboxBusy(true)
|
|
2671
|
+
try {
|
|
2672
|
+
await api.markRead({ all: true })
|
|
2673
|
+
setNotice(zh.markReadDone)
|
|
2674
|
+
await refresh()
|
|
2675
|
+
} catch (failure) {
|
|
2676
|
+
setLoadError(failure.message ?? zh.errorGeneric)
|
|
2677
|
+
} finally {
|
|
2678
|
+
setInboxBusy(false)
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
async function openTaskFromNotification(taskId) {
|
|
2683
|
+
setInbox(false)
|
|
2684
|
+
if (tasksRef.current.some((task) => task.id === taskId)) {
|
|
2685
|
+
selectTask(taskId)
|
|
2686
|
+
return
|
|
2687
|
+
}
|
|
2688
|
+
await refresh()
|
|
2689
|
+
if (tasksRef.current.some((task) => task.id === taskId)) selectTask(taskId)
|
|
664
2690
|
}
|
|
665
2691
|
|
|
666
2692
|
useEffect(() => {
|
|
@@ -694,53 +2720,108 @@ function AutomationPage(props) {
|
|
|
694
2720
|
return () => { detailSequenceRef.current += 1 }
|
|
695
2721
|
}, [selectedId])
|
|
696
2722
|
|
|
697
|
-
const
|
|
698
|
-
const schedulerState = meta?.scheduler?.state
|
|
2723
|
+
const schedulerActive = meta?.scheduler?.state === 'active'
|
|
699
2724
|
const storageReady = meta?.storage?.state !== 'unavailable'
|
|
2725
|
+
const templates = tasks.filter((task) => task.origin === 'builtin' && task.state === 'dormant')
|
|
2726
|
+
const selectedTask = tasks.find((task) => task.id === selectedId)
|
|
2727
|
+
const detailOpen = tab === 'tasks' && selectedId !== null
|
|
2728
|
+
// `/meta` arrives in the same batch as `/tasks`; until then the empty state would be a lie.
|
|
2729
|
+
const initialLoading = meta === null && loadError.length === 0
|
|
2730
|
+
|
|
700
2731
|
return h('div', { className: 'capital-automation-page' },
|
|
701
|
-
h('
|
|
702
|
-
h('
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
2732
|
+
h('datalist', { id: 'capital-automation-timezones' },
|
|
2733
|
+
TIMEZONES.map((zone) => h('option', { key: zone, value: zone }))),
|
|
2734
|
+
detailOpen ? null : h(Header, {
|
|
2735
|
+
tab,
|
|
2736
|
+
onTab: switchTab,
|
|
2737
|
+
onNewTask: () => setWizard(true),
|
|
2738
|
+
unread,
|
|
2739
|
+
onOpenInbox: () => setInbox(true),
|
|
2740
|
+
}),
|
|
2741
|
+
h(PageBanners, { meta, loadError, onRetry: () => { void refresh() } }),
|
|
2742
|
+
h('div', { className: 'capital-automation-scroll', ref: scrollRef },
|
|
2743
|
+
h('div', { className: 'capital-automation-container' },
|
|
2744
|
+
tab === 'tasks'
|
|
2745
|
+
? selectedId !== null
|
|
2746
|
+
? h('div', null,
|
|
2747
|
+
h(DetailBar, { onBack: backToTasks }),
|
|
2748
|
+
detail === null
|
|
2749
|
+
? h('div', { className: 'capital-automation-empty' }, zh.loading)
|
|
2750
|
+
: h(TaskDetailPage, {
|
|
2751
|
+
detail,
|
|
2752
|
+
meta,
|
|
2753
|
+
api,
|
|
2754
|
+
openSession,
|
|
2755
|
+
tab: detailTab,
|
|
2756
|
+
onTab: setDetailTab,
|
|
2757
|
+
onRequestConfirm: requestConfirm,
|
|
2758
|
+
onRequestCancelRun: (run) => requestConfirm('cancel-run', selectedTask ?? { id: run.taskId, title: run.taskTitle }, run),
|
|
2759
|
+
schedulerActive,
|
|
2760
|
+
storageReady,
|
|
2761
|
+
onChanged: async (taskId) => {
|
|
2762
|
+
await refresh()
|
|
2763
|
+
const id = taskId ?? selectedIdRef.current
|
|
2764
|
+
if (id !== null && selectedIdRef.current === id) await loadDetail(id)
|
|
2765
|
+
},
|
|
2766
|
+
}))
|
|
2767
|
+
: initialLoading
|
|
2768
|
+
? h(TaskDashboardSkeleton)
|
|
2769
|
+
: h(TaskDashboard, {
|
|
2770
|
+
tasks,
|
|
2771
|
+
templates,
|
|
2772
|
+
runs,
|
|
2773
|
+
onOpenTask: selectTask,
|
|
2774
|
+
onNewTask: () => setWizard(true),
|
|
2775
|
+
onEnableTemplate: (task) => { void enableTemplate(task) },
|
|
2776
|
+
onAction: (task, action) => { void performTaskAction(task, action) },
|
|
2777
|
+
onRequestConfirm: requestConfirm,
|
|
2778
|
+
onEdit: (id) => selectTask(id, 'config'),
|
|
2779
|
+
onGoRuns: () => switchTab('runs'),
|
|
2780
|
+
onRequestCancelRun: (task, run) => requestConfirm('cancel-run', task, run),
|
|
2781
|
+
schedulerActive,
|
|
2782
|
+
storageReady,
|
|
2783
|
+
busyTaskId,
|
|
2784
|
+
})
|
|
2785
|
+
: initialLoading
|
|
2786
|
+
? h(RunsSkeleton)
|
|
2787
|
+
: h(RunsPage, {
|
|
2788
|
+
runs,
|
|
2789
|
+
tasks,
|
|
2790
|
+
onCancel: (run) => requestConfirm('cancel-run', { id: run.taskId, title: run.taskTitle }, run),
|
|
2791
|
+
onOpenSession: openSession,
|
|
2792
|
+
onOpenTask: (id) => { if (tasksRef.current.some((task) => task.id === id)) selectTask(id) },
|
|
2793
|
+
onGoTasks: () => switchTab('tasks'),
|
|
2794
|
+
onNewTask: () => setWizard(true),
|
|
2795
|
+
busy: confirmBusy,
|
|
2796
|
+
}))),
|
|
2797
|
+
h(NewTaskModal, {
|
|
735
2798
|
open: wizard,
|
|
736
2799
|
onClose: () => setWizard(false),
|
|
737
2800
|
api,
|
|
738
2801
|
meta,
|
|
739
|
-
onCreated: async () => {
|
|
2802
|
+
onCreated: async (taskId) => {
|
|
740
2803
|
setWizard(false)
|
|
2804
|
+
setNotice(zh.created)
|
|
741
2805
|
await refresh()
|
|
2806
|
+
if (taskId !== null && tasksRef.current.some((task) => task.id === taskId)) selectTask(taskId)
|
|
742
2807
|
},
|
|
743
|
-
})
|
|
2808
|
+
}),
|
|
2809
|
+
h(InboxModal, {
|
|
2810
|
+
open: inbox,
|
|
2811
|
+
onClose: () => setInbox(false),
|
|
2812
|
+
notifications,
|
|
2813
|
+
onMarkAllRead: () => { void markAllRead() },
|
|
2814
|
+
onOpenTask: (taskId) => { void openTaskFromNotification(taskId) },
|
|
2815
|
+
busy: inboxBusy,
|
|
2816
|
+
}),
|
|
2817
|
+
h(ConfirmModal, {
|
|
2818
|
+
confirm,
|
|
2819
|
+
busy: confirmBusy,
|
|
2820
|
+
error: confirmError,
|
|
2821
|
+
onCancel: () => { if (!confirmBusy) { setConfirm(null); setConfirmError('') } },
|
|
2822
|
+
onConfirm: () => { void confirmAction() },
|
|
2823
|
+
}),
|
|
2824
|
+
notice.length > 0 ? h('div', { className: 'capital-automation-toast', role: 'status' }, notice) : null)
|
|
744
2825
|
}
|
|
745
2826
|
|
|
746
2827
|
function AutomationIcon() {
|
|
@@ -761,13 +2842,13 @@ function apply(ctx) {
|
|
|
761
2842
|
ctx.slots.inject('main', () => ctx.slots.register({
|
|
762
2843
|
name: 'main',
|
|
763
2844
|
key: PANEL_ID,
|
|
764
|
-
|
|
2845
|
+
inject: () => ({ api, openSession }),
|
|
765
2846
|
}, AutomationPage))
|
|
766
2847
|
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
767
2848
|
name: 'sidebar.panellist',
|
|
768
2849
|
id: PANEL_ID,
|
|
769
2850
|
order: 11,
|
|
770
|
-
|
|
2851
|
+
label: () => zh.panel,
|
|
771
2852
|
}, AutomationIcon))
|
|
772
2853
|
ctx.logger?.info?.(`${ENTRY_NAME}: 客户端半边已挂载(页面 + 侧栏入口)`)
|
|
773
2854
|
}
|