dsh-codearts-dock 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER.md +47 -0
- package/LICENSE +21 -0
- package/README.md +169 -2
- package/SECURITY.md +45 -0
- package/THIRD_PARTY_NOTICES.md +64 -0
- package/client.js +3491 -0
- package/cordis.patch.yml +10 -0
- package/docs/DETAIL.md +24 -0
- package/docs/DETAIL.zh.md +24 -0
- package/docs/PUBLISHING.md +43 -0
- package/docs/preview.svg +78 -0
- package/icons/dsh-connect-codearts-128.png +0 -0
- package/icons/dsh-connect-codearts-256.png +0 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +88 -4
- package/scripts/build-market-index.mjs +24 -0
- package/scripts/check-legal.sh +33 -0
- package/scripts/check-release.mjs +29 -0
- package/scripts/test.mjs +11 -0
- package/src/account.js +217 -0
- package/src/accounts.js +481 -0
- package/src/adapter.js +715 -0
- package/src/backup.js +89 -0
- package/src/catalog.js +269 -0
- package/src/checkin.js +271 -0
- package/src/credentials.js +435 -0
- package/src/features.js +79 -0
- package/src/gateway.js +521 -0
- package/src/health.js +15 -0
- package/src/index.js +1029 -0
- package/src/models.js +147 -0
- package/src/paths.js +36 -0
- package/src/preferences.js +87 -0
- package/src/protocol/crypto.js +160 -0
- package/src/protocol/sign.js +176 -0
- package/src/protocol/sm4.js +264 -0
- package/src/protocol/sse.js +134 -0
- package/src/sts.js +118 -0
- package/test/accounts.test.mjs +344 -0
- package/test/adapter.test.mjs +234 -0
- package/test/assembler.test.mjs +86 -0
- package/test/features.test.mjs +240 -0
- package/test/live-probe.mjs +55 -0
- package/test/protocol.test.mjs +167 -0
- package/test/registration.test.mjs +303 -0
- package/test/sm4.test.mjs +64 -0
- package/test/ui.test.mjs +732 -0
- package/test/visual.test.mjs +420 -0
package/client.js
ADDED
|
@@ -0,0 +1,3491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of the 码道 connector.
|
|
3
|
+
*
|
|
4
|
+
* Two surfaces, both inside slots the Host already allocates:
|
|
5
|
+
*
|
|
6
|
+
* • a settings page (`settings.section`) for credentials, the model
|
|
7
|
+
* catalog, and diagnostics;
|
|
8
|
+
* • a credit chip beside the composer (`conversation.composer.dock`) that
|
|
9
|
+
* stays out of the way unless a 码道 model is selected.
|
|
10
|
+
*
|
|
11
|
+
* The Host half does all gateway work; this file only reads the small JSON
|
|
12
|
+
* routes under `/plugins/dsh-connect-codearts/`. Nothing here touches
|
|
13
|
+
* credentials beyond posting them once.
|
|
14
|
+
*
|
|
15
|
+
* Written as a plain-JS module for the Client module table: React comes from
|
|
16
|
+
* the browser module table, no bundler and no duplicate React install.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
window.__ModuleLoader__.load({
|
|
20
|
+
id: 'dsh-codearts-dock',
|
|
21
|
+
factory(require) {
|
|
22
|
+
const module = { exports: {} }
|
|
23
|
+
const exports = module.exports
|
|
24
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
25
|
+
|
|
26
|
+
const React = require('react')
|
|
27
|
+
|
|
28
|
+
const h = React.createElement
|
|
29
|
+
const { useState, useEffect, useCallback, useRef } = React
|
|
30
|
+
|
|
31
|
+
/** Route root served by the plugin's Host half. */
|
|
32
|
+
const ROUTE = '/plugins/dsh-connect-codearts'
|
|
33
|
+
|
|
34
|
+
/** Provider route this plugin owns; the chip only shows for these models. */
|
|
35
|
+
const PROVIDER_ID = 'codearts'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The settings-nav glyph.
|
|
39
|
+
*
|
|
40
|
+
* Embedded as a data URL rather than fetched from the package's icon file:
|
|
41
|
+
* a Client module cannot import assets, and fetching at paint time would
|
|
42
|
+
* leave the nav row blank until the request resolved. 64px covers 2x/3x
|
|
43
|
+
* displays; the 128px source would add 26 KB for detail nobody can see at
|
|
44
|
+
* a 16px edge.
|
|
45
|
+
*/
|
|
46
|
+
const NAV_ICON = 'data:image/png;base64,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'
|
|
47
|
+
|
|
48
|
+
/** Localisation text, with an English fallback per key. */
|
|
49
|
+
const STRINGS = {
|
|
50
|
+
'time.justNow': ['刚刚', 'Just now'],
|
|
51
|
+
'time.minutesAgo': ['{count} 分钟前', '{count} min ago'],
|
|
52
|
+
'time.hoursAgo': ['{count} 小时前', '{count} hr ago'],
|
|
53
|
+
'time.daysAgo': ['{count} 天前', '{count} days ago'],
|
|
54
|
+
'health.details': ['查看异常详情', 'View error details'],
|
|
55
|
+
'presets.saveAs': ['保存为预设', 'Save as preset'],
|
|
56
|
+
'presets.details': ['配置详情', 'Configuration details'],
|
|
57
|
+
'backup.mode': ['备份操作', 'Backup action'],
|
|
58
|
+
'backup.encrypt': ['加密备份', 'Encrypt backup'],
|
|
59
|
+
'backup.encryptionRequired': ['含账号凭证,必须加密。', 'Credentials require encryption.'],
|
|
60
|
+
'backup.paste': ['粘贴 JSON(高级)', 'Paste JSON (advanced)'],
|
|
61
|
+
'backup.selected': ['已选择:{name}', 'Selected: {name}'],
|
|
62
|
+
'backup.encrypted': ['加密备份', 'Encrypted backup'],
|
|
63
|
+
'backup.plain': ['未加密备份', 'Unencrypted backup'],
|
|
64
|
+
'backup.importHint': ['选择备份文件,再预览将恢复的配置。', 'Choose a backup file, then preview the changes.'],
|
|
65
|
+
'backup.pasted': ['已粘贴备份内容', 'Backup contents pasted'],
|
|
66
|
+
'health.updateHint': ['更新「{name}」:填写同一个 AK 和新的 SK,将更新已有账号。', 'Update {name}: enter the same AK and the new SK to update the existing account.'],
|
|
67
|
+
"features.saved": ["已保存", "Saved"],
|
|
68
|
+
"health.available": ["可用", "Available"],
|
|
69
|
+
"health.insufficient": ["余额不足", "Insufficient credits"],
|
|
70
|
+
"health.credentials": ["凭证失效或权限不足", "Invalid credentials or permissions"],
|
|
71
|
+
"health.rate_limited": ["被限流", "Rate limited"],
|
|
72
|
+
"health.network": ["网络异常", "Network error"],
|
|
73
|
+
"health.gateway": ["上游异常", "Gateway error"],
|
|
74
|
+
"health.unknown": ["状态未确认", "Status unknown"],
|
|
75
|
+
"health.checked": ["最近检查", "Last checked"],
|
|
76
|
+
"health.recheck": ["重新检查", "Recheck"],
|
|
77
|
+
"health.update": ["更新凭证", "Update credentials"],
|
|
78
|
+
"health.switch": ["可切换备用账号", "Switch to a backup account"],
|
|
79
|
+
"models.imagesOnly": ["支持图片", "Image input"],
|
|
80
|
+
"models.reasoningOnly": ["支持推理", "Reasoning"],
|
|
81
|
+
"presets.title": ["模型配置预设", "Model presets"],
|
|
82
|
+
"presets.choose": ["选择预设…", "Choose a preset…"],
|
|
83
|
+
"presets.daily": ["日常低倍率", "Everyday / lower multiplier"],
|
|
84
|
+
"presets.deep": ["深度推理", "Deep reasoning"],
|
|
85
|
+
"presets.images": ["图片任务", "Image tasks"],
|
|
86
|
+
"presets.preview": ["预览配置", "Preview configuration"],
|
|
87
|
+
"presets.previewHint": ["预览:将启用 {count} 个模型。应用后仍需点击保存。", "Preview: {count} models will be enabled. Save after applying."],
|
|
88
|
+
"presets.apply": ["应用到草稿", "Apply to draft"],
|
|
89
|
+
"presets.applied": ["预设已应用到草稿,请确认后保存。", "Preset applied to draft. Review and save."],
|
|
90
|
+
"presets.name": ["预设名称", "Preset name"],
|
|
91
|
+
"presets.save": ["保存当前草稿为预设", "Save current draft as preset"],
|
|
92
|
+
"presets.delete": ["删除预设", "Delete preset"],
|
|
93
|
+
"presets.deleteConfirm": ["删除这个模型预设?当前模型配置不会改变。", "Delete this preset? Current model settings will remain."],
|
|
94
|
+
"presets.noModels": ["这套预设没有可用模型", "No available models for this preset"],
|
|
95
|
+
"presets.missing": ["部分模型已不在当前目录中,应用时只保留可用模型。", "Some models are no longer in the catalog; only available models will be applied."],
|
|
96
|
+
"backup.title": ["配置备份与迁移", "Configuration backup and migration"],
|
|
97
|
+
"backup.hint": ["包含模型选择、能力开关、推理强度、预设和其他偏好。账号凭证可选,勾选后必须设置密码加密。", "Includes model selection, capabilities, reasoning, presets and other preferences. Credentials are optional and require password encryption."],
|
|
98
|
+
"backup.export": ["导出配置", "Export configuration"],
|
|
99
|
+
"backup.include": ["包含账号凭证(AK/SK)", "Include account credentials (AK/SK)"],
|
|
100
|
+
"backup.exportPassword": ["加密密码", "Encryption password"],
|
|
101
|
+
"backup.confirmPassword": ["确认加密密码", "Confirm encryption password"],
|
|
102
|
+
"backup.passwordHint": ["密码至少 8 位,两次输入需一致。请妥善保存密码。", "Use at least 8 characters and matching passwords. Keep the password safe."],
|
|
103
|
+
"backup.download": ["下载备份", "Download backup"],
|
|
104
|
+
"backup.exported": ["备份已生成并开始下载。", "Backup generated; download started."],
|
|
105
|
+
"backup.restore": ["恢复配置", "Restore configuration"],
|
|
106
|
+
"backup.choose": ["选择备份文件", "Choose backup file"],
|
|
107
|
+
"backup.content": ["备份内容(也可粘贴 JSON)", "Backup contents (or paste JSON)"],
|
|
108
|
+
"backup.importPassword": ["解密密码", "Decryption password"],
|
|
109
|
+
"backup.preview": ["读取并预览", "Read and preview"],
|
|
110
|
+
"backup.summary": ["将更新 {settings} 项配置,新增 {added} 个账号,更新 {updated} 个账号。", "Updates {settings} settings, adds {added} accounts and updates {updated} accounts."],
|
|
111
|
+
"backup.mergeHint": ["配置将以备份为准;账号按 AK 合并,不移除现有账号。", "Settings follow the backup; accounts merge by AK without removing existing accounts."],
|
|
112
|
+
"backup.changes": ["查看将恢复的配置", "View settings to restore"],
|
|
113
|
+
"backup.confirm": ["确认恢复", "Confirm restore"],
|
|
114
|
+
"backup.restored": ["配置已恢复,新增 {added} 个账号,更新 {updated} 个账号。", "Restored; {added} accounts added and {updated} updated."],
|
|
115
|
+
"backup.failed": ["备份操作失败", "Backup operation failed"],
|
|
116
|
+
"backup.tooLarge": ["备份文件过大(最大 768 KB)", "Backup is too large (maximum 768 KB)"],
|
|
117
|
+
|
|
118
|
+
'meta.title': ['码道连接器', 'CodeArts connector'],
|
|
119
|
+
'meta.description': [
|
|
120
|
+
'把华为云码道(CodeArts Agent)的模型接入 DSH:原生适配器直连网关,带凭证管理、模型目录与只读积分概览。',
|
|
121
|
+
'Connects Huawei Cloud CodeArts models to DSH through a native adapter, with credential management, a model catalog, and a read-only credit overview.',
|
|
122
|
+
],
|
|
123
|
+
'common.more': ['更多操作', 'More actions'],
|
|
124
|
+
'pool.current': ['使用中', 'In use'],
|
|
125
|
+
'pool.allSigned': ['今日全部已签', 'All checked in today'],
|
|
126
|
+
'pool.manage': ['凭证管理', 'Credential management'],
|
|
127
|
+
'pool.showSecret': ['显示', 'Show'],
|
|
128
|
+
'pool.hideSecret': ['隐藏', 'Hide'],
|
|
129
|
+
'models.search': ['搜索模型名称或 ID', 'Search model name or ID'],
|
|
130
|
+
'models.all': ['全部', 'All'],
|
|
131
|
+
'models.enabledOnly': ['已启用', 'Enabled'],
|
|
132
|
+
'models.selectedCount': ['已启用 {enabled} / {total} 个', '{enabled} of {total} enabled'],
|
|
133
|
+
'models.sort': ['模型排序', 'Sort models'],
|
|
134
|
+
'models.sortDefault': ['默认顺序', 'Default order'],
|
|
135
|
+
'models.sortRatio': ['倍率从低到高', 'Multiplier: low to high'],
|
|
136
|
+
'models.sortName': ['名称排序', 'Name'],
|
|
137
|
+
'models.noMatches': ['没有符合条件的模型', 'No matching models'],
|
|
138
|
+
'models.clearFilters': ['清除筛选', 'Clear filters'],
|
|
139
|
+
'models.about': ['目录说明与使用帮助', 'About the catalog'],
|
|
140
|
+
'models.clean': ['模型配置已保存', 'Model settings saved'],
|
|
141
|
+
'models.saveHint': ['置顶即时保存;启用、能力开关和推理强度需点击「保存模型配置」。', 'Pins save immediately. Save model settings to apply selection, capability and reasoning changes.'],
|
|
142
|
+
'credit.lastResult': ['上次结果', 'Last result'],
|
|
143
|
+
'credit.updated': ['积分更新时间', 'Credits updated'],
|
|
144
|
+
'credit.refreshFailed': ['积分刷新失败,显示上次结果', 'Credits refresh failed; showing the last result'],
|
|
145
|
+
'credit.unavailable': ['积分暂时无法读取,请重试', 'Credits are unavailable; please retry'],
|
|
146
|
+
'chip.lastCredits': ['上次积分', 'Last credits'],
|
|
147
|
+
'models.pin': ['置顶 {model}', 'Pin {model}'],
|
|
148
|
+
'models.unpin': ['取消置顶 {model}', 'Unpin {model}'],
|
|
149
|
+
'models.favoriteSaved': ['常用置顶已保存', 'Pinned models saved'],
|
|
150
|
+
'models.unsaved': ['有未保存的模型配置', 'Unsaved model settings'],
|
|
151
|
+
'models.needOne': ['请至少启用一个模型后保存', 'Enable at least one model to save'],
|
|
152
|
+
'diag.details': ['技术详情', 'Technical details'],
|
|
153
|
+
'diag.copy': ['复制脱敏诊断信息', 'Copy redacted diagnostics'],
|
|
154
|
+
'diag.copied': ['已复制脱敏诊断信息', 'Redacted diagnostics copied'],
|
|
155
|
+
'diag.copyFailed': ['无法自动复制,请从下方手动复制。', 'Could not copy automatically. Copy the report below.'],
|
|
156
|
+
'diag.configured': ['凭证已配置', 'Credentials configured'],
|
|
157
|
+
'diag.notConfigured': ['尚未配置凭证', 'Credentials not configured'],
|
|
158
|
+
'diag.credentialIssue': ['凭证需要检查', 'Check credentials'],
|
|
159
|
+
'diag.catalogIssue': ['模型目录需要检查', 'Check catalog'],
|
|
160
|
+
'diag.catalogSynced': ['模型目录已同步', 'Catalog synced'],
|
|
161
|
+
'diag.catalogFallback': ['正在使用兜底目录', 'Using fallback catalog'],
|
|
162
|
+
'diag.catalogCached': ['正在使用缓存目录', 'Using cached catalog'],
|
|
163
|
+
'diag.errors': ['最近错误', 'Recent errors'],
|
|
164
|
+
'diag.noErrors': ['暂无错误记录', 'No errors reported'],
|
|
165
|
+
'nav.label': ['码道', 'CodeArts'],
|
|
166
|
+
'tab.account': ['账号', 'Accounts'],
|
|
167
|
+
'tab.models': ['模型', 'Models'],
|
|
168
|
+
'tab.diagnostics': ['诊断', 'Diagnostics'],
|
|
169
|
+
|
|
170
|
+
'account.title': ['华为云凭证', 'Huawei Cloud credentials'],
|
|
171
|
+
'account.hint': [
|
|
172
|
+
'填一次永久 AK/SK 即可长期使用:插件会自动换 STS 临时令牌并在到期前续期,不需要你手动维护。不填也行——装过并登录过码道客户端的话,插件会借用它的登录态。',
|
|
173
|
+
'One permanent AK/SK pair is enough: the plugin exchanges it for STS and renews before expiry. Leaving it empty also works when the CodeArts client is installed and signed in on this machine.',
|
|
174
|
+
],
|
|
175
|
+
'account.ak': ['Access Key ID', 'Access Key ID'],
|
|
176
|
+
'account.sk': ['Secret Access Key', 'Secret Access Key'],
|
|
177
|
+
'account.placeholdersuffix': ['(要改就整对重填)', ' (re-enter the whole pair to change)'],
|
|
178
|
+
'account.placeholderAk': ['粘贴 Access Key ID', 'Paste the Access Key ID'],
|
|
179
|
+
'account.placeholderSk': ['粘贴 Secret Access Key', 'Paste the Secret Access Key'],
|
|
180
|
+
'account.save': ['保存', 'Save'],
|
|
181
|
+
'account.saving': ['保存中…', 'Saving…'],
|
|
182
|
+
'account.saved': ['已保存并立即生效', 'Saved and in effect'],
|
|
183
|
+
'account.saveFail': ['保存失败', 'Save failed'],
|
|
184
|
+
'account.clear': ['清除已保存的凭证', 'Clear saved credentials'],
|
|
185
|
+
'account.clearConfirm': [
|
|
186
|
+
'清除后插件会立刻改用其它凭证来源(环境变量或码道登录态)。确定清除?',
|
|
187
|
+
'After clearing, the plugin falls back to other credential sources. Clear anyway?',
|
|
188
|
+
],
|
|
189
|
+
'account.cleared': ['已清除保存的凭证', 'Saved credentials cleared'],
|
|
190
|
+
'account.clearFail': ['清除失败', 'Clear failed'],
|
|
191
|
+
'account.test': ['测试连接', 'Test connection'],
|
|
192
|
+
'account.testing': ['测试中…', 'Testing…'],
|
|
193
|
+
'account.refreshing': ['刷新中…', 'Refreshing…'],
|
|
194
|
+
'account.refresh': ['刷新目录与积分', 'Refresh catalog and credit'],
|
|
195
|
+
'account.needBoth': ['Access Key ID 和 Secret Access Key 都要填。', 'Both fields are required.'],
|
|
196
|
+
'account.whereToGet': ['怎么拿到 AK/SK', 'Where to get an AK/SK'],
|
|
197
|
+
'account.whereToGetBody': [
|
|
198
|
+
'华为云控制台 → 右上角账号名 → 我的凭证 → 访问密钥 → 新增访问密钥。下载的 credentials.csv 里 Access Key Id 和 Secret Access Key 对应上面两栏(Secret 只在创建时显示一次)。不需要填 STS。',
|
|
199
|
+
'Huawei Cloud console → account menu → My credentials → Access keys → Add access key. The downloaded credentials.csv holds the Access Key Id and Secret Access Key (the secret is shown once). No STS value is needed.',
|
|
200
|
+
],
|
|
201
|
+
'account.sourceTitle': ['当前生效的凭证来源', 'Credential source in effect'],
|
|
202
|
+
'account.sourceNone': ['尚未解析到可用凭证', 'No usable credential resolved yet'],
|
|
203
|
+
'account.temporary': [
|
|
204
|
+
'正在使用从码道登录态借来的临时凭证,几小时后会失效。失效后打开一次码道客户端让它刷新即可恢复;填上永久 AK/SK 可以免去这一步。',
|
|
205
|
+
'Running on a temporary credential borrowed from the CodeArts client. It expires in a few hours; opening the client refreshes it. A permanent AK/SK removes this step.',
|
|
206
|
+
],
|
|
207
|
+
'account.identity': ['账号', 'Account'],
|
|
208
|
+
'account.credit': ['积分', 'Credits'],
|
|
209
|
+
'account.creditBalance': ['剩余 {remain} / 共 {total}', '{remain} of {total} remaining'],
|
|
210
|
+
'account.creditUnread': ['读不到积分(不影响对话)', 'Credits unreadable (chatting still works)'],
|
|
211
|
+
'account.roles': ['企业角色', 'Enterprise roles'],
|
|
212
|
+
|
|
213
|
+
'models.title': ['模型目录', 'Model catalog'],
|
|
214
|
+
'models.pickerHint': [
|
|
215
|
+
'这些模型会出现在输入框的模型选择器里,分组名是「码道 CodeArts」。若选择器里看不到,先确认本页目录不是「兜底清单」——兜底清单只在连不上网关时使用。',
|
|
216
|
+
'These models appear in the composer model picker under the group 码道 CodeArts. If the picker does not show them, check this page is not on the fallback list — the fallback is only used when the gateway cannot be reached.',
|
|
217
|
+
],
|
|
218
|
+
'models.hint': [
|
|
219
|
+
'目录每次刷新都从网关重新读取,上游上新或调价会自动跟上;下面看到的倍率就是上游此刻给出的。',
|
|
220
|
+
'The catalog is re-read from the gateway on every refresh, so new models and price changes follow automatically. The multiplier shown is the one upstream reports right now.',
|
|
221
|
+
],
|
|
222
|
+
'models.refresh': ['重读模型目录', 'Reload catalog'],
|
|
223
|
+
'models.source': ['来源', 'Source'],
|
|
224
|
+
'models.sourceGateway': ['上游网关', 'Upstream gateway'],
|
|
225
|
+
'models.sourceCache': ['本地缓存', 'Local cache'],
|
|
226
|
+
'models.sourceFallback': ['兜底清单(未连上网关)', 'Fallback list (gateway unreachable)'],
|
|
227
|
+
'models.refreshedAt': ['上次刷新', 'Last refreshed'],
|
|
228
|
+
'models.refreshed': ['已从上游重读模型目录', 'Catalog re-read from upstream'],
|
|
229
|
+
'models.saved': ['已保存,模型选择器已更新', 'Saved; the model picker has been updated'],
|
|
230
|
+
'models.savedReloadFailed': ['已保存,暂时无法重读模型目录。', 'Saved, but the catalog could not be reloaded.'],
|
|
231
|
+
'models.save': ['保存模型配置', 'Save model settings'],
|
|
232
|
+
'models.discard': ['放弃修改', 'Discard'],
|
|
233
|
+
'models.saveFailed': ['保存失败', 'Save failed'],
|
|
234
|
+
'models.dirty': ['未保存', 'unsaved'],
|
|
235
|
+
'models.images': ['图片', 'Image'],
|
|
236
|
+
'models.allowOff': ['可关闭思考', 'Can disable'],
|
|
237
|
+
'models.effort': ['默认推理强度', 'Default reasoning'],
|
|
238
|
+
'models.footnote': [
|
|
239
|
+
'只列上游接口明确公布的模型能力;勾选的模型才会出现在模型选择器里。',
|
|
240
|
+
'Only capabilities the upstream interface publishes are shown; a model appears in the picker only while it is ticked.',
|
|
241
|
+
],
|
|
242
|
+
'models.empty': [
|
|
243
|
+
'上游没有返回任何模型。先确认凭证可用,再重读目录。',
|
|
244
|
+
'Upstream returned no models. Check the credential, then reload the catalog.',
|
|
245
|
+
],
|
|
246
|
+
'models.refreshFailed': ['刷新失败', 'Refresh failed'],
|
|
247
|
+
'models.count': ['个数', 'Count'],
|
|
248
|
+
'models.colContext': ['上下文', 'Context'],
|
|
249
|
+
'models.colOutput': ['输出上限', 'Output cap'],
|
|
250
|
+
|
|
251
|
+
'diag.title': ['诊断', 'Diagnostics'],
|
|
252
|
+
'diag.provider': ['Provider 路由', 'Provider route'],
|
|
253
|
+
'diag.gateway': ['网关', 'Gateway'],
|
|
254
|
+
'diag.credentialPath': ['凭证文件', 'Credential file'],
|
|
255
|
+
'diag.catalogError': ['目录错误', 'Catalog error'],
|
|
256
|
+
'diag.credentialError': ['凭证错误', 'Credential error'],
|
|
257
|
+
'diag.reportTitle': ['脱敏诊断 JSON', 'Redacted diagnostics JSON'],
|
|
258
|
+
'diag.reportHint': [
|
|
259
|
+
'仅包含状态、来源类型和数量等诊断字段。',
|
|
260
|
+
'Includes diagnostic fields such as status, source type, and counts.',
|
|
261
|
+
],
|
|
262
|
+
'diag.none': ['(无)', '(none)'],
|
|
263
|
+
'diag.configSchema': ['Config schema(模型页显示卡片的前提)', 'Config schema (required for the model card)'],
|
|
264
|
+
'diag.schemaMissing': ['缺失(模型页不会显示本插件的卡片)', 'missing (the model page will not show this provider)'],
|
|
265
|
+
'diag.gatewayDefault': ['默认(cn-north-4)', 'Default (cn-north-4)'],
|
|
266
|
+
|
|
267
|
+
'common.loading': ['加载中…', 'Loading…'],
|
|
268
|
+
'common.retry': ['重试', 'Retry'],
|
|
269
|
+
'common.retryHint': [
|
|
270
|
+
'读不到宿主的这条路由,可能插件刚装好还没挂上。',
|
|
271
|
+
'Could not reach this plugin\'s Host route; it may not be mounted yet.',
|
|
272
|
+
],
|
|
273
|
+
'pool.title': ['账号池', 'Accounts'],
|
|
274
|
+
'pool.tagline': [
|
|
275
|
+
'每个账号独立计费与签到;请求只用「当前」那一个。',
|
|
276
|
+
'Each account bills and checks in on its own; requests use only the current one.',
|
|
277
|
+
],
|
|
278
|
+
'pool.inUse': ['当前使用:', 'In use: '],
|
|
279
|
+
'pool.expiring': ['{amount} 积分即将到期', '{amount} credits expiring'],
|
|
280
|
+
'pool.expiringHint': [
|
|
281
|
+
'上游会报告有多少积分将要过期,但不下发具体到期时间,所以这里只显示金额。',
|
|
282
|
+
'The upstream reports how many credits are expiring but never when, so only the amount is shown.',
|
|
283
|
+
],
|
|
284
|
+
'pool.colAccount': ['账号', 'Account'],
|
|
285
|
+
'pool.colCredits': ['积分', 'Credits'],
|
|
286
|
+
'pool.colCheckin': ['签到', 'Check-in'],
|
|
287
|
+
'pool.current': ['当前', 'Current'],
|
|
288
|
+
'pool.rename': ['账号备注', 'Account name'],
|
|
289
|
+
'pool.renameHint': ['点一下改备注,方便认出是哪个账号', 'Click to rename, so you can tell accounts apart'],
|
|
290
|
+
'pool.renamePlaceholder': ['例如:个人 / 公司', 'e.g. personal / work'],
|
|
291
|
+
'pool.renameFailed': ['改备注失败', 'Rename failed'],
|
|
292
|
+
'pool.use': ['切换', 'Use'],
|
|
293
|
+
'pool.switching': ['正在切换…', 'Switching…'],
|
|
294
|
+
'pool.switched': ['已切换到「{account}」', 'Switched to {account}'],
|
|
295
|
+
'pool.switchFailed': ['切换到「{account}」失败:{error}', 'Could not switch to {account}: {error}'],
|
|
296
|
+
'pool.remove': ['移除', 'Remove'],
|
|
297
|
+
'pool.removeConfirm': [
|
|
298
|
+
'移除这个账号?它保存的 AK/SK 会从本机删除。',
|
|
299
|
+
'Remove this account? Its saved AK/SK is deleted from this machine.',
|
|
300
|
+
],
|
|
301
|
+
'pool.empty': [
|
|
302
|
+
'还没有账号。在下面填一对 AK/SK,或者从华为云导出的 credentials.csv 导入。',
|
|
303
|
+
'No accounts yet. Add an AK/SK pair below, or import the credentials.csv exported from the Huawei Cloud console.',
|
|
304
|
+
],
|
|
305
|
+
'pool.addTitle': ['添加账号', 'Add an account'],
|
|
306
|
+
'pool.addLabel': ['名称(可选)', 'Name (optional)'],
|
|
307
|
+
'pool.addLabelPlaceholder': ['例如:个人 / 公司', 'e.g. personal / work'],
|
|
308
|
+
'pool.add': ['添加', 'Add'],
|
|
309
|
+
'pool.importTitle': ['导入', 'Import'],
|
|
310
|
+
'pool.importHint': [
|
|
311
|
+
'粘贴华为云 console 下载的 credentials.csv 内容、每行一对 AK,SK、或本插件导出的 JSON。',
|
|
312
|
+
'Paste the contents of a credentials.csv from the Huawei Cloud console, one AK,SK pair per line, or JSON exported by this plugin.',
|
|
313
|
+
],
|
|
314
|
+
'pool.importPlaceholder': ['AK,SK(每行一对)', 'AK,SK (one pair per line)'],
|
|
315
|
+
'pool.import': ['导入', 'Import'],
|
|
316
|
+
'pool.importResult': [
|
|
317
|
+
'导入完成:新增 {added},更新 {updated},跳过 {skipped}',
|
|
318
|
+
'Imported: {added} added, {updated} updated, {skipped} skipped',
|
|
319
|
+
],
|
|
320
|
+
'pool.importEmpty': ['没有认出任何 AK/SK 对。', 'No AK/SK pair recognised.'],
|
|
321
|
+
'pool.export': ['导出', 'Export'],
|
|
322
|
+
'pool.exportHint': [
|
|
323
|
+
'导出的内容含明文密钥,只贴到你自己信任的地方。',
|
|
324
|
+
'The export contains plain-text keys — only paste it somewhere you trust.',
|
|
325
|
+
],
|
|
326
|
+
'pool.exported': ['已导出文件 {name}', 'Saved {name}'],
|
|
327
|
+
'pool.importHint': [
|
|
328
|
+
'选一个华为云 credentials.csv、每行 AK,SK 的文本、或本插件导出的 JSON。选完会先显示预览,确认后再写入。',
|
|
329
|
+
'Pick a Huawei Cloud credentials.csv, a text file with one AK,SK per line, or JSON exported by this plugin. You see a preview before anything is written.',
|
|
330
|
+
],
|
|
331
|
+
'pool.checkinPending': ['待签', 'Due'],
|
|
332
|
+
'pool.added': ['已添加账号', 'Account added'],
|
|
333
|
+
'pool.updated': ['已更新该账号的密钥', 'That account was updated'],
|
|
334
|
+
'pool.importing': ['导入中…', 'Importing…'],
|
|
335
|
+
'pool.previewTotal': ['将导入以下 {count} 个账号,确认后写入:', 'The following {count} accounts will be imported after confirmation:'],
|
|
336
|
+
'pool.importConfirm': ['导入 {count} 个', 'Import {count}'],
|
|
337
|
+
'pool.cancel': ['取消', 'Cancel'],
|
|
338
|
+
'pool.exportFailed': ['导出失败', 'Export failed'],
|
|
339
|
+
'pool.importShow': ['批量导入', 'Bulk import'],
|
|
340
|
+
'pool.importHide': ['收起批量导入', 'Hide bulk import'],
|
|
341
|
+
'pool.checkinClaim': ['签到', 'Check in'],
|
|
342
|
+
'pool.checkinDone': ['今日已签', 'Checked in'],
|
|
343
|
+
'pool.checkinUnavailable': ['不可领取', 'Unavailable'],
|
|
344
|
+
'pool.checkinNone': ['无活动', 'No campaign'],
|
|
345
|
+
'pool.checkinAll': ['一键签到', 'Check in now'],
|
|
346
|
+
'pool.checkinAllHint': ['立刻为所有可签到的账号领取一次', 'Claim once for every eligible account'],
|
|
347
|
+
'pool.checkinClaiming': ['签到中…', 'Claiming…'],
|
|
348
|
+
'pool.checkinNoneToday': ['今天已没有可领取的签到', 'Nothing left to claim today'],
|
|
349
|
+
'pool.checkinResult': ['{claimed} 个账号已签到,{failed} 个失败', '{claimed} claimed, {failed} failed'],
|
|
350
|
+
'pool.checkinFailed': ['签到失败', 'Check-in failed'],
|
|
351
|
+
'chip.loading': ['读取中…', 'Reading…'],
|
|
352
|
+
'chip.credits': ['积分', 'credits'],
|
|
353
|
+
'chip.panelTitle': ['码道账号与积分', 'CodeArts accounts and credits'],
|
|
354
|
+
'chip.refreshHint': ['重新读取所有账号的积分', 'Re-read every account\'s credits'],
|
|
355
|
+
'chip.settings': ['设置', 'Settings'],
|
|
356
|
+
'chip.switchTo': ['切换到 {account}', 'Switch to {account}'],
|
|
357
|
+
'chip.current': ['当前选用', 'In use'],
|
|
358
|
+
'chip.refresh': ['刷新', 'Refresh'],
|
|
359
|
+
'chip.noCredential': ['未配置凭证', 'No credentials'],
|
|
360
|
+
'chip.noCredentialHint': [
|
|
361
|
+
'还没有可用的码道凭证。到「设置 → 码道」填 AK/SK,或登录码道客户端。',
|
|
362
|
+
'No usable 码道 credential yet. Add an AK/SK in Settings → 码道, or sign in to the CodeArts client.',
|
|
363
|
+
],
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Resolve a string for the active locale.
|
|
369
|
+
*
|
|
370
|
+
* Read from `document.documentElement.lang` rather than the Host's locale
|
|
371
|
+
* service: this module renders inside the same document, and reading the
|
|
372
|
+
* attribute avoids depending on a service whose signature may change.
|
|
373
|
+
*/
|
|
374
|
+
/** Whether the surrounding document is in Chinese. */
|
|
375
|
+
function isChinese() {
|
|
376
|
+
const lang = (
|
|
377
|
+
(typeof document !== 'undefined' && document.documentElement.lang) ||
|
|
378
|
+
(typeof navigator !== 'undefined' && navigator.language) ||
|
|
379
|
+
'en'
|
|
380
|
+
).toLowerCase()
|
|
381
|
+
return lang.startsWith('zh')
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function t(key) {
|
|
385
|
+
const entry = STRINGS[key]
|
|
386
|
+
if (!entry) return key
|
|
387
|
+
return isChinese() ? entry[0] : entry[1]
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Fetch one plugin route, tolerating a non-JSON answer. */
|
|
391
|
+
async function getRoute(path, options = {}) {
|
|
392
|
+
const response = await fetch(`${ROUTE}${path}`, { ...options, headers: { accept: 'application/json' } })
|
|
393
|
+
const text = await response.text()
|
|
394
|
+
try {
|
|
395
|
+
const payload = JSON.parse(text)
|
|
396
|
+
if (!response.ok) throw new Error(payload.error ?? `${path}: HTTP ${response.status}`)
|
|
397
|
+
return payload
|
|
398
|
+
} catch (error) {
|
|
399
|
+
if (error instanceof SyntaxError) throw new Error(`${path}: ${response.status} ${text.slice(0, 120)}`)
|
|
400
|
+
throw error
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** POST JSON to one plugin route. */
|
|
405
|
+
async function postRoute(path, body) {
|
|
406
|
+
const response = await fetch(`${ROUTE}${path}`, {
|
|
407
|
+
method: 'POST',
|
|
408
|
+
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
409
|
+
body: JSON.stringify(body ?? {}),
|
|
410
|
+
})
|
|
411
|
+
const text = await response.text()
|
|
412
|
+
try {
|
|
413
|
+
const payload = JSON.parse(text)
|
|
414
|
+
if (!response.ok) throw new Error(payload.error ?? `${path}: HTTP ${response.status}`)
|
|
415
|
+
return payload
|
|
416
|
+
} catch (error) {
|
|
417
|
+
if (error instanceof SyntaxError) throw new Error(`${path}: ${response.status} ${text.slice(0, 120)}`)
|
|
418
|
+
throw error
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Format an epoch-ms instant in the browser's own zone. */
|
|
423
|
+
function formatTime(ms) {
|
|
424
|
+
if (!ms) return '—'
|
|
425
|
+
try {
|
|
426
|
+
return new Date(ms).toLocaleString()
|
|
427
|
+
} catch {
|
|
428
|
+
return String(ms)
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Relative labels stay short; the full local timestamp remains in the title. */
|
|
433
|
+
function relativeTime(ms, now = Date.now()) {
|
|
434
|
+
if (!Number.isFinite(ms) || ms <= 0) return '—'
|
|
435
|
+
const minutes = Math.floor(Math.max(0, now - ms) / 60000)
|
|
436
|
+
if (minutes < 1) return t('time.justNow')
|
|
437
|
+
if (minutes < 60) return t('time.minutesAgo').replace('{count}', minutes)
|
|
438
|
+
if (minutes < 1440) return t('time.hoursAgo').replace('{count}', Math.floor(minutes / 60))
|
|
439
|
+
return t('time.daysAgo').replace('{count}', Math.floor(minutes / 1440))
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** Keep only the last successful value for the same credential identity. */
|
|
443
|
+
function keepCredit(previous, next) {
|
|
444
|
+
if (!next) return next
|
|
445
|
+
if (next.credit && Number.isFinite(next.credit.remain)) {
|
|
446
|
+
return { ...next, creditCheckedAt: next.creditCheckedAt ?? Date.now(), creditStale: false }
|
|
447
|
+
}
|
|
448
|
+
const identity = (value) => value?.creditIdentity ?? value?.id ?? value?.accountId ?? value?.source
|
|
449
|
+
const key = identity(next)
|
|
450
|
+
if (key && key === identity(previous) && previous.credit) {
|
|
451
|
+
return { ...next, credit: previous.credit, creditCheckedAt: previous.creditCheckedAt, creditStale: true }
|
|
452
|
+
}
|
|
453
|
+
return { ...next, credit: null, creditCheckedAt: null, creditStale: false }
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function mergeCredits(path, previous, next) {
|
|
457
|
+
if (path === '/account') return keepCredit(previous, next)
|
|
458
|
+
if (path === '/accounts') {
|
|
459
|
+
const old = new Map((previous?.accounts ?? []).map((account) => [account.id, account]))
|
|
460
|
+
return { ...next, accounts: (next.accounts ?? []).map((account) => keepCredit(old.get(account.id), account)) }
|
|
461
|
+
}
|
|
462
|
+
return next
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function staleCredits(path, previous) {
|
|
466
|
+
if (!previous) return previous
|
|
467
|
+
if (path === '/account') return { ...previous, creditStale: !!previous.credit }
|
|
468
|
+
if (path === '/accounts') return { ...previous, accounts: previous.accounts.map((account) => ({ ...account, creditStale: !!account.credit })) }
|
|
469
|
+
return previous
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function CreditStatus({ account, now = Date.now() }) {
|
|
473
|
+
if (!account?.creditStale) return null
|
|
474
|
+
return h('span', { className: 'dca-credit-status', title: t('credit.refreshFailed') },
|
|
475
|
+
t('credit.lastResult'),
|
|
476
|
+
account.creditCheckedAt ? h('time', { dateTime: new Date(account.creditCheckedAt).toISOString(), title: `${t('credit.updated')} ${formatTime(account.creditCheckedAt)}` }, ` · ${relativeTime(account.creditCheckedAt, now)}`) : null,
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Render a credit balance.
|
|
482
|
+
*
|
|
483
|
+
* One format string per locale instead of gluing a translated noun between
|
|
484
|
+
* two numbers: word order differs by language, and the previous shape
|
|
485
|
+
* produced "7425.22 剩余 / 7600 共" in Chinese and "7425.22 remaining /
|
|
486
|
+
* 7600 of" in English. Grouping separators keep five-figure balances
|
|
487
|
+
* readable at a glance.
|
|
488
|
+
*/
|
|
489
|
+
function formatBalance(credit) {
|
|
490
|
+
if (!credit) return ''
|
|
491
|
+
const remain = Number(credit.remain ?? 0).toLocaleString()
|
|
492
|
+
const total = Number(credit.total ?? 0).toLocaleString()
|
|
493
|
+
return t('account.creditBalance').replace('{remain}', remain).replace('{total}', total)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Compact a token count: 1048576 -> "1M". */
|
|
497
|
+
function formatTokens(value) {
|
|
498
|
+
if (typeof value !== 'number' || value <= 0) return '—'
|
|
499
|
+
if (value >= 1_000_000) return `${Math.round(value / 100_000) / 10}M`
|
|
500
|
+
if (value >= 1000) return `${Math.round(value / 100) / 10}K`
|
|
501
|
+
return String(value)
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* The plugin's stylesheet.
|
|
506
|
+
*
|
|
507
|
+
* The layout rules for the card, the section tabs, the account table and the
|
|
508
|
+
* model rows are taken from dsh-connect-workbuddy (MIT, Copyright (c) 2026
|
|
509
|
+
* LaoDing, https://github.com/dingminhua/dsh-connect-workbuddy) so that the
|
|
510
|
+
* two connector cards read as siblings in the same settings panel. Class
|
|
511
|
+
* names are this plugin's own (`dca-` prefix); the declarations, the values
|
|
512
|
+
* and the reasoning behind them are that project's.
|
|
513
|
+
*
|
|
514
|
+
* Shipped through the Client `styles` builtin rather than as inline style
|
|
515
|
+
* objects: the Client contract cannot import the design system, so the
|
|
516
|
+
* design system is reproduced here in CSS. Inline styles cannot express
|
|
517
|
+
* `:hover`, `:focus-visible`, `:has()` or media queries, which is exactly
|
|
518
|
+
* the feedback a control needs to feel like part of the shell.
|
|
519
|
+
*
|
|
520
|
+
* Every colour is a theme token with a literal fallback, so the page also
|
|
521
|
+
* survives a host that renames one.
|
|
522
|
+
*/
|
|
523
|
+
const CSS = `
|
|
524
|
+
/* The app ships no global reset, so a padded, bordered element with width:100%
|
|
525
|
+
overflows its container by exactly its padding plus border. Every box here
|
|
526
|
+
opts in explicitly. */
|
|
527
|
+
.dca-page,.dca-page *{box-sizing:border-box}
|
|
528
|
+
|
|
529
|
+
/* ---- shared shell ------------------------------------------------------ */
|
|
530
|
+
.dca-settings{container:dca-settings / inline-size;width:100%;min-width:0;max-width:100%}
|
|
531
|
+
.dca-page{min-width:0;max-width:100%;display:flex;flex-direction:column;gap:18px;color:var(--dsw-alias-label-primary,#e6e6e6);font-size:13px;line-height:1.6}
|
|
532
|
+
.dca-head{display:flex;flex-direction:column;gap:4px}
|
|
533
|
+
.dca-title{margin:0;font-size:16px;font-weight:500;line-height:24px}
|
|
534
|
+
.dca-hint{margin:0;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
|
|
535
|
+
.dca-card{
|
|
536
|
+
box-sizing:border-box;
|
|
537
|
+
border:1px solid var(--dsw-alias-border-l2,#36373b);
|
|
538
|
+
border-radius:12px;background:var(--dsw-alias-bg-layer-3,#202126);
|
|
539
|
+
padding:14px 16px;display:flex;flex-direction:column;gap:12px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* ---- account pool rows ------------------------------------------------
|
|
543
|
+
One row per account, two lines each: identity on the first, what the account
|
|
544
|
+
can do right now on the second. The reference lays its pool out this way, so
|
|
545
|
+
a long account name never pushes the figures out of alignment. */
|
|
546
|
+
.dca-pool-card-head{
|
|
547
|
+
display:flex;align-items:center;justify-content:space-between;
|
|
548
|
+
gap:8px 12px;flex-wrap:wrap;
|
|
549
|
+
}
|
|
550
|
+
.dca-pool-actions-group{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
551
|
+
.dca-pool-card-title{margin:0;font-size:13px;font-weight:600;line-height:20px}
|
|
552
|
+
.dca-pool-tagline{flex:1 1 auto;min-width:0}
|
|
553
|
+
.dca-pool-account-row{display:flex;align-items:center;gap:8px;min-width:0;flex-wrap:wrap}
|
|
554
|
+
/* The account name is a BUTTON that looks like text: the pencil only appears on
|
|
555
|
+
hover or focus, so the table does not read as a form with three inputs a row. */
|
|
556
|
+
.dca-rename-btn{
|
|
557
|
+
appearance:none;font:inherit;display:inline-flex;align-items:center;gap:5px;
|
|
558
|
+
padding:1px 6px;margin:-1px -6px;border:1px solid transparent;border-radius:6px;
|
|
559
|
+
background:transparent;color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
560
|
+
cursor:pointer;min-width:0;max-width:100%;
|
|
561
|
+
}
|
|
562
|
+
.dca-rename-btn:hover{border-color:var(--dsw-alias-border-l2,#3a3d45);background:var(--dsw-alias-bg-layer-2,#232529)}
|
|
563
|
+
.dca-rename-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
|
|
564
|
+
.dca-rename-btn b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
565
|
+
.dca-rename-glyph{
|
|
566
|
+
flex:none;font-size:11px;line-height:16px;
|
|
567
|
+
color:var(--dsw-alias-label-tertiary,#999);opacity:0;transition:opacity .15s;
|
|
568
|
+
}
|
|
569
|
+
.dca-rename-btn:hover .dca-rename-glyph,
|
|
570
|
+
.dca-rename-btn:focus-visible .dca-rename-glyph{opacity:1}
|
|
571
|
+
.dca-rename{max-width:220px;font-family:inherit;font-size:13px}
|
|
572
|
+
.dca-pool-probe{
|
|
573
|
+
display:flex;align-items:center;gap:7px 12px;flex-wrap:wrap;
|
|
574
|
+
font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#999);
|
|
575
|
+
min-width:0;overflow-wrap:anywhere;
|
|
576
|
+
}
|
|
577
|
+
.dca-pool-probe-cell{grid-area:probe;min-width:0}
|
|
578
|
+
.dca-pool-probe-main{
|
|
579
|
+
font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#999);
|
|
580
|
+
min-width:0;overflow-wrap:anywhere;
|
|
581
|
+
}
|
|
582
|
+
.dca-pool-credits-row{
|
|
583
|
+
grid-area:credits;
|
|
584
|
+
display:flex;flex-direction:row;flex-wrap:wrap;align-items:baseline;
|
|
585
|
+
justify-content:flex-end;gap:0 6px;min-width:0;
|
|
586
|
+
justify-self:end;text-align:right;font-variant-numeric:tabular-nums;
|
|
587
|
+
}
|
|
588
|
+
/* A small state chip on the name line, and a filled pill for "current". */
|
|
589
|
+
.dca-pool-tag{
|
|
590
|
+
flex:none;padding:1px 7px;border-radius:6px;
|
|
591
|
+
background:var(--dsw-alias-bg-layer-3,#2a2c33);
|
|
592
|
+
font-size:10px;line-height:16px;color:var(--dsw-alias-label-tertiary,#999);
|
|
593
|
+
}
|
|
594
|
+
.dca-badge{
|
|
595
|
+
flex:none;padding:2px 9px;border-radius:999px;
|
|
596
|
+
font-size:12px;line-height:18px;font-weight:500;
|
|
597
|
+
color:var(--dsw-alias-brand-primary,#5686fe);
|
|
598
|
+
background:rgba(86,134,254,.12);
|
|
599
|
+
border:1px solid rgba(86,134,254,.32);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/* ---- switch row -------------------------------------------------------
|
|
603
|
+
The platform checkbox, sized and drawn by the engine via accent-color. The
|
|
604
|
+
reference never paints its own toggle: that is what makes the box match the
|
|
605
|
+
reader's OS instead of looking like a painted square. */
|
|
606
|
+
/* The file input is visually hidden, not display:none: a display:none input
|
|
607
|
+
cannot be opened by script in every engine, and this one is clicked by the
|
|
608
|
+
button above it. */
|
|
609
|
+
.dca-file-input{
|
|
610
|
+
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
|
|
611
|
+
overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
|
|
612
|
+
}
|
|
613
|
+
.dca-transfer-dialog{
|
|
614
|
+
margin-top:8px;padding:10px 12px;
|
|
615
|
+
border:1px solid var(--dsw-alias-border-l2,#3a3d45);
|
|
616
|
+
border-radius:10px;background:var(--dsw-alias-bg-secondary,transparent);
|
|
617
|
+
}
|
|
618
|
+
.dca-transfer-list{
|
|
619
|
+
list-style:none;margin:0 0 8px;padding:0;
|
|
620
|
+
max-height:180px;overflow-y:auto;
|
|
621
|
+
}
|
|
622
|
+
.dca-transfer-list li{
|
|
623
|
+
font-size:12px;color:var(--dsw-alias-label-primary,#e8e9ed);
|
|
624
|
+
padding:2px 0;overflow-wrap:anywhere;
|
|
625
|
+
}
|
|
626
|
+
.dca-transfer-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap}
|
|
627
|
+
/* ---- model rows -------------------------------------------------------
|
|
628
|
+
Line one: enable box, name, ratio, flags on the left; the row's own switches
|
|
629
|
+
on the right. Line two: facts, indented to the name (22px = the box plus its
|
|
630
|
+
8px gap) so the two lines read as one block. */
|
|
631
|
+
.dca-model-head{
|
|
632
|
+
display:flex;align-items:center;justify-content:space-between;
|
|
633
|
+
flex-wrap:wrap;gap:12px;row-gap:8px;min-width:0;
|
|
634
|
+
}
|
|
635
|
+
.dca-model-controls{
|
|
636
|
+
display:flex;align-items:center;flex-wrap:wrap;
|
|
637
|
+
gap:12px;row-gap:8px;min-width:0;flex:none;
|
|
638
|
+
}
|
|
639
|
+
.dca-model-details{
|
|
640
|
+
display:flex;align-items:center;justify-content:space-between;
|
|
641
|
+
gap:12px;min-width:0;padding-inline-start:22px;
|
|
642
|
+
}
|
|
643
|
+
.dca-model-check{
|
|
644
|
+
margin:0;flex:none;width:16px;height:16px;
|
|
645
|
+
accent-color:var(--dsw-alias-brand-primary,#5686fe);
|
|
646
|
+
}
|
|
647
|
+
.dca-model-ratio{color:var(--dsw-alias-label-tertiary,#999);font-size:11px;font-weight:400;line-height:16px;flex:none}
|
|
648
|
+
.dca-model-flag{
|
|
649
|
+
display:inline-flex;align-items:center;gap:5px;flex:none;
|
|
650
|
+
font-size:11px;line-height:16px;
|
|
651
|
+
color:var(--dsw-alias-label-secondary,#c6c9d0);
|
|
652
|
+
}
|
|
653
|
+
.dca-card-plain{border-color:transparent;background:transparent;padding:0}
|
|
654
|
+
.dca-card-title{margin:0;font-size:13px;font-weight:600;line-height:20px}
|
|
655
|
+
.dca-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
656
|
+
.dca-fields{display:flex;gap:8px;flex-wrap:wrap}
|
|
657
|
+
/* Every field grows equally and may shrink: a fixed 220px basis forced the row to
|
|
658
|
+
wrap on a narrow card even when the inputs would have fitted. */
|
|
659
|
+
.dca-fields .dca-input{flex:1 1 160px;min-width:120px}
|
|
660
|
+
.dca-label{font-size:12px;color:var(--dsw-alias-label-tertiary,#999);line-height:18px}
|
|
661
|
+
.dca-input{
|
|
662
|
+
box-sizing:border-box;width:100%;
|
|
663
|
+
font-size:12px;line-height:20px;
|
|
664
|
+
font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
|
|
665
|
+
padding:4px 8px;border-radius:6px;
|
|
666
|
+
border:1px solid var(--dsw-alias-border-l2,#3a3d45);
|
|
667
|
+
background:var(--dsw-alias-bg-l1,transparent);
|
|
668
|
+
color:var(--dsw-alias-label-primary,#e8e9ed);
|
|
669
|
+
transition:border-color .15s;
|
|
670
|
+
}
|
|
671
|
+
.dca-input:hover{border-color:var(--dsw-alias-label-dimmed,#777)}
|
|
672
|
+
.dca-input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;border-color:var(--dsw-alias-brand-primary,#5686fe)}
|
|
673
|
+
|
|
674
|
+
/* ---- buttons -----------------------------------------------------------
|
|
675
|
+
A shared base plus one modifier per weight, so a row of buttons has one
|
|
676
|
+
height, one radius and one transition instead of three copies. */
|
|
677
|
+
.dca-btn{
|
|
678
|
+
box-sizing:border-box;appearance:none;font:inherit;font-size:13px;line-height:20px;
|
|
679
|
+
padding:5px 14px;border-radius:8px;min-height:32px;font-weight:500;cursor:pointer;
|
|
680
|
+
border:1px solid var(--dsw-alias-border-l2,#3a3d45);
|
|
681
|
+
background:var(--dsw-alias-bg-layer-2,#232529);
|
|
682
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
683
|
+
transition:background .15s,border-color .15s,opacity .15s;
|
|
684
|
+
white-space:nowrap;
|
|
685
|
+
}
|
|
686
|
+
.dca-btn:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#777)}
|
|
687
|
+
.dca-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
|
|
688
|
+
.dca-btn:disabled{opacity:.55;cursor:default}
|
|
689
|
+
.dca-btn-primary{
|
|
690
|
+
border-color:transparent;
|
|
691
|
+
/* An INVERTED surface, not a brand fill — the reference's primary is
|
|
692
|
+
label-primary on bg-layer-3, two tokens that are opposite by definition in
|
|
693
|
+
every theme, so the label can never vanish into its own background. */
|
|
694
|
+
background:var(--dsw-alias-label-primary,#e6e6e6);
|
|
695
|
+
color:var(--dsw-alias-bg-layer-3,#2a2c33);
|
|
696
|
+
font-weight:600;
|
|
697
|
+
}
|
|
698
|
+
.dca-btn-primary:hover:not(:disabled){opacity:.9}
|
|
699
|
+
/* If a host omits bg-base, the fallback must follow the theme too, or the
|
|
700
|
+
light theme turns this into dark-on-dark. Inert when the token exists. */
|
|
701
|
+
@media (prefers-color-scheme: light){
|
|
702
|
+
.dca-btn-primary{color:var(--dsw-alias-bg-base,#fff)}
|
|
703
|
+
}
|
|
704
|
+
.dca-btn-quiet{background:transparent;border-color:transparent;color:var(--dsw-alias-label-tertiary,#999)}
|
|
705
|
+
.dca-btn-quiet:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
706
|
+
|
|
707
|
+
/* ---- tabs -------------------------------------------------------------
|
|
708
|
+
A TABS STRIP pinned above scrolling content, matched to the reference: 7px
|
|
709
|
+
11px tabs with a 2px transparent bottom border that the active tab fills with
|
|
710
|
+
the accent, a hairline rule under the strip, and sticky positioning so the
|
|
711
|
+
labels stay put while the panel scrolls. The opaque background is
|
|
712
|
+
load-bearing — without it rows slide under the strip and show through the
|
|
713
|
+
gaps between labels. (An earlier revision drew card-shaped cells here; the
|
|
714
|
+
reference does not, and at four sections the cards read as buttons.) */
|
|
715
|
+
.dca-tabs{
|
|
716
|
+
position:sticky;top:-1px;z-index:2;
|
|
717
|
+
display:flex;align-items:stretch;gap:2px;margin:0;
|
|
718
|
+
border-bottom:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24));
|
|
719
|
+
background:var(--dsw-alias-bg-layer-1,#17181b);
|
|
720
|
+
}
|
|
721
|
+
.dca-tab{
|
|
722
|
+
appearance:none;font:inherit;cursor:pointer;border:0;background:transparent;
|
|
723
|
+
padding:7px 11px;margin-bottom:-1px;
|
|
724
|
+
border-bottom:2px solid transparent;
|
|
725
|
+
color:var(--dsw-alias-label-tertiary,#999);
|
|
726
|
+
font-size:13px;font-weight:600;line-height:20px;white-space:nowrap;
|
|
727
|
+
transition:color .15s,border-color .15s;
|
|
728
|
+
}
|
|
729
|
+
.dca-tab:hover:not(.dca-tab-on){color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
730
|
+
.dca-tab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
|
|
731
|
+
.dca-tab-on{
|
|
732
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
733
|
+
border-bottom-color:var(--dsw-alias-brand-primary,#5686fe);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/* ---- data table -------------------------------------------------------
|
|
737
|
+
Tabular figures so the multiplier column lines up digit for digit. */
|
|
738
|
+
/* Model rows are CARDS, not table rows — the reference lists models this way and
|
|
739
|
+
a settings column cannot hold six nowrap columns. Each row is a surface on
|
|
740
|
+
bg-layer-2, its facts on one 11px meta line, exactly like the reference. */
|
|
741
|
+
/* One bordered box; its first and last rows receive their own corner radii so
|
|
742
|
+
contextual row menus can extend beyond the table without being clipped. */
|
|
743
|
+
.dca-model-page{min-height:100%;padding-bottom:60px;gap:12px}
|
|
744
|
+
.dca-models{
|
|
745
|
+
display:flex;flex-direction:column;
|
|
746
|
+
border:1px solid var(--dsw-alias-border-l2,#36373b);
|
|
747
|
+
border-radius:10px;overflow:hidden;
|
|
748
|
+
}
|
|
749
|
+
.dca-model{
|
|
750
|
+
box-sizing:border-box;display:grid;grid-template-columns:minmax(0,1fr);gap:7px;
|
|
751
|
+
padding:10px 12px;background:var(--dsw-alias-bg-layer-2,#232529);
|
|
752
|
+
transition:background-color .16s;
|
|
753
|
+
}
|
|
754
|
+
.dca-model + .dca-model{border-top:1px solid var(--dsw-alias-border-l2,#36373b)}
|
|
755
|
+
/* An unticked model stays visible but recedes: it is still a thing you can
|
|
756
|
+
enable, so hiding it would make the catalog feel arbitrary. */
|
|
757
|
+
.dca-model-off{background:var(--dsw-alias-bg-layer-1,#1c1d21)}
|
|
758
|
+
/* The model panel's action bar: always present, disabled when clean. */
|
|
759
|
+
.dca-model-actions{
|
|
760
|
+
display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;
|
|
761
|
+
position:sticky;bottom:0;z-index:3;flex-shrink:0;
|
|
762
|
+
gap:12px;row-gap:8px;
|
|
763
|
+
background:var(--dsw-alias-bg-layer-1,#17181b);
|
|
764
|
+
box-shadow:0 -6px 16px rgba(0,0,0,.04);
|
|
765
|
+
border-top:1px solid var(--dsw-alias-border-l2,#36373b);
|
|
766
|
+
padding:12px 0;
|
|
767
|
+
}
|
|
768
|
+
.dca-model-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px}
|
|
769
|
+
.dca-dirty{
|
|
770
|
+
margin-left:8px;padding:0 6px;border-radius:6px;
|
|
771
|
+
font-size:10px;line-height:16px;font-weight:600;
|
|
772
|
+
color:var(--dsw-alias-state-warn-primary,#e8b34b);
|
|
773
|
+
border:1px solid currentColor;
|
|
774
|
+
}
|
|
775
|
+
.dca-model-controls label{cursor:pointer}
|
|
776
|
+
.dca-model-controls input[type="checkbox"]{
|
|
777
|
+
margin:0 5px 0 0;width:14px;height:14px;flex:none;
|
|
778
|
+
accent-color:var(--dsw-alias-brand-primary,#5686fe);
|
|
779
|
+
}
|
|
780
|
+
.dca-model-controls input[type="checkbox"]:disabled{cursor:default}
|
|
781
|
+
.dca-model-name{
|
|
782
|
+
display:inline-flex;align-items:baseline;gap:7px;
|
|
783
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
784
|
+
font-size:13px;font-weight:500;line-height:19px;
|
|
785
|
+
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
786
|
+
min-width:0;
|
|
787
|
+
}
|
|
788
|
+
.dca-model-name b{font-size:13px;font-weight:500;min-width:0;overflow:hidden;text-overflow:ellipsis}
|
|
789
|
+
.dca-effort{display:inline-flex;align-items:center;gap:5px;cursor:pointer}
|
|
790
|
+
/* A quiet pill, not a boxed form control: the row already carries two checkboxes,
|
|
791
|
+
and a third bordered control would make a settings table look like a form. */
|
|
792
|
+
.dca-effort-select{
|
|
793
|
+
font:inherit;font-size:11px;line-height:15px;
|
|
794
|
+
color:var(--dsw-alias-label-secondary,#c6c9d0);
|
|
795
|
+
background:rgba(174,179,187,.11);
|
|
796
|
+
border:1px solid transparent;border-radius:999px;
|
|
797
|
+
padding:1px 6px;cursor:pointer;max-width:180px;
|
|
798
|
+
}
|
|
799
|
+
.dca-effort-select:hover:not(:disabled){border-color:var(--dsw-alias-border-l2,#3a3d45)}
|
|
800
|
+
.dca-effort-select:focus-visible{
|
|
801
|
+
outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;
|
|
802
|
+
}
|
|
803
|
+
.dca-effort-select:disabled{opacity:.55;cursor:default}
|
|
804
|
+
.dca-model-meta{
|
|
805
|
+
display:flex;align-items:center;gap:7px 12px;flex-wrap:wrap;
|
|
806
|
+
color:var(--dsw-alias-label-tertiary,#999);font-size:11px;line-height:16px;
|
|
807
|
+
}
|
|
808
|
+
.dca-model-meta .dca-num{font-variant-numeric:tabular-nums}
|
|
809
|
+
.dca-id{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;color:var(--dsw-alias-label-tertiary,#999);line-height:16px}
|
|
810
|
+
|
|
811
|
+
/* ---- pills, key/value, messages --------------------------------------- */
|
|
812
|
+
|
|
813
|
+
/* DIAGNOSTICS: a two-column FACT TABLE, not prose. One row per thing the plugin
|
|
814
|
+
actually read, so a bug report can quote a line instead of paraphrasing the
|
|
815
|
+
UI. No control lives here on purpose — a diagnostics panel that can change
|
|
816
|
+
settings is a settings panel with a worse name. */
|
|
817
|
+
.dca-diag{
|
|
818
|
+
display:flex;flex-direction:column;
|
|
819
|
+
border:1px solid var(--dsw-alias-border-l2,#36373b);
|
|
820
|
+
border-radius:10px;overflow:hidden;
|
|
821
|
+
background:var(--dsw-alias-bg-layer-2,#232529);
|
|
822
|
+
}
|
|
823
|
+
.dca-diag-row{display:flex;align-items:baseline;justify-content:space-between;gap:16px;padding:8px 12px}
|
|
824
|
+
.dca-diag-row + .dca-diag-row{border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24))}
|
|
825
|
+
.dca-diag-label{flex:none;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
|
|
826
|
+
.dca-diag-value{
|
|
827
|
+
min-width:0;color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
828
|
+
font-size:12px;line-height:18px;text-align:right;overflow-wrap:anywhere;
|
|
829
|
+
}
|
|
830
|
+
.dca-diag-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
831
|
+
.dca-diag-bad{color:var(--dsw-alias-state-warn-primary,#e8b34b)}
|
|
832
|
+
.dca-diag-hint{margin:10px 0 0;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
|
|
833
|
+
.dca-msg{font-size:12px;line-height:18px;margin:0;white-space:pre-wrap}
|
|
834
|
+
.dca-msg-error{color:var(--dsw-alias-state-error-primary,#e5534b)}
|
|
835
|
+
.dca-msg-ok{color:var(--dsw-alias-state-success-primary,#3fb950)}
|
|
836
|
+
.dca-msg-warn{color:var(--dsw-alias-state-warn-primary,#d29922)}
|
|
837
|
+
.dca-pre{
|
|
838
|
+
margin:0;padding:10px;border-radius:8px;
|
|
839
|
+
background:var(--dsw-alias-bg-base,#121317);
|
|
840
|
+
border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24));
|
|
841
|
+
font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
842
|
+
font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-word;
|
|
843
|
+
max-height:240px;overflow:auto;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/* ---- account pool -----------------------------------------------------
|
|
847
|
+
A table of accounts, styled like the settings tables around it: one row per
|
|
848
|
+
account, aligned columns, the current one marked rather than reordered.
|
|
849
|
+
Every row is the same height so the check-in buttons line up. */
|
|
850
|
+
.dca-pool{display:flex;flex-direction:column;gap:12px;margin:0;padding:0 0 4px}
|
|
851
|
+
/* A grid table, matched to the reference card: rounded outer frame on
|
|
852
|
+
bg-layer-2, one row per account, uppercase 11px header row on bg-layer-3.
|
|
853
|
+
Not a <table> — the columns reflow to two lines on a narrow panel, which a
|
|
854
|
+
table cannot do. */
|
|
855
|
+
.dca-pool-table{
|
|
856
|
+
box-sizing:border-box;
|
|
857
|
+
border:1px solid var(--dsw-alias-border-l2,#3a3d45);
|
|
858
|
+
border-radius:12px;
|
|
859
|
+
background:var(--dsw-alias-bg-layer-2,#24262c);
|
|
860
|
+
}
|
|
861
|
+
.dca-pool-row{
|
|
862
|
+
display:grid;
|
|
863
|
+
grid-template-columns:minmax(0,1fr) minmax(140px,auto);
|
|
864
|
+
grid-template-areas:
|
|
865
|
+
"account credits"
|
|
866
|
+
"probe actions";
|
|
867
|
+
column-gap:12px;row-gap:4px;align-items:center;
|
|
868
|
+
padding:10px 14px;
|
|
869
|
+
border-top:1px solid var(--dsw-alias-border-l1,#2c2d31);
|
|
870
|
+
font-size:13px;
|
|
871
|
+
}
|
|
872
|
+
.dca-pool-row:first-of-type{border-top:0}
|
|
873
|
+
/* The serving row, findable at a glance: a left accent bar plus a faint tint.
|
|
874
|
+
The bar is what distinguishes it in a long table — a 7% wash alone reads as
|
|
875
|
+
an alternating-row stripe. */
|
|
876
|
+
.dca-pool-row-current{
|
|
877
|
+
/* The ONLY marker for the serving account now: a tint strong enough to read at
|
|
878
|
+
a glance plus the accent bar. A 7% wash alone reads as an alternating-row
|
|
879
|
+
stripe in a long table. */
|
|
880
|
+
background:rgba(86,134,254,.14);
|
|
881
|
+
box-shadow:inset 3px 0 0 var(--dsw-alias-brand-primary,#5686fe);
|
|
882
|
+
}
|
|
883
|
+
.dca-pool-row-head{
|
|
884
|
+
padding:8px 14px;row-gap:1px;
|
|
885
|
+
background:var(--dsw-alias-bg-layer-3,#2a2c33);
|
|
886
|
+
color:var(--dsw-alias-label-tertiary,#999);
|
|
887
|
+
font-size:11px;font-weight:600;letter-spacing:.02em;text-transform:uppercase;
|
|
888
|
+
}
|
|
889
|
+
.dca-pool-col-account{grid-area:account;min-width:0}
|
|
890
|
+
.dca-pool-col-credits{
|
|
891
|
+
grid-area:credits;justify-self:end;text-align:right;font-variant-numeric:tabular-nums;
|
|
892
|
+
}
|
|
893
|
+
.dca-pool-col-actions{grid-area:actions;justify-self:end}
|
|
894
|
+
.dca-pool-card-head{
|
|
895
|
+
display:flex;align-items:center;justify-content:space-between;
|
|
896
|
+
gap:8px 12px;flex-wrap:wrap;
|
|
897
|
+
}
|
|
898
|
+
.dca-pool-tagline{flex:1 1 auto;min-width:0}
|
|
899
|
+
.dca-pool-card-title{margin:0;font-size:13px;font-weight:600;line-height:20px}
|
|
900
|
+
|
|
901
|
+
.dca-pool-sub{display:block;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#999)}
|
|
902
|
+
.dca-pool-actions{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;align-items:center}
|
|
903
|
+
.dca-btn-xs{
|
|
904
|
+
box-sizing:border-box;appearance:none;font:inherit;font-size:12px;line-height:20px;font-weight:500;
|
|
905
|
+
padding:3px 10px;border-radius:8px;cursor:pointer;white-space:nowrap;
|
|
906
|
+
border:1px solid var(--dsw-alias-border-l2,#3a3d45);
|
|
907
|
+
background:var(--dsw-alias-bg-layer-2,#232529);
|
|
908
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
909
|
+
transition:background .15s,border-color .15s,opacity .15s;
|
|
910
|
+
}
|
|
911
|
+
.dca-btn-xs:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#777)}
|
|
912
|
+
.dca-btn-xs:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
|
|
913
|
+
.dca-btn-xs:disabled{opacity:.5;cursor:default}
|
|
914
|
+
|
|
915
|
+
.dca-tag{
|
|
916
|
+
display:inline-flex;align-items:center;padding:1px 8px;border-radius:var(--dsw-radius-xl,20px);
|
|
917
|
+
font-size:11px;line-height:16px;white-space:nowrap;
|
|
918
|
+
border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24));
|
|
919
|
+
color:var(--dsw-alias-label-tertiary,#999);
|
|
920
|
+
}
|
|
921
|
+
.dca-tag-ok{color:var(--dsw-alias-state-success-primary,#3fb950);border-color:currentColor}
|
|
922
|
+
.dca-tag-warn{color:var(--dsw-alias-state-warn-primary,#d29922);border-color:currentColor}
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
/* Compact controls share the host's colors in either theme. */
|
|
927
|
+
.dca-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
928
|
+
.dca-search{flex:1 1 200px;min-width:140px}
|
|
929
|
+
.dca-filter-group{display:inline-flex;gap:2px;padding:3px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:9px}
|
|
930
|
+
.dca-filter{appearance:none;font:inherit;border:0;border-radius:6px;padding:3px 10px;cursor:pointer;background:transparent;color:var(--dsw-alias-label-secondary,#c6c9d0)}
|
|
931
|
+
.dca-filter[aria-pressed="true"]{background:var(--dsw-alias-label-primary,#e6e6e6);color:var(--dsw-alias-bg-layer-1,#17181b)}
|
|
932
|
+
.dca-filter:focus-visible,.dca-details > summary:focus-visible,.dca-account-menu > summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}
|
|
933
|
+
.dca-sort{width:auto;max-width:100%;min-height:32px;font-family:inherit}
|
|
934
|
+
.dca-catalog-meta{display:flex;align-items:center;gap:6px 14px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-secondary,#c6c9d0)}
|
|
935
|
+
.dca-model-meta{color:var(--dsw-alias-label-secondary,#b6b8be)}
|
|
936
|
+
.dca-model-off .dca-model-controls,.dca-model-off .dca-effort{color:var(--dsw-alias-label-secondary,#b6b8be)}
|
|
937
|
+
.dca-model-controls input:disabled,.dca-effort-select:disabled{opacity:.75}
|
|
938
|
+
.dca-save-feedback{display:flex;flex-direction:column;gap:4px;flex:1 1 180px;min-width:0;overflow-wrap:anywhere}
|
|
939
|
+
.dca-save-status{font-size:12px;color:var(--dsw-alias-label-secondary,#c6c9d0)}
|
|
940
|
+
.dca-pool-feedback{grid-column:1 / -1;min-width:0;overflow-wrap:anywhere}
|
|
941
|
+
.dca-empty{padding:24px 16px;display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center}
|
|
942
|
+
.dca-details > summary{cursor:pointer;font-size:12px;color:var(--dsw-alias-label-secondary,#c6c9d0);border-radius:4px}
|
|
943
|
+
.dca-details[open] > summary{margin-bottom:12px}
|
|
944
|
+
.dca-details-body{display:flex;flex-direction:column;gap:12px;min-width:0}
|
|
945
|
+
.dca-add-tools > summary{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
946
|
+
.dca-form-field{display:flex;flex-direction:column;gap:5px;flex:1 1 180px;min-width:0;font-size:12px;color:var(--dsw-alias-label-secondary,#c6c9d0)}
|
|
947
|
+
.dca-form-field .dca-input{width:100%;min-width:0;flex:none}
|
|
948
|
+
.dca-secret-field{display:flex;align-items:center;gap:6px}
|
|
949
|
+
.dca-secret-field .dca-input{flex:1;min-width:0}
|
|
950
|
+
.dca-form{display:flex;flex-direction:column;gap:12px}
|
|
951
|
+
.dca-form .dca-fields{align-items:flex-start}
|
|
952
|
+
.dca-account-menu{position:relative}
|
|
953
|
+
.dca-account-menu > summary{cursor:pointer;list-style:none;padding:3px 10px;border:1px solid var(--dsw-alias-border-l2,#3a3d45);border-radius:8px;font-size:16px;line-height:20px}
|
|
954
|
+
.dca-account-menu > summary::-webkit-details-marker{display:none}
|
|
955
|
+
.dca-menu-actions{position:absolute;inset-inline-end:0;top:calc(100% + 4px);z-index:4;padding:5px;min-width:110px;border:1px solid var(--dsw-alias-border-l2,#3a3d45);border-radius:8px;background:var(--dsw-alias-bg-overlay,#26282e);box-shadow:0 4px 16px rgba(0,0,0,.12)}
|
|
956
|
+
.dca-menu-actions .dca-btn-xs{width:100%;text-align:left;border-color:transparent}
|
|
957
|
+
.dca-danger{color:var(--dsw-alias-state-error-primary,#ef4444)}
|
|
958
|
+
.dca-pool-row-head{border-radius:11px 11px 0 0}
|
|
959
|
+
.dca-pool-row:last-child{border-radius:0 0 11px 11px}
|
|
960
|
+
.dca-current-tag{display:inline-flex;font-size:11px;font-weight:500;color:var(--dsw-alias-brand-primary,#5686fe)}
|
|
961
|
+
.dca-diagnostic-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr));gap:10px}
|
|
962
|
+
.dca-summary-item{border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;padding:12px;display:flex;flex-direction:column;gap:5px;min-width:0}
|
|
963
|
+
.dca-summary-item strong{font-size:13px;font-weight:500}
|
|
964
|
+
.dca-summary-item p{overflow-wrap:anywhere}
|
|
965
|
+
.dca-section-error{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
966
|
+
.dca-section-error .dca-msg{flex:1;min-width:0}
|
|
967
|
+
@container dca-settings (max-width:640px){
|
|
968
|
+
.dca-model-head{align-items:flex-start;gap:10px}
|
|
969
|
+
.dca-model-controls{flex:1 1 100%}
|
|
970
|
+
.dca-toolbar .dca-search{flex-basis:100%}
|
|
971
|
+
.dca-pool-col-actions{max-width:100%}
|
|
972
|
+
.dca-model-controls{justify-content:flex-start;padding-inline-start:24px}
|
|
973
|
+
.dca-model-actions{gap:8px}
|
|
974
|
+
.dca-model-actions-buttons{margin-inline-start:auto}
|
|
975
|
+
.dca-model-meta{gap:4px 10px}
|
|
976
|
+
.dca-pool-row{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"account credits" "probe actions";padding:10px}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
@container dca-settings (max-width:420px){
|
|
980
|
+
.dca-pool-row{grid-template-columns:minmax(0,1fr) minmax(60px,auto);grid-template-areas:"account credits" "probe probe" "actions actions";row-gap:8px}
|
|
981
|
+
.dca-pool-col-actions{justify-self:stretch}
|
|
982
|
+
.dca-pool-actions{justify-content:flex-start}
|
|
983
|
+
.dca-pool-row-head .dca-pool-col-actions{display:none}
|
|
984
|
+
.dca-pool-account-row{gap:4px 8px}
|
|
985
|
+
.dca-model-name{white-space:normal;flex-wrap:wrap;overflow-wrap:anywhere}
|
|
986
|
+
.dca-model-actions-buttons{width:100%}
|
|
987
|
+
.dca-form-field{max-width:100%}
|
|
988
|
+
.dca-preset-tools .dca-preset-row > .dca-input{flex-basis:100%}
|
|
989
|
+
}
|
|
990
|
+
.dca-pin{appearance:none;display:inline-flex;align-items:center;justify-content:center;flex:none;width:28px;height:28px;padding:4px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--dsw-alias-label-tertiary,#999);cursor:pointer}
|
|
991
|
+
.dca-pin:hover{background:var(--dsw-alias-bg-layer-3,#202126);color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
992
|
+
.dca-pin-on{color:var(--dsw-alias-brand-primary,#5686fe)}
|
|
993
|
+
.dca-pin:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}
|
|
994
|
+
.dca-pin:disabled{opacity:.5;cursor:default}
|
|
995
|
+
.dca-credit-status{display:block;flex-basis:100%;font-size:11px;line-height:16px;color:var(--dsw-alias-state-warn-primary,#d49937)}
|
|
996
|
+
.dca-pop-notice{margin:6px 0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-warn-primary,#d49937)}
|
|
997
|
+
.dca-account-credits{font-size:16px;font-weight:600;line-height:22px}
|
|
998
|
+
.dca-account-error{max-width:100%;font-size:12px}
|
|
999
|
+
.dca-account-error > summary{color:var(--dsw-alias-state-error-primary,#ef4444)}
|
|
1000
|
+
.dca-account-error p{margin:6px 0 0;padding:8px 10px;border-inline-start:2px solid currentColor;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,#b6b8be)}
|
|
1001
|
+
.dca-capability-filters{display:flex;align-items:center;gap:8px 14px;flex-wrap:wrap;font-size:12px}
|
|
1002
|
+
.dca-capability-filters label{cursor:pointer;min-height:28px}
|
|
1003
|
+
.dca-mode-switch{display:flex;flex-wrap:wrap;gap:4px;padding:4px;border-radius:9px;background:var(--dsw-alias-bg-layer-1,#17181b)}
|
|
1004
|
+
.dca-mode-switch .dca-filter{flex:1;min-height:32px}
|
|
1005
|
+
.dca-file-state{display:flex;flex-direction:column;gap:4px;font-size:12px;overflow-wrap:anywhere}
|
|
1006
|
+
.dca-feature-stack.dca-backup-form{padding-top:0}
|
|
1007
|
+
.dca-preset-tools{display:flex;flex-direction:column;gap:10px;min-width:0}
|
|
1008
|
+
.dca-pop-dot-warn{background:var(--dsw-alias-state-warn-primary,#d49937)}
|
|
1009
|
+
|
|
1010
|
+
.dca-feature-stack{display:flex;flex-direction:column;gap:12px;min-width:0;padding-top:12px}
|
|
1011
|
+
.dca-feature-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(210px,100%),1fr));gap:12px}
|
|
1012
|
+
.dca-subtitle{font-size:13px;font-weight:600;margin:0}
|
|
1013
|
+
.dca-preview-box{border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;padding:12px;max-width:100%;overflow-wrap:anywhere}
|
|
1014
|
+
.dca-health{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:11px;color:var(--dsw-alias-label-secondary,#b6b8be)}
|
|
1015
|
+
.dca-health-bad{color:var(--dsw-alias-state-warn-primary,#d49937)}
|
|
1016
|
+
.dca-preset-preview{max-height:180px;overflow:auto;margin:0;padding-inline-start:20px}
|
|
1017
|
+
.dca-preset-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
1018
|
+
.dca-preset-row .dca-input{flex:1;min-width:min(180px,100%)}
|
|
1019
|
+
|
|
1020
|
+
@media(prefers-reduced-motion:reduce){
|
|
1021
|
+
.dca-page *,.dca-pop *{animation:none!important;transition:none!important}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/* ---- composer pill ----------------------------------------------------
|
|
1025
|
+
Plain composer text, no border or fill at rest: this row is a strip of
|
|
1026
|
+
compact controls and a boxed pill among them reads as a form field. The
|
|
1027
|
+
padding is only the click target, revealed by hover. */
|
|
1028
|
+
/* position:relative is load-bearing, not cosmetic: the popover is absolute, and
|
|
1029
|
+
without a positioned owner here it anchors to the nearest positioned ancestor
|
|
1030
|
+
— the composer card — so it appeared at the card's far-left edge rather than
|
|
1031
|
+
above the trigger the user just clicked. */
|
|
1032
|
+
.dca-chip{position:relative;display:inline-flex;align-items:center;min-width:0}
|
|
1033
|
+
.dca-chip-trigger{
|
|
1034
|
+
appearance:none;display:inline-flex;align-items:center;align-self:stretch;gap:5px;
|
|
1035
|
+
padding:2px 6px;border:0;border-radius:var(--dsw-radius-sm,8px);background:transparent;
|
|
1036
|
+
font-family:inherit;font-size:12px;line-height:18px;
|
|
1037
|
+
color:var(--dsw-alias-label-tertiary,#999);
|
|
1038
|
+
white-space:nowrap;cursor:pointer;font-variant-numeric:tabular-nums;
|
|
1039
|
+
}
|
|
1040
|
+
.dca-chip-trigger:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
|
|
1041
|
+
.dca-chip-trigger:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
|
|
1042
|
+
.dca-chip-trigger-on{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));color:var(--dsw-alias-label-primary,#e6e6e6)}
|
|
1043
|
+
.dca-chip-mark{opacity:.75;font-size:11px}
|
|
1044
|
+
/* Anchored to .dca-chip. Right-aligned rather than left so a trigger sitting at
|
|
1045
|
+
the right edge of the composer does not push the panel off-screen. */
|
|
1046
|
+
.dca-pop{
|
|
1047
|
+
position:absolute;bottom:calc(100% + 6px);right:0;z-index:20;min-width:250px;max-width:min(340px,80vw);
|
|
1048
|
+
padding:12px;border-radius:var(--dsw-radius-lg,16px);
|
|
1049
|
+
border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.24));
|
|
1050
|
+
background:var(--dsw-alias-bg-overlay,#26282e);
|
|
1051
|
+
box-shadow:0 8px 24px rgba(0,0,0,.28);
|
|
1052
|
+
display:flex;flex-direction:column;gap:10px;
|
|
1053
|
+
font-size:12px;line-height:18px;color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
1054
|
+
}
|
|
1055
|
+
.dca-pop-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
|
|
1056
|
+
/* nowrap: the header is a title plus a small control in a 248px popover, and
|
|
1057
|
+
without it the title broke across two lines the moment the control joined it. */
|
|
1058
|
+
.dca-pop-title{
|
|
1059
|
+
flex:none;white-space:nowrap;
|
|
1060
|
+
font-size:13px;font-weight:600;
|
|
1061
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
1062
|
+
}
|
|
1063
|
+
.dca-pop-refresh{
|
|
1064
|
+
appearance:none;flex:none;display:inline-flex;align-items:center;gap:4px;
|
|
1065
|
+
padding:3px 8px 3px 6px;margin-left:auto;
|
|
1066
|
+
border:1px solid transparent;border-radius:999px;background:transparent;
|
|
1067
|
+
color:var(--dsw-alias-label-secondary,#c6c9d0);
|
|
1068
|
+
font:inherit;font-size:11px;line-height:16px;font-weight:500;cursor:pointer;
|
|
1069
|
+
transition:background-color .12s ease,border-color .12s ease,color .12s ease;
|
|
1070
|
+
}
|
|
1071
|
+
.dca-pop-refresh:hover:not(:disabled){
|
|
1072
|
+
background:rgba(127,127,127,.10);
|
|
1073
|
+
border-color:var(--dsw-alias-border-l2,#3a3d45);
|
|
1074
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);
|
|
1075
|
+
}
|
|
1076
|
+
.dca-pop-refresh:disabled{cursor:default;opacity:.6}
|
|
1077
|
+
.dca-pop-refresh-icon{flex:none}
|
|
1078
|
+
.dca-pop-refresh-icon-spin{animation:dca-spin .9s linear infinite}
|
|
1079
|
+
@keyframes dca-spin{to{transform:rotate(360deg)}}
|
|
1080
|
+
/* The settings pill is the one control that LEAVES the panel, so it carries the
|
|
1081
|
+
brand tint while refresh above stays quiet: two equally loud pills would make
|
|
1082
|
+
the header read as a toolbar. */
|
|
1083
|
+
.dca-pop-settings{
|
|
1084
|
+
appearance:none;flex:none;display:inline-flex;align-items:center;gap:4px;
|
|
1085
|
+
padding:3px 8px 3px 6px;
|
|
1086
|
+
border:1px solid rgba(86,134,254,.32);border-radius:999px;
|
|
1087
|
+
background:rgba(86,134,254,.12);
|
|
1088
|
+
color:var(--dsw-alias-brand-primary,#5686fe);
|
|
1089
|
+
font:inherit;font-size:11px;line-height:16px;font-weight:500;cursor:pointer;
|
|
1090
|
+
}
|
|
1091
|
+
.dca-pop-settings:hover{background:rgba(86,134,254,.20)}
|
|
1092
|
+
.dca-pop-settings-icon{font-size:11px;line-height:1}
|
|
1093
|
+
/* A real table so every balance lands in one right-aligned column. */
|
|
1094
|
+
.dca-pop-table{width:100%;border-collapse:collapse;font-size:12px;line-height:18px}
|
|
1095
|
+
.dca-pop-table thead th{
|
|
1096
|
+
padding:0 0 7px;font-weight:500;text-align:left;font-size:11px;
|
|
1097
|
+
color:var(--dsw-alias-label-tertiary,#999);
|
|
1098
|
+
border-bottom:1px solid var(--dsw-alias-border-l1,#2c2d31);
|
|
1099
|
+
}
|
|
1100
|
+
.dca-pop-table thead th.dca-pop-num{padding-right:0}
|
|
1101
|
+
.dca-pop-table tbody td{padding:5px 0;border-top:1px solid transparent;vertical-align:top}
|
|
1102
|
+
.dca-pop-num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
1103
|
+
/* The row body is a button so switching accounts is one click, but it must read
|
|
1104
|
+
as a row: no border, no fill at rest, the whole cell as the target. */
|
|
1105
|
+
.dca-pop-switch{
|
|
1106
|
+
appearance:none;display:flex;align-items:flex-start;gap:6px;width:100%;
|
|
1107
|
+
/* Negative inline margin so the hover fill reaches the panel's edge while the
|
|
1108
|
+
text stays aligned with the header above it — the padding does the inset. */
|
|
1109
|
+
padding:4px 6px;margin-inline-start:-6px;
|
|
1110
|
+
border:0;border-radius:6px;background:transparent;font:inherit;text-align:left;
|
|
1111
|
+
color:var(--dsw-alias-label-primary,#e6e6e6);cursor:pointer;min-width:0;
|
|
1112
|
+
transition:background-color .12s ease;
|
|
1113
|
+
}
|
|
1114
|
+
/* Hover belongs to the SWITCH, not the row: the credits cell is not clickable, so
|
|
1115
|
+
lighting it up would promise an action it cannot perform. */
|
|
1116
|
+
.dca-pop-switch:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
|
|
1117
|
+
.dca-pop-switch:active:not(:disabled){background:var(--dsw-alias-interactive-bg-pressed,rgba(127,127,127,.20))}
|
|
1118
|
+
/* Keyboard gets the same affordance as the pointer, plus an outline: tabbing to a
|
|
1119
|
+
row must show which one is about to be switched. */
|
|
1120
|
+
.dca-pop-switch:focus-visible{
|
|
1121
|
+
outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-1px;
|
|
1122
|
+
background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14));
|
|
1123
|
+
}
|
|
1124
|
+
.dca-pop-switch:disabled{cursor:default}
|
|
1125
|
+
/* The serving row is already in use, so it is the one row that must NOT look
|
|
1126
|
+
clickable: it keeps the underline-free quiet treatment. */
|
|
1127
|
+
.dca-pop-row-current .dca-pop-name{font-weight:600}
|
|
1128
|
+
.dca-pop-dot{flex:none;width:7px;height:7px;border-radius:50%;margin-top:6px}
|
|
1129
|
+
.dca-pop-dot-ok{background:var(--dsw-alias-state-success-primary,#22a06b)}
|
|
1130
|
+
.dca-pop-dot-bad{background:var(--dsw-alias-state-error-primary,#ef4444)}
|
|
1131
|
+
.dca-pop-who{display:flex;flex-direction:column;min-width:0}
|
|
1132
|
+
.dca-pop-name{overflow:hidden;text-overflow:ellipsis}
|
|
1133
|
+
/* The state goes UNDER the name: a reason string is long, and beside the name in
|
|
1134
|
+
a 248px panel it would squeeze the name to a few characters. */
|
|
1135
|
+
.dca-pop-mark{display:flex;flex-direction:column;gap:1px;margin-top:1px;font-size:11px;line-height:15px}
|
|
1136
|
+
.dca-pop-mark-current{color:var(--dsw-alias-state-success-primary,#22a06b)}
|
|
1137
|
+
.dca-pop-mark-reason{color:var(--dsw-alias-state-warn-primary,#f59e0b);min-width:0;overflow-wrap:anywhere}
|
|
1138
|
+
/* The lapsing warning sits on its OWN line under the figure: the column is
|
|
1139
|
+
nowrap and tabular, so an inline span would sit beside the balance and stretch
|
|
1140
|
+
the column for every row. */
|
|
1141
|
+
.dca-pop-soon{
|
|
1142
|
+
display:block;margin-top:1px;
|
|
1143
|
+
font-size:11px;line-height:15px;font-weight:400;
|
|
1144
|
+
color:var(--dsw-alias-state-warn-primary,#f59e0b);
|
|
1145
|
+
}
|
|
1146
|
+
.dca-pop-empty{margin:0;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
|
|
1147
|
+
`
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* The state every tab needs before it can show anything.
|
|
1151
|
+
*
|
|
1152
|
+
* Without this, a tab rendered while the first fetch is still in flight
|
|
1153
|
+
* shows an empty page with no hint that data is on its way — and a failed
|
|
1154
|
+
* fetch looked identical to an account with no data.
|
|
1155
|
+
*/
|
|
1156
|
+
function Pending({ error, onRetry }) {
|
|
1157
|
+
if (error) {
|
|
1158
|
+
return h(
|
|
1159
|
+
'div',
|
|
1160
|
+
{ className: 'dca-card' },
|
|
1161
|
+
h('p', { className: 'dca-msg dca-msg-error' }, `${t('common.retryHint')}(${error})`),
|
|
1162
|
+
h(
|
|
1163
|
+
'div',
|
|
1164
|
+
{ className: 'dca-row' },
|
|
1165
|
+
h('button', { type: 'button', className: 'dca-btn', onClick: onRetry }, t('common.retry')),
|
|
1166
|
+
),
|
|
1167
|
+
)
|
|
1168
|
+
}
|
|
1169
|
+
return h(
|
|
1170
|
+
'div',
|
|
1171
|
+
{ className: 'dca-card' },
|
|
1172
|
+
h('p', { className: 'dca-hint' }, t('common.loading')),
|
|
1173
|
+
)
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/** Share only known diagnostic fields. Error strings and labels can contain secrets or paths. */
|
|
1177
|
+
function diagnosticReport(status, account) {
|
|
1178
|
+
const catalog = status?.catalog
|
|
1179
|
+
const credential = status?.credential
|
|
1180
|
+
const credentialSources = ['env', 'file', 'codearts']
|
|
1181
|
+
return {
|
|
1182
|
+
provider: PROVIDER_ID,
|
|
1183
|
+
catalog: {
|
|
1184
|
+
source: ['gateway', 'cache', 'fallback'].includes(catalog?.source) ? catalog.source : null,
|
|
1185
|
+
count: Number.isInteger(catalog?.models) ? catalog.models : null,
|
|
1186
|
+
refreshedAt: Number.isFinite(catalog?.refreshedAt) ? catalog.refreshedAt : null,
|
|
1187
|
+
hasError: Boolean(catalog?.error),
|
|
1188
|
+
},
|
|
1189
|
+
credential: {
|
|
1190
|
+
configured: credential?.configured === true,
|
|
1191
|
+
source: credentialSources.includes(credential?.source) ? credential.source : null,
|
|
1192
|
+
savedAkSet: Boolean(credential?.savedAk),
|
|
1193
|
+
savedSkSet: Boolean(credential?.savedSk),
|
|
1194
|
+
hasError: Boolean(credential?.error),
|
|
1195
|
+
},
|
|
1196
|
+
registration: { configSchema: status?.registration?.configSchema === true },
|
|
1197
|
+
account: account ? {
|
|
1198
|
+
ok: account.ok === true,
|
|
1199
|
+
stage: ['credentials', 'gateway'].includes(account.stage) ? account.stage : null,
|
|
1200
|
+
creditAvailable: Boolean(account.credit),
|
|
1201
|
+
} : null,
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
function catalogSourceLabel(source) {
|
|
1206
|
+
if (source === 'gateway') return t('models.sourceGateway')
|
|
1207
|
+
if (source === 'cache') return t('models.sourceCache')
|
|
1208
|
+
if (source === 'fallback') return t('models.sourceFallback')
|
|
1209
|
+
return '—'
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/** A small labelled value row. */
|
|
1213
|
+
function KV({ name, children }) {
|
|
1214
|
+
return h(
|
|
1215
|
+
React.Fragment,
|
|
1216
|
+
null,
|
|
1217
|
+
h('span', { className: 'dca-diag-label' }, name),
|
|
1218
|
+
h('span', { className: 'dca-diag-value' }, children),
|
|
1219
|
+
)
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* Add one account, import many, and export the pool.
|
|
1224
|
+
*
|
|
1225
|
+
* Import takes pasted text rather than a file picker: the browser can read
|
|
1226
|
+
* a dropped file, but a paste works for every source a user actually has
|
|
1227
|
+
* (the console's CSV contents, a chat message with a key in it, another
|
|
1228
|
+
* install's export).
|
|
1229
|
+
*/
|
|
1230
|
+
/**
|
|
1231
|
+
* Add accounts.
|
|
1232
|
+
*
|
|
1233
|
+
* Two paths, both in the reference's shape: a pair typed by hand (this
|
|
1234
|
+
* plugin's own route has an AK/SK form, which WorkBuddy does not need
|
|
1235
|
+
* because it signs in), and a FILE IMPORT that opens the system picker
|
|
1236
|
+
* directly — no ceremony dialog in front of a dialog the OS is about to show
|
|
1237
|
+
* anyway. The confirmation appears after the file is read, which is the step
|
|
1238
|
+
* that actually needs the user's attention.
|
|
1239
|
+
*
|
|
1240
|
+
* Export downloads a JSON file rather than copying to the clipboard: the
|
|
1241
|
+
* card runs inside the settings panel, where `a[download]` on a same-origin
|
|
1242
|
+
* Blob is the reliable way out, and a file is what a user expects when the
|
|
1243
|
+
* button says 导出.
|
|
1244
|
+
*/
|
|
1245
|
+
function AccountTools({ onChanged, onResult, hasAccounts, updateTarget }) {
|
|
1246
|
+
const [expanded, setExpanded] = useState(false)
|
|
1247
|
+
useEffect(() => {
|
|
1248
|
+
if (hasAccounts !== null) setExpanded(!hasAccounts)
|
|
1249
|
+
}, [hasAccounts])
|
|
1250
|
+
const [showSecret, setShowSecret] = useState(false)
|
|
1251
|
+
const [ak, setAk] = useState('')
|
|
1252
|
+
const [sk, setSk] = useState('')
|
|
1253
|
+
const [label, setLabel] = useState('')
|
|
1254
|
+
const [busy, setBusy] = useState(null)
|
|
1255
|
+
const [preview, setPreview] = useState(null)
|
|
1256
|
+
const fileInput = useRef(null)
|
|
1257
|
+
/** The picked file's text, held here: the picker closes immediately, so
|
|
1258
|
+
* there is no File on screen between preview and confirm. */
|
|
1259
|
+
const importText = useRef('')
|
|
1260
|
+
const akInput = useRef(null)
|
|
1261
|
+
useEffect(() => {
|
|
1262
|
+
if (!updateTarget) return
|
|
1263
|
+
setExpanded(true); setLabel(updateTarget.label ?? ''); setAk(''); setSk('')
|
|
1264
|
+
akInput.current?.focus()
|
|
1265
|
+
}, [updateTarget])
|
|
1266
|
+
|
|
1267
|
+
const add = useCallback(async () => {
|
|
1268
|
+
if (ak.trim() === '' || sk.trim() === '') {
|
|
1269
|
+
onResult({ kind: 'error', text: t('account.needBoth') })
|
|
1270
|
+
return
|
|
1271
|
+
}
|
|
1272
|
+
setBusy('add')
|
|
1273
|
+
try {
|
|
1274
|
+
const result = await postRoute('/accounts/add', { ak, sk, label })
|
|
1275
|
+
if (result.ok) {
|
|
1276
|
+
setAk(''); setSk(''); setLabel('')
|
|
1277
|
+
setShowSecret(false)
|
|
1278
|
+
setExpanded(false)
|
|
1279
|
+
onResult({ kind: 'success', text: result.added ? t('pool.added') : t('pool.updated') })
|
|
1280
|
+
await onChanged()
|
|
1281
|
+
} else {
|
|
1282
|
+
onResult({ kind: 'error', text: result.error ?? t('account.saveFail') })
|
|
1283
|
+
}
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
onResult({ kind: 'error', text: `${t('account.saveFail')}:${error.message}` })
|
|
1286
|
+
} finally { setBusy(null) }
|
|
1287
|
+
}, [ak, sk, label, onChanged, onResult])
|
|
1288
|
+
|
|
1289
|
+
/** Read the picked file and show what it contains before writing. */
|
|
1290
|
+
const readFile = useCallback(async (file) => {
|
|
1291
|
+
setBusy('import')
|
|
1292
|
+
setPreview(null)
|
|
1293
|
+
try {
|
|
1294
|
+
const text = await file.text()
|
|
1295
|
+
importText.current = text
|
|
1296
|
+
const result = await postRoute('/accounts/preview', { text })
|
|
1297
|
+
if (result.ok) {
|
|
1298
|
+
setPreview({ total: result.total, accounts: result.accounts })
|
|
1299
|
+
} else {
|
|
1300
|
+
onResult({ kind: 'error', text: result.error ?? t('pool.importEmpty') })
|
|
1301
|
+
}
|
|
1302
|
+
} catch (error) {
|
|
1303
|
+
onResult({ kind: 'error', text: error.message })
|
|
1304
|
+
} finally { setBusy(null) }
|
|
1305
|
+
}, [onResult])
|
|
1306
|
+
|
|
1307
|
+
const confirmImport = useCallback(async () => {
|
|
1308
|
+
setBusy('import')
|
|
1309
|
+
try {
|
|
1310
|
+
const result = await postRoute('/accounts/import', { text: importText.current })
|
|
1311
|
+
setPreview(null)
|
|
1312
|
+
importText.current = ''
|
|
1313
|
+
if (result.ok) {
|
|
1314
|
+
onResult({
|
|
1315
|
+
kind: 'success',
|
|
1316
|
+
text: t('pool.importResult')
|
|
1317
|
+
.replace('{added}', result.added)
|
|
1318
|
+
.replace('{updated}', result.updated)
|
|
1319
|
+
.replace('{skipped}', result.skipped),
|
|
1320
|
+
})
|
|
1321
|
+
await onChanged()
|
|
1322
|
+
} else {
|
|
1323
|
+
onResult({ kind: 'error', text: result.error ?? t('pool.importEmpty') })
|
|
1324
|
+
}
|
|
1325
|
+
} catch (error) {
|
|
1326
|
+
onResult({ kind: 'error', text: error.message })
|
|
1327
|
+
} finally { setBusy(null) }
|
|
1328
|
+
}, [onChanged, onResult])
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
return h(
|
|
1332
|
+
'details',
|
|
1333
|
+
{
|
|
1334
|
+
className: 'dca-card dca-details dca-add-tools',
|
|
1335
|
+
open: expanded,
|
|
1336
|
+
onToggle: (event) => setExpanded(event.currentTarget.open),
|
|
1337
|
+
},
|
|
1338
|
+
h('summary', null, t('pool.addTitle')),
|
|
1339
|
+
updateTarget ? h('p', { className: 'dca-hint' }, t('health.updateHint').replace('{name}', updateTarget.label)) : null,
|
|
1340
|
+
h(
|
|
1341
|
+
'form',
|
|
1342
|
+
{ className: 'dca-form', onSubmit: (event) => { event.preventDefault(); if (busy === null) void add() } },
|
|
1343
|
+
h(
|
|
1344
|
+
'div',
|
|
1345
|
+
{ className: 'dca-fields' },
|
|
1346
|
+
h('label', { className: 'dca-form-field', htmlFor: 'dca-ak2' },
|
|
1347
|
+
t('account.ak'),
|
|
1348
|
+
h('input', {
|
|
1349
|
+
ref: akInput, id: 'dca-ak2', className: 'dca-input', value: ak, autoComplete: 'off',
|
|
1350
|
+
placeholder: t('account.placeholderAk'), disabled: busy !== null,
|
|
1351
|
+
'aria-label': t('account.ak'), onChange: (event) => setAk(event.target.value),
|
|
1352
|
+
}),
|
|
1353
|
+
),
|
|
1354
|
+
h('label', { className: 'dca-form-field', htmlFor: 'dca-sk2' },
|
|
1355
|
+
t('account.sk'),
|
|
1356
|
+
h('span', { className: 'dca-secret-field' },
|
|
1357
|
+
h('input', {
|
|
1358
|
+
id: 'dca-sk2', className: 'dca-input', type: showSecret ? 'text' : 'password',
|
|
1359
|
+
value: sk, autoComplete: 'off', placeholder: t('account.placeholderSk'),
|
|
1360
|
+
disabled: busy !== null, 'aria-label': t('account.sk'),
|
|
1361
|
+
onChange: (event) => setSk(event.target.value),
|
|
1362
|
+
}),
|
|
1363
|
+
h('button', {
|
|
1364
|
+
type: 'button', className: 'dca-btn-xs', 'aria-controls': 'dca-sk2',
|
|
1365
|
+
'aria-pressed': showSecret, 'aria-label': t(showSecret ? 'pool.hideSecret' : 'pool.showSecret'), disabled: busy !== null,
|
|
1366
|
+
onClick: () => setShowSecret((current) => !current),
|
|
1367
|
+
}, t(showSecret ? 'pool.hideSecret' : 'pool.showSecret')),
|
|
1368
|
+
),
|
|
1369
|
+
),
|
|
1370
|
+
h('label', { className: 'dca-form-field', htmlFor: 'dca-label' },
|
|
1371
|
+
t('pool.addLabel'),
|
|
1372
|
+
h('input', {
|
|
1373
|
+
id: 'dca-label', className: 'dca-input', value: label, autoComplete: 'off',
|
|
1374
|
+
placeholder: t('pool.addLabelPlaceholder'), disabled: busy !== null,
|
|
1375
|
+
onChange: (event) => setLabel(event.target.value),
|
|
1376
|
+
}),
|
|
1377
|
+
),
|
|
1378
|
+
),
|
|
1379
|
+
h('div', { className: 'dca-pool-actions-group' },
|
|
1380
|
+
h('button', {
|
|
1381
|
+
type: 'submit', className: 'dca-btn dca-btn-primary',
|
|
1382
|
+
disabled: busy !== null || !ak.trim() || !sk.trim(),
|
|
1383
|
+
}, busy === 'add' ? t('account.saving') : t('pool.add')),
|
|
1384
|
+
h('button', {
|
|
1385
|
+
type: 'button', className: 'dca-btn', disabled: busy !== null,
|
|
1386
|
+
onClick: () => fileInput.current?.click(),
|
|
1387
|
+
}, busy === 'import' ? t('pool.importing') : t('pool.import')),
|
|
1388
|
+
),
|
|
1389
|
+
),
|
|
1390
|
+
h('input', {
|
|
1391
|
+
ref: fileInput, type: 'file', accept: 'application/json,.json,.csv,.txt',
|
|
1392
|
+
className: 'dca-file-input',
|
|
1393
|
+
onChange: (event) => {
|
|
1394
|
+
const file = event.target.files?.[0]
|
|
1395
|
+
event.target.value = ''
|
|
1396
|
+
if (file !== undefined) void readFile(file)
|
|
1397
|
+
},
|
|
1398
|
+
}),
|
|
1399
|
+
preview !== null
|
|
1400
|
+
? h(
|
|
1401
|
+
'div',
|
|
1402
|
+
{ className: 'dca-transfer-dialog', role: 'dialog', 'aria-label': t('pool.import') },
|
|
1403
|
+
h(
|
|
1404
|
+
'p',
|
|
1405
|
+
{ className: 'dca-hint' },
|
|
1406
|
+
t('pool.previewTotal').replace('{count}', preview.accounts.length),
|
|
1407
|
+
),
|
|
1408
|
+
h(
|
|
1409
|
+
'ul',
|
|
1410
|
+
{ className: 'dca-transfer-list' },
|
|
1411
|
+
...preview.accounts.map((entry) =>
|
|
1412
|
+
h(
|
|
1413
|
+
'li',
|
|
1414
|
+
{ key: entry.index },
|
|
1415
|
+
entry.label ?? entry.akMasked ?? `#${entry.index}`,
|
|
1416
|
+
),
|
|
1417
|
+
),
|
|
1418
|
+
),
|
|
1419
|
+
h(
|
|
1420
|
+
'div',
|
|
1421
|
+
{ className: 'dca-transfer-actions' },
|
|
1422
|
+
h(
|
|
1423
|
+
'button',
|
|
1424
|
+
{
|
|
1425
|
+
type: 'button',
|
|
1426
|
+
className: 'dca-btn',
|
|
1427
|
+
onClick: () => { setPreview(null); importText.current = '' },
|
|
1428
|
+
},
|
|
1429
|
+
t('pool.cancel'),
|
|
1430
|
+
),
|
|
1431
|
+
h(
|
|
1432
|
+
'button',
|
|
1433
|
+
{ type: 'button', className: 'dca-btn dca-btn-primary', onClick: confirmImport, disabled: busy !== null },
|
|
1434
|
+
busy === 'import'
|
|
1435
|
+
? t('pool.importing')
|
|
1436
|
+
: t('pool.importConfirm').replace('{count}', preview.accounts.length),
|
|
1437
|
+
),
|
|
1438
|
+
),
|
|
1439
|
+
)
|
|
1440
|
+
: null,
|
|
1441
|
+
h('details', { className: 'dca-details' },
|
|
1442
|
+
h('summary', null, t('account.whereToGet')),
|
|
1443
|
+
h('p', { className: 'dca-hint' }, t('account.whereToGetBody')),
|
|
1444
|
+
),
|
|
1445
|
+
)
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* The account pool.
|
|
1450
|
+
*
|
|
1451
|
+
* The header shows the account in use and one manual check-in action for
|
|
1452
|
+
* the whole pool. Two-line rows keep identity, balances and health aligned.
|
|
1453
|
+
*/
|
|
1454
|
+
function AccountPool({
|
|
1455
|
+
pool,
|
|
1456
|
+
rowAction,
|
|
1457
|
+
rowNotice,
|
|
1458
|
+
busy,
|
|
1459
|
+
onActivate,
|
|
1460
|
+
onRemove,
|
|
1461
|
+
onCheckinAll,
|
|
1462
|
+
onRename,
|
|
1463
|
+
onExport,
|
|
1464
|
+
onCheck,
|
|
1465
|
+
onUpdateCredentials,
|
|
1466
|
+
}) {
|
|
1467
|
+
/** Which row is being renamed, and its draft text. */
|
|
1468
|
+
const [editingId, setEditingId] = useState(null)
|
|
1469
|
+
const [draftLabel, setDraftLabel] = useState('')
|
|
1470
|
+
const [now, setNow] = useState(Date.now)
|
|
1471
|
+
useEffect(() => {
|
|
1472
|
+
const timer = setInterval(() => setNow(Date.now()), 30000)
|
|
1473
|
+
return () => clearInterval(timer)
|
|
1474
|
+
}, [])
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
const beginRename = useCallback((account) => {
|
|
1478
|
+
setEditingId(account.id)
|
|
1479
|
+
// Start from the current name, EXCEPT when it is the derived fallback
|
|
1480
|
+
// (a masked AK): that is a placeholder, not a name the user chose, and
|
|
1481
|
+
// prefilling it would make them delete it before typing.
|
|
1482
|
+
setDraftLabel(account.renameable === false ? '' : (account.label ?? ''))
|
|
1483
|
+
}, [])
|
|
1484
|
+
|
|
1485
|
+
const cancelRename = useCallback(() => {
|
|
1486
|
+
setEditingId(null)
|
|
1487
|
+
setDraftLabel('')
|
|
1488
|
+
}, [])
|
|
1489
|
+
|
|
1490
|
+
const commitRename = useCallback(async (id) => {
|
|
1491
|
+
const next = draftLabel.trim()
|
|
1492
|
+
setEditingId(null)
|
|
1493
|
+
setDraftLabel('')
|
|
1494
|
+
// An unchanged or empty draft is a cancel, not a request.
|
|
1495
|
+
if (next === '') return
|
|
1496
|
+
await onRename(id, next)
|
|
1497
|
+
}, [draftLabel, onRename])
|
|
1498
|
+
const accounts = pool?.accounts ?? []
|
|
1499
|
+
const busyId = rowAction?.id ?? null
|
|
1500
|
+
// `busy` is the KIND ('checkin' | 'test' | null); most checks only care
|
|
1501
|
+
// whether anything is running.
|
|
1502
|
+
const anyBusy = busy !== null && busy !== undefined && busy !== false
|
|
1503
|
+
// Something to claim right now? The button is disabled otherwise, so a
|
|
1504
|
+
// press that cannot do anything never looks like a broken button.
|
|
1505
|
+
const anyClaimable = accounts.some((account) => account.checkin?.claimable)
|
|
1506
|
+
const allSigned = accounts.length > 0 && accounts.every((account) => account.checkin?.claimedToday === true)
|
|
1507
|
+
const active = accounts.find((account) => account.active)
|
|
1508
|
+
return h(
|
|
1509
|
+
'div',
|
|
1510
|
+
{ className: 'dca-pool' },
|
|
1511
|
+
|
|
1512
|
+
h(
|
|
1513
|
+
'div',
|
|
1514
|
+
{ className: 'dca-pool-card-head' },
|
|
1515
|
+
h('h2', { className: 'dca-title' }, t('pool.title')),
|
|
1516
|
+
h('p', { className: 'dca-hint dca-pool-tagline' }, t('pool.tagline')),
|
|
1517
|
+
h('div', { className: 'dca-pool-actions-group' },
|
|
1518
|
+
active ? h('span', { className: 'dca-badge' }, `${t('pool.inUse')}${active.label}`) : null,
|
|
1519
|
+
accounts.length > 0 ? h('button', {
|
|
1520
|
+
type: 'button', className: 'dca-btn-xs', onClick: onExport, disabled: anyBusy || busyId !== null,
|
|
1521
|
+
title: t('pool.exportHint'),
|
|
1522
|
+
}, t('pool.export')) : null,
|
|
1523
|
+
),
|
|
1524
|
+
accounts.length === 0
|
|
1525
|
+
? null
|
|
1526
|
+
: h(
|
|
1527
|
+
'button',
|
|
1528
|
+
{
|
|
1529
|
+
type: 'button',
|
|
1530
|
+
className: 'dca-btn dca-btn-xs',
|
|
1531
|
+
disabled: anyBusy || busyId !== null || !anyClaimable,
|
|
1532
|
+
title: anyClaimable
|
|
1533
|
+
? t('pool.checkinAllHint')
|
|
1534
|
+
: t('pool.checkinNoneToday'),
|
|
1535
|
+
onClick: onCheckinAll,
|
|
1536
|
+
},
|
|
1537
|
+
busy === 'checkin' ? t('pool.checkinClaiming') : allSigned ? t('pool.allSigned') : t('pool.checkinAll'),
|
|
1538
|
+
),
|
|
1539
|
+
),
|
|
1540
|
+
|
|
1541
|
+
accounts.length === 0
|
|
1542
|
+
? h('p', { className: 'dca-hint' }, t('pool.empty'))
|
|
1543
|
+
: h(
|
|
1544
|
+
'div',
|
|
1545
|
+
{ className: 'dca-pool-table' },
|
|
1546
|
+
h(
|
|
1547
|
+
'div',
|
|
1548
|
+
{ className: 'dca-pool-row dca-pool-row-head' },
|
|
1549
|
+
h('span', { className: 'dca-pool-col-account' }, t('pool.colAccount')),
|
|
1550
|
+
h('span', { className: 'dca-pool-col-credits' }, t('pool.colCredits')),
|
|
1551
|
+
// An empty cell on purpose: the grid template names an `actions`
|
|
1552
|
+
// area, and without a box the credits label would claim that
|
|
1553
|
+
// track and stop lining up with the values below it. The buttons
|
|
1554
|
+
// speak for themselves, so it carries no text.
|
|
1555
|
+
h('span', { className: 'dca-pool-col-actions', 'aria-hidden': true }),
|
|
1556
|
+
),
|
|
1557
|
+
...accounts.map((account) => {
|
|
1558
|
+
const rowBusy = busyId === account.id
|
|
1559
|
+
const checkin = account.checkin
|
|
1560
|
+
return h(
|
|
1561
|
+
'div',
|
|
1562
|
+
{
|
|
1563
|
+
key: account.id,
|
|
1564
|
+
className: `dca-pool-row${account.active ? ' dca-pool-row-current' : ''}`,
|
|
1565
|
+
'aria-busy': rowBusy,
|
|
1566
|
+
},
|
|
1567
|
+
h(
|
|
1568
|
+
'div',
|
|
1569
|
+
{ className: 'dca-pool-col-account' },
|
|
1570
|
+
h(
|
|
1571
|
+
'div',
|
|
1572
|
+
{ className: 'dca-pool-account-row' },
|
|
1573
|
+
account.active ? h('span', { className: 'dca-current-tag' }, t('pool.current')) : null,
|
|
1574
|
+
editingId === account.id
|
|
1575
|
+
? h('input', {
|
|
1576
|
+
type: 'text',
|
|
1577
|
+
className: 'dca-input dca-rename',
|
|
1578
|
+
value: draftLabel,
|
|
1579
|
+
autoFocus: true,
|
|
1580
|
+
'aria-label': t('pool.rename'),
|
|
1581
|
+
placeholder: t('pool.renamePlaceholder'),
|
|
1582
|
+
onChange: (event) => setDraftLabel(event.target.value),
|
|
1583
|
+
onKeyDown: (event) => {
|
|
1584
|
+
if (event.key === 'Enter') void commitRename(account.id)
|
|
1585
|
+
// Escape must not save: an accidental click into the
|
|
1586
|
+
// field is the common way a user arrives here.
|
|
1587
|
+
else if (event.key === 'Escape') cancelRename()
|
|
1588
|
+
},
|
|
1589
|
+
onBlur: () => void commitRename(account.id),
|
|
1590
|
+
})
|
|
1591
|
+
: h(
|
|
1592
|
+
'button',
|
|
1593
|
+
{
|
|
1594
|
+
type: 'button',
|
|
1595
|
+
className: 'dca-rename-btn',
|
|
1596
|
+
title: t('pool.renameHint'),
|
|
1597
|
+
onClick: () => beginRename(account),
|
|
1598
|
+
},
|
|
1599
|
+
h('b', null, account.label),
|
|
1600
|
+
h('span', { className: 'dca-rename-glyph', 'aria-hidden': true }, '✎'),
|
|
1601
|
+
),
|
|
1602
|
+
),
|
|
1603
|
+
h(
|
|
1604
|
+
'div',
|
|
1605
|
+
{ className: 'dca-pool-probe' },
|
|
1606
|
+
h('div', { className: `dca-health${account.health?.state && account.health.state !== 'available' ? ' dca-health-bad' : ''}` },
|
|
1607
|
+
h('span', null, t(`health.${account.health?.state ?? 'unknown'}`)),
|
|
1608
|
+
account.health?.checkedAt ? h('time', {
|
|
1609
|
+
dateTime: new Date(account.health.checkedAt).toISOString(),
|
|
1610
|
+
title: `${t('health.checked')} ${formatTime(account.health.checkedAt)}`,
|
|
1611
|
+
}, relativeTime(account.health.checkedAt, now)) : null,
|
|
1612
|
+
),
|
|
1613
|
+
h('span', null, account.accountName ?? account.akMasked),
|
|
1614
|
+
account.error ? h('details', { className: 'dca-details dca-account-error' },
|
|
1615
|
+
h('summary', null, t('health.details')),
|
|
1616
|
+
h('p', null, account.error),
|
|
1617
|
+
) : null,
|
|
1618
|
+
),
|
|
1619
|
+
),
|
|
1620
|
+
h(
|
|
1621
|
+
'div',
|
|
1622
|
+
{ className: 'dca-pool-credits-row' },
|
|
1623
|
+
h('span', { className: 'dca-account-credits' }, account.credit ? formatCredits(account.credit.remain) : '—'),
|
|
1624
|
+
h(CreditStatus, { account, now }),
|
|
1625
|
+
account.credit?.plan ? h('span', { className: 'dca-pool-sub' }, account.credit.plan) : null,
|
|
1626
|
+
// Warn about credits that lapse. The amount is real; the
|
|
1627
|
+
// deadline is not knowable from this gateway, so the chip
|
|
1628
|
+
// states the amount and never a date it would have to invent.
|
|
1629
|
+
account.credit?.expiring > 0
|
|
1630
|
+
? h(
|
|
1631
|
+
'span',
|
|
1632
|
+
{
|
|
1633
|
+
className: 'dca-tag dca-tag-warn',
|
|
1634
|
+
title: t('pool.expiringHint'),
|
|
1635
|
+
},
|
|
1636
|
+
t('pool.expiring').replace(
|
|
1637
|
+
'{amount}',
|
|
1638
|
+
Number(account.credit.expiring).toLocaleString(),
|
|
1639
|
+
),
|
|
1640
|
+
)
|
|
1641
|
+
: null,
|
|
1642
|
+
),
|
|
1643
|
+
h(
|
|
1644
|
+
'div',
|
|
1645
|
+
{ className: 'dca-pool-probe-cell' },
|
|
1646
|
+
h(
|
|
1647
|
+
'div',
|
|
1648
|
+
{ className: 'dca-pool-probe-main' },
|
|
1649
|
+
checkin?.claimedToday
|
|
1650
|
+
? t('pool.checkinDone')
|
|
1651
|
+
: checkin?.claimable
|
|
1652
|
+
? t('pool.checkinPending')
|
|
1653
|
+
: '—',
|
|
1654
|
+
),
|
|
1655
|
+
),
|
|
1656
|
+
h(
|
|
1657
|
+
'div',
|
|
1658
|
+
{ className: 'dca-pool-col-actions' },
|
|
1659
|
+
h(
|
|
1660
|
+
'div',
|
|
1661
|
+
{ className: 'dca-pool-actions' },
|
|
1662
|
+
h('button', { type: 'button', className: 'dca-btn-xs', disabled: rowBusy || anyBusy || busyId !== null, onClick: () => onCheck(account.id) }, rowBusy && rowAction.kind === 'check' ? t('common.loading') : t('health.recheck')),
|
|
1663
|
+
account.health?.state === 'credentials' ? h('button', { type: 'button', className: 'dca-btn-xs', disabled: rowBusy || anyBusy || busyId !== null, onClick: () => onUpdateCredentials(account) }, t('health.update')) : null,
|
|
1664
|
+
account.health?.state === 'insufficient' ? h('span', { className: 'dca-hint' }, t('health.switch')) : null,
|
|
1665
|
+
account.active
|
|
1666
|
+
? null
|
|
1667
|
+
: h(
|
|
1668
|
+
'button',
|
|
1669
|
+
{
|
|
1670
|
+
type: 'button',
|
|
1671
|
+
className: 'dca-btn-xs',
|
|
1672
|
+
disabled: rowBusy || anyBusy || busyId !== null,
|
|
1673
|
+
onClick: () => onActivate(account),
|
|
1674
|
+
'aria-busy': rowBusy && rowAction.kind === 'activate',
|
|
1675
|
+
},
|
|
1676
|
+
rowBusy && rowAction.kind === 'activate' ? t('pool.switching') : t('pool.use'),
|
|
1677
|
+
),
|
|
1678
|
+
h('details', { className: 'dca-account-menu' },
|
|
1679
|
+
h('summary', {
|
|
1680
|
+
'aria-label': `${t('common.more')} — ${account.label}`,
|
|
1681
|
+
title: t('common.more'),
|
|
1682
|
+
'aria-disabled': anyBusy || busyId !== null,
|
|
1683
|
+
onClick: (event) => { if (anyBusy || busyId !== null) event.preventDefault() },
|
|
1684
|
+
}, '⋯'),
|
|
1685
|
+
h('div', { className: 'dca-menu-actions' },
|
|
1686
|
+
h('button', {
|
|
1687
|
+
type: 'button', className: 'dca-btn-xs dca-danger',
|
|
1688
|
+
disabled: rowBusy || anyBusy || busyId !== null,
|
|
1689
|
+
onClick: (event) => {
|
|
1690
|
+
event.currentTarget.closest('details').open = false
|
|
1691
|
+
void onRemove(account)
|
|
1692
|
+
},
|
|
1693
|
+
}, t('pool.remove')),
|
|
1694
|
+
),
|
|
1695
|
+
),
|
|
1696
|
+
),
|
|
1697
|
+
),
|
|
1698
|
+
rowNotice?.id === account.id
|
|
1699
|
+
? h('div', { className: 'dca-pool-feedback' }, h(FeatureNotice, { notice: rowNotice }))
|
|
1700
|
+
: null,
|
|
1701
|
+
)
|
|
1702
|
+
}),
|
|
1703
|
+
),
|
|
1704
|
+
|
|
1705
|
+
)
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// ── credentials tab ────────────────────────────────────────────────────
|
|
1709
|
+
|
|
1710
|
+
function AccountTab({ status, pool, onChanged }) {
|
|
1711
|
+
const [busy, setBusy] = useState(null)
|
|
1712
|
+
const [rowAction, setRowAction] = useState(null)
|
|
1713
|
+
const [rowNotice, setRowNotice] = useState(null)
|
|
1714
|
+
const [notice, setNotice] = useState(null)
|
|
1715
|
+
const [updateTarget, setUpdateTarget] = useState(null)
|
|
1716
|
+
|
|
1717
|
+
const credential = status?.credential
|
|
1718
|
+
const reload = onChanged
|
|
1719
|
+
|
|
1720
|
+
/** One place to report an outcome, so every action gets the same voice. */
|
|
1721
|
+
const report = useCallback((next) => setNotice(next), [])
|
|
1722
|
+
|
|
1723
|
+
/** Download the store as a JSON file. */
|
|
1724
|
+
const doExport = useCallback(async () => {
|
|
1725
|
+
setBusy('export')
|
|
1726
|
+
try {
|
|
1727
|
+
const result = await getRoute('/accounts/export')
|
|
1728
|
+
if (!result.ok || typeof result.text !== 'string') {
|
|
1729
|
+
report({ kind: 'error', text: result.error ?? t('pool.exportFailed') })
|
|
1730
|
+
return
|
|
1731
|
+
}
|
|
1732
|
+
if (typeof document === 'undefined' || typeof Blob === 'undefined') {
|
|
1733
|
+
report({ kind: 'error', text: t('pool.exportFailed') })
|
|
1734
|
+
return
|
|
1735
|
+
}
|
|
1736
|
+
const stamp = new Date()
|
|
1737
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
1738
|
+
const name = `codearts-accounts-${stamp.getFullYear()}-${pad(stamp.getMonth() + 1)}-${pad(stamp.getDate())}.json`
|
|
1739
|
+
const blob = new Blob([result.text], { type: 'application/json' })
|
|
1740
|
+
const url = URL.createObjectURL(blob)
|
|
1741
|
+
const anchor = document.createElement('a')
|
|
1742
|
+
anchor.href = url
|
|
1743
|
+
anchor.download = name
|
|
1744
|
+
document.body.appendChild(anchor)
|
|
1745
|
+
anchor.click()
|
|
1746
|
+
anchor.remove()
|
|
1747
|
+
URL.revokeObjectURL(url)
|
|
1748
|
+
report({ kind: 'success', text: `${t('pool.exported').replace('{name}', name)} · ${t('pool.exportHint')}` })
|
|
1749
|
+
} catch (error) {
|
|
1750
|
+
report({ kind: 'error', text: error.message })
|
|
1751
|
+
} finally { setBusy(null) }
|
|
1752
|
+
}, [report])
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
const activate = useCallback(async (account) => {
|
|
1756
|
+
setRowAction({ id: account.id, kind: 'activate' })
|
|
1757
|
+
setRowNotice(null); setNotice(null)
|
|
1758
|
+
try {
|
|
1759
|
+
const result = await postRoute('/accounts/activate', { id: account.id })
|
|
1760
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retryHint'))
|
|
1761
|
+
await reload()
|
|
1762
|
+
setRowNotice({ id: account.id, kind: 'success', text: t('pool.switched').replace('{account}', account.label) })
|
|
1763
|
+
} catch (error) {
|
|
1764
|
+
setRowNotice({ id: account.id, kind: 'error', text: t('pool.switchFailed').replace('{account}', account.label).replace('{error}', error.message) })
|
|
1765
|
+
} finally { setRowAction(null) }
|
|
1766
|
+
}, [reload])
|
|
1767
|
+
|
|
1768
|
+
const remove = useCallback(async (account) => {
|
|
1769
|
+
const ask = t('pool.removeConfirm')
|
|
1770
|
+
if (typeof window !== 'undefined' && typeof window.confirm === 'function' && !window.confirm(ask)) return
|
|
1771
|
+
setRowAction({ id: account.id, kind: 'remove' }); setRowNotice(null)
|
|
1772
|
+
try {
|
|
1773
|
+
await postRoute('/accounts/remove', { id: account.id })
|
|
1774
|
+
report({ kind: 'success', text: t('pool.remove') })
|
|
1775
|
+
await reload()
|
|
1776
|
+
} catch (error) {
|
|
1777
|
+
report({ kind: 'error', text: error.message })
|
|
1778
|
+
} finally { setRowAction(null) }
|
|
1779
|
+
}, [reload, report])
|
|
1780
|
+
|
|
1781
|
+
/** Claim once for the pool after an explicit click. */
|
|
1782
|
+
const checkinAll = useCallback(async () => {
|
|
1783
|
+
setBusy('checkin')
|
|
1784
|
+
try {
|
|
1785
|
+
const result = await postRoute('/checkin/claim-all', {})
|
|
1786
|
+
const summary = result.summary
|
|
1787
|
+
if (summary) {
|
|
1788
|
+
report({
|
|
1789
|
+
kind: summary.failures.length === 0 ? 'success' : 'warn',
|
|
1790
|
+
text: t('pool.checkinResult')
|
|
1791
|
+
.replace('{claimed}', summary.claimed)
|
|
1792
|
+
.replace('{failed}', summary.failures.length),
|
|
1793
|
+
})
|
|
1794
|
+
} else if (result.error) {
|
|
1795
|
+
report({ kind: 'error', text: result.error })
|
|
1796
|
+
}
|
|
1797
|
+
await reload()
|
|
1798
|
+
} catch (error) {
|
|
1799
|
+
report({ kind: 'error', text: `${t('pool.checkinFailed')}:${error.message}` })
|
|
1800
|
+
} finally {
|
|
1801
|
+
setBusy(null)
|
|
1802
|
+
}
|
|
1803
|
+
}, [reload, report])
|
|
1804
|
+
|
|
1805
|
+
/** Rename one account; the pool's inline editor calls this. */
|
|
1806
|
+
const rename = useCallback(async (id, label) => {
|
|
1807
|
+
try {
|
|
1808
|
+
const result = await postRoute('/accounts/rename', { id, label })
|
|
1809
|
+
if (!result.ok) report({ kind: 'error', text: result.error ?? t('pool.renameFailed') })
|
|
1810
|
+
await reload()
|
|
1811
|
+
} catch (error) {
|
|
1812
|
+
report({ kind: 'error', text: `${t('pool.renameFailed')}:${error.message}` })
|
|
1813
|
+
}
|
|
1814
|
+
}, [reload, report])
|
|
1815
|
+
|
|
1816
|
+
const test = useCallback(async () => {
|
|
1817
|
+
setBusy('test')
|
|
1818
|
+
setNotice(null)
|
|
1819
|
+
try {
|
|
1820
|
+
const result = await getRoute('/test')
|
|
1821
|
+
const lines = (result.steps ?? []).map((step) => `${step.ok ? '✓' : '✗'} ${step.step}:${step.detail}`)
|
|
1822
|
+
setNotice({ kind: result.ok ? 'success' : 'error', text: lines.join('\n') || t('diag.none'), pre: true })
|
|
1823
|
+
await onChanged()
|
|
1824
|
+
} catch (error) {
|
|
1825
|
+
setNotice({ kind: 'error', text: error.message })
|
|
1826
|
+
} finally {
|
|
1827
|
+
setBusy(null)
|
|
1828
|
+
}
|
|
1829
|
+
}, [onChanged])
|
|
1830
|
+
|
|
1831
|
+
// Destructive and irreversible from the UI, so it asks first — the button
|
|
1832
|
+
// sits at the same weight as the harmless refresh beside it.
|
|
1833
|
+
const clear = useCallback(async () => {
|
|
1834
|
+
if (typeof window !== 'undefined' && typeof window.confirm === 'function') {
|
|
1835
|
+
if (!window.confirm(t('account.clearConfirm'))) return
|
|
1836
|
+
}
|
|
1837
|
+
setBusy('clear')
|
|
1838
|
+
setNotice(null)
|
|
1839
|
+
try {
|
|
1840
|
+
await postRoute('/clear', {})
|
|
1841
|
+
setNotice({ kind: 'success', text: t('account.cleared') })
|
|
1842
|
+
await onChanged()
|
|
1843
|
+
} catch (error) {
|
|
1844
|
+
setNotice({ kind: 'error', text: `${t('account.clearFail')}:${error.message}` })
|
|
1845
|
+
} finally {
|
|
1846
|
+
setBusy(null)
|
|
1847
|
+
}
|
|
1848
|
+
}, [onChanged])
|
|
1849
|
+
|
|
1850
|
+
const checkAccount = async (id) => {
|
|
1851
|
+
setRowAction({ id, kind: 'check' }); setRowNotice(null)
|
|
1852
|
+
try {
|
|
1853
|
+
const result = await postRoute('/accounts/check', { id })
|
|
1854
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retry'))
|
|
1855
|
+
report({ kind: result.account.health.state === 'available' ? 'success' : 'warn', text: `${result.account.label}:${t(`health.${result.account.health.state}`)}` })
|
|
1856
|
+
await reload()
|
|
1857
|
+
} catch (error) { report({ kind: 'error', text: error.message }) } finally { setRowAction(null) }
|
|
1858
|
+
}
|
|
1859
|
+
const accounts = pool?.accounts ?? []
|
|
1860
|
+
return h(
|
|
1861
|
+
'div',
|
|
1862
|
+
{ className: 'dca-page' },
|
|
1863
|
+
// The pool below renders its own head — title, tagline and the in-use
|
|
1864
|
+
// badge — so the page must not render a second one above it. It did, and
|
|
1865
|
+
// the two read as a duplicated heading with two different sentences
|
|
1866
|
+
// under it.
|
|
1867
|
+
|
|
1868
|
+
// One line for every outcome of every action on this tab, announced.
|
|
1869
|
+
notice
|
|
1870
|
+
? h(
|
|
1871
|
+
'p',
|
|
1872
|
+
{
|
|
1873
|
+
className: `dca-msg dca-msg-${
|
|
1874
|
+
notice.kind === 'error' ? 'error' : notice.kind === 'success' ? 'ok' : 'warn'
|
|
1875
|
+
}`,
|
|
1876
|
+
role: notice.kind === 'error' ? 'alert' : 'status',
|
|
1877
|
+
'aria-live': notice.kind === 'error' ? 'assertive' : 'polite',
|
|
1878
|
+
},
|
|
1879
|
+
notice.text,
|
|
1880
|
+
)
|
|
1881
|
+
: null,
|
|
1882
|
+
|
|
1883
|
+
// The pool renders its own head, its own switch block, the table and the
|
|
1884
|
+
// batch action — the order the reference card uses. The daily switch is
|
|
1885
|
+
// passed in rather than drawn as a separate card, so it sits above the
|
|
1886
|
+
// table where the reference puts it.
|
|
1887
|
+
h(AccountPool, {
|
|
1888
|
+
pool,
|
|
1889
|
+
rowAction,
|
|
1890
|
+
rowNotice,
|
|
1891
|
+
// The pool takes the raw kind, not a collapsed boolean: the check-in
|
|
1892
|
+
// button must know whether IT is the one running so it can show
|
|
1893
|
+
// 「签到中…」 — a boolean cannot express that.
|
|
1894
|
+
busy,
|
|
1895
|
+
onActivate: activate,
|
|
1896
|
+
onRemove: remove,
|
|
1897
|
+
onCheckinAll: checkinAll,
|
|
1898
|
+
onRename: rename,
|
|
1899
|
+
onExport: doExport,
|
|
1900
|
+
onCheck: checkAccount,
|
|
1901
|
+
onUpdateCredentials: (account) => setUpdateTarget({ ...account }),
|
|
1902
|
+
}),
|
|
1903
|
+
|
|
1904
|
+
h(AccountTools, { onChanged, onResult: report, hasAccounts: pool ? accounts.length > 0 : null, updateTarget }),
|
|
1905
|
+
h(BackupTools, { onRestored: onChanged }),
|
|
1906
|
+
|
|
1907
|
+
accounts.length === 0 || credential?.error
|
|
1908
|
+
? null
|
|
1909
|
+
: h(
|
|
1910
|
+
'div',
|
|
1911
|
+
{ className: 'dca-card dca-card-plain' },
|
|
1912
|
+
h(
|
|
1913
|
+
'div',
|
|
1914
|
+
{ className: 'dca-row' },
|
|
1915
|
+
h('button', { type: 'button', className: 'dca-btn', onClick: test, disabled: busy !== null },
|
|
1916
|
+
busy === 'test' ? t('account.testing') : t('account.test')),
|
|
1917
|
+
|
|
1918
|
+
),
|
|
1919
|
+
h('details', { className: 'dca-details' },
|
|
1920
|
+
h('summary', null, t('pool.manage')),
|
|
1921
|
+
h('button', { type: 'button', className: 'dca-btn dca-danger', onClick: clear, disabled: busy !== null }, t('account.clear')),
|
|
1922
|
+
),
|
|
1923
|
+
),
|
|
1924
|
+
)
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
function FeatureNotice({ notice }) {
|
|
1928
|
+
if (!notice) return null
|
|
1929
|
+
return h('p', { className: `dca-msg dca-msg-${notice.kind === 'error' ? 'error' : 'ok'}`, role: notice.kind === 'error' ? 'alert' : 'status' }, notice.text)
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function downloadJson(value, name) {
|
|
1933
|
+
const url = URL.createObjectURL(new Blob([JSON.stringify(value, null, 2)], { type: 'application/json' }))
|
|
1934
|
+
const anchor = document.createElement('a')
|
|
1935
|
+
anchor.href = url
|
|
1936
|
+
anchor.download = name
|
|
1937
|
+
document.body.appendChild(anchor)
|
|
1938
|
+
anchor.click()
|
|
1939
|
+
anchor.remove()
|
|
1940
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 1000)
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
function BackupTools({ onRestored }) {
|
|
1944
|
+
const [mode, setMode] = useState('export')
|
|
1945
|
+
const [includeCredentials, setIncludeCredentials] = useState(false)
|
|
1946
|
+
const [encryptExport, setEncryptExport] = useState(false)
|
|
1947
|
+
const [exportPassword, setExportPassword] = useState('')
|
|
1948
|
+
const [confirmation, setConfirmation] = useState('')
|
|
1949
|
+
const [text, setText] = useState('')
|
|
1950
|
+
const [fileName, setFileName] = useState('')
|
|
1951
|
+
const [password, setPassword] = useState('')
|
|
1952
|
+
const [preview, setPreview] = useState(null)
|
|
1953
|
+
const [busy, setBusy] = useState(null)
|
|
1954
|
+
const [notice, setNotice] = useState(null)
|
|
1955
|
+
const fileInput = useRef(null)
|
|
1956
|
+
const needsEncryption = includeCredentials || encryptExport
|
|
1957
|
+
const validPassword = exportPassword.length >= 8 && exportPassword.length <= 256 && exportPassword === confirmation
|
|
1958
|
+
let importFormat
|
|
1959
|
+
try { importFormat = JSON.parse(text)?.format } catch {}
|
|
1960
|
+
const encryptedImport = importFormat === 'dsh-connect-codearts-encrypted'
|
|
1961
|
+
const importLabel = encryptedImport ? 'backup.encrypted' : importFormat === 'dsh-connect-codearts-backup' ? 'backup.plain' : null
|
|
1962
|
+
const canInspect = text.trim() && (!encryptedImport || (password.length >= 8 && password.length <= 256))
|
|
1963
|
+
const changeMode = (next) => {
|
|
1964
|
+
if (busy || next === mode) return
|
|
1965
|
+
setMode(next); setNotice(null); setPreview(null)
|
|
1966
|
+
setExportPassword(''); setConfirmation(''); setPassword('')
|
|
1967
|
+
}
|
|
1968
|
+
const updateImport = (next, name = '') => {
|
|
1969
|
+
setText(next); setFileName(name); setPassword(''); setPreview(null); setNotice(null)
|
|
1970
|
+
}
|
|
1971
|
+
const selectFile = async (event) => {
|
|
1972
|
+
const file = event.target.files?.[0]; event.target.value = ''
|
|
1973
|
+
if (!file || busy) return
|
|
1974
|
+
setBusy('file'); setPreview(null); setNotice(null)
|
|
1975
|
+
updateImport('')
|
|
1976
|
+
try {
|
|
1977
|
+
if (file.size > 768 * 1024) throw new Error(t('backup.tooLarge'))
|
|
1978
|
+
updateImport(await file.text(), file.name)
|
|
1979
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
1980
|
+
}
|
|
1981
|
+
const exportBackup = async (event) => {
|
|
1982
|
+
event.preventDefault()
|
|
1983
|
+
if (busy || (needsEncryption && !validPassword)) return
|
|
1984
|
+
setBusy('export'); setNotice(null)
|
|
1985
|
+
try {
|
|
1986
|
+
const result = await postRoute('/backup/export', { includeCredentials, password: needsEncryption ? exportPassword : '' })
|
|
1987
|
+
if (!result.ok) throw new Error(result.error ?? t('backup.failed'))
|
|
1988
|
+
downloadJson(result.backup, `codearts-backup-${new Date().toISOString().slice(0, 10)}.json`)
|
|
1989
|
+
setExportPassword(''); setConfirmation('')
|
|
1990
|
+
setNotice({ kind: 'success', text: t('backup.exported') })
|
|
1991
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
1992
|
+
}
|
|
1993
|
+
const inspect = async () => {
|
|
1994
|
+
if (busy || !canInspect) return
|
|
1995
|
+
setBusy('preview'); setNotice(null); setPreview(null)
|
|
1996
|
+
try {
|
|
1997
|
+
const result = await postRoute('/backup/preview', { text, password: encryptedImport ? password : '' })
|
|
1998
|
+
if (!result.ok) throw new Error(result.error ?? t('backup.failed'))
|
|
1999
|
+
setPreview(result)
|
|
2000
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
2001
|
+
}
|
|
2002
|
+
const restore = async () => {
|
|
2003
|
+
if (!preview || busy) return
|
|
2004
|
+
setBusy('restore'); setNotice(null)
|
|
2005
|
+
try {
|
|
2006
|
+
const result = await postRoute('/backup/restore', { text, password: encryptedImport ? password : '' })
|
|
2007
|
+
if (!result.ok) throw new Error(result.error ?? t('backup.failed'))
|
|
2008
|
+
updateImport('')
|
|
2009
|
+
await onRestored()
|
|
2010
|
+
setNotice({ kind: 'success', text: t('backup.restored').replace('{added}', result.added).replace('{updated}', result.updated) })
|
|
2011
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
2012
|
+
}
|
|
2013
|
+
return h('details', { className: 'dca-card dca-details' },
|
|
2014
|
+
h('summary', null, t('backup.title')),
|
|
2015
|
+
h('div', { className: 'dca-feature-stack' },
|
|
2016
|
+
h('div', { className: 'dca-mode-switch', role: 'group', 'aria-label': t('backup.mode') },
|
|
2017
|
+
...['export', 'restore'].map((value) => h('button', {
|
|
2018
|
+
key: value, type: 'button', className: 'dca-filter', 'aria-pressed': mode === value,
|
|
2019
|
+
disabled: busy !== null, onClick: () => changeMode(value),
|
|
2020
|
+
}, t(`backup.${value}`))),
|
|
2021
|
+
),
|
|
2022
|
+
h(FeatureNotice, { notice }),
|
|
2023
|
+
mode === 'export' ? h('form', { className: 'dca-feature-stack dca-backup-form', onSubmit: exportBackup },
|
|
2024
|
+
h('p', { className: 'dca-hint' }, t('backup.hint')),
|
|
2025
|
+
h('label', { className: 'dca-row' }, h('input', {
|
|
2026
|
+
type: 'checkbox', checked: includeCredentials, disabled: busy !== null,
|
|
2027
|
+
onChange: (event) => {
|
|
2028
|
+
setIncludeCredentials(event.target.checked)
|
|
2029
|
+
if (!event.target.checked && !encryptExport) { setExportPassword(''); setConfirmation('') }
|
|
2030
|
+
},
|
|
2031
|
+
}), t('backup.include')),
|
|
2032
|
+
includeCredentials ? h('p', { className: 'dca-hint' }, t('backup.encryptionRequired'))
|
|
2033
|
+
: h('label', { className: 'dca-row' }, h('input', {
|
|
2034
|
+
type: 'checkbox', checked: encryptExport, disabled: busy !== null,
|
|
2035
|
+
onChange: (event) => { setEncryptExport(event.target.checked); setExportPassword(''); setConfirmation('') },
|
|
2036
|
+
}), t('backup.encrypt')),
|
|
2037
|
+
needsEncryption ? h(React.Fragment, null,
|
|
2038
|
+
h('div', { className: 'dca-feature-grid' },
|
|
2039
|
+
h('label', { className: 'dca-form-field' }, t('backup.exportPassword'), h('input', { className: 'dca-input', type: 'password', autoComplete: 'new-password', maxLength: 256, value: exportPassword, disabled: busy !== null, onChange: (event) => setExportPassword(event.target.value) })),
|
|
2040
|
+
h('label', { className: 'dca-form-field' }, t('backup.confirmPassword'), h('input', { className: 'dca-input', type: 'password', autoComplete: 'new-password', maxLength: 256, value: confirmation, disabled: busy !== null, onChange: (event) => setConfirmation(event.target.value) })),
|
|
2041
|
+
),
|
|
2042
|
+
!validPassword ? h('p', { className: 'dca-hint' }, t('backup.passwordHint')) : null,
|
|
2043
|
+
) : null,
|
|
2044
|
+
h('div', { className: 'dca-row' }, h('button', { className: 'dca-btn', type: 'submit', disabled: busy !== null || (needsEncryption && !validPassword) }, busy === 'export' ? t('common.loading') : t('backup.download'))),
|
|
2045
|
+
) : h('div', { className: 'dca-feature-stack dca-backup-form' },
|
|
2046
|
+
h('p', { className: 'dca-hint' }, t('backup.importHint')),
|
|
2047
|
+
h('div', { className: 'dca-row' },
|
|
2048
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null, onClick: () => fileInput.current?.click() }, busy === 'file' ? t('common.loading') : t('backup.choose')),
|
|
2049
|
+
h('input', { ref: fileInput, type: 'file', accept: '.json,application/json', className: 'dca-file-input', disabled: busy !== null, onChange: selectFile }),
|
|
2050
|
+
),
|
|
2051
|
+
text.trim() ? h('div', { className: 'dca-file-state', role: 'status' },
|
|
2052
|
+
h('span', null, fileName ? t('backup.selected').replace('{name}', fileName) : t('backup.pasted')),
|
|
2053
|
+
importLabel ? h('span', { className: 'dca-hint' }, t(importLabel)) : null,
|
|
2054
|
+
) : null,
|
|
2055
|
+
h('details', { className: 'dca-details' }, h('summary', null, t('backup.paste')),
|
|
2056
|
+
h('label', { className: 'dca-form-field' }, t('backup.content'), h('textarea', {
|
|
2057
|
+
className: 'dca-input', rows: 4, maxLength: 786432, value: text, disabled: busy !== null,
|
|
2058
|
+
onChange: (event) => updateImport(event.target.value),
|
|
2059
|
+
})),
|
|
2060
|
+
),
|
|
2061
|
+
encryptedImport ? h('label', { className: 'dca-form-field' }, t('backup.importPassword'), h('input', { className: 'dca-input', type: 'password', autoComplete: 'off', maxLength: 256, value: password, disabled: busy !== null, onChange: (event) => { setPassword(event.target.value); setPreview(null) } })) : null,
|
|
2062
|
+
h('div', { className: 'dca-row' }, h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null || !canInspect, onClick: inspect }, busy === 'preview' ? t('common.loading') : t('backup.preview'))),
|
|
2063
|
+
preview ? h('div', { className: 'dca-feature-stack dca-preview-box', role: 'region', 'aria-label': t('backup.preview') },
|
|
2064
|
+
h('p', null, t('backup.summary').replace('{settings}', preview.changes.length).replace('{added}', preview.accounts.added).replace('{updated}', preview.accounts.updated)),
|
|
2065
|
+
h('p', { className: 'dca-hint' }, t('backup.mergeHint')),
|
|
2066
|
+
h('details', { className: 'dca-details' }, h('summary', null, t('backup.changes')), h('pre', { className: 'dca-pre', tabIndex: 0 }, JSON.stringify(preview.preferences, null, 2))),
|
|
2067
|
+
h('div', { className: 'dca-row' },
|
|
2068
|
+
h('button', { type: 'button', className: 'dca-btn dca-btn-primary', disabled: busy !== null, onClick: restore }, busy === 'restore' ? t('common.loading') : t('backup.confirm')),
|
|
2069
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null, onClick: () => updateImport('') }, t('pool.cancel')),
|
|
2070
|
+
),
|
|
2071
|
+
) : null,
|
|
2072
|
+
),
|
|
2073
|
+
),
|
|
2074
|
+
)
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
// ── models tab ─────────────────────────────────────────────────────────
|
|
2078
|
+
|
|
2079
|
+
/**
|
|
2080
|
+
* The model catalog.
|
|
2081
|
+
*
|
|
2082
|
+
* Row layout follows the reference: line one carries the enable checkbox,
|
|
2083
|
+
* the name, its ratio and any badge on the left, with the row's own flags on
|
|
2084
|
+
* the right; line two carries the facts on the left, indented to the name so
|
|
2085
|
+
* the two lines read as one block rather than a checkbox beside two toppled
|
|
2086
|
+
* fragments.
|
|
2087
|
+
*/
|
|
2088
|
+
/**
|
|
2089
|
+
* The model catalog.
|
|
2090
|
+
*
|
|
2091
|
+
* Each row carries its own selection checkbox and its own capability
|
|
2092
|
+
* switches, exactly as the reference does — a model row is where a user
|
|
2093
|
+
* decides what this provider may send, so the controls live on the row
|
|
2094
|
+
* rather than behind an edit dialog. Edits are local until saved; the
|
|
2095
|
+
* reference uses the same save/discard posture for this panel.
|
|
2096
|
+
*/
|
|
2097
|
+
function ModelsTab({ models, onRefresh, onSaved }) {
|
|
2098
|
+
const [busy, setBusy] = useState(null)
|
|
2099
|
+
const [query, setQuery] = useState('')
|
|
2100
|
+
const [filter, setFilter] = useState('all')
|
|
2101
|
+
const [sort, setSort] = useState('default')
|
|
2102
|
+
const [imagesOnly, setImagesOnly] = useState(false)
|
|
2103
|
+
const [reasoningOnly, setReasoningOnly] = useState(false)
|
|
2104
|
+
const [presetId, setPresetId] = useState('')
|
|
2105
|
+
const [presetName, setPresetName] = useState('')
|
|
2106
|
+
const [presetEditorOpen, setPresetEditorOpen] = useState(false)
|
|
2107
|
+
const [presetPreview, setPresetPreview] = useState(null)
|
|
2108
|
+
const [savedFavorites, setSavedFavorites] = useState(null)
|
|
2109
|
+
useEffect(() => { setSavedFavorites(null) }, [models.favoriteModelIds])
|
|
2110
|
+
const favoriteIds = savedFavorites ?? models.favoriteModelIds ?? []
|
|
2111
|
+
const favorites = new Set(favoriteIds)
|
|
2112
|
+
const [savedPresets, setSavedPresets] = useState(null)
|
|
2113
|
+
useEffect(() => { setSavedPresets(null) }, [models.presets])
|
|
2114
|
+
const [notice, setNotice] = useState(null)
|
|
2115
|
+
/** Local draft: null means "no unsaved edits". */
|
|
2116
|
+
const [enabledIds, setEnabledIds] = useState(null)
|
|
2117
|
+
const [overrides, setOverrides] = useState({})
|
|
2118
|
+
|
|
2119
|
+
const list = models?.models ?? []
|
|
2120
|
+
const selectionIsDefault = models?.enabledIds === null || models?.enabledIds === undefined
|
|
2121
|
+
// The rows as they should LOOK: the draft when there is one, the saved
|
|
2122
|
+
// state otherwise. Without this the first paint after an edit would snap
|
|
2123
|
+
// back to the saved state.
|
|
2124
|
+
const isEnabled = (id) => {
|
|
2125
|
+
if (enabledIds !== null) return enabledIds.includes(id)
|
|
2126
|
+
// No draft: trust what the Host said about the saved selection. When it
|
|
2127
|
+
// sent no list at all, everything is offered.
|
|
2128
|
+
const saved = models?.enabledIds
|
|
2129
|
+
if (Array.isArray(saved)) return saved.includes(id)
|
|
2130
|
+
return true
|
|
2131
|
+
}
|
|
2132
|
+
const dirty = (enabledIds !== null && list.some((model) =>
|
|
2133
|
+
enabledIds.includes(model.id) !== (selectionIsDefault || models.enabledIds.includes(model.id)))) ||
|
|
2134
|
+
Object.entries(overrides).some(([id, patch]) => {
|
|
2135
|
+
const model = list.find((entry) => entry.id === id)
|
|
2136
|
+
if (!model) return false
|
|
2137
|
+
const saved = { images: model.supportsImages, allowOff: model.allowOff !== false, defaultStrength: model.defaultStrength, ...model.overrides }
|
|
2138
|
+
return Object.entries(patch).some(([key, value]) => value !== saved[key])
|
|
2139
|
+
})
|
|
2140
|
+
const selectedIds = list.filter((model) => isEnabled(model.id)).map((model) => model.id)
|
|
2141
|
+
const selectedCount = selectedIds.length
|
|
2142
|
+
const normalizedQuery = query.trim().toLowerCase()
|
|
2143
|
+
const visibleModels = list.filter((model) =>
|
|
2144
|
+
(filter !== 'enabled' || isEnabled(model.id)) &&
|
|
2145
|
+
(!imagesOnly || (overrides[model.id]?.images ?? model.supportsImages) === true) &&
|
|
2146
|
+
(!reasoningOnly || model.strengths?.length > 0) &&
|
|
2147
|
+
(!normalizedQuery || `${model.name} ${model.id}`.toLowerCase().includes(normalizedQuery)))
|
|
2148
|
+
if (sort === 'ratio') {
|
|
2149
|
+
const ratioOf = (model) => {
|
|
2150
|
+
const value = Number.parseFloat(String(model.ratio ?? '').trim().replace(/^x/i, ''))
|
|
2151
|
+
return Number.isFinite(value) ? value : Infinity
|
|
2152
|
+
}
|
|
2153
|
+
visibleModels.sort((left, right) => ratioOf(left) - ratioOf(right))
|
|
2154
|
+
} else if (sort === 'name') {
|
|
2155
|
+
visibleModels.sort((left, right) => left.name.localeCompare(right.name))
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
// Preserve the chosen sort within the pinned and unpinned groups.
|
|
2159
|
+
visibleModels.sort((left, right) => Number(favorites.has(right.id)) - Number(favorites.has(left.id)))
|
|
2160
|
+
const toggleFavorite = async (id) => {
|
|
2161
|
+
if (busy) return
|
|
2162
|
+
setBusy('favorite'); setNotice(null)
|
|
2163
|
+
try {
|
|
2164
|
+
const next = favorites.has(id) ? favoriteIds.filter((entry) => entry !== id) : [...favoriteIds, id]
|
|
2165
|
+
const result = await postRoute('/preferences/save', { favoriteModelIds: next })
|
|
2166
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retry'))
|
|
2167
|
+
setSavedFavorites(result.preferences.favoriteModelIds)
|
|
2168
|
+
setNotice({ kind: 'success', text: t('models.favoriteSaved') })
|
|
2169
|
+
await onRefresh()
|
|
2170
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
const toggle = useCallback((id, next) => {
|
|
2174
|
+
setNotice(null)
|
|
2175
|
+
setEnabledIds((current) => {
|
|
2176
|
+
const base = current ?? (selectionIsDefault ? list.map((m) => m.id) : (models?.enabledIds ?? []))
|
|
2177
|
+
return next ? [...new Set([...base, id])] : base.filter((entry) => entry !== id)
|
|
2178
|
+
})
|
|
2179
|
+
}, [list, models, selectionIsDefault])
|
|
2180
|
+
|
|
2181
|
+
const setOverride = useCallback((id, patch) => {
|
|
2182
|
+
setNotice(null)
|
|
2183
|
+
setOverrides((current) => ({
|
|
2184
|
+
...current,
|
|
2185
|
+
[id]: { ...(current[id] ?? {}), ...patch },
|
|
2186
|
+
}))
|
|
2187
|
+
}, [])
|
|
2188
|
+
|
|
2189
|
+
const save = useCallback(async () => {
|
|
2190
|
+
setBusy('save'); setNotice(null)
|
|
2191
|
+
try {
|
|
2192
|
+
const payload = {
|
|
2193
|
+
// A draft that matches the whole roster is the same thing as "all",
|
|
2194
|
+
// and storing `null` keeps the user's intent ("everything") intact
|
|
2195
|
+
// so a model the upstream adds later still appears.
|
|
2196
|
+
enabledIds:
|
|
2197
|
+
enabledIds === null
|
|
2198
|
+
? (selectionIsDefault ? null : (models?.enabledIds ?? []))
|
|
2199
|
+
: selectedIds.length === list.length
|
|
2200
|
+
? null
|
|
2201
|
+
: selectedIds,
|
|
2202
|
+
overrides: Object.fromEntries(list.map((model) => [model.id, { ...model.overrides, ...overrides[model.id] }])),
|
|
2203
|
+
}
|
|
2204
|
+
const result = await postRoute('/models/select', payload)
|
|
2205
|
+
// NOT just `result.ok`: a mis-routed request can land on a read route
|
|
2206
|
+
// that also answers `ok: true`, which makes a save look successful
|
|
2207
|
+
// while nothing was written. The acknowledgement carries the counts.
|
|
2208
|
+
if (result.ok && typeof result.enabled === 'number') {
|
|
2209
|
+
const reloaded = await onSaved()
|
|
2210
|
+
if (reloaded) {
|
|
2211
|
+
setEnabledIds(null)
|
|
2212
|
+
setOverrides({})
|
|
2213
|
+
}
|
|
2214
|
+
setNotice(reloaded
|
|
2215
|
+
? { kind: 'success', text: t('models.saved') }
|
|
2216
|
+
: { kind: 'error', text: t('models.savedReloadFailed') })
|
|
2217
|
+
} else {
|
|
2218
|
+
setNotice({ kind: 'error', text: result.error ?? t('models.saveFailed') })
|
|
2219
|
+
}
|
|
2220
|
+
} catch (error) {
|
|
2221
|
+
setNotice({ kind: 'error', text: `${t('models.saveFailed')}:${error.message}` })
|
|
2222
|
+
} finally {
|
|
2223
|
+
setBusy(null)
|
|
2224
|
+
}
|
|
2225
|
+
}, [enabledIds, overrides, list, models, onSaved, selectedIds, selectionIsDefault])
|
|
2226
|
+
|
|
2227
|
+
const discard = useCallback(() => {
|
|
2228
|
+
setEnabledIds(null)
|
|
2229
|
+
setOverrides({})
|
|
2230
|
+
setNotice(null)
|
|
2231
|
+
}, [])
|
|
2232
|
+
|
|
2233
|
+
const refresh = useCallback(async () => {
|
|
2234
|
+
setBusy('refresh')
|
|
2235
|
+
try {
|
|
2236
|
+
const result = await getRoute('/refresh')
|
|
2237
|
+
const reloaded = await onRefresh()
|
|
2238
|
+
setNotice(result.ok && reloaded
|
|
2239
|
+
? { kind: 'success', text: t('models.refreshed') }
|
|
2240
|
+
: { kind: 'error', text: result.error ?? t('models.refreshFailed') })
|
|
2241
|
+
} catch (error) {
|
|
2242
|
+
setNotice({ kind: 'error', text: `${t('models.refreshFailed')}:${error.message}` })
|
|
2243
|
+
} finally {
|
|
2244
|
+
setBusy(null)
|
|
2245
|
+
}
|
|
2246
|
+
}, [onRefresh])
|
|
2247
|
+
|
|
2248
|
+
const ratioOf = (model) => {
|
|
2249
|
+
const value = Number.parseFloat(String(model.ratio ?? '').trim().replace(/^x/i, ''))
|
|
2250
|
+
return Number.isFinite(value) ? value : Infinity
|
|
2251
|
+
}
|
|
2252
|
+
const makeBuiltin = (id, name, targets, deep = false) => ({
|
|
2253
|
+
id, name, enabledModelIds: targets.map((model) => model.id),
|
|
2254
|
+
modelOverrides: Object.fromEntries(list.map((model) => {
|
|
2255
|
+
const base = model.defaults ?? model
|
|
2256
|
+
const strengths = model.strengths ?? []
|
|
2257
|
+
const strength = deep && targets.some((entry) => entry.id === model.id)
|
|
2258
|
+
? (strengths.includes('max') ? 'max' : strengths.at(-1))
|
|
2259
|
+
: base.defaultStrength
|
|
2260
|
+
return [model.id, { images: base.supportsImages === true, allowOff: base.allowOff !== false,
|
|
2261
|
+
...(strengths.includes(strength) ? { defaultStrength: strength } : strengths.length ? { defaultStrength: strengths[0] } : {}),
|
|
2262
|
+
}]
|
|
2263
|
+
})),
|
|
2264
|
+
})
|
|
2265
|
+
const presets = [
|
|
2266
|
+
makeBuiltin('builtin:daily', t('presets.daily'), [...list].sort((a, b) => ratioOf(a) - ratioOf(b)).slice(0, 3)),
|
|
2267
|
+
makeBuiltin('builtin:deep', t('presets.deep'), list.filter((model) => model.strengths?.length), true),
|
|
2268
|
+
makeBuiltin('builtin:images', t('presets.images'), list.filter((model) => (model.defaults ?? model).supportsImages)),
|
|
2269
|
+
...(savedPresets ?? models.presets ?? []),
|
|
2270
|
+
]
|
|
2271
|
+
const selectedPreset = presets.find((entry) => entry.id === presetId)
|
|
2272
|
+
const previewIds = presetPreview ? (presetPreview.enabledModelIds ?? list.map((entry) => entry.id)).filter((id) => list.some((entry) => entry.id === id)) : []
|
|
2273
|
+
const snapshotOverrides = () => Object.fromEntries(list.map((model) => {
|
|
2274
|
+
const patch = { ...model.overrides, ...overrides[model.id] }
|
|
2275
|
+
const strengths = model.strengths ?? []
|
|
2276
|
+
const strength = patch.defaultStrength ?? model.defaultStrength
|
|
2277
|
+
return [model.id, { images: patch.images ?? model.supportsImages, allowOff: patch.allowOff ?? model.allowOff ?? true,
|
|
2278
|
+
...(strengths.length ? { defaultStrength: strengths.includes(strength) ? strength : strengths[0] } : {}),
|
|
2279
|
+
}]
|
|
2280
|
+
}))
|
|
2281
|
+
const savePreset = async () => {
|
|
2282
|
+
if (!presetName.trim() || !selectedCount || busy) return
|
|
2283
|
+
setBusy('preset')
|
|
2284
|
+
try {
|
|
2285
|
+
const result = await postRoute('/presets', { action: 'save', name: presetName.trim(), enabledModelIds: selectedCount === list.length ? null : selectedIds, modelOverrides: snapshotOverrides() })
|
|
2286
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retry'))
|
|
2287
|
+
setSavedPresets(result.presets); setPresetName(''); setPresetEditorOpen(false)
|
|
2288
|
+
setNotice({ kind: 'success', text: t('features.saved') })
|
|
2289
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
2290
|
+
}
|
|
2291
|
+
const deletePreset = async () => {
|
|
2292
|
+
if (!selectedPreset || selectedPreset.id.startsWith('builtin:') || busy || !window.confirm(t('presets.deleteConfirm'))) return
|
|
2293
|
+
setBusy('preset')
|
|
2294
|
+
try {
|
|
2295
|
+
const result = await postRoute('/presets', { action: 'delete', id: selectedPreset.id })
|
|
2296
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retry'))
|
|
2297
|
+
setSavedPresets(result.presets); setPresetId(''); setPresetPreview(null)
|
|
2298
|
+
setNotice({ kind: 'success', text: t('features.saved') })
|
|
2299
|
+
} catch (error) { setNotice({ kind: 'error', text: error.message }) } finally { setBusy(null) }
|
|
2300
|
+
}
|
|
2301
|
+
const applyPreset = () => {
|
|
2302
|
+
if (!previewIds.length || busy) return
|
|
2303
|
+
setEnabledIds(previewIds)
|
|
2304
|
+
setOverrides(Object.fromEntries(Object.entries(presetPreview.modelOverrides ?? {}).filter(([id]) => list.some((model) => model.id === id))))
|
|
2305
|
+
setPresetPreview(null); setPresetId('')
|
|
2306
|
+
setNotice({ kind: 'success', text: t('presets.applied') })
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
const source = catalogSourceLabel(models.source)
|
|
2310
|
+
|
|
2311
|
+
return h(
|
|
2312
|
+
'div',
|
|
2313
|
+
{ className: 'dca-page dca-model-page' },
|
|
2314
|
+
h(
|
|
2315
|
+
'div',
|
|
2316
|
+
{ className: 'dca-pool-card-head' },
|
|
2317
|
+
h(
|
|
2318
|
+
'div',
|
|
2319
|
+
null,
|
|
2320
|
+
h(
|
|
2321
|
+
'h2',
|
|
2322
|
+
{ className: 'dca-title' },
|
|
2323
|
+
t('models.title'),
|
|
2324
|
+
dirty ? h('span', { className: 'dca-dirty' }, t('models.dirty')) : null,
|
|
2325
|
+
),
|
|
2326
|
+
),
|
|
2327
|
+
h(
|
|
2328
|
+
'div',
|
|
2329
|
+
{ className: 'dca-pool-actions-group' },
|
|
2330
|
+
h('span', { className: 'dca-pool-tag' }, source),
|
|
2331
|
+
h(
|
|
2332
|
+
'button',
|
|
2333
|
+
{ type: 'button', className: 'dca-btn', onClick: refresh, disabled: busy !== null },
|
|
2334
|
+
busy === 'refresh' ? t('account.refreshing') : t('models.refresh'),
|
|
2335
|
+
),
|
|
2336
|
+
),
|
|
2337
|
+
),
|
|
2338
|
+
h('div', { className: 'dca-catalog-meta' },
|
|
2339
|
+
h('span', null, t('models.selectedCount').replace('{enabled}', selectedCount).replace('{total}', list.length)),
|
|
2340
|
+
h('span', null, `${t('models.refreshedAt')}:${formatTime(models?.refreshedAt)}`),
|
|
2341
|
+
),
|
|
2342
|
+
h('p', { className: 'dca-hint' }, t('models.saveHint')),
|
|
2343
|
+
h('div', { className: 'dca-toolbar' },
|
|
2344
|
+
h('input', {
|
|
2345
|
+
type: 'search', className: 'dca-input dca-search', value: query,
|
|
2346
|
+
placeholder: t('models.search'), 'aria-label': t('models.search'),
|
|
2347
|
+
onChange: (event) => setQuery(event.target.value),
|
|
2348
|
+
}),
|
|
2349
|
+
h('div', { className: 'dca-filter-group', role: 'group', 'aria-label': t('models.title') },
|
|
2350
|
+
...[['all', 'models.all'], ['enabled', 'models.enabledOnly']].map(([value, key]) =>
|
|
2351
|
+
h('button', { type: 'button', key: value, className: 'dca-filter',
|
|
2352
|
+
'aria-pressed': filter === value, onClick: () => setFilter(value),
|
|
2353
|
+
}, t(key))),
|
|
2354
|
+
),
|
|
2355
|
+
h('select', { className: 'dca-input dca-sort', value: sort, 'aria-label': t('models.sort'),
|
|
2356
|
+
onChange: (event) => setSort(event.target.value),
|
|
2357
|
+
}, ...[['default', 'models.sortDefault'], ['ratio', 'models.sortRatio'], ['name', 'models.sortName']].map(([value, key]) =>
|
|
2358
|
+
h('option', { key: value, value }, t(key)))),
|
|
2359
|
+
),
|
|
2360
|
+
h('div', { className: 'dca-capability-filters' },
|
|
2361
|
+
h('label', { className: 'dca-row' }, h('input', { type: 'checkbox', checked: imagesOnly, onChange: (event) => setImagesOnly(event.target.checked) }), t('models.imagesOnly')),
|
|
2362
|
+
h('label', { className: 'dca-row' }, h('input', { type: 'checkbox', checked: reasoningOnly, onChange: (event) => setReasoningOnly(event.target.checked) }), t('models.reasoningOnly')),
|
|
2363
|
+
),
|
|
2364
|
+
h('div', { className: 'dca-preset-tools' },
|
|
2365
|
+
h('div', { className: 'dca-preset-row' },
|
|
2366
|
+
h('select', {
|
|
2367
|
+
className: 'dca-input', value: presetId, disabled: busy !== null,
|
|
2368
|
+
'aria-label': t('presets.title'), onChange: (event) => {
|
|
2369
|
+
const next = event.target.value
|
|
2370
|
+
setPresetId(next); setPresetPreview(presets.find((entry) => entry.id === next) ?? null)
|
|
2371
|
+
setPresetEditorOpen(false)
|
|
2372
|
+
},
|
|
2373
|
+
}, h('option', { value: '' }, t('presets.choose')), ...presets.map((preset) => h('option', { key: preset.id, value: preset.id }, preset.name))),
|
|
2374
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null || !selectedCount,
|
|
2375
|
+
'aria-expanded': presetEditorOpen, onClick: () => { setPresetEditorOpen((value) => !value); setPresetPreview(null); setPresetId('') },
|
|
2376
|
+
}, t('presets.saveAs')),
|
|
2377
|
+
),
|
|
2378
|
+
presetEditorOpen ? h('form', { className: 'dca-preset-row', onSubmit: (event) => { event.preventDefault(); void savePreset() } },
|
|
2379
|
+
h('input', { className: 'dca-input', value: presetName, maxLength: 48, autoFocus: true, placeholder: t('presets.name'), 'aria-label': t('presets.name'), disabled: busy !== null, onChange: (event) => setPresetName(event.target.value) }),
|
|
2380
|
+
h('button', { type: 'submit', className: 'dca-btn', disabled: busy !== null || !presetName.trim() || !selectedCount }, t('presets.save')),
|
|
2381
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null, onClick: () => setPresetEditorOpen(false) }, t('pool.cancel')),
|
|
2382
|
+
) : null,
|
|
2383
|
+
presetPreview ? h('div', { className: 'dca-preview-box dca-feature-stack', role: 'region', 'aria-label': t('presets.preview') },
|
|
2384
|
+
h('p', { className: 'dca-hint' }, t('presets.previewHint').replace('{count}', previewIds.length)),
|
|
2385
|
+
!previewIds.length ? h('p', { className: 'dca-hint' }, t('presets.noModels')) : null,
|
|
2386
|
+
presetPreview.enabledModelIds && previewIds.length < presetPreview.enabledModelIds.length ? h('p', { className: 'dca-hint' }, t('presets.missing')) : null,
|
|
2387
|
+
h('ul', { className: 'dca-preset-preview' }, ...previewIds.map((id) => h('li', { key: id }, list.find((model) => model.id === id).name))),
|
|
2388
|
+
h('details', { className: 'dca-details' }, h('summary', null, t('presets.details')),
|
|
2389
|
+
h('pre', { className: 'dca-pre', tabIndex: 0 }, JSON.stringify(presetPreview.modelOverrides, null, 2)),
|
|
2390
|
+
selectedPreset && !selectedPreset.id.startsWith('builtin:') ? h('button', { type: 'button', className: 'dca-btn dca-danger', disabled: busy !== null, onClick: deletePreset }, t('presets.delete')) : null,
|
|
2391
|
+
),
|
|
2392
|
+
h('div', { className: 'dca-row' },
|
|
2393
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null || !previewIds.length, onClick: applyPreset }, t('presets.apply')),
|
|
2394
|
+
h('button', { type: 'button', className: 'dca-btn', disabled: busy !== null, onClick: () => { setPresetPreview(null); setPresetId('') } }, t('pool.cancel')),
|
|
2395
|
+
),
|
|
2396
|
+
) : null,
|
|
2397
|
+
),
|
|
2398
|
+
h('details', { className: 'dca-details' },
|
|
2399
|
+
h('summary', null, t('models.about')),
|
|
2400
|
+
h('div', { className: 'dca-details-body' },
|
|
2401
|
+
h('p', { className: 'dca-hint' }, t('models.hint')),
|
|
2402
|
+
h('p', { className: 'dca-hint' }, t('models.pickerHint')),
|
|
2403
|
+
),
|
|
2404
|
+
),
|
|
2405
|
+
models?.error ? h('p', { className: 'dca-msg dca-msg-warn' }, models.error) : null,
|
|
2406
|
+
h(
|
|
2407
|
+
'div',
|
|
2408
|
+
{ className: 'dca-models' },
|
|
2409
|
+
list.length === 0
|
|
2410
|
+
? h('p', { className: 'dca-hint' }, t('models.empty'))
|
|
2411
|
+
: visibleModels.length === 0
|
|
2412
|
+
? h('div', { className: 'dca-empty', role: 'status' },
|
|
2413
|
+
h('p', { className: 'dca-hint' }, t('models.noMatches')),
|
|
2414
|
+
h('button', { type: 'button', className: 'dca-btn', onClick: () => { setQuery(''); setFilter('all'); setImagesOnly(false); setReasoningOnly(false) } }, t('models.clearFilters')),
|
|
2415
|
+
)
|
|
2416
|
+
: h(
|
|
2417
|
+
React.Fragment,
|
|
2418
|
+
null,
|
|
2419
|
+
...visibleModels.map((model) => {
|
|
2420
|
+
const on = isEnabled(model.id)
|
|
2421
|
+
const override = { ...model.overrides, ...overrides[model.id] }
|
|
2422
|
+
const images = typeof override.images === 'boolean' ? override.images : model.supportsImages
|
|
2423
|
+
const strengths = model.strengths ?? []
|
|
2424
|
+
const preferredStrength = override.defaultStrength ?? model.defaultStrength
|
|
2425
|
+
const defaultStrength = strengths.includes(preferredStrength) ? preferredStrength : strengths[0]
|
|
2426
|
+
return h(
|
|
2427
|
+
'div',
|
|
2428
|
+
{ key: model.id, className: `dca-model${on ? '' : ' dca-model-off'}` },
|
|
2429
|
+
h(
|
|
2430
|
+
'div',
|
|
2431
|
+
{ className: 'dca-model-head' },
|
|
2432
|
+
h(
|
|
2433
|
+
'div',
|
|
2434
|
+
{ className: 'dca-model-name' },
|
|
2435
|
+
h('input', {
|
|
2436
|
+
type: 'checkbox',
|
|
2437
|
+
checked: on,
|
|
2438
|
+
'aria-label': model.name,
|
|
2439
|
+
className: 'dca-model-check',
|
|
2440
|
+
disabled: busy !== null,
|
|
2441
|
+
onChange: (event) => toggle(model.id, event.target.checked),
|
|
2442
|
+
}),
|
|
2443
|
+
h('b', null, model.name),
|
|
2444
|
+
h('button', {
|
|
2445
|
+
type: 'button', className: `dca-pin${favorites.has(model.id) ? ' dca-pin-on' : ''}`,
|
|
2446
|
+
disabled: busy !== null, 'aria-pressed': favorites.has(model.id),
|
|
2447
|
+
title: t(favorites.has(model.id) ? 'models.unpin' : 'models.pin').replace('{model}', model.name),
|
|
2448
|
+
'aria-label': t(favorites.has(model.id) ? 'models.unpin' : 'models.pin').replace('{model}', model.name),
|
|
2449
|
+
onClick: () => void toggleFavorite(model.id),
|
|
2450
|
+
}, h('svg', { width: 15, height: 15, viewBox: '0 0 24 24', fill: favorites.has(model.id) ? 'currentColor' : 'none', stroke: 'currentColor', strokeWidth: 1.8, 'aria-hidden': true },
|
|
2451
|
+
h('path', { d: 'm12 3 2.8 5.7 6.3.9-4.6 4.5 1.1 6.3L12 17.4l-5.6 3 1.1-6.3L3 9.6l6.2-.9Z' }))),
|
|
2452
|
+
model.ratio
|
|
2453
|
+
? h(
|
|
2454
|
+
'span',
|
|
2455
|
+
{ className: 'dca-model-ratio' },
|
|
2456
|
+
`x${String(model.ratio).replace(/x$/i, '')}`,
|
|
2457
|
+
)
|
|
2458
|
+
: null,
|
|
2459
|
+
),
|
|
2460
|
+
h(
|
|
2461
|
+
'div',
|
|
2462
|
+
{ className: 'dca-model-controls' },
|
|
2463
|
+
h(
|
|
2464
|
+
'label',
|
|
2465
|
+
{ className: 'dca-model-flag' },
|
|
2466
|
+
h('input', {
|
|
2467
|
+
type: 'checkbox',
|
|
2468
|
+
checked: images === true,
|
|
2469
|
+
disabled: !on || busy !== null,
|
|
2470
|
+
onChange: (event) =>
|
|
2471
|
+
setOverride(model.id, { images: event.target.checked }),
|
|
2472
|
+
}),
|
|
2473
|
+
t('models.images'),
|
|
2474
|
+
),
|
|
2475
|
+
strengths.length
|
|
2476
|
+
? h(
|
|
2477
|
+
'label',
|
|
2478
|
+
{ className: 'dca-model-flag' },
|
|
2479
|
+
h('input', {
|
|
2480
|
+
type: 'checkbox',
|
|
2481
|
+
checked: (override.allowOff ?? model.allowOff) !== false,
|
|
2482
|
+
disabled: !on || busy !== null,
|
|
2483
|
+
onChange: (event) =>
|
|
2484
|
+
setOverride(model.id, { allowOff: event.target.checked }),
|
|
2485
|
+
}),
|
|
2486
|
+
t('models.allowOff'),
|
|
2487
|
+
)
|
|
2488
|
+
: null,
|
|
2489
|
+
),
|
|
2490
|
+
),
|
|
2491
|
+
h(
|
|
2492
|
+
'div',
|
|
2493
|
+
{ className: 'dca-model-details' },
|
|
2494
|
+
h(
|
|
2495
|
+
'div',
|
|
2496
|
+
{ className: 'dca-model-meta' },
|
|
2497
|
+
h(
|
|
2498
|
+
'span',
|
|
2499
|
+
{ className: 'dca-num' },
|
|
2500
|
+
`${t('models.colContext')} ${formatTokens(model.context)}`,
|
|
2501
|
+
),
|
|
2502
|
+
h(
|
|
2503
|
+
'span',
|
|
2504
|
+
{ className: 'dca-num' },
|
|
2505
|
+
`${t('models.colOutput')} ${formatTokens(model.maxOutput)}`,
|
|
2506
|
+
),
|
|
2507
|
+
// The default thinking level is a CHOICE, not a caption:
|
|
2508
|
+
// a user running a reasoning model wants to decide how
|
|
2509
|
+
// much it thinks before each request, and the picker
|
|
2510
|
+
// cannot express a per-model default on its own.
|
|
2511
|
+
strengths.length
|
|
2512
|
+
? h(
|
|
2513
|
+
'label',
|
|
2514
|
+
{ className: 'dca-effort' },
|
|
2515
|
+
h('span', null, t('models.effort')),
|
|
2516
|
+
h(
|
|
2517
|
+
'select',
|
|
2518
|
+
{
|
|
2519
|
+
className: 'dca-effort-select',
|
|
2520
|
+
value: defaultStrength,
|
|
2521
|
+
disabled: !on || busy !== null,
|
|
2522
|
+
'aria-label': `${t('models.effort')} — ${model.name}`,
|
|
2523
|
+
onChange: (event) =>
|
|
2524
|
+
setOverride(model.id, { defaultStrength: event.target.value }),
|
|
2525
|
+
},
|
|
2526
|
+
...strengths.map((level) =>
|
|
2527
|
+
h('option', { key: level, value: level }, effortLabel(level)),
|
|
2528
|
+
),
|
|
2529
|
+
),
|
|
2530
|
+
)
|
|
2531
|
+
: null,
|
|
2532
|
+
h('span', { className: 'dca-id' }, model.id),
|
|
2533
|
+
),
|
|
2534
|
+
),
|
|
2535
|
+
)
|
|
2536
|
+
}),
|
|
2537
|
+
),
|
|
2538
|
+
),
|
|
2539
|
+
h('p', { className: 'dca-hint' }, t('models.footnote')),
|
|
2540
|
+
|
|
2541
|
+
// The action bar is ALWAYS present and merely disabled when there is
|
|
2542
|
+
// nothing to save. A bar that appears only once something is dirty moves
|
|
2543
|
+
// under the pointer exactly when the user is looking for it.
|
|
2544
|
+
h(
|
|
2545
|
+
'div',
|
|
2546
|
+
{ className: 'dca-model-actions' },
|
|
2547
|
+
h('div', { className: 'dca-save-feedback' },
|
|
2548
|
+
h('span', { className: 'dca-save-status', role: 'status', 'aria-live': 'polite' },
|
|
2549
|
+
busy === 'save' ? t('account.saving') : selectedCount === 0 ? t('models.needOne') : t(dirty ? 'models.unsaved' : 'models.clean')),
|
|
2550
|
+
h(FeatureNotice, { notice }),
|
|
2551
|
+
),
|
|
2552
|
+
h(
|
|
2553
|
+
'div',
|
|
2554
|
+
{ className: 'dca-model-actions-buttons' },
|
|
2555
|
+
h(
|
|
2556
|
+
'button',
|
|
2557
|
+
{
|
|
2558
|
+
type: 'button',
|
|
2559
|
+
className: 'dca-btn',
|
|
2560
|
+
disabled: !dirty || busy !== null,
|
|
2561
|
+
onClick: discard,
|
|
2562
|
+
},
|
|
2563
|
+
t('models.discard'),
|
|
2564
|
+
),
|
|
2565
|
+
h(
|
|
2566
|
+
'button',
|
|
2567
|
+
{
|
|
2568
|
+
type: 'button',
|
|
2569
|
+
className: 'dca-btn dca-btn-primary',
|
|
2570
|
+
// Never let the last enabled model be removed: an empty picker
|
|
2571
|
+
// has no model to select and no way back from inside the picker.
|
|
2572
|
+
disabled: !dirty || busy !== null || selectedCount === 0,
|
|
2573
|
+
onClick: save,
|
|
2574
|
+
},
|
|
2575
|
+
busy === 'save' ? t('account.saving') : t('models.save'),
|
|
2576
|
+
),
|
|
2577
|
+
),
|
|
2578
|
+
),
|
|
2579
|
+
)
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
// ── diagnostics tab ────────────────────────────────────────────────────
|
|
2583
|
+
|
|
2584
|
+
function DiagnosticsTab({ status, account, accountError }) {
|
|
2585
|
+
const [copyNotice, setCopyNotice] = useState(null)
|
|
2586
|
+
const [reportOpen, setReportOpen] = useState(false)
|
|
2587
|
+
const reportText = JSON.stringify(diagnosticReport(status, account), null, 2)
|
|
2588
|
+
const catalogSummary = status.catalog?.source === 'fallback' ? 'diag.catalogFallback'
|
|
2589
|
+
: status.catalog?.source === 'cache' ? 'diag.catalogCached'
|
|
2590
|
+
: status.catalog?.source === 'gateway' && !status.catalog.error ? 'diag.catalogSynced'
|
|
2591
|
+
: 'diag.catalogIssue'
|
|
2592
|
+
|
|
2593
|
+
const errors = [status?.credential?.error, status?.catalog?.error, account?.error, accountError].filter(Boolean)
|
|
2594
|
+
const copyReport = async () => {
|
|
2595
|
+
try {
|
|
2596
|
+
if (!navigator.clipboard?.writeText) throw new Error('clipboard unavailable')
|
|
2597
|
+
await navigator.clipboard.writeText(reportText)
|
|
2598
|
+
setCopyNotice({ kind: 'success', text: t('diag.copied') })
|
|
2599
|
+
} catch {
|
|
2600
|
+
setReportOpen(true)
|
|
2601
|
+
setCopyNotice({ kind: 'error', text: t('diag.copyFailed') })
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
// `mono` marks a machine value a user copies verbatim; `bad` marks a field
|
|
2605
|
+
// that is reporting a failure, so a wall of same-coloured rows still shows
|
|
2606
|
+
// where the problem is. Both are the reference's own conventions.
|
|
2607
|
+
const rows = [
|
|
2608
|
+
{ label: t('diag.provider'), value: status?.provider ?? '—' },
|
|
2609
|
+
{ label: t('diag.gateway'), value: status?.settings?.gateway ?? t('diag.gatewayDefault'), mono: true },
|
|
2610
|
+
{ label: t('diag.credentialPath'), value: status?.credential?.pathInUse ?? status?.credential?.path ?? '—', mono: true },
|
|
2611
|
+
{ label: t('models.source'), value: catalogSourceLabel(status?.catalog?.source) },
|
|
2612
|
+
{ label: t('models.count'), value: String(status?.catalog?.models ?? 0) },
|
|
2613
|
+
{ label: t('models.refreshedAt'), value: formatTime(status?.catalog?.refreshedAt) },
|
|
2614
|
+
{
|
|
2615
|
+
label: t('diag.catalogError'),
|
|
2616
|
+
value: status?.catalog?.error ?? t('diag.none'),
|
|
2617
|
+
bad: Boolean(status?.catalog?.error),
|
|
2618
|
+
},
|
|
2619
|
+
{
|
|
2620
|
+
label: t('diag.credentialError'),
|
|
2621
|
+
value: status?.credential?.error ?? t('diag.none'),
|
|
2622
|
+
bad: Boolean(status?.credential?.error),
|
|
2623
|
+
},
|
|
2624
|
+
// The settings-page gates, reported rather than guessed: without a Config
|
|
2625
|
+
// schema the Host emits no namespace, and Settings → Models then hides
|
|
2626
|
+
// this provider's row with no error anywhere.
|
|
2627
|
+
{
|
|
2628
|
+
label: t('diag.configSchema'),
|
|
2629
|
+
value: status?.registration?.configSchema
|
|
2630
|
+
? (status.registration.settingsNs ?? t('diag.none'))
|
|
2631
|
+
: t('diag.schemaMissing'),
|
|
2632
|
+
bad: status?.registration?.configSchema !== true,
|
|
2633
|
+
mono: status?.registration?.configSchema === true,
|
|
2634
|
+
},
|
|
2635
|
+
]
|
|
2636
|
+
|
|
2637
|
+
return h(
|
|
2638
|
+
'div', { className: 'dca-page' },
|
|
2639
|
+
h('div', { className: 'dca-pool-card-head' },
|
|
2640
|
+
h('h2', { className: 'dca-title' }, t('diag.title')),
|
|
2641
|
+
h('button', { type: 'button', className: 'dca-btn', onClick: copyReport }, t('diag.copy')),
|
|
2642
|
+
),
|
|
2643
|
+
copyNotice ? h('p', { className: `dca-msg dca-msg-${copyNotice.kind === 'error' ? 'error' : 'ok'}`, role: 'status' }, copyNotice.text) : null,
|
|
2644
|
+
h('div', { className: 'dca-diagnostic-summary' },
|
|
2645
|
+
h('div', { className: 'dca-summary-item' },
|
|
2646
|
+
h('strong', null, t(status?.credential?.error ? 'diag.credentialIssue' : status?.credential?.configured ? 'diag.configured' : 'diag.notConfigured')),
|
|
2647
|
+
h('p', { className: 'dca-hint' }, status?.credential?.sourceLabel ?? t('account.sourceNone')),
|
|
2648
|
+
),
|
|
2649
|
+
h('div', { className: 'dca-summary-item' },
|
|
2650
|
+
h('strong', null, t(catalogSummary)),
|
|
2651
|
+
h('p', { className: 'dca-hint' }, `${t('models.count')}:${status?.catalog?.models ?? 0}`),
|
|
2652
|
+
h('p', { className: 'dca-hint' }, `${t('models.refreshedAt')}:${formatTime(status?.catalog?.refreshedAt)}`),
|
|
2653
|
+
),
|
|
2654
|
+
h('div', { className: 'dca-summary-item' },
|
|
2655
|
+
h('strong', null, t('diag.errors')),
|
|
2656
|
+
h('p', { className: errors.length ? 'dca-hint dca-danger' : 'dca-hint' }, errors.join(';') || t(account || accountError ? 'diag.noErrors' : 'common.loading')),
|
|
2657
|
+
),
|
|
2658
|
+
),
|
|
2659
|
+
h('details', { className: 'dca-card dca-details' },
|
|
2660
|
+
h('summary', null, t('diag.details')),
|
|
2661
|
+
h('div', { className: 'dca-diag' }, ...rows.map((row) =>
|
|
2662
|
+
h('div', { key: row.label, className: 'dca-diag-row' },
|
|
2663
|
+
h('span', { className: 'dca-diag-label' }, row.label),
|
|
2664
|
+
h('span', { className: `dca-diag-value${row.mono ? ' dca-diag-mono' : ''}${row.bad ? ' dca-diag-bad' : ''}` }, row.value),
|
|
2665
|
+
),
|
|
2666
|
+
)),
|
|
2667
|
+
),
|
|
2668
|
+
h('details', { className: 'dca-card dca-details', open: reportOpen, onToggle: (event) => setReportOpen(event.currentTarget.open) },
|
|
2669
|
+
h('summary', null, t('diag.reportTitle')),
|
|
2670
|
+
h('p', { className: 'dca-hint' }, t('diag.reportHint')),
|
|
2671
|
+
h('pre', { className: 'dca-pre', tabIndex: 0 }, reportText),
|
|
2672
|
+
),
|
|
2673
|
+
)
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
// ── the settings nav glyph ────────────────────────────────────────────
|
|
2677
|
+
|
|
2678
|
+
/**
|
|
2679
|
+
* The row's icon.
|
|
2680
|
+
*
|
|
2681
|
+
* The shell asks for a square edge and says whether this row is selected;
|
|
2682
|
+
* honouring both keeps the glyph on the same rhythm as the built-in rows'
|
|
2683
|
+
* own icons. It is registered under the SAME id as the settings section —
|
|
2684
|
+
* that pairing is how the shell knows which row the glyph belongs to, and an
|
|
2685
|
+
* unmatched id never renders at all.
|
|
2686
|
+
*/
|
|
2687
|
+
function NavIcon(props) {
|
|
2688
|
+
const edge = typeof props?.size === 'number' ? props.size : 16
|
|
2689
|
+
return h('img', {
|
|
2690
|
+
src: NAV_ICON,
|
|
2691
|
+
alt: '',
|
|
2692
|
+
'aria-hidden': true,
|
|
2693
|
+
width: edge,
|
|
2694
|
+
height: edge,
|
|
2695
|
+
style: {
|
|
2696
|
+
display: 'block',
|
|
2697
|
+
borderRadius: '4px',
|
|
2698
|
+
flexShrink: 0,
|
|
2699
|
+
opacity: props?.active === false ? 0.75 : 1,
|
|
2700
|
+
},
|
|
2701
|
+
})
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
// ── the settings page ──────────────────────────────────────────────────
|
|
2705
|
+
|
|
2706
|
+
function SettingsPage() {
|
|
2707
|
+
const [tab, setTab] = useState('account')
|
|
2708
|
+
const [data, setData] = useState({})
|
|
2709
|
+
const [errors, setErrors] = useState({})
|
|
2710
|
+
const requests = useRef(new Map())
|
|
2711
|
+
const tabButtons = useRef({})
|
|
2712
|
+
const panelId = React.useId()
|
|
2713
|
+
|
|
2714
|
+
const loadRoute = useCallback(async (path, background = false) => {
|
|
2715
|
+
const previous = requests.current.get(path)
|
|
2716
|
+
if (previous && background) return false
|
|
2717
|
+
previous?.abort()
|
|
2718
|
+
const controller = new AbortController()
|
|
2719
|
+
requests.current.set(path, controller)
|
|
2720
|
+
setErrors((current) => ({ ...current, [path]: null }))
|
|
2721
|
+
try {
|
|
2722
|
+
const value = await getRoute(path, { signal: controller.signal })
|
|
2723
|
+
if (controller.signal.aborted) return false
|
|
2724
|
+
if (!value || (path !== '/account' && value.ok !== true)) {
|
|
2725
|
+
throw new Error(value?.error ?? t('common.retryHint'))
|
|
2726
|
+
}
|
|
2727
|
+
setData((current) => ({ ...current, [path]: mergeCredits(path, current[path], value) }))
|
|
2728
|
+
return true
|
|
2729
|
+
} catch (error) {
|
|
2730
|
+
if (!controller.signal.aborted) {
|
|
2731
|
+
setData((current) => ({ ...current, [path]: staleCredits(path, current[path]) }))
|
|
2732
|
+
setErrors((current) => ({ ...current, [path]: `${path}:${error.message}` }))
|
|
2733
|
+
}
|
|
2734
|
+
return false
|
|
2735
|
+
} finally {
|
|
2736
|
+
if (requests.current.get(path) === controller) requests.current.delete(path)
|
|
2737
|
+
}
|
|
2738
|
+
}, [])
|
|
2739
|
+
|
|
2740
|
+
const loadAll = useCallback((background = false) => Promise.all(
|
|
2741
|
+
['/status', '/models', '/account', '/accounts'].map((path) => loadRoute(path, background)),
|
|
2742
|
+
), [loadRoute])
|
|
2743
|
+
const loadModels = useCallback(() => loadRoute('/models'), [loadRoute])
|
|
2744
|
+
const refreshModels = useCallback(() => {
|
|
2745
|
+
void loadRoute('/status', true)
|
|
2746
|
+
return loadModels()
|
|
2747
|
+
}, [loadModels, loadRoute])
|
|
2748
|
+
|
|
2749
|
+
useEffect(() => {
|
|
2750
|
+
void loadAll(true)
|
|
2751
|
+
const timer = setInterval(() => void loadAll(true), 5 * 60 * 1000)
|
|
2752
|
+
const activeRequests = requests.current
|
|
2753
|
+
return () => {
|
|
2754
|
+
clearInterval(timer)
|
|
2755
|
+
for (const controller of activeRequests.values()) controller.abort()
|
|
2756
|
+
activeRequests.clear()
|
|
2757
|
+
}
|
|
2758
|
+
}, [loadAll])
|
|
2759
|
+
|
|
2760
|
+
const status = data['/status']
|
|
2761
|
+
const models = data['/models']
|
|
2762
|
+
const account = data['/account']
|
|
2763
|
+
const pool = data['/accounts']
|
|
2764
|
+
const tabs = [
|
|
2765
|
+
{ id: 'account', paths: ['/accounts'], content: pool && h(AccountTab, { status, pool, onChanged: loadAll }) },
|
|
2766
|
+
{ id: 'models', paths: ['/models'], content: models && h(ModelsTab, { models, onRefresh: refreshModels, onSaved: loadModels }) },
|
|
2767
|
+
{ id: 'diagnostics', paths: ['/status', '/account'], content: status && h(DiagnosticsTab, { status, account, accountError: errors['/account'] }) },
|
|
2768
|
+
]
|
|
2769
|
+
|
|
2770
|
+
return h(
|
|
2771
|
+
'div',
|
|
2772
|
+
{ className: 'dca-page dca-settings' },
|
|
2773
|
+
h(
|
|
2774
|
+
'div',
|
|
2775
|
+
{ role: 'tablist', className: 'dca-tabs', 'aria-label': t('nav.label') },
|
|
2776
|
+
...tabs.map(({ id }, index) => h(
|
|
2777
|
+
'button',
|
|
2778
|
+
{
|
|
2779
|
+
key: id,
|
|
2780
|
+
type: 'button',
|
|
2781
|
+
role: 'tab',
|
|
2782
|
+
id: `${panelId}-tab-${id}`,
|
|
2783
|
+
ref: (button) => { tabButtons.current[id] = button },
|
|
2784
|
+
'aria-selected': tab === id,
|
|
2785
|
+
'aria-controls': `${panelId}-panel-${id}`,
|
|
2786
|
+
tabIndex: tab === id ? 0 : -1,
|
|
2787
|
+
className: `dca-tab${tab === id ? ' dca-tab-on' : ''}`,
|
|
2788
|
+
onClick: () => setTab(id),
|
|
2789
|
+
onKeyDown: (event) => {
|
|
2790
|
+
let nextIndex
|
|
2791
|
+
switch (event.key) {
|
|
2792
|
+
case 'ArrowRight': nextIndex = (index + 1) % tabs.length; break
|
|
2793
|
+
case 'ArrowLeft': nextIndex = (index - 1 + tabs.length) % tabs.length; break
|
|
2794
|
+
case 'Home': nextIndex = 0; break
|
|
2795
|
+
case 'End': nextIndex = tabs.length - 1; break
|
|
2796
|
+
default: return
|
|
2797
|
+
}
|
|
2798
|
+
event.preventDefault()
|
|
2799
|
+
const next = tabs[nextIndex].id
|
|
2800
|
+
setTab(next)
|
|
2801
|
+
tabButtons.current[next]?.focus()
|
|
2802
|
+
},
|
|
2803
|
+
},
|
|
2804
|
+
t(`tab.${id}`),
|
|
2805
|
+
)),
|
|
2806
|
+
),
|
|
2807
|
+
// Keep the panels mounted so navigation preserves edits and filters.
|
|
2808
|
+
...tabs.map(({ id, paths, content }) => {
|
|
2809
|
+
const error = paths.map((path) => errors[path]).filter(Boolean).join(';')
|
|
2810
|
+
const retry = () => Promise.all(paths.filter((path) => !data[path] || errors[path]).map((path) => loadRoute(path)))
|
|
2811
|
+
return h(
|
|
2812
|
+
'div',
|
|
2813
|
+
{ key: id, role: 'tabpanel', id: `${panelId}-panel-${id}`, 'aria-labelledby': `${panelId}-tab-${id}`, hidden: tab !== id, tabIndex: 0 },
|
|
2814
|
+
content ?? h(Pending, { error, onRetry: retry }),
|
|
2815
|
+
content && error ? h('div', { className: 'dca-section-error' },
|
|
2816
|
+
h('p', { className: 'dca-msg dca-msg-error', role: 'alert' }, error),
|
|
2817
|
+
h('button', { type: 'button', className: 'dca-btn', onClick: retry }, t('common.retry')),
|
|
2818
|
+
) : null,
|
|
2819
|
+
)
|
|
2820
|
+
}),
|
|
2821
|
+
)
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
// ── the composer chip ──────────────────────────────────────────────────
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* The credit reading beside the composer.
|
|
2828
|
+
*
|
|
2829
|
+
* Rendered as a slot entry inside the composer dock, so it takes the
|
|
2830
|
+
* space the Host allocates instead of floating over other controls.
|
|
2831
|
+
*/
|
|
2832
|
+
/**
|
|
2833
|
+
* Display names for reasoning levels.
|
|
2834
|
+
*
|
|
2835
|
+
* The picker already localises these via the adapter's reasoning metadata;
|
|
2836
|
+
* the model page printed the raw id, so the same level read `high` in one
|
|
2837
|
+
* place and 高 in the other.
|
|
2838
|
+
*/
|
|
2839
|
+
const EFFORT_LABELS = {
|
|
2840
|
+
off: ['关闭', 'Off'],
|
|
2841
|
+
low: ['低', 'Low'],
|
|
2842
|
+
medium: ['中', 'Medium'],
|
|
2843
|
+
high: ['高', 'High'],
|
|
2844
|
+
max: ['最高', 'Max'],
|
|
2845
|
+
xhigh: ['极高', 'Extra high'],
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
/** One reasoning level in the active language, falling back to its id. */
|
|
2849
|
+
function effortLabel(id) {
|
|
2850
|
+
const pair = EFFORT_LABELS[id]
|
|
2851
|
+
if (!pair) return id
|
|
2852
|
+
return isChinese() ? pair[0] : pair[1]
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
/** Credits with the grouping a balance deserves: 7,424.92. */
|
|
2856
|
+
function formatCredits(value) {
|
|
2857
|
+
const n = Number(value)
|
|
2858
|
+
if (!Number.isFinite(n)) return '—'
|
|
2859
|
+
return n.toLocaleString(undefined, { maximumFractionDigits: 2 })
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
/**
|
|
2863
|
+
* Which colour the row's dot takes.
|
|
2864
|
+
*
|
|
2865
|
+
* Red marks a known credential or balance problem. Amber marks a probe
|
|
2866
|
+
* error or unconfirmed health; healthy accounts need no extra status text.
|
|
2867
|
+
*/
|
|
2868
|
+
function dotTone(account) {
|
|
2869
|
+
const state = account.health?.state
|
|
2870
|
+
if (state === 'credentials' || state === 'insufficient') return ' dca-pop-dot-bad'
|
|
2871
|
+
if (account.creditStale || account.error || (state && state !== 'available')) return ' dca-pop-dot-warn'
|
|
2872
|
+
return ' dca-pop-dot-ok'
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function ComposerChip(props) {
|
|
2876
|
+
const [accountInfo, setAccountInfo] = useState(null)
|
|
2877
|
+
const [open, setOpen] = useState(false)
|
|
2878
|
+
const [busy, setBusy] = useState(false)
|
|
2879
|
+
const container = useRef(null)
|
|
2880
|
+
const loadSequence = useRef(0)
|
|
2881
|
+
const [now, setNow] = useState(Date.now())
|
|
2882
|
+
const [actionNotice, setActionNotice] = useState(null)
|
|
2883
|
+
const [switchingId, setSwitchingId] = useState(null)
|
|
2884
|
+
const openSettings = props?.openSettings
|
|
2885
|
+
|
|
2886
|
+
// Only speak up when this session is actually pointed at a 码道 model.
|
|
2887
|
+
// Without this the readout would sit in every session's composer,
|
|
2888
|
+
// including sessions that can never route a request here — noise for
|
|
2889
|
+
// anyone not using this provider, and a misleading figure for anyone
|
|
2890
|
+
// who is using a different one.
|
|
2891
|
+
//
|
|
2892
|
+
// `next` wins over `lastUsed`: a selection that has landed but not yet
|
|
2893
|
+
// been sent is still the one the composer is displaying. Both are
|
|
2894
|
+
// optional, so a host without this projection simply renders the pill
|
|
2895
|
+
// (fail-open) rather than hiding a working readout.
|
|
2896
|
+
const projection = props?.useProjection ? props.useProjection('modelSelection') : undefined
|
|
2897
|
+
const selected = projection?.next ?? projection?.lastUsed
|
|
2898
|
+
const selectedProvider = typeof selected?.provider === 'string' ? selected.provider : undefined
|
|
2899
|
+
const ownsSelection = selectedProvider === undefined || selectedProvider === PROVIDER_ID
|
|
2900
|
+
|
|
2901
|
+
const load = useCallback(async () => {
|
|
2902
|
+
const sequence = ++loadSequence.current
|
|
2903
|
+
const [accountR, poolR] = await Promise.allSettled([getRoute('/account'), getRoute('/accounts')])
|
|
2904
|
+
if (sequence !== loadSequence.current) return
|
|
2905
|
+
setNow(Date.now())
|
|
2906
|
+
setAccountInfo((previous) => {
|
|
2907
|
+
const accountOk = accountR.status === 'fulfilled' && (accountR.value?.ok === true || accountR.value?.stage === 'credentials')
|
|
2908
|
+
const poolOk = poolR.status === 'fulfilled' && poolR.value?.ok === true && Array.isArray(poolR.value.accounts)
|
|
2909
|
+
const account = accountOk
|
|
2910
|
+
? mergeCredits('/account', previous, accountR.value)
|
|
2911
|
+
: staleCredits('/account', previous) ?? { ok: false, stage: 'gateway' }
|
|
2912
|
+
return {
|
|
2913
|
+
...account,
|
|
2914
|
+
pool: poolOk ? mergeCredits('/accounts', previous?.pool, poolR.value) : staleCredits('/accounts', previous?.pool),
|
|
2915
|
+
accountReadFailed: !accountOk || accountR.value?.ok !== true || !accountR.value?.credit,
|
|
2916
|
+
poolReadFailed: !poolOk,
|
|
2917
|
+
}
|
|
2918
|
+
})
|
|
2919
|
+
}, [])
|
|
2920
|
+
|
|
2921
|
+
useEffect(() => {
|
|
2922
|
+
// Nothing is fetched while another provider is selected: the readout is
|
|
2923
|
+
// hidden then, and a 5-minute poll would ask the gateway on behalf of
|
|
2924
|
+
// every session in the app.
|
|
2925
|
+
if (!ownsSelection) return undefined
|
|
2926
|
+
void load()
|
|
2927
|
+
const timer = setInterval(() => void load(), 5 * 60 * 1000)
|
|
2928
|
+
return () => { clearInterval(timer); loadSequence.current += 1 }
|
|
2929
|
+
}, [load, ownsSelection])
|
|
2930
|
+
|
|
2931
|
+
useEffect(() => {
|
|
2932
|
+
if (!open) return undefined
|
|
2933
|
+
setNow(Date.now())
|
|
2934
|
+
const timer = setInterval(() => setNow(Date.now()), 30000)
|
|
2935
|
+
return () => clearInterval(timer)
|
|
2936
|
+
}, [open])
|
|
2937
|
+
|
|
2938
|
+
// Closing on an outside click keeps the panel from being modal: it is a
|
|
2939
|
+
// reading, not a task.
|
|
2940
|
+
useEffect(() => {
|
|
2941
|
+
if (!open) return undefined
|
|
2942
|
+
const onDown = (event) => {
|
|
2943
|
+
if (container.current && !container.current.contains(event.target)) setOpen(false)
|
|
2944
|
+
}
|
|
2945
|
+
const onKey = (event) => {
|
|
2946
|
+
if (event.key === 'Escape') setOpen(false)
|
|
2947
|
+
}
|
|
2948
|
+
document.addEventListener('mousedown', onDown)
|
|
2949
|
+
document.addEventListener('keydown', onKey)
|
|
2950
|
+
return () => {
|
|
2951
|
+
document.removeEventListener('mousedown', onDown)
|
|
2952
|
+
document.removeEventListener('keydown', onKey)
|
|
2953
|
+
}
|
|
2954
|
+
}, [open])
|
|
2955
|
+
|
|
2956
|
+
const refresh = useCallback(async () => {
|
|
2957
|
+
setBusy(true); setActionNotice(null)
|
|
2958
|
+
try {
|
|
2959
|
+
await load()
|
|
2960
|
+
} finally {
|
|
2961
|
+
setBusy(false)
|
|
2962
|
+
}
|
|
2963
|
+
}, [load])
|
|
2964
|
+
|
|
2965
|
+
/** Move the pool to another account; the panel's rows call this. */
|
|
2966
|
+
const activateAccount = useCallback(async (account) => {
|
|
2967
|
+
setBusy(true); setActionNotice(null); setSwitchingId(account.id)
|
|
2968
|
+
loadSequence.current += 1
|
|
2969
|
+
try {
|
|
2970
|
+
const result = await postRoute('/accounts/activate', { id: account.id })
|
|
2971
|
+
if (!result.ok) throw new Error(result.error ?? t('common.retry'))
|
|
2972
|
+
// The previous headline belongs to another account, even if the next read fails.
|
|
2973
|
+
setAccountInfo((previous) => previous ? { ...previous, credit: null, creditCheckedAt: null, creditStale: false, creditIdentity: null, accountId: account.id, source: undefined,
|
|
2974
|
+
pool: previous.pool ? { ...previous.pool, accounts: previous.pool.accounts.map((entry) => ({ ...entry, active: entry.id === account.id })) } : null,
|
|
2975
|
+
} : previous)
|
|
2976
|
+
await load()
|
|
2977
|
+
setActionNotice({ kind: 'success', text: t('pool.switched').replace('{account}', account.label) })
|
|
2978
|
+
} catch (error) {
|
|
2979
|
+
setActionNotice({ kind: 'error', text: t('pool.switchFailed').replace('{account}', account.label).replace('{error}', error.message) })
|
|
2980
|
+
} finally { setBusy(false); setSwitchingId(null) }
|
|
2981
|
+
}, [load])
|
|
2982
|
+
|
|
2983
|
+
const accounts = accountInfo?.pool?.accounts ?? []
|
|
2984
|
+
const refreshing = busy && switchingId === null
|
|
2985
|
+
const refreshFailed = accountInfo?.accountReadFailed || accountInfo?.poolReadFailed || accountInfo?.creditStale || accounts.some((account) => account.creditStale)
|
|
2986
|
+
// Nothing to show until the Host answers, and nothing to show when no
|
|
2987
|
+
// credential is configured: an empty pill on every composer would be
|
|
2988
|
+
// noise for anyone not using this provider.
|
|
2989
|
+
if (!accountInfo || accountInfo.composerChip === false) return null
|
|
2990
|
+
if (!ownsSelection) return null
|
|
2991
|
+
// With a 码道 model selected but no usable credential, saying nothing was
|
|
2992
|
+
// the worst option: the user picked this provider and the readout simply
|
|
2993
|
+
// is not there. Show the state and where to fix it instead.
|
|
2994
|
+
const hasCredential = accountInfo?.ok === true || accountInfo?.source || accountInfo?.account || accountInfo?.stage === 'gateway'
|
|
2995
|
+
if (!hasCredential) {
|
|
2996
|
+
const body = [
|
|
2997
|
+
h('span', { key: 'm', 'aria-hidden': true, className: 'dca-chip-mark' }, '◈'),
|
|
2998
|
+
h('span', { key: 'l' }, t('chip.noCredential')),
|
|
2999
|
+
]
|
|
3000
|
+
// No credential: the pill becomes the way to fix that. The jump is
|
|
3001
|
+
// soft-probed at press time, so it works whenever the settings shell is
|
|
3002
|
+
// present and does nothing when it is not.
|
|
3003
|
+
return h(
|
|
3004
|
+
'div',
|
|
3005
|
+
{ className: 'dca-chip' },
|
|
3006
|
+
h(
|
|
3007
|
+
'button',
|
|
3008
|
+
{
|
|
3009
|
+
type: 'button',
|
|
3010
|
+
className: 'dca-chip-trigger',
|
|
3011
|
+
title: accountInfo?.error ?? t('chip.noCredentialHint'),
|
|
3012
|
+
onClick: openSettings,
|
|
3013
|
+
},
|
|
3014
|
+
...body,
|
|
3015
|
+
),
|
|
3016
|
+
)
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
const credits = accountInfo.credit
|
|
3020
|
+
const label = credits
|
|
3021
|
+
? `${t(accountInfo.creditStale ? 'chip.lastCredits' : 'chip.credits')} ${formatCredits(credits.remain)}`
|
|
3022
|
+
: t('account.creditUnread')
|
|
3023
|
+
|
|
3024
|
+
return h(
|
|
3025
|
+
'div',
|
|
3026
|
+
{ ref: container, className: 'dca-chip' },
|
|
3027
|
+
h(
|
|
3028
|
+
'button',
|
|
3029
|
+
{
|
|
3030
|
+
type: 'button',
|
|
3031
|
+
title: accountInfo.creditStale ? t('credit.refreshFailed') : t('chip.panelTitle'),
|
|
3032
|
+
'aria-haspopup': 'dialog',
|
|
3033
|
+
'aria-expanded': open,
|
|
3034
|
+
onClick: () => setOpen((value) => !value),
|
|
3035
|
+
// Borderless at rest (see .dca-chip-trigger): this row is a strip of
|
|
3036
|
+
// compact controls, and a boxed pill among them reads as a form
|
|
3037
|
+
// field. Hover and focus come from the stylesheet, which inline
|
|
3038
|
+
// styles cannot express.
|
|
3039
|
+
className: `dca-chip-trigger${open ? ' dca-chip-trigger-on' : ''}`,
|
|
3040
|
+
},
|
|
3041
|
+
h('span', { 'aria-hidden': true, className: 'dca-chip-mark' }, '◈'),
|
|
3042
|
+
h('span', null, label),
|
|
3043
|
+
),
|
|
3044
|
+
open
|
|
3045
|
+
? h(
|
|
3046
|
+
'div',
|
|
3047
|
+
{
|
|
3048
|
+
role: 'dialog',
|
|
3049
|
+
'aria-label': t('chip.panelTitle'),
|
|
3050
|
+
className: 'dca-pop',
|
|
3051
|
+
},
|
|
3052
|
+
h(
|
|
3053
|
+
'div',
|
|
3054
|
+
{ className: 'dca-pop-head' },
|
|
3055
|
+
h('span', { className: 'dca-pop-title' }, t('chip.panelTitle')),
|
|
3056
|
+
h(
|
|
3057
|
+
'button',
|
|
3058
|
+
{
|
|
3059
|
+
type: 'button',
|
|
3060
|
+
className: 'dca-pop-refresh',
|
|
3061
|
+
disabled: busy,
|
|
3062
|
+
title: t('chip.refreshHint'),
|
|
3063
|
+
'aria-label': t('chip.refreshHint'),
|
|
3064
|
+
onClick: refresh,
|
|
3065
|
+
},
|
|
3066
|
+
h(
|
|
3067
|
+
'svg',
|
|
3068
|
+
{
|
|
3069
|
+
className: `dca-pop-refresh-icon${refreshing ? ' dca-pop-refresh-icon-spin' : ''}`,
|
|
3070
|
+
viewBox: '0 0 16 16',
|
|
3071
|
+
width: 12,
|
|
3072
|
+
height: 12,
|
|
3073
|
+
fill: 'none',
|
|
3074
|
+
'aria-hidden': 'true',
|
|
3075
|
+
focusable: 'false',
|
|
3076
|
+
},
|
|
3077
|
+
h('path', {
|
|
3078
|
+
d: 'M13.3 8a5.3 5.3 0 1 1-1.55-3.75',
|
|
3079
|
+
stroke: 'currentColor',
|
|
3080
|
+
strokeWidth: 1.5,
|
|
3081
|
+
strokeLinecap: 'round',
|
|
3082
|
+
}),
|
|
3083
|
+
h('path', {
|
|
3084
|
+
d: 'M13.3 2.2v3.1h-3.1',
|
|
3085
|
+
stroke: 'currentColor',
|
|
3086
|
+
strokeWidth: 1.5,
|
|
3087
|
+
strokeLinecap: 'round',
|
|
3088
|
+
strokeLinejoin: 'round',
|
|
3089
|
+
}),
|
|
3090
|
+
),
|
|
3091
|
+
refreshFailed ? t('common.retry') : t('chip.refresh'),
|
|
3092
|
+
),
|
|
3093
|
+
h(
|
|
3094
|
+
'button',
|
|
3095
|
+
{
|
|
3096
|
+
type: 'button',
|
|
3097
|
+
className: 'dca-pop-settings',
|
|
3098
|
+
onClick: () => {
|
|
3099
|
+
openSettings()
|
|
3100
|
+
setOpen(false)
|
|
3101
|
+
},
|
|
3102
|
+
},
|
|
3103
|
+
h('span', { 'aria-hidden': true, className: 'dca-pop-settings-icon' }, '⚙'),
|
|
3104
|
+
t('chip.settings'),
|
|
3105
|
+
),
|
|
3106
|
+
),
|
|
3107
|
+
h(FeatureNotice, { notice: actionNotice }),
|
|
3108
|
+
refreshFailed ? h('p', { className: 'dca-pop-notice', role: 'status' }, accountInfo.credit || accounts.some((account) => account.credit) ? t('credit.refreshFailed') : t('credit.unavailable')) : null,
|
|
3109
|
+
h(CreditStatus, { account: accountInfo, now }),
|
|
3110
|
+
// One row per account, in a real table so the balances line up in a
|
|
3111
|
+
// single right-aligned column. The serving account is a row, not a
|
|
3112
|
+
// header: "which account" and "how many credits" are the same fact
|
|
3113
|
+
// about the same thing, and splitting them made the panel read as
|
|
3114
|
+
// two unrelated blocks.
|
|
3115
|
+
accounts.length === 0
|
|
3116
|
+
? h(
|
|
3117
|
+
'p',
|
|
3118
|
+
{ className: 'dca-pop-empty' },
|
|
3119
|
+
accountInfo.credit ? formatBalance(accountInfo.credit) : t('account.creditUnread'),
|
|
3120
|
+
)
|
|
3121
|
+
: h(
|
|
3122
|
+
'table',
|
|
3123
|
+
{ className: 'dca-pop-table' },
|
|
3124
|
+
h(
|
|
3125
|
+
'thead',
|
|
3126
|
+
null,
|
|
3127
|
+
h(
|
|
3128
|
+
'tr',
|
|
3129
|
+
null,
|
|
3130
|
+
h('th', { scope: 'col' }, t('pool.colAccount')),
|
|
3131
|
+
h('th', { scope: 'col', className: 'dca-pop-num' }, t('pool.colCredits')),
|
|
3132
|
+
),
|
|
3133
|
+
),
|
|
3134
|
+
h(
|
|
3135
|
+
'tbody',
|
|
3136
|
+
null,
|
|
3137
|
+
...accounts.map((account) =>
|
|
3138
|
+
h(
|
|
3139
|
+
'tr',
|
|
3140
|
+
{
|
|
3141
|
+
key: account.id,
|
|
3142
|
+
// The serving row: bold name, and its switch is
|
|
3143
|
+
// disabled, so it never takes the hover fill either.
|
|
3144
|
+
className: account.active ? 'dca-pop-row-current' : undefined,
|
|
3145
|
+
},
|
|
3146
|
+
h(
|
|
3147
|
+
'td',
|
|
3148
|
+
null,
|
|
3149
|
+
h(
|
|
3150
|
+
'button',
|
|
3151
|
+
{
|
|
3152
|
+
type: 'button',
|
|
3153
|
+
className: 'dca-pop-switch',
|
|
3154
|
+
disabled: busy || account.active,
|
|
3155
|
+
'aria-busy': switchingId === account.id,
|
|
3156
|
+
title: t('chip.switchTo').replace('{account}', account.label),
|
|
3157
|
+
'aria-label': t('chip.switchTo').replace('{account}', account.label),
|
|
3158
|
+
onClick: () => void activateAccount(account),
|
|
3159
|
+
},
|
|
3160
|
+
h('span', {
|
|
3161
|
+
className: `dca-pop-dot${dotTone(account)}`,
|
|
3162
|
+
'aria-hidden': 'true',
|
|
3163
|
+
}),
|
|
3164
|
+
h(
|
|
3165
|
+
'span',
|
|
3166
|
+
{ className: 'dca-pop-who' },
|
|
3167
|
+
h('span', { className: 'dca-pop-name' }, account.label),
|
|
3168
|
+
switchingId === account.id || account.active || account.error || (account.health?.state && account.health.state !== 'available')
|
|
3169
|
+
? h('span', { className: 'dca-pop-mark' },
|
|
3170
|
+
switchingId === account.id ? h('span', { role: 'status' }, t('pool.switching')) : null,
|
|
3171
|
+
account.active ? h('span', { className: 'dca-pop-mark-current' }, t('chip.current')) : null,
|
|
3172
|
+
account.error || (account.health?.state && account.health.state !== 'available')
|
|
3173
|
+
? h('span', { className: 'dca-pop-mark-reason', title: account.error || undefined }, t(`health.${account.health?.state && account.health.state !== 'available' ? account.health.state : 'unknown'}`))
|
|
3174
|
+
: null,
|
|
3175
|
+
)
|
|
3176
|
+
: null,
|
|
3177
|
+
),
|
|
3178
|
+
),
|
|
3179
|
+
),
|
|
3180
|
+
h(
|
|
3181
|
+
'td',
|
|
3182
|
+
{ className: 'dca-pop-num' },
|
|
3183
|
+
account.credit ? formatCredits(account.credit.remain) : '—',
|
|
3184
|
+
h(CreditStatus, { account, now }),
|
|
3185
|
+
account.credit?.expiring > 0
|
|
3186
|
+
? h(
|
|
3187
|
+
'span',
|
|
3188
|
+
{ className: 'dca-pop-soon' },
|
|
3189
|
+
t('pool.expiring').replace(
|
|
3190
|
+
'{amount}',
|
|
3191
|
+
Number(account.credit.expiring).toLocaleString(),
|
|
3192
|
+
),
|
|
3193
|
+
)
|
|
3194
|
+
: null,
|
|
3195
|
+
),
|
|
3196
|
+
),
|
|
3197
|
+
),
|
|
3198
|
+
),
|
|
3199
|
+
),
|
|
3200
|
+
)
|
|
3201
|
+
: null,
|
|
3202
|
+
)
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
// ── registration ───────────────────────────────────────────────────────
|
|
3206
|
+
|
|
3207
|
+
const name = 'dsh-connect-codearts-client'
|
|
3208
|
+
const inject = ['slots']
|
|
3209
|
+
|
|
3210
|
+
/**
|
|
3211
|
+
* Register both surfaces.
|
|
3212
|
+
*
|
|
3213
|
+
* Every registration is installed through `ctx.slots.inject`, so the Host
|
|
3214
|
+
* disposes it when the owning declaration collapses, and re-installs it
|
|
3215
|
+
* when the declaration returns.
|
|
3216
|
+
*
|
|
3217
|
+
* The stylesheet is mounted FIRST, as a tagged <style> element.
|
|
3218
|
+
*
|
|
3219
|
+
* NOT through a `styles.insert(css)` builtin: that symbol belongs to the
|
|
3220
|
+
* dynamic client-runner lane, which evaluates a definition with
|
|
3221
|
+
* `new Function('React','console','styles',…)`. This file is a Module
|
|
3222
|
+
* Loader bundle — `window.__ModuleLoader__.load({ factory(require) })` —
|
|
3223
|
+
* and no such binding exists here. A `typeof styles` guard would have made
|
|
3224
|
+
* that mistake silent: markup would render with class names that no rule
|
|
3225
|
+
* matches, giving unstyled buttons and a popover in normal flow.
|
|
3226
|
+
*
|
|
3227
|
+
* The tag is claimed by data attributes and re-written in place rather than
|
|
3228
|
+
* appended twice, so a hot reload refreshes the rules instead of stacking
|
|
3229
|
+
* copies of them.
|
|
3230
|
+
*/
|
|
3231
|
+
function apply(ctx) {
|
|
3232
|
+
if (typeof document !== 'undefined') {
|
|
3233
|
+
ctx.effect(() => {
|
|
3234
|
+
const cssId = 'dsh-connect-codearts/client.css'
|
|
3235
|
+
const selector = `style[data-plugin-css="${cssId}"]`
|
|
3236
|
+
const existing = document.querySelector(selector)
|
|
3237
|
+
if (existing !== null) {
|
|
3238
|
+
existing.textContent = CSS
|
|
3239
|
+
} else {
|
|
3240
|
+
const tag = document.createElement('style')
|
|
3241
|
+
tag.dataset.plugin = 'dsh-connect-codearts'
|
|
3242
|
+
tag.dataset.pluginCss = cssId
|
|
3243
|
+
tag.textContent = CSS
|
|
3244
|
+
document.head.appendChild(tag)
|
|
3245
|
+
}
|
|
3246
|
+
return () => {
|
|
3247
|
+
const owned = document.querySelector(selector)
|
|
3248
|
+
if (owned !== null) owned.remove()
|
|
3249
|
+
}
|
|
3250
|
+
}, 'dsh-connect-codearts: stylesheet')
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
// The page and its glyph come from ONE callback: the section's
|
|
3254
|
+
// declaration is what makes the glyph addressable, and registering both
|
|
3255
|
+
// here means neither can outlive the other. The glyph is decoration — a
|
|
3256
|
+
// host that declares the section but not its icon seat must still get the
|
|
3257
|
+
// page — so its failure is logged, not thrown.
|
|
3258
|
+
ctx.slots.inject('settings.section', () => {
|
|
3259
|
+
const disposers = [
|
|
3260
|
+
ctx.slots.register(
|
|
3261
|
+
{
|
|
3262
|
+
name: 'settings.section',
|
|
3263
|
+
id: 'dsh-connect-codearts',
|
|
3264
|
+
order: 36,
|
|
3265
|
+
label: () => t('nav.label'),
|
|
3266
|
+
},
|
|
3267
|
+
SettingsPage,
|
|
3268
|
+
),
|
|
3269
|
+
]
|
|
3270
|
+
try {
|
|
3271
|
+
const iconInject = ctx.slots.inject('settings.section.icon', () => {
|
|
3272
|
+
const dispose = ctx.slots.register(
|
|
3273
|
+
{ name: 'settings.section.icon', id: 'dsh-connect-codearts' },
|
|
3274
|
+
NavIcon,
|
|
3275
|
+
)
|
|
3276
|
+
disposers.push(dispose)
|
|
3277
|
+
return dispose
|
|
3278
|
+
})
|
|
3279
|
+
if (typeof iconInject === 'function') disposers.push(iconInject)
|
|
3280
|
+
} catch (error) {
|
|
3281
|
+
console.error('[dsh-connect-codearts] settings nav icon failed to register (page unaffected):', error)
|
|
3282
|
+
}
|
|
3283
|
+
return () => {
|
|
3284
|
+
for (const dispose of disposers) {
|
|
3285
|
+
try {
|
|
3286
|
+
dispose()
|
|
3287
|
+
} catch {
|
|
3288
|
+
// Already disposed by the slot service.
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
})
|
|
3293
|
+
|
|
3294
|
+
// Where the panel's 「设置」 button goes: this plugin's own section INSIDE
|
|
3295
|
+
// the settings dialog.
|
|
3296
|
+
//
|
|
3297
|
+
// The old route called `pluginNavigation.openBundle(...)`, which asks the
|
|
3298
|
+
// Plugins page to select a bundle — it lands on that bundle's page, not on
|
|
3299
|
+
// this plugin's section, and it only works while that page's own service
|
|
3300
|
+
// exists. The supported route is the settings shell's store seat: read the
|
|
3301
|
+
// `settings.section` entry's store, create its handle, and ask it to open
|
|
3302
|
+
// the section by id. Everything here is soft-probed and wrapped, because it
|
|
3303
|
+
// is another bundle's service on a composed profile.
|
|
3304
|
+
const softGet = (name) => (typeof ctx.get === 'function' ? ctx.get(name) : undefined)
|
|
3305
|
+
|
|
3306
|
+
/**
|
|
3307
|
+
* The shipped slot whose STORE SEAT is the settings shell's state handle.
|
|
3308
|
+
*
|
|
3309
|
+
* Verified against the shipped client, not assumed: ui-settings-general
|
|
3310
|
+
* registers `{ name: 'sidebar.settings', store: shellStore, ... }`, and that
|
|
3311
|
+
* store's actions are `{ open, close, select, openSection }`. NOT
|
|
3312
|
+
* `settings.section` — that slot lists the PAGES and carries no store.
|
|
3313
|
+
*
|
|
3314
|
+
* `openSection` is otherwise handed only to onboarding steps and section
|
|
3315
|
+
* owner props (`close`), so reading a seat the shell published is the
|
|
3316
|
+
* supported way in rather than registering a fake first-run step.
|
|
3317
|
+
*/
|
|
3318
|
+
const SETTINGS_SLOT = 'sidebar.settings'
|
|
3319
|
+
|
|
3320
|
+
/**
|
|
3321
|
+
* The panel container. `data-shortcut-modal="settings"` is the shell's OWN
|
|
3322
|
+
* attribute — its shortcut router keys off it — so it is far more stable
|
|
3323
|
+
* than any class name, which is a CSS-module hash.
|
|
3324
|
+
*/
|
|
3325
|
+
const SETTINGS_PANEL_SELECTOR = '[data-shortcut-modal="settings"]'
|
|
3326
|
+
|
|
3327
|
+
/** The sidebar's settings trigger: dialog semantics plus an expanded state. */
|
|
3328
|
+
const TRIGGER_SELECTOR = 'button[aria-haspopup="dialog"][aria-expanded]'
|
|
3329
|
+
|
|
3330
|
+
/**
|
|
3331
|
+
* Budget for "panel mounted + nav row rendered". The panel mounts
|
|
3332
|
+
* synchronously on the click, but the nav rows' labels wait for a locale
|
|
3333
|
+
* snapshot, so a same-frame query is often one tick too early.
|
|
3334
|
+
*/
|
|
3335
|
+
const RETRY_DELAYS_MS = [0, 60, 70, 80, 90]
|
|
3336
|
+
|
|
3337
|
+
const schedule = (run, ms) => {
|
|
3338
|
+
try {
|
|
3339
|
+
window.setTimeout(run, ms)
|
|
3340
|
+
} catch {
|
|
3341
|
+
run()
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
/**
|
|
3346
|
+
* Route 1: the shell's own store seat — one call, exact, no timing.
|
|
3347
|
+
*
|
|
3348
|
+
* @returns 'opened' when the dialog is on the right section, 'shell' when
|
|
3349
|
+
* the dialog opened but without preselection (route 2 can still click the
|
|
3350
|
+
* row), and undefined when the seat is absent or unusable.
|
|
3351
|
+
*/
|
|
3352
|
+
const openThroughStoreSeat = (get, sectionId) => {
|
|
3353
|
+
let slots
|
|
3354
|
+
try {
|
|
3355
|
+
slots = get('slots')
|
|
3356
|
+
} catch {
|
|
3357
|
+
return undefined
|
|
3358
|
+
}
|
|
3359
|
+
if (slots === undefined || typeof slots.entries !== 'function') return undefined
|
|
3360
|
+
|
|
3361
|
+
let seat
|
|
3362
|
+
try {
|
|
3363
|
+
// A plain ledger read, but it is another bundle's service: a composed
|
|
3364
|
+
// profile can replace `slots` with something that throws here.
|
|
3365
|
+
seat = slots.entries(SETTINGS_SLOT)[0]?.store
|
|
3366
|
+
} catch {
|
|
3367
|
+
return undefined
|
|
3368
|
+
}
|
|
3369
|
+
if (seat === null || typeof seat !== 'object') return undefined
|
|
3370
|
+
if (typeof seat.create !== 'function') return undefined
|
|
3371
|
+
|
|
3372
|
+
try {
|
|
3373
|
+
// The shell pins `create()` to its ONE live instance. A bare handle
|
|
3374
|
+
// would mint a private copy per call, and `openSection` on that copy
|
|
3375
|
+
// would move a dialog nobody renders.
|
|
3376
|
+
const instance = seat.create()
|
|
3377
|
+
const openSection = instance?.actions?.openSection
|
|
3378
|
+
if (typeof openSection === 'function') {
|
|
3379
|
+
openSection(sectionId)
|
|
3380
|
+
return 'opened'
|
|
3381
|
+
}
|
|
3382
|
+
// A shell whose store predates `openSection`. Pressing still opens the
|
|
3383
|
+
// dialog, so hand back 'shell' and let route 2 click the nav row.
|
|
3384
|
+
const open = instance?.actions?.open
|
|
3385
|
+
if (typeof open === 'function') {
|
|
3386
|
+
open()
|
|
3387
|
+
return 'shell'
|
|
3388
|
+
}
|
|
3389
|
+
} catch {
|
|
3390
|
+
// `create()` or a baked action threw. Nothing left here.
|
|
3391
|
+
}
|
|
3392
|
+
return undefined
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
/** Find the nav-row button whose label is this plugin's. */
|
|
3396
|
+
const findSectionRow = (scope, label) => {
|
|
3397
|
+
const want = String(label ?? '').trim()
|
|
3398
|
+
if (want === '') return undefined
|
|
3399
|
+
return Array.from(scope.querySelectorAll('button')).find(
|
|
3400
|
+
(button) => (button.textContent ?? '').trim() === want,
|
|
3401
|
+
)
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
/**
|
|
3405
|
+
* Route 2: drive the chrome — click the trigger, then this plugin's nav row.
|
|
3406
|
+
* Kept for a shell whose store predates the seat: deleting it would trade a
|
|
3407
|
+
* working route for nothing on those hosts.
|
|
3408
|
+
*/
|
|
3409
|
+
const openThroughChrome = () => {
|
|
3410
|
+
try {
|
|
3411
|
+
// The panel may ALREADY be open (the user was on another section).
|
|
3412
|
+
// Clicking the trigger then would CLOSE it — the jump would turn into a
|
|
3413
|
+
// disappearing act — so only drive the trigger when it is absent.
|
|
3414
|
+
if (document.querySelector(SETTINGS_PANEL_SELECTOR) === null) {
|
|
3415
|
+
const triggers = Array.from(document.querySelectorAll(TRIGGER_SELECTOR))
|
|
3416
|
+
const collapsed = triggers.find((button) => button.getAttribute('aria-expanded') !== 'true')
|
|
3417
|
+
// No trigger at all: this host has no settings panel to open. Do not
|
|
3418
|
+
// guess — report that nothing was driven.
|
|
3419
|
+
if (collapsed === undefined) return false
|
|
3420
|
+
collapsed.click()
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
let clicked = false
|
|
3424
|
+
for (const delay of RETRY_DELAYS_MS) {
|
|
3425
|
+
schedule(() => {
|
|
3426
|
+
if (clicked) return
|
|
3427
|
+
try {
|
|
3428
|
+
const scope = document.querySelector(SETTINGS_PANEL_SELECTOR) ?? document
|
|
3429
|
+
const row = findSectionRow(scope, t('nav.label'))
|
|
3430
|
+
if (row !== undefined) {
|
|
3431
|
+
clicked = true
|
|
3432
|
+
row.click()
|
|
3433
|
+
}
|
|
3434
|
+
} catch {
|
|
3435
|
+
// Shell shaped differently: this attempt is done, the next runs.
|
|
3436
|
+
}
|
|
3437
|
+
}, delay)
|
|
3438
|
+
}
|
|
3439
|
+
return true
|
|
3440
|
+
} catch {
|
|
3441
|
+
return false
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
/**
|
|
3446
|
+
* Open Settings on this plugin's section.
|
|
3447
|
+
*
|
|
3448
|
+
* Two routes, best first. Every step is wrapped: this runs from a RENDER
|
|
3449
|
+
* path (a click handler in the composer panel), so a throw here would take
|
|
3450
|
+
* out the whole readout rather than one button. A shell of a different shape
|
|
3451
|
+
* degrades to a silent no-op.
|
|
3452
|
+
*
|
|
3453
|
+
* Probed PER PRESS rather than captured during apply: the seat belongs to
|
|
3454
|
+
* another bundle whose apply order is not ours to assume, and a captured
|
|
3455
|
+
* `undefined` would leave the button dead for the whole session.
|
|
3456
|
+
*/
|
|
3457
|
+
const openSettings = () => {
|
|
3458
|
+
let seatResult
|
|
3459
|
+
try {
|
|
3460
|
+
seatResult = openThroughStoreSeat(softGet, 'dsh-connect-codearts')
|
|
3461
|
+
} catch {
|
|
3462
|
+
seatResult = undefined
|
|
3463
|
+
}
|
|
3464
|
+
if (seatResult === 'opened') return
|
|
3465
|
+
try {
|
|
3466
|
+
openThroughChrome()
|
|
3467
|
+
} catch {
|
|
3468
|
+
// A navigation failure must not break the composer row.
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
ctx.slots.inject('conversation.input.right', () =>
|
|
3473
|
+
ctx.slots.register(
|
|
3474
|
+
{
|
|
3475
|
+
name: 'conversation.input.right',
|
|
3476
|
+
id: 'dsh-connect-codearts-chip',
|
|
3477
|
+
order: 6,
|
|
3478
|
+
inject: () => ({ openSettings }),
|
|
3479
|
+
},
|
|
3480
|
+
ComposerChip,
|
|
3481
|
+
),
|
|
3482
|
+
)
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
exports.name = name
|
|
3486
|
+
exports.inject = inject
|
|
3487
|
+
exports.apply = apply
|
|
3488
|
+
exports.STRINGS = STRINGS
|
|
3489
|
+
return module.exports
|
|
3490
|
+
},
|
|
3491
|
+
})
|