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
package/src/cli/web/routes.ts
CHANGED
|
@@ -156,40 +156,100 @@ export function buildConsoleRoutes(context: ConsoleContext): WebRoute[] {
|
|
|
156
156
|
|
|
157
157
|
consoleEndpoint({ path: '/', methods: ['GET'] }, async (_req, res) => {
|
|
158
158
|
const status = await readRescueStatus(paths)
|
|
159
|
-
const
|
|
159
|
+
const hasBlockedSafe = status.safeMode.some((r) => r.state === 'blocked')
|
|
160
|
+
const hasStaleLock = status.lock.present && status.lock.state === 'STALE_LOCK_DETECTED'
|
|
161
|
+
const hasEncrypted = status.backups.some((b) => b.containerType === 'encrypted')
|
|
162
|
+
const scored: Array<{ score: number; card: ActionCard }> = [
|
|
160
163
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
score: hasStaleLock ? 100 : (status.lock.present ? 60 : 20),
|
|
165
|
+
card: {
|
|
166
|
+
id: 'recover-lock',
|
|
167
|
+
title: '环境锁 / 回收残留锁',
|
|
168
|
+
description: '查看锁状态;仅当持有进程被确证不存在时才允许回收(活锁一律拒绝)。',
|
|
169
|
+
when: '启动或写操作报环境锁冲突、怀疑上次异常退出残留锁文件时先点它。',
|
|
170
|
+
href: '/lock',
|
|
171
|
+
disabled: false,
|
|
172
|
+
},
|
|
166
173
|
},
|
|
167
174
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
score: hasBlockedSafe ? 95 : (status.snapshots.length > 0 ? 75 : 15),
|
|
176
|
+
card: {
|
|
177
|
+
id: 'restore',
|
|
178
|
+
title: '恢复快照',
|
|
179
|
+
description: '先看逐项恢复计划(零写入),确认后覆盖回滚到某个导入前快照。',
|
|
180
|
+
when: '刚导入配置或变更设置后 DSH 异常,需要按计划回滚到导入前安全快照时点它。',
|
|
181
|
+
href: '/restore',
|
|
182
|
+
disabled: false,
|
|
183
|
+
},
|
|
173
184
|
},
|
|
174
185
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
186
|
+
score: 85,
|
|
187
|
+
card: {
|
|
188
|
+
id: 'session-repair',
|
|
189
|
+
title: '会话布局修复',
|
|
190
|
+
description: '位置与 header cwd 不一致的会话按计划归位(前置:DSH 已停、无 SAFE MODE、无残留锁)。',
|
|
191
|
+
when: '会话打不开、报 cwd/路径不一致,或存在重放重复行需要零损失清理时点它。',
|
|
192
|
+
href: '/sessions',
|
|
193
|
+
disabled: false,
|
|
194
|
+
},
|
|
180
195
|
},
|
|
181
196
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
197
|
+
score: status.instances.length > 0 ? 70 : 65,
|
|
198
|
+
card: {
|
|
199
|
+
id: 'profiles',
|
|
200
|
+
title: '档案与实例',
|
|
201
|
+
description: '查看本机档案与在跑的实例,并把某个档案作为独立实例启动(DSH 起不来时最有用的一条路)。',
|
|
202
|
+
when: '想另起一个干净 profile 应急继续干活,或需要停掉阻塞写入的在跑实例时点它。',
|
|
203
|
+
href: '/profiles',
|
|
204
|
+
disabled: false,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
score: 55,
|
|
209
|
+
card: {
|
|
210
|
+
id: 'disk-cleanup',
|
|
211
|
+
title: '清理磁盘',
|
|
212
|
+
description: '可重建缓存与过期导出产物;导入前快照与同步数据永不在候选集内。',
|
|
213
|
+
when: '磁盘空间告急、怀疑缓存损坏,或要按保留期回收旧导出产物时点它。',
|
|
214
|
+
href: '/disk',
|
|
215
|
+
disabled: false,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
score: 45,
|
|
220
|
+
card: {
|
|
221
|
+
id: 'export',
|
|
222
|
+
title: '离线导出',
|
|
223
|
+
description: '把离线可读的文件类分区导出成与 GUI 同结构的 ZIP(落盘后自检)。',
|
|
224
|
+
when: '准备重装、迁移机器或大改配置前,需要先把当前可读文件备份出来时点它。',
|
|
225
|
+
href: '/export',
|
|
226
|
+
disabled: false,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
score: hasEncrypted ? 40 : 10,
|
|
231
|
+
card: {
|
|
232
|
+
id: 'unlock',
|
|
233
|
+
title: '解锁加密备份',
|
|
234
|
+
description: '用密码在内存里解出明文并查看条目清单;不写盘、不回传内容。',
|
|
235
|
+
when: '手里有加密容器备份,需用密码在内存里核对包含哪些配置条目时点它。',
|
|
236
|
+
href: '/unlock',
|
|
237
|
+
disabled: false,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
score: 5,
|
|
242
|
+
card: {
|
|
243
|
+
id: 'reinstall',
|
|
244
|
+
title: '重装 DSH',
|
|
245
|
+
description: '最危险的动作:卸载并重装全局 DSH。需要终端里打印的 6 位确认码。',
|
|
246
|
+
when: '前几项排查都无效、怀疑全局 DSH 程序损坏须卸载重装时点它(需终端确认码)。',
|
|
247
|
+
href: '/reinstall',
|
|
248
|
+
disabled: false,
|
|
249
|
+
},
|
|
187
250
|
},
|
|
188
|
-
{ id: 'restore', title: '恢复快照', description: '先看逐项恢复计划(零写入),确认后覆盖回滚到某个导入前快照。', href: '/restore', disabled: false },
|
|
189
|
-
{ id: 'export', title: '离线导出', description: '把离线可读的文件类分区导出成与 GUI 同结构的 ZIP(落盘后自检)。', href: '/export', disabled: false },
|
|
190
|
-
{ id: 'unlock', title: '解锁加密备份', description: '用密码在内存里解出明文并查看条目清单;不写盘、不回传内容。', href: '/unlock', disabled: false },
|
|
191
|
-
{ id: 'reinstall', title: '重装 DSH', description: '最危险的动作:卸载并重装全局 DSH。需要终端里打印的 6 位确认码。', href: '/reinstall', disabled: false },
|
|
192
251
|
]
|
|
252
|
+
const actions: ActionCard[] = scored.sort((a, b) => b.score - a.score).map((item) => item.card)
|
|
193
253
|
writeHtml(res, 200, renderHomePage({ status, version, actions }))
|
|
194
254
|
}),
|
|
195
255
|
|
package/src/cli/web/web.test.ts
CHANGED
|
@@ -486,6 +486,33 @@ test('V-F1 写门:存在残留锁时写动作被拒(文档与防线一致)
|
|
|
486
486
|
})
|
|
487
487
|
})
|
|
488
488
|
|
|
489
|
+
test('V-F1c 写门:就地修复(POST /sessions/inline-repair)同受环境锁拦截(审计 P11-4)', async () => {
|
|
490
|
+
await withConsole(async (handle, paths) => {
|
|
491
|
+
const { cookie } = await bootstrap(handle)
|
|
492
|
+
// 错位会话 → /sessions 页渲染出确认表单(动作 token 本次控制台通用,从那里取)
|
|
493
|
+
const { encodeZstdFrame } = await import('../../utils/zstd-frame.ts')
|
|
494
|
+
const dir = path.join(paths.homeDir, 'sessions', '--D-Ghost-proj--', 'session-inline')
|
|
495
|
+
await fs.mkdir(dir, { recursive: true })
|
|
496
|
+
await fs.writeFile(path.join(dir, 'session.v3.jsonl.zstd'), Buffer.concat([
|
|
497
|
+
encodeZstdFrame(Buffer.from(JSON.stringify({ version: 3, id: 'session-inline', cwd: 'D:/Real/proj' }) + '\n', 'utf8')),
|
|
498
|
+
encodeZstdFrame(Buffer.from('{"seq":1}\n', 'utf8')),
|
|
499
|
+
]))
|
|
500
|
+
// stale 锁(ownership 指向不存在的 pid):就地修复此前不传 locksDir ⇒ 照样改写 .zstd 字节
|
|
501
|
+
await fs.mkdir(paths.locksDir, { recursive: true })
|
|
502
|
+
await fs.writeFile(path.join(paths.locksDir, 'environment.lock'), JSON.stringify({
|
|
503
|
+
schemaVersion: 1, op: 'test-op', target: 'x', lockVersion: '0.1.0',
|
|
504
|
+
owner: { instanceId: 'dead-instance', instanceStartedAt: Date.now() - 600_000, pid: 999_999_999, hostname: 'h' },
|
|
505
|
+
createdAt: Date.now() - 600_000,
|
|
506
|
+
}))
|
|
507
|
+
const html = await getPage(handle, cookie!, '/sessions')
|
|
508
|
+
const token = actionTokenOf(html)
|
|
509
|
+
const res = await postForm(handle, cookie!, '/sessions/inline-repair', { 'unit:ghost/session-inline': 'on', token })
|
|
510
|
+
assert.equal(res.status, 409, res.body.slice(0, 300))
|
|
511
|
+
assert.match(res.body, /就地修复未执行(写入门拒绝)/, '被门拒绝(而不是进到逐条执行后的「有未完成项」)')
|
|
512
|
+
assert.match(res.body, /环境锁/)
|
|
513
|
+
})
|
|
514
|
+
})
|
|
515
|
+
|
|
489
516
|
test('V-F2 读不到 ≠ 没有:快照/导出目录不可读时首页给出横幅,而不是「没有」', async () => {
|
|
490
517
|
await withConsole(async (handle, paths) => {
|
|
491
518
|
const { cookie } = await bootstrap(handle)
|
|
@@ -1444,3 +1471,41 @@ test('cli-F7 //x 形态的请求目标不得被解析成首页', async () => {
|
|
|
1444
1471
|
})
|
|
1445
1472
|
})
|
|
1446
1473
|
|
|
1474
|
+
test('R4-01 页面结构重排、圆角 token、低边框与动效微反馈契约', async () => {
|
|
1475
|
+
await withConsole(async (handle) => {
|
|
1476
|
+
const { cookie } = await bootstrap(handle)
|
|
1477
|
+
const home = await getPage(handle, cookie!, '/')
|
|
1478
|
+
const restore = await getPage(handle, cookie!, '/restore')
|
|
1479
|
+
const style = /<style>([\s\S]*?)<\/style>/.exec(home)?.[1] ?? ''
|
|
1480
|
+
const darkBlock = /:root\[data-theme="dark"\]\{([^}]*)\}/.exec(style)?.[1] ?? ''
|
|
1481
|
+
|
|
1482
|
+
// 1) 圆角 token 只定义在亮色 :root,暗色块不得重复
|
|
1483
|
+
assert.match(style, /--radius:8px/)
|
|
1484
|
+
assert.match(style, /--radius-sm:6px/)
|
|
1485
|
+
assert.doesNotMatch(darkBlock, /--radius/)
|
|
1486
|
+
|
|
1487
|
+
// 2) 分隔边框收敛(显著低于改造前 29 处:仅页头底线与表行底线作纯分隔)
|
|
1488
|
+
const activeBorders = [...style.matchAll(/\b(?:border|border-top|border-bottom|border-left|border-right):([^;'}]+)/g)]
|
|
1489
|
+
.filter((m) => !m[1]!.startsWith('0') && m[1] !== 'none')
|
|
1490
|
+
assert.ok(activeBorders.length <= 10, '实际有效 border 声明应 ≤ 10,实际=' + String(activeBorders.length))
|
|
1491
|
+
|
|
1492
|
+
// 3) 处境分组导航(3 个顶层组 ≤ 5)且首页首屏只答「DSH 现在能不能起」+ <=3 张带触发条件的建议卡
|
|
1493
|
+
const navHtml = /<nav class="sitNav"[\s\S]*?<\/nav>/.exec(home)?.[0] ?? ''
|
|
1494
|
+
const topGroups = (navHtml.match(/class="navGroup"|href="\/"/g) ?? []).length
|
|
1495
|
+
assert.equal(topGroups, 3, '顶层导航收拢为 状态/救援动作/检查 三组')
|
|
1496
|
+
assert.match(home, /DSH 现在可以启动|DSH 正在运行|DSH 写动作受阻|DSH 可能被环境锁卡住|DSH 存在待排查状态/)
|
|
1497
|
+
const homeActionCards = (home.match(/class="actionCard"/g) ?? []).length
|
|
1498
|
+
assert.ok(homeActionCards >= 1 && homeActionCards <= 3, '首页首屏建议卡应 1–3 张,实际=' + String(homeActionCards))
|
|
1499
|
+
assert.equal((home.match(/class="btnPrimary"/g) ?? []).length, 1, '首页首屏同屏仅允许 1 个主色按钮')
|
|
1500
|
+
assert.match(home, /什么情况下点它/)
|
|
1501
|
+
|
|
1502
|
+
// 4) 能力边界与全部 8 入口进第二屏折叠区,写操作页带三段步进条,脚本含 spinner 与复制微反馈
|
|
1503
|
+
assert.match(home, /data-dcm-persist="home-capability"/)
|
|
1504
|
+
assert.match(home, /data-dcm-persist="home-all-actions"/)
|
|
1505
|
+
assert.match(restore, /aria-label="操作三阶段"/)
|
|
1506
|
+
const { CONSOLE_SCRIPT } = await import('./client-script.ts')
|
|
1507
|
+
assert.match(CONSOLE_SCRIPT, /btnSpinner/)
|
|
1508
|
+
assert.match(CONSOLE_SCRIPT, /已复制 ✓/)
|
|
1509
|
+
})
|
|
1510
|
+
})
|
|
1511
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 写动作的三道门(SAFE MODE → 残留环境锁 → DSH 未运行),CLI 与救急台网页共用同一实现。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独成文件:门的判据必须唯一(网页不许自己重写判定),而它依赖的只读事实在
|
|
5
|
+
* control-state.ts;从 1600 行的 actions.ts 里拆出来后,调用点仍经 actions.ts 的 re-export 取用。
|
|
6
|
+
*/
|
|
7
|
+
import fssync from 'node:fs'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
|
|
10
|
+
import { OWNERSHIP_FILE } from '../utils/env-lock.ts'
|
|
11
|
+
import { readLockState, readRunningInstances, readSafeMode } from './control-state.ts'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export type WriteRefusalCode =
|
|
15
|
+
| 'safe-mode'
|
|
16
|
+
| 'stale-lock'
|
|
17
|
+
| 'dsh-running'
|
|
18
|
+
| 'nothing-to-do'
|
|
19
|
+
| 'io-error'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* SAFE MODE 拒因码的**单点常量**:`src/cli/index.ts` 的源码守卫(P0-11-07)禁止
|
|
23
|
+
* CLI 自带 `'safe-mode'` 字面量,判据必须复用本常量(否则改一处漏一处)。
|
|
24
|
+
*/
|
|
25
|
+
export const SAFE_MODE_REFUSAL_CODE: WriteRefusalCode = 'safe-mode'
|
|
26
|
+
|
|
27
|
+
export interface WriteGateRefusal {
|
|
28
|
+
ok: false
|
|
29
|
+
code: WriteRefusalCode
|
|
30
|
+
/** 用户可读原因(页面直接展示) */
|
|
31
|
+
reason: string
|
|
32
|
+
/**
|
|
33
|
+
* 拒因的结构化明细(页面据此给出「怎么解除」的可操作指引,而不是只丢一句 reason)。
|
|
34
|
+
*
|
|
35
|
+
* 为什么要有:`dsh-running` 是最常被撞到的一道门,光给「请先关闭 DSH」用户会问
|
|
36
|
+
* 「关哪个、怎么确认关掉了」。这里把**是谁在跑**(心跳台账里的 profile/pid/端口)
|
|
37
|
+
* 如实带出来 —— 只读事实,不猜、不代关进程。
|
|
38
|
+
*/
|
|
39
|
+
detail?: {
|
|
40
|
+
kind: 'dsh-running' | 'stale-lock' | 'safe-mode'
|
|
41
|
+
/** 正在运行的实例(心跳合并视图:本插件启动的 + 手动启动的) */
|
|
42
|
+
instances?: Array<{ name: string; pid: number; port: number | null }>
|
|
43
|
+
/** 环境锁状态(kind = 'stale-lock') */
|
|
44
|
+
lock?: { state: string; locksDir: string }
|
|
45
|
+
/** SAFE MODE 标记文件(kind = 'safe-mode') */
|
|
46
|
+
markers?: string[]
|
|
47
|
+
/** 与 CLI 逐字同源的等价命令(可复制去终端跑) */
|
|
48
|
+
commands: string[]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type WriteGateOutcome = { ok: true } | WriteGateRefusal
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 从控制面候选根派生**环境锁目录**(`<root>/locks`)。
|
|
56
|
+
*
|
|
57
|
+
* 为什么由根派生而不是让每个调用点多传一个参数:`checkWriteGates` 的 `locksDir` 是**可选**的,
|
|
58
|
+
* 「少传一个参数」就静默退化成「不查环境锁」。审计 P11-4 正是这么漏掉的:就地修复(repairSessionLogInline)
|
|
59
|
+
* 不传 locksDir,残留/被持有的环境锁存在时照样改写 `.zstd` 会话字节。
|
|
60
|
+
* 派生顺序与 `resolveControlRoots` 同源:第一个真实持有 `locks/environment.lock` 的候选根;
|
|
61
|
+
* 都没有就退回首个候选的 `locks`(读不到即视为无锁,判据仍只由 readLockState 给)。
|
|
62
|
+
*/
|
|
63
|
+
export function locksDirFromControlRoots(controlRoots: readonly string[]): string | undefined {
|
|
64
|
+
const first = controlRoots[0]
|
|
65
|
+
if (first === undefined) return undefined
|
|
66
|
+
for (const root of controlRoots) {
|
|
67
|
+
const candidate = path.join(root, 'locks')
|
|
68
|
+
if (fssync.existsSync(path.join(candidate, OWNERSHIP_FILE))) return candidate
|
|
69
|
+
}
|
|
70
|
+
return path.join(first, 'locks')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 写动作的前置门(与 CLI `sessions repair --fix` 同一判据)。
|
|
75
|
+
*
|
|
76
|
+
* `needsDshStopped`:**改写/搬动会话字节**的动作(会话布局归位 repairSessions、字节级就地修复
|
|
77
|
+
* repairSessionLogInline)与**快照恢复**(runSnapshotRestore 会覆盖/删除 `$DSH_HOME` 下正在使用的文件)
|
|
78
|
+
* 都要「DSH 已停」这一条;磁盘清理不需要(只碰可重建缓存)。
|
|
79
|
+
*/
|
|
80
|
+
export async function checkWriteGates(
|
|
81
|
+
controlRoots: readonly string[],
|
|
82
|
+
options: { needsDshStopped: boolean; locksDir?: string } = { needsDshStopped: true },
|
|
83
|
+
): Promise<WriteGateOutcome> {
|
|
84
|
+
for (const report of readSafeMode(controlRoots)) {
|
|
85
|
+
if (report.state === 'blocked') {
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
code: 'safe-mode',
|
|
89
|
+
reason: 'SAFE MODE 已激活(存在未结案的配置 transaction):先处理恢复事项再改磁盘。标记:' + report.marker,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (report.state === 'unknown') {
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
code: 'safe-mode',
|
|
96
|
+
reason: 'SAFE MODE 标记无法判定(按最保守口径处理):先人工核对标记文件。路径:' + report.marker,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* ② 环境锁:**存在锁就必须先处理**。
|
|
102
|
+
*
|
|
103
|
+
* 为什么不能跳过:CLI 侧 destructive 入口(restore/reinstall)都要求成功获取 GLOBAL 环境锁,
|
|
104
|
+
* 而残留锁(STALE_LOCK_DETECTED)正是「上次异常退出、别的操作也被挡着」的状态;
|
|
105
|
+
* 这时改磁盘等于在一个已知不一致的状态上继续写。判据与 `recover-stale-lock` 同源(inspectLockState),
|
|
106
|
+
* 所以**不给自动回收**,只如实拒绝并把出口指出来。
|
|
107
|
+
*/
|
|
108
|
+
// 环境锁目录**不再由调用点决定是否检查**(审计 P11-10):locksDir 曾经是可选参数,
|
|
109
|
+
// 「少传一个」就静默退化成「不查环境锁」——5 个调用点因此排出 3 种组合、实漏 2 处。
|
|
110
|
+
// 现在缺省一律由控制面根派生(与 locksDirFromControlRoots 同源),调用点只在
|
|
111
|
+
// 「锁目录确实不在 <root>/locks」时才需要显式覆盖。
|
|
112
|
+
const locksDir = options.locksDir ?? locksDirFromControlRoots(controlRoots)
|
|
113
|
+
if (locksDir !== undefined) {
|
|
114
|
+
const lock = await readLockState(locksDir)
|
|
115
|
+
if (lock.present) {
|
|
116
|
+
const stale = lock.state === 'STALE_LOCK_DETECTED'
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
code: 'stale-lock',
|
|
120
|
+
reason: (stale
|
|
121
|
+
? '检测到残留的环境锁(持有进程已被确证不存在):先回收它再执行写动作。'
|
|
122
|
+
: '环境锁被持有或状态无法判定(' + lock.state + '):先确认没有其它操作在跑,再执行写动作。')
|
|
123
|
+
+ '锁目录:' + lock.locksDir + ';出口:dsh-config-manager recover-stale-lock(本机救急台的「环境锁」页也可回收)。',
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (options.needsDshStopped) {
|
|
128
|
+
const running = await readRunningInstances(controlRoots)
|
|
129
|
+
if (running.length > 0) {
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
code: 'dsh-running',
|
|
133
|
+
reason: '检测到 DSH 正在运行(' + running.map((i) => i.name + ' pid=' + String(i.pid)).join('、')
|
|
134
|
+
+ '):请先关闭 DSH 再改写会话字节。',
|
|
135
|
+
detail: {
|
|
136
|
+
kind: 'dsh-running',
|
|
137
|
+
instances: running.map((i) => ({ name: i.name, pid: i.pid, port: i.port })),
|
|
138
|
+
commands: [
|
|
139
|
+
// 桌面端独占档案不让普通 CLI 停,如实给出「关窗口」这条唯一通道(见 AGENTS.md 的 desktop 条)
|
|
140
|
+
...running.filter((i) => i.name === 'desktop').map(() => '桌面端(desktop):直接关闭 DSH 桌面窗口;它不接受命令行停止'),
|
|
141
|
+
...running.filter((i) => i.name !== 'desktop').map((i) => 'dsh-config-manager stop ' + i.name + ' # 或在「档案与实例」页点「停止 ' + i.name + '」'),
|
|
142
|
+
'dsh-config-manager web # 停完再回本页点「重新检查」',
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { ok: true }
|
|
149
|
+
}
|
|
@@ -46,6 +46,7 @@ import { EnvironmentPanel } from './environment/EnvironmentPanel.tsx'
|
|
|
46
46
|
import { HistoryPanel } from './history/HistoryPanel.tsx'
|
|
47
47
|
import { RunsCenter } from './common/RunsCenter.tsx'
|
|
48
48
|
import { toRecoveryView } from './recovery/recovery-view.ts'
|
|
49
|
+
import { requestRollbackLedgerOpen } from './recovery/rollback-enabled.ts'
|
|
49
50
|
import { ConfirmDialog } from './common/ConfirmDialog.tsx'
|
|
50
51
|
import { MODAL_ROOT_ID } from './common/Modal.tsx'
|
|
51
52
|
import { Banner, IconButton, StatusDot } from './common/ui.tsx'
|
|
@@ -368,7 +369,7 @@ const navLayoutResult = navWidths === null
|
|
|
368
369
|
? t('nav.sync')
|
|
369
370
|
: state.snapshots.running
|
|
370
371
|
? t('shell.running.restore')
|
|
371
|
-
: state.recovery.running
|
|
372
|
+
: (state.recovery.running || state.recovery.write !== null)
|
|
372
373
|
? t('palette.rescue.recovery')
|
|
373
374
|
: null
|
|
374
375
|
|
|
@@ -378,7 +379,7 @@ const navLayoutResult = navWidths === null
|
|
|
378
379
|
+ (state.import.running ? 1 : 0)
|
|
379
380
|
+ (state.sync.busy !== null ? 1 : 0)
|
|
380
381
|
+ (state.snapshots.running ? 1 : 0)
|
|
381
|
-
+ (state.recovery.running ? 1 : 0)
|
|
382
|
+
+ (state.recovery.running || state.recovery.write !== null ? 1 : 0)
|
|
382
383
|
const statusKind: 'ok' | 'info' | 'error' = recoveryRequired
|
|
383
384
|
? 'error'
|
|
384
385
|
: runningCount > 0 ? 'info' : 'ok'
|
|
@@ -441,8 +442,11 @@ const navLayoutResult = navWidths === null
|
|
|
441
442
|
case 'recovery.open': openMaintenance(); return
|
|
442
443
|
// 救援模式:与事故恢复同一子视图(救援卡在其中);两条命令都必须存在(§3.6)
|
|
443
444
|
case 'rescue.open': openMaintenance(); return
|
|
444
|
-
// S7
|
|
445
|
-
case 'rollback.open':
|
|
445
|
+
// S7:回滚点卡也在维护与诊断里(紧跟会话体检),命令直达并自动打开台账弹窗
|
|
446
|
+
case 'rollback.open':
|
|
447
|
+
requestRollbackLedgerOpen()
|
|
448
|
+
openMaintenance()
|
|
449
|
+
return
|
|
446
450
|
default: return
|
|
447
451
|
}
|
|
448
452
|
}
|
|
@@ -20,9 +20,9 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
20
20
|
import type { TranslateNS } from '../client-types.ts'
|
|
21
21
|
import type { ConfigManagerApi } from '../api.ts'
|
|
22
22
|
import { Badge, Banner, Button, Card } from '../common/ui.tsx'
|
|
23
|
+
import { ErrorBanner } from '../common/ErrorBanner.tsx'
|
|
23
24
|
import { Skeleton } from '../common/Skeleton.tsx'
|
|
24
25
|
import { CopyButton } from '../common/CopyButton.tsx'
|
|
25
|
-
import { InfoHint } from '../common/InfoHint.tsx'
|
|
26
26
|
import { ABOUT_CLI, ABOUT_LINKS, ABOUT_META, aboutStatusRows, aboutUpdateView, buildFeedbackSnippet } from './about-view.ts'
|
|
27
27
|
import type { AboutStatusRows, AboutUpdateView } from './about-view.ts'
|
|
28
28
|
import { ReleaseNotesDialog } from './ReleaseNotesDialog.tsx'
|
|
@@ -114,12 +114,7 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
114
114
|
<Card>
|
|
115
115
|
{state.loading && <Skeleton count={3} label={t('about.loading')} />}
|
|
116
116
|
{state.loadError !== null && (
|
|
117
|
-
<
|
|
118
|
-
<Banner kind="error">{redact(state.loadError)}</Banner>
|
|
119
|
-
<div className={css.actionRow}>
|
|
120
|
-
<Button onClick={() => { void loadStatus() }}>{t('about.retryStatus')}</Button>
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
117
|
+
<ErrorBanner error={redact(state.loadError)} onRetry={() => { void loadStatus() }} t={api.t} />
|
|
123
118
|
)}
|
|
124
119
|
{state.rows !== null && (
|
|
125
120
|
<div className={css.statRow}>
|
|
@@ -134,7 +129,7 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
134
129
|
用于自查「装了插件却没被备份识别到」——此前用户完全无从查看。 */}
|
|
135
130
|
{state.rows?.diagnostics != null && (
|
|
136
131
|
<div className={css.statRow + ' ' + css.statRowStack}>
|
|
137
|
-
<span className={css.groupLabel}
|
|
132
|
+
<span className={css.groupLabel} title={t('about.diag.hint')}>{t('about.diag.label')}</span>
|
|
138
133
|
<span>{t('about.diag.profileDir', { path: state.rows.diagnostics.profileDir })}</span>
|
|
139
134
|
<span>{t('about.diag.profile', { profile: state.rows.diagnostics.profile })}</span>
|
|
140
135
|
<span>{t('about.diag.pluginCount', { count: String(state.rows.diagnostics.pluginCount) })}</span>
|
|
@@ -148,7 +143,6 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
148
143
|
拼接规则是 ./about-view.ts 的纯函数,组件只装配(AGENTS.md §UI 分层铁律)。 */}
|
|
149
144
|
{state.rows !== null && (
|
|
150
145
|
<div className={css.actionRow}>
|
|
151
|
-
<InfoHint text={t('about.feedbackHint')} label={t('common.infoHint')} />
|
|
152
146
|
<CopyButton
|
|
153
147
|
text={buildFeedbackSnippet(state.rows, t)}
|
|
154
148
|
label={t('about.copyEnv')}
|
|
@@ -162,7 +156,7 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
162
156
|
为什么放在「关于」页:这是用户唯一会主动查看「我装的是哪一版」的地方;
|
|
163
157
|
检查失败如实显示原因并允许重试,绝不显示成「已是最新」。 */}
|
|
164
158
|
<Card>
|
|
165
|
-
<span className={css.groupLabel}
|
|
159
|
+
<span className={css.groupLabel} title={t('about.update.offline')}>{t('about.update.title')}</span>
|
|
166
160
|
<div className={css.statRow}>
|
|
167
161
|
{state.rows !== null && (
|
|
168
162
|
<Badge kind="info">{t('about.update.current', { version: state.rows.version })}</Badge>
|
|
@@ -216,7 +210,10 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
216
210
|
<Card>
|
|
217
211
|
<span className={css.groupLabel}>{t('about.links')}</span>
|
|
218
212
|
<div className={css.actionRow}>
|
|
219
|
-
|
|
213
|
+
{/* 只有一颗 primary 的纪律:本页的 primary 属于「立即更新」(更新卡),
|
|
214
|
+
Star 是外链邀请、与更新抢同一层强调时,用户会先看见「去点赞」而错过更新。
|
|
215
|
+
2026-11-13 随设计稿落地改为 ghost(0.5px 描边),行为与落点不变。 */}
|
|
216
|
+
<Button href={ABOUT_LINKS.starUrl}>{t('about.star')}</Button>
|
|
220
217
|
</div>
|
|
221
218
|
<div className={css.aboutLinkRow}>
|
|
222
219
|
<Button href={ABOUT_LINKS.repoUrl}>{t('about.repo')}</Button>
|
|
@@ -239,7 +236,7 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
|
|
|
239
236
|
|
|
240
237
|
{/* P1-⑩:CLI 救援工具引导卡(GUI 里唯一能发现 CLI 的地方;独立安装、DSH 挂了也能用) */}
|
|
241
238
|
<Card>
|
|
242
|
-
<span className={css.groupLabel}
|
|
239
|
+
<span className={css.groupLabel} title={t('about.cli.hint')}>{t('about.cli.title')}</span>
|
|
243
240
|
<pre className={css.cliCommand}>{ABOUT_CLI.installCommand}</pre>
|
|
244
241
|
<ul className={css.reportList}>
|
|
245
242
|
{ABOUT_CLI.commands.map((c) => (
|
|
@@ -152,6 +152,23 @@ test('fetchReleases: 错误处理(403 限流 / 404 / 500)', async () => {
|
|
|
152
152
|
assert.equal(res404.hasMore, false);
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
test('fetchReleases: 请求挂住时按超时失败,不会永久停在骨架(审计 P8-4)', async () => {
|
|
156
|
+
let sawSignal = false;
|
|
157
|
+
const hanging = (_url: string, init?: RequestInit) => {
|
|
158
|
+
sawSignal = init?.signal instanceof AbortSignal;
|
|
159
|
+
return new Promise<Response>((_resolve, reject) => {
|
|
160
|
+
init?.signal?.addEventListener('abort', () => {
|
|
161
|
+
reject(new DOMException('This operation was aborted', 'AbortError'));
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
await assert.rejects(
|
|
166
|
+
() => fetchReleases('https://github.com/foo/bar', 1, 5, hanging as unknown as typeof fetch, t, 20),
|
|
167
|
+
/超时/,
|
|
168
|
+
);
|
|
169
|
+
assert.equal(sawSignal, true, '必须把 AbortSignal 交给 fetcher,否则超时无从生效');
|
|
170
|
+
});
|
|
171
|
+
|
|
155
172
|
test('parseMarkdownBlocks: 解析标题、列表、引用、代码块与段落', () => {
|
|
156
173
|
const md = [
|
|
157
174
|
'# Release 1.0',
|
|
@@ -140,8 +140,19 @@ export function parseReleasesResponse(data: unknown): FormattedRelease[] {
|
|
|
140
140
|
return list;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* 单次 GitHub API 请求的上限(ms)。
|
|
145
|
+
*
|
|
146
|
+
* 审计 P8-4:此前没有任何超时 —— 连接被静默丢弃(代理、断网、NAT 超时)时 fetch 既不
|
|
147
|
+
* resolve 也不 reject,更新说明弹窗就永久停在骨架,用户既看不到错也没有可点的重试。
|
|
148
|
+
* 10 s 覆盖移动网络最差的一段交互等待,又不至于让慢但可用的链路被误判。
|
|
149
|
+
*/
|
|
150
|
+
const RELEASES_FETCH_TIMEOUT_MS = 10_000;
|
|
151
|
+
|
|
143
152
|
/**
|
|
144
153
|
* 分页获取 GitHub Releases。
|
|
154
|
+
*
|
|
155
|
+
* `timeoutMs` 覆盖**整次请求**(含读 body):只有响应头到达、body 挂住同样会卡住弹窗。
|
|
145
156
|
*/
|
|
146
157
|
export async function fetchReleases(
|
|
147
158
|
repoUrl: string,
|
|
@@ -149,35 +160,49 @@ export async function fetchReleases(
|
|
|
149
160
|
perPage = 5,
|
|
150
161
|
fetcher: typeof fetch = globalThis.fetch,
|
|
151
162
|
t: TranslateNS<'config-manager'>,
|
|
163
|
+
timeoutMs = RELEASES_FETCH_TIMEOUT_MS,
|
|
152
164
|
): Promise<FetchReleasesResult> {
|
|
153
165
|
const url = buildReleasesApiUrl(repoUrl, page, perPage);
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
const controller = new AbortController();
|
|
167
|
+
const timer = setTimeout(() => { controller.abort() }, timeoutMs);
|
|
168
|
+
try {
|
|
169
|
+
const res = await fetcher(url, {
|
|
170
|
+
headers: {
|
|
171
|
+
Accept: 'application/vnd.github.v3+json',
|
|
172
|
+
},
|
|
173
|
+
signal: controller.signal,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (!res.ok) {
|
|
177
|
+
if (res.status === 403 || res.status === 429) {
|
|
178
|
+
throw new Error(t('about.releaseNotes.rateLimited'));
|
|
179
|
+
}
|
|
180
|
+
if (res.status === 404) {
|
|
181
|
+
return { releases: [], hasMore: false, page };
|
|
182
|
+
}
|
|
183
|
+
throw new Error(t('about.releaseNotes.fetchFailed', { status: String(res.status), statusText: res.statusText }));
|
|
163
184
|
}
|
|
164
|
-
|
|
165
|
-
|
|
185
|
+
|
|
186
|
+
const json: unknown = await res.json();
|
|
187
|
+
const releases = parseReleasesResponse(json);
|
|
188
|
+
|
|
189
|
+
// 如果返回的有效条目数达到 perPage,则推测还有下一页
|
|
190
|
+
const hasMore = Array.isArray(json) && json.length >= perPage;
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
releases,
|
|
194
|
+
hasMore,
|
|
195
|
+
page,
|
|
196
|
+
};
|
|
197
|
+
} catch (err) {
|
|
198
|
+
// 自己发起的中止 = 超时:给用户一句能照做的原因,而不是把 AbortError 原样抛上去
|
|
199
|
+
if (controller.signal.aborted) {
|
|
200
|
+
throw new Error(t('about.releaseNotes.timeout', { seconds: String(Math.round(timeoutMs / 1000)) }));
|
|
166
201
|
}
|
|
167
|
-
throw
|
|
202
|
+
throw err;
|
|
203
|
+
} finally {
|
|
204
|
+
clearTimeout(timer);
|
|
168
205
|
}
|
|
169
|
-
|
|
170
|
-
const json: unknown = await res.json();
|
|
171
|
-
const releases = parseReleasesResponse(json);
|
|
172
|
-
|
|
173
|
-
// 如果返回的有效条目数达到 perPage,则推测还有下一页
|
|
174
|
-
const hasMore = Array.isArray(json) && json.length >= perPage;
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
releases,
|
|
178
|
-
hasMore,
|
|
179
|
-
page,
|
|
180
|
-
};
|
|
181
206
|
}
|
|
182
207
|
|
|
183
208
|
/* ---------------- 轻量级 Markdown 块解析 ---------------- */
|
package/src/client/api.ts
CHANGED
|
@@ -45,6 +45,7 @@ import type { DiskUsageReport } from '../core/disk-usage.ts';
|
|
|
45
45
|
import type { BrowseResult } from '../core/path-browse.ts';
|
|
46
46
|
import type { NativePickResult } from '../core/native-path-picker.ts';
|
|
47
47
|
import type { UiT } from '../ui/i18n.ts';
|
|
48
|
+
import type { SyncPushBody } from '../ui/sync-settings-view.ts';
|
|
48
49
|
import { failedSectionsFromResponse } from '../ui/export-flow.ts';
|
|
49
50
|
import type { SessionFormatDisposition } from '../ui/session-format-disposition.ts';
|
|
50
51
|
import { CONFIG_MANAGER_API } from './common/routes.ts';
|
|
@@ -898,7 +899,7 @@ export class ConfigManagerApi {
|
|
|
898
899
|
|
|
899
900
|
// ------------------------------------------------- Phase 7 迁移前咨询
|
|
900
901
|
/** 迁移前咨询(只读健康评分 + 建议):对 4 种可迁移源生成统一咨询报告。 */
|
|
901
|
-
async consult(input: { type: 'export-zip' | 'local-snapshot' | 'remote-snapshot' | 'profile'; id: string; snapshotId?: string }): Promise<ConsultReport> {
|
|
902
|
+
async consult(input: SyncPushBody & { type: 'export-zip' | 'local-snapshot' | 'remote-snapshot' | 'profile'; id: string; snapshotId?: string }): Promise<ConsultReport> {
|
|
902
903
|
// 只读咨询要读备份/快照内容:长操作档位。
|
|
903
904
|
return postJson<ConsultReport>(CONFIG_MANAGER_API.consult, input, this.t, LONG_OPTS);
|
|
904
905
|
}
|
|
@@ -426,8 +426,8 @@ function ChatEntryBody({ node, sessionId, openFile, openSkill, renderMessageImag
|
|
|
426
426
|
<ChatEntryCopyAction text={bubble.text} t={t} />
|
|
427
427
|
{/* 回退入口:**只有图标**(无文字标签、无边框按钮样式),与时间戳/复制图标同一行同观感 ——
|
|
428
428
|
2026-10-10 用户第二条要求「回退按钮只有一个 icon 而不是一个按钮」。可见文案退到
|
|
429
|
-
aria-label/title;禁用原因是原生 title
|
|
430
|
-
|
|
429
|
+
aria-label/title;禁用原因是原生 title 里的一句话。按钮始终留在原地(禁用而不是消失):
|
|
430
|
+
入口可见性不随判据漂移。 */}
|
|
431
431
|
{/* 开关**关闭时整颗收起**(issue #88 明确要求「入口收起」,不是置灰;2026-10-17 起连登记
|
|
432
432
|
都会被撤销,整条气泡交回宿主原生渲染,这里只是兜底的那一层)。
|
|
433
433
|
与上面那条「入口可见性不随判据漂移」不冲突:那说的是**暂时读不到点**这类判据,
|
|
@@ -179,9 +179,14 @@ export function chatFileChangeAvailable(files: readonly ChatPreviewFileRow[]): b
|
|
|
179
179
|
export function readRollbackPreviewRemovals(workspace: unknown): string[] {
|
|
180
180
|
const removals = (workspace as { removals?: unknown } | null | undefined)?.removals
|
|
181
181
|
if (!Array.isArray(removals)) return []
|
|
182
|
+
// 去重集与结果数组分开:此前用 out.includes(item) 线性查重,2 万条路径的回滚预览是
|
|
183
|
+
// O(n²),实测主线程阻塞 2.2 s(审计 P8-3),而这一层每次渲染都会重算。Set 把判重降为 O(1),
|
|
184
|
+
// 输出顺序仍按引擎给的顺序(不受 Set 插入顺序以外的任何影响)。
|
|
185
|
+
const seen = new Set<string>()
|
|
182
186
|
const out: string[] = []
|
|
183
187
|
for (const item of removals) {
|
|
184
|
-
if (typeof item !== 'string' || item === '' ||
|
|
188
|
+
if (typeof item !== 'string' || item === '' || seen.has(item)) continue
|
|
189
|
+
seen.add(item)
|
|
185
190
|
out.push(item)
|
|
186
191
|
}
|
|
187
192
|
return out
|