dsh-config-manager 0.9.0 → 0.10.0

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.
Files changed (150) hide show
  1. package/lib/adapters/mcp.js +9 -2
  2. package/lib/adapters/plugins.js +65 -10
  3. package/lib/adapters/prompts.js +15 -4
  4. package/lib/adapters/test-helpers.d.ts +15 -1
  5. package/lib/adapters/test-helpers.js +11 -0
  6. package/lib/cli/help.d.ts +1 -1
  7. package/lib/cli/help.js +21 -14
  8. package/lib/cli/index.js +118 -104
  9. package/lib/cli/sessions-repair.js +58 -22
  10. package/lib/cli/web/client-script.d.ts +1 -1
  11. package/lib/cli/web/client-script.js +71 -5
  12. package/lib/cli/web/page.d.ts +9 -19
  13. package/lib/cli/web/page.js +277 -173
  14. package/lib/cli/web/routes.js +85 -25
  15. package/lib/client.d.ts +93 -27
  16. package/lib/client.js +11461 -11339
  17. package/lib/core/messages.d.ts +10 -0
  18. package/lib/core/messages.js +20 -0
  19. package/lib/core/model-tools.js +7 -1
  20. package/lib/core/patch-chain.d.ts +65 -0
  21. package/lib/core/patch-chain.js +100 -0
  22. package/lib/core/patch-document.d.ts +32 -4
  23. package/lib/core/patch-document.js +48 -17
  24. package/lib/core/patch-secret-guard.d.ts +1 -1
  25. package/lib/core/patch-secret-guard.js +1 -1
  26. package/lib/core/types.d.ts +16 -1
  27. package/lib/index.d.ts +9 -4
  28. package/lib/index.js +42 -47
  29. package/lib/routes/sync.js +6 -0
  30. package/lib/sync/autosync-scheduler.d.ts +13 -1
  31. package/lib/sync/autosync-scheduler.js +73 -17
  32. package/lib/sync/local-changes.d.ts +15 -0
  33. package/lib/sync/local-changes.js +39 -0
  34. package/lib/sync/merge-keyed.d.ts +68 -0
  35. package/lib/sync/merge-keyed.js +124 -0
  36. package/lib/sync/patch-line-identity.d.ts +19 -0
  37. package/lib/sync/patch-line-identity.js +99 -0
  38. package/lib/sync/pending-merge.d.ts +8 -1
  39. package/lib/sync/pending-merge.js +13 -5
  40. package/lib/sync/plugin-removals.d.ts +15 -15
  41. package/lib/sync/plugin-removals.js +134 -83
  42. package/lib/sync/push-skip.d.ts +55 -0
  43. package/lib/sync/push-skip.js +70 -0
  44. package/lib/sync/sync-engine.d.ts +22 -12
  45. package/lib/sync/sync-engine.js +53 -70
  46. package/lib/sync/workspace-merge.d.ts +8 -2
  47. package/lib/ui/artifact-view.d.ts +1 -1
  48. package/lib/ui/foreign-view.d.ts +14 -0
  49. package/lib/ui/foreign-view.js +34 -0
  50. package/lib/ui/i18n.d.ts +5 -0
  51. package/lib/ui/i18n.js +11 -0
  52. package/lib/ui/selection-model.d.ts +2 -2
  53. package/lib/ui/selection-model.js +7 -3
  54. package/lib/utils/async-once.d.ts +11 -0
  55. package/lib/utils/async-once.js +15 -0
  56. package/lib/utils/patch-chain-read.d.ts +51 -0
  57. package/lib/utils/patch-chain-read.js +240 -0
  58. package/package.json +2 -2
  59. package/src/adapters/mcp.ts +9 -2
  60. package/src/adapters/plugins.test.ts +115 -0
  61. package/src/adapters/plugins.ts +64 -11
  62. package/src/adapters/prompts.ts +15 -4
  63. package/src/adapters/test-helpers.ts +15 -1
  64. package/src/cli/help.ts +21 -14
  65. package/src/cli/index.ts +105 -107
  66. package/src/cli/sessions-repair.ts +55 -22
  67. package/src/cli/web/client-script.ts +71 -5
  68. package/src/cli/web/page.ts +327 -208
  69. package/src/cli/web/routes.ts +85 -25
  70. package/src/cli/web/web.test.ts +38 -0
  71. package/src/client/ConfigManagerSection.tsx +8 -4
  72. package/src/client/about/AboutPanel.tsx +2 -6
  73. package/src/client/api.ts +2 -1
  74. package/src/client/common/ContentPicker.tsx +11 -12
  75. package/src/client/common/plan-text-redaction.test.ts +2 -2
  76. package/src/client/config-manager.module.css +10 -0
  77. package/src/client/environment/EnvironmentPanel.tsx +2 -4
  78. package/src/client/environment/maintenance/DiskUsageCard.tsx +4 -5
  79. package/src/client/home/BackupScheduleCard.tsx +52 -49
  80. package/src/client/home/HomePanel.tsx +2 -2
  81. package/src/client/import/ForeignImportView.tsx +60 -3
  82. package/src/client/import/ImportWizardView.tsx +2 -1
  83. package/src/client/import/PathMappingForm.tsx +32 -5
  84. package/src/client/import/import-wizard-split.test.ts +1 -1
  85. package/src/client/library/BackupInspectView.tsx +4 -2
  86. package/src/client/library/LibraryActions.tsx +60 -12
  87. package/src/client/library/LibraryPanel.tsx +9 -10
  88. package/src/client/locales/backup.ts +5 -0
  89. package/src/client/locales/foreign.ts +2 -0
  90. package/src/client/locales/import.ts +2 -0
  91. package/src/client/locales/restore.ts +2 -0
  92. package/src/client/market/MarketImportReview.tsx +4 -4
  93. package/src/client/market/MarketPanel.tsx +20 -36
  94. package/src/client/market/MyConfigsView.tsx +3 -10
  95. package/src/client/recovery/RecoveryPanel.tsx +4 -6
  96. package/src/client/recovery/RollbackCard.tsx +74 -59
  97. package/src/client/recovery/rollback-enabled.ts +29 -0
  98. package/src/client/recovery/use-recovery-write.ts +5 -0
  99. package/src/client/sync/AutosyncCard.tsx +3 -1
  100. package/src/client/sync/MergePreviewView.tsx +2 -2
  101. package/src/client/sync/PushPreviewCard.tsx +2 -1
  102. package/src/client/sync/SyncConfirmView.tsx +127 -130
  103. package/src/client/sync/SyncLogList.tsx +14 -10
  104. package/src/client/sync/SyncPanel.tsx +37 -28
  105. package/src/client/sync/SyncSettingsDialog.tsx +10 -21
  106. package/src/client/sync/history-model.ts +2 -0
  107. package/src/client/sync/sync-api.ts +1 -1
  108. package/src/client/sync/sync-locales.ts +8 -0
  109. package/src/client/sync/sync-push-preview.test.ts +9 -0
  110. package/src/client/sync/sync-view.ts +34 -0
  111. package/src/core/messages.ts +20 -0
  112. package/src/core/model-tools.ts +7 -1
  113. package/src/core/patch-chain.test.ts +83 -0
  114. package/src/core/patch-chain.ts +150 -0
  115. package/src/core/patch-document.test.ts +48 -1
  116. package/src/core/patch-document.ts +66 -15
  117. package/src/core/patch-layers.test.ts +1 -1
  118. package/src/core/patch-secret-guard.ts +1 -1
  119. package/src/core/smoke.test.ts +2 -1
  120. package/src/core/types.ts +16 -1
  121. package/src/index.facade.test.ts +186 -6
  122. package/src/index.ts +53 -47
  123. package/src/routes/sync.ts +6 -0
  124. package/src/security/security.test.ts +1 -1
  125. package/src/sync/autosync-scheduler.test.ts +98 -0
  126. package/src/sync/autosync-scheduler.ts +78 -17
  127. package/src/sync/local-changes.ts +40 -0
  128. package/src/sync/merge-keyed.test.ts +167 -0
  129. package/src/sync/merge-keyed.ts +160 -0
  130. package/src/sync/messages.ts +1 -0
  131. package/src/sync/patch-line-identity.test.ts +73 -0
  132. package/src/sync/patch-line-identity.ts +105 -0
  133. package/src/sync/pending-merge.test.ts +41 -0
  134. package/src/sync/pending-merge.ts +13 -5
  135. package/src/sync/plugin-removals.test.ts +199 -39
  136. package/src/sync/plugin-removals.ts +150 -64
  137. package/src/sync/push-skip.test.ts +326 -0
  138. package/src/sync/push-skip.ts +102 -0
  139. package/src/sync/sync-engine.ts +68 -67
  140. package/src/sync/workspace-merge.ts +9 -2
  141. package/src/ui/artifact-view.ts +1 -1
  142. package/src/ui/foreign-view.test.ts +49 -0
  143. package/src/ui/foreign-view.ts +47 -0
  144. package/src/ui/i18n.ts +11 -0
  145. package/src/ui/selection-model.test.ts +14 -0
  146. package/src/ui/selection-model.ts +7 -4
  147. package/src/utils/async-once.ts +14 -0
  148. package/src/utils/patch-chain-read.test.ts +171 -0
  149. package/src/utils/patch-chain-read.ts +259 -0
  150. package/src/utils/patch-yaml.test.ts +8 -2
