dsh-config-manager 0.8.1 → 0.9.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 (368) hide show
  1. package/lib/adapters/mcp.js +42 -13
  2. package/lib/adapters/messages.d.ts +1 -0
  3. package/lib/adapters/messages.js +2 -0
  4. package/lib/adapters/patch-key-guard.d.ts +23 -0
  5. package/lib/adapters/patch-key-guard.js +13 -0
  6. package/lib/adapters/plugin-data.d.ts +19 -5
  7. package/lib/adapters/plugin-data.js +76 -22
  8. package/lib/adapters/plugins.d.ts +14 -1
  9. package/lib/adapters/plugins.js +147 -4
  10. package/lib/cli/actions.d.ts +7 -105
  11. package/lib/cli/actions.js +16 -172
  12. package/lib/cli/control-state.d.ts +54 -0
  13. package/lib/cli/control-state.js +107 -0
  14. package/lib/cli/index.js +14 -0
  15. package/lib/cli/write-gates.d.ts +61 -0
  16. package/lib/cli/write-gates.js +110 -0
  17. package/lib/client.d.ts +122 -50
  18. package/lib/client.js +12676 -12091
  19. package/lib/core/backup.d.ts +0 -4
  20. package/lib/core/backup.js +21 -4
  21. package/lib/core/boot-rescue.d.ts +1 -1
  22. package/lib/core/boot-rescue.js +12 -1
  23. package/lib/core/boot-safety.js +37 -2
  24. package/lib/core/conflict-decisions.js +2 -1
  25. package/lib/core/exporter.js +22 -1
  26. package/lib/core/journal.d.ts +54 -4
  27. package/lib/core/journal.js +158 -35
  28. package/lib/core/local-plugin-host.d.ts +29 -0
  29. package/lib/core/local-plugin-host.js +55 -48
  30. package/lib/core/messages.d.ts +7 -0
  31. package/lib/core/messages.js +14 -0
  32. package/lib/core/migration-history.js +16 -9
  33. package/lib/core/model-tools.d.ts +2 -2
  34. package/lib/core/model-tools.js +14 -2
  35. package/lib/core/patch-secret-guard.d.ts +49 -0
  36. package/lib/core/patch-secret-guard.js +164 -0
  37. package/lib/core/reconcile.d.ts +8 -0
  38. package/lib/core/reconcile.js +18 -3
  39. package/lib/core/reinstall.d.ts +2 -0
  40. package/lib/core/reinstall.js +6 -2
  41. package/lib/core/restore.js +31 -6
  42. package/lib/core/section-sanitize.d.ts +32 -0
  43. package/lib/core/section-sanitize.js +13 -0
  44. package/lib/core/snapshot-diff.d.ts +30 -0
  45. package/lib/core/snapshot-diff.js +56 -20
  46. package/lib/core/startup-barrier.js +8 -2
  47. package/lib/core/types.d.ts +22 -0
  48. package/lib/core/update-check.js +51 -2
  49. package/lib/foreign/kernel.js +9 -2
  50. package/lib/foreign/read-claude-plugins.js +29 -11
  51. package/lib/foreign/read-dsh.js +31 -2
  52. package/lib/foreign/read-trae.d.ts +11 -0
  53. package/lib/foreign/read-trae.js +124 -4
  54. package/lib/foreign/session-ir.js +50 -9
  55. package/lib/foreign/session-read.d.ts +8 -0
  56. package/lib/foreign/session-read.js +26 -0
  57. package/lib/foreign/session-source.d.ts +12 -4
  58. package/lib/foreign/session-source.js +5 -3
  59. package/lib/foreign/trae-sqlcipher.d.ts +127 -0
  60. package/lib/foreign/trae-sqlcipher.js +519 -0
  61. package/lib/foreign/trae.js +3 -1
  62. package/lib/foreign/truth-table.js +3 -2
  63. package/lib/foreign/types.d.ts +9 -1
  64. package/lib/index.d.ts +1 -1
  65. package/lib/index.js +1 -1
  66. package/lib/profiles/dsh-profile-io.d.ts +20 -0
  67. package/lib/profiles/dsh-profile-io.js +27 -0
  68. package/lib/profiles/dsh-profile-manager.d.ts +27 -0
  69. package/lib/profiles/dsh-profile-manager.js +45 -4
  70. package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
  71. package/lib/profiles/dsh-profile-runtime.js +16 -3
  72. package/lib/profiles/process-control.d.ts +18 -1
  73. package/lib/profiles/process-control.js +25 -1
  74. package/lib/routes/profiles.js +2 -1
  75. package/lib/routes/sync.js +13 -1
  76. package/lib/schema/types.d.ts +11 -0
  77. package/lib/security/redaction.js +22 -6
  78. package/lib/sync/autosync-repeat.d.ts +27 -0
  79. package/lib/sync/autosync-repeat.js +23 -0
  80. package/lib/sync/autosync-scheduler.d.ts +34 -1
  81. package/lib/sync/autosync-scheduler.js +151 -43
  82. package/lib/sync/baseline-heal.js +7 -0
  83. package/lib/sync/baseline-record.d.ts +67 -0
  84. package/lib/sync/baseline-record.js +74 -0
  85. package/lib/sync/blob-store.js +13 -0
  86. package/lib/sync/content-diff.d.ts +39 -0
  87. package/lib/sync/content-diff.js +46 -0
  88. package/lib/sync/git/git-transport.d.ts +32 -1
  89. package/lib/sync/git/git-transport.js +146 -26
  90. package/lib/sync/github-auth.d.ts +17 -1
  91. package/lib/sync/github-auth.js +37 -1
  92. package/lib/sync/merge-apply-plan.d.ts +38 -0
  93. package/lib/sync/merge-apply-plan.js +76 -0
  94. package/lib/sync/messages.d.ts +1 -0
  95. package/lib/sync/messages.js +2 -0
  96. package/lib/sync/pending-merge.d.ts +34 -0
  97. package/lib/sync/pending-merge.js +53 -0
  98. package/lib/sync/s3/s3-transport.d.ts +14 -2
  99. package/lib/sync/s3/s3-transport.js +72 -48
  100. package/lib/sync/sync-engine.d.ts +23 -40
  101. package/lib/sync/sync-engine.js +115 -132
  102. package/lib/sync/sync-history.d.ts +7 -0
  103. package/lib/sync/sync-state.d.ts +28 -0
  104. package/lib/sync/sync-state.js +20 -0
  105. package/lib/sync/transport.d.ts +12 -3
  106. package/lib/sync/transport.js +13 -4
  107. package/lib/sync/webdav/webdav-transport.d.ts +19 -2
  108. package/lib/sync/webdav/webdav-transport.js +81 -40
  109. package/lib/ui/commands.js +5 -11
  110. package/lib/ui/dsh-profiles-view.d.ts +8 -3
  111. package/lib/ui/dsh-profiles-view.js +9 -5
  112. package/lib/ui/foreign-view.d.ts +19 -0
  113. package/lib/ui/foreign-view.js +24 -0
  114. package/lib/ui/i18n.d.ts +7 -1
  115. package/lib/ui/i18n.js +17 -2
  116. package/lib/ui/menu-placement.js +1 -1
  117. package/lib/ui/migration-consult-view.d.ts +11 -0
  118. package/lib/ui/migration-consult-view.js +15 -0
  119. package/lib/ui/overview-view.d.ts +7 -0
  120. package/lib/ui/overview-view.js +3 -0
  121. package/lib/ui/report.d.ts +9 -0
  122. package/lib/ui/report.js +17 -4
  123. package/lib/ui/selection-model.d.ts +8 -0
  124. package/lib/ui/selection-model.js +16 -0
  125. package/lib/utils/patch-yaml.d.ts +39 -1
  126. package/lib/utils/patch-yaml.js +82 -2
  127. package/lib/utils/paths.d.ts +13 -0
  128. package/lib/utils/paths.js +35 -0
  129. package/lib/utils/workdir-lock.js +18 -3
  130. package/package.json +2 -1
  131. package/src/adapters/mcp.test.ts +29 -0
  132. package/src/adapters/mcp.ts +43 -12
  133. package/src/adapters/messages.ts +2 -0
  134. package/src/adapters/patch-key-guard.ts +29 -0
  135. package/src/adapters/plugin-data.test.ts +126 -0
  136. package/src/adapters/plugin-data.ts +97 -26
  137. package/src/adapters/plugins.test.ts +288 -0
  138. package/src/adapters/plugins.ts +141 -4
  139. package/src/cli/actions.test.ts +74 -1
  140. package/src/cli/actions.ts +27 -246
  141. package/src/cli/control-state.ts +143 -0
  142. package/src/cli/index.ts +18 -0
  143. package/src/cli/web/web.test.ts +27 -0
  144. package/src/cli/write-gates.ts +149 -0
  145. package/src/client/about/AboutPanel.tsx +7 -6
  146. package/src/client/about/release-notes-view.test.ts +17 -0
  147. package/src/client/about/release-notes-view.ts +49 -24
  148. package/src/client/chat/ChatEntryView.tsx +2 -2
  149. package/src/client/chat/rollback-entry-view.ts +6 -1
  150. package/src/client/common/CommandPalette.tsx +6 -3
  151. package/src/client/common/ConfirmDialog.tsx +29 -12
  152. package/src/client/common/ContentPicker.tsx +13 -12
  153. package/src/client/common/Modal.tsx +12 -5
  154. package/src/client/common/MoreMenu.tsx +4 -1
  155. package/src/client/common/RunsCenter.tsx +103 -32
  156. package/src/client/common/Select.tsx +2 -2
  157. package/src/client/common/floating-bounds.ts +1 -1
  158. package/src/client/common/floating-units.test.ts +1 -2
  159. package/src/client/common/plan-text-redaction.test.ts +188 -3
  160. package/src/client/common/runs-center-guard.test.ts +60 -0
  161. package/src/client/common/runs-center-view.test.ts +128 -0
  162. package/src/client/common/runs-center-view.ts +96 -0
  163. package/src/client/common/section-title-action.test.ts +66 -0
  164. package/src/client/common/ui.tsx +93 -30
  165. package/src/client/config-manager.module.css +1507 -272
  166. package/src/client/consult/ConsultCard.tsx +7 -6
  167. package/src/client/environment/EnvironmentPanel.tsx +20 -21
  168. package/src/client/environment/maintenance/DiskUsageCard.tsx +65 -91
  169. package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
  170. package/src/client/export/ExportView.tsx +7 -16
  171. package/src/client/history/HistoryPanel.tsx +88 -28
  172. package/src/client/history/history-locales.ts +3 -3
  173. package/src/client/home/BackupScheduleCard.tsx +35 -30
  174. package/src/client/home/HomePanel.tsx +45 -10
  175. package/src/client/import/ConflictList.tsx +13 -13
  176. package/src/client/import/ForeignImportView.tsx +32 -13
  177. package/src/client/import/ImportWizardView.tsx +2 -3
  178. package/src/client/import/PathMappingForm.tsx +4 -4
  179. package/src/client/import/PathPickerDialog.tsx +2 -1
  180. package/src/client/import/foreign-import-view-guard.test.ts +1 -1
  181. package/src/client/import/import-wizard-steps.tsx +51 -39
  182. package/src/client/import/use-import-wizard-controller.test.ts +129 -0
  183. package/src/client/import/use-import-wizard-controller.ts +116 -22
  184. package/src/client/library/ArtifactRow.tsx +2 -2
  185. package/src/client/library/BackupInspectView.tsx +19 -15
  186. package/src/client/library/LibraryActions.tsx +56 -16
  187. package/src/client/library/LibraryPanel.tsx +7 -7
  188. package/src/client/library/RestorePlanView.tsx +13 -8
  189. package/src/client/locales/about.ts +0 -2
  190. package/src/client/locales/backup.ts +10 -12
  191. package/src/client/locales/common.ts +2 -0
  192. package/src/client/locales/export.ts +5 -12
  193. package/src/client/locales/foreign.ts +11 -2
  194. package/src/client/locales/import.ts +3 -2
  195. package/src/client/locales/overview.ts +4 -0
  196. package/src/client/locales/profiles.ts +32 -4
  197. package/src/client/locales/restore.ts +0 -2
  198. package/src/client/locales/sessions.ts +0 -2
  199. package/src/client/locales/shell.ts +2 -2
  200. package/src/client/market/MarketPanel.tsx +38 -20
  201. package/src/client/market/MyConfigsList.tsx +34 -32
  202. package/src/client/market/MyConfigsLoginCard.tsx +12 -15
  203. package/src/client/market/MyConfigsView.tsx +5 -5
  204. package/src/client/market/MyConfigsWizard.tsx +7 -12
  205. package/src/client/market/market-locales.ts +0 -6
  206. package/src/client/market/my-configs-split.test.ts +2 -1
  207. package/src/client/nav-menu-clip-guard.test.ts +52 -0
  208. package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
  209. package/src/client/recovery/RecoveryPanel.tsx +31 -16
  210. package/src/client/recovery/RollbackCard.tsx +58 -16
  211. package/src/client/recovery/RollbackFileChanges.tsx +40 -27
  212. package/src/client/recovery/SessionHealthCard.tsx +2 -2
  213. package/src/client/recovery/SessionHealthDialog.tsx +5 -7
  214. package/src/client/recovery/SessionLayoutSection.tsx +3 -5
  215. package/src/client/recovery/recovery-locales.ts +12 -8
  216. package/src/client/run-store.test.ts +30 -0
  217. package/src/client/run-store.ts +21 -1
  218. package/src/client/sync/AddChannelCard.tsx +65 -0
  219. package/src/client/sync/AutosyncCard.tsx +182 -108
  220. package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
  221. package/src/client/sync/ChannelConfigDialog.tsx +27 -48
  222. package/src/client/sync/MergePreviewView.tsx +3 -5
  223. package/src/client/sync/PushReportSections.tsx +35 -0
  224. package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
  225. package/src/client/sync/SyncConfirmView.tsx +3 -3
  226. package/src/client/sync/SyncLogList.tsx +16 -5
  227. package/src/client/sync/SyncPanel.tsx +153 -159
  228. package/src/client/sync/SyncProbeRow.tsx +5 -7
  229. package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
  230. package/src/client/sync/SyncSecuritySection.tsx +157 -0
  231. package/src/client/sync/SyncSettingsDialog.tsx +304 -0
  232. package/src/client/sync/SyncSettingsView.test.ts +26 -8
  233. package/src/client/sync/WorkDirCard.tsx +2 -4
  234. package/src/client/sync/config-clear-guard.test.ts +94 -0
  235. package/src/client/sync/config-clear-guard.ts +98 -0
  236. package/src/client/sync/config-dirty.test.ts +91 -0
  237. package/src/client/sync/config-dirty.ts +88 -0
  238. package/src/client/sync/history-model.test.ts +2 -0
  239. package/src/client/sync/history-model.ts +3 -0
  240. package/src/client/sync/merge-request.ts +20 -0
  241. package/src/client/sync/sync-api.ts +12 -0
  242. package/src/client/sync/sync-locales.ts +87 -47
  243. package/src/client/sync/sync-panel-clear.test.ts +44 -0
  244. package/src/client/sync/sync-view.test.ts +20 -0
  245. package/src/client/sync/sync-view.ts +42 -4
  246. package/src/core/backup.test.ts +61 -1
  247. package/src/core/backup.ts +21 -4
  248. package/src/core/boot-rescue.test.ts +35 -0
  249. package/src/core/boot-rescue.ts +13 -2
  250. package/src/core/boot-safety.test.ts +25 -0
  251. package/src/core/boot-safety.ts +37 -2
  252. package/src/core/conflict-decisions.ts +2 -1
  253. package/src/core/exporter.ts +21 -1
  254. package/src/core/journal.test.ts +183 -0
  255. package/src/core/journal.ts +163 -25
  256. package/src/core/local-plugin-host.test.ts +68 -2
  257. package/src/core/local-plugin-host.ts +31 -4
  258. package/src/core/messages.ts +14 -0
  259. package/src/core/migration-history.test.ts +27 -0
  260. package/src/core/migration-history.ts +12 -4
  261. package/src/core/model-tools.test.ts +67 -0
  262. package/src/core/model-tools.ts +16 -4
  263. package/src/core/patch-secret-guard.test.ts +110 -0
  264. package/src/core/patch-secret-guard.ts +176 -0
  265. package/src/core/reconcile.ts +32 -4
  266. package/src/core/reinstall.ts +8 -2
  267. package/src/core/restore.ts +32 -7
  268. package/src/core/section-sanitize.ts +37 -0
  269. package/src/core/snapshot-diff.test.ts +73 -1
  270. package/src/core/snapshot-diff.ts +66 -21
  271. package/src/core/startup-barrier.test.ts +64 -0
  272. package/src/core/startup-barrier.ts +8 -2
  273. package/src/core/types.ts +27 -1
  274. package/src/core/update-check.test.ts +40 -0
  275. package/src/core/update-check.ts +53 -2
  276. package/src/foreign/claude-code.test.ts +5 -0
  277. package/src/foreign/claude-plugins.test.ts +57 -0
  278. package/src/foreign/claude-sessions-bytes.test.ts +7 -1
  279. package/src/foreign/dsh.test.ts +23 -0
  280. package/src/foreign/file-budget.test.ts +7 -1
  281. package/src/foreign/kernel.ts +9 -2
  282. package/src/foreign/read-claude-plugins.ts +32 -11
  283. package/src/foreign/read-dsh.ts +33 -2
  284. package/src/foreign/read-trae.ts +117 -5
  285. package/src/foreign/session-ir.test.ts +67 -0
  286. package/src/foreign/session-ir.ts +54 -14
  287. package/src/foreign/session-read.ts +23 -0
  288. package/src/foreign/session-source.ts +15 -5
  289. package/src/foreign/trae-sqlcipher.test.ts +360 -0
  290. package/src/foreign/trae-sqlcipher.ts +564 -0
  291. package/src/foreign/trae.test.ts +188 -0
  292. package/src/foreign/trae.ts +3 -1
  293. package/src/foreign/truth-table.ts +4 -2
  294. package/src/foreign/types.ts +10 -1
  295. package/src/index.ts +1 -1
  296. package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
  297. package/src/profiles/dsh-profile-io.ts +29 -0
  298. package/src/profiles/dsh-profile-manager.test.ts +30 -0
  299. package/src/profiles/dsh-profile-manager.ts +53 -5
  300. package/src/profiles/dsh-profile-runtime.test.ts +29 -7
  301. package/src/profiles/dsh-profile-runtime.ts +17 -3
  302. package/src/profiles/process-control.test.ts +97 -0
  303. package/src/profiles/process-control.ts +28 -1
  304. package/src/routes/profiles.ts +2 -1
  305. package/src/routes/sync.ts +13 -1
  306. package/src/schema/types.ts +16 -1
  307. package/src/security/redaction.test.ts +31 -0
  308. package/src/security/redaction.ts +23 -6
  309. package/src/sync/autosync-repeat.test.ts +58 -0
  310. package/src/sync/autosync-repeat.ts +55 -0
  311. package/src/sync/autosync-scheduler.test.ts +417 -0
  312. package/src/sync/autosync-scheduler.ts +154 -41
  313. package/src/sync/baseline-heal.ts +6 -0
  314. package/src/sync/baseline-record.ts +135 -0
  315. package/src/sync/blob-store.test.ts +16 -0
  316. package/src/sync/blob-store.ts +13 -0
  317. package/src/sync/content-diff.test.ts +95 -0
  318. package/src/sync/content-diff.ts +79 -0
  319. package/src/sync/git/git-transport.test.ts +151 -4
  320. package/src/sync/git/git-transport.ts +143 -27
  321. package/src/sync/github-auth.test.ts +26 -1
  322. package/src/sync/github-auth.ts +37 -1
  323. package/src/sync/merge-apply-plan.ts +117 -0
  324. package/src/sync/messages.ts +2 -0
  325. package/src/sync/pending-merge.ts +77 -0
  326. package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
  327. package/src/sync/s3/s3-transport.ts +76 -42
  328. package/src/sync/sync-config.test.ts +39 -12
  329. package/src/sync/sync-device-identity.test.ts +3 -0
  330. package/src/sync/sync-engine.test.ts +465 -12
  331. package/src/sync/sync-engine.ts +130 -135
  332. package/src/sync/sync-history.ts +7 -0
  333. package/src/sync/sync-state.ts +48 -0
  334. package/src/sync/transport.test.ts +13 -1
  335. package/src/sync/transport.ts +12 -4
  336. package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
  337. package/src/sync/webdav/webdav-transport.ts +86 -34
  338. package/src/ui/commands.test.ts +11 -0
  339. package/src/ui/commands.ts +5 -14
  340. package/src/ui/dsh-profiles-view.test.ts +16 -0
  341. package/src/ui/dsh-profiles-view.ts +11 -5
  342. package/src/ui/foreign-view.test.ts +36 -0
  343. package/src/ui/foreign-view.ts +46 -0
  344. package/src/ui/i18n.ts +17 -2
  345. package/src/ui/menu-placement.ts +1 -1
  346. package/src/ui/migration-consult-view.test.ts +20 -1
  347. package/src/ui/migration-consult-view.ts +17 -0
  348. package/src/ui/overview-view.ts +10 -0
  349. package/src/ui/report.test.ts +25 -1
  350. package/src/ui/report.ts +15 -4
  351. package/src/ui/selection-model.test.ts +15 -1
  352. package/src/ui/selection-model.ts +18 -0
  353. package/src/utils/js-yaml4.d.ts +35 -0
  354. package/src/utils/patch-yaml.test.ts +207 -1
  355. package/src/utils/patch-yaml.ts +98 -2
  356. package/src/utils/paths.test.ts +14 -1
  357. package/src/utils/paths.ts +35 -0
  358. package/src/utils/workdir-lock.test.ts +69 -0
  359. package/src/utils/workdir-lock.ts +17 -3
  360. package/lib/ui/path-mapping.d.ts +0 -38
  361. package/lib/ui/path-mapping.js +0 -75
  362. package/src/client/common/InfoHint.tsx +0 -289
  363. package/src/client/common/info-hint-guard.test.ts +0 -1119
  364. package/src/client/sync/DecryptPasswordCard.tsx +0 -48
  365. package/src/client/sync/SecurityOptionsCard.tsx +0 -97
  366. package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
  367. package/src/ui/path-mapping.test.ts +0 -67
  368. package/src/ui/path-mapping.ts +0 -103
