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
|
@@ -29,18 +29,21 @@ import type { TranslateNS } from '../client-types.ts'
|
|
|
29
29
|
import type { ConfigManagerApi, ForeignImportResponse } from '../api.ts'
|
|
30
30
|
import type { UiT } from '../../ui/i18n.ts'
|
|
31
31
|
import {
|
|
32
|
+
foreignAgentPrompt,
|
|
32
33
|
foreignImportFailure,
|
|
33
34
|
foreignLossyRows,
|
|
34
35
|
foreignPathsText,
|
|
36
|
+
foreignProducedSkips,
|
|
35
37
|
foreignSourcesViewModel,
|
|
36
38
|
type ForeignImportFailure,
|
|
37
39
|
type ForeignSourceRow,
|
|
38
40
|
} from '../../ui/foreign-view.ts'
|
|
39
41
|
import { Badge, Banner, Button, Card, SectionTitle } from '../common/ui.tsx'
|
|
42
|
+
import { CopyButton } from '../common/CopyButton.tsx'
|
|
40
43
|
import { SkeletonList } from '../common/Skeleton.tsx'
|
|
41
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
42
44
|
import { ErrorBanner } from '../common/ErrorBanner.tsx'
|
|
43
45
|
import { redact } from '../../security/redaction.ts'
|
|
46
|
+
import { sectionLabeler } from '../common/section-labels.ts'
|
|
44
47
|
import css from '../config-manager.module.css'
|
|
45
48
|
|
|
46
49
|
export interface ForeignImportViewProps {
|
|
@@ -146,6 +149,8 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
146
149
|
}, [api, uiT, tick])
|
|
147
150
|
|
|
148
151
|
const rows = vm?.rows ?? []
|
|
152
|
+
const selectedRow = rows.find((r) => r.id === selected) ?? null
|
|
153
|
+
const producedSkips = foreignProducedSkips(produced?.skipped, uiT)
|
|
149
154
|
/**
|
|
150
155
|
* 三类已知有损的展示行(F-5):尚未产包时 applicable=null(界面不渲染适用性徽章),
|
|
151
156
|
* 产包后按包内分区逐条标注是否适用。判定全在 src/ui/foreign-view.ts 的纯函数里。
|
|
@@ -211,7 +216,7 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
211
216
|
|
|
212
217
|
return (
|
|
213
218
|
<div className={css.viewBody}>
|
|
214
|
-
<SectionTitle title={t('foreign.source.title')}
|
|
219
|
+
<SectionTitle title={t('foreign.source.title')} tooltip={t('foreign.source.hint')} />
|
|
215
220
|
|
|
216
221
|
{loadError !== null && (
|
|
217
222
|
<ErrorBanner
|
|
@@ -255,7 +260,7 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
255
260
|
**位置**:来源列表之后、动作行(含「开始导入」)之前 —— 既保证「导入前必读」,
|
|
256
261
|
又不把六个来源挤出首屏(t10 的 T10-F2 真机体验反馈)。 */}
|
|
257
262
|
<Card>
|
|
258
|
-
<div className={css.groupLabel}
|
|
263
|
+
<div className={css.groupLabel} title={t('foreign.lossy.hint')}>{t('foreign.lossy.title')}</div>
|
|
259
264
|
<ul className={css.skipList}>
|
|
260
265
|
{lossyRows.map((row) => (
|
|
261
266
|
<li key={row.kind} className={css.skipRow}>
|
|
@@ -264,7 +269,8 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
264
269
|
{row.applicable ? t('foreign.lossy.applies') : t('foreign.lossy.notApplies')}
|
|
265
270
|
</Badge>
|
|
266
271
|
)}
|
|
267
|
-
|
|
272
|
+
{/* detail 在窄画布上会被折行截断(T-03 剩余缺陷):title 兜住完整原文,不加布局、不加 CSS。 */}
|
|
273
|
+
<span className={css.skipText} title={redact(row.detail)}>
|
|
268
274
|
<strong>{redact(row.title)}</strong>{' '}
|
|
269
275
|
{redact(row.detail)}
|
|
270
276
|
</span>
|
|
@@ -275,12 +281,20 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
275
281
|
|
|
276
282
|
{/* 选中来源的未迁移项:**在选它之后**才展开,避免六来源的码堆在一起淹没有效信息 */}
|
|
277
283
|
{(() => {
|
|
278
|
-
const row =
|
|
284
|
+
const row = selectedRow
|
|
279
285
|
if (row === null || row.skips.length === 0) return null
|
|
280
286
|
return (
|
|
281
287
|
<Card>
|
|
282
|
-
<div className={css.
|
|
283
|
-
|
|
288
|
+
<div className={css.headRow}>
|
|
289
|
+
<div className={css.groupLabel}>
|
|
290
|
+
{t('foreign.skipped', { count: String(row.skips.length) })}
|
|
291
|
+
</div>
|
|
292
|
+
<span className={css.statusSpacer} />
|
|
293
|
+
<CopyButton
|
|
294
|
+
text={foreignAgentPrompt({ label: row.label, paths: row.paths, skips: row.skips }, uiT)}
|
|
295
|
+
label={t('foreign.copyAgentPrompt')}
|
|
296
|
+
t={t}
|
|
297
|
+
/>
|
|
284
298
|
</div>
|
|
285
299
|
<ul className={css.skipList}>
|
|
286
300
|
{row.skips.map((s, i) => (
|
|
@@ -303,15 +317,44 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
303
317
|
{/* 产包结果(成功后才出现):让用户在进向导前先看到「包里有什么」 */}
|
|
304
318
|
{produced !== null && (
|
|
305
319
|
<Card>
|
|
306
|
-
<div className={css.groupLabel}>{t('foreign.previewTitle')} <
|
|
320
|
+
<div className={css.groupLabel}>{t('foreign.previewTitle')} <span className={css.hint}>{t('foreign.previewDryRun')}</span></div>
|
|
307
321
|
<div className={css.statRow}>
|
|
308
322
|
<Badge kind="ok">
|
|
309
|
-
{t('foreign.previewSections', { sections: produced.sections.join(' · ') })}
|
|
323
|
+
{t('foreign.previewSections', { sections: produced.sections.map(sectionLabeler(t)).join(' · ') })}
|
|
310
324
|
</Badge>
|
|
311
325
|
{produced.credentialRefs.length > 0
|
|
312
326
|
? <Badge kind="warn">{t('foreign.credentialRefs', { count: String(produced.credentialRefs.length) })}</Badge>
|
|
313
327
|
: <Badge kind="info">{t('foreign.credentialRefsNone')}</Badge>}
|
|
314
328
|
</div>
|
|
329
|
+
{producedSkips.length > 0 && (
|
|
330
|
+
<>
|
|
331
|
+
<div className={css.headRow}>
|
|
332
|
+
<div className={css.groupLabel}>
|
|
333
|
+
{t('foreign.skipped', { count: String(producedSkips.length) })}
|
|
334
|
+
</div>
|
|
335
|
+
<span className={css.statusSpacer} />
|
|
336
|
+
<CopyButton
|
|
337
|
+
text={foreignAgentPrompt({
|
|
338
|
+
label: selectedRow?.label ?? redact(produced.source),
|
|
339
|
+
paths: produced.detectedPaths,
|
|
340
|
+
skips: producedSkips,
|
|
341
|
+
}, uiT)}
|
|
342
|
+
label={t('foreign.copyAgentPrompt')}
|
|
343
|
+
t={t}
|
|
344
|
+
/>
|
|
345
|
+
</div>
|
|
346
|
+
<ul className={css.skipList}>
|
|
347
|
+
{producedSkips.map((s, i) => (
|
|
348
|
+
<SkipLine
|
|
349
|
+
key={s.code + '-' + String(i)}
|
|
350
|
+
code={s.code}
|
|
351
|
+
text={redact(s.text)}
|
|
352
|
+
meta={s.origin !== undefined ? redact(s.origin) : (s.count !== undefined ? String(s.count) : '')}
|
|
353
|
+
/>
|
|
354
|
+
))}
|
|
355
|
+
</ul>
|
|
356
|
+
</>
|
|
357
|
+
)}
|
|
315
358
|
</Card>
|
|
316
359
|
)}
|
|
317
360
|
|
|
@@ -320,6 +363,21 @@ export function ForeignImportView({ api, t, uiT, onReady }: ForeignImportViewPro
|
|
|
320
363
|
{t('foreign.importFailed', { reason: redact(importFailure.text) })}
|
|
321
364
|
{/* 稳定码保留给排查/上报:文案是人话,码是可搜索的锚点(未知码时它就是唯一信息) */}
|
|
322
365
|
{importFailure.code !== null && <span className={css.skipCode}>{importFailure.code}</span>}
|
|
366
|
+
{selectedRow !== null && (
|
|
367
|
+
<>
|
|
368
|
+
<span className={css.statusSpacer} />
|
|
369
|
+
<CopyButton
|
|
370
|
+
text={foreignAgentPrompt({
|
|
371
|
+
label: selectedRow.label,
|
|
372
|
+
paths: selectedRow.paths,
|
|
373
|
+
skips: selectedRow.skips,
|
|
374
|
+
failure: importFailure,
|
|
375
|
+
}, uiT)}
|
|
376
|
+
label={t('foreign.copyAgentPrompt')}
|
|
377
|
+
t={t}
|
|
378
|
+
/>
|
|
379
|
+
</>
|
|
380
|
+
)}
|
|
323
381
|
</Banner>
|
|
324
382
|
)}
|
|
325
383
|
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from '../../ui/session-format-disposition.ts'
|
|
42
42
|
import type { ImportPreviewSummary } from '../../ui/types.ts'
|
|
43
43
|
import type { ImportAnalysis, ImportPlan, ImportResult } from '../../core/types.ts'
|
|
44
|
+
import type { SectionId } from '../../schema/types.ts'
|
|
44
45
|
import type { UiT } from '../../ui/i18n.ts'
|
|
45
46
|
import type { ConfigManagerApi } from '../api.ts'
|
|
46
47
|
import type { TranslateNS } from '../client-types.ts'
|
|
@@ -48,7 +49,6 @@ import { runStore } from '../run-store.ts'
|
|
|
48
49
|
import {
|
|
49
50
|
Badge, Banner, Button, Card, SectionTitle, Stepper,
|
|
50
51
|
} from '../common/ui.tsx'
|
|
51
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
52
52
|
import { ErrorBanner, ErrorList } from '../common/ErrorBanner.tsx'
|
|
53
53
|
import { ProgressBar } from '../common/ProgressBar.tsx'
|
|
54
54
|
import type { RunProgress } from '../common/progress-view.ts'
|
|
@@ -105,7 +105,7 @@ function NextStepsCard({ plan, result, t }: {
|
|
|
105
105
|
<ul className={`${css.reportList} ${css.nextStepsList}`}>
|
|
106
106
|
{steps.restartItems.map((item) => (
|
|
107
107
|
// description 由宿主按计划项拼装(可能含 MCP env/headers 等本地配置片段)→ 渲染前过 redact
|
|
108
|
-
<li key={item.id}>{item.adapter}: {redact(item.description)}</li>
|
|
108
|
+
<li key={item.id}>{sectionLabel(item.adapter as SectionId, t)}: {redact(item.description)}</li>
|
|
109
109
|
))}
|
|
110
110
|
</ul>
|
|
111
111
|
</div>
|
|
@@ -150,7 +150,7 @@ function CompatibilityStep(props: {
|
|
|
150
150
|
const notes = compatibilityNotes(analysis.compatibilityReasons)
|
|
151
151
|
return (
|
|
152
152
|
<div className={css.viewBody}>
|
|
153
|
-
<SectionTitle title={t('import.compatibility.title')} />
|
|
153
|
+
<SectionTitle title={t('import.compatibility.title')} tooltip={t('import.compatibility.hint')} />
|
|
154
154
|
<div className={css.statRow}>
|
|
155
155
|
<Badge kind={compatibilityBadgeKind(level)}>
|
|
156
156
|
{t('import.compatibility.score', { score: t(scoreKey) })}
|
|
@@ -263,7 +263,7 @@ function ContentSelectStage(props: {
|
|
|
263
263
|
} = props
|
|
264
264
|
return (
|
|
265
265
|
<div className={css.viewBody}>
|
|
266
|
-
<SectionTitle title={t('import.picker.title')}
|
|
266
|
+
<SectionTitle title={t('import.picker.title')} tooltip={t('import.picker.hint')} />
|
|
267
267
|
<div className={css.statRow}>
|
|
268
268
|
<Badge kind={summary.willChange > 0 ? 'info' : 'ok'}>{t('import.preview.willChange', { count: String(summary.willChange) })}</Badge>
|
|
269
269
|
{summary.unchanged > 0 && <Badge kind="ok">{t('import.preview.unchanged', { count: String(summary.unchanged) })}</Badge>}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 路径映射表单(规范 §12,绑 src/ui/types.ts 的 PathMappingDraft 形状)。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 浏览器半不能引 node:path,所以这里只做「收集用户输入」:输入输出形状与 core 的
|
|
5
|
+
* PathMapping 完全一致(oldPrefix/newPrefix/appliesTo),实际前缀替换由 Host 侧 core 在
|
|
6
|
+
* createImportPlan 阶段执行。此前另有一份 src/ui/path-mapping.ts 的同规则实现(依赖
|
|
7
|
+
* utils/paths.ts),生产零引用,已删(审计 P10-6:同一规则只留一处)。
|
|
8
8
|
*/
|
|
9
9
|
import { useMemo, useState } from 'react'
|
|
10
10
|
import type { ChangeEvent } from 'react'
|
|
11
11
|
import type { PathIssue, PathMapping } from '../../core/types.ts'
|
|
12
12
|
import type { TranslateNS } from '../client-types.ts'
|
|
13
|
-
import { Banner, IconButton } from '../common/ui.tsx'
|
|
13
|
+
import { Banner, Button, IconButton } from '../common/ui.tsx'
|
|
14
14
|
import { FolderOpenIcon } from '../common/Icon.tsx'
|
|
15
15
|
import { PathPickerDialog } from './PathPickerDialog.tsx'
|
|
16
16
|
import type { PathBrowsePort } from './PathPickerDialog.tsx'
|
|
@@ -53,15 +53,35 @@ export function PathMappingForm({ issues, initial, t, onChange, api }: PathMappi
|
|
|
53
53
|
return out
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
const
|
|
57
|
-
const next = { ...drafts, [oldPrefix]: value }
|
|
56
|
+
const commitDrafts = (next: Record<string, string>): void => {
|
|
58
57
|
setDrafts(next)
|
|
59
58
|
const mappings: PathMapping[] = Object.entries(next)
|
|
60
|
-
.filter(([, v]) => v !== '')
|
|
61
|
-
.map(([oldPrefix, newPrefix]) => ({ oldPrefix, newPrefix, appliesTo: [] }))
|
|
59
|
+
.filter(([, v]) => v.trim() !== '')
|
|
60
|
+
.map(([oldPrefix, newPrefix]) => ({ oldPrefix, newPrefix: newPrefix.trim(), appliesTo: [] }))
|
|
62
61
|
onChange(mappings)
|
|
63
62
|
}
|
|
64
63
|
|
|
64
|
+
const setNewPrefix = (oldPrefix: string, value: string): void => {
|
|
65
|
+
commitDrafts({ ...drafts, [oldPrefix]: value })
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const suggestedIssues = issues.filter(
|
|
69
|
+
(issue) =>
|
|
70
|
+
typeof issue.mappedTo === 'string' &&
|
|
71
|
+
issue.mappedTo.trim() !== '' &&
|
|
72
|
+
(drafts[issue.value] ?? '').trim() === '',
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const applySuggested = (): void => {
|
|
76
|
+
const next = { ...drafts }
|
|
77
|
+
for (const issue of suggestedIssues) {
|
|
78
|
+
if (typeof issue.mappedTo === 'string' && issue.mappedTo.trim() !== '') {
|
|
79
|
+
next[issue.value] = issue.mappedTo
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
commitDrafts(next)
|
|
83
|
+
}
|
|
84
|
+
|
|
65
85
|
/**
|
|
66
86
|
* 文件夹按钮的完整动作,三层降级,任一层拿到绝对路径就回填:
|
|
67
87
|
* ① **DSH 宿主自带**的目录选择器(就是「选择工作区目录」那个原生窗口,跟着宿主主进程走,最稳);
|
|
@@ -102,6 +122,13 @@ export function PathMappingForm({ issues, initial, t, onChange, api }: PathMappi
|
|
|
102
122
|
{unresolved.length > 0 && (
|
|
103
123
|
<Banner kind="info">{t('import.paths.unresolved', { count: String(unresolved.length) })}</Banner>
|
|
104
124
|
)}
|
|
125
|
+
{suggestedIssues.length > 0 && (
|
|
126
|
+
<div className={css.actionRow}>
|
|
127
|
+
<Button size="sm" variant="ghost" onClick={applySuggested}>
|
|
128
|
+
{t('import.paths.applySuggested')}
|
|
129
|
+
</Button>
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
105
132
|
{issues.length === 0 && <div className={css.empty}>{t('import.paths.empty')}</div>}
|
|
106
133
|
{issues.map((issue) => (
|
|
107
134
|
<div key={issue.value} className={css.pathRow}>
|
|
@@ -22,6 +22,7 @@ import type { BrowseErrorCode, BrowseResult } from '../../core/path-browse.ts'
|
|
|
22
22
|
import type { ConfigManagerApi } from '../api.ts'
|
|
23
23
|
import type { TranslateNS } from '../client-types.ts'
|
|
24
24
|
import { Modal } from '../common/Modal.tsx'
|
|
25
|
+
import { redact } from '../../security/redaction.ts'
|
|
25
26
|
import { Banner, Button, Spinner } from '../common/ui.tsx'
|
|
26
27
|
import { FileIcon, FolderIcon } from '../common/Icon.tsx'
|
|
27
28
|
import css from '../config-manager.module.css'
|
|
@@ -100,7 +101,7 @@ export function PathPickerDialog({ open, api, t, startPath, onPick, onClose }: P
|
|
|
100
101
|
},
|
|
101
102
|
(error: unknown) => {
|
|
102
103
|
if (!alive) return
|
|
103
|
-
setState({ kind: 'failed', detail: error instanceof Error ? error.message : String(error) })
|
|
104
|
+
setState({ kind: 'failed', detail: redact(error instanceof Error ? error.message : String(error)) })
|
|
104
105
|
},
|
|
105
106
|
)
|
|
106
107
|
return () => { alive = false }
|
|
@@ -82,7 +82,7 @@ test('t45/t50: 脱敏登记渲染点必须留在主文件(或日志面板模
|
|
|
82
82
|
/import \{ redact \} from '\.\.\/\.\.\/security\/redaction\.ts'/,
|
|
83
83
|
'tests/client/import-wizard-redaction.test.ts 要求主文件 import redact',
|
|
84
84
|
)
|
|
85
|
-
assert.match(view, /\{item\.adapter\}: \{redact\(item\.description\)\}<\/li>/, '收尾清单登记点必须留在主文件')
|
|
85
|
+
assert.match(view, /\{sectionLabel\(item\.adapter as SectionId, t\)\}: \{redact\(item\.description\)\}<\/li>/, '收尾清单登记点必须留在主文件')
|
|
86
86
|
assert.match(view, /\{analysis\.warnings\.map\(\(w, i\) => <div key=\{i\}>\{redact\(w\)\}<\/div>\)\}/, '分析告警登记点必须留在主文件')
|
|
87
87
|
// 2026-09:日志改为「合并后的项状态行 + 明细行」,两处脱敏渲染点在日志面板模块内
|
|
88
88
|
// (同点登记见 src/client/common/plan-text-redaction.test.ts 的 import-log-* 两条)
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Badge, Banner, Button, Card, Checkbox, Empty, SectionTitle,
|
|
18
18
|
} from '../common/ui.tsx'
|
|
19
19
|
import { Skeleton } from '../common/Skeleton.tsx'
|
|
20
|
-
import {
|
|
20
|
+
import { ImportIcon } from '../common/Icon.tsx'
|
|
21
21
|
import { ErrorBanner, ErrorList } from '../common/ErrorBanner.tsx'
|
|
22
22
|
import { CopyButton } from '../common/CopyButton.tsx'
|
|
23
23
|
import {
|
|
@@ -101,7 +101,7 @@ export function SelectStep(props: {
|
|
|
101
101
|
const { fileInput, selectModel, uploading, error, onCancel, onPickFile, onReset, apiT, t } = props
|
|
102
102
|
return (
|
|
103
103
|
<div className={`${css.viewBody} ${css.sparseFill}`}>
|
|
104
|
-
<SectionTitle title={t('import.select.title')}
|
|
104
|
+
<SectionTitle title={t('import.select.title')} tooltip={t('import.select.hint')} />
|
|
105
105
|
<input
|
|
106
106
|
ref={fileInput}
|
|
107
107
|
type="file"
|
|
@@ -113,6 +113,18 @@ export function SelectStep(props: {
|
|
|
113
113
|
void onPickFile(file)
|
|
114
114
|
}}
|
|
115
115
|
/>
|
|
116
|
+
{/* 投放容器(W3 R-1):只承载图标与主按钮,不做拖拽(宿主没有 drop 能力,
|
|
117
|
+
写「拖拽到此处」就是承诺做不到的事);点击目标仍是那颗唯一的主按钮。 */}
|
|
118
|
+
<div className={css.dropZone}>
|
|
119
|
+
<ImportIcon size={22} className={css.dropZoneIcon} />
|
|
120
|
+
<Button
|
|
121
|
+
variant="primary"
|
|
122
|
+
loading={uploading}
|
|
123
|
+
onClick={() => { fileInput.current?.click() }}
|
|
124
|
+
>
|
|
125
|
+
{t(browseLabelKey(selectModel.selectedName !== null))}
|
|
126
|
+
</Button>
|
|
127
|
+
</div>
|
|
116
128
|
{selectModel.selectedName !== null && (
|
|
117
129
|
/* 已选文件是**值**,不是说明:用徽章承载(原先是一句「已选择:xxx」),
|
|
118
130
|
data-testid 保持不变以便既有守卫继续定位。 */
|
|
@@ -120,20 +132,13 @@ export function SelectStep(props: {
|
|
|
120
132
|
<Badge kind="info">{t('import.select.file', { name: selectModel.selectedName })}</Badge>
|
|
121
133
|
</div>
|
|
122
134
|
)}
|
|
123
|
-
|
|
124
|
-
{
|
|
135
|
+
{selectModel.selectedName !== null && (
|
|
136
|
+
<div className={css.actionRow} style={{ marginBottom: 0 }}>
|
|
125
137
|
<Button variant="ghost" onClick={onCancel}>
|
|
126
138
|
{t('import.select.cancel')}
|
|
127
139
|
</Button>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
variant="primary"
|
|
131
|
-
loading={uploading}
|
|
132
|
-
onClick={() => { fileInput.current?.click() }}
|
|
133
|
-
>
|
|
134
|
-
{t(browseLabelKey(selectModel.selectedName !== null))}
|
|
135
|
-
</Button>
|
|
136
|
-
</div>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
137
142
|
{error !== null && <ErrorBanner error={error} onRetry={onReset} t={apiT} />}
|
|
138
143
|
</div>
|
|
139
144
|
)
|
|
@@ -170,10 +175,10 @@ export function ConsultStage(props: {
|
|
|
170
175
|
const { consultLoading, consultReport, error, onNext, onReset, apiT, t } = props
|
|
171
176
|
return (
|
|
172
177
|
<div className={css.viewBody}>
|
|
173
|
-
<SectionTitle title={t('import.preview.title')}
|
|
178
|
+
<SectionTitle title={t('import.preview.title')} tooltip={t('import.consult.hint')} />
|
|
174
179
|
{consultLoading && <Skeleton shape="line" count={5} label={apiT('consult.loading')} />}
|
|
175
180
|
{consultReport !== null && <ConsultCard report={consultReport} t={apiT} />}
|
|
176
|
-
{!consultLoading && consultReport === null && (
|
|
181
|
+
{!consultLoading && consultReport === null && error === null && (
|
|
177
182
|
<Banner kind="info">{t('import.consult.unavailable')}</Banner>
|
|
178
183
|
)}
|
|
179
184
|
{error !== null && <ErrorBanner error={error} onRetry={onNext} t={apiT} />}
|
|
@@ -201,27 +206,34 @@ export function DecryptArchiveStep(props: {
|
|
|
201
206
|
const { password, onPasswordChange, unlockError, unlocking, onUnlock, onReset, apiT, t } = props
|
|
202
207
|
return (
|
|
203
208
|
<div className={css.viewBody}>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
className={css.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
209
|
+
{/* 解锁卡(W3 R-3):徽章 / 标题 / 密码 / 动作收进同一张卡,屏幕上只剩一个黑底主按钮。
|
|
210
|
+
机制句只进标题 title(DESIGN §7:说明性文案不进正文)。 */}
|
|
211
|
+
<Card className={css.optionsCard}>
|
|
212
|
+
<div className={css.statRow}>
|
|
213
|
+
<Badge kind="error">🔒 {t('import.decrypt.badge')}</Badge>
|
|
214
|
+
</div>
|
|
215
|
+
<SectionTitle title={t('import.decryptArchive.title')} tooltip={t('import.decryptArchive.hint')} />
|
|
216
|
+
<input
|
|
217
|
+
type="password"
|
|
218
|
+
className={css.input}
|
|
219
|
+
autoComplete="off"
|
|
220
|
+
placeholder={t('import.decryptArchive.passwordPlaceholder')}
|
|
221
|
+
value={password}
|
|
222
|
+
onChange={(e: ChangeEvent<HTMLInputElement>) => { onPasswordChange(e.target.value) }}
|
|
223
|
+
/>
|
|
224
|
+
{unlockError !== null && <ErrorBanner error={unlockError} t={apiT} />}
|
|
225
|
+
<div className={css.actionRow} style={{ marginBottom: 0 }}>
|
|
226
|
+
<Button variant="ghost" onClick={onReset}>{t('import.select.reselect')}</Button>
|
|
227
|
+
<Button
|
|
228
|
+
variant="primary"
|
|
229
|
+
loading={unlocking}
|
|
230
|
+
disabled={password === ''}
|
|
231
|
+
onClick={onUnlock}
|
|
232
|
+
>
|
|
233
|
+
{t('import.decryptArchive.unlock')}
|
|
234
|
+
</Button>
|
|
235
|
+
</div>
|
|
236
|
+
</Card>
|
|
225
237
|
</div>
|
|
226
238
|
)
|
|
227
239
|
}
|
|
@@ -237,7 +249,7 @@ export function ConflictsStage(props: {
|
|
|
237
249
|
const { collector, onChanged, onBack, onNext, t } = props
|
|
238
250
|
return (
|
|
239
251
|
<div className={css.viewBody}>
|
|
240
|
-
<SectionTitle title={t('import.conflicts.title')}
|
|
252
|
+
<SectionTitle title={t('import.conflicts.title')} />
|
|
241
253
|
<ConflictList
|
|
242
254
|
collector={collector}
|
|
243
255
|
t={t}
|
|
@@ -267,7 +279,7 @@ export function PathMappingStage(props: {
|
|
|
267
279
|
const { issues, mappings, onMappingsChange, onBack, onNext, t, api } = props
|
|
268
280
|
return (
|
|
269
281
|
<div className={css.viewBody}>
|
|
270
|
-
<SectionTitle title={t('import.paths.title')}
|
|
282
|
+
<SectionTitle title={t('import.paths.title')} tooltip={t('import.paths.hint')} />
|
|
271
283
|
<PathMappingForm issues={issues} initial={mappings} t={t} onChange={onMappingsChange} api={api} />
|
|
272
284
|
<div className={css.actionRow}>
|
|
273
285
|
<Button variant="ghost" onClick={onBack}>{t('common.back')}</Button>
|
|
@@ -289,7 +301,7 @@ export function SecretsStage(props: {
|
|
|
289
301
|
const { missing, value, onValueChange, onBack, onNext, t } = props
|
|
290
302
|
return (
|
|
291
303
|
<div className={css.viewBody}>
|
|
292
|
-
<SectionTitle title={t('import.secrets.title')}
|
|
304
|
+
<SectionTitle title={t('import.secrets.title')} tooltip={t('import.secrets.hint')} />
|
|
293
305
|
<SecretsForm
|
|
294
306
|
missing={missing}
|
|
295
307
|
value={value}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 导入向导控制器的两处事务语义(审计 P9-7 / P9-8)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么测纯函数而不是 hook:仓库没有组件测试环境(AGENTS.md:逻辑提炼到可 node 跑的函数)。
|
|
5
|
+
* 于是把「解锁 → 继续分析」写成注入端口的异步事务、把「咨询失败 → 文案」写成纯函数,
|
|
6
|
+
* 这里直接跑它们;再用一条源码断言锁住 hook 里**确实调用了**这两处(纯函数测绿但没接线 = 白测)。
|
|
7
|
+
*/
|
|
8
|
+
import test from 'node:test'
|
|
9
|
+
import assert from 'node:assert/strict'
|
|
10
|
+
import fs from 'node:fs'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
|
|
13
|
+
import { ConfigManagerApiError } from '../common/http.ts'
|
|
14
|
+
import {
|
|
15
|
+
consultFailureError,
|
|
16
|
+
unlockArchiveThenAnalyze,
|
|
17
|
+
type ArchiveUnlockFlow,
|
|
18
|
+
} from './use-import-wizard-controller.ts'
|
|
19
|
+
|
|
20
|
+
/** 被实测的接线源码(断言 hook 里确实调用了下面两个纯函数) */
|
|
21
|
+
const CONTROLLER = fileURLToPath(new URL('./use-import-wizard-controller.ts', import.meta.url))
|
|
22
|
+
|
|
23
|
+
/* ---------------------------------------------------------------- P9-7 ---- */
|
|
24
|
+
|
|
25
|
+
test('P9-7 consultFailureError:404 = 宿主不支持(null),其余失败 = 可读消息', () => {
|
|
26
|
+
// 404:老宿主没有 /consult 路由 —— 界面继续按「宿主不支持」渲染 info 横幅,不制造错误
|
|
27
|
+
assert.equal(consultFailureError(new ConfigManagerApiError('Not Found', 404)), null)
|
|
28
|
+
assert.equal(
|
|
29
|
+
consultFailureError(new ConfigManagerApiError('404 no route', 404, 'not-found')),
|
|
30
|
+
null,
|
|
31
|
+
'带 code 的 404 同样是「不支持」',
|
|
32
|
+
)
|
|
33
|
+
// 其它状态码:必须变成可见错误(此前 catch 只 setConsultReport(null) ⇒ 用户看到「没有结论」)
|
|
34
|
+
assert.equal(consultFailureError(new ConfigManagerApiError('boom', 500)), 'boom')
|
|
35
|
+
assert.equal(consultFailureError(new ConfigManagerApiError('timeout', 504)), 'timeout')
|
|
36
|
+
// 无 status(网络层 / 解析失败)
|
|
37
|
+
assert.equal(consultFailureError(new Error('fetch failed')), 'fetch failed')
|
|
38
|
+
// 非 Error 值兜底为字符串,不能变成 undefined / [object Object]
|
|
39
|
+
assert.equal(consultFailureError('plain text'), 'plain text')
|
|
40
|
+
assert.equal(consultFailureError(undefined), 'undefined')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('P9-7 接线:consult 失败时把消息写进 import.error(而不是只清空报告)', () => {
|
|
44
|
+
const src = fs.readFileSync(CONTROLLER, 'utf8')
|
|
45
|
+
assert.match(src, /const message = consultFailureError\(err\)/, 'catch 必须经 consultFailureError 分档')
|
|
46
|
+
assert.match(src, /if \(message !== null\) \{\s*runStore\.patch\(\{ import: \{ error: message \} \}\)/, '非 404 失败必须写 import.error 供 ErrorBanner 渲染')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
/* ---------------------------------------------------------------- P9-8 ---- */
|
|
50
|
+
|
|
51
|
+
interface Trace {
|
|
52
|
+
calls: string[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function flow(
|
|
56
|
+
trace: Trace,
|
|
57
|
+
opts: {
|
|
58
|
+
unlockFails?: boolean
|
|
59
|
+
analyzeFails?: boolean
|
|
60
|
+
/** 第 n 次调用 cancelled() 的返回值(默认恒 false) */
|
|
61
|
+
cancelledAt?: (call: number) => boolean
|
|
62
|
+
} = {},
|
|
63
|
+
): ArchiveUnlockFlow<string> {
|
|
64
|
+
let cancelledCalls = 0
|
|
65
|
+
return {
|
|
66
|
+
unlock: async () => {
|
|
67
|
+
trace.calls.push('unlock')
|
|
68
|
+
if (opts.unlockFails === true) throw new Error('密码错误')
|
|
69
|
+
return { refs: ['a', 'b'] }
|
|
70
|
+
},
|
|
71
|
+
commitUnlocked: (refs) => { trace.calls.push('commit:' + refs.join(',')) },
|
|
72
|
+
analyze: async () => {
|
|
73
|
+
trace.calls.push('analyze')
|
|
74
|
+
if (opts.analyzeFails === true) throw new Error('ZIP 解析失败')
|
|
75
|
+
return null
|
|
76
|
+
},
|
|
77
|
+
rollbackUnlocked: () => { trace.calls.push('rollback') },
|
|
78
|
+
cancelled: () => {
|
|
79
|
+
cancelledCalls += 1
|
|
80
|
+
return opts.cancelledAt === undefined ? false : opts.cancelledAt(cancelledCalls)
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
test('P9-8 unlockArchiveThenAnalyze:成功路径按 解锁 → 提交 → 分析 顺序进行,不回滚', async () => {
|
|
86
|
+
const trace: Trace = { calls: [] }
|
|
87
|
+
const outcome = await unlockArchiveThenAnalyze(flow(trace))
|
|
88
|
+
assert.deepEqual(outcome, { status: 'ok' })
|
|
89
|
+
assert.deepEqual(trace.calls, ['unlock', 'commit:a,b', 'analyze'])
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('P9-8 unlockArchiveThenAnalyze:解锁成功但 selectZip 抛错 ⇒ 回滚已提交的解锁态', async () => {
|
|
93
|
+
const trace: Trace = { calls: [] }
|
|
94
|
+
const outcome = await unlockArchiveThenAnalyze(flow(trace, { analyzeFails: true }))
|
|
95
|
+
// 这就是审计的根因场景:archiveUnlocked 已 true 而 phase 停在 decrypt-archive
|
|
96
|
+
assert.deepEqual(outcome, { status: 'failed', message: 'ZIP 解析失败', unlocked: true })
|
|
97
|
+
assert.deepEqual(trace.calls, ['unlock', 'commit:a,b', 'analyze', 'rollback'], '提交过就必须回滚,且只回滚一次')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('P9-8 unlockArchiveThenAnalyze:解锁本身失败 ⇒ 不提交、不回滚', async () => {
|
|
101
|
+
const trace: Trace = { calls: [] }
|
|
102
|
+
const outcome = await unlockArchiveThenAnalyze(flow(trace, { unlockFails: true }))
|
|
103
|
+
assert.deepEqual(outcome, { status: 'failed', message: '密码错误', unlocked: false })
|
|
104
|
+
assert.deepEqual(trace.calls, ['unlock'], '没提交过的解锁态没有可回滚的东西')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('P9-8 unlockArchiveThenAnalyze:解锁期间向导被重置 ⇒ 丢弃结果,不提交', async () => {
|
|
108
|
+
const trace: Trace = { calls: [] }
|
|
109
|
+
const outcome = await unlockArchiveThenAnalyze(flow(trace, { cancelledAt: (n) => n === 1 }))
|
|
110
|
+
assert.deepEqual(outcome, { status: 'cancelled' })
|
|
111
|
+
assert.deepEqual(trace.calls, ['unlock'], 'reset 已清空状态,再提交会污染新一轮导入')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test('P9-8 unlockArchiveThenAnalyze:分析失败时若向导已被重置 ⇒ 不回滚(不覆盖新一轮)', async () => {
|
|
115
|
+
const trace: Trace = { calls: [] }
|
|
116
|
+
// 第 1 次(提交前)false,第 2 次(catch 里)true —— 用户恰在 analyze 期间点了重新选择
|
|
117
|
+
const outcome = await unlockArchiveThenAnalyze(flow(trace, { analyzeFails: true, cancelledAt: (n) => n === 2 }))
|
|
118
|
+
assert.deepEqual(outcome, { status: 'cancelled' })
|
|
119
|
+
assert.deepEqual(trace.calls, ['unlock', 'commit:a,b', 'analyze'], '回滚会把已重置的向导再拽回 decrypt-archive')
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test('P9-8 接线:onUnlockArchive 使用事务,且回滚同时写 wizard 与 store 两份状态', () => {
|
|
123
|
+
const src = fs.readFileSync(CONTROLLER, 'utf8')
|
|
124
|
+
assert.match(src, /const outcome = await unlockArchiveThenAnalyze\(\{/, 'onUnlockArchive 必须走事务,而不是 try 里直接 patch')
|
|
125
|
+
// 回滚块:wizard 侧(setDecryptPassword('') / setArchiveEncrypted(true, …))+ store 侧四个字段
|
|
126
|
+
assert.match(src, /wizard\.setArchiveEncrypted\(true, encryptedPath\)/, '回滚必须把 wizard 恢复成「加密未解锁」')
|
|
127
|
+
assert.match(src, /archiveUnlocked: false,[\s\S]{0,120}phase: 'decrypt-archive'/, '回滚必须把 phase 退回 decrypt-archive(与 archiveUnlocked 一致)')
|
|
128
|
+
assert.match(src, /if \(outcome\.status === 'failed'\) \{/, '失败必须走可见错误(archiveUnlockError)')
|
|
129
|
+
})
|