@gluztm/dsh-guard 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Client half of @gluztm/dsh-guard — Cross-platform read-only health, masked key readiness,
3
- * snapshot timeline, and Windows DSHGuard Desktop Console bridge for DeepSeek Harness.
2
+ * Client half of @gluztm/dsh-guard — Cross-platform DSH profile manager,
3
+ * plugin/MCP switchboard, one-way .credentials.yaml writer, llm-pi-ai inspector,
4
+ * and local config snapshot & diff rollback panel for DeepSeek Harness.
4
5
  *
5
- * Strictly zero-secret-leak: never reads, slices, stores, or transmits API keys or tokens.
6
- * Uses only React.createElement, useState, useEffect, and Component so lightweight ModuleLoader hosts stay compatible.
6
+ * Strictly zero-secret-leak: never reads, displays, or transmits plaintext secret values.
7
+ * Uses only React.createElement, useState, useEffect, and Component for universal ModuleLoader compatibility.
7
8
  */
8
9
  window.__ModuleLoader__.load({
9
10
  id: '@gluztm/dsh-guard',
@@ -13,247 +14,275 @@ window.__ModuleLoader__.load({
13
14
 
14
15
  const SIDE_ID = 'dsh-guard'
15
16
  const API_BASE = 'api/dsh-guard'
16
- const STYLE_ID = 'dsh-guard-panel-styles-v241'
17
- const VERSION = '2.4.1'
17
+ const STYLE_ID = 'dsh-guard-panel-styles-v242'
18
+ const VERSION = '2.4.2'
18
19
  const REPO_FALLBACK = 'https://github.com/gluztm/DSHGuard'
19
- const RELEASE_FALLBACK = 'https://github.com/gluztm/DSHGuard/releases/latest'
20
- const INSTALLER_FALLBACK = 'https://github.com/gluztm/DSHGuard/releases/download/2.4.1/DSHGuard-Setup-2.4.1.exe'
20
+ const RELEASE_FALLBACK = 'https://github.com/gluztm/DSHGuard/releases/tag/2.4.2'
21
+ const INSTALLER_FALLBACK = 'https://github.com/gluztm/DSHGuard/releases/download/2.4.2/DSHGuard-Setup-2.4.2.exe'
21
22
 
22
23
  const COPY = {
23
24
  zh: {
24
- brand: 'DSH 守护壳',
25
- subtitle: '双轨体检 · 脱敏对账 · 快照回望',
25
+ brand: 'DSH 守护伴生',
26
+ subtitle: '插件启停 · 凭据盲写 · 配置快照',
27
+ guideDesc: '内置管理插件/MCP 开关、断链修复、单向写入 .credentials.yaml 与本地 YAML 配置快照。',
26
28
  versionPill: `v${VERSION}`,
27
- refresh: '重新体检',
28
- refreshing: '体检中',
29
+ refresh: '刷新',
30
+ refreshing: '同步中',
29
31
  langSwitch: 'EN',
30
- healthy: '双轨配置健康',
31
- unhealthy: (n) => `发现 ${n} 项异常`,
32
- loading: '正在读取双轨配置、凭据键与快照状态…',
32
+ healthy: '配置健康',
33
+ unhealthy: (n) => `${n} 项待处理`,
34
+ loading: '正在读取双轨配置、模型提供商、密钥状态与快照…',
33
35
  retry: '重试',
34
- checkedAt: (t) => `最近体检 ${t}`,
36
+ checkedAt: (t) => `同步于 ${t}`,
37
+ openDesktopBtn: '打开桌面端',
38
+ launchingBtn: '正在拉起…',
35
39
  tabOverview: '总览',
40
+ tabPlugins: '插件',
36
41
  tabCreds: '凭据',
37
42
  tabSnapshots: '快照',
38
- kpiProfilesLabel: '双轨插件',
39
- kpiProfilesSub: 'Web / 桌面启用',
40
- kpiCredsLabel: '凭据就绪',
41
- kpiCredsSub: '非空环境键',
42
- kpiSnapsLabel: '变更快照',
43
- kpiSnapsSub: '桌面守护存档',
44
- supervisorTitleWinMissing: '安装 DSHGuard 桌面完整版',
45
- supervisorBadgeWin: 'Windows · 免管理员',
46
- supervisorDescWinMissing: '伴生插件仅负责 DSH 内只读体检;安装 Windows 桌面控制台可解锁以下日常高频能力:',
47
- feat1Title: '四协议模型配置与测速',
48
- feat1Sub: '自动补全 /v1 与 /v1beta',
49
- feat2Title: 'CC Switch 多源导密钥',
50
- feat2Sub: '文件拖入与跨端只读导入',
51
- feat3Title: '插件批量查新防串轨',
52
- feat3Sub: '万款市场插件安全升级',
53
- feat4Title: '进程外救援与快照回滚',
54
- feat4Sub: '启动崩溃时桌面一键还原',
55
- btnDownloadExe: '直接下载 Windows 安装包 (.exe)',
56
- btnViewRepo: '主页与动图预览',
57
- btnRedetect: '已安装?重新检测',
58
- supervisorTitleWinReady: 'DSHGuard 桌面控制台',
59
- supervisorBadgeReady: '桌面控制台已就绪',
60
- supervisorDescWinReady: '已对接本机桌面守护壳,支持四协议模型配置与测速、CC Switch 导入及快照回滚。',
61
- btnOpenGuard: '打开 DSHGuard 桌面控制台',
62
- btnOpeningGuard: '正在唤起…',
63
- supervisorTitleOther: '跨平台只读体检模式',
64
- supervisorDescOther: (plat) => `当前运行环境为 ${plat},伴生插件双轨体检、凭据脱敏对账与 /guard 命令已全部就绪;Windows 桌面完整版独立提供图形化模型配置、CC Switch 导入与进程外崩溃救援。`,
65
- btnViewReleases: '查看 Windows 版 Releases',
66
- profilesTitle: 'Web / 桌面双轨对账',
67
- webTrack: 'Web 引擎',
68
- desktopTrack: '桌面版',
69
- missingDir: '未检测到该端配置目录',
70
- bundlesLabel: '插件',
71
- depsLabel: '依赖',
72
- patchOk: (n) => (n > 0 ? `Patch 正常 · 禁 ${n} 项` : 'Patch 正常'),
73
- patchMissing: '未建 cordis.patch.yml',
74
- patchErr: (e) => `Patch 异常:${e}`,
75
- pkgErr: 'package.json 解析异常',
76
- missingInDeps: '清单缺依赖',
77
- unregisteredDeps: '未登记插件',
78
- issuesTitle: '诊断建议',
79
- issueActionOpen: '在桌面控制台一键排查修复',
80
- issueActionDownload: '下载桌面控制台辅助排查 (.exe)',
81
- credsTitle: '凭据脱敏就绪度',
82
- credsPrivacyHint: '严格零秘密原则:仅核对环境键是否非空,绝不读取、截断或传输真实密钥。',
83
- credReadyBadge: (ready, total) => `已就绪 ${ready} / ${total}`,
84
- credMissingFile: '未创建 .credentials.yaml',
85
- credProgressPatch: (ready, total) => `cordis.patch.yml 引用键就绪 ${ready} / ${total}`,
86
- credProgressFile: (nonEmpty, total) => `.credentials.yaml 非空键 ${nonEmpty} / ${total}`,
87
- credStatusReady: '已就绪',
88
- credStatusMissing: '未配置',
89
- credNoRefs: '当前双端 cordis.patch.yml 暂未引用任何 apiKeyEnv 环境变量。',
90
- credUpsellTitle: '需要图形化管理模型与密钥?',
91
- credUpsellDesc: '在 DSHGuard 桌面版「凭据中心」可直接点击卡片编辑 OpenAI / Anthropic / Gemini 接口、测试单模型连通性,或从 CC Switch 与本地 Agent 一键导入。',
92
- credUpsellOpen: '打开桌面端「凭据中心」',
93
- credUpsellDownload: '下载桌面完整版开启「凭据中心」(.exe)',
94
- snapshotsTitle: '变更前快照回望',
95
- snapshotsTotal: (t) => `共 ${t} 份`,
96
- snapshotsEmptyTitle: '暂无变更前快照存档',
97
- snapshotsEmptyDesc: '使用 DSHGuard 桌面控制台执行插件安装、升级或切换配置前,系统都会自动存档以供随时回滚。',
98
- snapItems: (n) => `${n} 项文件`,
99
- snapNoReason: '操作前自动快照',
100
- snapActionOpen: '在桌面端管理 / 回滚快照',
101
- snapActionDownload: '下载 Windows 桌面版开启自动快照 (.exe)',
102
- footerNote: `DSHGuard v${VERSION} · 严格零秘密只读伴生模式`,
103
- footerHome: 'GitHub 主页',
104
- errorRecover: '守护壳面板已触发渲染保护恢复',
105
- guideDesc: '双端配置体检 · 凭据键就绪状态 · 快照历史 · 联动 DSHGuard 桌面端',
43
+ kpiHealth: '配置健康',
44
+ kpiHealthOk: '一致',
45
+ kpiHealthWarn: (n) => `${n} 项`,
46
+ kpiExt: '插件 / MCP',
47
+ kpiCreds: '密钥 / 提供商',
48
+ kpiSnaps: '配置快照',
49
+ secProfiles: '双轨运行档案',
50
+ webTrack: 'Web 端',
51
+ desktopTrack: '桌面端',
52
+ present: '已就绪',
53
+ absent: '未初始化',
54
+ depsLabel: '总依赖',
55
+ thirdPartyLabel: '第三方',
56
+ mcpLabel: 'MCP 服务',
57
+ disabledLabel: '已禁用',
58
+ brokenLabel: '断链数',
59
+ repairLinksBtn: '一键修复断链',
60
+ repairingBtn: '修复中…',
61
+ allHealthyTitle: 'Web 与桌面端档案健康且无断裂软链接',
62
+ allHealthySub: '当前插件依赖、MCP 补丁与双轨配置均已对齐,可在上方切换标签管理插件开关、单向写入密钥或创建本地快照。',
63
+ quickSnapWeb: '备份 Web 配置',
64
+ quickGoPlugins: '管理插件开关',
65
+ warningsTitle: '巡检提示',
66
+ searchPlaceholder: '搜索插件包名、loader ID 或 MCP 服务名…',
67
+ mcpSectionTitle: 'MCP 服务开关',
68
+ mcpEmpty: '当前档案尚未配置 MCP 服务。',
69
+ pluginsSectionTitle: '已安装插件',
70
+ pluginsEmpty: '未匹配到插件条目。',
71
+ badgeCore: '核心保护',
72
+ badgeSelf: '当前伴生',
73
+ badgeEnabled: '已启用',
74
+ badgeDisabled: '已禁用',
75
+ badgeAllCount: (shown, total) => `${shown} / ${total}`,
76
+ boundaryPluginsSummary: '能力边界说明:为什么插件全新安装/卸载与强杀锁死进程不在此完成?',
77
+ boundaryPluginsP1: '本插件运行于当前 DSH Node 宿主进程内部:在运行时热删除或重装 node_modules 可能导致已加载模块撕裂锁死;同时为遵循插件最小权限安全红线,本插件不会从远端拉取二进制安装包或托管宿主进程生命周期。',
78
+ boundaryPluginsP2: '在伴生插件内,你可直接安全启停第三方插件与 MCP 服务(每次改动均会自动备份),并一键修复断裂依赖链接;完整增删插件、校验压缩包安装及进程外强启停由独立原生桌面端承担。',
79
+ boundaryCredsSummary: '能力边界说明:为什么不在此回显/导出明文密钥或提供 Windows DPAPI 加密库?',
80
+ boundaryCredsP1: '安全合规要求持有前端请求能力的插件不得反向读取并回显真实 API 密钥。本插件采用「只核验键名 + 单向覆盖写入 .credentials.yaml」机制,所有明文仅从输入框单向落盘(0o600),响应报文绝不返回密钥字符。',
81
+ boundaryCredsP2: '硬件绑定的 Windows DPAPI 凭据保险箱加密以及跨 CC Switch 等工具链批量迁移属于系统原生能力,仅独立的 Windows 原生桌面端具备。',
82
+ boundarySnapsSummary: '能力边界说明:为什么配置快照仅恢复 YAML/JSON 配对文件而不覆盖整包扩展?',
83
+ boundarySnapsP1: '伴生插件可在不干扰宿主运行的前提下,安全完成 cordis.patch.yml、cordis.yml、package.json 与 settings.yaml 的实时 SHA256 比对、备份与白名单一键回滚(自动排除 .credentials.yaml)。',
84
+ boundarySnapsP2: '涵盖 node_modules 整包 ZIP 回溯与主程序崩溃后的带外拉起恢复必须脱离宿主进程执行,仅在独立原生桌面端提供。',
85
+ desktopWinLink: `下载 Windows 原生桌面端 v${VERSION} ↗`,
86
+ desktopReleaseLink: '查看 GitHub Releases ↗',
87
+ desktopNonWinNote: '注:原生桌面端目前仅提供 Windows 安装包;当前平台的启停开关、单向写密钥与配置回滚已全部内置于伴生插件。',
88
+ providersTitle: '模型提供商 (llm-pi-ai)',
89
+ providersEmpty: '尚未在 cordis.patch.yml 中发现 llm-pi-ai 提供商配置。',
90
+ modelsUnit: '个模型',
91
+ keyReady: '密钥就绪',
92
+ keyMissing: '缺密钥',
93
+ setKeyBtn: '设置密钥',
94
+ updateKeyBtn: '更新密钥',
95
+ cancelBtn: '取消',
96
+ keyPlaceholder: '输入 API Key(单向盲写,保存后立即清空,绝不回显)',
97
+ writeKeyBtn: '写入 .credentials.yaml',
98
+ writingKeyBtn: '写入中…',
99
+ addKeyToggle: '+ 新增自定义环境变量密钥',
100
+ envNameLabel: '环境变量名 (如 DEEPSEEK_API_KEY)',
101
+ credsAuditTitle: '.credentials.yaml 键名状态审计',
102
+ credsAuditSub: '仅展示键名是否存在及保护标记(绝不读取或传输密钥字符)。',
103
+ credProtected: '受保护 OAuth',
104
+ credPresent: '已写入',
105
+ credEnvOnly: '仅环境变量',
106
+ credsEmpty: '当前尚未创建 .credentials.yaml 或 refs 下尚无键值。',
107
+ snapCreateWeb: '+ 备份 Web 配置',
108
+ snapCreateDesktop: '+ 备份桌面端配置',
109
+ snapCreating: '备份中…',
110
+ snapSourcePlugin: '插件快照',
111
+ snapSourceDesktop: '桌面端快照',
112
+ snapSame: '与磁盘一致',
113
+ snapDiff: (n) => `${n} 处已变更`,
114
+ snapFilesToggle: (n) => `查看 ${n} 个文件比对明细`,
115
+ snapRestoreBtn: '恢复此配置快照',
116
+ snapRestoring: '恢复中…',
117
+ snapNoFiles: '该快照暂无可比对配置文件',
118
+ snapDesktopOnlyTip: '桌面端全量包产物需在桌面端还原',
119
+ fileSame: '一致',
120
+ fileModified: '与现行配置不同',
121
+ fileMissing: '磁盘已删除',
122
+ fileUnknown: '仅记录',
123
+ snapshotsEmpty: '暂无本地配置快照',
124
+ snapshotsEmptyDesc: '点击上方备份按钮,或在修改插件开关时自动留存一份配置档案。',
125
+ footerNote: `@gluztm/dsh-guard v${VERSION}`,
126
+ footerHome: 'GitHub',
106
127
  },
107
128
  en: {
108
- brand: 'DSHGuard',
109
- subtitle: 'Dual-Track Health · Masked Keys · Snapshots',
129
+ brand: 'DSH Companion',
130
+ subtitle: 'Plugins · Blind-Write Creds · Snapshots',
131
+ guideDesc: 'Manage plugins & MCP toggles, repair broken links, blind-write .credentials.yaml refs, and restore YAML config snapshots.',
110
132
  versionPill: `v${VERSION}`,
111
133
  refresh: 'Refresh',
112
- refreshing: 'Checking',
113
- langSwitch: '中',
114
- healthy: 'Dual-Track Healthy',
115
- unhealthy: (n) => `${n} Issue${n === 1 ? '' : 's'} Found`,
116
- loading: 'Inspecting DSH profiles, credential readiness, and snapshots…',
134
+ refreshing: 'Syncing',
135
+ langSwitch: '中文',
136
+ healthy: 'Healthy',
137
+ unhealthy: (n) => `${n} item${n > 1 ? 's' : ''}`,
138
+ loading: 'Loading profiles, providers, credential keys, and snapshots…',
117
139
  retry: 'Retry',
118
- checkedAt: (t) => `Checked ${t}`,
140
+ checkedAt: (t) => `Synced ${t}`,
141
+ openDesktopBtn: 'Open Desktop',
142
+ launchingBtn: 'Launching…',
119
143
  tabOverview: 'Overview',
144
+ tabPlugins: 'Plugins',
120
145
  tabCreds: 'Credentials',
121
146
  tabSnapshots: 'Snapshots',
122
- kpiProfilesLabel: 'Bundles',
123
- kpiProfilesSub: 'Web / Desktop',
124
- kpiCredsLabel: 'Key Slots',
125
- kpiCredsSub: 'Non-empty env',
126
- kpiSnapsLabel: 'Snapshots',
127
- kpiSnapsSub: 'Guard backups',
128
- supervisorTitleWinMissing: 'Install DSHGuard Desktop Console',
129
- supervisorBadgeWin: 'Windows · Non-Admin',
130
- supervisorDescWinMissing: 'This companion plugin stays strictly read-only. Install the Windows desktop app to unlock:',
131
- feat1Title: '4-Protocol Model Setup & Ping',
132
- feat1Sub: 'Auto /v1 & /v1beta endpoints',
133
- feat2Title: 'CC Switch & Multi-Source Import',
134
- feat2Sub: 'Drop configs or read local agents',
135
- feat3Title: 'Safe Batch Plugin Updates',
136
- feat3Sub: '10,700+ catalog, zero cross-track',
137
- feat4Title: 'Out-of-Band Recovery & Rollback',
138
- feat4Sub: 'Restore broken startups externally',
139
- btnDownloadExe: 'Direct Download Windows Installer (.exe)',
140
- btnViewRepo: 'Homepage & Visual Tour',
141
- btnRedetect: 'Installed? Re-detect',
142
- supervisorTitleWinReady: 'DSHGuard Desktop Console',
143
- supervisorBadgeReady: 'Desktop Console Ready',
144
- supervisorDescWinReady: 'Connected to your local DSHGuard executable for visual model configuration, CC Switch import, and snapshot rollback.',
145
- btnOpenGuard: 'Open DSHGuard Desktop Console',
146
- btnOpeningGuard: 'Launching…',
147
- supervisorTitleOther: 'Cross-Platform Read-Only Mode',
148
- supervisorDescOther: (plat) => `Running on ${plat} with full dual-track auditing, masked key checks, and /guard commands. Full out-of-band GUI tools run on Windows.`,
149
- btnViewReleases: 'View Windows Releases',
150
- profilesTitle: 'Web / Desktop Profile Alignment',
151
- webTrack: 'Web Engine',
152
- desktopTrack: 'Desktop',
153
- missingDir: 'Profile directory not found',
154
- bundlesLabel: 'Enabled',
147
+ kpiHealth: 'Health',
148
+ kpiHealthOk: 'Synced',
149
+ kpiHealthWarn: (n) => `${n} alert`,
150
+ kpiExt: 'Plugins / MCP',
151
+ kpiCreds: 'Keys / Providers',
152
+ kpiSnaps: 'Snapshots',
153
+ secProfiles: 'Profile Tracks',
154
+ webTrack: 'Web Profile',
155
+ desktopTrack: 'Desktop Profile',
156
+ present: 'Ready',
157
+ absent: 'Absent',
155
158
  depsLabel: 'Deps',
156
- patchOk: (n) => (n > 0 ? `Patch OK · ${n} disabled` : 'Patch OK'),
157
- patchMissing: 'No cordis.patch.yml',
158
- patchErr: (e) => `Patch error: ${e}`,
159
- pkgErr: 'Invalid package.json',
160
- missingInDeps: 'Missing in deps',
161
- unregisteredDeps: 'Unregistered deps',
162
- issuesTitle: 'Diagnostics',
163
- issueActionOpen: 'Troubleshoot in DSHGuard Desktop',
164
- issueActionDownload: 'Download Windows Supervisor (.exe)',
165
- credsTitle: 'Masked Credential Readiness',
166
- credsPrivacyHint: 'Zero-secret guarantee: checks only whether key names are non-empty, never reading or transmitting secret values.',
167
- credReadyBadge: (ready, total) => `${ready} / ${total} Ready`,
168
- credMissingFile: '.credentials.yaml not found',
169
- credProgressPatch: (ready, total) => `Referenced apiKeyEnv keys ready: ${ready} / ${total}`,
170
- credProgressFile: (nonEmpty, total) => `Non-empty entries in .credentials.yaml: ${nonEmpty} / ${total}`,
171
- credStatusReady: 'Ready',
172
- credStatusMissing: 'Missing',
173
- credNoRefs: 'No apiKeyEnv references detected in either cordis.patch.yml.',
174
- credUpsellTitle: 'Configure models & keys visually',
175
- credUpsellDesc: 'Use the desktop Credential Hub to edit OpenAI / Anthropic / Gemini endpoints, test model connectivity, or import non-subscription keys from CC Switch.',
176
- credUpsellOpen: 'Open Credential Hub in Desktop',
177
- credUpsellDownload: 'Download Desktop Console for Credential Hub (.exe)',
178
- snapshotsTitle: 'Pre-Change Snapshot Timeline',
179
- snapshotsTotal: (t) => `${t} total`,
180
- snapshotsEmptyTitle: 'No pre-change snapshots yet',
181
- snapshotsEmptyDesc: 'DSHGuard automatically saves config and plugin snapshots before any risky change on Windows so you can roll back cleanly.',
182
- snapItems: (n) => `${n} files`,
183
- snapNoReason: 'Automatic checkpoint',
184
- snapActionOpen: 'Manage / Roll back in Desktop',
185
- snapActionDownload: 'Download Windows App for Auto-Snapshots (.exe)',
186
- footerNote: `DSHGuard v${VERSION} · Strictly Read-Only Companion`,
159
+ thirdPartyLabel: '3rd-party',
160
+ mcpLabel: 'MCP',
161
+ disabledLabel: 'Disabled',
162
+ brokenLabel: 'Broken Links',
163
+ repairLinksBtn: 'Repair Broken Links',
164
+ repairingBtn: 'Repairing…',
165
+ allHealthyTitle: 'Web & Desktop configs are healthy with no broken links',
166
+ allHealthySub: 'Dependencies, MCP entries, and Cordis patches look clean. Switch tabs above to toggle extensions, set API keys one-way, or manage snapshots.',
167
+ quickSnapWeb: 'Backup Web Config',
168
+ quickGoPlugins: 'Manage Plugins',
169
+ warningsTitle: 'Diagnostics',
170
+ searchPlaceholder: 'Filter package name, loader ID, or MCP server…',
171
+ mcpSectionTitle: 'MCP Servers',
172
+ mcpEmpty: 'No MCP entries configured in this profile.',
173
+ pluginsSectionTitle: 'Installed Plugins',
174
+ pluginsEmpty: 'No matching plugins.',
175
+ badgeCore: 'Core',
176
+ badgeSelf: 'Self',
177
+ badgeEnabled: 'On',
178
+ badgeDisabled: 'Off',
179
+ badgeAllCount: (shown, total) => `${shown} / ${total}`,
180
+ boundaryPluginsSummary: 'Capability boundary: why fresh package install & force process control live outside this plugin',
181
+ boundaryPluginsP1: 'This plugin shares the live DSH Node process: mutating node_modules via npm install at runtime can lock or tear active modules, and companion plugins intentionally lack remote binary execution and host watchdog rights.',
182
+ boundaryPluginsP2: 'Safe plugin & MCP toggling (with automatic pre-change snapshots) and broken symlink repair work right here; full install/uninstall lifecycle and process supervision belong to the native desktop supervisor.',
183
+ boundaryCredsSummary: 'Security boundary: why plaintext key readback & Windows DPAPI vault live outside this plugin',
184
+ boundaryCredsP1: 'By security policy, Web UI plugins must never reverse-read and display plaintext secrets. This tab enforces strict one-way blind-write directly into .credentials.yaml refs: while showing only key presence.',
185
+ boundaryCredsP2: 'Hardware-backed Windows DPAPI encryption vaults and CC Switch cross-tool migrations rely on native Windows security APIs unavailable inside a cross-platform DSH plugin.',
186
+ boundarySnapsSummary: 'Runtime boundary: why snapshots restore YAML/JSON configs rather than full node_modules bundles',
187
+ boundarySnapsP1: 'Within the running DSH process, this tab safely computes live SHA256 diffs, creates snapshots, and performs whitelist rollback of cordis.patch.yml, cordis.yml, package.json, and settings.yaml (excluding secrets).',
188
+ boundarySnapsP2: 'Full extension bundle ZIP replacement and out-of-band crash recovery require shutting down or restarting the DSH process from an external native binary.',
189
+ desktopWinLink: `Download Windows Desktop v${VERSION} ↗`,
190
+ desktopReleaseLink: 'GitHub Releases ↗',
191
+ desktopNonWinNote: 'Note: The native desktop shell is Windows-only; in-plugin toggling, blind-write credentials, and config rollback work natively on this OS.',
192
+ providersTitle: 'Model Providers (llm-pi-ai)',
193
+ providersEmpty: 'No llm-pi-ai provider entries found in cordis.patch.yml.',
194
+ modelsUnit: 'models',
195
+ keyReady: 'Key Ready',
196
+ keyMissing: 'Missing Key',
197
+ setKeyBtn: 'Set Key',
198
+ updateKeyBtn: 'Update Key',
199
+ cancelBtn: 'Cancel',
200
+ keyPlaceholder: 'Paste API key (one-way write only; cleared & never echoed)',
201
+ writeKeyBtn: 'Save to .credentials.yaml',
202
+ writingKeyBtn: 'Saving…',
203
+ addKeyToggle: '+ Add custom env ref key',
204
+ envNameLabel: 'Env Var Name (e.g. DEEPSEEK_API_KEY)',
205
+ credsAuditTitle: '.credentials.yaml Key Presence Audit',
206
+ credsAuditSub: 'Verifies key readiness and protected OAuth flags without reading secret values.',
207
+ credProtected: 'Protected OAuth',
208
+ credPresent: 'Configured',
209
+ credEnvOnly: 'Env Only',
210
+ credsEmpty: 'No .credentials.yaml entries found yet.',
211
+ snapCreateWeb: '+ Backup Web Config',
212
+ snapCreateDesktop: '+ Backup Desktop Config',
213
+ snapCreating: 'Backing up…',
214
+ snapSourcePlugin: 'Plugin',
215
+ snapSourceDesktop: 'Desktop',
216
+ snapSame: 'Matches Disk',
217
+ snapDiff: (n) => `${n} modified`,
218
+ snapFilesToggle: (n) => `Inspect ${n} file diff(s)`,
219
+ snapRestoreBtn: 'Restore Config Files',
220
+ snapRestoring: 'Restoring…',
221
+ snapNoFiles: 'No comparable config files in this snapshot',
222
+ snapDesktopOnlyTip: 'Desktop binary archives require the native desktop app',
223
+ fileSame: 'Same',
224
+ fileModified: 'Changed on disk',
225
+ fileMissing: 'Deleted on disk',
226
+ fileUnknown: 'Recorded',
227
+ snapshotsEmpty: 'No configuration snapshots yet',
228
+ snapshotsEmptyDesc: 'Create a manual backup above or toggle a plugin to automatically preserve a snapshot.',
229
+ footerNote: `@gluztm/dsh-guard v${VERSION}`,
187
230
  footerHome: 'GitHub',
188
- errorRecover: 'Panel recovered by ErrorBoundary',
189
- guideDesc: 'Dual-track health · Masked key readiness · Snapshots · DSHGuard Desktop bridge',
190
231
  },
191
232
  }
192
233
 
193
234
  const CSS = `
194
- @keyframes dshg-spin {
195
- from { transform: rotate(0deg); }
196
- to { transform: rotate(360deg); }
197
- }
198
- @keyframes dshg-pulse {
199
- 0%, 100% { opacity: 1; }
200
- 50% { opacity: 0.45; }
201
- }
202
- .dshg-root {
203
- --dshg-card: var(--dsw-alias-card-fill, var(--dsw-alias-bg-layer-1, rgba(128, 128, 140, 0.08)));
204
- --dshg-card-hover: var(--dsw-alias-card-fill-hover, var(--dsw-alias-bg-layer-2, rgba(128, 128, 140, 0.14)));
205
- --dshg-fill: var(--dsw-alias-fill-l1, rgba(128, 128, 140, 0.11));
206
- --dshg-fill-subtle: var(--dsw-alias-bg-layer-2, rgba(128, 128, 140, 0.06));
207
- --dshg-border: var(--dsw-alias-border-l1, rgba(128, 128, 140, 0.18));
208
- --dshg-border-strong: var(--dsw-alias-border-l2, rgba(128, 128, 140, 0.30));
209
- --dshg-text: var(--dsw-alias-label-primary, inherit);
210
- --dshg-text-2: var(--dsw-alias-label-secondary, rgba(128, 128, 140, 0.88));
211
- --dshg-text-3: var(--dsw-alias-label-tertiary, rgba(128, 128, 140, 0.64));
212
- --dshg-accent: var(--dsw-alias-brand-primary, #2563eb);
213
- --dshg-accent-soft: rgba(37, 99, 235, 0.10);
214
- --dshg-accent-border: rgba(59, 130, 246, 0.34);
215
- --dshg-ok: #16a34a;
216
- --dshg-ok-soft: rgba(34, 197, 94, 0.12);
217
- --dshg-ok-border: rgba(34, 197, 94, 0.32);
218
- --dshg-warn: #d97706;
235
+ @keyframes dshg-spin { to { transform: rotate(360deg); } }
236
+ @keyframes dshg-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
237
+
238
+ .dshg-wrap {
239
+ --dshg-bg: var(--dsw-alias-bg-container, transparent);
240
+ --dshg-card: var(--dsw-alias-card-fill, var(--dsw-alias-bg-elevated, rgba(127, 127, 127, 0.06)));
241
+ --dshg-card-hover: var(--dsw-alias-card-fill-hover, var(--dsw-alias-fill-secondary, rgba(127, 127, 127, 0.1)));
242
+ --dshg-fill: var(--dsw-alias-fill-l1, var(--dsw-alias-fill-tertiary, rgba(127, 127, 127, 0.12)));
243
+ --dshg-fill-subtle: var(--dsw-alias-bg-layer-2, var(--dsw-alias-fill-quaternary, rgba(127, 127, 127, 0.04)));
244
+ --dshg-border: var(--dsw-alias-border-l1, var(--dsw-alias-border-secondary, rgba(127, 127, 127, 0.18)));
245
+ --dshg-border-strong: var(--dsw-alias-border-l2, var(--dsw-alias-border-primary, rgba(127, 127, 127, 0.32)));
246
+ --dshg-text: var(--dsw-alias-label-primary, var(--dsw-alias-text-primary, inherit));
247
+ --dshg-text-2: var(--dsw-alias-label-secondary, var(--dsw-alias-text-secondary, rgba(127, 127, 127, 0.92)));
248
+ --dshg-text-3: var(--dsw-alias-label-tertiary, var(--dsw-alias-text-tertiary, rgba(127, 127, 127, 0.7)));
249
+ --dshg-accent: var(--dsw-alias-brand-primary, var(--dsw-alias-color-primary, #2563eb));
250
+ --dshg-accent-soft: rgba(59, 130, 246, 0.11);
251
+ --dshg-accent-border: rgba(59, 130, 246, 0.28);
252
+ --dshg-ok-soft: rgba(16, 185, 129, 0.12);
253
+ --dshg-ok-border: rgba(16, 185, 129, 0.28);
219
254
  --dshg-warn-soft: rgba(245, 158, 11, 0.12);
220
- --dshg-warn-border: rgba(245, 158, 11, 0.34);
221
- background: transparent;
222
- color: var(--dshg-text);
223
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
255
+ --dshg-warn-border: rgba(245, 158, 11, 0.3);
224
256
  display: flex;
225
257
  flex-direction: column;
226
- gap: 10px;
227
- padding: 12px;
258
+ gap: 11px;
228
259
  height: 100%;
260
+ min-height: 0;
261
+ padding: 12px 14px 16px;
229
262
  box-sizing: border-box;
230
263
  overflow-y: auto;
231
- font-size: 12px;
264
+ background: var(--dshg-bg);
265
+ color: var(--dshg-text);
266
+ font-family: inherit;
267
+ font-size: 13px;
232
268
  line-height: 1.45;
233
269
  }
234
- .dshg-root[data-variant="main"] {
235
- max-width: 780px;
270
+ .dshg-wrap[data-variant="main"] {
271
+ max-width: 960px;
236
272
  margin: 0 auto;
237
- padding: 20px 18px;
273
+ padding: 22px 26px 32px;
238
274
  }
239
- .dshg-card {
240
- border: 1px solid var(--dshg-border);
241
- background: var(--dshg-card);
242
- border-radius: 12px;
243
- padding: 11px 12px;
275
+ .dshg-tab-body {
244
276
  display: flex;
245
277
  flex-direction: column;
246
- gap: 9px;
247
- }
248
- .dshg-card-spotlight {
249
- border: 1px solid var(--dshg-accent-border);
250
- background: var(--dshg-accent-soft);
278
+ gap: 10px;
251
279
  }
252
280
  .dshg-header {
253
281
  display: flex;
254
282
  align-items: center;
255
283
  justify-content: space-between;
256
- gap: 8px;
284
+ gap: 10px;
285
+ flex-wrap: wrap;
257
286
  }
258
287
  .dshg-brand {
259
288
  display: flex;
@@ -261,62 +290,69 @@ window.__ModuleLoader__.load({
261
290
  gap: 9px;
262
291
  min-width: 0;
263
292
  }
264
- .dshg-logo-wrap {
265
- width: 34px;
266
- height: 34px;
293
+ .dshg-logo {
294
+ width: 30px;
295
+ height: 30px;
267
296
  border-radius: 9px;
268
- display: inline-flex;
297
+ display: flex;
269
298
  align-items: center;
270
299
  justify-content: center;
271
- background: var(--dshg-accent-soft);
272
- border: 1px solid var(--dshg-accent-border);
273
- color: var(--dshg-accent);
300
+ background: linear-gradient(135deg, var(--dshg-accent), #6366f1);
301
+ color: #ffffff;
274
302
  flex-shrink: 0;
303
+ box-shadow: 0 2px 7px rgba(59, 130, 246, 0.24);
304
+ }
305
+ .dshg-title-box {
306
+ display: flex;
307
+ flex-direction: column;
308
+ min-width: 0;
275
309
  }
276
310
  .dshg-title-row {
277
311
  display: flex;
278
312
  align-items: center;
279
313
  gap: 6px;
280
- flex-wrap: wrap;
281
314
  }
282
315
  .dshg-title {
283
- font-size: 13.5px;
284
- font-weight: 600;
285
- line-height: 1.2;
316
+ font-size: 14px;
317
+ font-weight: 650;
286
318
  letter-spacing: -0.01em;
319
+ white-space: nowrap;
287
320
  }
288
321
  .dshg-ver {
289
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
290
- font-size: 11px;
322
+ font-size: 10.5px;
291
323
  font-weight: 500;
292
324
  padding: 1px 6px;
293
325
  border-radius: 99px;
294
- border: 1px solid var(--dshg-border);
295
326
  background: var(--dshg-fill);
296
327
  color: var(--dshg-text-2);
328
+ border: 1px solid var(--dshg-border);
297
329
  }
298
330
  .dshg-sub {
299
331
  font-size: 11px;
300
- color: var(--dshg-text-2);
301
- margin-top: 2px;
332
+ color: var(--dshg-text-3);
333
+ white-space: nowrap;
334
+ overflow: hidden;
335
+ text-overflow: ellipsis;
302
336
  }
303
337
  .dshg-actions {
304
338
  display: flex;
305
339
  align-items: center;
306
- gap: 5px;
340
+ gap: 6px;
307
341
  flex-shrink: 0;
308
342
  }
309
343
  .dshg-btn {
344
+ appearance: none;
310
345
  display: inline-flex;
311
346
  align-items: center;
312
347
  justify-content: center;
313
- gap: 6px;
348
+ gap: 5px;
314
349
  height: 28px;
315
350
  padding: 0 10px;
316
351
  border-radius: 8px;
317
352
  border: 1px solid var(--dshg-border);
318
353
  background: var(--dshg-card);
319
354
  color: var(--dshg-text);
355
+ font-family: inherit;
320
356
  font-size: 11.5px;
321
357
  font-weight: 500;
322
358
  cursor: pointer;
@@ -330,7 +366,7 @@ window.__ModuleLoader__.load({
330
366
  border-color: var(--dshg-border-strong);
331
367
  }
332
368
  .dshg-btn:disabled {
333
- opacity: 0.58;
369
+ opacity: 0.52;
334
370
  cursor: default;
335
371
  }
336
372
  .dshg-btn-icon {
@@ -341,27 +377,18 @@ window.__ModuleLoader__.load({
341
377
  background: var(--dshg-accent);
342
378
  border-color: transparent;
343
379
  color: #ffffff;
344
- height: 34px;
345
- padding: 0 14px;
346
- font-size: 12.5px;
347
380
  font-weight: 600;
348
- width: 100%;
349
- border-radius: 9px;
350
381
  }
351
382
  .dshg-btn-primary:hover:not(:disabled) {
352
383
  background: var(--dshg-accent);
353
384
  border-color: transparent;
354
385
  opacity: 0.92;
355
386
  }
356
- .dshg-btn-row {
357
- display: grid;
358
- grid-template-columns: repeat(2, minmax(0, 1fr));
359
- gap: 6px;
360
- }
361
- .dshg-btn-row .dshg-btn {
362
- width: 100%;
387
+ .dshg-btn-sm {
388
+ height: 24px;
363
389
  padding: 0 8px;
364
390
  font-size: 11px;
391
+ border-radius: 6px;
365
392
  }
366
393
  .dshg-spin {
367
394
  animation: dshg-spin 0.9s linear infinite;
@@ -406,20 +433,23 @@ window.__ModuleLoader__.load({
406
433
  }
407
434
  .dshg-kpi-strip {
408
435
  display: grid;
409
- grid-template-columns: repeat(3, minmax(0, 1fr));
436
+ grid-template-columns: repeat(2, minmax(0, 1fr));
410
437
  gap: 6px;
411
438
  }
439
+ .dshg-wrap[data-variant="main"] .dshg-kpi-strip {
440
+ grid-template-columns: repeat(4, minmax(0, 1fr));
441
+ }
412
442
  .dshg-kpi {
413
443
  border: 1px solid var(--dshg-border);
414
444
  background: var(--dshg-card);
415
445
  border-radius: 10px;
416
- padding: 8px 9px;
446
+ padding: 8px 10px;
417
447
  display: flex;
418
448
  flex-direction: column;
419
449
  gap: 2px;
420
450
  text-align: left;
421
451
  cursor: pointer;
422
- color: var(--dshg-text);
452
+ color: inherit;
423
453
  transition: border-color 0.15s ease, background 0.15s ease;
424
454
  }
425
455
  .dshg-kpi:hover {
@@ -432,59 +462,61 @@ window.__ModuleLoader__.load({
432
462
  }
433
463
  .dshg-kpi-label {
434
464
  font-size: 11px;
435
- color: var(--dshg-text-2);
465
+ color: var(--dshg-text-3);
436
466
  }
437
467
  .dshg-kpi-val {
438
- font-size: 14px;
439
- font-weight: 600;
440
- font-variant-numeric: tabular-nums;
441
- line-height: 1.25;
442
- }
443
- .dshg-kpi-sub {
444
- font-size: 11px;
445
- color: var(--dshg-text-3);
446
- white-space: nowrap;
447
- overflow: hidden;
448
- text-overflow: ellipsis;
468
+ font-size: 14.5px;
469
+ font-weight: 650;
470
+ letter-spacing: -0.02em;
449
471
  }
450
472
  .dshg-seg {
451
473
  display: grid;
452
- grid-template-columns: repeat(3, minmax(0, 1fr));
453
- gap: 4px;
474
+ grid-template-columns: repeat(4, minmax(0, 1fr));
475
+ gap: 3px;
454
476
  padding: 3px;
455
477
  border-radius: 10px;
478
+ background: var(--dshg-fill-subtle);
456
479
  border: 1px solid var(--dshg-border);
480
+ }
481
+ .dshg-seg-2 {
482
+ display: inline-grid;
483
+ grid-template-columns: repeat(2, minmax(0, 1fr));
484
+ gap: 3px;
485
+ padding: 2px;
486
+ border-radius: 8px;
457
487
  background: var(--dshg-fill-subtle);
488
+ border: 1px solid var(--dshg-border);
458
489
  }
459
490
  .dshg-seg-btn {
460
- height: 27px;
461
- border: 1px solid transparent;
462
- border-radius: 7px;
491
+ appearance: none;
492
+ border: none;
463
493
  background: transparent;
464
494
  color: var(--dshg-text-2);
495
+ font-family: inherit;
465
496
  font-size: 11.5px;
466
497
  font-weight: 500;
498
+ padding: 5px 4px;
499
+ border-radius: 7px;
467
500
  cursor: pointer;
468
501
  display: inline-flex;
469
502
  align-items: center;
470
503
  justify-content: center;
471
- gap: 5px;
472
- transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
473
- }
474
- .dshg-seg-btn:hover {
475
- color: var(--dshg-text);
504
+ gap: 4px;
505
+ transition: background 0.15s ease, color 0.15s ease;
476
506
  }
477
507
  .dshg-seg-btn[data-active="true"] {
478
- background: var(--dshg-card);
479
- border-color: var(--dshg-border);
508
+ background: var(--dshg-card-hover);
480
509
  color: var(--dshg-text);
481
510
  font-weight: 600;
482
511
  }
483
- .dshg-seg-dot {
484
- width: 5px;
485
- height: 5px;
486
- border-radius: 50%;
487
- background: #f59e0b;
512
+ .dshg-card {
513
+ border: 1px solid var(--dshg-border);
514
+ background: var(--dshg-card);
515
+ border-radius: 11px;
516
+ padding: 11px 12px;
517
+ display: flex;
518
+ flex-direction: column;
519
+ gap: 9px;
488
520
  }
489
521
  .dshg-sec-head {
490
522
  display: flex;
@@ -500,39 +532,9 @@ window.__ModuleLoader__.load({
500
532
  color: var(--dshg-text-2);
501
533
  line-height: 1.45;
502
534
  }
503
- .dshg-feat-grid {
504
- display: grid;
505
- grid-template-columns: repeat(2, minmax(0, 1fr));
506
- gap: 6px;
507
- }
508
- .dshg-feat-item {
509
- border: 1px solid var(--dshg-border);
510
- background: var(--dshg-card);
511
- border-radius: 9px;
512
- padding: 8px 9px;
513
- display: flex;
514
- align-items: flex-start;
515
- gap: 7px;
516
- }
517
- .dshg-feat-ico {
518
- color: var(--dshg-accent);
519
- flex-shrink: 0;
520
- margin-top: 1px;
521
- }
522
- .dshg-feat-t {
523
- font-size: 11.5px;
524
- font-weight: 600;
525
- line-height: 1.25;
526
- }
527
- .dshg-feat-s {
528
- font-size: 11px;
529
- color: var(--dshg-text-2);
530
- margin-top: 2px;
531
- line-height: 1.3;
532
- }
533
535
  .dshg-profile-grid {
534
536
  display: grid;
535
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
537
+ grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
536
538
  gap: 7px;
537
539
  }
538
540
  .dshg-subcard {
@@ -541,7 +543,7 @@ window.__ModuleLoader__.load({
541
543
  padding: 9px 10px;
542
544
  display: flex;
543
545
  flex-direction: column;
544
- gap: 6px;
546
+ gap: 5px;
545
547
  background: var(--dshg-fill-subtle);
546
548
  }
547
549
  .dshg-row {
@@ -551,95 +553,199 @@ window.__ModuleLoader__.load({
551
553
  gap: 6px;
552
554
  font-size: 11.5px;
553
555
  }
554
- .dshg-pills {
556
+ .dshg-toolbar {
555
557
  display: flex;
558
+ align-items: center;
559
+ justify-content: space-between;
560
+ gap: 8px;
556
561
  flex-wrap: wrap;
557
- gap: 5px;
558
562
  }
559
- .dshg-pill {
560
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
561
- font-size: 11px;
562
- padding: 2px 7px;
563
- border-radius: 6px;
564
- border: 1px solid var(--dshg-border);
565
- background: var(--dshg-fill);
566
- color: var(--dshg-text);
567
- word-break: break-all;
563
+ .dshg-search-wrap {
564
+ position: relative;
565
+ flex: 1 1 160px;
566
+ min-width: 140px;
568
567
  }
569
- .dshg-pill[data-tone="warn"] {
570
- background: var(--dshg-warn-soft);
571
- border-color: var(--dshg-warn-border);
572
- color: #f59e0b;
568
+ .dshg-search-ico {
569
+ position: absolute;
570
+ left: 9px;
571
+ top: 50%;
572
+ transform: translateY(-50%);
573
+ color: var(--dshg-text-3);
574
+ pointer-events: none;
573
575
  }
574
- .dshg-progress-wrap {
575
- display: flex;
576
- flex-direction: column;
577
- gap: 5px;
576
+ .dshg-input {
577
+ width: 100%;
578
+ height: 29px;
579
+ box-sizing: border-box;
580
+ border-radius: 8px;
581
+ border: 1px solid var(--dshg-border);
582
+ background: var(--dshg-fill-subtle);
583
+ color: var(--dshg-text);
584
+ font-family: inherit;
585
+ font-size: 11.5px;
586
+ padding: 0 9px;
587
+ outline: none;
588
+ transition: border-color 0.15s ease, background 0.15s ease;
578
589
  }
579
- .dshg-progress-track {
580
- height: 5px;
581
- border-radius: 99px;
582
- background: var(--dshg-fill);
583
- overflow: hidden;
590
+ .dshg-input.with-ico {
591
+ padding-left: 28px;
584
592
  }
585
- .dshg-progress-fill {
586
- height: 100%;
587
- border-radius: 99px;
588
- background: #22c55e;
589
- transition: width 0.25s ease;
593
+ .dshg-input:focus {
594
+ border-color: var(--dshg-accent);
595
+ background: var(--dshg-card);
590
596
  }
591
- .dshg-cred-list {
597
+ .dshg-list {
592
598
  display: flex;
593
599
  flex-direction: column;
594
600
  gap: 6px;
595
601
  }
596
- .dshg-cred-item {
602
+ .dshg-item {
597
603
  border: 1px solid var(--dshg-border);
598
604
  background: var(--dshg-fill-subtle);
599
605
  border-radius: 9px;
600
- padding: 7px 10px;
606
+ padding: 8px 10px;
607
+ display: flex;
608
+ flex-direction: column;
609
+ gap: 6px;
610
+ }
611
+ .dshg-item-row {
601
612
  display: flex;
602
613
  align-items: center;
603
614
  justify-content: space-between;
604
615
  gap: 8px;
605
616
  }
606
- .dshg-cred-key {
607
- display: inline-flex;
617
+ .dshg-item-main {
618
+ min-width: 0;
619
+ flex: 1;
620
+ display: flex;
621
+ flex-direction: column;
622
+ gap: 2px;
623
+ }
624
+ .dshg-item-title {
625
+ display: flex;
608
626
  align-items: center;
609
627
  gap: 6px;
628
+ flex-wrap: wrap;
629
+ font-size: 12px;
630
+ font-weight: 600;
631
+ word-break: break-word;
632
+ }
633
+ .dshg-mono {
610
634
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
611
- font-size: 11.5px;
612
- font-weight: 500;
613
- min-width: 0;
635
+ font-size: 11px;
614
636
  word-break: break-all;
637
+ color: var(--dshg-text-2);
638
+ }
639
+ .dshg-switch {
640
+ position: relative;
641
+ width: 34px;
642
+ height: 19px;
643
+ border-radius: 99px;
644
+ border: 1px solid var(--dshg-border-strong);
645
+ background: var(--dshg-fill);
646
+ cursor: pointer;
647
+ padding: 0;
648
+ flex-shrink: 0;
649
+ transition: background 0.16s ease, border-color 0.16s ease;
650
+ }
651
+ .dshg-switch[data-on="true"] {
652
+ background: #10b981;
653
+ border-color: #10b981;
654
+ }
655
+ .dshg-switch:disabled {
656
+ opacity: 0.45;
657
+ cursor: default;
658
+ }
659
+ .dshg-switch-thumb {
660
+ position: absolute;
661
+ top: 2px;
662
+ left: 2px;
663
+ width: 13px;
664
+ height: 13px;
665
+ border-radius: 50%;
666
+ background: #ffffff;
667
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
668
+ transition: transform 0.16s ease;
669
+ }
670
+ .dshg-switch[data-on="true"] .dshg-switch-thumb {
671
+ transform: translateX(15px);
615
672
  }
616
- .dshg-timeline {
673
+ .dshg-drawer {
674
+ border-top: 1px solid var(--dshg-border);
675
+ padding-top: 8px;
617
676
  display: flex;
618
677
  flex-direction: column;
619
- gap: 7px;
678
+ gap: 6px;
620
679
  }
621
- .dshg-snap-item {
622
- border: 1px solid var(--dshg-border);
623
- border-radius: 9px;
624
- padding: 8px 10px;
680
+ .dshg-drawer-row {
625
681
  display: flex;
626
- flex-direction: column;
682
+ gap: 6px;
683
+ align-items: center;
684
+ }
685
+ .dshg-pills {
686
+ display: flex;
687
+ flex-wrap: wrap;
627
688
  gap: 4px;
689
+ }
690
+ .dshg-pill {
691
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
692
+ font-size: 10.5px;
693
+ padding: 1.5px 6px;
694
+ border-radius: 5px;
695
+ border: 1px solid var(--dshg-border);
696
+ background: var(--dshg-fill);
697
+ color: var(--dshg-text-2);
698
+ word-break: break-all;
699
+ }
700
+ .dshg-boundary {
701
+ border: 1px solid var(--dshg-border);
702
+ border-radius: 10px;
628
703
  background: var(--dshg-fill-subtle);
704
+ overflow: hidden;
629
705
  }
630
- .dshg-snap-head {
706
+ .dshg-boundary > summary {
707
+ list-style: none;
708
+ cursor: pointer;
709
+ padding: 8px 11px;
710
+ font-size: 11px;
711
+ font-weight: 500;
712
+ color: var(--dshg-text-2);
631
713
  display: flex;
632
714
  align-items: center;
633
715
  justify-content: space-between;
634
- gap: 6px;
716
+ gap: 8px;
717
+ user-select: none;
635
718
  }
636
- .dshg-snap-title {
637
- display: inline-flex;
638
- align-items: center;
719
+ .dshg-boundary > summary::-webkit-details-marker {
720
+ display: none;
721
+ }
722
+ .dshg-boundary[open] > summary {
723
+ border-bottom: 1px solid var(--dshg-border);
724
+ color: var(--dshg-text);
725
+ }
726
+ .dshg-boundary-body {
727
+ padding: 9px 11px;
728
+ display: flex;
729
+ flex-direction: column;
639
730
  gap: 6px;
640
- font-size: 12px;
731
+ font-size: 11px;
732
+ line-height: 1.5;
733
+ color: var(--dshg-text-2);
734
+ }
735
+ .dshg-boundary-links {
736
+ display: flex;
737
+ flex-wrap: wrap;
738
+ gap: 8px;
739
+ margin-top: 2px;
740
+ }
741
+ .dshg-boundary-links a {
742
+ font-size: 11px;
743
+ color: var(--dshg-accent);
744
+ text-decoration: none;
641
745
  font-weight: 500;
642
- min-width: 0;
746
+ }
747
+ .dshg-boundary-links a:hover {
748
+ text-decoration: underline;
643
749
  }
644
750
  .dshg-track-dot {
645
751
  width: 7px;
@@ -647,31 +753,15 @@ window.__ModuleLoader__.load({
647
753
  border-radius: 50%;
648
754
  flex-shrink: 0;
649
755
  }
650
- .dshg-mono {
651
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
652
- font-size: 11px;
653
- word-break: break-all;
654
- color: var(--dshg-text-2);
655
- }
656
- .dshg-path-box {
657
- border: 1px solid var(--dshg-border);
658
- border-radius: 8px;
659
- background: var(--dshg-fill-subtle);
660
- padding: 6px 9px;
661
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
662
- font-size: 11px;
663
- color: var(--dshg-text-2);
664
- word-break: break-all;
665
- }
666
756
  .dshg-empty {
667
757
  border: 1px dashed var(--dshg-border-strong);
668
758
  border-radius: 10px;
669
- padding: 16px 12px;
759
+ padding: 15px 12px;
670
760
  display: flex;
671
761
  flex-direction: column;
672
762
  align-items: center;
673
763
  text-align: center;
674
- gap: 7px;
764
+ gap: 6px;
675
765
  color: var(--dshg-text-2);
676
766
  }
677
767
  .dshg-notice {
@@ -721,12 +811,20 @@ window.__ModuleLoader__.load({
721
811
  const store = {
722
812
  lang: 'zh',
723
813
  tab: 'overview',
814
+ pluginProfile: 'web',
815
+ search: '',
724
816
  loading: false,
725
- launching: false,
817
+ busyKey: '',
726
818
  error: '',
727
819
  notice: '',
728
820
  data: null,
729
821
  checkedAt: 0,
822
+ editProviderKey: '',
823
+ draftSecret: '',
824
+ showAddKey: false,
825
+ newKeyName: '',
826
+ newKeySecret: '',
827
+ expandedSnaps: {},
730
828
  }
731
829
 
732
830
  const listeners = new Set()
@@ -736,7 +834,7 @@ window.__ModuleLoader__.load({
736
834
  try {
737
835
  listener()
738
836
  } catch {
739
- // Ignore subscriber errors safely.
837
+ // Ignore unmounted subscriber errors cleanly.
740
838
  }
741
839
  }
742
840
  }
@@ -747,82 +845,69 @@ window.__ModuleLoader__.load({
747
845
  }
748
846
 
749
847
  function useStore() {
750
- const [, bump] = React.useState(0)
848
+ const [, setTick] = React.useState(0)
751
849
  React.useEffect(() => {
752
- const fn = () => bump((n) => n + 1)
753
- listeners.add(fn)
754
- return () => listeners.delete(fn)
850
+ const listener = () => setTick((v) => v + 1)
851
+ listeners.add(listener)
852
+ return () => listeners.delete(listener)
755
853
  }, [])
756
854
  return store
757
855
  }
758
856
 
759
- async function fetchOverview() {
760
- if (store.loading || typeof fetch !== 'function') return
857
+ async function fetchOverview(force = false) {
858
+ if (store.loading && !force) return
761
859
  patch({ loading: true, error: '' })
762
860
  try {
763
- const res = await fetch(`${API_BASE}/overview`, {
764
- cache: 'no-store',
765
- credentials: 'same-origin',
766
- headers: { accept: 'application/json' },
767
- })
861
+ const res = await fetch(`${API_BASE}/overview`, { credentials: 'same-origin' })
768
862
  const json = await res.json()
769
- if (!res.ok || !json || json.ok === false) {
863
+ if (!res.ok || !json || !json.ok) {
770
864
  throw new Error((json && json.error) || `HTTP ${res.status}`)
771
865
  }
772
866
  patch({
867
+ loading: false,
773
868
  data: json,
774
869
  checkedAt: json.checkedAt || Date.now(),
775
- error: '',
776
870
  })
777
871
  } catch (err) {
778
- patch({ error: err && err.message ? String(err.message) : 'Failed to inspect DSHGuard status' })
779
- } finally {
780
- patch({ loading: false })
872
+ patch({
873
+ loading: false,
874
+ error: err && err.message ? String(err.message) : 'Failed to load companion state',
875
+ })
781
876
  }
782
877
  }
783
878
 
784
- async function launchDesktopGuard() {
785
- if (store.launching || typeof fetch !== 'function') return
786
- patch({ launching: true, notice: '', error: '' })
879
+ async function postAction(endpoint, payload, busyId, successMsgBuilder) {
880
+ patch({ busyKey: busyId, error: '', notice: '' })
787
881
  try {
788
- const res = await fetch(`${API_BASE}/open`, {
882
+ const res = await fetch(`${API_BASE}${endpoint}`, {
789
883
  method: 'POST',
790
- cache: 'no-store',
791
884
  credentials: 'same-origin',
792
- headers: { accept: 'application/json' },
885
+ headers: { 'content-type': 'application/json' },
886
+ body: JSON.stringify(payload || {}),
793
887
  })
794
888
  const json = await res.json()
795
889
  if (!res.ok || !json || json.ok === false) {
796
- throw new Error((json && json.error) || `HTTP ${res.status}`)
890
+ throw new Error((json && (json.error || json.message)) || `HTTP ${res.status}`)
797
891
  }
798
- patch({ notice: json.message || 'DSHGuard action completed' })
892
+ const msg = typeof successMsgBuilder === 'function' ? successMsgBuilder(json) : ''
893
+ patch({ busyKey: '', notice: msg || '' })
894
+ await fetchOverview(true)
895
+ return json
799
896
  } catch (err) {
800
- patch({ error: err && err.message ? String(err.message) : 'Failed to launch DSHGuard' })
801
- } finally {
802
- patch({ launching: false })
897
+ patch({
898
+ busyKey: '',
899
+ error: err && err.message ? String(err.message) : 'Action failed',
900
+ })
901
+ return null
803
902
  }
804
903
  }
805
904
 
806
- function formatShortTime(value) {
807
- if (!value) return ''
808
- const d = new Date(value)
809
- if (Number.isNaN(d.getTime())) return String(value)
810
- const p = (n) => String(n).padStart(2, '0')
811
- return `${d.getMonth() + 1}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
812
- }
813
-
814
- function formatClockOnly(value) {
815
- if (!value) return ''
816
- const d = new Date(value)
817
- if (Number.isNaN(d.getTime())) return String(value)
818
- const p = (n) => String(n).padStart(2, '0')
819
- return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
905
+ async function launchGuardDesktop() {
906
+ await postAction('/open', {}, 'open-desktop', (json) => json.message || '')
820
907
  }
821
908
 
822
- /** Crisp Whale-Shield glyph rendered in currentColor for tabs & rail icons. */
823
- function GuardIcon(props) {
824
- const size = props && typeof props.size === 'number' && props.size > 0 ? props.size : 17
825
- const active = Boolean(props && props.active)
909
+ function SvgIcon(props) {
910
+ const size = props.size || 15
826
911
  return h(
827
912
  'svg',
828
913
  {
@@ -831,113 +916,79 @@ window.__ModuleLoader__.load({
831
916
  viewBox: '0 0 24 24',
832
917
  fill: 'none',
833
918
  stroke: 'currentColor',
834
- strokeWidth: active ? 2.1 : 1.75,
919
+ strokeWidth: 2,
835
920
  strokeLinecap: 'round',
836
921
  strokeLinejoin: 'round',
837
- 'aria-hidden': true,
838
- focusable: false,
839
- style: { display: 'block', flexShrink: 0 },
922
+ className: props.className || undefined,
923
+ 'aria-hidden': 'true',
840
924
  },
841
- h('path', { d: 'M12 2.8 4.8 5.8v5.7c0 4.6 3.1 8.3 7.2 9.7 4.1-1.4 7.2-5.1 7.2-9.7V5.8L12 2.8Z' }),
842
- h('path', { d: 'M8.5 13c.8-2 2.5-3 4.3-2.6 1.5.3 2.5 1.3 3.2 2.2.8-.6 1.4-1.3 1.7-2.2' }),
843
- h('circle', { cx: '11', cy: '12.6', r: '0.65', fill: 'currentColor' }),
925
+ props.children,
844
926
  )
845
927
  }
846
928
 
847
- /** Flat outline SVG icon set (zero emoji). */
848
- function SvgIcon({ name, size = 14, className = '' }) {
849
- const common = {
850
- width: size,
851
- height: size,
852
- viewBox: '0 0 24 24',
853
- fill: 'none',
854
- stroke: 'currentColor',
855
- strokeWidth: 1.85,
856
- strokeLinecap: 'round',
857
- strokeLinejoin: 'round',
858
- 'aria-hidden': true,
859
- focusable: false,
860
- className: className || undefined,
861
- style: { display: 'block', flexShrink: 0 },
862
- }
863
- switch (name) {
864
- case 'refresh':
865
- return h(
866
- 'svg',
867
- common,
868
- h('path', { d: 'M20 11a8.1 8.1 0 0 0-15.5-2m-.5-4v4h4' }),
869
- h('path', { d: 'M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4' }),
870
- )
871
- case 'download':
872
- return h(
873
- 'svg',
874
- common,
875
- h('path', { d: 'M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2' }),
876
- h('path', { d: 'M7 11l5 5 5-5' }),
877
- h('path', { d: 'M12 4v12' }),
878
- )
879
- case 'external':
880
- return h(
881
- 'svg',
882
- common,
883
- h('path', { d: 'M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6' }),
884
- h('path', { d: 'M11 13l9-9' }),
885
- h('path', { d: 'M15 4h5v5' }),
886
- )
887
- case 'window':
888
- return h(
889
- 'svg',
890
- common,
891
- h('rect', { x: 3, y: 4, width: 18, height: 16, rx: 3 }),
892
- h('path', { d: 'M3 9h18' }),
893
- h('path', { d: 'M10 14.5l2.5-2.5 2.5 2.5' }),
894
- )
895
- case 'bolt':
896
- return h('svg', common, h('path', { d: 'M13 3L4 14h7l-1 7 9-11h-7l1-7z' }))
897
- case 'key':
898
- return h(
899
- 'svg',
900
- common,
901
- h('circle', { cx: 8.5, cy: 15.5, r: 4.5 }),
902
- h('path', { d: 'M11.7 12.3L19 5' }),
903
- h('path', { d: 'M16.5 7.5l2 2' }),
904
- h('path', { d: 'M14 10l2 2' }),
905
- )
906
- case 'layers':
907
- return h(
908
- 'svg',
909
- common,
910
- h('path', { d: 'M12 3l9 4.5-9 4.5-9-4.5 9-4.5z' }),
911
- h('path', { d: 'M3 12l9 4.5 9-4.5' }),
912
- h('path', { d: 'M3 16.5l9 4.5 9-4.5' }),
913
- )
914
- case 'shield':
915
- return h(
916
- 'svg',
917
- common,
918
- h('path', { d: 'M12 3l7.5 3v6c0 4.5-3.2 8.2-7.5 9.5C7.7 20.2 4.5 16.5 4.5 12V6L12 3z' }),
919
- h('path', { d: 'M9 12l2 2 4-4' }),
920
- )
921
- case 'clock':
922
- return h(
923
- 'svg',
924
- common,
925
- h('circle', { cx: 12, cy: 12, r: 9 }),
926
- h('path', { d: 'M12 7v5l3 2' }),
927
- )
928
- case 'check':
929
- return h('svg', common, h('path', { d: 'M5 12l5 5 9-9' }))
930
- case 'alert':
931
- return h(
932
- 'svg',
933
- common,
934
- h('path', { d: 'M12 9v4' }),
935
- h('path', { d: 'M10.4 4.3L3.1 17a1.8 1.8 0 0 0 1.6 2.7h14.6a1.8 1.8 0 0 0 1.6-2.7L13.6 4.3a1.8 1.8 0 0 0-3.2 0z' }),
936
- h('circle', { cx: 12, cy: 16.3, r: 0.6, fill: 'currentColor' }),
937
- )
938
- default:
939
- return null
940
- }
929
+ function GuardIcon(props) {
930
+ return h(
931
+ SvgIcon,
932
+ props,
933
+ h('path', { d: 'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z' }),
934
+ h('path', { d: 'm9 12 2 2 4-4' }),
935
+ )
936
+ }
937
+
938
+ function RefreshIcon(props) {
939
+ return h(
940
+ SvgIcon,
941
+ props,
942
+ h('path', { d: 'M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8' }),
943
+ h('path', { d: 'M3 3v5h5' }),
944
+ h('path', { d: 'M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16' }),
945
+ h('path', { d: 'M16 16h5v5' }),
946
+ )
947
+ }
948
+
949
+ function SearchIcon(props) {
950
+ return h(
951
+ SvgIcon,
952
+ props,
953
+ h('circle', { cx: 11, cy: 11, r: 7 }),
954
+ h('path', { d: 'm20 20-3.5-3.5' }),
955
+ )
956
+ }
957
+
958
+ function ChevronIcon(props) {
959
+ return h(
960
+ SvgIcon,
961
+ { size: props.size || 13 },
962
+ h('path', { d: 'm6 9 6 6 6-6' }),
963
+ )
964
+ }
965
+
966
+ function ExternalIcon(props) {
967
+ return h(
968
+ SvgIcon,
969
+ props,
970
+ h('path', { d: 'M15 3h6v6' }),
971
+ h('path', { d: 'M10 14 21 3' }),
972
+ h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
973
+ )
974
+ }
975
+
976
+ function CheckCircleIcon(props) {
977
+ return h(
978
+ SvgIcon,
979
+ props,
980
+ h('circle', { cx: 12, cy: 12, r: 9 }),
981
+ h('path', { d: 'm9 12 2 2 4-4' }),
982
+ )
983
+ }
984
+
985
+ function LockIcon(props) {
986
+ return h(
987
+ SvgIcon,
988
+ props,
989
+ h('rect', { x: 4, y: 11, width: 16, height: 10, rx: 2 }),
990
+ h('path', { d: 'M7 11V7a5 5 0 0 1 10 0v4' }),
991
+ )
941
992
  }
942
993
 
943
994
  class GuardErrorBoundary extends React.Component {
@@ -950,30 +1001,13 @@ window.__ModuleLoader__.load({
950
1001
  }
951
1002
  render() {
952
1003
  if (this.state.error) {
953
- const t = COPY[store.lang] || COPY.zh
954
1004
  return h(
955
1005
  'div',
956
- { className: 'dshg-root' },
1006
+ { className: 'dshg-wrap' },
957
1007
  h(
958
1008
  'div',
959
- { className: 'dshg-card' },
960
- h('div', { style: { fontWeight: 600, fontSize: 13 } }, t.errorRecover),
961
- h(
962
- 'div',
963
- { style: { fontSize: 11.5, color: 'var(--dshg-text-2)' } },
964
- String((this.state.error && this.state.error.message) || this.state.error),
965
- ),
966
- h(
967
- 'button',
968
- {
969
- className: 'dshg-btn',
970
- onClick: () => {
971
- this.setState({ error: null })
972
- void fetchOverview()
973
- },
974
- },
975
- t.retry,
976
- ),
1009
+ { className: 'dshg-error' },
1010
+ `DSH Companion Error: ${String(this.state.error.message || this.state.error)}`,
977
1011
  ),
978
1012
  )
979
1013
  }
@@ -981,385 +1015,909 @@ window.__ModuleLoader__.load({
981
1015
  }
982
1016
  }
983
1017
 
984
- function ProfileSubcard({ profile, t }) {
985
- const isWeb = profile.target === 'web'
986
- const trackName = isWeb ? t.webTrack : t.desktopTrack
987
- const trackTone = isWeb ? 'blue' : 'ok'
988
-
989
- if (!profile.exists) {
990
- return h(
991
- 'div',
992
- { className: 'dshg-subcard' },
993
- h(
994
- 'div',
995
- { className: 'dshg-row' },
996
- h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, trackName),
997
- ),
998
- h('div', { style: { fontSize: 11, color: 'var(--dshg-text-2)' } }, t.missingDir),
999
- )
1018
+ function formatTimeShort(value) {
1019
+ if (!value) return '--'
1020
+ try {
1021
+ const d = typeof value === 'number' ? new Date(value) : new Date(String(value))
1022
+ if (Number.isNaN(d.getTime())) return String(value).slice(0, 16)
1023
+ const now = new Date()
1024
+ const sameDay =
1025
+ d.getFullYear() === now.getFullYear() &&
1026
+ d.getMonth() === now.getMonth() &&
1027
+ d.getDate() === now.getDate()
1028
+ const hh = String(d.getHours()).padStart(2, '0')
1029
+ const mm = String(d.getMinutes()).padStart(2, '0')
1030
+ if (sameDay) return `${hh}:${mm}`
1031
+ return `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${hh}:${mm}`
1032
+ } catch {
1033
+ return String(value).slice(0, 16)
1000
1034
  }
1035
+ }
1001
1036
 
1002
- const patchInfo = profile.patch || {}
1003
- const patchText = !patchInfo.exists
1004
- ? t.patchMissing
1005
- : patchInfo.syntaxOk
1006
- ? t.patchOk(patchInfo.disabledCount || 0)
1007
- : t.patchErr(patchInfo.error || 'YAML')
1008
- const patchTone = patchInfo.exists && !patchInfo.syntaxOk ? 'warn' : 'ok'
1009
-
1037
+ function BoundaryDisclosure(props) {
1038
+ const { summary, p1, p2, isWin, installerUrl, releaseUrl, t } = props
1010
1039
  return h(
1011
- 'div',
1012
- { className: 'dshg-subcard' },
1040
+ 'details',
1041
+ { className: 'dshg-boundary' },
1013
1042
  h(
1014
- 'div',
1015
- { className: 'dshg-row' },
1016
- h('span', { className: 'dshg-badge', 'data-tone': trackTone }, trackName),
1017
- h(
1018
- 'span',
1019
- { style: { fontSize: 11, color: 'var(--dshg-text-2)', fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap' } },
1020
- `${profile.bundlesCount} ${t.bundlesLabel} · ${profile.dependenciesCount} ${t.depsLabel}`,
1021
- ),
1043
+ 'summary',
1044
+ null,
1045
+ h('span', null, summary),
1046
+ h(ChevronIcon, { size: 13 }),
1022
1047
  ),
1023
1048
  h(
1024
1049
  'div',
1025
- { className: 'dshg-badge', 'data-tone': patchTone, style: { whiteSpace: 'nowrap' } },
1026
- h(SvgIcon, { name: patchTone === 'ok' ? 'check' : 'alert', size: 11 }),
1027
- patchText,
1050
+ { className: 'dshg-boundary-body' },
1051
+ h('div', null, p1),
1052
+ h('div', null, p2),
1053
+ isWin
1054
+ ? h(
1055
+ 'div',
1056
+ { className: 'dshg-boundary-links' },
1057
+ h(
1058
+ 'a',
1059
+ { href: installerUrl, target: '_blank', rel: 'noopener noreferrer' },
1060
+ t.desktopWinLink,
1061
+ ),
1062
+ h(
1063
+ 'a',
1064
+ { href: releaseUrl, target: '_blank', rel: 'noopener noreferrer' },
1065
+ t.desktopReleaseLink,
1066
+ ),
1067
+ )
1068
+ : h('div', { style: { opacity: 0.85 } }, t.desktopNonWinNote),
1028
1069
  ),
1029
- !profile.packageJsonOk
1030
- ? h('div', { style: { fontSize: 11, color: '#f59e0b' } }, t.pkgErr)
1031
- : null,
1032
- Array.isArray(profile.missingInDeps) && profile.missingInDeps.length > 0
1033
- ? h(
1034
- 'div',
1035
- { className: 'dshg-pills' },
1036
- h('span', { style: { fontSize: 11, color: '#f59e0b' } }, `${t.missingInDeps}:`),
1037
- ...profile.missingInDeps.map((pkg) => h('span', { key: pkg, className: 'dshg-pill', 'data-tone': 'warn' }, pkg)),
1038
- )
1039
- : null,
1040
- Array.isArray(profile.unregisteredDeps) && profile.unregisteredDeps.length > 0
1041
- ? h(
1042
- 'div',
1043
- { className: 'dshg-pills' },
1044
- h('span', { style: { fontSize: 11, color: '#f59e0b' } }, `${t.unregisteredDeps}:`),
1045
- ...profile.unregisteredDeps.map((pkg) => h('span', { key: pkg, className: 'dshg-pill', 'data-tone': 'warn' }, pkg)),
1046
- )
1047
- : null,
1048
1070
  )
1049
1071
  }
1050
1072
 
1051
- function SupervisorCard({ platform, guard, installerUrl, releaseUrl, repoUrl, launching, t }) {
1052
- const isWin = platform === 'win32'
1053
- if (isWin && guard.installed) {
1054
- return h(
1073
+ function ToggleSwitch(props) {
1074
+ const { on, disabled, busy, onToggle, title } = props
1075
+ return h(
1076
+ 'button',
1077
+ {
1078
+ type: 'button',
1079
+ role: 'switch',
1080
+ 'aria-checked': Boolean(on),
1081
+ 'aria-label': title,
1082
+ className: 'dshg-switch',
1083
+ 'data-on': Boolean(on) ? 'true' : 'false',
1084
+ disabled: Boolean(disabled || busy),
1085
+ onClick: onToggle,
1086
+ },
1087
+ h('span', { className: 'dshg-switch-thumb' }),
1088
+ )
1089
+ }
1090
+
1091
+ function GuardPanelInner(props) {
1092
+ ensureStyles()
1093
+ const state = useStore()
1094
+ const t = COPY[state.lang] || COPY.zh
1095
+
1096
+ React.useEffect(() => {
1097
+ if (!store.data && !store.loading) {
1098
+ fetchOverview(false)
1099
+ }
1100
+ }, [])
1101
+
1102
+ const data = state.data
1103
+ const health = (data && data.health) || null
1104
+ const snapshots = (data && data.snapshots) || (health && health.snapshots) || { total: 0, snapshots: [] }
1105
+ const guard = (health && health.guard) || { installed: false }
1106
+ const isWin = ((data && data.platform) || (health && health.platform) || '') === 'win32'
1107
+ const installerUrl = (data && data.installerUrl) || INSTALLER_FALLBACK
1108
+ const releaseUrl = (data && data.releaseUrl) || RELEASE_FALLBACK
1109
+ const repoUrl = (data && data.repoUrl) || REPO_FALLBACK
1110
+
1111
+ const webProfile = (health && health.profiles && health.profiles.web) || {
1112
+ exists: false, totalDependencies: 0, thirdPartyCount: 0, mcpCount: 0, disabledEntryCount: 0, brokenLinkCount: 0,
1113
+ }
1114
+ const deskProfile = (health && health.profiles && health.profiles.desktop) || {
1115
+ exists: false, totalDependencies: 0, thirdPartyCount: 0, mcpCount: 0, disabledEntryCount: 0, brokenLinkCount: 0,
1116
+ }
1117
+ const credentials = (health && health.credentials) || { present: false, count: 0, keys: [] }
1118
+ const providers = Array.isArray(health && health.providers) ? health.providers : []
1119
+ const issues = Array.isArray(health && health.issues) ? health.issues : []
1120
+ const healthy = health ? Boolean(health.healthy) : true
1121
+
1122
+ const activeExtProfile = state.pluginProfile === 'desktop' ? 'desktop' : 'web'
1123
+ const extTrack = (health && health.extensions && health.extensions[activeExtProfile]) || {
1124
+ plugins: [], mcpServers: [],
1125
+ }
1126
+
1127
+ const query = state.search.trim().toLowerCase()
1128
+ const filteredMcps = extTrack.mcpServers.filter((m) =>
1129
+ !query ||
1130
+ String(m.serverName || '').toLowerCase().includes(query) ||
1131
+ String(m.id || '').toLowerCase().includes(query),
1132
+ )
1133
+ const filteredPlugins = extTrack.plugins.filter((p) =>
1134
+ !query ||
1135
+ String(p.name || '').toLowerCase().includes(query) ||
1136
+ String(p.primaryId || '').toLowerCase().includes(query),
1137
+ )
1138
+
1139
+ const totalExtCount = (webProfile.thirdPartyCount || 0) + (webProfile.mcpCount || 0)
1140
+ const credsSummaryVal = `${credentials.count || 0} / ${providers.length}`
1141
+ const totalBrokenLinks = (webProfile.brokenLinkCount || 0) + (deskProfile.brokenLinkCount || 0)
1142
+
1143
+ const renderOverviewTab = () =>
1144
+ h(
1145
+ 'div',
1146
+ { className: 'dshg-tab-body' },
1147
+ totalBrokenLinks > 0
1148
+ ? h(
1149
+ 'div',
1150
+ { className: 'dshg-card', style: { borderColor: 'var(--dshg-warn-border)' } },
1151
+ h(
1152
+ 'div',
1153
+ { className: 'dshg-sec-head' },
1154
+ h('span', null, `${t.brokenLabel} (${totalBrokenLinks})`),
1155
+ h(
1156
+ 'div',
1157
+ { className: 'dshg-actions' },
1158
+ webProfile.brokenLinkCount > 0
1159
+ ? h(
1160
+ 'button',
1161
+ {
1162
+ type: 'button',
1163
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1164
+ disabled: Boolean(state.busyKey),
1165
+ onClick: () =>
1166
+ postAction(
1167
+ '/repair-links',
1168
+ { target: 'web' },
1169
+ 'repair-web',
1170
+ (res) => `Web 断链处理完成:修复 ${res.repairedCount},未解析 ${res.unresolvableCount}`,
1171
+ ),
1172
+ },
1173
+ state.busyKey === 'repair-web' ? t.repairingBtn : `${t.repairLinksBtn} (Web)`,
1174
+ )
1175
+ : null,
1176
+ deskProfile.brokenLinkCount > 0
1177
+ ? h(
1178
+ 'button',
1179
+ {
1180
+ type: 'button',
1181
+ className: 'dshg-btn dshg-btn-sm',
1182
+ disabled: Boolean(state.busyKey),
1183
+ onClick: () =>
1184
+ postAction(
1185
+ '/repair-links',
1186
+ { target: 'desktop' },
1187
+ 'repair-desk',
1188
+ (res) => `桌面端断链处理完成:修复 ${res.repairedCount},未解析 ${res.unresolvableCount}`,
1189
+ ),
1190
+ },
1191
+ state.busyKey === 'repair-desk' ? t.repairingBtn : `${t.repairLinksBtn} (Desktop)`,
1192
+ )
1193
+ : null,
1194
+ ),
1195
+ ),
1196
+ h(
1197
+ 'div',
1198
+ { className: 'dshg-pills' },
1199
+ ...[...(webProfile.brokenLinks || []), ...(deskProfile.brokenLinks || [])].map((b, i) =>
1200
+ h('span', { key: `${b.name}-${i}`, className: 'dshg-pill' }, b.name),
1201
+ ),
1202
+ ),
1203
+ )
1204
+ : null,
1205
+
1206
+ h(
1207
+ 'div',
1208
+ { className: 'dshg-card' },
1209
+ h(
1210
+ 'div',
1211
+ { className: 'dshg-sec-head' },
1212
+ h('span', null, t.secProfiles),
1213
+ h('span', { className: 'dshg-badge', 'data-tone': healthy ? 'ok' : 'warn' }, healthy ? t.healthy : t.unhealthy(issues.length)),
1214
+ ),
1215
+ h(
1216
+ 'div',
1217
+ { className: 'dshg-profile-grid' },
1218
+ ...[
1219
+ { label: t.webTrack, p: webProfile },
1220
+ { label: t.desktopTrack, p: deskProfile },
1221
+ ].map(({ label, p }) =>
1222
+ h(
1223
+ 'div',
1224
+ { key: label, className: 'dshg-subcard' },
1225
+ h(
1226
+ 'div',
1227
+ { className: 'dshg-row' },
1228
+ h('strong', null, label),
1229
+ h('span', { className: 'dshg-badge', 'data-tone': p.exists ? 'ok' : 'muted' }, p.exists ? t.present : t.absent),
1230
+ ),
1231
+ h('div', { className: 'dshg-row' }, h('span', { style: { color: 'var(--dshg-text-3)' } }, t.depsLabel), h('span', { className: 'dshg-mono' }, String(p.totalDependencies))),
1232
+ h('div', { className: 'dshg-row' }, h('span', { style: { color: 'var(--dshg-text-3)' } }, t.thirdPartyLabel), h('span', { className: 'dshg-mono' }, String(p.thirdPartyCount))),
1233
+ h('div', { className: 'dshg-row' }, h('span', { style: { color: 'var(--dshg-text-3)' } }, t.mcpLabel), h('span', { className: 'dshg-mono' }, String(p.mcpCount || 0))),
1234
+ h('div', { className: 'dshg-row' }, h('span', { style: { color: 'var(--dshg-text-3)' } }, t.disabledLabel), h('span', { className: 'dshg-mono' }, String(p.disabledEntryCount || 0))),
1235
+ ),
1236
+ ),
1237
+ ),
1238
+ ),
1239
+
1240
+ issues.length > 0
1241
+ ? h(
1242
+ 'div',
1243
+ { className: 'dshg-card' },
1244
+ h('div', { className: 'dshg-sec-head' }, h('span', null, t.warningsTitle)),
1245
+ h(
1246
+ 'div',
1247
+ { className: 'dshg-list' },
1248
+ ...issues.map((msg, idx) =>
1249
+ h('div', { key: idx, className: 'dshg-item', style: { fontSize: 11.5 } }, msg),
1250
+ ),
1251
+ ),
1252
+ )
1253
+ : h(
1254
+ 'div',
1255
+ { className: 'dshg-card' },
1256
+ h(
1257
+ 'div',
1258
+ { className: 'dshg-item-row' },
1259
+ h(
1260
+ 'div',
1261
+ { className: 'dshg-item-main' },
1262
+ h(
1263
+ 'div',
1264
+ { className: 'dshg-item-title' },
1265
+ h(CheckCircleIcon, { size: 14, className: undefined }),
1266
+ h('span', null, t.allHealthyTitle),
1267
+ ),
1268
+ h('div', { className: 'dshg-sec-sub' }, t.allHealthySub),
1269
+ ),
1270
+ ),
1271
+ h(
1272
+ 'div',
1273
+ { className: 'dshg-actions', style: { flexWrap: 'wrap' } },
1274
+ h(
1275
+ 'button',
1276
+ {
1277
+ type: 'button',
1278
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1279
+ disabled: Boolean(state.busyKey),
1280
+ onClick: () =>
1281
+ postAction(
1282
+ '/snapshots/create',
1283
+ { target: 'web', reason: '总览快捷备份' },
1284
+ 'quick-snap',
1285
+ (res) => `已创建快照 ${res.snapshot.id}`,
1286
+ ),
1287
+ },
1288
+ state.busyKey === 'quick-snap' ? t.snapCreating : t.quickSnapWeb,
1289
+ ),
1290
+ h(
1291
+ 'button',
1292
+ {
1293
+ type: 'button',
1294
+ className: 'dshg-btn dshg-btn-sm',
1295
+ onClick: () => patch({ tab: 'plugins' }),
1296
+ },
1297
+ t.quickGoPlugins,
1298
+ ),
1299
+ ),
1300
+ ),
1301
+ )
1302
+
1303
+ const renderPluginsTab = () =>
1304
+ h(
1055
1305
  'div',
1056
- { className: 'dshg-card dshg-card-spotlight' },
1306
+ { className: 'dshg-tab-body' },
1057
1307
  h(
1058
1308
  'div',
1059
- { className: 'dshg-sec-head' },
1309
+ { className: 'dshg-toolbar' },
1060
1310
  h(
1061
- 'span',
1062
- { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } },
1063
- h(GuardIcon, { size: 15, active: true }),
1064
- t.supervisorTitleWinReady,
1311
+ 'div',
1312
+ { className: 'dshg-seg-2' },
1313
+ h(
1314
+ 'button',
1315
+ {
1316
+ type: 'button',
1317
+ className: 'dshg-seg-btn',
1318
+ 'data-active': activeExtProfile === 'web' ? 'true' : 'false',
1319
+ onClick: () => patch({ pluginProfile: 'web' }),
1320
+ },
1321
+ t.webTrack,
1322
+ ),
1323
+ h(
1324
+ 'button',
1325
+ {
1326
+ type: 'button',
1327
+ className: 'dshg-seg-btn',
1328
+ 'data-active': activeExtProfile === 'desktop' ? 'true' : 'false',
1329
+ onClick: () => patch({ pluginProfile: 'desktop' }),
1330
+ },
1331
+ t.desktopTrack,
1332
+ ),
1065
1333
  ),
1066
1334
  h(
1067
- 'span',
1068
- { className: 'dshg-badge', 'data-tone': 'ok' },
1069
- h('span', { className: 'dshg-dot' }),
1070
- t.supervisorBadgeReady,
1335
+ 'div',
1336
+ { className: 'dshg-search-wrap' },
1337
+ h('span', { className: 'dshg-search-ico' }, h(SearchIcon, { size: 13 })),
1338
+ h('input', {
1339
+ type: 'search',
1340
+ className: 'dshg-input with-ico',
1341
+ value: state.search,
1342
+ placeholder: t.searchPlaceholder,
1343
+ onChange: (e) => patch({ search: e.target.value }),
1344
+ }),
1071
1345
  ),
1072
1346
  ),
1073
- h('div', { className: 'dshg-sec-sub' }, t.supervisorDescWinReady),
1074
- h('div', { className: 'dshg-path-box' }, guard.exePath || 'DSHGuard.exe'),
1347
+
1075
1348
  h(
1076
- 'button',
1077
- {
1078
- className: 'dshg-btn dshg-btn-primary',
1079
- disabled: launching,
1080
- onClick: () => void launchDesktopGuard(),
1081
- },
1082
- h(SvgIcon, { name: 'window', size: 15 }),
1083
- launching ? t.btnOpeningGuard : t.btnOpenGuard,
1349
+ 'div',
1350
+ { className: 'dshg-card' },
1351
+ h(
1352
+ 'div',
1353
+ { className: 'dshg-sec-head' },
1354
+ h('span', null, t.mcpSectionTitle),
1355
+ h('span', { className: 'dshg-badge', 'data-tone': 'blue' }, String(filteredMcps.length)),
1356
+ ),
1357
+ filteredMcps.length > 0
1358
+ ? h(
1359
+ 'div',
1360
+ { className: 'dshg-list' },
1361
+ ...filteredMcps.map((m) =>
1362
+ h(
1363
+ 'div',
1364
+ { key: m.id, className: 'dshg-item' },
1365
+ h(
1366
+ 'div',
1367
+ { className: 'dshg-item-row' },
1368
+ h(
1369
+ 'div',
1370
+ { className: 'dshg-item-main' },
1371
+ h(
1372
+ 'div',
1373
+ { className: 'dshg-item-title' },
1374
+ h('span', null, m.serverName),
1375
+ h('span', { className: 'dshg-pill' }, m.transport),
1376
+ ),
1377
+ h('div', { className: 'dshg-mono' }, m.command || m.url || m.id),
1378
+ ),
1379
+ h(ToggleSwitch, {
1380
+ on: m.enabled,
1381
+ busy: state.busyKey === `toggle-${m.id}`,
1382
+ title: m.serverName,
1383
+ onToggle: () =>
1384
+ postAction(
1385
+ '/toggle-entry',
1386
+ { target: activeExtProfile, id: m.id, disabled: m.enabled },
1387
+ `toggle-${m.id}`,
1388
+ (res) => res.restartHint,
1389
+ ),
1390
+ }),
1391
+ ),
1392
+ ),
1393
+ ),
1394
+ )
1395
+ : h('div', { className: 'dshg-sec-sub' }, t.mcpEmpty),
1084
1396
  ),
1397
+
1398
+ h(
1399
+ 'div',
1400
+ { className: 'dshg-card' },
1401
+ h(
1402
+ 'div',
1403
+ { className: 'dshg-sec-head' },
1404
+ h('span', null, t.pluginsSectionTitle),
1405
+ h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, t.badgeAllCount(filteredPlugins.length, extTrack.plugins.length)),
1406
+ ),
1407
+ filteredPlugins.length > 0
1408
+ ? h(
1409
+ 'div',
1410
+ { className: 'dshg-list' },
1411
+ ...filteredPlugins.map((p) =>
1412
+ h(
1413
+ 'div',
1414
+ { key: p.name, className: 'dshg-item' },
1415
+ h(
1416
+ 'div',
1417
+ { className: 'dshg-item-row' },
1418
+ h(
1419
+ 'div',
1420
+ { className: 'dshg-item-main' },
1421
+ h(
1422
+ 'div',
1423
+ { className: 'dshg-item-title' },
1424
+ h('span', null, p.name),
1425
+ p.isSelf
1426
+ ? h('span', { className: 'dshg-badge', 'data-tone': 'blue' }, t.badgeSelf)
1427
+ : p.isCore
1428
+ ? h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, t.badgeCore)
1429
+ : h('span', { className: 'dshg-badge', 'data-tone': p.enabled ? 'ok' : 'warn' }, p.enabled ? t.badgeEnabled : t.badgeDisabled),
1430
+ ),
1431
+ h('div', { className: 'dshg-mono' }, `${p.primaryId}${p.version ? ` · v${p.version}` : ''}`),
1432
+ ),
1433
+ h(ToggleSwitch, {
1434
+ on: p.enabled,
1435
+ disabled: !p.canToggle,
1436
+ busy: state.busyKey === `toggle-${p.primaryId}`,
1437
+ title: p.name,
1438
+ onToggle: () =>
1439
+ postAction(
1440
+ '/toggle-entry',
1441
+ { target: activeExtProfile, id: p.primaryId, disabled: p.enabled },
1442
+ `toggle-${p.primaryId}`,
1443
+ (res) => res.restartHint,
1444
+ ),
1445
+ }),
1446
+ ),
1447
+ ),
1448
+ ),
1449
+ )
1450
+ : h('div', { className: 'dshg-sec-sub' }, t.pluginsEmpty),
1451
+ ),
1452
+
1453
+ h(BoundaryDisclosure, {
1454
+ summary: t.boundaryPluginsSummary,
1455
+ p1: t.boundaryPluginsP1,
1456
+ p2: t.boundaryPluginsP2,
1457
+ isWin,
1458
+ installerUrl,
1459
+ releaseUrl,
1460
+ t,
1461
+ }),
1085
1462
  )
1086
- }
1087
1463
 
1088
- if (isWin) {
1089
- const feats = [
1090
- { icon: 'bolt', title: t.feat1Title, sub: t.feat1Sub },
1091
- { icon: 'key', title: t.feat2Title, sub: t.feat2Sub },
1092
- { icon: 'layers', title: t.feat3Title, sub: t.feat3Sub },
1093
- { icon: 'shield', title: t.feat4Title, sub: t.feat4Sub },
1094
- ]
1095
- return h(
1464
+ const renderCredsTab = () =>
1465
+ h(
1096
1466
  'div',
1097
- { className: 'dshg-card dshg-card-spotlight' },
1467
+ { className: 'dshg-tab-body' },
1098
1468
  h(
1099
1469
  'div',
1100
- { className: 'dshg-sec-head' },
1470
+ { className: 'dshg-card' },
1101
1471
  h(
1102
- 'span',
1103
- { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } },
1104
- h(GuardIcon, { size: 15, active: true }),
1105
- t.supervisorTitleWinMissing,
1472
+ 'div',
1473
+ { className: 'dshg-sec-head' },
1474
+ h('span', null, t.providersTitle),
1475
+ h('span', { className: 'dshg-badge', 'data-tone': 'blue' }, String(providers.length)),
1106
1476
  ),
1107
- h('span', { className: 'dshg-badge', 'data-tone': 'blue' }, t.supervisorBadgeWin),
1477
+ providers.length > 0
1478
+ ? h(
1479
+ 'div',
1480
+ { className: 'dshg-list' },
1481
+ ...providers.map((prov) => {
1482
+ const editingThis = Boolean(prov.apiKeyEnv && state.editProviderKey === prov.id)
1483
+ return h(
1484
+ 'div',
1485
+ { key: prov.id, className: 'dshg-item' },
1486
+ h(
1487
+ 'div',
1488
+ { className: 'dshg-item-row' },
1489
+ h(
1490
+ 'div',
1491
+ { className: 'dshg-item-main' },
1492
+ h(
1493
+ 'div',
1494
+ { className: 'dshg-item-title' },
1495
+ h('span', null, prov.displayName),
1496
+ h('span', { className: 'dshg-pill' }, prov.api),
1497
+ h('span', { className: 'dshg-pill' }, `${prov.models.length} ${t.modelsUnit}`),
1498
+ ),
1499
+ prov.baseURL ? h('div', { className: 'dshg-mono' }, prov.baseURL) : null,
1500
+ h(
1501
+ 'div',
1502
+ { className: 'dshg-pills', style: { marginTop: 2 } },
1503
+ ...(prov.profiles || []).map((pf) => h('span', { key: pf, className: 'dshg-pill' }, pf)),
1504
+ prov.apiKeyEnv
1505
+ ? h('span', { className: 'dshg-badge', 'data-tone': prov.keyConfigured ? 'ok' : 'warn' }, `${prov.apiKeyEnv} · ${prov.keyConfigured ? t.keyReady : t.keyMissing}`)
1506
+ : null,
1507
+ ),
1508
+ ),
1509
+ prov.apiKeyEnv
1510
+ ? h(
1511
+ 'button',
1512
+ {
1513
+ type: 'button',
1514
+ className: 'dshg-btn dshg-btn-sm',
1515
+ onClick: () =>
1516
+ patch({
1517
+ editProviderKey: editingThis ? '' : prov.id,
1518
+ draftSecret: '',
1519
+ }),
1520
+ },
1521
+ editingThis ? t.cancelBtn : prov.keyConfigured ? t.updateKeyBtn : t.setKeyBtn,
1522
+ )
1523
+ : null,
1524
+ ),
1525
+ editingThis
1526
+ ? h(
1527
+ 'div',
1528
+ { className: 'dshg-drawer' },
1529
+ h(
1530
+ 'div',
1531
+ { className: 'dshg-drawer-row' },
1532
+ h('input', {
1533
+ type: 'password',
1534
+ className: 'dshg-input',
1535
+ autoComplete: 'new-password',
1536
+ value: state.draftSecret,
1537
+ placeholder: t.keyPlaceholder,
1538
+ onChange: (e) => patch({ draftSecret: e.target.value }),
1539
+ }),
1540
+ h(
1541
+ 'button',
1542
+ {
1543
+ type: 'button',
1544
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1545
+ disabled: Boolean(state.busyKey || !state.draftSecret.trim()),
1546
+ onClick: async () => {
1547
+ const secret = state.draftSecret
1548
+ patch({ draftSecret: '' })
1549
+ const res = await postAction(
1550
+ '/credential-key',
1551
+ { key: prov.apiKeyEnv, value: secret },
1552
+ `write-${prov.apiKeyEnv}`,
1553
+ (r) => `已将 ${r.key} 单向写入 .credentials.yaml(绝不回显)`,
1554
+ )
1555
+ if (res && res.ok) patch({ editProviderKey: '' })
1556
+ },
1557
+ },
1558
+ state.busyKey === `write-${prov.apiKeyEnv}` ? t.writingKeyBtn : t.writeKeyBtn,
1559
+ ),
1560
+ ),
1561
+ )
1562
+ : null,
1563
+ )
1564
+ }),
1565
+ )
1566
+ : h('div', { className: 'dshg-sec-sub' }, t.providersEmpty),
1108
1567
  ),
1109
- h('div', { className: 'dshg-sec-sub' }, t.supervisorDescWinMissing),
1568
+
1110
1569
  h(
1111
1570
  'div',
1112
- { className: 'dshg-feat-grid' },
1113
- ...feats.map((f) =>
1571
+ { className: 'dshg-card' },
1572
+ h(
1573
+ 'div',
1574
+ { className: 'dshg-sec-head' },
1575
+ h('span', null, t.credsAuditTitle),
1114
1576
  h(
1115
- 'div',
1116
- { key: f.title, className: 'dshg-feat-item' },
1117
- h('div', { className: 'dshg-feat-ico' }, h(SvgIcon, { name: f.icon, size: 14 })),
1118
- h(
1119
- 'div',
1120
- null,
1121
- h('div', { className: 'dshg-feat-t' }, f.title),
1122
- h('div', { className: 'dshg-feat-s' }, f.sub),
1123
- ),
1577
+ 'button',
1578
+ {
1579
+ type: 'button',
1580
+ className: 'dshg-btn dshg-btn-sm',
1581
+ onClick: () => patch({ showAddKey: !state.showAddKey, newKeySecret: '' }),
1582
+ },
1583
+ state.showAddKey ? t.cancelBtn : t.addKeyToggle,
1124
1584
  ),
1125
1585
  ),
1586
+ h('div', { className: 'dshg-sec-sub' }, t.credsAuditSub),
1587
+ state.showAddKey
1588
+ ? h(
1589
+ 'div',
1590
+ { className: 'dshg-drawer', style: { borderTop: 'none', paddingTop: 0 } },
1591
+ h('input', {
1592
+ type: 'text',
1593
+ className: 'dshg-input',
1594
+ value: state.newKeyName,
1595
+ placeholder: t.envNameLabel,
1596
+ onChange: (e) => patch({ newKeyName: e.target.value }),
1597
+ }),
1598
+ h(
1599
+ 'div',
1600
+ { className: 'dshg-drawer-row' },
1601
+ h('input', {
1602
+ type: 'password',
1603
+ className: 'dshg-input',
1604
+ autoComplete: 'new-password',
1605
+ value: state.newKeySecret,
1606
+ placeholder: t.keyPlaceholder,
1607
+ onChange: (e) => patch({ newKeySecret: e.target.value }),
1608
+ }),
1609
+ h(
1610
+ 'button',
1611
+ {
1612
+ type: 'button',
1613
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1614
+ disabled: Boolean(state.busyKey || !state.newKeyName.trim() || !state.newKeySecret.trim()),
1615
+ onClick: async () => {
1616
+ const keyName = state.newKeyName.trim()
1617
+ const secret = state.newKeySecret
1618
+ patch({ newKeySecret: '' })
1619
+ const res = await postAction(
1620
+ '/credential-key',
1621
+ { key: keyName, value: secret },
1622
+ 'write-custom-key',
1623
+ (r) => `已将 ${r.key} 单向写入 .credentials.yaml(绝不回显)`,
1624
+ )
1625
+ if (res && res.ok) patch({ newKeyName: '', showAddKey: false })
1626
+ },
1627
+ },
1628
+ state.busyKey === 'write-custom-key' ? t.writingKeyBtn : t.writeKeyBtn,
1629
+ ),
1630
+ ),
1631
+ )
1632
+ : null,
1633
+ credentials.keys && credentials.keys.length > 0
1634
+ ? h(
1635
+ 'div',
1636
+ { className: 'dshg-list' },
1637
+ ...credentials.keys.map((k) =>
1638
+ h(
1639
+ 'div',
1640
+ { key: k.key, className: 'dshg-item', style: { padding: '6px 9px' } },
1641
+ h(
1642
+ 'div',
1643
+ { className: 'dshg-item-row' },
1644
+ h(
1645
+ 'span',
1646
+ {
1647
+ className: 'dshg-mono',
1648
+ style: {
1649
+ color: 'var(--dshg-text)',
1650
+ fontWeight: 500,
1651
+ display: 'inline-flex',
1652
+ alignItems: 'center',
1653
+ gap: 5,
1654
+ },
1655
+ },
1656
+ k.protected ? h(LockIcon, { size: 12 }) : null,
1657
+ k.key,
1658
+ ),
1659
+ k.protected
1660
+ ? h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, t.credProtected)
1661
+ : h('span', { className: 'dshg-badge', 'data-tone': k.present ? 'ok' : 'blue' }, k.present ? t.credPresent : t.credEnvOnly),
1662
+ ),
1663
+ ),
1664
+ ),
1665
+ )
1666
+ : h('div', { className: 'dshg-sec-sub' }, t.credsEmpty),
1126
1667
  ),
1127
- h(
1128
- 'a',
1129
- {
1130
- className: 'dshg-btn dshg-btn-primary',
1131
- href: installerUrl,
1132
- target: '_blank',
1133
- rel: 'noopener noreferrer',
1134
- },
1135
- h(SvgIcon, { name: 'download', size: 15 }),
1136
- t.btnDownloadExe,
1137
- ),
1668
+
1669
+ h(BoundaryDisclosure, {
1670
+ summary: t.boundaryCredsSummary,
1671
+ p1: t.boundaryCredsP1,
1672
+ p2: t.boundaryCredsP2,
1673
+ isWin,
1674
+ installerUrl,
1675
+ releaseUrl,
1676
+ t,
1677
+ }),
1678
+ )
1679
+
1680
+ const renderSnapshotsTab = () =>
1681
+ h(
1682
+ 'div',
1683
+ { className: 'dshg-tab-body' },
1138
1684
  h(
1139
1685
  'div',
1140
- { className: 'dshg-btn-row' },
1686
+ { className: 'dshg-toolbar' },
1141
1687
  h(
1142
- 'a',
1688
+ 'button',
1143
1689
  {
1144
- className: 'dshg-btn',
1145
- href: repoUrl,
1146
- target: '_blank',
1147
- rel: 'noopener noreferrer',
1690
+ type: 'button',
1691
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1692
+ disabled: Boolean(state.busyKey),
1693
+ onClick: () =>
1694
+ postAction(
1695
+ '/snapshots/create',
1696
+ { target: 'web', reason: 'Web 手动备份' },
1697
+ 'snap-web',
1698
+ (res) => `已创建 Web 快照 ${res.snapshot.id}`,
1699
+ ),
1148
1700
  },
1149
- h(SvgIcon, { name: 'external', size: 12 }),
1150
- t.btnViewRepo,
1701
+ state.busyKey === 'snap-web' ? t.snapCreating : t.snapCreateWeb,
1151
1702
  ),
1152
1703
  h(
1153
1704
  'button',
1154
1705
  {
1155
- className: 'dshg-btn',
1156
- onClick: () => void fetchOverview(),
1706
+ type: 'button',
1707
+ className: 'dshg-btn dshg-btn-sm',
1708
+ disabled: Boolean(state.busyKey),
1709
+ onClick: () =>
1710
+ postAction(
1711
+ '/snapshots/create',
1712
+ { target: 'desktop', reason: '桌面端手动备份' },
1713
+ 'snap-desktop',
1714
+ (res) => `已创建桌面端快照 ${res.snapshot.id}`,
1715
+ ),
1157
1716
  },
1158
- h(SvgIcon, { name: 'refresh', size: 12 }),
1159
- t.btnRedetect,
1717
+ state.busyKey === 'snap-desktop' ? t.snapCreating : t.snapCreateDesktop,
1160
1718
  ),
1161
1719
  ),
1162
- )
1163
- }
1164
1720
 
1165
- return h(
1166
- 'div',
1167
- { className: 'dshg-card' },
1168
- h(
1169
- 'div',
1170
- { className: 'dshg-sec-head' },
1171
- h(
1172
- 'span',
1173
- { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } },
1174
- h(GuardIcon, { size: 15, active: true }),
1175
- t.supervisorTitleOther,
1176
- ),
1177
- platform ? h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, platform) : null,
1178
- ),
1179
- h('div', { className: 'dshg-sec-sub' }, t.supervisorDescOther(platform || 'POSIX')),
1180
- h(
1181
- 'div',
1182
- { className: 'dshg-btn-row' },
1183
- h(
1184
- 'a',
1185
- {
1186
- className: 'dshg-btn',
1187
- href: repoUrl,
1188
- target: '_blank',
1189
- rel: 'noopener noreferrer',
1190
- },
1191
- h(SvgIcon, { name: 'external', size: 12 }),
1192
- t.btnViewRepo,
1193
- ),
1194
1721
  h(
1195
- 'a',
1196
- {
1197
- className: 'dshg-btn',
1198
- href: releaseUrl,
1199
- target: '_blank',
1200
- rel: 'noopener noreferrer',
1201
- },
1202
- h(SvgIcon, { name: 'download', size: 12 }),
1203
- t.btnViewReleases,
1204
- ),
1205
- ),
1206
- )
1207
- }
1208
-
1209
- function GuardPanelInner({ variant }) {
1210
- const snap = useStore()
1211
- const t = COPY[snap.lang] || COPY.zh
1212
-
1213
- React.useEffect(() => {
1214
- ensureStyles()
1215
- if (!store.data && !store.loading) {
1216
- void fetchOverview()
1217
- }
1218
- }, [])
1219
-
1220
- const data = snap.data
1221
- const health = data && data.health
1222
- const snapshots = data && data.snapshots
1223
- const platform = (data && data.platform) || (health && health.platform) || ''
1224
- const guard = (health && health.guard) || {}
1225
- const releaseUrl = (guard && guard.releaseUrl) || (snapshots && snapshots.releaseUrl) || RELEASE_FALLBACK
1226
- const installerUrl = (data && data.installerUrl) || (guard && guard.installerUrl) || (snapshots && snapshots.installerUrl) || INSTALLER_FALLBACK
1227
- const repoUrl = (data && data.repoUrl) || (guard && guard.repoUrl) || REPO_FALLBACK
1228
- const creds = (health && health.credentials) || {}
1229
- const refKeys = Array.isArray(creds.referencedKeys) ? creds.referencedKeys : []
1230
- const snapList = snapshots && Array.isArray(snapshots.snapshots) ? snapshots.snapshots : []
1231
- const profiles = health && Array.isArray(health.profiles) ? health.profiles : []
1232
-
1233
- const webProfile = profiles.find((p) => p.target === 'web')
1234
- const deskProfile = profiles.find((p) => p.target === 'desktop')
1235
- const kpiProfilesText = profiles.length
1236
- ? `${webProfile && webProfile.exists ? webProfile.bundlesCount : 0} · ${deskProfile && deskProfile.exists ? deskProfile.bundlesCount : 0}`
1237
- : '—'
1238
- const refReadyCount = refKeys.filter((r) => r.ready).length
1239
- const kpiCredsReady = refKeys.length > 0 ? refReadyCount : (creds.nonEmptyKeysCount || 0)
1240
- const kpiCredsTotal = refKeys.length > 0 ? refKeys.length : (creds.totalKeysCount || 0)
1241
- const kpiCredsText = health ? (creds.fileExists ? `${kpiCredsReady}/${kpiCredsTotal}` : '0/0') : '—'
1242
- const kpiSnapsText = snapshots ? String(snapshots.total || 0) : '—'
1243
-
1244
- const hasProfileIssues = Boolean(health && Array.isArray(health.issues) && health.issues.length > 0)
1245
- const hasMissingCreds = Boolean(
1246
- !creds.fileExists || (Array.isArray(creds.missingReferencedKeys) && creds.missingReferencedKeys.length > 0),
1247
- )
1722
+ 'div',
1723
+ { className: 'dshg-card' },
1724
+ h(
1725
+ 'div',
1726
+ { className: 'dshg-sec-head' },
1727
+ h('span', null, t.kpiSnaps),
1728
+ h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, String(snapshots.total || 0)),
1729
+ ),
1730
+ snapshots.snapshots && snapshots.snapshots.length > 0
1731
+ ? h(
1732
+ 'div',
1733
+ { className: 'dshg-list' },
1734
+ ...snapshots.snapshots.map((s) => {
1735
+ const expanded = Boolean(state.expandedSnaps[s.id])
1736
+ const trackColor = s.target === 'desktop' ? '#f59e0b' : '#3b82f6'
1737
+ const fileStatusLabel = (st) =>
1738
+ st === 'same' ? t.fileSame : st === 'modified' ? t.fileModified : st === 'missing_now' ? t.fileMissing : t.fileUnknown
1739
+ const fileTone = (st) =>
1740
+ st === 'same' ? 'ok' : st === 'modified' || st === 'missing_now' ? 'warn' : 'muted'
1248
1741
 
1249
- const credRatioPct = kpiCredsTotal > 0 ? Math.min(100, Math.round((kpiCredsReady / kpiCredsTotal) * 100)) : 0
1742
+ return h(
1743
+ 'div',
1744
+ { key: s.id, className: 'dshg-item' },
1745
+ h(
1746
+ 'div',
1747
+ { className: 'dshg-item-row' },
1748
+ h(
1749
+ 'div',
1750
+ { className: 'dshg-item-main' },
1751
+ h(
1752
+ 'div',
1753
+ { className: 'dshg-item-title' },
1754
+ h('span', { className: 'dshg-track-dot', style: { background: trackColor } }),
1755
+ h('span', null, s.reason || s.id),
1756
+ h('span', { className: 'dshg-pill' }, s.source === 'desktop' ? t.snapSourceDesktop : t.snapSourcePlugin),
1757
+ ),
1758
+ h('div', { className: 'dshg-mono' }, `${s.target} · ${formatTimeShort(s.createdAt)} · ${s.itemCount} files`),
1759
+ ),
1760
+ h(
1761
+ 'span',
1762
+ { className: 'dshg-badge', 'data-tone': s.changedCount > 0 ? 'warn' : 'ok' },
1763
+ s.changedCount > 0 ? t.snapDiff(s.changedCount) : t.snapSame,
1764
+ ),
1765
+ ),
1766
+ h(
1767
+ 'div',
1768
+ { className: 'dshg-actions', style: { justifyContent: 'space-between', marginTop: 2 } },
1769
+ h(
1770
+ 'button',
1771
+ {
1772
+ type: 'button',
1773
+ className: 'dshg-btn dshg-btn-sm',
1774
+ onClick: () =>
1775
+ patch({
1776
+ expandedSnaps: { ...state.expandedSnaps, [s.id]: !expanded },
1777
+ }),
1778
+ },
1779
+ t.snapFilesToggle((s.files || []).length),
1780
+ ),
1781
+ s.restorableCount > 0
1782
+ ? h(
1783
+ 'button',
1784
+ {
1785
+ type: 'button',
1786
+ className: 'dshg-btn dshg-btn-primary dshg-btn-sm',
1787
+ disabled: Boolean(state.busyKey),
1788
+ onClick: () =>
1789
+ postAction(
1790
+ '/snapshots/restore-config',
1791
+ { snapshotId: s.id },
1792
+ `restore-${s.id}`,
1793
+ (res) => `已恢复 ${res.restoredFiles.length} 个配置文件(恢复前已自动备份 ${res.preRestoreId})`,
1794
+ ),
1795
+ },
1796
+ state.busyKey === `restore-${s.id}` ? t.snapRestoring : t.snapRestoreBtn,
1797
+ )
1798
+ : h('span', { className: 'dshg-sec-sub' }, t.snapDesktopOnlyTip),
1799
+ ),
1800
+ expanded
1801
+ ? h(
1802
+ 'div',
1803
+ { className: 'dshg-drawer' },
1804
+ s.files && s.files.length > 0
1805
+ ? s.files.map((f) =>
1806
+ h(
1807
+ 'div',
1808
+ { key: f.relPath || f.name, className: 'dshg-row' },
1809
+ h('span', { className: 'dshg-mono' }, f.relPath || f.name),
1810
+ h('span', { className: 'dshg-badge', 'data-tone': fileTone(f.status) }, fileStatusLabel(f.status)),
1811
+ ),
1812
+ )
1813
+ : h('div', { className: 'dshg-sec-sub' }, t.snapNoFiles),
1814
+ )
1815
+ : null,
1816
+ )
1817
+ }),
1818
+ )
1819
+ : h(
1820
+ 'div',
1821
+ { className: 'dshg-empty' },
1822
+ h('div', { style: { fontWeight: 600, fontSize: 12 } }, t.snapshotsEmpty),
1823
+ h('div', { style: { fontSize: 11, lineHeight: 1.5 } }, t.snapshotsEmptyDesc),
1824
+ ),
1825
+ ),
1250
1826
 
1251
- function renderDesktopCta(openLabel, downloadLabel) {
1252
- if (platform === 'win32' && guard.installed) {
1253
- return h(
1254
- 'button',
1255
- {
1256
- className: 'dshg-btn dshg-btn-primary',
1257
- disabled: snap.launching,
1258
- onClick: () => void launchDesktopGuard(),
1259
- },
1260
- h(SvgIcon, { name: 'window', size: 14 }),
1261
- snap.launching ? t.btnOpeningGuard : openLabel,
1262
- )
1263
- }
1264
- if (platform === 'win32') {
1265
- return h(
1266
- 'a',
1267
- {
1268
- className: 'dshg-btn dshg-btn-primary',
1269
- href: installerUrl,
1270
- target: '_blank',
1271
- rel: 'noopener noreferrer',
1272
- },
1273
- h(SvgIcon, { name: 'download', size: 14 }),
1274
- downloadLabel,
1275
- )
1276
- }
1277
- return h(
1278
- 'a',
1279
- {
1280
- className: 'dshg-btn',
1281
- href: repoUrl,
1282
- target: '_blank',
1283
- rel: 'noopener noreferrer',
1284
- },
1285
- h(SvgIcon, { name: 'external', size: 13 }),
1286
- t.btnViewRepo,
1827
+ h(BoundaryDisclosure, {
1828
+ summary: t.boundarySnapsSummary,
1829
+ p1: t.boundarySnapsP1,
1830
+ p2: t.boundarySnapsP2,
1831
+ isWin,
1832
+ installerUrl,
1833
+ releaseUrl,
1834
+ t,
1835
+ }),
1287
1836
  )
1288
- }
1289
1837
 
1290
1838
  return h(
1291
1839
  'div',
1292
- { className: 'dshg-root', 'data-variant': variant || 'dock' },
1293
-
1294
- // Brand Header Card
1840
+ { className: 'dshg-wrap', 'data-variant': (props && props.variant) || 'dock' },
1841
+ // Clean Header (zero install-nudge CTA when EXE is missing)
1295
1842
  h(
1296
1843
  'div',
1297
- { className: 'dshg-card' },
1844
+ { className: 'dshg-header' },
1298
1845
  h(
1299
1846
  'div',
1300
- { className: 'dshg-header' },
1847
+ { className: 'dshg-brand' },
1848
+ h('div', { className: 'dshg-logo' }, h(GuardIcon, { size: 16 })),
1301
1849
  h(
1302
1850
  'div',
1303
- { className: 'dshg-brand' },
1304
- h('div', { className: 'dshg-logo-wrap' }, h(GuardIcon, { size: 18, active: true })),
1851
+ { className: 'dshg-title-box' },
1305
1852
  h(
1306
1853
  'div',
1307
- null,
1308
- h(
1309
- 'div',
1310
- { className: 'dshg-title-row' },
1311
- h('span', { className: 'dshg-title' }, t.brand),
1312
- h('span', { className: 'dshg-ver' }, t.versionPill),
1313
- ),
1314
- h('div', { className: 'dshg-sub' }, t.subtitle),
1854
+ { className: 'dshg-title-row' },
1855
+ h('span', { className: 'dshg-title' }, t.brand),
1856
+ h('span', { className: 'dshg-ver' }, t.versionPill),
1315
1857
  ),
1858
+ h('div', { className: 'dshg-sub' }, t.subtitle),
1316
1859
  ),
1860
+ ),
1861
+ h(
1862
+ 'div',
1863
+ { className: 'dshg-actions' },
1864
+ guard.installed
1865
+ ? h(
1866
+ 'button',
1867
+ {
1868
+ type: 'button',
1869
+ className: 'dshg-btn',
1870
+ disabled: Boolean(state.busyKey),
1871
+ onClick: launchGuardDesktop,
1872
+ },
1873
+ h(ExternalIcon, { size: 12 }),
1874
+ h('span', null, state.busyKey === 'open-desktop' ? t.launchingBtn : t.openDesktopBtn),
1875
+ )
1876
+ : null,
1317
1877
  h(
1318
- 'div',
1319
- { className: 'dshg-actions' },
1320
- h(
1321
- 'button',
1322
- {
1323
- className: 'dshg-btn dshg-btn-icon',
1324
- disabled: snap.loading,
1325
- title: t.refresh,
1326
- 'aria-label': t.refresh,
1327
- onClick: () => void fetchOverview(),
1328
- },
1329
- h(SvgIcon, { name: 'refresh', size: 14, className: snap.loading ? 'dshg-spin' : '' }),
1330
- ),
1331
- h(
1332
- 'button',
1333
- {
1334
- className: 'dshg-btn',
1335
- onClick: () => patch({ lang: snap.lang === 'zh' ? 'en' : 'zh' }),
1336
- },
1337
- t.langSwitch,
1338
- ),
1878
+ 'button',
1879
+ {
1880
+ type: 'button',
1881
+ className: 'dshg-btn dshg-btn-icon',
1882
+ title: t.refresh,
1883
+ disabled: state.loading,
1884
+ onClick: () => fetchOverview(true),
1885
+ },
1886
+ h(RefreshIcon, { size: 13, className: state.loading ? 'dshg-spin' : undefined }),
1887
+ ),
1888
+ h(
1889
+ 'button',
1890
+ {
1891
+ type: 'button',
1892
+ className: 'dshg-btn',
1893
+ onClick: () => patch({ lang: state.lang === 'zh' ? 'en' : 'zh' }),
1894
+ },
1895
+ t.langSwitch,
1339
1896
  ),
1340
1897
  ),
1341
- health
1342
- ? h(
1343
- 'div',
1344
- { className: 'dshg-row' },
1345
- h(
1346
- 'span',
1347
- { className: 'dshg-badge', 'data-tone': health.healthy ? 'ok' : 'warn' },
1348
- h('span', { className: 'dshg-dot' }),
1349
- health.healthy ? t.healthy : t.unhealthy(health.issuesCount || 0),
1350
- ),
1351
- snap.checkedAt
1352
- ? h(
1353
- 'span',
1354
- { style: { fontSize: 11, color: 'var(--dshg-text-3)', fontVariantNumeric: 'tabular-nums' } },
1355
- t.checkedAt(formatClockOnly(snap.checkedAt)),
1356
- )
1357
- : null,
1358
- )
1359
- : null,
1360
1898
  ),
1361
1899
 
1362
- // Compact 3-Column KPI Strip
1900
+ state.error ? h('div', { className: 'dshg-error' }, state.error) : null,
1901
+ state.notice ? h('div', { className: 'dshg-notice' }, state.notice) : null,
1902
+
1903
+ // Status row
1904
+ data
1905
+ ? h(
1906
+ 'div',
1907
+ { className: 'dshg-row' },
1908
+ h(
1909
+ 'span',
1910
+ { className: 'dshg-badge', 'data-tone': healthy ? 'ok' : 'warn' },
1911
+ h('span', { className: 'dshg-dot' }),
1912
+ healthy ? t.healthy : t.unhealthy(issues.length),
1913
+ ),
1914
+ state.checkedAt
1915
+ ? h('span', { style: { fontSize: 11, color: 'var(--dshg-text-3)' } }, t.checkedAt(formatTimeShort(state.checkedAt)))
1916
+ : null,
1917
+ )
1918
+ : null,
1919
+
1920
+ // Interactive 4-KPI Strip
1363
1921
  data
1364
1922
  ? h(
1365
1923
  'div',
@@ -1367,281 +1925,103 @@ window.__ModuleLoader__.load({
1367
1925
  h(
1368
1926
  'button',
1369
1927
  {
1928
+ type: 'button',
1370
1929
  className: 'dshg-kpi',
1371
- 'data-active': snap.tab === 'overview' ? 'true' : 'false',
1930
+ 'data-active': state.tab === 'overview' ? 'true' : 'false',
1372
1931
  onClick: () => patch({ tab: 'overview' }),
1373
1932
  },
1374
- h('span', { className: 'dshg-kpi-label' }, t.kpiProfilesLabel),
1375
- h('span', { className: 'dshg-kpi-val' }, kpiProfilesText),
1376
- h('span', { className: 'dshg-kpi-sub' }, t.kpiProfilesSub),
1933
+ h('span', { className: 'dshg-kpi-label' }, t.kpiHealth),
1934
+ h('span', { className: 'dshg-kpi-val' }, healthy ? t.kpiHealthOk : t.kpiHealthWarn(issues.length)),
1377
1935
  ),
1378
1936
  h(
1379
1937
  'button',
1380
1938
  {
1939
+ type: 'button',
1381
1940
  className: 'dshg-kpi',
1382
- 'data-active': snap.tab === 'creds' ? 'true' : 'false',
1383
- onClick: () => patch({ tab: 'creds' }),
1941
+ 'data-active': state.tab === 'plugins' ? 'true' : 'false',
1942
+ onClick: () => patch({ tab: 'plugins' }),
1384
1943
  },
1385
- h('span', { className: 'dshg-kpi-label' }, t.kpiCredsLabel),
1386
- h('span', { className: 'dshg-kpi-val' }, kpiCredsText),
1387
- h('span', { className: 'dshg-kpi-sub' }, t.kpiCredsSub),
1944
+ h('span', { className: 'dshg-kpi-label' }, t.kpiExt),
1945
+ h('span', { className: 'dshg-kpi-val' }, String(totalExtCount)),
1388
1946
  ),
1389
1947
  h(
1390
1948
  'button',
1391
1949
  {
1950
+ type: 'button',
1392
1951
  className: 'dshg-kpi',
1393
- 'data-active': snap.tab === 'snapshots' ? 'true' : 'false',
1394
- onClick: () => patch({ tab: 'snapshots' }),
1395
- },
1396
- h('span', { className: 'dshg-kpi-label' }, t.kpiSnapsLabel),
1397
- h('span', { className: 'dshg-kpi-val' }, kpiSnapsText),
1398
- h('span', { className: 'dshg-kpi-sub' }, t.kpiSnapsSub),
1399
- ),
1400
- )
1401
- : null,
1402
-
1403
- // Segmented Control Tabs
1404
- data
1405
- ? h(
1406
- 'div',
1407
- { className: 'dshg-seg', role: 'tablist' },
1408
- h(
1409
- 'button',
1410
- {
1411
- className: 'dshg-seg-btn',
1412
- role: 'tab',
1413
- 'aria-selected': snap.tab === 'overview',
1414
- 'data-active': snap.tab === 'overview' ? 'true' : 'false',
1415
- onClick: () => patch({ tab: 'overview' }),
1416
- },
1417
- t.tabOverview,
1418
- hasProfileIssues ? h('span', { className: 'dshg-seg-dot' }) : null,
1419
- ),
1420
- h(
1421
- 'button',
1422
- {
1423
- className: 'dshg-seg-btn',
1424
- role: 'tab',
1425
- 'aria-selected': snap.tab === 'creds',
1426
- 'data-active': snap.tab === 'creds' ? 'true' : 'false',
1952
+ 'data-active': state.tab === 'creds' ? 'true' : 'false',
1427
1953
  onClick: () => patch({ tab: 'creds' }),
1428
1954
  },
1429
- t.tabCreds,
1430
- hasMissingCreds ? h('span', { className: 'dshg-seg-dot' }) : null,
1955
+ h('span', { className: 'dshg-kpi-label' }, t.kpiCreds),
1956
+ h('span', { className: 'dshg-kpi-val' }, credsSummaryVal),
1431
1957
  ),
1432
1958
  h(
1433
1959
  'button',
1434
1960
  {
1435
- className: 'dshg-seg-btn',
1436
- role: 'tab',
1437
- 'aria-selected': snap.tab === 'snapshots',
1438
- 'data-active': snap.tab === 'snapshots' ? 'true' : 'false',
1961
+ type: 'button',
1962
+ className: 'dshg-kpi',
1963
+ 'data-active': state.tab === 'snapshots' ? 'true' : 'false',
1439
1964
  onClick: () => patch({ tab: 'snapshots' }),
1440
1965
  },
1441
- t.tabSnapshots,
1966
+ h('span', { className: 'dshg-kpi-label' }, t.kpiSnaps),
1967
+ h('span', { className: 'dshg-kpi-val' }, String(snapshots.total || 0)),
1442
1968
  ),
1443
1969
  )
1444
1970
  : null,
1445
1971
 
1446
- snap.error ? h('div', { className: 'dshg-error' }, snap.error) : null,
1447
- snap.notice ? h('div', { className: 'dshg-notice' }, snap.notice) : null,
1448
-
1449
- !data && snap.loading
1450
- ? h('div', { className: 'dshg-card', style: { color: 'var(--dshg-text-2)' } }, t.loading)
1451
- : null,
1452
-
1453
- // TAB 1: Overview
1454
- data && snap.tab === 'overview'
1455
- ? [
1456
- h(SupervisorCard, {
1457
- key: 'supervisor',
1458
- platform,
1459
- guard,
1460
- installerUrl,
1461
- releaseUrl,
1462
- repoUrl,
1463
- launching: snap.launching,
1464
- t,
1465
- }),
1466
- health && profiles.length > 0
1467
- ? h(
1468
- 'div',
1469
- { key: 'profiles', className: 'dshg-card' },
1470
- h('div', { className: 'dshg-sec-head' }, h('span', null, t.profilesTitle)),
1471
- h(
1472
- 'div',
1473
- { className: 'dshg-profile-grid' },
1474
- ...profiles.map((p) => h(ProfileSubcard, { key: p.target, profile: p, t })),
1475
- ),
1476
- )
1477
- : null,
1478
- hasProfileIssues
1479
- ? h(
1480
- 'div',
1481
- { key: 'issues', className: 'dshg-card' },
1482
- h(
1483
- 'div',
1484
- { className: 'dshg-sec-head' },
1485
- h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6, color: '#f59e0b' } }, h(SvgIcon, { name: 'alert', size: 14 }), t.issuesTitle),
1486
- ),
1487
- ...health.issues.map((issue, idx) =>
1488
- h('div', { key: idx, style: { fontSize: 11.5, color: '#f59e0b', wordBreak: 'break-word' } }, `• ${issue}`),
1489
- ),
1490
- platform === 'win32'
1491
- ? renderDesktopCta(t.issueActionOpen, t.issueActionDownload)
1492
- : null,
1493
- )
1494
- : null,
1495
- ]
1496
- : null,
1497
-
1498
- // TAB 2: Masked Credentials Readiness
1499
- data && snap.tab === 'creds' && health
1500
- ? [
1501
- h(
1502
- 'div',
1503
- { key: 'cred-status', className: 'dshg-card' },
1972
+ // Segmented 4-Tab Bar
1973
+ data
1974
+ ? h(
1975
+ 'div',
1976
+ { className: 'dshg-seg' },
1977
+ ...[
1978
+ ['overview', t.tabOverview],
1979
+ ['plugins', t.tabPlugins],
1980
+ ['creds', t.tabCreds],
1981
+ ['snapshots', t.tabSnapshots],
1982
+ ].map(([id, label]) =>
1504
1983
  h(
1505
- 'div',
1506
- { className: 'dshg-sec-head' },
1507
- h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } }, h(SvgIcon, { name: 'key', size: 14 }), t.credsTitle),
1508
- h(
1509
- 'span',
1510
- { className: 'dshg-badge', 'data-tone': creds.fileExists && !hasMissingCreds ? 'ok' : creds.fileExists ? 'warn' : 'muted' },
1511
- creds.fileExists
1512
- ? t.credReadyBadge(kpiCredsReady, kpiCredsTotal)
1513
- : t.credMissingFile,
1514
- ),
1984
+ 'button',
1985
+ {
1986
+ key: id,
1987
+ type: 'button',
1988
+ className: 'dshg-seg-btn',
1989
+ 'data-active': state.tab === id ? 'true' : 'false',
1990
+ onClick: () => patch({ tab: id }),
1991
+ },
1992
+ label,
1515
1993
  ),
1516
- h('div', { className: 'dshg-sec-sub' }, t.credsPrivacyHint),
1517
- creds.fileExists
1518
- ? h(
1519
- 'div',
1520
- { className: 'dshg-progress-wrap' },
1521
- h(
1522
- 'div',
1523
- { className: 'dshg-row', style: { fontSize: 11, color: 'var(--dshg-text-2)' } },
1524
- h(
1525
- 'span',
1526
- null,
1527
- refKeys.length > 0
1528
- ? t.credProgressPatch(refReadyCount, refKeys.length)
1529
- : t.credProgressFile(creds.nonEmptyKeysCount || 0, creds.totalKeysCount || 0),
1530
- ),
1531
- h('span', { style: { fontVariantNumeric: 'tabular-nums' } }, `${credRatioPct}%`),
1532
- ),
1533
- h(
1534
- 'div',
1535
- { className: 'dshg-progress-track' },
1536
- h('div', { className: 'dshg-progress-fill', style: { width: `${credRatioPct}%` } }),
1537
- ),
1538
- )
1539
- : null,
1540
- refKeys.length > 0
1541
- ? h(
1542
- 'div',
1543
- { className: 'dshg-cred-list' },
1544
- ...refKeys.map((item) =>
1545
- h(
1546
- 'div',
1547
- { key: item.key, className: 'dshg-cred-item' },
1548
- h(
1549
- 'span',
1550
- { className: 'dshg-cred-key' },
1551
- h(SvgIcon, { name: 'key', size: 12 }),
1552
- item.key,
1553
- ),
1554
- h(
1555
- 'span',
1556
- { className: 'dshg-badge', 'data-tone': item.ready ? 'ok' : 'warn' },
1557
- h(SvgIcon, { name: item.ready ? 'check' : 'alert', size: 11 }),
1558
- item.ready ? t.credStatusReady : t.credStatusMissing,
1559
- ),
1560
- ),
1561
- ),
1562
- )
1563
- : h('div', { className: 'dshg-sec-sub' }, t.credNoRefs),
1564
1994
  ),
1565
- h(
1566
- 'div',
1567
- { key: 'cred-upsell', className: 'dshg-card dshg-card-spotlight' },
1568
- h('div', { className: 'dshg-sec-head' }, h('span', null, t.credUpsellTitle)),
1569
- h('div', { className: 'dshg-sec-sub' }, t.credUpsellDesc),
1570
- renderDesktopCta(t.credUpsellOpen, t.credUpsellDownload),
1571
- ),
1572
- ]
1995
+ )
1573
1996
  : null,
1574
1997
 
1575
- // TAB 3: Snapshots Timeline
1576
- data && snap.tab === 'snapshots' && snapshots
1998
+ !data && state.loading
1999
+ ? h('div', { className: 'dshg-card', style: { fontSize: 12, color: 'var(--dshg-text-2)' } }, t.loading)
2000
+ : null,
2001
+
2002
+ !data && !state.loading && state.error
1577
2003
  ? h(
1578
2004
  'div',
1579
- { className: 'dshg-card' },
1580
- h(
1581
- 'div',
1582
- { className: 'dshg-sec-head' },
1583
- h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 6 } }, h(SvgIcon, { name: 'clock', size: 14 }), t.snapshotsTitle),
1584
- h('span', { className: 'dshg-badge', 'data-tone': 'muted' }, t.snapshotsTotal(snapshots.total || 0)),
1585
- ),
1586
- snapList.length > 0
1587
- ? [
1588
- h(
1589
- 'div',
1590
- { key: 'list', className: 'dshg-timeline' },
1591
- ...snapList.slice(0, 10).map((s) =>
1592
- h(
1593
- 'div',
1594
- { key: s.id, className: 'dshg-snap-item' },
1595
- h(
1596
- 'div',
1597
- { className: 'dshg-snap-head' },
1598
- h(
1599
- 'span',
1600
- { className: 'dshg-snap-title' },
1601
- h('span', {
1602
- className: 'dshg-track-dot',
1603
- style: { background: s.target === 'desktop' ? '#22c55e' : '#3b82f6' },
1604
- }),
1605
- s.reason || t.snapNoReason,
1606
- ),
1607
- h(
1608
- 'span',
1609
- { className: 'dshg-badge', 'data-tone': s.target === 'desktop' ? 'ok' : 'blue' },
1610
- s.target === 'desktop' ? t.desktopTrack : t.webTrack,
1611
- ),
1612
- ),
1613
- h(
1614
- 'div',
1615
- { className: 'dshg-row', style: { fontSize: 11, color: 'var(--dshg-text-2)' } },
1616
- h('span', null, t.snapItems(s.itemCount || 0)),
1617
- h('span', { style: { fontVariantNumeric: 'tabular-nums' } }, formatShortTime(s.createdAt)),
1618
- ),
1619
- h('div', { className: 'dshg-mono' }, s.id),
1620
- ),
1621
- ),
1622
- ),
1623
- h('div', { key: 'snap-cta' }, renderDesktopCta(t.snapActionOpen, t.snapActionDownload)),
1624
- ]
1625
- : h(
1626
- 'div',
1627
- { className: 'dshg-empty' },
1628
- h('div', { style: { color: 'var(--dshg-text-2)' } }, h(SvgIcon, { name: 'clock', size: 22 })),
1629
- h('div', { style: { fontWeight: 600, fontSize: 12, color: 'var(--dshg-text)' } }, t.snapshotsEmptyTitle),
1630
- h('div', { style: { fontSize: 11, lineHeight: 1.5 } }, t.snapshotsEmptyDesc),
1631
- renderDesktopCta(t.snapActionOpen, t.snapActionDownload),
1632
- ),
2005
+ { className: 'dshg-empty' },
2006
+ h('div', { style: { fontSize: 12 } }, state.error),
2007
+ h('button', { type: 'button', className: 'dshg-btn', onClick: () => fetchOverview(true) }, t.retry),
1633
2008
  )
1634
2009
  : null,
1635
2010
 
1636
- // Subtle Footer
2011
+ data && state.tab === 'overview' ? renderOverviewTab() : null,
2012
+ data && state.tab === 'plugins' ? renderPluginsTab() : null,
2013
+ data && state.tab === 'creds' ? renderCredsTab() : null,
2014
+ data && state.tab === 'snapshots' ? renderSnapshotsTab() : null,
2015
+
1637
2016
  h(
1638
2017
  'div',
1639
2018
  { className: 'dshg-footer' },
1640
2019
  h('span', null, t.footerNote),
1641
2020
  h(
1642
- 'a',
1643
- { href: repoUrl, target: '_blank', rel: 'noopener noreferrer' },
1644
- t.footerHome,
2021
+ 'div',
2022
+ { style: { display: 'flex', gap: 10 } },
2023
+ h('a', { href: releaseUrl, target: '_blank', rel: 'noopener noreferrer' }, 'Releases'),
2024
+ h('a', { href: repoUrl, target: '_blank', rel: 'noopener noreferrer' }, t.footerHome),
1645
2025
  ),
1646
2026
  ),
1647
2027
  )