@@ -44,9 +44,8 @@ import type { ReactNode } from 'react'
44
44
  import type { TranslateNS } from '../client-types.ts'
45
45
  import type { SyncPullReport, SyncPushPreview, SyncPushReport } from '../../sync/sync-engine.ts'
46
46
  import type { SectionId } from '../../schema/types.ts'
47
- import { Badge, Banner, Button, Card, SectionTitle, Spinner } from '../common/ui.tsx'
47
+ import { Badge, Banner, Button, Card, Checkbox, SectionTitle, Spinner } from '../common/ui.tsx'
48
48
  import { ErrorBanner } from '../common/ErrorBanner.tsx'
49
- import { InfoHint } from '../common/InfoHint.tsx'
50
49
  import { Select } from '../common/Select.tsx'
51
50
  import { RefreshIcon } from '../common/Icon.tsx'
52
51
  import { toast } from '../common/toast-store.ts'
@@ -60,13 +59,16 @@ import type {
60
59
  SyncPushPayload, SyncStartResponse, SyncStatusResponse,
61
60
  } from './sync-api.ts'
62
61
  import { resolveSmartSync } from './sync-entry.ts'
62
+ import { consumeMergeDecision } from './merge-request.ts'
63
63
  import { reportPreviewFailure } from './preview-failure.ts'
