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
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* t42 物理拆分(从 SyncSettingsView.tsx 拆出的渲染段,同领域目录平铺;v2 第 5 步主文件改名 SyncPanel.tsx)。
|
|
3
|
-
*
|
|
4
|
-
* 约定:只接收「渲染所需的数据 + 回调」;React 状态、副作用与网络调用仍由
|
|
5
|
-
* SyncPanel 持有(单一状态源);可测纯逻辑在 src/ui/sync-settings-view.ts。
|
|
6
|
-
*/
|
|
7
|
-
import type { ChangeEvent } from 'react'
|
|
8
|
-
import type { TranslateNS } from '../client-types.ts'
|
|
9
|
-
import { Badge, Button, Card } from '../common/ui.tsx'
|
|
10
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
11
|
-
import type { ChannelSyncState } from './sync-view.ts'
|
|
12
|
-
import type { SyncChannelSettingsPatch } from '../../ui/sync-settings-view.ts'
|
|
13
|
-
import css from '../config-manager.module.css'
|
|
14
|
-
|
|
15
|
-
/** 解密密码卡(当前通道拉取/一键同步加密快照用;输入即保存到本机凭据库)。 */
|
|
16
|
-
export function DecryptPasswordCard({ t, settings, onPatchSettings, onPersistDecryptPassword, onClearSavedPassword }: {
|
|
17
|
-
t: TranslateNS<'config-manager-sync'>
|
|
18
|
-
settings: Pick<ChannelSyncState, 'decryptPassword' | 'decryptPasswordSaved'>
|
|
19
|
-
onPatchSettings: (patch: SyncChannelSettingsPatch) => void
|
|
20
|
-
onPersistDecryptPassword: () => void
|
|
21
|
-
onClearSavedPassword: () => void
|
|
22
|
-
}) {
|
|
23
|
-
return (
|
|
24
|
-
<Card>
|
|
25
|
-
<div className={css.field}>
|
|
26
|
-
<span className={css.fieldLabel}>{t('mode.decryptPassword')} <InfoHint text={t('mode.decryptPasswordHint')} label={t('common.infoHint')} /></span>
|
|
27
|
-
<input aria-label={t('mode.decryptPassword')}
|
|
28
|
-
type="password"
|
|
29
|
-
className={css.input}
|
|
30
|
-
value={settings.decryptPassword}
|
|
31
|
-
autoComplete="off"
|
|
32
|
-
placeholder={settings.decryptPasswordSaved ? t('mode.decryptPasswordPlaceholder') : undefined}
|
|
33
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => { onPatchSettings({ decryptPassword: e.target.value }) }}
|
|
34
|
-
onBlur={onPersistDecryptPassword}
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
37
|
-
{settings.decryptPasswordSaved && (
|
|
38
|
-
<div className={css.actionRow}>
|
|
39
|
-
<Badge kind="ok">{t('mode.decryptPasswordSaved')}</Badge>
|
|
40
|
-
{/* 危险语义:删除本机已保存的密码(不可逆,用户主动操作) */}
|
|
41
|
-
<Button size="sm" variant="danger" onClick={onClearSavedPassword}>
|
|
42
|
-
{t('mode.clearSavedPassword')}
|
|
43
|
-
</Button>
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
46
|
-
</Card>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* t42 物理拆分(从 SyncSettingsView.tsx 拆出的渲染段,同领域目录平铺;v2 第 5 步主文件改名 SyncPanel.tsx)。
|
|
3
|
-
*
|
|
4
|
-
* 约定:只接收「渲染所需的数据 + 回调」;React 状态、副作用与网络调用仍由
|
|
5
|
-
* SyncPanel 持有(单一状态源);可测纯逻辑在 src/ui/sync-settings-view.ts。
|
|
6
|
-
*/
|
|
7
|
-
import type { ChangeEvent } from 'react'
|
|
8
|
-
import type { TranslateNS } from '../client-types.ts'
|
|
9
|
-
import { Card, Checkbox } from '../common/ui.tsx'
|
|
10
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
11
|
-
import type { ChannelSyncState } from './sync-view.ts'
|
|
12
|
-
import type { SyncChannelSettingsPatch } from '../../ui/sync-settings-view.ts'
|
|
13
|
-
import css from '../config-manager.module.css'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 加密与密钥导出(当前通道手动推送;仿「导出备份·自定义模式」安全选项)。
|
|
17
|
-
* 只看渲染所需字段 + 回调;联动规则在 ui/sync-settings-view.ts 的 encryptToggle/includeSecretsToggle。
|
|
18
|
-
*/
|
|
19
|
-
export function SecurityOptionsCard({ t, settings, onToggleEncrypt, onToggleIncludeSecrets, onPatchSettings, onPersistEncryptPassword }: {
|
|
20
|
-
t: TranslateNS<'config-manager-sync'>
|
|
21
|
-
settings: Pick<ChannelSyncState, 'encrypt' | 'includeSecrets' | 'encryptPassword' | 'encryptPasswordConfirm' | 'encryptPasswordSaved'>
|
|
22
|
-
onToggleEncrypt: (next: boolean) => void
|
|
23
|
-
onToggleIncludeSecrets: (next: boolean) => void
|
|
24
|
-
onPatchSettings: (patch: SyncChannelSettingsPatch) => void
|
|
25
|
-
onPersistEncryptPassword: () => void
|
|
26
|
-
}) {
|
|
27
|
-
return (
|
|
28
|
-
<Card>
|
|
29
|
-
<span className={css.groupLabel}>{t('mode.security')}</span>
|
|
30
|
-
{/* 说明性文案一律进 ⓘ(2026-10-12 用户要求:卡里只留勾选项与控件)。
|
|
31
|
-
「加密方式 + 密码存哪 + 自动同步跳过加密快照」两句合成同一颗 ⓘ。 */}
|
|
32
|
-
<div className={css.controlRow}>
|
|
33
|
-
<Checkbox
|
|
34
|
-
checked={settings.encrypt}
|
|
35
|
-
onChange={onToggleEncrypt}
|
|
36
|
-
label={<span className={css.categoryName}>{t('mode.encrypt')}</span>}
|
|
37
|
-
/>
|
|
38
|
-
<InfoHint
|
|
39
|
-
text={t('mode.encryptHint') + ' ' + t('mode.encryptAutosyncNotice')}
|
|
40
|
-
label={t('common.infoHint')}
|
|
41
|
-
/>
|
|
42
|
-
</div>
|
|
43
|
-
{/* 数据丢失后果贴在它真正发生的那个勾选框下面(且只在确有已保存密码时出现)。
|
|
44
|
-
原先写在密码输入区里:用户在「改密码」的位置读到「取消勾选会删密码」,位置与决定对不上。 */}
|
|
45
|
-
{settings.encrypt && settings.encryptPasswordSaved && (
|
|
46
|
-
<span className={css.hint + ' ' + css.warnText}>{t('mode.passwordClearNotice')}</span>
|
|
47
|
-
)}
|
|
48
|
-
{settings.encrypt && (
|
|
49
|
-
<div className={css.secretFields}>
|
|
50
|
-
<div className={css.field}>
|
|
51
|
-
<span className={css.fieldLabel}>
|
|
52
|
-
{t('mode.password')}
|
|
53
|
-
{' '}
|
|
54
|
-
{settings.encryptPasswordSaved && <InfoHint text={t('mode.passwordSavedHint')} label={t('common.infoHint')} />}
|
|
55
|
-
</span>
|
|
56
|
-
<input aria-label={t('mode.password')}
|
|
57
|
-
type="password"
|
|
58
|
-
className={css.input}
|
|
59
|
-
value={settings.encryptPassword}
|
|
60
|
-
autoComplete="new-password"
|
|
61
|
-
placeholder={settings.encryptPasswordSaved ? t('mode.passwordPlaceholder') : undefined}
|
|
62
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => { onPatchSettings({ encryptPassword: e.target.value }) }}
|
|
63
|
-
// 失焦即落库(两个框一致才写)——用户不必手动保存,下次留空即沿用
|
|
64
|
-
onBlur={onPersistEncryptPassword}
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
<label className={css.field}>
|
|
68
|
-
<span className={css.fieldLabel}>{t('mode.passwordConfirm')}</span>
|
|
69
|
-
<input
|
|
70
|
-
type="password"
|
|
71
|
-
className={css.input}
|
|
72
|
-
value={settings.encryptPasswordConfirm}
|
|
73
|
-
autoComplete="new-password"
|
|
74
|
-
placeholder={settings.encryptPasswordSaved ? t('mode.passwordPlaceholder') : undefined}
|
|
75
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => { onPatchSettings({ encryptPasswordConfirm: e.target.value }) }}
|
|
76
|
-
onBlur={onPersistEncryptPassword}
|
|
77
|
-
/>
|
|
78
|
-
</label>
|
|
79
|
-
{settings.encryptPassword !== '' && settings.encryptPassword !== settings.encryptPasswordConfirm && (
|
|
80
|
-
<span className={css.formError}>{t('mode.passwordMismatch')}</span>
|
|
81
|
-
)}
|
|
82
|
-
{settings.encryptPassword === '' && !settings.encryptPasswordSaved && (
|
|
83
|
-
<span className={css.formError}>{t('mode.passwordRequired')}</span>
|
|
84
|
-
)}
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
<div className={css.controlRow}>
|
|
88
|
-
<Checkbox
|
|
89
|
-
checked={settings.includeSecrets}
|
|
90
|
-
onChange={onToggleIncludeSecrets}
|
|
91
|
-
label={<span className={css.categoryName}>{t('mode.includeSecrets')}</span>}
|
|
92
|
-
/>
|
|
93
|
-
<InfoHint text={t('mode.includeSecretsHint')} label={t('common.infoHint')} />
|
|
94
|
-
</div>
|
|
95
|
-
</Card>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* t42 物理拆分(从 SyncSettingsView.tsx 拆出的渲染段,同领域目录平铺;v2 第 5 步主文件改名 SyncPanel.tsx)。
|
|
3
|
-
*
|
|
4
|
-
* 约定:只接收「渲染所需的数据 + 回调」;React 状态、副作用与网络调用仍由
|
|
5
|
-
* SyncPanel 持有(单一状态源);可测纯逻辑在 src/ui/sync-settings-view.ts。
|
|
6
|
-
*
|
|
7
|
-
* P0-3:新增「逐会话勾选」视图 —— 同一个 Modal 内切换(**不嵌套第二个 Modal**:
|
|
8
|
-
* 双 overlay 会与宿主遮罩互相打架,且关闭语义会变得含糊)。会话单元清单来自
|
|
9
|
-
* /export-preview(与导出页同一份 listUnits 口径),选择模型复用 ContentPicker。
|
|
10
|
-
*/
|
|
11
|
-
import { useEffect, useState } from 'react'
|
|
12
|
-
import type { ChangeEvent } from 'react'
|
|
13
|
-
import type { TranslateNS } from '../client-types.ts'
|
|
14
|
-
import type { SectionId } from '../../schema/types.ts'
|
|
15
|
-
import { Badge, Banner, Button, Card, Checkbox } from '../common/ui.tsx'
|
|
16
|
-
import { Modal } from '../common/Modal.tsx'
|
|
17
|
-
import { ContentPicker } from '../common/ContentPicker.tsx'
|
|
18
|
-
import { Skeleton } from '../common/Skeleton.tsx'
|
|
19
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
20
|
-
import type { SelectionSection } from '../../ui/selection-model.ts'
|
|
21
|
-
import {
|
|
22
|
-
initialSessionPicks, pickedSessionIds, sessionPickerSelection,
|
|
23
|
-
} from '../../ui/sync-settings-view.ts'
|
|
24
|
-
import type { UiT } from '../../ui/i18n.ts'
|
|
25
|
-
import { DEFAULT_SYNC_SESSIONS_LIMIT, syncSectionGroups } from './sync-view.ts'
|
|
26
|
-
import type { SyncSectionOption } from './sync-view.ts'
|
|
27
|
-
import css from '../config-manager.module.css'
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 同步分区选择弹窗(Radix Modal,与通道配置弹窗同一体系):分组勾选 + 「最新 N 个会话」
|
|
31
|
-
* + 逐会话点名。分区一律由用户手动勾选(没有模式分段)。改动**即时生效并持久化**
|
|
32
|
-
* (与导出选择器一致的弹窗语义),因此底部只有「完成」—— 没有「取消」
|
|
33
|
-
* (取消会让用户以为改动被丢弃)。
|
|
34
|
-
*/
|
|
35
|
-
export function SyncSectionPickerDialog({ open, t, cmT, uiT, sectionName, catalog, sections, sessionsLimit, sessionsInclude, deletePlugins, sessionNode, sessionPending, sessionFailed, onToggleSection, onSessionsLimit, onSessionsInclude, onToggleDeletePlugins, onClose }: {
|
|
36
|
-
t: TranslateNS<'config-manager-sync'>
|
|
37
|
-
/** ui 命名空间的翻译器(UiT):分区描述与分组说明的**字典键**由它解析(英文界面零中文) */
|
|
38
|
-
uiT: UiT
|
|
39
|
-
/** config-manager 命名空间的翻译器:ContentPicker 的搜索/全选/合计文案来自它 */
|
|
40
|
-
cmT: TranslateNS<'config-manager'>
|
|
41
|
-
open: boolean
|
|
42
|
-
sectionName: (id: SectionId) => string
|
|
43
|
-
catalog: SyncSectionOption[]
|
|
44
|
-
sections: readonly SectionId[]
|
|
45
|
-
sessionsLimit: number
|
|
46
|
-
/** 显式点名的会话单元 id(非空时优先于 sessionsLimit) */
|
|
47
|
-
sessionsInclude: readonly string[]
|
|
48
|
-
/** 跟随远端删除插件(issue 132;只在 plugins 分区被勾选时可操作) */
|
|
49
|
-
deletePlugins: boolean
|
|
50
|
-
/** 会话单元清单(未取到 / 读取失败 → undefined) */
|
|
51
|
-
sessionNode: SelectionSection | undefined
|
|
52
|
-
sessionPending: boolean
|
|
53
|
-
sessionFailed: boolean
|
|
54
|
-
onToggleSection: (id: SectionId, checked: boolean) => void
|
|
55
|
-
onSessionsLimit: (value: number) => void
|
|
56
|
-
/** 点名结果(空数组 = 回到「最新 N 个」模式) */
|
|
57
|
-
onSessionsInclude: (ids: string[]) => void
|
|
58
|
-
onToggleDeletePlugins: (next: boolean) => void
|
|
59
|
-
onClose: () => void
|
|
60
|
-
}) {
|
|
61
|
-
/** 弹窗内的两个视图:分区目录 / 会话逐项勾选(同一 Modal,不嵌套第二个遮罩) */
|
|
62
|
-
const [view, setView] = useState<'sections' | 'sessions'>('sections')
|
|
63
|
-
// 关闭即复位:下次打开总是回到分区目录(用户的心智入口)
|
|
64
|
-
useEffect(() => { if (!open) setView('sections') }, [open])
|
|
65
|
-
|
|
66
|
-
const sessionIds = (sessionNode?.units ?? []).map((u) => u.id)
|
|
67
|
-
const sessionNodes: SelectionSection[] = sessionNode === undefined ? [] : [sessionNode]
|
|
68
|
-
const sessionValue = sessionPickerSelection(
|
|
69
|
-
sessionIds,
|
|
70
|
-
initialSessionPicks(sessionIds, sessionsInclude, sessionsLimit),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
if (view === 'sessions') {
|
|
74
|
-
return (
|
|
75
|
-
<Modal open={open} onClose={onClose} title={t('mode.sessionsPickTitle')} wide>
|
|
76
|
-
<Modal.Header
|
|
77
|
-
title={t('mode.sessionsPickTitle')}
|
|
78
|
-
closeLabel={t('common.close')}
|
|
79
|
-
onClose={onClose}
|
|
80
|
-
// 视图级说明:贴在标题右边(Modal.Header trailing),不单独成行
|
|
81
|
-
trailing={<InfoHint text={t('mode.sessionsPickHint')} label={t('common.infoHint')} />}
|
|
82
|
-
/>
|
|
83
|
-
<Modal.Body scroll style={{ maxHeight: '66vh' }}>
|
|
84
|
-
{sessionFailed && <span className={css.hint}>{cmT('picker.unitsUnavailable')}</span>}
|
|
85
|
-
{!sessionFailed && sessionNodes.length === 0 && sessionPending && (
|
|
86
|
-
<Skeleton count={4} label={t('common.loading')} />
|
|
87
|
-
)}
|
|
88
|
-
{!sessionFailed && sessionNodes.length > 0 && (
|
|
89
|
-
<ContentPicker
|
|
90
|
-
nodes={sessionNodes}
|
|
91
|
-
value={sessionValue}
|
|
92
|
-
onChange={(next) => { onSessionsInclude(pickedSessionIds(next, sessionIds)) }}
|
|
93
|
-
t={cmT}
|
|
94
|
-
sectionLabel={sectionName}
|
|
95
|
-
mode="export"
|
|
96
|
-
busy={sessionPending}
|
|
97
|
-
/>
|
|
98
|
-
)}
|
|
99
|
-
</Modal.Body>
|
|
100
|
-
<Modal.Footer>
|
|
101
|
-
<Button onClick={() => { setView('sections') }}>{t('mode.pickerBack')}</Button>
|
|
102
|
-
<Button variant="primary" onClick={onClose}>{t('mode.pickerDone')}</Button>
|
|
103
|
-
</Modal.Footer>
|
|
104
|
-
</Modal>
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<Modal open={open} onClose={onClose} title={t('mode.pickerTitle')} wide>
|
|
110
|
-
<Modal.Header
|
|
111
|
-
title={t('mode.pickerTitle')}
|
|
112
|
-
closeLabel={t('common.close')}
|
|
113
|
-
onClose={onClose}
|
|
114
|
-
// 弹窗级说明(哪些分区会被带走):贴在标题右边,不单独成行
|
|
115
|
-
trailing={<InfoHint text={t('mode.sectionsHint')} label={t('common.infoHint')} />}
|
|
116
|
-
/>
|
|
117
|
-
<Modal.Body scroll style={{ maxHeight: '66vh' }}>
|
|
118
|
-
{catalog.length === 0 ? (
|
|
119
|
-
<Skeleton count={4} label={t('common.loading')} />
|
|
120
|
-
) : (
|
|
121
|
-
/* 分组勾选目录:与「导出备份·自定义模式」同构(分组 Card + 名称/描述/徽章),
|
|
122
|
-
分区名走 section-labels 单一映射 —— 与导出选择器显示**同一个中文名**。 */
|
|
123
|
-
<div className={css.groupList}>
|
|
124
|
-
{syncSectionGroups(catalog, uiT).map((g) => (
|
|
125
|
-
<Card key={g.group} className={css.groupCard}>
|
|
126
|
-
<div className={css.groupHeader}>
|
|
127
|
-
<span className={css.groupLabel}>{g.label}</span>
|
|
128
|
-
</div>
|
|
129
|
-
<div className={css.groupItems}>
|
|
130
|
-
{g.items.map((s) => (
|
|
131
|
-
<div key={s.id} className={css.sectionOptionRow}>
|
|
132
|
-
<Checkbox
|
|
133
|
-
checked={sections.includes(s.id)}
|
|
134
|
-
onChange={(checked) => { onToggleSection(s.id, checked) }}
|
|
135
|
-
label={
|
|
136
|
-
<span className={css.categoryItem}>
|
|
137
|
-
{/* 分区显示名只经 sectionLabeler(禁止在本文件另建一套名字) */}
|
|
138
|
-
<span className={css.categoryName}>{sectionName(s.id)}</span>
|
|
139
|
-
<span className={css.categoryDesc}>{s.description}</span>
|
|
140
|
-
{s.portability === 'portable' && <Badge kind="info">{t('mode.sectionPortable')}</Badge>}
|
|
141
|
-
{s.portability === 'platformSpecific' && (
|
|
142
|
-
<Badge kind="warn">{t('mode.sectionPlatformSpecific')}</Badge>
|
|
143
|
-
)}
|
|
144
|
-
{s.portability === 'deviceSpecific' && (
|
|
145
|
-
<Badge kind="warn">{t('mode.sectionDeviceSpecific')}</Badge>
|
|
146
|
-
)}
|
|
147
|
-
{/* issue #78:MCP 的机器相关内容(绝对路径 command / cwd、缺运行时)走 ⓘ,
|
|
148
|
-
与「机制说明进 InfoHint」的同一条纪律(见 info-hint-guard)。 */}
|
|
149
|
-
{s.id === 'mcp' && <InfoHint text={t('mode.mcpHint')} label={t('common.infoHint')} />}
|
|
150
|
-
{s.defaultIncluded && <Badge kind="ok">{t('mode.sectionRecommended')}</Badge>}
|
|
151
|
-
</span>
|
|
152
|
-
}
|
|
153
|
-
/>
|
|
154
|
-
{/* 历史会话专属参数:数量上限 + 逐会话点名。必须放在 Checkbox **之外** ——
|
|
155
|
-
Checkbox 内部是 label 元素,把输入控件放进去会让点输入框也切换勾选。 */}
|
|
156
|
-
{s.id === 'sessions' && sections.includes('sessions') && (
|
|
157
|
-
<div className={css.field}>
|
|
158
|
-
<div className={css.field}>
|
|
159
|
-
<span className={css.fieldLabel}>{t('mode.sessionsLimit')} <InfoHint text={t('mode.sessionsLimitHint')} label={t('common.infoHint')} /></span>
|
|
160
|
-
<input aria-label={t('mode.sessionsLimit')}
|
|
161
|
-
type="number"
|
|
162
|
-
min={0}
|
|
163
|
-
max={10000}
|
|
164
|
-
className={css.input}
|
|
165
|
-
value={String(sessionsLimit)}
|
|
166
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
167
|
-
onSessionsLimit(e.target.value === '' ? DEFAULT_SYNC_SESSIONS_LIMIT : Number(e.target.value))
|
|
168
|
-
}}
|
|
169
|
-
/>
|
|
170
|
-
</div>
|
|
171
|
-
<div className={css.actionRowTop}>
|
|
172
|
-
<Button size="sm" onClick={() => { setView('sessions') }}>{t('mode.sessionsPick')}</Button>
|
|
173
|
-
{sessionsInclude.length > 0 && (
|
|
174
|
-
<Badge kind="info">{t('mode.sessionsPickCount', { n: String(sessionsInclude.length) })}</Badge>
|
|
175
|
-
)}
|
|
176
|
-
{sessionsInclude.length > 0 && (
|
|
177
|
-
<Button size="sm" onClick={() => { onSessionsInclude([]) }}>
|
|
178
|
-
{t('mode.sessionsPickReset')}
|
|
179
|
-
</Button>
|
|
180
|
-
)}
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
)}
|
|
184
|
-
{/* issue 132:插件专属的「跟随远端删除」。放在 Checkbox **之外**(同 sessions
|
|
185
|
-
参数的理由:Checkbox 内部是 label,嵌进去点开关会连带切换分区勾选)。
|
|
186
|
-
只在 plugins 已被勾选时出现 —— 没勾这个分区,这条开关没有任何作用对象。 */}
|
|
187
|
-
{s.id === 'plugins' && sections.includes('plugins') && (
|
|
188
|
-
<div className={css.controlRow}>
|
|
189
|
-
<Checkbox
|
|
190
|
-
checked={deletePlugins}
|
|
191
|
-
onChange={onToggleDeletePlugins}
|
|
192
|
-
label={<span className={css.categoryName}>{t('mode.deletePlugins')}</span>}
|
|
193
|
-
/>
|
|
194
|
-
<InfoHint text={t('mode.deletePluginsHint')} label={t('common.infoHint')} />
|
|
195
|
-
</div>
|
|
196
|
-
)}
|
|
197
|
-
</div>
|
|
198
|
-
))}
|
|
199
|
-
</div>
|
|
200
|
-
</Card>
|
|
201
|
-
))}
|
|
202
|
-
</div>
|
|
203
|
-
)}
|
|
204
|
-
{sections.length === 0 && <Banner kind="warn">{t('mode.atLeastOne')}</Banner>}
|
|
205
|
-
</Modal.Body>
|
|
206
|
-
<Modal.Footer>
|
|
207
|
-
{/* 2026-11-01 用户要求:删掉「改动即时生效并保存(关闭弹窗即完成)」那颗 ⓘ ——
|
|
208
|
-
它在解释一件用户无从选择的事(勾了就走,没有保存按钮),占位置不改决定。 */}
|
|
209
|
-
<Button variant="primary" onClick={onClose}>{t('mode.pickerDone')}</Button>
|
|
210
|
-
</Modal.Footer>
|
|
211
|
-
</Modal>
|
|
212
|
-
)
|
|
213
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* path-mapping 测试(m6-ui,规范 §12):
|
|
3
|
-
* 单项映射 + 批量前缀映射、preview 替换、toPathMappings 只含已解析、isComplete。
|
|
4
|
-
*/
|
|
5
|
-
import test from 'node:test';
|
|
6
|
-
import assert from 'node:assert/strict';
|
|
7
|
-
import { PathMappingEditor } from './path-mapping.ts';
|
|
8
|
-
import type { PathIssue } from '../core/types.ts';
|
|
9
|
-
|
|
10
|
-
const ISSUES: PathIssue[] = [
|
|
11
|
-
{ kind: 'missing', value: 'C:\\Users\\alice\\projects\\ops' },
|
|
12
|
-
{ kind: 'platformMismatch', value: 'C:\\Users\\alice\\projects\\dev' },
|
|
13
|
-
{ kind: 'missing', value: '/Users/alice/work' },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
test('path-mapping: 从 issues 初始化草稿,全部未解析', () => {
|
|
17
|
-
const ed = new PathMappingEditor({ issues: ISSUES });
|
|
18
|
-
assert.equal(ed.all.length, 3);
|
|
19
|
-
assert.equal(ed.unresolved.length, 3);
|
|
20
|
-
assert.equal(ed.isComplete, false);
|
|
21
|
-
assert.equal(ed.toPathMappings().length, 0);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('path-mapping: 单项映射后 toPathMappings 只含已解析', () => {
|
|
25
|
-
const ed = new PathMappingEditor({ issues: ISSUES });
|
|
26
|
-
ed.setMapping('C:\\Users\\alice\\projects\\ops', 'D:\\data\\ops');
|
|
27
|
-
const mappings = ed.toPathMappings();
|
|
28
|
-
assert.equal(mappings.length, 1);
|
|
29
|
-
assert.equal(mappings[0]!.oldPrefix, 'C:\\Users\\alice\\projects\\ops');
|
|
30
|
-
assert.equal(mappings[0]!.newPrefix, 'D:\\data\\ops');
|
|
31
|
-
assert.deepEqual(mappings[0]!.appliesTo, []);
|
|
32
|
-
assert.equal(ed.unresolved.length, 2);
|
|
33
|
-
assert.equal(ed.isComplete, false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('path-mapping: 批量前缀映射聚合到单条 draft', () => {
|
|
37
|
-
const ed = new PathMappingEditor({ issues: ISSUES });
|
|
38
|
-
ed.setMapping('C:\\Users\\alice\\', 'C:\\Users\\bob\\');
|
|
39
|
-
const mappings = ed.toPathMappings();
|
|
40
|
-
assert.equal(mappings.length, 1);
|
|
41
|
-
assert.equal(mappings[0]!.oldPrefix, 'C:\\Users\\alice\\');
|
|
42
|
-
// 三条 issue 中两条以该前缀开头 → 全部视为已解决;/Users/alice/work 未解决
|
|
43
|
-
assert.equal(ed.unresolved.length, 1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('path-mapping: preview 用 applyPrefixMappings 替换', () => {
|
|
47
|
-
const ed = new PathMappingEditor({ issues: ISSUES });
|
|
48
|
-
ed.setMapping('C:\\Users\\alice\\', 'C:\\Users\\bob\\');
|
|
49
|
-
assert.equal(ed.preview('C:\\Users\\alice\\projects\\ops'), 'C:/Users/bob/projects/ops');
|
|
50
|
-
assert.equal(ed.preview('/Users/alice/work'), '/Users/alice/work');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('path-mapping: 全部解决后 isComplete 为 true', () => {
|
|
54
|
-
const ed = new PathMappingEditor({ issues: ISSUES });
|
|
55
|
-
ed.setMapping('C:\\Users\\alice\\', 'C:\\Users\\bob\\');
|
|
56
|
-
ed.setMapping('/Users/alice/work', '/home/bob/work');
|
|
57
|
-
assert.equal(ed.isComplete, true);
|
|
58
|
-
assert.equal(ed.toPathMappings().length, 2);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('path-mapping: existing 预置映射可直接复用(oldPrefix 聚合)', () => {
|
|
62
|
-
const ed = new PathMappingEditor({
|
|
63
|
-
existing: [{ oldPrefix: 'C:\\Users\\alice\\', newPrefix: 'C:\\Users\\bob\\', appliesTo: ['workspaces', 'mcp'] }],
|
|
64
|
-
});
|
|
65
|
-
assert.equal(ed.resolved.length, 1);
|
|
66
|
-
assert.deepEqual(ed.resolved[0]!.appliesTo, ['workspaces', 'mcp']);
|
|
67
|
-
});
|
package/src/ui/path-mapping.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路径映射编辑器(规范 §12,m6-ui)。
|
|
3
|
-
*
|
|
4
|
-
* 两种形态(§12 批量映射优先):
|
|
5
|
-
* - 单项映射:某条具体 PathIssue(如 workspace 绝对路径)→ 新路径;
|
|
6
|
-
* - 批量前缀映射:oldPrefix → newPrefix,一次替换全部相关路径。
|
|
7
|
-
*
|
|
8
|
-
* 输出 core PathMapping[]:newPrefix 非空的映射才进入执行计划
|
|
9
|
-
* (core mergePathMappings 只保留已解析映射;未解析项保留在 plan.items 供 UI 提示)。
|
|
10
|
-
* 应用范围 appliesTo 缺省 [](全部相关分区),与 core applyMappingsToSections 语义一致。
|
|
11
|
-
*/
|
|
12
|
-
import type { PathIssue, PathMapping } from '../core/types.ts';
|
|
13
|
-
import { applyPrefixMappings } from '../utils/paths.ts';
|
|
14
|
-
import type { PathMappingAppliesTo, PathMappingDraft } from './types.ts';
|
|
15
|
-
|
|
16
|
-
export interface PathMappingEditorOptions {
|
|
17
|
-
/** 从分析结果得到的路径问题 */
|
|
18
|
-
issues?: PathIssue[];
|
|
19
|
-
/** 预置映射(如上次导入可复用的映射) */
|
|
20
|
-
existing?: PathMapping[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class PathMappingEditor {
|
|
24
|
-
private readonly issues: PathIssue[];
|
|
25
|
-
private drafts = new Map<string, PathMappingDraft>();
|
|
26
|
-
|
|
27
|
-
constructor(opts: PathMappingEditorOptions = {}) {
|
|
28
|
-
this.issues = opts.issues ?? [];
|
|
29
|
-
for (const issue of this.issues) {
|
|
30
|
-
this.drafts.set(issue.value, {
|
|
31
|
-
oldPrefix: issue.value,
|
|
32
|
-
newPrefix: issue.mappedTo ?? '',
|
|
33
|
-
issue,
|
|
34
|
-
appliesTo: [],
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// 批量映射按 oldPrefix 聚合(一个 oldPrefix 一条 draft)
|
|
38
|
-
for (const m of opts.existing ?? []) {
|
|
39
|
-
const prev = this.drafts.get(m.oldPrefix);
|
|
40
|
-
this.drafts.set(m.oldPrefix, {
|
|
41
|
-
oldPrefix: m.oldPrefix,
|
|
42
|
-
newPrefix: m.newPrefix,
|
|
43
|
-
appliesTo: [...m.appliesTo] as PathMappingAppliesTo[],
|
|
44
|
-
});
|
|
45
|
-
void prev;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** 全部草稿(含未解析) */
|
|
50
|
-
get all(): PathMappingDraft[] {
|
|
51
|
-
return [...this.drafts.values()];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** 已解析(newPrefix 非空)的草稿 */
|
|
55
|
-
get resolved(): PathMappingDraft[] {
|
|
56
|
-
return this.all.filter((d) => d.newPrefix !== '');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 未解析的问题(UI 需提示用户选择文件夹;按「是否被已解析映射覆盖」判断,批量前缀映射一次覆盖多条) */
|
|
60
|
-
get unresolved(): PathIssue[] {
|
|
61
|
-
const mappings = this.toPathMappings();
|
|
62
|
-
return (this.issues ?? []).filter((issue) => {
|
|
63
|
-
const mapped = applyPrefixMappings(issue.value, mappings);
|
|
64
|
-
return mapped === issue.value;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** 单项/批量设置映射(oldPrefix 已存在则更新;否则新建批量映射) */
|
|
69
|
-
setMapping(oldPrefix: string, newPrefix: string, appliesTo: PathMappingAppliesTo[] = []): void {
|
|
70
|
-
const existing = this.drafts.get(oldPrefix);
|
|
71
|
-
this.drafts.set(oldPrefix, {
|
|
72
|
-
oldPrefix,
|
|
73
|
-
newPrefix,
|
|
74
|
-
appliesTo,
|
|
75
|
-
issue: existing?.issue,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** 对某个具体值应用当前映射,返回替换结果(预览用;无映射则原样返回) */
|
|
80
|
-
preview(value: string): string {
|
|
81
|
-
const resolved = this.resolved.map((d) => ({
|
|
82
|
-
oldPrefix: d.oldPrefix,
|
|
83
|
-
newPrefix: d.newPrefix,
|
|
84
|
-
appliesTo: d.appliesTo,
|
|
85
|
-
}));
|
|
86
|
-
const mapped = applyPrefixMappings(value, resolved);
|
|
87
|
-
return typeof mapped === 'string' ? mapped : value;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** 未解析项是否可进入执行(false = 有路径问题未解决) */
|
|
91
|
-
get isComplete(): boolean {
|
|
92
|
-
return this.unresolved.length === 0;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** 输出 core PathMapping[](仅已解析项) */
|
|
96
|
-
toPathMappings(): PathMapping[] {
|
|
97
|
-
return this.resolved.map((d) => ({
|
|
98
|
-
oldPrefix: d.oldPrefix,
|
|
99
|
-
newPrefix: d.newPrefix,
|
|
100
|
-
appliesTo: d.appliesTo as PathMapping['appliesTo'],
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
}
|