@@ -29,14 +29,17 @@ import type { TranslateNS } from '../client-types.ts'
29
29
  import type { ConfigManagerApi, ForeignImportResponse } from '../api.ts'
30
30
  import type { UiT } from '../../ui/i18n.ts'
31
31
  import {
32
+ foreignAgentPrompt,
32
33
  foreignImportFailure,
33
34
  foreignLossyRows,
34
35
  foreignPathsText,
36
+ foreignProducedSkips,
35
37
  foreignSourcesViewModel,
36
38
  type ForeignImportFailure,
37
39
  type ForeignSourceRow,
38
40
  } from '../../ui/foreign-view.ts'
39
41
  import { Badge, Banner, Button, Card, SectionTitle } from '../common/ui.tsx'
42
+ import { CopyButton } from '../common/CopyButton.tsx'
40
43
  import { SkeletonList } from '../common/Skeleton.tsx'
41
44
  import { ErrorBanner } from '../common/ErrorBanner.tsx'
42
45
  import { redact } from '../../security/redaction.ts'
@@ -146,6 +149,8 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
146
149
  }, [api, uiT, tick])
147
150
 
148
151
  const rows = vm?.rows ?? []
152
+ const selectedRow = rows.find((r) => r.id === selected) ?? null
153
+ const producedSkips = foreignProducedSkips(produced?.skipped, uiT)
149
154
  /**
150
155
  * 三类已知有损的展示行(F-5):尚未产包时 applicable=null(界面不渲染适用性徽章),
151
156
  * 产包后按包内分区逐条标注是否适用。判定全在 src/ui/foreign-view.ts 的纯函数里。
@@ -276,12 +281,20 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
276
281
 
277
282
  {/* 选中来源的未迁移项:**在选它之后**才展开,避免六来源的码堆在一起淹没有效信息 */}
