dsh-config-manager 0.8.2 → 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.
- package/lib/adapters/mcp.js +51 -15
- package/lib/adapters/messages.d.ts +1 -0
- package/lib/adapters/messages.js +2 -0
- package/lib/adapters/patch-key-guard.d.ts +23 -0
- package/lib/adapters/patch-key-guard.js +13 -0
- package/lib/adapters/plugin-data.d.ts +19 -5
- package/lib/adapters/plugin-data.js +76 -22
- package/lib/adapters/plugins.d.ts +14 -1
- package/lib/adapters/plugins.js +204 -6
- package/lib/adapters/prompts.js +15 -4
- package/lib/adapters/test-helpers.d.ts +15 -1
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.d.ts +7 -105
- package/lib/cli/actions.js +16 -172
- package/lib/cli/control-state.d.ts +54 -0
- package/lib/cli/control-state.js +107 -0
- package/lib/cli/help.d.ts +1 -1
- package/lib/cli/help.js +21 -14
- package/lib/cli/index.js +132 -104
- package/lib/cli/sessions-repair.js +58 -22
- package/lib/cli/web/client-script.d.ts +1 -1
- package/lib/cli/web/client-script.js +71 -5
- package/lib/cli/web/page.d.ts +9 -19
- package/lib/cli/web/page.js +277 -173
- package/lib/cli/web/routes.js +85 -25
- package/lib/cli/write-gates.d.ts +61 -0
- package/lib/cli/write-gates.js +110 -0
- package/lib/client.d.ts +196 -75
- package/lib/client.js +8139 -7487
- package/lib/core/backup.d.ts +0 -4
- package/lib/core/backup.js +21 -4
- package/lib/core/boot-rescue.d.ts +1 -1
- package/lib/core/boot-rescue.js +12 -1
- package/lib/core/boot-safety.js +37 -2
- package/lib/core/conflict-decisions.js +2 -1
- package/lib/core/exporter.js +22 -1
- package/lib/core/journal.d.ts +54 -4
- package/lib/core/journal.js +158 -35
- package/lib/core/local-plugin-host.d.ts +29 -0
- package/lib/core/local-plugin-host.js +55 -48
- package/lib/core/messages.d.ts +17 -0
- package/lib/core/messages.js +34 -0
- package/lib/core/migration-history.js +16 -9
- package/lib/core/model-tools.d.ts +2 -2
- package/lib/core/model-tools.js +20 -2
- package/lib/core/patch-chain.d.ts +65 -0
- package/lib/core/patch-chain.js +100 -0
- package/lib/core/patch-document.d.ts +32 -4
- package/lib/core/patch-document.js +48 -17
- package/lib/core/patch-secret-guard.d.ts +49 -0
- package/lib/core/patch-secret-guard.js +164 -0
- package/lib/core/reconcile.d.ts +8 -0
- package/lib/core/reconcile.js +18 -3
- package/lib/core/reinstall.d.ts +2 -0
- package/lib/core/reinstall.js +6 -2
- package/lib/core/restore.js +31 -6
- package/lib/core/section-sanitize.d.ts +32 -0
- package/lib/core/section-sanitize.js +13 -0
- package/lib/core/snapshot-diff.d.ts +30 -0
- package/lib/core/snapshot-diff.js +56 -20
- package/lib/core/startup-barrier.js +8 -2
- package/lib/core/types.d.ts +38 -1
- package/lib/core/update-check.js +51 -2
- package/lib/foreign/kernel.js +9 -2
- package/lib/foreign/read-claude-plugins.js +29 -11
- package/lib/foreign/read-dsh.js +31 -2
- package/lib/foreign/session-ir.js +50 -9
- package/lib/foreign/session-read.d.ts +8 -0
- package/lib/foreign/session-read.js +26 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +42 -47
- package/lib/profiles/dsh-profile-io.d.ts +20 -0
- package/lib/profiles/dsh-profile-io.js +27 -0
- package/lib/profiles/dsh-profile-manager.d.ts +27 -0
- package/lib/profiles/dsh-profile-manager.js +45 -4
- package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
- package/lib/profiles/dsh-profile-runtime.js +16 -3
- package/lib/profiles/process-control.d.ts +18 -1
- package/lib/profiles/process-control.js +25 -1
- package/lib/routes/profiles.js +2 -1
- package/lib/routes/sync.js +19 -1
- package/lib/schema/types.d.ts +11 -0
- package/lib/security/redaction.js +22 -6
- package/lib/sync/autosync-repeat.d.ts +27 -0
- package/lib/sync/autosync-repeat.js +23 -0
- package/lib/sync/autosync-scheduler.d.ts +47 -2
- package/lib/sync/autosync-scheduler.js +217 -53
- package/lib/sync/baseline-heal.js +7 -0
- package/lib/sync/baseline-record.d.ts +67 -0
- package/lib/sync/baseline-record.js +74 -0
- package/lib/sync/blob-store.js +13 -0
- package/lib/sync/content-diff.d.ts +39 -0
- package/lib/sync/content-diff.js +46 -0
- package/lib/sync/git/git-transport.d.ts +32 -1
- package/lib/sync/git/git-transport.js +146 -26
- package/lib/sync/github-auth.d.ts +17 -1
- package/lib/sync/github-auth.js +37 -1
- package/lib/sync/local-changes.d.ts +15 -0
- package/lib/sync/local-changes.js +39 -0
- package/lib/sync/merge-apply-plan.d.ts +38 -0
- package/lib/sync/merge-apply-plan.js +76 -0
- package/lib/sync/merge-keyed.d.ts +68 -0
- package/lib/sync/merge-keyed.js +124 -0
- package/lib/sync/messages.d.ts +1 -0
- package/lib/sync/messages.js +2 -0
- package/lib/sync/patch-line-identity.d.ts +19 -0
- package/lib/sync/patch-line-identity.js +99 -0
- package/lib/sync/pending-merge.d.ts +41 -0
- package/lib/sync/pending-merge.js +61 -0
- package/lib/sync/plugin-removals.d.ts +15 -15
- package/lib/sync/plugin-removals.js +134 -83
- package/lib/sync/push-skip.d.ts +55 -0
- package/lib/sync/push-skip.js +70 -0
- package/lib/sync/s3/s3-transport.d.ts +14 -2
- package/lib/sync/s3/s3-transport.js +72 -48
- package/lib/sync/sync-engine.d.ts +44 -51
- package/lib/sync/sync-engine.js +160 -194
- package/lib/sync/sync-history.d.ts +7 -0
- package/lib/sync/sync-state.d.ts +28 -0
- package/lib/sync/sync-state.js +20 -0
- package/lib/sync/transport.d.ts +12 -3
- package/lib/sync/transport.js +13 -4
- package/lib/sync/webdav/webdav-transport.d.ts +19 -2
- package/lib/sync/webdav/webdav-transport.js +81 -40
- package/lib/sync/workspace-merge.d.ts +8 -2
- package/lib/ui/artifact-view.d.ts +1 -1
- package/lib/ui/commands.js +5 -11
- package/lib/ui/dsh-profiles-view.d.ts +8 -3
- package/lib/ui/dsh-profiles-view.js +9 -5
- package/lib/ui/foreign-view.d.ts +14 -0
- package/lib/ui/foreign-view.js +34 -0
- package/lib/ui/i18n.d.ts +7 -1
- package/lib/ui/i18n.js +15 -2
- package/lib/ui/menu-placement.js +1 -1
- package/lib/ui/migration-consult-view.d.ts +11 -0
- package/lib/ui/migration-consult-view.js +15 -0
- package/lib/ui/overview-view.d.ts +7 -0
- package/lib/ui/overview-view.js +3 -0
- package/lib/ui/report.d.ts +9 -0
- package/lib/ui/report.js +17 -4
- package/lib/ui/selection-model.d.ts +10 -2
- package/lib/ui/selection-model.js +23 -3
- package/lib/utils/async-once.d.ts +11 -0
- package/lib/utils/async-once.js +15 -0
- package/lib/utils/patch-chain-read.d.ts +51 -0
- package/lib/utils/patch-chain-read.js +240 -0
- package/lib/utils/patch-yaml.d.ts +39 -1
- package/lib/utils/patch-yaml.js +82 -2
- package/lib/utils/paths.d.ts +13 -0
- package/lib/utils/paths.js +35 -0
- package/lib/utils/workdir-lock.js +18 -3
- package/package.json +3 -2
- package/src/adapters/mcp.test.ts +29 -0
- package/src/adapters/mcp.ts +52 -14
- package/src/adapters/messages.ts +2 -0
- package/src/adapters/patch-key-guard.ts +29 -0
- package/src/adapters/plugin-data.test.ts +126 -0
- package/src/adapters/plugin-data.ts +97 -26
- package/src/adapters/plugins.test.ts +403 -0
- package/src/adapters/plugins.ts +198 -8
- package/src/adapters/prompts.ts +15 -4
- package/src/adapters/test-helpers.ts +15 -1
- package/src/cli/actions.test.ts +74 -1
- package/src/cli/actions.ts +27 -246
- package/src/cli/control-state.ts +143 -0
- package/src/cli/help.ts +21 -14
- package/src/cli/index.ts +123 -107
- package/src/cli/sessions-repair.ts +55 -22
- package/src/cli/web/client-script.ts +71 -5
- package/src/cli/web/page.ts +327 -208
- package/src/cli/web/routes.ts +85 -25
- package/src/cli/web/web.test.ts +65 -0
- package/src/cli/write-gates.ts +149 -0
- package/src/client/ConfigManagerSection.tsx +8 -4
- package/src/client/about/AboutPanel.tsx +9 -12
- package/src/client/about/release-notes-view.test.ts +17 -0
- package/src/client/about/release-notes-view.ts +49 -24
- package/src/client/api.ts +2 -1
- package/src/client/chat/ChatEntryView.tsx +2 -2
- package/src/client/chat/rollback-entry-view.ts +6 -1
- package/src/client/common/CommandPalette.tsx +6 -3
- package/src/client/common/ConfirmDialog.tsx +29 -12
- package/src/client/common/ContentPicker.tsx +24 -24
- package/src/client/common/Modal.tsx +12 -5
- package/src/client/common/MoreMenu.tsx +4 -1
- package/src/client/common/RunsCenter.tsx +103 -32
- package/src/client/common/Select.tsx +2 -2
- package/src/client/common/floating-bounds.ts +1 -1
- package/src/client/common/floating-units.test.ts +1 -2
- package/src/client/common/plan-text-redaction.test.ts +190 -5
- package/src/client/common/runs-center-guard.test.ts +60 -0
- package/src/client/common/runs-center-view.test.ts +128 -0
- package/src/client/common/runs-center-view.ts +96 -0
- package/src/client/common/section-title-action.test.ts +66 -0
- package/src/client/common/ui.tsx +93 -30
- package/src/client/config-manager.module.css +1515 -270
- package/src/client/consult/ConsultCard.tsx +7 -6
- package/src/client/environment/EnvironmentPanel.tsx +22 -25
- package/src/client/environment/maintenance/DiskUsageCard.tsx +69 -96
- package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
- package/src/client/export/ExportView.tsx +7 -16
- package/src/client/history/HistoryPanel.tsx +88 -28
- package/src/client/history/history-locales.ts +3 -3
- package/src/client/home/BackupScheduleCard.tsx +77 -69
- package/src/client/home/HomePanel.tsx +47 -12
- package/src/client/import/ConflictList.tsx +13 -13
- package/src/client/import/ForeignImportView.tsx +67 -9
- package/src/client/import/ImportWizardView.tsx +4 -4
- package/src/client/import/PathMappingForm.tsx +36 -9
- package/src/client/import/PathPickerDialog.tsx +2 -1
- package/src/client/import/import-wizard-split.test.ts +1 -1
- package/src/client/import/import-wizard-steps.tsx +51 -39
- package/src/client/import/use-import-wizard-controller.test.ts +129 -0
- package/src/client/import/use-import-wizard-controller.ts +116 -22
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/BackupInspectView.tsx +21 -15
- package/src/client/library/LibraryActions.tsx +116 -28
- package/src/client/library/LibraryPanel.tsx +14 -15
- package/src/client/library/RestorePlanView.tsx +13 -8
- package/src/client/locales/about.ts +0 -2
- package/src/client/locales/backup.ts +15 -12
- package/src/client/locales/common.ts +2 -0
- package/src/client/locales/export.ts +5 -12
- package/src/client/locales/foreign.ts +4 -2
- package/src/client/locales/import.ts +5 -2
- package/src/client/locales/overview.ts +4 -0
- package/src/client/locales/profiles.ts +32 -4
- package/src/client/locales/restore.ts +2 -2
- package/src/client/locales/sessions.ts +0 -2
- package/src/client/locales/shell.ts +2 -2
- package/src/client/market/MarketImportReview.tsx +4 -4
- package/src/client/market/MarketPanel.tsx +58 -56
- package/src/client/market/MyConfigsList.tsx +34 -32
- package/src/client/market/MyConfigsLoginCard.tsx +12 -15
- package/src/client/market/MyConfigsView.tsx +8 -15
- package/src/client/market/MyConfigsWizard.tsx +7 -12
- package/src/client/market/market-locales.ts +0 -6
- package/src/client/market/my-configs-split.test.ts +2 -1
- package/src/client/nav-menu-clip-guard.test.ts +52 -0
- package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
- package/src/client/recovery/RecoveryPanel.tsx +35 -22
- package/src/client/recovery/RollbackCard.tsx +132 -75
- package/src/client/recovery/RollbackFileChanges.tsx +40 -27
- package/src/client/recovery/SessionHealthCard.tsx +2 -2
- package/src/client/recovery/SessionHealthDialog.tsx +5 -7
- package/src/client/recovery/SessionLayoutSection.tsx +3 -5
- package/src/client/recovery/recovery-locales.ts +12 -8
- package/src/client/recovery/rollback-enabled.ts +29 -0
- package/src/client/recovery/use-recovery-write.ts +5 -0
- package/src/client/run-store.test.ts +30 -0
- package/src/client/run-store.ts +21 -1
- package/src/client/sync/AddChannelCard.tsx +65 -0
- package/src/client/sync/AutosyncCard.tsx +184 -108
- package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
- package/src/client/sync/ChannelConfigDialog.tsx +27 -48
- package/src/client/sync/MergePreviewView.tsx +5 -7
- package/src/client/sync/PushPreviewCard.tsx +2 -1
- package/src/client/sync/PushReportSections.tsx +35 -0
- package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
- package/src/client/sync/SyncConfirmView.tsx +130 -133
- package/src/client/sync/SyncLogList.tsx +29 -14
- package/src/client/sync/SyncPanel.tsx +188 -185
- package/src/client/sync/SyncProbeRow.tsx +5 -7
- package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
- package/src/client/sync/SyncSecuritySection.tsx +157 -0
- package/src/client/sync/SyncSettingsDialog.tsx +293 -0
- package/src/client/sync/SyncSettingsView.test.ts +26 -8
- package/src/client/sync/WorkDirCard.tsx +2 -4
- package/src/client/sync/config-clear-guard.test.ts +94 -0
- package/src/client/sync/config-clear-guard.ts +98 -0
- package/src/client/sync/config-dirty.test.ts +91 -0
- package/src/client/sync/config-dirty.ts +88 -0
- package/src/client/sync/history-model.test.ts +2 -0
- package/src/client/sync/history-model.ts +5 -0
- package/src/client/sync/merge-request.ts +20 -0
- package/src/client/sync/sync-api.ts +13 -1
- package/src/client/sync/sync-locales.ts +95 -47
- package/src/client/sync/sync-panel-clear.test.ts +44 -0
- package/src/client/sync/sync-push-preview.test.ts +9 -0
- package/src/client/sync/sync-view.test.ts +20 -0
- package/src/client/sync/sync-view.ts +76 -4
- package/src/core/backup.test.ts +61 -1
- package/src/core/backup.ts +21 -4
- package/src/core/boot-rescue.test.ts +35 -0
- package/src/core/boot-rescue.ts +13 -2
- package/src/core/boot-safety.test.ts +25 -0
- package/src/core/boot-safety.ts +37 -2
- package/src/core/conflict-decisions.ts +2 -1
- package/src/core/exporter.ts +21 -1
- package/src/core/journal.test.ts +183 -0
- package/src/core/journal.ts +163 -25
- package/src/core/local-plugin-host.test.ts +68 -2
- package/src/core/local-plugin-host.ts +31 -4
- package/src/core/messages.ts +34 -0
- package/src/core/migration-history.test.ts +27 -0
- package/src/core/migration-history.ts +12 -4
- package/src/core/model-tools.test.ts +67 -0
- package/src/core/model-tools.ts +22 -4
- package/src/core/patch-chain.test.ts +83 -0
- package/src/core/patch-chain.ts +150 -0
- package/src/core/patch-document.test.ts +48 -1
- package/src/core/patch-document.ts +66 -15
- package/src/core/patch-layers.test.ts +1 -1
- package/src/core/patch-secret-guard.test.ts +110 -0
- package/src/core/patch-secret-guard.ts +176 -0
- package/src/core/reconcile.ts +32 -4
- package/src/core/reinstall.ts +8 -2
- package/src/core/restore.ts +32 -7
- package/src/core/section-sanitize.ts +37 -0
- package/src/core/smoke.test.ts +2 -1
- package/src/core/snapshot-diff.test.ts +73 -1
- package/src/core/snapshot-diff.ts +66 -21
- package/src/core/startup-barrier.test.ts +64 -0
- package/src/core/startup-barrier.ts +8 -2
- package/src/core/types.ts +43 -2
- package/src/core/update-check.test.ts +40 -0
- package/src/core/update-check.ts +53 -2
- package/src/foreign/claude-code.test.ts +5 -0
- package/src/foreign/claude-plugins.test.ts +57 -0
- package/src/foreign/claude-sessions-bytes.test.ts +7 -1
- package/src/foreign/dsh.test.ts +23 -0
- package/src/foreign/kernel.ts +9 -2
- package/src/foreign/read-claude-plugins.ts +32 -11
- package/src/foreign/read-dsh.ts +33 -2
- package/src/foreign/session-ir.test.ts +67 -0
- package/src/foreign/session-ir.ts +54 -14
- package/src/foreign/session-read.ts +23 -0
- package/src/index.facade.test.ts +186 -6
- package/src/index.ts +53 -47
- package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
- package/src/profiles/dsh-profile-io.ts +29 -0
- package/src/profiles/dsh-profile-manager.test.ts +30 -0
- package/src/profiles/dsh-profile-manager.ts +53 -5
- package/src/profiles/dsh-profile-runtime.test.ts +29 -7
- package/src/profiles/dsh-profile-runtime.ts +17 -3
- package/src/profiles/process-control.test.ts +97 -0
- package/src/profiles/process-control.ts +28 -1
- package/src/routes/profiles.ts +2 -1
- package/src/routes/sync.ts +19 -1
- package/src/schema/types.ts +16 -1
- package/src/security/redaction.test.ts +31 -0
- package/src/security/redaction.ts +23 -6
- package/src/security/security.test.ts +1 -1
- package/src/sync/autosync-repeat.test.ts +58 -0
- package/src/sync/autosync-repeat.ts +55 -0
- package/src/sync/autosync-scheduler.test.ts +515 -0
- package/src/sync/autosync-scheduler.ts +225 -51
- package/src/sync/baseline-heal.ts +6 -0
- package/src/sync/baseline-record.ts +135 -0
- package/src/sync/blob-store.test.ts +16 -0
- package/src/sync/blob-store.ts +13 -0
- package/src/sync/content-diff.test.ts +95 -0
- package/src/sync/content-diff.ts +79 -0
- package/src/sync/git/git-transport.test.ts +151 -4
- package/src/sync/git/git-transport.ts +143 -27
- package/src/sync/github-auth.test.ts +26 -1
- package/src/sync/github-auth.ts +37 -1
- package/src/sync/local-changes.ts +40 -0
- package/src/sync/merge-apply-plan.ts +117 -0
- package/src/sync/merge-keyed.test.ts +167 -0
- package/src/sync/merge-keyed.ts +160 -0
- package/src/sync/messages.ts +3 -0
- package/src/sync/patch-line-identity.test.ts +73 -0
- package/src/sync/patch-line-identity.ts +105 -0
- package/src/sync/pending-merge.test.ts +41 -0
- package/src/sync/pending-merge.ts +85 -0
- package/src/sync/plugin-removals.test.ts +199 -39
- package/src/sync/plugin-removals.ts +150 -64
- package/src/sync/push-skip.test.ts +326 -0
- package/src/sync/push-skip.ts +102 -0
- package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
- package/src/sync/s3/s3-transport.ts +76 -42
- package/src/sync/sync-config.test.ts +39 -12
- package/src/sync/sync-device-identity.test.ts +3 -0
- package/src/sync/sync-engine.test.ts +465 -12
- package/src/sync/sync-engine.ts +189 -193
- package/src/sync/sync-history.ts +7 -0
- package/src/sync/sync-state.ts +48 -0
- package/src/sync/transport.test.ts +13 -1
- package/src/sync/transport.ts +12 -4
- package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
- package/src/sync/webdav/webdav-transport.ts +86 -34
- package/src/sync/workspace-merge.ts +9 -2
- package/src/ui/artifact-view.ts +1 -1
- package/src/ui/commands.test.ts +11 -0
- package/src/ui/commands.ts +5 -14
- package/src/ui/dsh-profiles-view.test.ts +16 -0
- package/src/ui/dsh-profiles-view.ts +11 -5
- package/src/ui/foreign-view.test.ts +49 -0
- package/src/ui/foreign-view.ts +47 -0
- package/src/ui/i18n.ts +15 -2
- package/src/ui/menu-placement.ts +1 -1
- package/src/ui/migration-consult-view.test.ts +20 -1
- package/src/ui/migration-consult-view.ts +17 -0
- package/src/ui/overview-view.ts +10 -0
- package/src/ui/report.test.ts +25 -1
- package/src/ui/report.ts +15 -4
- package/src/ui/selection-model.test.ts +29 -1
- package/src/ui/selection-model.ts +25 -4
- package/src/utils/async-once.ts +14 -0
- package/src/utils/js-yaml4.d.ts +35 -0
- package/src/utils/patch-chain-read.test.ts +171 -0
- package/src/utils/patch-chain-read.ts +259 -0
- package/src/utils/patch-yaml.test.ts +215 -3
- package/src/utils/patch-yaml.ts +98 -2
- package/src/utils/paths.test.ts +14 -1
- package/src/utils/paths.ts +35 -0
- package/src/utils/workdir-lock.test.ts +69 -0
- package/src/utils/workdir-lock.ts +17 -3
- package/lib/ui/path-mapping.d.ts +0 -38
- package/lib/ui/path-mapping.js +0 -75
- package/src/client/common/InfoHint.tsx +0 -289
- package/src/client/common/info-hint-guard.test.ts +0 -1119
- package/src/client/sync/DecryptPasswordCard.tsx +0 -48
- package/src/client/sync/SecurityOptionsCard.tsx +0 -97
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
- package/src/ui/path-mapping.test.ts +0 -67
- package/src/ui/path-mapping.ts +0 -103
|
@@ -31,6 +31,71 @@ import { ConfigManagerApiError } from '../common/http.ts'
|
|
|
31
31
|
// 直接报 "missed the module table",整个插件不加载(仓库既有铁律 + 本轮实测)。
|
|
32
32
|
import { ENCRYPTED_CONTAINER_CODE } from '../../utils/shared-constants.ts'
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* 迁移前咨询失败 → 界面文案(纯函数,node 可测)。
|
|
36
|
+
*
|
|
37
|
+
* 两种「没有报告」必须分开(审计 P9-7):
|
|
38
|
+
* - 404 = 宿主没有 `/consult` 路由(老宿主/老插件)→ null,界面继续按「宿主不支持」渲染
|
|
39
|
+
* info 横幅,不制造错误;
|
|
40
|
+
* - 其它失败(5xx / 超时 / 断网 / 响应解析失败)→ 返回可读消息,交给 ErrorBanner。
|
|
41
|
+
* 此前 catch 只 setConsultReport(null),用户看到的是「没有结论」而不是「咨询失败」。
|
|
42
|
+
*/
|
|
43
|
+
export function consultFailureError(err: unknown): string | null {
|
|
44
|
+
if (err instanceof ConfigManagerApiError && err.status === 404) return null
|
|
45
|
+
return err instanceof Error ? err.message : String(err)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 解锁加密容器的端口(注入以便 node 直接测事务语义,不依赖 React / store)。 */
|
|
49
|
+
export interface ArchiveUnlockFlow<Ref> {
|
|
50
|
+
/** 解密容器 → 明文 ZIP + 被解出的凭据覆盖清单 refs */
|
|
51
|
+
unlock: () => Promise<{ refs: readonly Ref[] }>
|
|
52
|
+
/** 解锁成功后的中间态写回(archiveUnlocked / decryptPassword / decryptRefs) */
|
|
53
|
+
commitUnlocked: (refs: readonly Ref[]) => void
|
|
54
|
+
/** 解锁成功后的下一步(selectZip → analyze → 兼容性) */
|
|
55
|
+
analyze: () => Promise<unknown>
|
|
56
|
+
/** 回滚已提交的解锁态(只会在「已提交」之后被调用) */
|
|
57
|
+
rollbackUnlocked: () => void
|
|
58
|
+
/** 向导已被用户重置:在途结果整体丢弃,不写任何状态 */
|
|
59
|
+
cancelled: () => boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type ArchiveUnlockOutcome =
|
|
63
|
+
| { status: 'ok' }
|
|
64
|
+
| { status: 'cancelled' }
|
|
65
|
+
| { status: 'failed'; message: string; unlocked: boolean }
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 「解锁 → 继续分析」事务(审计 P9-8)。
|
|
69
|
+
*
|
|
70
|
+
* 根因:解锁成功后先写 archiveUnlocked=true,再调 selectZip;后者抛错时 catch 只写 error,
|
|
71
|
+
* 于是 archiveUnlocked=true 而 phase 仍停在 decrypt-archive —— 界面判定「已解锁」,
|
|
72
|
+
* 用户却停在解锁页,重输密码也不会重新解锁(wizard 里解锁已经成功过一次)。
|
|
73
|
+
* 这里把「已提交 → 后续失败必须回滚」写成事务,回滚内容由调用方给出(store 与 wizard 两份状态)。
|
|
74
|
+
*/
|
|
75
|
+
export async function unlockArchiveThenAnalyze<Ref>(
|
|
76
|
+
flow: ArchiveUnlockFlow<Ref>,
|
|
77
|
+
): Promise<ArchiveUnlockOutcome> {
|
|
78
|
+
let unlocked = false
|
|
79
|
+
try {
|
|
80
|
+
const { refs } = await flow.unlock()
|
|
81
|
+
if (flow.cancelled()) return { status: 'cancelled' }
|
|
82
|
+
flow.commitUnlocked(refs)
|
|
83
|
+
unlocked = true
|
|
84
|
+
await flow.analyze()
|
|
85
|
+
if (flow.cancelled()) return { status: 'cancelled' }
|
|
86
|
+
return { status: 'ok' }
|
|
87
|
+
} catch (err) {
|
|
88
|
+
// 用户已重置向导:resetWizard 已清空两份状态,再回滚只会覆盖新一轮导入
|
|
89
|
+
if (flow.cancelled()) return { status: 'cancelled' }
|
|
90
|
+
if (unlocked) flow.rollbackUnlocked()
|
|
91
|
+
return {
|
|
92
|
+
status: 'failed',
|
|
93
|
+
message: err instanceof Error ? err.message : String(err),
|
|
94
|
+
unlocked,
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
34
99
|
export function useImportWizardController(api: ConfigManagerApi, t: TranslateNS<'config-manager'>) {
|
|
35
100
|
|
|
36
101
|
// m2:状态统一来自模块级 store;控制器实例由 store 缓存复用(不重建)
|
|
@@ -302,14 +367,24 @@ export function useImportWizardController(api: ConfigManagerApi, t: TranslateNS<
|
|
|
302
367
|
}, [api])
|
|
303
368
|
|
|
304
369
|
/** Phase 7 迁移前咨询:预览步对当前 ZIP 生成咨询报告(只读,零写入)。
|
|
305
|
-
* zipPath 变化 / 进入 preview
|
|
370
|
+
* zipPath 变化 / 进入 preview 步时重新获取。失败**不再静默**(审计 P9-7):
|
|
371
|
+
* 「宿主不支持」= 404,仍按 info 横幅说明;其它失败写 import.error 走 ErrorBanner,
|
|
372
|
+
* 用户看到的是「咨询失败」而不是「没有结论」。咨询本身是建议性的,不阻断导入。 */
|
|
306
373
|
useEffect(() => {
|
|
307
374
|
if (step !== 'preview' || imp.zipPath === null) return
|
|
308
375
|
let cancelled = false
|
|
309
376
|
setConsultLoading(true)
|
|
310
377
|
api.consult({ type: 'export-zip', id: imp.zipPath })
|
|
311
378
|
.then((report) => { if (!cancelled) setConsultReport(report) })
|
|
312
|
-
.catch(() => {
|
|
379
|
+
.catch((err: unknown) => {
|
|
380
|
+
if (cancelled) return
|
|
381
|
+
setConsultReport(null)
|
|
382
|
+
const message = consultFailureError(err)
|
|
383
|
+
if (message !== null) {
|
|
384
|
+
runStore.patch({ import: { error: message } })
|
|
385
|
+
runStore.syncWizard()
|
|
386
|
+
}
|
|
387
|
+
})
|
|
313
388
|
.finally(() => { if (!cancelled) setConsultLoading(false) })
|
|
314
389
|
return () => { cancelled = true }
|
|
315
390
|
}, [step, imp.zipPath, api])
|
|
@@ -401,36 +476,55 @@ export function useImportWizardController(api: ConfigManagerApi, t: TranslateNS<
|
|
|
401
476
|
// 竞态守卫:解锁/继续分析期间用户可能点「重新选择」(resetWizard 递增 pickGeneration),
|
|
402
477
|
// 此时丢弃在途结果,防止晚到的 selectZip 把已重置的向导推进到 compatibility。
|
|
403
478
|
const generation = pickGeneration.current
|
|
479
|
+
const encryptedPath = imp.zipPath
|
|
404
480
|
setUnlocking(true)
|
|
405
481
|
setArchiveUnlockError(null)
|
|
406
482
|
try {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
483
|
+
const outcome = await unlockArchiveThenAnalyze({
|
|
484
|
+
unlock: () => wizard.unlockArchive(encryptedPath, archivePassword),
|
|
485
|
+
commitUnlocked: (refs) => {
|
|
486
|
+
// 容器密码即内部凭据解密密码:交给向导(execute 时解密 secrets.enc 用)
|
|
487
|
+
wizard.setDecryptPassword(archivePassword)
|
|
488
|
+
// refs 为解锁时顺带解出的凭据覆盖清单(非值):secrets 阶段据此剔除已恢复项
|
|
489
|
+
runStore.patch({
|
|
490
|
+
import: {
|
|
491
|
+
archiveUnlocked: true,
|
|
492
|
+
decryptPassword: archivePassword,
|
|
493
|
+
decryptRefs: [...refs],
|
|
494
|
+
},
|
|
495
|
+
})
|
|
496
|
+
runStore.syncWizard()
|
|
497
|
+
},
|
|
498
|
+
analyze: () => wizard.selectZip(encryptedPath),
|
|
499
|
+
rollbackUnlocked: () => {
|
|
500
|
+
// 两份状态必须同时回到「未解锁」:wizard 内部标志决定后续请求的真实行为,
|
|
501
|
+
// store 决定界面判定;只回滚一边 = 两边继续互相矛盾(审计 P9-8)。
|
|
502
|
+
wizard.setDecryptPassword('')
|
|
503
|
+
wizard.setArchiveEncrypted(true, encryptedPath)
|
|
504
|
+
runStore.patch({
|
|
505
|
+
import: {
|
|
506
|
+
archiveUnlocked: false,
|
|
507
|
+
decryptPassword: '',
|
|
508
|
+
decryptRefs: [],
|
|
509
|
+
phase: 'decrypt-archive',
|
|
510
|
+
},
|
|
511
|
+
})
|
|
512
|
+
runStore.syncWizard()
|
|
417
513
|
},
|
|
514
|
+
cancelled: () => generation !== pickGeneration.current,
|
|
418
515
|
})
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
516
|
+
if (outcome.status === 'cancelled') return
|
|
517
|
+
if (outcome.status === 'failed') {
|
|
518
|
+
setArchiveUnlockError(outcome.message)
|
|
519
|
+
runStore.patch({ import: { error: outcome.message } })
|
|
520
|
+
runStore.syncWizard()
|
|
521
|
+
return
|
|
522
|
+
}
|
|
424
523
|
runStore.syncWizard()
|
|
425
524
|
// 解锁后 phase 不再停留在 decrypt-archive,否则 preview 页会被解锁页劫持。
|
|
426
525
|
// 用最新 store 快照计算下一阶段:decrypt-archive 已解锁(archiveUnlocked=true)
|
|
427
526
|
// 不再适用,nextFlowPhase 取第一项——conflicts、path-mapping、secrets 或 confirm。
|
|
428
527
|
runStore.patch({ import: { phase: 'preview' } })
|
|
429
|
-
} catch (err) {
|
|
430
|
-
if (generation !== pickGeneration.current) return
|
|
431
|
-
setArchiveUnlockError(err instanceof Error ? err.message : String(err))
|
|
432
|
-
runStore.patch({ import: { error: err instanceof Error ? err.message : String(err) } })
|
|
433
|
-
runStore.syncWizard()
|
|
434
528
|
} finally {
|
|
435
529
|
setUnlocking(false)
|
|
436
530
|
}
|
|
@@ -74,7 +74,7 @@ export interface ArtifactRowViewProps {
|
|
|
74
74
|
* (旧快照没有来源,绝不显示空档案名或「未标注」徽章)。`hint` 只在「与当前档案不同」时给,
|
|
75
75
|
* 徽章本体只写档案名,差异语不重复表达。
|
|
76
76
|
*/
|
|
77
|
-
originBadge?: { label: string;
|
|
77
|
+
originBadge?: { label: string; kind: 'info' | 'warn' } | undefined
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function ArtifactRowView({
|
|
@@ -139,7 +139,7 @@ export function ArtifactRowView({
|
|
|
139
139
|
))}
|
|
140
140
|
{/* 来源档案排在状态徽章之后:先读「这行现在是什么状态」,再读「它来自哪个档案」 */}
|
|
141
141
|
{originBadge !== undefined && (
|
|
142
|
-
<Badge kind={originBadge.kind}
|
|
142
|
+
<Badge kind={originBadge.kind}>{originBadge.label}</Badge>
|
|
143
143
|
)}
|
|
144
144
|
</div>
|
|
145
145
|
)}
|
|
@@ -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">{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>
|
|
@@ -48,12 +50,13 @@ export function BackupInspectView({ result, t }: BackupInspectViewProps) {
|
|
|
48
50
|
<div className={css.inspectGroup}>
|
|
49
51
|
<div className={css.groupLabel}>{t('backupFiles.inspectDiff')}</div>
|
|
50
52
|
<div className={css.statRow}>
|
|
51
|
-
{
|
|
52
|
-
{summary.
|
|
53
|
-
{summary.
|
|
54
|
-
{summary.
|
|
55
|
-
{summary.
|
|
56
|
-
{summary.
|
|
53
|
+
{/* 徽章统一叠屏私有的 .inspectBadge:只加同色 15% 细描边(稿 D-05:142-159),本体的四态色不动 */}
|
|
54
|
+
{summary.willChange > 0 && <Badge kind="info" className={css.inspectBadge}>{t('import.preview.willChange', { count: String(summary.willChange) })}</Badge>}
|
|
55
|
+
{summary.unchanged > 0 && <Badge kind="ok" className={css.inspectBadge}>{t('import.preview.unchanged', { count: String(summary.unchanged) })}</Badge>}
|
|
56
|
+
{summary.conflicts > 0 && <Badge kind="error" className={css.inspectBadge}>{t('import.preview.conflicts', { count: String(summary.conflicts) })}</Badge>}
|
|
57
|
+
{summary.secretsNeeded > 0 && <Badge kind="warn" className={css.inspectBadge}>{t('import.preview.secrets', { count: String(summary.secretsNeeded) })}</Badge>}
|
|
58
|
+
{summary.pathMappingsNeeded > 0 && <Badge kind="warn" className={css.inspectBadge}>{t('import.preview.paths', { count: String(summary.pathMappingsNeeded) })}</Badge>}
|
|
59
|
+
{summary.needsRestart && <Badge kind="warn" className={css.inspectBadge}>{t('report.needsRestart')}</Badge>}
|
|
57
60
|
</div>
|
|
58
61
|
</div>
|
|
59
62
|
|
|
@@ -62,19 +65,22 @@ export function BackupInspectView({ result, t }: BackupInspectViewProps) {
|
|
|
62
65
|
<div className={css.inspectGroup}>
|
|
63
66
|
<div className={css.groupLabel}>{t('backupFiles.inspectItems')}</div>
|
|
64
67
|
{groups.map((group) => (
|
|
65
|
-
<div key={group.key} className={css.
|
|
68
|
+
<div key={group.key} className={css.inspectSubGroup}>
|
|
66
69
|
<div className={css.groupHeader}>
|
|
67
70
|
<span className={css.groupLabel}>{t(groupLabelKey(group.key))}</span>
|
|
68
|
-
<Badge kind={group.kind}>{String(group.items.length)}</Badge>
|
|
71
|
+
<Badge kind={group.kind} className={css.inspectBadge}>{String(group.items.length)}</Badge>
|
|
69
72
|
</div>
|
|
70
|
-
<div className={css.reportScroll}>
|
|
73
|
+
<div className={css.reportScroll + ' ' + css.inspectItemsScroll}>
|
|
71
74
|
<ul className={css.reportList}>
|
|
72
75
|
{group.items.map((item) => (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
/* 条目三段(稿 D-05:170-181):圆点 + 等宽彩色 adapter + 描述。
|
|
77
|
+
逐项不再重复 kind:分组标题已按 kind 命名,裸枚举值(Create/Skip…)没有第二种说法。
|
|
78
|
+
描述由宿主拼装 → 渲染前过 redact;plan-text-redaction 的 snapshot-inspect-description
|
|
79
|
+
在同一次提交里同步改成这里的锚点(见该表)。 */
|
|
80
|
+
<li key={item.id} className={css.inspectItem}>
|
|
81
|
+
<span className={css.inspectDot} aria-hidden="true" />
|
|
82
|
+
<span className={css.inspectAdapter}>{sectionLabel(item.adapter as SectionId, t)}:</span>
|
|
83
|
+
<span className={css.inspectDesc}>{redact(item.description)}</span>
|
|
78
84
|
</li>
|
|
79
85
|
))}
|
|
80
86
|
</ul>
|
|
@@ -18,14 +18,20 @@ 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'
|
|
24
30
|
import { formatDateTimeFull } from '../sync/history-model.ts'
|
|
25
31
|
import type { TranslateNS } from '../client-types.ts'
|
|
26
|
-
import { Banner, Button, Empty, Spinner } from '../common/ui.tsx'
|
|
32
|
+
import { Badge, Banner, Button, Empty, Spinner } from '../common/ui.tsx'
|
|
33
|
+
import { Icon } from '../common/Icon.tsx'
|
|
27
34
|
import { Skeleton, SkeletonList, SkeletonTable } from '../common/Skeleton.tsx'
|
|
28
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
29
35
|
import { ConfirmDialog } from '../common/ConfirmDialog.tsx'
|
|
30
36
|
import { Modal } from '../common/Modal.tsx'
|
|
31
37
|
import { toast } from '../common/toast-store.ts'
|
|
@@ -163,7 +169,7 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
163
169
|
},
|
|
164
170
|
(err) => {
|
|
165
171
|
if (!mounted.current || gen !== generation.current) return
|
|
166
|
-
setPlan({ snapshotId: row.ref.snapshotId ?? '', loading: false, plan: null, changeSummary: undefined, planFingerprint: undefined, error:
|
|
172
|
+
setPlan({ snapshotId: row.ref.snapshotId ?? '', loading: false, plan: null, changeSummary: undefined, planFingerprint: undefined, error: redactErrorText(err) })
|
|
167
173
|
reportPending(row.key, null)
|
|
168
174
|
},
|
|
169
175
|
)
|
|
@@ -238,7 +244,7 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
238
244
|
if (mounted.current && gen === generation.current) setInspect({ name, loading: false, error: null, result })
|
|
239
245
|
} catch (err) {
|
|
240
246
|
if (mounted.current && gen === generation.current) {
|
|
241
|
-
setInspect({ name, loading: false, error:
|
|
247
|
+
setInspect({ name, loading: false, error: redactErrorText(err), result: null })
|
|
242
248
|
}
|
|
243
249
|
}
|
|
244
250
|
})()
|
|
@@ -436,16 +442,36 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
436
442
|
closeLabel={t('common.close')}
|
|
437
443
|
onClose={() => { setPull(null) }}
|
|
438
444
|
closeDisabled={pull?.phase === 'running'}
|
|
445
|
+
trailing={pull?.phase === 'running'
|
|
446
|
+
? <Badge kind="info" className={css.pullBadge}>{t('library.pullBadge')}</Badge>
|
|
447
|
+
: undefined}
|
|
439
448
|
/>
|
|
440
449
|
<Modal.Body scroll>
|
|
441
450
|
{pull !== null && (
|
|
442
451
|
<>
|
|
443
|
-
|
|
452
|
+
{/* 稿 D-04:215-226:左侧 Spinner + 主文案,右侧文件名(等宽、省略)。
|
|
453
|
+
文件名不是「说明文字」:它是这次操作唯一能区分对象的标识,必须与状态同排可见。 */}
|
|
454
|
+
<div className={css.pullMeta}>
|
|
455
|
+
<span className={css.pullStatus}>
|
|
456
|
+
{pull.phase === 'running' && (
|
|
457
|
+
<>
|
|
458
|
+
<Spinner label={pullProgressLabel(pull.mode, t)} />
|
|
459
|
+
<span>{pullProgressLabel(pull.mode, t)}</span>
|
|
460
|
+
</>
|
|
461
|
+
)}
|
|
462
|
+
</span>
|
|
463
|
+
<span className={css.pullName} title={fileNameOf(pull.row)}>{fileNameOf(pull.row)}</span>
|
|
464
|
+
</div>
|
|
465
|
+
{/* 不定态进度条:宿主不回报分区级进度(/sync/pull 是一次 RPC),
|
|
466
|
+
所以只表达「在动」,不编造百分比(稿上的 12/18 与 68% 无数据来源)。 */}
|
|
444
467
|
{pull.phase === 'running' && (
|
|
445
|
-
<
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
468
|
+
<span
|
|
469
|
+
className={css.progressTrack + ' ' + css.pullTrack}
|
|
470
|
+
role="progressbar"
|
|
471
|
+
aria-valuetext={pullProgressLabel(pull.mode, t)}
|
|
472
|
+
>
|
|
473
|
+
<span className={css.progressBar + ' ' + css.progressIndeterminate + ' ' + css.pullBar} />
|
|
474
|
+
</span>
|
|
449
475
|
)}
|
|
450
476
|
{pull.phase === 'failed' && pull.error !== null && <Banner kind="error">{pull.error}</Banner>}
|
|
451
477
|
</>
|
|
@@ -469,7 +495,6 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
469
495
|
closeLabel={t('common.close')}
|
|
470
496
|
onClose={() => { setPlan(null) }}
|
|
471
497
|
closeDisabled={running}
|
|
472
|
-
trailing={<InfoHint text={t('snapshots.selectHint')} label={t('common.infoHint')} />}
|
|
473
498
|
/>
|
|
474
499
|
<Modal.Body scroll>
|
|
475
500
|
{/* 恢复计划预览:结果是一张「文件 → 动作」表 → 按表格铺骨架 */}
|
|
@@ -526,8 +551,7 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
526
551
|
? t('backupFiles.deleteConfirm', { name: fileNameOf(confirmDelete) })
|
|
527
552
|
: confirmDelete.kind === 'remote-snapshot'
|
|
528
553
|
? t('library.remoteDeleteConfirm', { time: timeText(confirmDelete) })
|
|
529
|
-
|
|
530
|
-
: t('snapshots.deleteConfirm', { time: confirmDelete.title.kind === 'time' ? confirmDelete.title.iso : '' })}
|
|
554
|
+
: t('snapshots.deleteConfirm', { time: timeText(confirmDelete) })}
|
|
531
555
|
confirmLabel={confirmDelete === null ? t('snapshots.delete')
|
|
532
556
|
: confirmDelete.kind === 'backup-file' ? t('backupFiles.delete')
|
|
533
557
|
: confirmDelete.kind === 'remote-snapshot' ? t('library.delete')
|
|
@@ -536,7 +560,16 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
536
560
|
danger
|
|
537
561
|
onConfirm={doDelete}
|
|
538
562
|
onCancel={() => { setConfirmDelete(null) }}
|
|
539
|
-
|
|
563
|
+
>
|
|
564
|
+
{/* 「命中当前基线」不是附注,而是会给用户带来后果的一句事实(稿 D-07:214-219):
|
|
565
|
+
从 message 里拆出来做成警告盒,正文只留「删什么、为什么不可恢复」。 */}
|
|
566
|
+
{confirmDelete !== null && confirmDelete.kind === 'remote-snapshot' && confirmDelete.badges.includes('current') && (
|
|
567
|
+
<div className={css.confirmNote}>
|
|
568
|
+
<span className={css.confirmNoteIcon} aria-hidden="true"><Icon name="warn" size={14} /></span>
|
|
569
|
+
<span>{t('library.remoteDeleteBaseline')}</span>
|
|
570
|
+
</div>
|
|
571
|
+
)}
|
|
572
|
+
</ConfirmDialog>
|
|
540
573
|
|
|
541
574
|
{/* 查看与对比(只读,零写入) */}
|
|
542
575
|
<Modal open={inspect !== null} onClose={() => { setInspect(null) }} title={t('backupFiles.inspect')} wide>
|
|
@@ -548,6 +581,9 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
548
581
|
{inspect !== null && !inspect.loading && inspect.result === null && inspect.error === null && <Empty>{t('backupFiles.inspectEmpty')}</Empty>}
|
|
549
582
|
{inspect?.result != null && <BackupInspectView result={inspect.result} t={t} />}
|
|
550
583
|
</Modal.Body>
|
|
584
|
+
<Modal.Footer>
|
|
585
|
+
<Button variant="ghost" onClick={() => { setInspect(null) }}>{t('common.close')}</Button>
|
|
586
|
+
</Modal.Footer>
|
|
551
587
|
</Modal>
|
|
552
588
|
|
|
553
589
|
{/* 执行恢复的报告(一次性回执,必须给显式退出入口) */}
|
|
@@ -556,10 +592,13 @@ export function LibraryActions({ api, syncApi, t, target, onDone, onChanged, onO
|
|
|
556
592
|
<Modal.Body scroll>
|
|
557
593
|
{report !== null && (
|
|
558
594
|
<>
|
|
595
|
+
{report.preRestoreDir !== undefined && report.preRestoreDir !== '' && (
|
|
596
|
+
<div className={css.hint}>{t('snapshots.preRestoreDir', { dir: redact(report.preRestoreDir) })}</div>
|
|
597
|
+
)}
|
|
559
598
|
{reportLine(t('snapshots.restored'), report.restored, t)}
|
|
560
599
|
{reportLine(t('snapshots.removedPlugins'), report.removedPlugins, t)}
|
|
561
600
|
{reportLine(t('snapshots.manualHints'), report.manualHints, t, true)}
|
|
562
|
-
{reportLine(t('snapshots.failed'), report.failed.map((f) =>
|
|
601
|
+
{reportLine(t('snapshots.failed'), report.failed.map((f) => ({ path: f.item, text: f.reason })), t, true)}
|
|
563
602
|
{reportLine(t('snapshots.skipped'), report.skipped, t)}
|
|
564
603
|
</>
|
|
565
604
|
)}
|
|
@@ -613,28 +652,64 @@ function pullProgressLabel(mode: PullState['mode'], t: TranslateNS<'config-manag
|
|
|
613
652
|
* 咨询 / 拉取 / 下载 / 删除四条远端动作共用这一份判定,避免各写一份而分叉。
|
|
614
653
|
* 地址从 /sync/status 现取,与产物库加载远端列表同源。
|
|
615
654
|
*/
|
|
616
|
-
|
|
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> {
|
|
617
693
|
// 只要通道与地址,不要工作副本的 ahead/dirty/远端快照(省 5 次 git 子进程启动)
|
|
618
694
|
const status = await syncApi.status({ workDirDetail: false })
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
const payload = isWebdav
|
|
623
|
-
? (webdavUrl !== '' ? { transport: 'webdav' as const, url: webdavUrl } : null)
|
|
624
|
-
: (repoUrl !== '' ? { transport: 'git' as const, repoUrl } : null)
|
|
625
|
-
if (payload === null) throw new Error('sync channel address is unavailable')
|
|
626
|
-
return payload
|
|
695
|
+
const resolved = resolveRemoteChannelPayload(status)
|
|
696
|
+
if (resolved === null) throw new Error('sync channel address is unavailable')
|
|
697
|
+
return resolved.payload
|
|
627
698
|
}
|
|
628
699
|
|
|
629
700
|
/**
|
|
630
701
|
* 「迁移前咨询」的输入:**四种可迁移源统一走这一个入口**(§6.8 ②)。
|
|
631
702
|
* 每种的 id 语义不同(快照 id / 备份路径 / 远端快照 id),照 consult 路由的契约给。
|
|
632
703
|
*/
|
|
633
|
-
async function consultInput(
|
|
704
|
+
async function consultInput(
|
|
705
|
+
row: ArtifactRow,
|
|
706
|
+
syncApi: SyncApi,
|
|
707
|
+
): Promise<SyncPushBody & { type: 'export-zip' | 'local-snapshot' | 'remote-snapshot'; id: string; snapshotId?: string }> {
|
|
634
708
|
if (row.kind === 'snapshot') return { type: 'local-snapshot', id: row.ref.snapshotId ?? '', snapshotId: row.ref.snapshotId }
|
|
635
709
|
if (row.kind === 'remote-snapshot') {
|
|
636
710
|
// 远端来源**必须**带通道与地址(与拉取/下载/删除共用 remotePayload 那一份判定)
|
|
637
|
-
|
|
711
|
+
const remote = await remotePayload(syncApi)
|
|
712
|
+
return { ...remote, type: 'remote-snapshot', id: row.ref.remoteId ?? '', snapshotId: row.ref.remoteId }
|
|
638
713
|
}
|
|
639
714
|
return { type: 'export-zip', id: row.ref.path ?? '' }
|
|
640
715
|
}
|
|
@@ -676,16 +751,29 @@ function runStorePatchImport(row: ArtifactRow): void {
|
|
|
676
751
|
function runStoreWatch(): void { runStore.watchRunning('restore', 500) }
|
|
677
752
|
function runStoreStopWatch(): void { runStore.stopRunWatch('restore') }
|
|
678
753
|
|
|
679
|
-
|
|
754
|
+
/** 报告条目:纯文本,或「路径 + 原因」两段(路径等宽,原因沿用行字色) */
|
|
755
|
+
type ReportLineItem = string | { path: string; text: string }
|
|
756
|
+
|
|
757
|
+
function reportLine(title: string, items: ReportLineItem[], t: TranslateNS<'config-manager'>, warn = false) {
|
|
680
758
|
if (items.length === 0) return null
|
|
681
759
|
return (
|
|
682
760
|
<div className={css.inspectGroup} key={title}>
|
|
683
761
|
<div className={css.groupHeader}>
|
|
684
|
-
|
|
762
|
+
{/* 组标题用正文档字号 + 600(.reportGroupTitle):裸 <strong> 在 11px 小节头里比条目还小 */}
|
|
763
|
+
<strong className={warn ? `${css.reportGroupTitle} ${css.warnText}` : css.reportGroupTitle}>{title}{t('common.parens', { text: String(items.length) })}</strong>
|
|
685
764
|
</div>
|
|
686
765
|
<div className={css.reportScroll}>
|
|
687
766
|
<ul className={css.reportList}>
|
|
688
|
-
{items.map((item, i) =>
|
|
767
|
+
{items.map((item, i) => (
|
|
768
|
+
<li key={`${title}-${i}`} className={css.reportItem}>
|
|
769
|
+
{typeof item === 'string' ? item : (
|
|
770
|
+
<>
|
|
771
|
+
<span className={css.reportItemPath}>{item.path}:</span>
|
|
772
|
+
<span>{item.text}</span>
|
|
773
|
+
</>
|
|
774
|
+
)}
|
|
775
|
+
</li>
|
|
776
|
+
))}
|
|
689
777
|
</ul>
|
|
690
778
|
</div>
|
|
691
779
|
</div>
|
|
@@ -22,13 +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
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
31
31
|
import { ArtifactRowView, type ArtifactPendingAction } from './ArtifactRow.tsx'
|
|
32
|
+
import { resolveRemoteChannelPayload } from './LibraryActions.tsx'
|
|
32
33
|
import css from '../config-manager.module.css'
|
|
33
34
|
|
|
34
35
|
export interface LibraryPanelProps {
|
|
@@ -82,7 +83,7 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
82
83
|
/** 快照目录读不出来的事实(宿主 out.unreadable;null = 正常) */
|
|
83
84
|
const [snapshotsUnreadable, setSnapshotsUnreadable] = useState<string | null>(null)
|
|
84
85
|
const [currentRemoteId, setCurrentRemoteId] = useState<string | null>(null)
|
|
85
|
-
const [remoteChannel, setRemoteChannel] = useState<
|
|
86
|
+
const [remoteChannel, setRemoteChannel] = useState<SyncChannel | null>(null)
|
|
86
87
|
/** 面板内部的刷新信号(失败源卡片里的「重试」);外部的走 props.refreshTick */
|
|
87
88
|
const [localTick, setLocalTick] = useState(0)
|
|
88
89
|
/**
|
|
@@ -125,15 +126,11 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
125
126
|
// 先取 /sync/status 拿到通道与地址,再据此发请求;两处都不可用时该源如实标失败,绝不空手请求。
|
|
126
127
|
put(setRemote, syncApi.status({ workDirDetail: false }).then((status) => {
|
|
127
128
|
if (!mounted.current) return [] as SyncSnapshotLite[]
|
|
128
|
-
|
|
129
|
+
const resolved = resolveRemoteChannelPayload(status)
|
|
130
|
+
setRemoteChannel(resolved?.channel ?? (isClientChannel(status.lastSyncChannel) ? status.lastSyncChannel : null))
|
|
129
131
|
const configured = status.configured === true
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const payload = status.lastSyncChannel === 'webdav'
|
|
133
|
-
? (webdavUrl.trim() !== '' ? { transport: 'webdav' as const, url: webdavUrl.trim() } : null)
|
|
134
|
-
: (repoUrl.trim() !== '' ? { transport: 'git' as const, repoUrl: repoUrl.trim() } : null)
|
|
135
|
-
if (!configured || payload === null) return [] as SyncSnapshotLite[]
|
|
136
|
-
return syncApi.snapshotsList(payload).then((res) => {
|
|
132
|
+
if (!configured || resolved === null) return [] as SyncSnapshotLite[]
|
|
133
|
+
return syncApi.snapshotsList(resolved.payload).then((res) => {
|
|
137
134
|
if (mounted.current) setCurrentRemoteId(res.currentSnapshotId ?? null)
|
|
138
135
|
return res.snapshots
|
|
139
136
|
})
|
|
@@ -210,12 +207,12 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
210
207
|
* 行首来源徽章:档案名恒显示;只有「已知当前档案且不同」时才升到 warn 并带差异说明
|
|
211
208
|
* (宿主没给当前档案时只显示名字 —— 那是无法证明的结论)。
|
|
212
209
|
*/
|
|
213
|
-
const originBadgeOf = (row: ArtifactRow): { label: string;
|
|
210
|
+
const originBadgeOf = (row: ArtifactRow): { label: string; kind: 'info' | 'warn' } | undefined => {
|
|
214
211
|
if (row.kind !== 'snapshot') return undefined
|
|
215
212
|
const profile = originOfSnapshot.get(row.ref.snapshotId ?? '')
|
|
216
213
|
if (profile === undefined) return undefined
|
|
217
214
|
return snapshotOriginState({ originProfile: profile }, currentProfile ?? undefined) === 'foreign'
|
|
218
|
-
? { label: profile,
|
|
215
|
+
? { label: profile, kind: 'warn' }
|
|
219
216
|
: { label: profile, kind: 'info' }
|
|
220
217
|
}
|
|
221
218
|
|
|
@@ -280,7 +277,9 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
280
277
|
)}
|
|
281
278
|
|
|
282
279
|
{/* 加载态 / 空态与列表**同一条高度契约**(.libraryListState):三者都吃掉剩余高度,
|
|
283
|
-
底栏因此恒贴底(只在有数据时才需要列表本身,空态不该让页面塌成半截)。
|
|
280
|
+
底栏因此恒贴底(只在有数据时才需要列表本身,空态不该让页面塌成半截)。
|
|
281
|
+
2026-11-14 用户要求:空态卡本身也要吃满这块空间(.libraryEmptyFill)——
|
|
282
|
+
此前它只有内容高、居中悬在几百像素的空白里,整页读成「这里坏了」。 */}
|
|
284
283
|
{/* 还有来源在路上(本机两源已就绪但为空)时也走加载态:绝不先给「暂无产物」的结论。
|
|
285
284
|
与空态共用同一个 .libraryListState 契约(守卫要求恰好两处:加载态 + 空态)。 */}
|
|
286
285
|
{(loading || (anySourcePending && filtered.length === 0)) && (
|
|
@@ -292,7 +291,7 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
292
291
|
)}
|
|
293
292
|
|
|
294
293
|
{!loading && !anySourcePending && filtered.length === 0 && (
|
|
295
|
-
<div className={css.libraryListState}>
|
|
294
|
+
<div className={css.libraryListState + ' ' + css.libraryEmptyFill}>
|
|
296
295
|
<Empty>
|
|
297
296
|
{lib.query.trim() !== '' || lib.sourceFilter !== null
|
|
298
297
|
? t('library.emptyFiltered')
|
|
@@ -340,11 +339,11 @@ export function LibraryPanel({ api, syncApi, marketApi, t, uiT, onAction, onOpen
|
|
|
340
339
|
{encryptedCount > 0 && (
|
|
341
340
|
<Badge kind="warn">{uiT('library.summary.encrypted', { count: encryptedCount })}</Badge>
|
|
342
341
|
)}
|
|
343
|
-
<InfoHint text={t('backupFiles.hint')} label={t('common.infoHint')} />
|
|
344
342
|
<span className={css.statusSpacer} />
|
|
345
343
|
{/* 底栏四个入口,只有「导出」是这一页的产品级动作(把本机配置打成可分享的包);
|
|
346
344
|
其余三个是「拿别人的东西进来 / 去别处找」。主按钮只留一个,否则整屏没有焦点
|
|
347
345
|
(app-screens §13:强调色应用在数据与至多一个控件上)。 */}
|
|
346
|
+
{/* 不再挂 backupFiles.hint:那句写的是备份文件的清理规则,与「把配置打成可分享的包」无关(issue #143)。 */}
|
|
348
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>
|