64
64
  import { savedConfigState } from './config-save-state.ts'
65
+ import { formPatchFromStatus, markDirty, resetDirty } from './config-dirty.ts'
66
+ import { clearedChannelFormFields, prepareClear, shouldDiscardSaveResult } from './config-clear-guard.ts'
65
67
  import {
66
68
  channelMapOf, channelStateMap, computeGithubLoginView, computeSyncButtons, defaultChannelSyncState,
67
- githubPollMessage, isClientChannel, pushReportView, readStoredChannel,
69
+ githubPollMessage, isClientChannel, pushReportView, readStoredChannel, sectionCountsOf,
68
70
  gistSessionsRiskKey,
69
- initialSyncSections, normalizeSessionsLimit, syncSectionOptions, writeStoredChannel,
71
+ initialSyncSections, normalizeSessionsLimit, syncSectionOptions, writeStoredChannel, SYNC_CHANNEL_ORDER,
70
72
  } from './sync-view.ts'
71
73
  import type {
72
74
  ChannelSyncState, GithubLoginPhase, SyncChannel, SyncSectionOption,
@@ -74,7 +76,7 @@ import type {
74
76
  // t42:可测纯逻辑下沉到 src/ui(框架无关、node 可测);本组件只做装配。
75
77
  import {
76
78
  buildSelectionRequest, buildSyncChannelBody, buildSyncConfigBody, buildSyncPushBody,
77
- channelBackfillFromStatus, channelRemoteReady, cloudFormFromStatus, computeEncryptInvalid, encryptToggle,
79
+ channelBackfillFromStatus, channelRemoteReady, computeEncryptInvalid, encryptToggle,
78
80
  githubPollDecision, hasSelectedSections, includeSecretsToggle, isGithubFlowInFlight, pickSyncPrimary, resolveInitialChannel,
79
81
  needsSessionInventory, saveQueueOnFlush, saveQueueOnRequest, saveQueueOnSettled, toggleSectionSelection,
80
82
  validateCloudForm, DEFAULT_S3_PROVIDER,
@@ -83,23 +85,22 @@ import {
83
85
  import type { CloudFormIssue, SaveQueueState, SyncFormSnapshot } from '../../ui/sync-settings-view.ts'
84
86
  // t42 物理拆分:渲染段各自成文件(本领域目录平铺,不新增子目录),主文件只做装配
85
87
  import { SyncChannelEntryCard } from './SyncChannelEntryCard.tsx'
88
+ import { AddChannelCard } from './AddChannelCard.tsx'
86
89
  import { ChannelConfigDialog } from './ChannelConfigDialog.tsx'
87
90
  import { ChannelClearConfirmDialog } from './ChannelClearConfirmDialog.tsx'
88
- import { SyncSectionPickerDialog } from './SyncSectionPickerDialog.tsx'
91
+ import { SyncSettingsDialog } from './SyncSettingsDialog.tsx'
89
92
  import type { SelectionSection } from '../../ui/selection-model.ts'
90
93
  import type { ExportPreviewResponse } from '../api.ts'
91
- import { SecurityOptionsCard } from './SecurityOptionsCard.tsx'
92
- import { DecryptPasswordCard } from './DecryptPasswordCard.tsx'
93
- import { AutosyncCard } from './AutosyncCard.tsx'
94
94
  import { WorkDirCard } from './WorkDirCard.tsx'
95
95
  import { Collapse } from '../common/Motion.tsx'
96
96
  import { SyncLogList } from './SyncLogList.tsx'
97
97
  import { UnreadableSnapshotsBanner } from './UnreadableSnapshotsBanner.tsx'
98
98
  import { SyncProbeRow } from './SyncProbeRow.tsx'
99
- import { deviceLabel } from './remote-device-view.ts'
100
99
  import { PushPreviewCard } from './PushPreviewCard.tsx'
100
+ import { PushReportSections } from './PushReportSections.tsx'
101
101
  import { MergeModal } from './MergeModal.tsx'
102
102
  import { SyncActivityBar } from './SyncActivityBar.tsx'
103
+ import { deviceLabel } from './remote-device-view.ts'
103
104
  import { SyncConfirmView } from './SyncConfirmView.tsx'
104
105
  import css from '../config-manager.module.css'
105
106
 
@@ -183,6 +184,8 @@ interface SyncUiState {
183
184
  savingConfig: boolean
184
185
  busy: 'sync' | 'push' | 'pull' | 'rollback' | null
185
186
  pushReport: SyncPushReport | null
187
+ /** D-12:推送前从只读预览派生的 sectionId → 条数(预览缺失时为空 ⇒ 结果弹窗只显示分区名)。 */
188
+ pushSectionCounts: Record<string, number>
186
189
  /** P0-②:push 前只读预览弹窗(preview 结果 + 打开状态;非敏感,切 tab/刷新不丢) */
187
190
  pushPreview: PushPreviewSlice
188
191
  /**
@@ -258,6 +261,7 @@ const initial: SyncUiState = {
258
261
  savingConfig: false,
259
262
  busy: null,
260
263
  pushReport: null,
264
+ pushSectionCounts: {},
261
265
  pullReport: null,
262
266
  pushPreview: { preview: null, open: false },
263
267
  confirmSession: null,
@@ -339,8 +343,13 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
339
343
  const [mergeSeed, setMergeSeed] = useState<{ channel: SyncChannel; preview: MergePreviewResponse } | null>(null)
340
344
  /** 一键同步阶段(null = 空闲):'preview' 拉远端快照预览、'sync' 差异确认/导入;只驱动文案 */
341
345
  const [syncPhase, setSyncPhase] = useState<'preview' | 'sync' | null>(null)
342
- /** 同步分区选择弹窗开关(瞬态 UI:模式与勾选在弹窗内即时生效并持久化,关闭即完成) */
343
- const [sectionPickerOpen, setSectionPickerOpen] = useState(false)
346
+ /** issue 140:确认弹窗里的「强制推送」(内容没变也新建快照)。只影响这一次推送,不持久化。 */
347
+ const [forcePush, setForcePush] = useState(false)
348
+ /**
349
+ * 同步设置弹窗开关(2026-11-14 用户要求:同步分区 / 加密与密钥导出 / 解密密码三块收进
350
+ * 一个弹窗,页面只剩一行摘要)。瞬态 UI:改动在弹窗内即时生效并持久化,关闭即完成。
351
+ */
352
+ const [settingsOpen, setSettingsOpen] = useState(false)
344
353
  /**
345
354
  * P0-3:会话单元清单(逐会话勾选的数据源)。
346
355
  *
@@ -373,20 +382,20 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
373
382
 
374
383
  /** 勾选会话分区 + 打开弹窗时补一次清单(清单未到货则先显示加载态)。 */
375
384
  useEffect(() => {
376
- if (!sectionPickerOpen) return
385
+ if (!settingsOpen) return
377
386
  if (!needsSessionInventory(state.byChannel[state.channel].syncSections)) return
378
387
  void fetchSessionInventory()
379
388
  // 只在「弹窗打开」与「是否勾了会话」变化时触发;fetchSessionInventory 自身幂等
380
389
  // eslint-disable-next-line react-hooks/exhaustive-deps
381
- }, [sectionPickerOpen, state.byChannel[state.channel].syncSections])
390
+ }, [settingsOpen, state.byChannel[state.channel].syncSections])
382
391
 
383
392
  /**
384
- * 打开同步分区弹窗:同样先切到该通道 —— 弹窗内的勾选/会话点名都写进**该通道**的切片。
385
- * (§8 的关键修正:分区选择在通道内,不是全局一节。)
393
+ * 打开同步设置弹窗:同样先切到该通道 —— 弹窗内的勾选/会话点名/加密与密码都写进**该通道**的切片。
394
+ * (§8 的关键修正:这些设置属于通道,不是全局一节。)
386
395
  */
387
- const openSectionPickerFor = (channel: SyncChannel): void => {
396
+ const openSyncSettingsFor = (channel: SyncChannel): void => {
388
397
  switchChannel(channel)
389
- setSectionPickerOpen(true)
398
+ setSettingsOpen(true)
390
399
  }
391
400
 
392
401
  /** 会话点名清单(持久化;空数组 = 回到「最新 N 个」模式)。 */
@@ -457,6 +466,13 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
457
466
  const saveTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
458
467
  /** 保存防重入状态机的纯数据(在途标记 + 待发改动;t42 起由 ui/sync-settings-view.ts 决策) */
459
468
  const saveQueueRef = useRef<SaveQueueState>({ inFlight: false, pending: null })
469
+ /** P9-4/P9-5 时序守卫:用户改过但未落盘的表单字段 / 断开世代号 */
470
+ const dirtyRef = useRef<Set<string>>(new Set()); const epochRef = useRef(0)
471
+ /** 丢掉该通道还没发出去的输入(防抖 timer + 排队载荷)。keepInFlight=true 供断开前等待用(清掉 inFlight 会让等待立刻放行)。 */
472
+ const dropPendingSave = (keepInFlight: boolean): void => {
473
+ if (saveTimer.current !== null) { clearTimeout(saveTimer.current); saveTimer.current = null }
474
+ saveQueueRef.current = { inFlight: keepInFlight && saveQueueRef.current.inFlight, pending: null }
475
+ }
460
476
  /** 正在拉取远端快照列表(按通道独立防抖/防并发) */
461
477
  const loadingSnapshotsRef = useRef<Record<SyncChannel, boolean>>(channelMapOf(() => false))
462
478
 
@@ -496,14 +512,9 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
496
512
  loading: false,
497
513
  statusInfo: info,
498
514
  channel: remembered ?? savedChannel,
499
- repoUrl: info.repoUrl ?? '',
500
- gitSubdir: info.subdir ?? '',
501
- webdavUrl: info.webdav?.url ?? '',
502
- webdavUsername: info.webdav?.username ?? '',
503
515
  catalog,
504
516
  byChannel: channelMapOf((ch) => ({ ...stateRef.current.byChannel[ch], ...backfill(ch) })),
505
- // 云端点非密字段回填(s3/gist 的密钥值永不回传:只回 secretStored 布尔,供徽章显示)
506
- ...cloudFormFromStatus(info),
517
+ ...formPatchFromStatus(info, dirtyRef.current),
507
518
  })
508
519
  // 独立拉取 autosync(若 status 未带按通道状态则补一次)
509
520
  if (autoByCh === undefined) {
@@ -588,7 +599,13 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
588
599
  }
589
600
 
590
601
  useEffect(() => {
591
- void loadStatus()
602
+ void (async () => {
603
+ await loadStatus()
604
+ // P2(2026-11-14 真机事故):首页「待裁决」活动行用一次性信号把用户送到这里
605
+ // (merge-request.ts;取走即清空)。首页只知道「有事要裁决」,怎么把裁决视图
606
+ // 拉起来只有这里知道 —— 一键同步 → /sync/merge-preview → MergeModal。
607
+ if (consumeMergeDecision() > 0) void runSyncSmart(stateRef.current.channel)
608
+ })()
592
609
  // api 为注入单例(注册时创建),生命周期内稳定;仅挂载时加载一次
593
610
  // eslint-disable-next-line react-hooks/exhaustive-deps
594
611
  }, [])
@@ -638,47 +655,54 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
638
655
  /** 表单快照 → 请求体(t42 起组装逻辑在 ui/sync-settings-view.ts,组件只装配) */
639
656
  const payload = (): SyncPushPayload => buildSyncChannelBody(formOf(state))
640
657
 
641
- /* ------------------------------------------------ 通道配置持久化(自动保存 + 显式保存) */
658
+ /* ------------------------------------------------ 通道配置持久化(全自动保存:防抖 + 卸载补发) */
642
659
 
643
660
  /** 按给定 state 构建「保存配置」请求体;当前通道远端地址未就绪(webdav url / git repoUrl 为空)
644
661
  * → 返回 null(无可保存内容,自动保存跳过)。password/token 仅非空携带(空 = 沿用已保存凭据)。 */
645
662
  const buildConfigPayload = (s: SyncUiState): SyncPushPayload | null => buildSyncConfigBody(formOf(s))
646
663
 
647
- /** 实际发送保存请求:成功清空已入库的 password/token(与 push 一致)并刷新凭据徽章;
648
- * 失败保留表单值以便重试。防重入:保存中又排入新改动 → 完成后自动补发最新 payload。
649
- * announce:仅「手动点保存」为 true —— 自动保存(输入防抖)成功时不弹 Toast,
650
- * 否则每次停顿改字段都会刷一条通知;但**失败必须始终提示**(用户的改动没落盘)。 */
651
- const doSaveConfig = async (payloadToSave: SyncPushPayload, announce = false): Promise<void> => {
664
+ /** 实际发送保存请求:成功清空已入库的 password/token 并刷新凭据徽章;失败保留表单值以便重试。
665
+ * 防重入:保存中又排入新改动 → 完成后补发。成功只闪「已保存」徽章(弹窗标题行),失败必须提示。 */
666
+ const doSaveConfig = async (payloadToSave: SyncPushPayload): Promise<void> => {
652
667
  // t42:防重入状态机(在途 → 记下最新待发改动并返回 'queue')在 ui/sync-settings-view.ts
653
668
  const decision = saveQueueOnRequest(saveQueueRef.current, payloadToSave)
654
669
  saveQueueRef.current = decision.state
655
670
  if (decision.action === 'queue') return
656
671
  patch({ savingConfig: true })
672
+ const sendEpoch = epochRef.current // P9-5:期间用户断开通道 ⇒ 这次回执描述的配置已不存在(见下)
673
+ let stale = false
657
674
  try {
658
675
  const saved = await api.saveConfig(payloadToSave)
659
- // 基于 stateRef 计算(同步权威),经 commit 落库:即使保存完成时组件已卸载
660
- // (切走 tab),savingConfig 复位与凭据清空仍会镜像进 store,切回后一致
661
- const s = stateRef.current
662
- // 凭据清空 + 徽章合并的自包含演算下沉到 ./config-save-state.ts(本文件有行数棘轮)
663
- const next: SyncUiState = { ...s, ...savedConfigState(s, saved, payloadToSave) }
664
- commit(next)
665
- // M-17:手动保存给出 toast 回执;自动保存不弹 toast(防抖会刷屏),改为计数 +1 → 弹窗内的「已保存」徽章
666
- if (announce) toast.ok(t('toast.configSaved'))
667
- else setSaveTick((n) => n + 1)
668
- // 手动填入的 git token 保存成功 → 校验有效性(有效则隐藏 GitHub 登录块)。
669
- // 只有 git 通道用 SYNC_CREDENTIAL_REF:云端点通道的密钥走各自的槽位,与 GitHub 登录无关。
670
- if (payloadToSave.transport === 'git' && saved.credentialConfigured) {
671
- void validateGithub()
676
+ stale = shouldDiscardSaveResult(sendEpoch, epochRef.current)
677
+ if (stale) {
678
+ // 回执作废:一个字段都不写回(清空的地址/凭据不能复活);断开前已等在途保存落定 ⇒ 宿主不会晚到写,故不做自愈 clear(反方实测:会把随后保存成功的新配置连凭据一起删掉)。
679
+ if (!saveQueueRef.current.inFlight) patch({ savingConfig: false })
680
+ } else {
681
+ // 基于 stateRef 计算(同步权威)后 commit 落库:即使保存完成时组件已卸载(切走 tab),
682
+ // savingConfig 复位与凭据清空仍镜像进 store,切回后一致
683
+ const s = stateRef.current
684
+ // 凭据清空 + 徽章合并的自包含演算下沉到 ./config-save-state.ts(本文件有行数棘轮)
685
+ const next: SyncUiState = { ...s, ...savedConfigState(s, saved, payloadToSave) }
686
+ commit(next)
687
+ dirtyRef.current = resetDirty() // 宿主回执即权威:落盘字段不再算「用户输入中」
688
+ // M-17:成功只闪「已保存」徽章(防抖保存不弹 toast,否则每次停顿都刷屏);计数 +1 让连续保存各闪一次
689
+ setSaveTick((n) => n + 1)
690
+ // 手动填入的 git token 保存成功 → 校验有效性(有效则隐藏 GitHub 登录块)。
691
+ // 只有 git 通道用 SYNC_CREDENTIAL_REF:云端点通道的密钥走各自的槽位,与 GitHub 登录无关。
692
+ if (payloadToSave.transport === 'git' && saved.credentialConfigured) void validateGithub()
672
693
  }
673
694
  } catch (err) {
674
- // R-20:保存失败**始终**提示(无论手动还是自动)——用户的改动没有落盘
695
+ // R-20:保存失败**始终**提示 —— 用户的改动没有落盘,静默等于骗人
675
696
  toast.error(t('toast.configSaveFailed') + t('common.labelSeparator') + redact(err instanceof Error ? err.message : String(err)))
676
697
  patch({ savingConfig: false })
677
698
  } finally {
678
- // 保存期间又排入的新改动 → 立即补发(保底,不丢输入)
679
- const settled = saveQueueOnSettled(saveQueueRef.current)
680
- saveQueueRef.current = settled.state
681
- if (settled.next !== null) void doSaveConfig(settled.next, announce)
699
+ // 保存期间又排入的新改动 → 立即补发(保底,不丢输入)。
700
+ // 回执作废时队列已由 onChannelCleared 重置、此刻可能有**新的**保存正飞 —— 再写 inFlight 会让防重入失效。
701
+ if (!stale) {
702
+ const settled = saveQueueOnSettled(saveQueueRef.current)
703
+ saveQueueRef.current = settled.state
704
+ if (settled.next !== null) void doSaveConfig(settled.next)
705
+ }
682
706
  }
683
707
  }
684
708
 
@@ -698,9 +722,8 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
698
722
  }, SYNC_CONFIG_SAVE_DEBOUNCE_MS)
699
723
  }
700
724
 
701
- /** 立即保存(「保存配置」按钮 / 防抖到点):优先待发改动,否则按当前表单值。
702
- * announce:仅手动点按钮为 true —— 自动保存成功不弹回执(见 doSaveConfig)。 */
703
- const flushConfigSave = (announce = false): void => {
725
+ /** 立即保存(防抖到点 / 卸载补发共用):优先待发改动,否则按当前表单值。 */
726
+ const flushConfigSave = (): void => {
704
727
  if (saveTimer.current !== null) {
705
728
  clearTimeout(saveTimer.current)
706
729
  saveTimer.current = null
@@ -708,40 +731,23 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
708
731
  // t42:flush 取哪个载荷(优先待发改动,否则按当前表单值重建)由纯函数决策
709
732
  const flushed = saveQueueOnFlush(saveQueueRef.current, buildConfigPayload(stateRef.current))
710
733
  saveQueueRef.current = flushed.state
711
- if (flushed.payload === null) {
712
- // M-17:手动点保存但地址未填写 → 此前直接 return(按钮看起来无反应),现给出明确提示
713
- if (announce) toast.info(t('toast.configNothingToSave'))
714
- return
715
- }
716
- void doSaveConfig(flushed.payload, announce)
734
+ if (flushed.payload === null) return // 地址还没填全:无可保存内容(表单会校验并内联报错)
735
+ void doSaveConfig(flushed.payload)
717
736
  }
718
737
 
719
738
  /* ------------------------------------------------ 断开通道配置(用户要求:配置过必须能删掉) */
720
739
 
721
- /** 断开成功后的收尾:清该通道的表单残留 + 撤销在途自动保存 + 重拉 status(徽章/配置态/地址重算)。
722
- * 撤销自动保存是必须的:否则防抖到点的旧 payload 会把刚删掉的配置又写回去。 */
740
+ /** 断开成功后收尾:清表单残留 + 撤销在途自动保存 + 重拉 status;在途请求取消不掉 → 递增世代让回执作废。 */
723
741
  const onChannelCleared = (channel: SyncChannel): void => {
724
742
  setClearTarget(null)
725
- if (saveTimer.current !== null) { clearTimeout(saveTimer.current); saveTimer.current = null }
726
- saveQueueRef.current = { inFlight: false, pending: null }
727
- // 断开 git = 删掉 SYNC_CREDENTIAL_REF(GitHub 登录与手动 token 是**同一个槽位**)→ 登录态必然失效。
728
- // 不在这里复位的话 githubSignedIn 会一直是 true、登录块恒隐藏:用户以为断开了还能重新登录,
729
- // 实际要重启 profile 才看得到登录入口(真机用户报告)。进行中的轮询也要一并停掉。
730
- if (channel === 'git') {
731
- if (githubPollTimer.current !== null) { clearTimeout(githubPollTimer.current); githubPollTimer.current = null }
732
- }
743
+ dropPendingSave(false); epochRef.current += 1
744
+ dirtyRef.current = resetDirty()
745
+ // 断开 git = 删掉 SYNC_CREDENTIAL_REF(与手动 token 同槽位)→ 登录态必然失效:不复位 githubSignedIn 会恒隐藏
746
+ // 登录块(用户以为还能重新登录,真机报告);进行中的轮询一并停掉。
747
+ if (channel === 'git' && githubPollTimer.current !== null) { clearTimeout(githubPollTimer.current); githubPollTimer.current = null }
733
748
  patch({
734
749
  ...(channel === 'git' ? { githubSignedIn: false, github: initialGithub } : {}),
735
- ...(channel === 'webdav'
736
- ? { webdavUrl: '', webdavUsername: '', webdavPassword: '' }
737
- : channel === 's3'
738
- ? {
739
- s3Endpoint: '', s3Region: '', s3Bucket: '', s3Prefix: '', s3AccessKeyId: '',
740
- s3Secret: '', s3PathStyle: false, s3Provider: DEFAULT_S3_PROVIDER,
741
- }
742
- : channel === 'gist'
743
- ? { gistId: '', gistApiBaseUrl: '', gistFilePrefix: '', gistToken: '' }
744
- : { repoUrl: '', token: '' }),
750
+ ...clearedChannelFormFields(channel),
745
751
  })
746
752
  patchChannelOf(channel, { snapshots: [], selectedSnapshotId: '' })
747
753
  void loadStatus()
@@ -859,7 +865,7 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
859
865
  if (phase === 'starting' || phase === 'waiting' || phase === 'polling') {
860
866
  void runGithubCancel()
861
867
  }
862
- setChannelOpen(false)
868
+ dirtyRef.current = resetDirty(); setChannelOpen(false)
863
869
  }
864
870
 
865
871
  /**
@@ -887,11 +893,14 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
887
893
 
888
894
  /** P0-②:确认弹窗里点「确认推送」→ 真正推送(复用既有 push 语义)。 */
889
895
  const runPush = async (): Promise<void> => {
890
- patch({ busy: 'push', pushReport: null })
896
+ // D-12:条数只能取这次推送前的预览(成功分支会把 pushPreview 清空),必须在 await 之前抓。
897
+ const pushSectionCounts = sectionCountsOf(stateRef.current.pushPreview.preview?.sections)
898
+ patch({ busy: 'push', pushReport: null, pushSectionCounts })
891
899
  try {
892
900
  // 推送前先把加密密码落库(下次推送不必重输)
893
901
  await persistEncryptPassword()
894
- const report = await api.push(buildPushPayload())
902
+ // issue 140:force 只在这一次请求里生效(勾选框默认关 = 内容没变就跳过)
903
+ const report = await api.push({ ...buildPushPayload(), ...(forcePush ? { force: true } : {}) })
895
904
  // 成功即清空 token/webdavPassword/加密密码输入框;失败保留以便重试
896
905
  patch({
897
906
  busy: null, pushReport: report, pushPreview: { preview: null, open: false },
@@ -902,8 +911,9 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
902
911
  if (report.ok) {
903
912
  // 输入框清空,但「已保存」标记保留 —— 密码在本机凭据库里,下次留空即用
904
913
  patchChannel({ encryptPassword: '', encryptPasswordConfirm: '' })
905
- // M-19:推送终局回执(结果弹窗关闭后不再有任何痕迹)
906
- toast.ok(t('toast.pushDone'))
914
+ // M-19:推送终局回执(结果弹窗关闭后不再有任何痕迹)。
915
+ // issue 140:没新建快照时必须说「已跳过」,不能报「已推送」。
916
+ toast.ok(report.skipped === 'unchanged' ? t('toast.pushSkipped') : t('toast.pushDone'))
907
917
  void loadSnapshots()
908
918
  } else {
909
919
  // 失败保留结果弹窗(K-15,含告警明细);同时给出不依赖弹窗的回执
@@ -1010,7 +1020,10 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1010
1020
 
1011
1021
  /* ------------------------------------------------ 一键同步(方案 A) */
1012
1022
 
1013
- /** 一键同步:拉取 → 差异确认会话(先取消旧会话,再发起新会话)。 */
1023
+ /**
1024
+ * 一键同步:拉取 → 差异确认会话(先取消旧会话,再发起新会话)。
1025
+ * snapshotId 缺省 = 用远端最新快照(快照行选过才传具体 id)。
1026
+ */
1014
1027
  const runSync = async (snapshotId?: string): Promise<void> => {
1015
1028
  // 清理旧的差异确认会话(避免残留临时 ZIP / 同 key 冲突)
1016
1029
  if (state.confirmSession !== null) {
@@ -1102,6 +1115,7 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1102
1115
  const switchChannel = (ch: SyncChannel): void => {
1103
1116
  if (ch === state.channel || state.busy !== null) return
1104
1117
  patch({ channel: ch })
1118
+ dirtyRef.current = resetDirty() // 旧通道的 dirty 不得永久屏蔽新通道的同名键
1105
1119
  writeStoredChannel(ch) // 同步写 localStorage 立即生效(status 未带回填时的兜底)
1106
1120
  // 异步持久化到磁盘(ui-prefs.json,随 self 分区进导出备份);失败静默降级
1107
1121
  void api.saveUiPrefs({ lastSyncChannel: ch }).catch(() => { /* 保存失败不阻断切换 */ })
@@ -1167,9 +1181,7 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1167
1181
  const remoteReadyOf = (channel: SyncChannel): boolean => channelRemoteReady({ ...formOf(state), channel })
1168
1182
  /** 云端点表单的校验问题(对话框内联提示用;git/webdav 恒为空表)。 */
1169
1183
  const cloudIssues: CloudFormIssue[] = validateCloudForm(formOf(state))
1170
- /** 激活通道的远端就绪态(弹窗 / 页面级判断用) */
1171
- const remoteReady = remoteReadyOf(state.channel)
1172
- const pushView = pushReportView(state.pushReport, uiT)
1184
+ const pushView = pushReportView(state.pushReport, uiT, state.pushSectionCounts)
1173
1185
  const githubView = computeGithubLoginView(
1174
1186
  state.github.phase, state.github.userCode, state.github.verificationUri, state.github.error, uiT,
1175
1187
  )
@@ -1209,6 +1221,8 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1209
1221
  const channelContentId = (c: SyncChannel): string => 'sync-channel-' + c
1210
1222
 
1211
1223
  const renderChannelCard = (channel: SyncChannel): ReactNode => {
1224
+ // 2026-11-14:只渲染**已配置**的通道卡(判据只有 remoteReadyOf 一处),其余进 AddChannelCard
1225
+ if (!remoteReadyOf(channel)) return null
1212
1226
  const cs = channelStateOf(channel)
1213
1227
  const ready = remoteReadyOf(channel)
1214
1228
  const busy = state.busy !== null
@@ -1232,24 +1246,21 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1232
1246
  <Collapse open={ready && isChannelExpanded(channel)} id={channelContentId(channel)} className={css.syncChannelBody}>
1233
1247
  {ready && (
1234
1248
  <Card>
1235
- {/* 同步内容跟着通道卡走 —— autosync 与 sync-selection 都按通道独立,做成全局一节
1236
- 会让用户以为两个通道共用一份选择(§8 的关键修正)。
1237
- 2026-11-01:原为独立一张卡,卡内只有「9 selected」+ 一个 Choose…,右侧四百多像素
1238
- 全空(app-screens §4.2 卡内死空间,白吃约 115px 把 Auto Sync 挤出画布)。改成本卡
1239
- 内的选择行:它本来就是动作的前置条件(选哪些分区的改动才参与合并/推送)。 */}
1240
- {/* ⓘ 一律跟在**相关标题/操作的右边**(同一行):单独成行会让卡片出现「孤零零一个图标」
1241
- 的断行。标题内联沿用 AboutPanel / EnvironmentPanel 的既有写法(零新增样式)。 */}
1249
+ {/* 摘要行(2026-11-14 用户要求:分区 / 加密 / 解密三块收进「同步设置」弹窗,
1250
+ 卡内只留一行)。留下的是 push 之前**必须看见**的两个判断依据:选了多少分区、
1251
+ 加密开没开 —— 不需要的说明文字一律不进这一行。设置仍按通道独立(§8),
1252
+ 点按钮前先 switchChannel,弹窗里的改动写进该通道的切片。 */}
1242
1253
  <div className={css.sectionPickerRow}>
1243
- <span className={css.groupLabel}>{t('mode.title')} <InfoHint text={t('mode.hint')} label={t('common.infoHint')} /></span>
1254
+ <span className={css.groupLabel}>{t('mode.title')}</span>
1244
1255
  <span className={css.categoryDesc}>
1245
1256
  {state.loadError !== null ? t('load.failed')
1246
1257
  : state.catalog.length === 0 ? t('common.loading')
1247
1258
  : t('mode.selectedCount', { n: String(cs.syncSections.length), total: String(state.catalog.length) })}
1248
1259
  </span>
1249
- {/* 按钮靠右成列(2026-11-01 用户要求:左描述、右按钮)。行内不再挂「已保存」ⓘ ——
1250
- 它在说一件用户无从选择的事(选完自然保存),与弹窗底那颗重复。 */}
1251
- <Button className={css.pickerBtn} onClick={() => { openSectionPickerFor(channel) }} disabled={busy}>
1252
- {t('mode.choose')}
1260
+ <Badge kind={cs.encrypt ? 'ok' : 'info'}>{cs.encrypt ? t('mode.encryptOn') : t('mode.encryptOff')}</Badge>
1261
+ {/* 这一行只剩「设置」入口:只读自检回到它服务的快照行(低频诊断与受控控件同排)。 */}
1262
+ <Button className={css.pickerBtn} onClick={() => { openSyncSettingsFor(channel) }} disabled={busy}>
1263
+ {t('mode.settingsOpen')}
1253
1264
  </Button>
1254
1265
  </div>
1255
1266
  {cs.syncSections.length === 0 && <Banner kind="warn">{t('mode.atLeastOne')}</Banner>}
@@ -1322,42 +1333,11 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1322
1333
  </span>
1323
1334
  )}
1324
1335
  </div>
1325
-
1326
- {/* 自动同步行(按通道;文案与倒计时在卡内派生) */}
1327
- <AutosyncCard
1328
- t={t}
1329
- uiT={uiT}
1330
- settings={cs}
1331
- busy={busy}
1332
- onToggleAutosync={(enabled) => { void toggleAutosync(channel, enabled) }}
1333
- onUpdateInterval={(interval) => { void updateAutosyncInterval(channel, interval) }}
1334
- onUpdateOptions={(patch) => { void updateAutosyncOptions(channel, patch) }}
1335
- />
1336
1336
  </Card>
1337
1337
  )}
1338
- {/* v3(P-IA-7 / §2.2-6):加密与解密**属于这一条通道**,因此渲染在它自己的卡里。
1339
- 此前这两张卡挂在页面级、绑定一个被「点某张卡的按钮」悄悄切换的隐式当前通道 ——
1340
- 用户会以为四个通道共用一份加密设置。现在每张已配置的通道卡各自持有自己的凭据区,
1341
- 所有 handler 都显式传 channel(不再读 state.channel)。 */}
1342
- {ready && (
1343
- <SecurityOptionsCard
1344
- t={t}
1345
- settings={cs}
1346
- onToggleEncrypt={(next) => { setEncrypt(channel, next) }}
1347
- onToggleIncludeSecrets={(next) => { setIncludeSecrets(channel, next) }}
1348
- onPatchSettings={(p) => { patchChannelOf(channel, p) }}
1349
- onPersistEncryptPassword={() => { void persistEncryptPassword(channel) }}
1350
- />
1351
- )}
1352
- {ready && (
1353
- <DecryptPasswordCard
1354
- t={t}
1355
- settings={cs}
1356
- onPatchSettings={(p) => { patchChannelOf(channel, p) }}
1357
- onPersistDecryptPassword={() => { void persistDecryptPassword(channel) }}
1358
- onClearSavedPassword={() => { clearSavedDecryptPassword(channel) }}
1359
- />
1360
- )}
1338
+ {/* v3(P-IA-7 / §2.2-6)的教训保留:加密与解密**属于这一条通道**。
1339
+ 2026-11-14 起它们搬进「同步设置」弹窗(入口是上方摘要行的按钮),打开前先 switchChannel,
1340
+ 弹窗内每个 handler 都写该通道的切片 —— 仍然不会出现「四个通道共用一份加密设置」。 */}
1361
1341
  {/* issue #79:工作副本(git 专属;确认弹窗/宿主调用/回执全在 WorkDirCard.tsx) */}
1362
1342
  {ready && channel === 'git' && <WorkDirCard t={t} api={api} workDir={state.statusInfo?.workDir} busy={busy} onChanged={() => { void loadStatus() }} />}
1363
1343
  {/* issue #59:远端快照列表不完整时的常驻告知(push 报成功但列表为空时,这里是唯一线索)。
@@ -1371,7 +1351,7 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1371
1351
  /* ------------------------------------------------ 渲染 */
1372
1352
  return (
1373
1353
  <div className={css.viewBody}>
1374
- <SectionTitle title={t('section.label')} info={<InfoHint text={t('section.description')} label={t('common.infoHint')} />} />
1354
+ <SectionTitle title={t('section.label')} tooltip={t('section.description')} />
1375
1355
 
1376
1356
  {/* M-16:页面级加载失败就地提示(此前 loadError 只写不读,宿主不可达时整页显示
1377
1357
  「未配置」假象)。此处保留可就地重试的 ErrorBanner —— 它是**页面是否可用**
@@ -1385,13 +1365,14 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1385
1365
  />
1386
1366
  )}
1387
1367
 
1388
- {/* 两个通道卡**恒显示**(§8 定案):未配置的走矮态。
1389
- 一致、可发现,配置入口永远在同一位置 —— 不做「只显示已配置的」那种
1390
- 随状态变化的页面结构(配完 Git 回来看不到 WebDAV 只会被当成 bug)。 */}
1368
+ {/* 2026-11-14 用户要求:页面只留**已配置**的通道卡,其余通道收进末尾那张「添加通道」卡
1369
+ (点开选通道 → 进配置弹窗)。此前四张恒显示、理由是「配完 Git 找不到 WebDAV 会被当成
1370
+ bug」;那条理由现在由 AddChannelCard 承接 —— 只要还有未配置通道,它就常驻页面末尾。 */}
1391
1371
  {renderChannelCard('git')}
1392
1372
  {renderChannelCard('webdav')}
1393
1373
  {renderChannelCard('s3')}
1394
1374
  {renderChannelCard('gist')}
1375
+ <AddChannelCard t={t} channels={SYNC_CHANNEL_ORDER.filter((c) => !remoteReadyOf(c))} onPick={openChannelDialogFor} />
1395
1376
  {/* 通道配置弹窗(渲染段拆到 ChannelConfigDialog,t42):只配置**打开它的那条通道**,弹窗内不提供切换 */}
1396
1377
  <ChannelConfigDialog
1397
1378
  open={channelOpen}
@@ -1402,22 +1383,21 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1402
1383
  cloudIssues={cloudIssues}
1403
1384
  busy={state.busy !== null}
1404
1385
  savingConfig={state.savingConfig}
1405
- remoteReady={remoteReady}
1406
1386
  statusInfo={state.statusInfo}
1407
1387
  githubSignedIn={state.githubSignedIn}
1408
1388
  saveTick={saveTick}
1409
1389
  githubView={githubView}
1410
1390
  onClose={closeChannelDialog}
1411
- onFormChange={(p) => { patch(p); scheduleConfigSave() }}
1391
+ onFormChange={(p) => { dirtyRef.current = markDirty(dirtyRef.current, Object.keys(p)); patch(p); scheduleConfigSave() }}
1412
1392
  onGithubStart={() => { void runGithubStart() }}
1413
1393
  onGithubCancel={() => { void runGithubCancel() }}
1414
- onSave={() => { flushConfigSave(true) }}
1415
1394
  />
1416
1395
  {/* 断开通道配置的二次确认:**独立于配置弹窗**(不在弹窗里嵌套弹窗 —— Radix 遮罩层
1417
1396
  嵌套会让内层点不动,见 Modal.tsx 的说明)。确认成功后由 onChannelCleared 统一收尾。 */}
1418
1397
  {clearTarget !== null && (
1419
1398
  <ChannelClearConfirmDialog
1420
1399
  open channel={clearTarget} api={api} t={t}
1400
+ beforeClear={() => prepareClear({ cancelPendingSave: () => dropPendingSave(true), isBusy: () => saveQueueRef.current.inFlight, busyMessage: t('channel.clearBusy') })}
1421
1401
  onCancel={() => { setClearTarget(null) }}
1422
1402
  onCleared={() => { onChannelCleared(clearTarget) }}
1423
1403
  />
@@ -1427,9 +1407,12 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1427
1407
  与页面级各渲染一次(重复表达),且页面级那张绑定的是隐式的「当前通道」。
1428
1408
  分区选择现在只存在于它所属的通道卡内(§2.2-6、不变量 §3-19)。 */}
1429
1409
 
1430
- {/* 同步分区弹窗(渲染段拆到 SyncSectionPickerDialog,t42) */}
1431
- <SyncSectionPickerDialog
1432
- open={sectionPickerOpen}
1410
+ {/* 同步设置弹窗(渲染段拆到 SyncSettingsDialog / SyncSecuritySection)。
1411
+ 2026-11-14 用户要求:分区 / 自动同步 / 加密与密钥导出 / 解密密码四块收进这一个弹窗,
1412
+ 页面只留一行摘要。内含三个页签:「同步内容」(分区 + 会话点名)/「自动同步」
1413
+ (整块复用 AutosyncCard)/「加密与密码」;通道卡只保留快照行与两枚方向按钮。 */}
1414
+ <SyncSettingsDialog
1415
+ open={settingsOpen}
1433
1416
  t={t}
1434
1417
  cmT={cmT}
1435
1418
  uiT={uiT}
@@ -1446,16 +1429,23 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1446
1429
  onSessionsLimit={(value) => { setSessionsLimit(state.channel, value) }}
1447
1430
  onSessionsInclude={(ids) => { setSessionsInclude(state.channel, ids) }}
1448
1431
  onToggleDeletePlugins={(next) => { setDeletePlugins(state.channel, next) }}
1449
- onClose={() => { setSectionPickerOpen(false) }}
1432
+ busy={state.busy !== null}
1433
+ onToggleAutosync={(enabled) => { void toggleAutosync(state.channel, enabled) }}
1434
+ onUpdateAutosyncInterval={(interval) => { void updateAutosyncInterval(state.channel, interval) }}
1435
+ onUpdateAutosyncOptions={(patchOptions) => { void updateAutosyncOptions(state.channel, patchOptions) }}
1436
+ settings={chState}
1437
+ {...(state.statusInfo?.pendingMerge === undefined ? {} : { pendingMerge: state.statusInfo.pendingMerge })}
1438
+ onToggleEncrypt={(next) => { setEncrypt(state.channel, next) }}
1439
+ onToggleIncludeSecrets={(next) => { setIncludeSecrets(state.channel, next) }}
1440
+ onPatchSettings={(patchSettings) => { patchChannelOf(state.channel, patchSettings) }}
1441
+ onPersistEncryptPassword={() => { void persistEncryptPassword(state.channel) }}
1442
+ onPersistDecryptPassword={() => { void persistDecryptPassword(state.channel) }}
1443
+ onClearSavedPassword={() => { clearSavedDecryptPassword(state.channel) }}
1444
+ onClose={() => { setSettingsOpen(false) }}
1450
1445
  />
1451
1446
  {/* v3:页面级的加密/解密/快照列表卡已移入各自的通道卡(见 renderChannelCard)。 */}
1452
- {/* 同步记录(只留操作日志):远端快照行已搬进产物库(§8)。
1453
- 这条指路行是**必须的** —— 否则用户会以为「远端快照不见了」。 */}
1454
- <div className={css.actionRow}>
1455
- <Button size="sm" onClick={() => { runStore.patch({ panel: 'library', library: { sourceFilter: 'remote-snapshot' } }) }}>
1456
- {t('history.remoteMovedAction')}
1457
- </Button>
1458
- </div>
1447
+ {/* 同步记录(只留操作日志)。2026-11-14 用户要求删掉原先那条「在产物库查看远端快照」
1448
+ 指路按钮:远端快照本来就在产物库的来源页签里,页面不必另递一只手指过去。 */}
1459
1449
  <SyncLogList api={api} t={t} />
1460
1450
 
1461
1451
  {/* P0-②:push 前只读预览确认弹窗(「将推送什么」→ 确认后才真正上传;Radix Modal) */}
@@ -1474,6 +1464,14 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1474
1464
  />
1475
1465
  <Modal.Body scroll>
1476
1466
  <PushPreviewCard preview={state.pushPreview.preview} t={t} uiT={uiT} sectionName={sectionName} />
1467
+ {/* issue 140:内容没变时缺省不新建快照(远端不再堆重复快照)。要「就算一样也新建」
1468
+ 必须在这里显式勾选 —— 与 agent 侧的 force 是同一个开关,只是给了等价入口。 */}
1469
+ <Checkbox
1470
+ checked={forcePush}
1471
+ onChange={setForcePush}
1472
+ disabled={state.busy === 'push'}
1473
+ label={t('syncflow.pushForce')}
1474
+ />
1477
1475
  </Modal.Body>
1478
1476
  <Modal.Footer>
1479
1477
  <Button
@@ -1507,20 +1505,16 @@ export function SyncPanel({ api, t, cmT }: SyncPanelProps) {
1507
1505
  />
1508
1506
  <Modal.Body scroll style={{ maxHeight: '70vh' }}>
1509
1507
  {pushView !== null && (<>
1510
- <Banner kind={pushView.kind === 'ok' ? 'ok' : 'error'}>{pushView.headline}</Banner>
1508
+ <Banner kind={pushView.kind === 'ok' ? 'ok' : pushView.kind === 'skipped' ? 'info' : 'error'}>{pushView.headline}</Banner>
1511
1509
  {pushView.sections.length > 0 && (
1512
- <div>
1513
- <span className={css.fieldLabel}>{t('sections.title')}</span>
1514
- <div className={css.statRow}>
1515
- {pushView.sections.map((s) => <Badge key={s} kind="info">{s}</Badge>)}
1516
- </div>
1517
- </div>
1510
+ <PushReportSections sections={pushView.sections} counts={pushView.counts}
1511
+ sectionName={(id) => sectionName(id as SectionId)} label={t('sections.title')} />
1518
1512
  )}
1519
1513
  {pushView.warnings.length > 0 && (
1520
1514
  <div>
1521
1515
  <span className={css.fieldLabel}>{t('warnings.title')}</span>
1522
1516
  <ul className={css.warnList}>
1523
- {pushView.warnings.map((w, i) => <li key={i}>{w}</li>)}
1517
+ {pushView.warnings.map((w, i) => <li key={i}>{redact(w)}</li>)}
1524
1518
  </ul>
1525
1519
  </div>
1526
1520
  )}