278
283
  {(() => {
279
- const row = rows.find((r) => r.id === selected) ?? null
284
+ const row = selectedRow
280
285
  if (row === null || row.skips.length === 0) return null
281
286
  return (
282
287
  <Card>
283
- <div className={css.groupLabel}>
284
- {t('foreign.skipped', { count: String(row.skips.length) })}
288
+ <div className={css.headRow}>
289
+ <div className={css.groupLabel}>
290
+ {t('foreign.skipped', { count: String(row.skips.length) })}
291
+ </div>
292
+ <span className={css.statusSpacer} />
293
+ <CopyButton
294
+ text={foreignAgentPrompt({ label: row.label, paths: row.paths, skips: row.skips }, uiT)}
295
+ label={t('foreign.copyAgentPrompt')}
296
+ t={t}
297
+ />
285
298
  </div>
286
299
  <ul className={css.skipList}>
287
300
  {row.skips.map((s, i) => (
@@ -313,6 +326,35 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
313
326
  ? <Badge kind="warn">{t('foreign.credentialRefs', { count: String(produced.credentialRefs.length) })}</Badge>
314
327
  : <Badge kind="info">{t('foreign.credentialRefsNone')}</Badge>}
315
328
  </div>
329
+ {producedSkips.length > 0 && (
330
+ <>
331
+ <div className={css.headRow}>
332
+ <div className={css.groupLabel}>
333
+ {t('foreign.skipped', { count: String(producedSkips.length) })}
334
+ </div>
335
+ <span className={css.statusSpacer} />
336
+ <CopyButton
337
+ text={foreignAgentPrompt({
338
+ label: selectedRow?.label ?? redact(produced.source),
339
+ paths: produced.detectedPaths,
340
+ skips: producedSkips,
341
+ }, uiT)}
342
+ label={t('foreign.copyAgentPrompt')}
343
+ t={t}
344
+ />
345
+ </div>
346
+ <ul className={css.skipList}>
347
+ {producedSkips.map((s, i) => (
348
+ <SkipLine
349
+ key={s.code + '-' + String(i)}
350
+ code={s.code}
351
+ text={redact(s.text)}
352
+ meta={s.origin !== undefined ? redact(s.origin) : (s.count !== undefined ? String(s.count) : '')}
353
+ />
354
+ ))}
355
+ </ul>
356
+ </>
357
+ )}
316
358
  </Card>
317
359
  )}
318
360
 
@@ -321,6 +363,21 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
321
363
  {t('foreign.importFailed', { reason: redact(importFailure.text) })}
322
364
  {/* 稳定码保留给排查/上报:文案是人话,码是可搜索的锚点(未知码时它就是唯一信息) */}
323
365
  {importFailure.code !== null && <span className={css.skipCode}>{importFailure.code}</span>}
366
+ {selectedRow !== null && (
367
+ <>
368
+ <span className={css.statusSpacer} />
369
+ <CopyButton
370
+ text={foreignAgentPrompt({
371
+ label: selectedRow.label,
372
+ paths: selectedRow.paths,
373
+ skips: selectedRow.skips,
374
+ failure: importFailure,
375
+ }, uiT)}
376
+ label={t('foreign.copyAgentPrompt')}
377
+ t={t}
378
+ />
379
+ </>
380
+ )}
324
381
  </Banner>
325
382
  )}
326
383
 
@@ -41,6 +41,7 @@ import {
41
41
  } from '../../ui/session-format-disposition.ts'
42
42
  import type { ImportPreviewSummary } from '../../ui/types.ts'
43
43
  import type { ImportAnalysis, ImportPlan, ImportResult } from '../../core/types.ts'
44
+ import type { SectionId } from '../../schema/types.ts'
44
45
  import type { UiT } from '../../ui/i18n.ts'
45
46
  import type { ConfigManagerApi } from '../api.ts'
46
47
  import type { TranslateNS } from '../client-types.ts'
@@ -104,7 +105,7 @@ function NextStepsCard({ plan, result, t }: {
104
105
  <ul className={`${css.reportList} ${css.nextStepsList}`}>
105
106
  {steps.restartItems.map((item) => (
106
107
  // description 由宿主按计划项拼装(可能含 MCP env/headers 等本地配置片段)→ 渲染前过 redact
107
- <li key={item.id}>{item.adapter}: {redact(item.description)}</li>
108
+ <li key={item.id}>{sectionLabel(item.adapter as SectionId, t)}: {redact(item.description)}</li>
108
109
  ))}
109
110
  </ul>
110
111
  </div>
@@ -10,7 +10,7 @@ import { useMemo, useState } from 'react'
10
10
  import type { ChangeEvent } from 'react'
11
11
  import type { PathIssue, PathMapping } from '../../core/types.ts'
12
12
  import type { TranslateNS } from '../client-types.ts'
13
- import { Banner, IconButton } from '../common/ui.tsx'
13
+ import { Banner, Button, IconButton } from '../common/ui.tsx'
14
14
  import { FolderOpenIcon } from '../common/Icon.tsx'
15
15
  import { PathPickerDialog } from './PathPickerDialog.tsx'
16
16
  import type { PathBrowsePort } from './PathPickerDialog.tsx'
@@ -53,15 +53,35 @@ export function PathMappingForm({ issues, initial, t, onChange, api }: PathMappi
53
53
  return out
54
54
  })
55
55
 
56
- const setNewPrefix = (oldPrefix: string, value: string): void => {
57
- const next = { ...drafts, [oldPrefix]: value }
56
+ const commitDrafts = (next: Record<string, string>): void => {
58
57
  setDrafts(next)
59
58
  const mappings: PathMapping[] = Object.entries(next)
60
- .filter(([, v]) => v !== '')
61
- .map(([oldPrefix, newPrefix]) => ({ oldPrefix, newPrefix, appliesTo: [] }))
59
+ .filter(([, v]) => v.trim() !== '')
60
+ .map(([oldPrefix, newPrefix]) => ({ oldPrefix, newPrefix: newPrefix.trim(), appliesTo: [] }))
62
61
  onChange(mappings)
63
62
  }
64
63
 
64
+ const setNewPrefix = (oldPrefix: string, value: string): void => {
65
+ commitDrafts({ ...drafts, [oldPrefix]: value })
66
+ }
67
+
68
+ const suggestedIssues = issues.filter(
69
+ (issue) =>
70
+ typeof issue.mappedTo === 'string' &&
71
+ issue.mappedTo.trim() !== '' &&
72
+ (drafts[issue.value] ?? '').trim() === '',
73
+ )
74
+
75
+ const applySuggested = (): void => {
76
+ const next = { ...drafts }
77
+ for (const issue of suggestedIssues) {
78
+ if (typeof issue.mappedTo === 'string' && issue.mappedTo.trim() !== '') {
79
+ next[issue.value] = issue.mappedTo
80
+ }
81
+ }
82
+ commitDrafts(next)
83
+ }
84
+
65
85
  /**
66
86
  * 文件夹按钮的完整动作,三层降级,任一层拿到绝对路径就回填:
67
87
  * ① **DSH 宿主自带**的目录选择器(就是「选择工作区目录」那个原生窗口,跟着宿主主进程走,最稳);
@@ -102,6 +122,13 @@ export function PathMappingForm({ issues, initial, t, onChange, api }: PathMappi
102
122
  {unresolved.length > 0 && (
103
123
  <Banner kind="info">{t('import.paths.unresolved', { count: String(unresolved.length) })}</Banner>
104
124
  )}
125
+ {suggestedIssues.length > 0 && (
126
+ <div className={css.actionRow}>
127
+ <Button size="sm" variant="ghost" onClick={applySuggested}>
128
+ {t('import.paths.applySuggested')}
129
+ </Button>
130
+ </div>
131
+ )}
105
132
  {issues.length === 0 && <div className={css.empty}>{t('import.paths.empty')}</div>}
106
133
  {issues.map((issue) => (
107
134
  <div key={issue.value} className={css.pathRow}>
@@ -82,7 +82,7 @@ test('t45/t50: 脱敏登记渲染点必须留在主文件(或日志面板模
82
82
  /import \{ redact \} from '\.\.\/\.\.\/security\/redaction\.ts'/,
83
83
  'tests/client/import-wizard-redaction.test.ts 要求主文件 import redact',
84
84
  )
85
- assert.match(view, /\{item\.adapter\}: \{redact\(item\.description\)\}<\/li>/, '收尾清单登记点必须留在主文件')
85
+ assert.match(view, /\{sectionLabel\(item\.adapter as SectionId, t\)\}: \{redact\(item\.description\)\}<\/li>/, '收尾清单登记点必须留在主文件')
86
86
  assert.match(view, /\{analysis\.warnings\.map\(\(w, i\) => <div key=\{i\}>\{redact\(w\)\}<\/div>\)\}/, '分析告警登记点必须留在主文件')
87
87
  // 2026-09:日志改为「合并后的项状态行 + 明细行」,两处脱敏渲染点在日志面板模块内
88
88
  // (同点登记见 src/client/common/plan-text-redaction.test.ts 的 import-log-* 两条)
@@ -9,7 +9,9 @@ import { inspectGroupedChanges, inspectSections, inspectSummary, type InspectGro
9
9
  // 脱敏:计划项文本由宿主拼装,渲染前必须过 redact(安全自查)
10
10
  import { redact } from '../../security/redaction.ts'
11
11
  import type { BackupInspectResult } from '../api.ts'
12
+ import type { SectionId } from '../../schema/types.ts'
12
13
  import type { TranslateNS } from '../client-types.ts'
14
+ import { sectionLabel } from '../common/section-labels.ts'
13
15
  import { Badge } from '../common/ui.tsx'
14
16
  import css from '../config-manager.module.css'
15
17
 
@@ -39,7 +41,7 @@ export function BackupInspectView({ result, t }: BackupInspectViewProps) {
39
41
  <div className={css.groupLabel}>{t('backupFiles.inspectSections')}</div>
40
42
  <div className={css.statRow}>
41
43
  {sections.map((s) => (
42
- <Badge key={s.section} kind="info" className={css.inspectBadge}>{s.section}: {s.count}</Badge>
44
+ <Badge key={s.section} kind="info" className={css.inspectBadge}>{sectionLabel(s.section as SectionId, t)}: {s.count}</Badge>
43
45
  ))}
44
46
  </div>
45
47
  </div>
@@ -77,7 +79,7 @@ export function BackupInspectView({ result, t }: BackupInspectViewProps) {
77
79
  在同一次提交里同步改成这里的锚点(见该表)。 */
78
80
  <li key={item.id} className={css.inspectItem}>
79
81
  <span className={css.inspectDot} aria-hidden="true" />
80
- <span className={css.mono + ' ' + css.inspectAdapter}>{item.adapter}:</span>
82
+ <span className={css.inspectAdapter}>{sectionLabel(item.adapter as SectionId, t)}:</span>
81
83
  <span className={css.inspectDesc}>{redact(item.description)}</span>
82
84
  </li>
83
85
  ))}
@@ -18,6 +18,12 @@ import type { ConsultReport } from '../../core/migration-consult.ts'
18
18
  import type { ArtifactCapability, ArtifactRow } from '../../ui/artifact-view.ts'
19
19
  import { remoteSnapshotFileName } from '../../ui/artifact-view.ts'
20
20
  import { planHasExecutableActions } from '../../ui/snapshots-view.ts'
21
+ import {
22
+ buildSyncChannelBody, channelRemoteReady, cloudFormFromStatus,
23
+ type SyncFormSnapshot, type SyncPushBody,
24
+ } from '../../ui/sync-settings-view.ts'
25
+ import { isClientChannel, SYNC_CHANNEL_ORDER, type SyncChannel } from '../sync/sync-view.ts'
26
+ import type { SyncStatusResponse } from '../sync/sync-api.ts'
21
27
  import { runStore } from '../run-store.ts'
22
28
  import type { ConfigManagerApi, BackupInspectResult } from '../api.ts'
23
29
  import type { SyncApi } from '../sync/sync-api.ts'
@@ -545,7 +551,7 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
545
551
  ? t('backupFiles.deleteConfirm', { name: fileNameOf(confirmDelete) })
546
552
  : confirmDelete.kind === 'remote-snapshot'
547
553
  ? t('library.remoteDeleteConfirm', { time: timeText(confirmDelete) })
548
- : t('snapshots.deleteConfirm', { time: confirmDelete.title.kind === 'time' ? confirmDelete.title.iso : '' })}
554
+ : t('snapshots.deleteConfirm', { time: timeText(confirmDelete) })}
549
555
  confirmLabel={confirmDelete === null ? t('snapshots.delete')
550
556
  : confirmDelete.kind === 'backup-file' ? t('backupFiles.delete')
551
557
  : confirmDelete.kind === 'remote-snapshot' ? t('library.delete')
@@ -575,6 +581,9 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
575
581
  {inspect !== null && !inspect.loading && inspect.result === null && inspect.error === null && <Empty>{t('backupFiles.inspectEmpty')}</Empty>}
576
582
  {inspect?.result != null && <BackupInspectView result={inspect.result} t={t} />}
577
583
  </Modal.Body>
584
+ <Modal.Footer>
585
+ <Button variant="ghost" onClick={() => { setInspect(null) }}>{t('common.close')}</Button>
586
+ </Modal.Footer>
578
587
  </Modal>
579
588
 
580
589
  {/* 执行恢复的报告(一次性回执,必须给显式退出入口) */}
@@ -583,6 +592,9 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
583
592
  <Modal.Body scroll>
584
593
  {report !== null && (
585
594
  <>
595
+ {report.preRestoreDir !== undefined && report.preRestoreDir !== '' && (
596
+ <div className={css.hint}>{t('snapshots.preRestoreDir', { dir: redact(report.preRestoreDir) })}</div>
597
+ )}
586
598
  {reportLine(t('snapshots.restored'), report.restored, t)}
587
599
  {reportLine(t('snapshots.removedPlugins'), report.removedPlugins, t)}
588
600
  {reportLine(t('snapshots.manualHints'), report.manualHints, t, true)}
@@ -640,28 +652,64 @@ function pullProgressLabel(mode: PullState['mode'], t: TranslateNS<'config-manag
640
652
  * 咨询 / 拉取 / 下载 / 删除四条远端动作共用这一份判定,避免各写一份而分叉。
641
653
  * 地址从 /sync/status 现取,与产物库加载远端列表同源。
642
654
  */
643
- async function remotePayload(syncApi: SyncApi): Promise<{ transport: 'git'; repoUrl: string } | { transport: 'webdav'; url: string }> {
655
+ /**
656
+ * 从 /sync/status 响应解析当前可用的远端通道与请求载荷(覆盖 git/webdav/s3/gist 四通道)。
657
+ * 优先取 lastSyncChannel 或 transport.type;若首选通道未就绪,按 SYNC_CHANNEL_ORDER 顺延找第一个已就绪通道。
658
+ */
659
+ export function resolveRemoteChannelPayload(
660
+ status: SyncStatusResponse,
661
+ ): { channel: SyncChannel; payload: SyncPushBody } | null {
662
+ const preferred: SyncChannel = isClientChannel(status.lastSyncChannel)
663
+ ? status.lastSyncChannel
664
+ : isClientChannel(status.transport?.type)
665
+ ? status.transport.type
666
+ : 'git'
667
+ const candidates: SyncChannel[] = [
668
+ preferred,
669
+ ...SYNC_CHANNEL_ORDER.filter((ch) => ch !== preferred),
670
+ ]
671
+ const cloud = cloudFormFromStatus(status)
672
+ for (const ch of candidates) {
673
+ const form: SyncFormSnapshot = {
674
+ channel: ch,
675
+ repoUrl: status.repoUrl ?? '',
676
+ gitSubdir: status.subdir ?? '',
677
+ token: '',
678
+ webdavUrl: status.webdav?.url ?? '',
679
+ webdavUsername: status.webdav?.username ?? '',
680
+ webdavPassword: '',
681
+ ...cloud,
682
+ s3Secret: '',
683
+ gistToken: '',
684
+ }
685
+ if (channelRemoteReady(form)) {
686
+ return { channel: ch, payload: buildSyncChannelBody(form) }
687
+ }
688
+ }
689
+ return null
690
+ }
691
+
692
+ async function remotePayload(syncApi: SyncApi): Promise<SyncPushBody> {
644
693
  // 只要通道与地址,不要工作副本的 ahead/dirty/远端快照(省 5 次 git 子进程启动)
645
694
  const status = await syncApi.status({ workDirDetail: false })
646
- const isWebdav = status.lastSyncChannel === 'webdav'
647
- const webdavUrl = (status.webdav?.url ?? '').trim()
648
- const repoUrl = (status.repoUrl ?? '').trim()
649
- const payload = isWebdav
650
- ? (webdavUrl !== '' ? { transport: 'webdav' as const, url: webdavUrl } : null)
651
- : (repoUrl !== '' ? { transport: 'git' as const, repoUrl } : null)
652
- if (payload === null) throw new Error('sync channel address is unavailable')
653
- return payload
695
+ const resolved = resolveRemoteChannelPayload(status)
696
+ if (resolved === null) throw new Error('sync channel address is unavailable')
697
+ return resolved.payload
654
698
  }
655
699
 
656
700
  /**
657
701
  * 「迁移前咨询」的输入:**四种可迁移源统一走这一个入口**(§6.8 ②)。
658
702
  * 每种的 id 语义不同(快照 id / 备份路径 / 远端快照 id),照 consult 路由的契约给。
659
703
  */
660
- async function consultInput(row: ArtifactRow, syncApi: SyncApi): Promise<{ type: 'export-zip' | 'local-snapshot' | 'remote-snapshot'; id: string; snapshotId?: string; transport?: 'git' | 'webdav'; repoUrl?: string; url?: string }> {
704
+ async function consultInput(
705
+ row: ArtifactRow,
706
+ syncApi: SyncApi,
707
+ ): Promise<SyncPushBody & { type: 'export-zip' | 'local-snapshot' | 'remote-snapshot'; id: string; snapshotId?: string }> {
661
708
  if (row.kind === 'snapshot') return { type: 'local-snapshot', id: row.ref.snapshotId ?? '', snapshotId: row.ref.snapshotId }
662
709
  if (row.kind === 'remote-snapshot') {
663
710
  // 远端来源**必须**带通道与地址(与拉取/下载/删除共用 remotePayload 那一份判定)
664
- return { type: 'remote-snapshot', id: row.ref.remoteId ?? '', ...(await remotePayload(syncApi)) }
711
+ const remote = await remotePayload(syncApi)
712
+ return { ...remote, type: 'remote-snapshot', id: row.ref.remoteId ?? '', snapshotId: row.ref.remoteId }
665
713
  }
666
714
  return { type: 'export-zip', id: row.ref.path ?? '' }
667
715
  }
@@ -22,12 +22,14 @@ import type { MarketApi } from '../market/market-api.ts'
22
22
  import type { TranslateNS } from '../client-types.ts'
23
23
  import { formatDateTimeFull } from '../sync/history-model.ts'
24
24
  import { deviceLabelsById } from '../sync/remote-device-view.ts'
25
+ import { isClientChannel, type SyncChannel } from '../sync/sync-view.ts'
25
26
  import { runStore, type LibraryStoreSlice } from '../run-store.ts'
26
27
  import { Badge, Button, Card, Empty } from '../common/ui.tsx'
27
28
  import { snapshotOriginOf, snapshotOriginState } from '../../ui/snapshots-view.ts'
28
29
  import { SkeletonRows } from '../common/Skeleton.tsx'
29
30
  import { redact } from '../../security/redaction.ts'
30
31
  import { ArtifactRowView, type ArtifactPendingAction } from './ArtifactRow.tsx'
32
+ import { resolveRemoteChannelPayload } from './LibraryActions.tsx'
31
33
  import css from '../config-manager.module.css'
32
34
 
33
35
  export interface LibraryPanelProps {
@@ -81,7 +83,7 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
81
83
  /** 快照目录读不出来的事实(宿主 out.unreadable;null = 正常) */
82
84
  const [snapshotsUnreadable, setSnapshotsUnreadable] = useState<string | null>(null)
83
85
  const [currentRemoteId, setCurrentRemoteId] = useState<string | null>(null)
84
- const [remoteChannel, setRemoteChannel] = useState<'git' | 'webdav' | null>(null)
86
+ const [remoteChannel, setRemoteChannel] = useState<SyncChannel | null>(null)
85
87
  /** 面板内部的刷新信号(失败源卡片里的「重试」);外部的走 props.refreshTick */
86
88
  const [localTick, setLocalTick] = useState(0)
87
89
  /**
@@ -124,15 +126,11 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
124
126
  // 先取 /sync/status 拿到通道与地址,再据此发请求;两处都不可用时该源如实标失败,绝不空手请求。
125
127
  put(setRemote, syncApi.status({ workDirDetail: false }).then((status) => {
126
128
  if (!mounted.current) return [] as SyncSnapshotLite[]
127
- setRemoteChannel(status.lastSyncChannel === 'webdav' ? 'webdav' : status.lastSyncChannel === 'git' ? 'git' : null)
129
+ const resolved = resolveRemoteChannelPayload(status)
130
+ setRemoteChannel(resolved?.channel ?? (isClientChannel(status.lastSyncChannel) ? status.lastSyncChannel : null))
128
131
  const configured = status.configured === true
129
- const webdavUrl = status.webdav?.url ?? ''
130
- const repoUrl = status.repoUrl ?? ''
131
- const payload = status.lastSyncChannel === 'webdav'
132
- ? (webdavUrl.trim() !== '' ? { transport: 'webdav' as const, url: webdavUrl.trim() } : null)
133
- : (repoUrl.trim() !== '' ? { transport: 'git' as const, repoUrl: repoUrl.trim() } : null)
134
- if (!configured || payload === null) return [] as SyncSnapshotLite[]
135
- return syncApi.snapshotsList(payload).then((res) => {
132
+ if (!configured || resolved === null) return [] as SyncSnapshotLite[]
133
+ return syncApi.snapshotsList(resolved.payload).then((res) => {
136
134
  if (mounted.current) setCurrentRemoteId(res.currentSnapshotId ?? null)
137
135
  return res.snapshots
138
136
  })
@@ -345,7 +343,8 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
345
343
  {/* 底栏四个入口,只有「导出」是这一页的产品级动作(把本机配置打成可分享的包);
346
344
  其余三个是「拿别人的东西进来 / 去别处找」。主按钮只留一个,否则整屏没有焦点
347
345
  (app-screens §13:强调色应用在数据与至多一个控件上)。 */}
348
- <Button size="sm" variant="primary" onClick={onOpenExport} title={t('backupFiles.hint')}>{t('library.new.export')}</Button>
346
+ {/* 不再挂 backupFiles.hint:那句写的是备份文件的清理规则,与「把配置打成可分享的包」无关(issue #143)。 */}
347
+ <Button size="sm" variant="primary" onClick={onOpenExport}>{t('library.new.export')}</Button>
349
348
  <Button size="sm" onClick={() => { onOpenTask('import') }}>{t('library.new.import')}</Button>
350
349
  <Button size="sm" onClick={() => { onOpenTask('market') }}>{t('library.new.market')}</Button>
351
350
  <Button size="sm" onClick={onOpenPublish}>{t('task.title.publish')}</Button>
@@ -42,6 +42,8 @@ export const zh = {
42
42
  'backupSchedule.error': '定时备份设置加载失败',
43
43
  // —— 保留策略(m-retention:GFS 分层)——
44
44
  'retention.title': '保留策略',
45
+ // issue #143:标题本身说出覆盖面(快照 + 定时备份),豁免细则仍只在 retention.hint 的悬停里
46
+ 'retention.titleScoped': '保留策略(快照 + 定时备份)',
45
47
  'retention.hint': '快照与定时备份共用;置顶快照与未收敛的恢复点恒豁免自动清理。',
46
48
  'retention.keepLast': '最近保留',
47
49
  'retention.keepLastHint': '按时间保留最近 N 份;0 = 不按「最近」保留',
@@ -53,6 +55,8 @@ export const zh = {
53
55
  'retention.months': '个月',
54
56
  'retention.years': '年',
55
57
  'retention.tiersOff': '仅保留最近 N 份',
58
+ // 已停用(issue #143):这句写死了旧默认值 10,且此前挂在产物库「导出」按钮上,与导出无关。
59
+ // 键因 engine-locale 冻结基线(372 键)不得删除,但没有消费点;保留策略的覆盖面由 retention.titleScoped 承担。
56
60
  'backupFiles.hint': '定时备份自动保留最近 10 个,更早的会被删除。',
57
61
  'backupFiles.empty': '暂无备份文件',
58
62
  'backupFiles.delete': '删除',
@@ -108,6 +112,7 @@ export const en: Record<keyof typeof zh, string> = {
108
112
  'backupSchedule.error': 'Failed to load scheduled backup settings',
109
113
  // —— Retention policy (m-retention: GFS tiers) ——
110
114
  'retention.title': 'Retention policy',
115
+ 'retention.titleScoped': 'Retention policy (snapshots + backups)',
111
116
  'retention.hint': 'Shared by snapshots and scheduled backups; pinned snapshots and unsettled recovery points are always exempt.',
112
117
  'retention.keepLast': 'Keep last',
113
118
  'retention.keepLastHint': 'Keep the newest N by time; 0 disables the "recent" tier',
@@ -102,6 +102,7 @@ export const zh = {
102
102
  'foreign.skip.trae-db-schema-mismatch': 'Trae 加密会话库解密成功但表结构不符(缺 chat_session / history_v2 或必需列):不猜字段,本次未读出任何会话',
103
103
  // 冲突语义(用户决策:同 id 不覆盖、跳过并报码)
104
104
  'foreign.conflict.policy': '同 id 冲突不覆盖本机内容:跳过并逐条报告',
105
+ 'foreign.copyAgentPrompt': '复制转换提示词',
105
106
  } as const;
106
107
 
107
108
  export const en: Record<keyof typeof zh, string> = {
@@ -190,4 +191,5 @@ export const en: Record<keyof typeof zh, string> = {
190
191
  'foreign.skip.trae-db-decrypt-failed': 'The Trae encrypted session database cannot be decrypted: the file is truncated, not in SQLCipher form, or unreadable, so no session was read',
191
192
  'foreign.skip.trae-db-schema-mismatch': 'The Trae encrypted session database decrypted but its schema does not match (chat_session / history_v2 or a required column is missing): fields are never guessed, so no session was read',
192
193
  'foreign.conflict.policy': 'Same-id conflicts never overwrite local content: skipped and listed in the report',
194
+ 'foreign.copyAgentPrompt': 'Copy conversion prompt',
193
195
  };
@@ -87,6 +87,7 @@ export const zh = {
87
87
  'import.paths.kind.homeMismatch': '基础路径不同',
88
88
  'import.paths.unresolved': '还有 {count} 条路径未映射(留空将跳过该路径,可以继续)',
89
89
  'import.paths.empty': '无需映射路径',
90
+ 'import.paths.applySuggested': '填入建议路径',
90
91
  // 「选择本机路径」弹窗(第③项):浏览器拿不到本机真实路径,目录列举走宿主只读端点
91
92
  'import.paths.browse': '选择本机路径',
92
93
  'import.paths.picker.title': '选择本机路径',
@@ -178,6 +179,7 @@ export const en: Record<keyof typeof zh, string> = {
178
179
  'import.paths.kind.homeMismatch': 'Different base path',
179
180
  'import.paths.unresolved': '{count} {count, plural, path|paths} unmapped (blank = skip that path, you can continue)',
180
181
  'import.paths.empty': 'No paths to map',
182
+ 'import.paths.applySuggested': 'Apply suggested paths',
181
183
  'import.paths.browse': 'Choose a local path',
182
184
  'import.paths.picker.title': 'Choose a local path',
183
185
  'import.paths.picker.up': 'Up one level',
@@ -30,6 +30,7 @@ export const zh = {
30
30
  'snapshots.manualHints': '需人工处理',
31
31
  'snapshots.failed': '失败',
32
32
  'snapshots.skipped': '跳过',
33
+ 'snapshots.preRestoreDir': '恢复前安全备份目录:{dir}',
33
34
  // 恢复计划动作 kind 标签(原硬编码中文字符串,改走字典)
34
35
  // —— git 风格恢复预览(快照改动逐行对照) ——
35
36
  'snapshots.plan.changed': '将被还原 {count}',
@@ -92,6 +93,7 @@ export const en: Record<keyof typeof zh, string> = {
92
93
  'snapshots.manualHints': 'Manual action needed',
93
94
  'snapshots.failed': 'Failed',
94
95
  'snapshots.skipped': 'Skipped',
96
+ 'snapshots.preRestoreDir': 'Pre-restore safety backup: {dir}',
95
97
  // —— git-style restore preview (line-by-line) ——
96
98
  'snapshots.plan.changed': '{count} {count, plural, file|files} to restore',
97
99
  'snapshots.plan.added': '{count} added',
@@ -37,7 +37,7 @@ import {
37
37
  type MarketPickerFilter, type MarketReviewStep,
38
38
  } from '../../ui/market-import.ts'
39
39
  import { redact } from '../../security/redaction.ts'
40
- import { Badge, Banner, Button, Chip, Segmented, Stepper } from '../common/ui.tsx'
40
+ import { Badge, Banner, Button, Chip, Empty, Segmented, Stepper } from '../common/ui.tsx'
41
41
  import { ContentPicker } from '../common/ContentPicker.tsx'
42
42
  import { ConflictList } from '../import/ConflictList.tsx'
43
43
  import { ConfirmDialog } from '../common/ConfirmDialog.tsx'
@@ -273,7 +273,7 @@ export function MarketImportReview({
273
273
  {countBadges}
274
274
  {/* 步骤名由顶部 Stepper 承担:这里再写一遍「本次将改动的内容」是同屏第二次说同一步叫什么 */}
275
275
  {sectionSummaries.length === 0
276
- ? <div className={css.hint}>{t('review.changeEmpty')}</div>
276
+ ? <Empty>{t('review.changeEmpty')}</Empty>
277
277
  : renderSectionRows(false)}
278
278
  </div>
279
279
  <div className={css.actionRow}>
@@ -291,7 +291,7 @@ export function MarketImportReview({
291
291
  ariaLabel={t('review.filterAria')}
292
292
  />
293
293
  {visibleNodes.length === 0
294
- ? <div className={css.hint}>{t('review.filterEmpty')}</div>
294
+ ? <Empty>{t('review.filterEmpty')}</Empty>
295
295
  : (
296
296
  <ContentPicker
297
297
  nodes={visibleNodes}
@@ -353,7 +353,7 @@ export function MarketImportReview({
353
353
  <>
354
354
  <div className={css.marketReviewScroll}>
355
355
  {result === null
356
- ? <div className={css.hint}>{t('review.changeEmpty')}</div>
356
+ ? <Empty>{t('review.changeEmpty')}</Empty>
357
357
  : (
358
358
  <>
359
359
  {(() => {
@@ -25,7 +25,8 @@ import type { TranslateNS } from '../client-types.ts'
25
25
  import type { ConfigManagerApi } from '../api.ts'
26
26
  import type { ImportResult, ItemResolution } from '../../core/types.ts'
27
27
  import type { SectionId } from '../../schema/types.ts'
28
- import { Badge, Banner, Button, Card, Empty, SectionTitle } from '../common/ui.tsx'
28
+ import { Badge, Banner, Button, Card, Checkbox, Empty, SectionTitle, Segmented } from '../common/ui.tsx'
29
+ import { ErrorBanner } from '../common/ErrorBanner.tsx'
29
30
  import { InspectIcon } from '../common/Icon.tsx'
30
31
  import { Skeleton, SkeletonList } from '../common/Skeleton.tsx'
31
32
  import { Select } from '../common/Select.tsx'
@@ -51,6 +52,7 @@ import type { MyInstallSlice, MyWizardSlice } from './my-configs-view.ts'
51
52
  import { readDisclaimerDismissed, writeDisclaimerDismissed } from './disclaimer.ts'
52
53
  import type { DisclaimerKey } from './disclaimer.ts'
53
54
  import { ConfirmDialog } from '../common/ConfirmDialog.tsx'
55
+ import { sectionLabel } from '../common/section-labels.ts'
54
56
  import { redact } from '../../security/redaction.ts'
55
57
  import { runStore, toMarketStoreSlice, type MarketStoreSlice } from '../run-store.ts'
56
58
  import css from '../config-manager.module.css'
@@ -434,26 +436,15 @@ export function MarketPanel({ api, myConfigsApi, importApi, syncApi, t, cmT, ope
434
436
  }
435
437
  >
436
438
  {/* 子视图切换(§4.6):浏览市场 / 我的配置(低频面板状态镜像 runStore,切 tab/刷新不丢) */}
437
- <div className={css.modeTabs} role="tablist">
438
- <button
439
- type="button" role="tab"
440
- aria-selected={state.subView === 'browse'}
441
- data-active={state.subView === 'browse' ? '' : undefined}
442
- className={css.modeTab}
443
- onClick={() => { patch({ subView: 'browse' }) }}
444
- >
445
- {t('myconfigs.tab.browse')}
446
- </button>
447
- <button
448
- type="button" role="tab"
449
- aria-selected={state.subView === 'myconfigs'}
450
- data-active={state.subView === 'myconfigs' ? '' : undefined}
451
- className={css.modeTab}
452
- onClick={() => { patch({ subView: 'myconfigs' }) }}
453
- >
454
- {t('myconfigs.tab.myconfigs')}
455
- </button>
456
- </div>
439
+ <Segmented
440
+ items={[
441
+ { id: 'browse', label: t('myconfigs.tab.browse') },
442
+ { id: 'myconfigs', label: t('myconfigs.tab.myconfigs') },
443
+ ]}
444
+ active={state.subView}
445
+ onChange={(id) => { patch({ subView: id as 'browse' | 'myconfigs' }) }}
446
+ ariaLabel={t('section.label')}
447
+ />
457
448
 
458
449
  {/* 「我的配置」子视图(登录卡 / 上传向导 / 已上传列表 / 装回本地) */}
459
450
  {state.subView === 'myconfigs' ? (
@@ -616,12 +607,12 @@ export function MarketPanel({ api, myConfigsApi, importApi, syncApi, t, cmT, ope
616
607
  (「内置市场尚未加载,请先『拉取最新』」),错误原文被整个丢弃 ——
617
608
  用户只会反复点刷新,永远不知是宿主没就绪、网络不通还是本地 index 读不出来。 */}
618
609
  {state.loadError !== null && (
619
- <>
620
- <Banner kind="error">{redact(state.loadError)}</Banner>
621
- <div className={css.actionRow}>
622
- <Button loading={state.loading} onClick={() => { void loadStatus() }}>{t('common.retry')}</Button>
623
- </div>
624
- </>
610
+ <ErrorBanner
611
+ error={redact(state.loadError)}
612
+ onRetry={() => { void loadStatus() }}
613
+ retrying={state.loading}
614
+ t={api.t}
615
+ />
625
616
  )}
626
617
  {state.loadError === null && (<>
627
618
  {/* 筛选控件 2×2 网格(搜索框跨两列 + 4 个 select 两两一行):
@@ -656,7 +647,7 @@ export function MarketPanel({ api, myConfigsApi, importApi, syncApi, t, cmT, ope
656
647
  onChange={(next) => { patch({ sectionFilter: next }) }}
657
648
  options={[
658
649
  { value: '', label: t('list.sectionsAll') },
659
- ...sectionOptions.map((s) => ({ value: s, label: s })),
650
+ ...sectionOptions.map((s) => ({ value: s, label: sectionLabel(s as SectionId, cmT) })),
660
651
  ]}
661
652
  />
662
653
  <Select
@@ -751,14 +742,7 @@ export function MarketPanel({ api, myConfigsApi, importApi, syncApi, t, cmT, ope
751
742
  onConfirm={confirmDownloadDisclaimer}
752
743
  onCancel={() => { setDisclaimerKey(null) }}
753
744
  >
754
- <label className={css.checkboxRow}>
755
- <input
756
- type="checkbox"
757
- checked={dontAsk}
758
- onChange={(e: ChangeEvent<HTMLInputElement>) => { setDontAsk(e.target.checked) }}
759
- />
760
- <span>{t('disclaimer.dontAsk')}</span>
761
- </label>
745
+ <Checkbox checked={dontAsk} onChange={setDontAsk} label={t('disclaimer.dontAsk')} />
762
746
  </ConfirmDialog>
763
747
  </>
764
748
  )}