dsh-config-manager 0.4.1 → 0.4.3
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/README.md +14 -0
- package/lib/cli/actions.js +2 -3
- package/lib/cli/import-source.js +2 -6
- package/lib/cli/index.js +2 -3
- package/lib/client.d.ts +5 -5
- package/lib/client.js +26250 -25872
- package/lib/core/access-mode.d.ts +25 -0
- package/lib/core/access-mode.js +28 -0
- package/lib/core/exporter.js +2 -4
- package/lib/core/host-schedulers/cache-cleanup.d.ts +41 -0
- package/lib/core/host-schedulers/cache-cleanup.js +45 -0
- package/lib/core/host-schedulers/lifecycle-hooks.d.ts +51 -0
- package/lib/core/host-schedulers/lifecycle-hooks.js +78 -0
- package/lib/core/host-schedulers/market-cache.d.ts +40 -0
- package/lib/core/host-schedulers/market-cache.js +92 -0
- package/lib/core/model-tools.js +2 -6
- package/lib/core/restore.d.ts +0 -2
- package/lib/core/restore.js +16 -18
- package/lib/core/verify-recovery.js +4 -7
- package/lib/index.d.ts +3 -22
- package/lib/index.js +74 -330
- package/lib/profiles/dsh-profile-manager.d.ts +23 -1
- package/lib/profiles/dsh-profile-manager.js +70 -2
- package/lib/routes/kit.d.ts +61 -1
- package/lib/routes/kit.js +72 -3
- package/lib/routes/prefs.js +6 -6
- package/lib/routes/recovery.js +25 -41
- package/lib/routes/request-trust.d.ts +28 -0
- package/lib/routes/request-trust.js +65 -0
- package/lib/routes/route-support.d.ts +23 -1
- package/lib/routes/route-support.js +185 -0
- package/lib/routes/snapshots.js +4 -11
- package/lib/routes/sync.js +5 -7
- package/lib/security/redaction.d.ts +5 -1
- package/lib/security/redaction.js +26 -23
- package/lib/sync/backup-scheduler.js +2 -6
- package/lib/ui/backup-inspect.d.ts +1 -1
- package/lib/ui/dsh-profiles-view.d.ts +0 -10
- package/lib/ui/dsh-profiles-view.js +3 -7
- package/lib/ui/snapshots-view.d.ts +0 -14
- package/lib/ui/snapshots-view.js +16 -2
- package/lib/utils/paths.d.ts +20 -4
- package/lib/utils/paths.js +22 -6
- package/lib/utils/time.d.ts +31 -0
- package/lib/utils/time.js +54 -0
- package/package.json +1 -1
- package/src/cli/actions.ts +2 -3
- package/src/cli/import-source.ts +2 -7
- package/src/cli/index.ts +2 -3
- package/src/client/about/AboutPanel.tsx +8 -1
- package/src/client/about/ReleaseBody.tsx +22 -52
- package/src/client/about/ReleaseNotesDialog.tsx +15 -69
- package/src/client/about/release-notes-view.ts +4 -11
- package/src/client/common/access-mode.ts +21 -0
- package/src/client/common/info-hint-guard.test.ts +11 -5
- package/src/client/common/ui.tsx +23 -0
- package/src/client/config-manager.module.css +201 -32
- package/src/client/css-token-guard.test.ts +135 -1
- package/src/client/home/HomePanel.tsx +31 -6
- package/src/client/import/ConflictList.tsx +3 -3
- package/src/client/import/ImportWizardView.tsx +1 -1
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/RestorePlanView.tsx +21 -9
- package/src/client/library/report-dismiss.test.ts +5 -3
- package/src/client/locales/about.ts +103 -0
- package/src/client/locales/backup.ts +141 -0
- package/src/client/locales/common.ts +113 -0
- package/src/client/locales/export.ts +184 -0
- package/src/client/locales/foreign.ts +184 -0
- package/src/client/locales/import-compat.ts +32 -0
- package/src/client/locales/import.ts +192 -0
- package/src/client/locales/next-steps.ts +25 -0
- package/src/client/locales/overview-control.ts +32 -0
- package/src/client/locales/overview.ts +153 -0
- package/src/client/locales/profiles.ts +263 -0
- package/src/client/locales/report.ts +17 -0
- package/src/client/locales/restore.ts +132 -0
- package/src/client/locales/sessions.ts +257 -0
- package/src/client/locales/shell.ts +149 -0
- package/src/client/locales.ts +49 -1783
- package/src/client/market/MarketImportReview.tsx +2 -2
- package/src/client/market/MarketPanel.tsx +1 -1
- package/src/client/market/market-view.ts +3 -5
- package/src/client/recovery/RecoveryPanel.tsx +62 -1054
- package/src/client/recovery/SessionHealthCard.tsx +134 -0
- package/src/client/recovery/SessionHealthDialog.tsx +665 -0
- package/src/client/recovery/SessionLayoutSection.tsx +284 -0
- package/src/client/recovery/recovery-api.ts +10 -1
- package/src/client/recovery/recovery-panel-layout.test.ts +20 -5
- package/src/client/recovery/session-dialog-mount.test.ts +16 -9
- package/src/client/recovery/use-recovery-write.test.ts +90 -0
- package/src/client/recovery/use-recovery-write.ts +53 -0
- package/src/client/run-store.ts +57 -2
- package/src/client/sync/PushPreviewCard.tsx +2 -2
- package/src/client/sync/SyncConfirmView.tsx +5 -5
- package/src/client/sync/SyncLogList.tsx +2 -2
- package/src/client/sync/history-model.ts +4 -5
- package/src/client/sync/sync-view.ts +3 -4
- package/src/core/access-mode.ts +37 -0
- package/src/core/exporter.ts +2 -4
- package/src/core/host-schedulers/cache-cleanup.test.ts +84 -0
- package/src/core/host-schedulers/cache-cleanup.ts +74 -0
- package/src/core/host-schedulers/lifecycle-hooks.test.ts +111 -0
- package/src/core/host-schedulers/lifecycle-hooks.ts +118 -0
- package/src/core/host-schedulers/market-cache.test.ts +93 -0
- package/src/core/host-schedulers/market-cache.ts +116 -0
- package/src/core/model-tools.ts +2 -7
- package/src/core/restore-failure-state.test.ts +210 -0
- package/src/core/restore.ts +16 -18
- package/src/core/verify-recovery.ts +4 -7
- package/src/index.ts +81 -335
- package/src/profiles/dsh-profile-copy-rollback.test.ts +156 -0
- package/src/profiles/dsh-profile-manager.ts +71 -3
- package/src/routes/kit.ts +106 -3
- package/src/routes/prefs.ts +6 -6
- package/src/routes/recovery.ts +25 -42
- package/src/routes/request-trust.ts +97 -0
- package/src/routes/route-support.ts +208 -1
- package/src/routes/snapshots.ts +4 -9
- package/src/routes/sync.ts +4 -7
- package/src/security/redaction.ts +29 -23
- package/src/sync/backup-scheduler.ts +3 -6
- package/src/sync/sync-config.test.ts +24 -13
- package/src/ui/backup-inspect.ts +1 -1
- package/src/ui/dsh-profiles-view.ts +3 -5
- package/src/ui/i18n.test.ts +8 -3
- package/src/ui/snapshots-view.ts +2 -2
- package/src/utils/paths.test.ts +36 -1
- package/src/utils/paths.ts +30 -6
- package/src/utils/time.test.ts +46 -0
- package/src/utils/time.ts +55 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「会话体检」入口卡(T5/T10)—— 从 RecoveryPanel.tsx 拆出的独立文件(tech-debt #7)。
|
|
3
|
+
*
|
|
4
|
+
* 职责边界:卡片只留入口与一行摘要,整屏结果与全部动作都在 SessionHealthDialog。
|
|
5
|
+
* 弹窗**只在打开时挂载**是刻意的:常驻会让卡片每次重渲染都拖着整屏内容一起走(真机反馈是整个设置页变空白)。
|
|
6
|
+
* 本卡片不做业务判断:严重级 / 摘要 / 空态 / 截断全在 `ui/session-inventory-view.ts` 的纯函数里,
|
|
7
|
+
* 拆分前后渲染分支逐字未改。
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useRef, useState } from 'react'
|
|
10
|
+
import type { TranslateNS } from '../client-types.ts'
|
|
11
|
+
import { Badge, Button, Card } from '../common/ui.tsx'
|
|
12
|
+
import { InfoHint } from '../common/InfoHint.tsx'
|
|
13
|
+
import { sessionHealthSummaryView, sessionRepairEntries, type SessionHealthResponse } from '../../ui/session-inventory-view.ts'
|
|
14
|
+
import type { SessionExportProbe } from '../session-export/session-export-view.ts'
|
|
15
|
+
import type { LayoutRecoveryApi } from './recovery-api.ts'
|
|
16
|
+
import { SessionHealthDialog } from './SessionHealthDialog.tsx'
|
|
17
|
+
import css from '../config-manager.module.css'
|
|
18
|
+
|
|
19
|
+
/** 卡片 props:与拆分前 `Pick<RecoveryPanelProps, ...>` 等价(面板只透传这四项)。 */
|
|
20
|
+
export interface SessionHealthCardProps {
|
|
21
|
+
recoveryApi: LayoutRecoveryApi
|
|
22
|
+
t: TranslateNS<'config-manager-recovery'>
|
|
23
|
+
copyT?: TranslateNS<'config-manager'>
|
|
24
|
+
diskApi: import('../api.ts').ConfigManagerApi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 「会话体检」区块(T5)—— 事故恢复子 tab 的只读扫描。
|
|
29
|
+
*
|
|
30
|
+
* 数据流:`recoveryApi.sessions()`(只读路由)→ `ui/session-inventory-view.ts` 的展示模型 → 渲染。
|
|
31
|
+
* **本组件不做任何业务判断**(严重级/摘要/空态/截断全在纯函数里),只装配 + 交互状态。
|
|
32
|
+
*
|
|
33
|
+
* 硬约束(known-gaps G-24 / T8 / T9):应用内只做**能从字节证明**的修复 —— 零损失(重放重复行 /
|
|
34
|
+
* 可证明的合成收尾块)与**有损截断**(seq 空洞 / 不可解析行,必须用户显式确认);
|
|
35
|
+
* 每一条都过服务层的写入门与预览-应用指纹,另有备份可一键回滚。其余类别只提供「复制离线命令」。
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* 缺省剪贴板翻译器:本区块只用到「复制成功/失败」两条通用反馈,且**绝不**编造主字典之外的键。
|
|
39
|
+
* 返回键名本身(与字典缺键时的回退语义一致),保证缺省路径也不会抛错或渲染出空文案。
|
|
40
|
+
*/
|
|
41
|
+
const EMPTY_COPY_T: TranslateNS<'config-manager'> = ((key: string) => key) as TranslateNS<'config-manager'>
|
|
42
|
+
export function SessionHealthCard({ recoveryApi, t, copyT, diskApi }: SessionHealthCardProps) {
|
|
43
|
+
/**
|
|
44
|
+
* 剪贴板反馈的翻译器(config-manager 命名空间)。缺省 = `EMPTY_COPY_T`(**返回键名本身**,
|
|
45
|
+
* 与字典缺键的回退语义一致)—— 不传 copyT 时渲染的是键名,缺省路径不会出现中文。
|
|
46
|
+
*/
|
|
47
|
+
const clipboardT = copyT ?? EMPTY_COPY_T
|
|
48
|
+
/** 体检结果住**卡片**里:弹窗每次打开重新扫一遍(scanVersion 变化即重扫),关掉不留一屏陈旧数据。 */
|
|
49
|
+
const [response, setResponse] = useState<SessionHealthResponse | null>(null)
|
|
50
|
+
const [loading, setLoading] = useState(false)
|
|
51
|
+
const [error, setError] = useState<string | null>(null)
|
|
52
|
+
const [open, setOpen] = useState(false)
|
|
53
|
+
const [scanVersion, setScanVersion] = useState(0)
|
|
54
|
+
const scan = (): void => { setScanVersion((v) => v + 1) }
|
|
55
|
+
/**
|
|
56
|
+
* F-2:官方 session.export 端的可用性探测(一次;打开弹窗时顺带探)。
|
|
57
|
+
*
|
|
58
|
+
* 为什么**只在打开弹窗时**探:探测要走一次宿主自请求,用户没进这个界面时毫无意义;
|
|
59
|
+
* 而进程内缓存(setState 在卡片上)保证同一次对话里只探一次 —— 后端能力不会中途变化。
|
|
60
|
+
* 探测失败(网络/宿主异常)**不写 error**:它是「下载入口的可用性未知」,不是体检失败。
|
|
61
|
+
*/
|
|
62
|
+
const [zipProbe, setZipProbe] = useState<SessionExportProbe | null>(null)
|
|
63
|
+
const zipChecked = useRef(false)
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!open || zipChecked.current) return
|
|
66
|
+
zipChecked.current = true
|
|
67
|
+
let alive = true
|
|
68
|
+
diskApi.sessionExportProbe()
|
|
69
|
+
.then((probe) => { if (alive) setZipProbe(probe) })
|
|
70
|
+
// 探测本身失败(宿主不可达等)→ 落到保守三态:**绝不**改判成不可用而把入口藏掉。
|
|
71
|
+
.catch(() => { if (alive) setZipProbe({ availability: 'unknown', reason: 'network-error', status: 0, path: '', checkedAt: new Date().toISOString() }) })
|
|
72
|
+
return () => { alive = false }
|
|
73
|
+
}, [open, diskApi])
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!open) return
|
|
77
|
+
let alive = true
|
|
78
|
+
setLoading(true)
|
|
79
|
+
setError(null)
|
|
80
|
+
recoveryApi.sessions()
|
|
81
|
+
.then((next) => { if (alive) { setResponse(next); setLoading(false) } })
|
|
82
|
+
.catch((err) => { if (alive) { setError(err instanceof Error ? err.message : String(err)); setLoading(false) } })
|
|
83
|
+
return () => { alive = false }
|
|
84
|
+
}, [open, scanVersion, recoveryApi])
|
|
85
|
+
|
|
86
|
+
const summary = sessionHealthSummaryView(response)
|
|
87
|
+
const repairEntries = sessionRepairEntries(response)
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Card className={css.card}>
|
|
91
|
+
<div className={css.statRow}>
|
|
92
|
+
<strong>{t('sessions.title')}</strong>
|
|
93
|
+
{/* 徽章语义:扫描只读;修复是显式动作(预览 → 确认 → 自动备份 → 可回滚) */}
|
|
94
|
+
<Badge kind="info">{t('sessions.readOnly')}</Badge>
|
|
95
|
+
<InfoHint text={t('sessions.desc')} label={t('common.infoHint')} />
|
|
96
|
+
<span className={css.statusSpacer} />
|
|
97
|
+
</div>
|
|
98
|
+
{/* T10:结果全部搬进独立弹窗 —— 卡片只留入口与一行摘要,绝不把上千行塞进设置页。
|
|
99
|
+
2026-10-12 用户要求:本卡**退出折叠**,入口与摘要常驻可见(不再有 chevron)。 */}
|
|
100
|
+
{/* 2026-10-12 用户要求:预扫描说明文案已删(点按钮即扫,屏上只留真正的摘要)。 */}
|
|
101
|
+
{summary !== null && response !== null && (
|
|
102
|
+
<div className={css.statRow}>
|
|
103
|
+
<Badge kind="info">{t('sessions.dialog.lastScan.total', { count: String(summary.total) })}</Badge>
|
|
104
|
+
<Badge kind={summary.needsAttention > 0 ? 'warn' : 'ok'}>{t('sessions.dialog.lastScan.issues', { count: String(summary.needsAttention) })}</Badge>
|
|
105
|
+
{repairEntries.length > 0 && <Badge kind="info">{t('sessions.dialog.lastScan.repairs', { count: String(repairEntries.length) })}</Badge>}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
<div className={css.actionRow}>
|
|
109
|
+
<Button variant="ghost" loading={loading} onClick={() => { setOpen(true) }}>
|
|
110
|
+
{loading ? t('sessions.scanning') : t('sessions.dialog.open')}
|
|
111
|
+
</Button>
|
|
112
|
+
</div>
|
|
113
|
+
{/*
|
|
114
|
+
弹窗**只在打开时挂载**:它是整屏内容的组件,常驻会让卡片每次重渲染都带着它一起走
|
|
115
|
+
(真机反馈:弹窗加载一会儿后整个设置页变空白)。关闭即卸载,状态随之释放。
|
|
116
|
+
*/}
|
|
117
|
+
{open && (
|
|
118
|
+
<SessionHealthDialog
|
|
119
|
+
open={open}
|
|
120
|
+
onClose={() => { setOpen(false) }}
|
|
121
|
+
recoveryApi={recoveryApi}
|
|
122
|
+
t={t}
|
|
123
|
+
clipboardT={clipboardT}
|
|
124
|
+
response={response}
|
|
125
|
+
loading={loading}
|
|
126
|
+
error={error}
|
|
127
|
+
onScan={scan}
|
|
128
|
+
zipProbe={zipProbe}
|
|
129
|
+
api={diskApi}
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
132
|
+
</Card>
|
|
133
|
+
)
|
|
134
|
+
}
|