@narumitw/pi-sync 0.61.0 → 0.62.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/CHANGELOG.md +12 -0
- package/README.md +24 -17
- package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-3E3TR3JE.ts} +4 -4
- package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-6PFZUEUG.ts} +41 -18
- package/dist/chunks/chunk-6PFZUEUG.ts.map +7 -0
- package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
- package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
- package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
- package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-GSCZ4VXV.ts} +5 -5
- package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
- package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-INECVQNR.ts} +10 -10
- package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
- package/dist/chunks/{chunk-277VHM2P.ts → chunk-MNYRU5U5.ts} +5 -2
- package/dist/chunks/{chunk-277VHM2P.ts.map → chunk-MNYRU5U5.ts.map} +2 -2
- package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-NHFGAZEC.ts} +11 -8
- package/dist/chunks/chunk-NHFGAZEC.ts.map +7 -0
- package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
- package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
- package/dist/chunks/{chunk-PJMM75W5.ts → chunk-PWESMTH6.ts} +6 -6
- package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
- package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
- package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
- package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
- package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-ZB3GNX3P.ts} +11 -11
- package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
- package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-6ATREPG7.ts} +16 -16
- package/dist/chunks/command-handler-6ATREPG7.ts.map +7 -0
- package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-MAOGTIAI.ts} +4 -4
- package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
- package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
- package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-QR2KZVGD.ts} +10 -10
- package/dist/chunks/manager-result-dispatcher-MC6EQOQY.ts +19 -0
- package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-AOFUNXAJ.ts} +547 -135
- package/dist/chunks/manager-ui-AOFUNXAJ.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-4BTP2OJR.ts +18 -0
- package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-Y6AMFFNK.ts} +7 -7
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-5G426MOZ.ts} +10 -10
- package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
- package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
- package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
- package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-ITZ6Z4DE.ts} +5 -5
- package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-NMVKF7SE.ts} +13 -9
- package/dist/chunks/sync-operations-NMVKF7SE.ts.map +7 -0
- package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
- package/dist/daemon/LICENSE +21 -0
- package/dist/daemon/dist/build-version.js +8 -0
- package/dist/daemon/dist/child-sdk.mjs +17 -0
- package/dist/daemon/dist/cli.js +169 -0
- package/dist/daemon/dist/client.js +909 -0
- package/dist/daemon/dist/consent.js +265 -0
- package/dist/daemon/dist/document.js +6 -0
- package/dist/daemon/dist/endpoint.js +91 -0
- package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
- package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
- package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +715 -0
- package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
- package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
- package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
- package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
- package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
- package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
- package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
- package/dist/daemon/dist/engine/commands/command-types.js +1 -0
- package/dist/daemon/dist/engine/host.js +16 -0
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +186 -0
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +322 -0
- package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
- package/dist/daemon/dist/engine/paths.js +71 -0
- package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
- package/dist/daemon/dist/engine/settings/config-file.js +736 -0
- package/dist/daemon/dist/engine/settings/config.js +301 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +193 -0
- package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
- package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
- package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
- package/dist/daemon/dist/engine/snapshot/session-paths.js +160 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +276 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +813 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
- package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
- package/dist/daemon/dist/engine/state/json-file.js +49 -0
- package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
- package/dist/daemon/dist/engine/state/lock.js +259 -0
- package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
- package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
- package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
- package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
- package/dist/daemon/dist/engine/state/state-directory.js +227 -0
- package/dist/daemon/dist/engine/state/state-types.js +1 -0
- package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
- package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
- package/dist/daemon/dist/engine/sync/agent-plan.js +84 -0
- package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
- package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
- package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
- package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
- package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +132 -0
- package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
- package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
- package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
- package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
- package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
- package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
- package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
- package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
- package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
- package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +521 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
- package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
- package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
- package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
- package/dist/daemon/dist/engine/sync/initialization.js +80 -0
- package/dist/daemon/dist/engine/sync/json-document.js +172 -0
- package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +529 -0
- package/dist/daemon/dist/engine/sync/merge-journal.js +295 -0
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +674 -0
- package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
- package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
- package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +104 -0
- package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
- package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
- package/dist/daemon/dist/engine/sync/session-push.js +33 -0
- package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
- package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
- package/dist/daemon/dist/engine/sync/signals.js +8 -0
- package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
- package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
- package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
- package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
- package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
- package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +733 -0
- package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
- package/dist/daemon/dist/engine/sync/sync-policy.js +621 -0
- package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
- package/dist/daemon/dist/engine/sync/sync-state.js +129 -0
- package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
- package/dist/daemon/dist/engine/types.js +2 -0
- package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
- package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
- package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
- package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
- package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
- package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
- package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
- package/dist/daemon/dist/engine-service.js +344 -0
- package/dist/daemon/dist/identity.js +241 -0
- package/dist/daemon/dist/idle-exit.js +77 -0
- package/dist/daemon/dist/index.js +4 -0
- package/dist/daemon/dist/lifecycle-log.js +53 -0
- package/dist/daemon/dist/lifecycle.js +21 -0
- package/dist/daemon/dist/model-signature.js +7 -0
- package/dist/daemon/dist/monitor.js +272 -0
- package/dist/daemon/dist/participant-admission.js +30 -0
- package/dist/daemon/dist/protocol.js +104 -0
- package/dist/daemon/dist/resolver-host.js +78 -0
- package/dist/daemon/dist/server.js +953 -0
- package/dist/daemon/dist/service-host.js +174 -0
- package/dist/daemon/dist/upgrade-repair.js +55 -0
- package/dist/daemon/package.json +3 -0
- package/dist/index.ts +21 -21
- package/dist/package.json +6 -0
- package/docs/daemon-migration.md +27 -16
- package/package.json +9 -3
- package/skills/configure-pi-sync/SKILL.md +38 -13
- package/skills/configure-pi-sync/references/configuration.md +2 -2
- package/src/commands/command-execution.ts +1 -1
- package/src/settings/config.ts +1 -0
- package/src/sync/sync-operations.ts +18 -10
- package/src/ui/excluded-paths-ui.ts +4 -1
- package/src/ui/ignore-file-ui.ts +271 -0
- package/src/ui/ignore-migration-prompt.ts +65 -0
- package/src/ui/manager-state.ts +27 -13
- package/src/ui/manager-ui.ts +38 -19
- package/src/ui/remote-selection-ui.ts +41 -8
- package/src/ui/settings-review.ts +26 -0
- package/src/ui/settings-ui.ts +316 -213
- package/src/ui/storage-connections-ui.ts +20 -12
- package/src/ui/sync-setups-ui.ts +45 -27
- package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
- package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
- package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
- package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
- package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
- /package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-3E3TR3JE.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
- /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
- /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-GSCZ4VXV.ts.map} +0 -0
- /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
- /package/dist/chunks/{chunk-E3YLRLJM.ts.map → chunk-INECVQNR.ts.map} +0 -0
- /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
- /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
- /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
- /package/dist/chunks/{chunk-PJMM75W5.ts.map → chunk-PWESMTH6.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
- /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
- /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
- /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
- /package/dist/chunks/{chunk-4KTJLJSJ.ts.map → chunk-ZB3GNX3P.ts.map} +0 -0
- /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-MAOGTIAI.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
- /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
- /package/dist/chunks/{file-selection-MGGVOKM7.ts.map → file-selection-QR2KZVGD.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-MC6EQOQY.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-4BTP2OJR.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-Y6AMFFNK.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-5G426MOZ.ts.map} +0 -0
- /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
- /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-ITZ6Z4DE.ts.map} +0 -0
- /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
|
@@ -3,19 +3,27 @@ import type { CommandOptions } from "../commands/command-types.js";
|
|
|
3
3
|
import { remoteOperation } from "../daemon/pi-client.js";
|
|
4
4
|
import type { SetupPullOutcome } from "./setup-switch.js";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
ctx: ExtensionContext,
|
|
8
|
-
operation: string,
|
|
9
|
-
options: CommandOptions,
|
|
10
|
-
): Promise<SetupPullOutcome | undefined> {
|
|
11
|
-
const result = await remoteOperation(ctx, operation, options);
|
|
6
|
+
function transferResult(result: unknown): SetupPullOutcome | undefined {
|
|
12
7
|
if (result === undefined || result === "applied" || result === "cancelled") return result;
|
|
13
8
|
throw new Error("Invalid transfer result from pi-sync-daemon.");
|
|
14
9
|
}
|
|
15
|
-
export const push = (ctx: ExtensionContext, options: CommandOptions) =>
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
|
|
10
|
+
export const push = async (ctx: ExtensionContext, options: CommandOptions) =>
|
|
11
|
+
transferResult(await remoteOperation(ctx, "push", options));
|
|
12
|
+
export const pull = async (ctx: ExtensionContext, options: CommandOptions) =>
|
|
13
|
+
transferResult(await remoteOperation(ctx, "pull", options));
|
|
14
|
+
export async function syncBoth(ctx: ExtensionContext, options: CommandOptions) {
|
|
15
|
+
const result = await remoteOperation(ctx, options.auto ? "startup-transfer" : "sync", options);
|
|
16
|
+
if (
|
|
17
|
+
result === "archived" &&
|
|
18
|
+
!options.auto &&
|
|
19
|
+
!options.agentRetryRefusal &&
|
|
20
|
+
!options.yes &&
|
|
21
|
+
ctx.hasUI &&
|
|
22
|
+
(ctx.mode === "tui" || ctx.mode === "rpc")
|
|
23
|
+
)
|
|
24
|
+
return result;
|
|
25
|
+
return transferResult(result);
|
|
26
|
+
}
|
|
19
27
|
export async function rollback(ctx: ExtensionContext, options: CommandOptions) {
|
|
20
28
|
await remoteOperation(ctx, "rollback", options);
|
|
21
29
|
}
|
|
@@ -100,6 +100,8 @@ export async function showExcludedPaths(ctx: ExtensionCommandContext, setupName:
|
|
|
100
100
|
setupName,
|
|
101
101
|
(setup) => {
|
|
102
102
|
validate();
|
|
103
|
+
if (setup.sync.pathPolicy === "ignore-file")
|
|
104
|
+
throw new Error("Edit the ignore file to change this setup's policy.");
|
|
103
105
|
return { ...setup, sync: { ...setup.sync, exclude } };
|
|
104
106
|
},
|
|
105
107
|
{ expectedConfigFingerprint: syncCheckConfigFingerprint(config), upgradeExclude: true, signal },
|
|
@@ -217,7 +219,8 @@ export async function showDirectoryScope(ctx: ExtensionCommandContext, config: A
|
|
|
217
219
|
config.setupName,
|
|
218
220
|
(setup) => {
|
|
219
221
|
validate();
|
|
220
|
-
if (setup.sync.scope !== "agent-directory"
|
|
222
|
+
if (setup.sync.scope !== "agent-directory" || setup.sync.pathPolicy === "ignore-file")
|
|
223
|
+
throw new Error("Sync scope changed during review.");
|
|
221
224
|
return {
|
|
222
225
|
...setup,
|
|
223
226
|
sync: {
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { type ExtensionCommandContext, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { CURSOR_MARKER, Editor, isKeyRelease, Key, matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
4
|
+
import { HorizontalRule, hardWrapTerminalDocument, runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
5
|
+
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
6
|
+
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
7
|
+
import { runCancellableTask } from "./cancellable-operation.js";
|
|
8
|
+
import { confirmMergeReview } from "./merge-review.js";
|
|
9
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
10
|
+
|
|
11
|
+
interface IgnoreFile {
|
|
12
|
+
filename: string;
|
|
13
|
+
path: string;
|
|
14
|
+
text: string;
|
|
15
|
+
sourceDigest: string;
|
|
16
|
+
identity: string;
|
|
17
|
+
sharingSetups: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type IgnoreOperation = "edit" | "switch" | "migrate";
|
|
21
|
+
|
|
22
|
+
type EditorResult = { kind: "draft"; text: string } | { kind: "cancelled" | "unsafe" };
|
|
23
|
+
|
|
24
|
+
export async function ignoreFileSettingsAvailable(ctx: ExtensionCommandContext, signal?: AbortSignal) {
|
|
25
|
+
if (signal?.aborted) return false;
|
|
26
|
+
try {
|
|
27
|
+
const client = piDaemonClient(ctx);
|
|
28
|
+
const result = await client.run("ignore.capabilities", {}, signal, ctx);
|
|
29
|
+
client.validate();
|
|
30
|
+
return !signal?.aborted && (result as { available?: unknown } | undefined)?.available === true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function manualIgnoreFileGuidance(filename: string) {
|
|
37
|
+
return `Edit existing ignore rules manually: ${safeTerminalText(resolve(getAgentDir(), filename))}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function showIgnoreFileAction(
|
|
41
|
+
ctx: ExtensionCommandContext,
|
|
42
|
+
setup: string,
|
|
43
|
+
action: IgnoreOperation,
|
|
44
|
+
filename: string,
|
|
45
|
+
signal: AbortSignal,
|
|
46
|
+
offerToken?: string,
|
|
47
|
+
) {
|
|
48
|
+
if (signal.aborted || !ctx.hasUI) return;
|
|
49
|
+
if (ctx.mode !== "tui") {
|
|
50
|
+
if (ctx.mode === "rpc" && action === "edit") ctx.ui.notify(manualIgnoreFileGuidance(filename), "info");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const validateOwner = captureMutationOwner(ctx, signal);
|
|
54
|
+
const client = piDaemonClient(ctx);
|
|
55
|
+
const isCurrent = () => {
|
|
56
|
+
try {
|
|
57
|
+
validateOwner();
|
|
58
|
+
client.validate();
|
|
59
|
+
return true;
|
|
60
|
+
} catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const work = async (
|
|
65
|
+
method: "read" | "save" | "switch" | "migrate",
|
|
66
|
+
message: string,
|
|
67
|
+
payload: Record<string, unknown> = {},
|
|
68
|
+
) => {
|
|
69
|
+
const result = await runCancellableTask(
|
|
70
|
+
ctx,
|
|
71
|
+
message,
|
|
72
|
+
(workSignal, onCommit) => client.run(`ignore.${method}`, { setup, ...payload }, workSignal, ctx, onCommit),
|
|
73
|
+
{
|
|
74
|
+
signal,
|
|
75
|
+
isCurrent,
|
|
76
|
+
cancelledMessage: null,
|
|
77
|
+
commitAware: method !== "read",
|
|
78
|
+
cancelAcrossDialogs: method !== "read",
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
return isCurrent() && result.kind === "completed" ? result : undefined;
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
if (action === "migrate") {
|
|
85
|
+
const result = await work("migrate", "Preparing ignore-file migration review…", offerToken ? { offerToken } : {});
|
|
86
|
+
if (isCurrent() && result?.value === "saved")
|
|
87
|
+
ctx.ui.notify("Ignore-file policy saved locally. No transfer started.", "info");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (action === "switch") {
|
|
91
|
+
const entered = await askIgnoreFilename(ctx, filename, signal);
|
|
92
|
+
if (!isCurrent() || !entered || entered === filename) return;
|
|
93
|
+
const result = await work("switch", "Checking the selected ignore file for review…", {
|
|
94
|
+
filename: entered,
|
|
95
|
+
expectedFilename: filename,
|
|
96
|
+
});
|
|
97
|
+
if (isCurrent() && result?.value === "saved") ctx.ui.notify("Ignore file selected. No transfer started.", "info");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const result = await work("read", "Opening existing ignore file…");
|
|
101
|
+
if (!isCurrent() || !result) return;
|
|
102
|
+
const source = decodeIgnoreFile(result.value);
|
|
103
|
+
const path = safeTerminalText(source.path);
|
|
104
|
+
if (!isEditorSafe(source.text)) {
|
|
105
|
+
ctx.ui.notify(
|
|
106
|
+
`Pi cannot edit this file without changing or hiding some characters. Edit ${path} manually.`,
|
|
107
|
+
"warning",
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const sharing = source.sharingSetups.length
|
|
112
|
+
? `Also used by: ${source.sharingSetups.map((name) => `“${safeTerminalText(name)}”`).join(", ")}`
|
|
113
|
+
: undefined;
|
|
114
|
+
const draft = await editIgnoreText(ctx, source.text, path, sharing, signal, isCurrent);
|
|
115
|
+
if (!isCurrent() || draft.kind !== "completed") return;
|
|
116
|
+
if (draft.value.kind === "unsafe") {
|
|
117
|
+
ctx.ui.notify(`Unsafe terminal characters in the draft. No save; edit ${path} manually.`, "warning");
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (draft.value.kind !== "draft" || draft.value.text === source.text) return;
|
|
121
|
+
const text = draft.value.text;
|
|
122
|
+
const lines = [
|
|
123
|
+
path,
|
|
124
|
+
...(sharing ? [sharing] : []),
|
|
125
|
+
"This replaces the local rules. Removing rules may expose more files on a later sync.",
|
|
126
|
+
"No transfer starts; remote history is retained.",
|
|
127
|
+
];
|
|
128
|
+
const confirmed = await confirmMergeReview(ctx, "Save ignore rules?", text, signal, isCurrent, "save rules", lines);
|
|
129
|
+
if (!isCurrent() || !confirmed) return;
|
|
130
|
+
const saved = await work("save", "Saving ignore rules…", {
|
|
131
|
+
text,
|
|
132
|
+
sourceDigest: source.sourceDigest,
|
|
133
|
+
identity: source.identity,
|
|
134
|
+
});
|
|
135
|
+
if (isCurrent() && saved) ctx.ui.notify("Ignore rules saved. No transfer started.", "info");
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (isCurrent())
|
|
138
|
+
ctx.ui.notify(`Pi Sync: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`, "error");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function decodeIgnoreFile(value: unknown): IgnoreFile {
|
|
143
|
+
const file = value as Partial<IgnoreFile> | null;
|
|
144
|
+
if (!file || typeof file.filename !== "string" || typeof file.path !== "string")
|
|
145
|
+
throw new Error("Invalid ignore-file response from the daemon.");
|
|
146
|
+
if (file.identity === undefined && file.text === undefined)
|
|
147
|
+
throw new Error(`Ignore file does not exist: ${file.path}. No file was created.`);
|
|
148
|
+
if (
|
|
149
|
+
typeof file.text !== "string" ||
|
|
150
|
+
typeof file.identity !== "string" ||
|
|
151
|
+
file.identity.length === 0 ||
|
|
152
|
+
typeof file.sourceDigest !== "string" ||
|
|
153
|
+
!Array.isArray(file.sharingSetups) ||
|
|
154
|
+
!file.sharingSetups.every((setup) => typeof setup === "string")
|
|
155
|
+
)
|
|
156
|
+
throw new Error("Invalid ignore-file response from the daemon.");
|
|
157
|
+
return file as IgnoreFile;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function askIgnoreFilename(ctx: ExtensionCommandContext, filename: string, signal: AbortSignal) {
|
|
161
|
+
const cancel = new AbortController();
|
|
162
|
+
const stop = ctx.ui.onTerminalInput((data) => {
|
|
163
|
+
if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
|
|
164
|
+
cancel.abort();
|
|
165
|
+
return { consume: true };
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const inputSignal = AbortSignal.any([signal, cancel.signal]);
|
|
169
|
+
try {
|
|
170
|
+
const entered = await ctx.ui.input(`Existing ignore filename (current: ${safeTerminalText(filename)})`, undefined, {
|
|
171
|
+
signal: inputSignal,
|
|
172
|
+
});
|
|
173
|
+
return inputSignal.aborted ? undefined : entered;
|
|
174
|
+
} finally {
|
|
175
|
+
stop();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function isEditorSafe(text: string) {
|
|
180
|
+
const flattened = text.replaceAll("\n", "");
|
|
181
|
+
return flattened === safeTerminalText(flattened);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function editIgnoreText(
|
|
185
|
+
ctx: ExtensionCommandContext,
|
|
186
|
+
original: string,
|
|
187
|
+
path: string,
|
|
188
|
+
sharing: string | undefined,
|
|
189
|
+
signal: AbortSignal,
|
|
190
|
+
isCurrent: () => boolean,
|
|
191
|
+
) {
|
|
192
|
+
return runCustomInteraction<EditorResult, ExtensionCommandContext>(ctx, {
|
|
193
|
+
signal,
|
|
194
|
+
isCurrent,
|
|
195
|
+
create: ({ tui, theme, keybindings, complete, signal: editorSignal }) => {
|
|
196
|
+
const muted = (line: string) => theme.fg("muted", line);
|
|
197
|
+
const editor = new Editor(tui, {
|
|
198
|
+
borderColor: (line) => theme.fg("borderMuted", line),
|
|
199
|
+
selectList: {
|
|
200
|
+
selectedPrefix: (line) => theme.fg("accent", line),
|
|
201
|
+
selectedText: (line) => theme.fg("accent", line),
|
|
202
|
+
description: muted,
|
|
203
|
+
scrollInfo: muted,
|
|
204
|
+
noMatch: muted,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
editor.setText(original);
|
|
208
|
+
let text = original;
|
|
209
|
+
let beforeChange = original;
|
|
210
|
+
editor.onChange = () => {
|
|
211
|
+
beforeChange = text;
|
|
212
|
+
text = editor.getExpandedText();
|
|
213
|
+
if (!isEditorSafe(text)) complete({ kind: "unsafe" });
|
|
214
|
+
};
|
|
215
|
+
editor.onSubmit = () => complete({ kind: "draft", text: beforeChange });
|
|
216
|
+
const rule = new HorizontalRule({ ruleStyle: (line) => theme.fg("border", line) });
|
|
217
|
+
let layout: { width: number; first: number; count: number; editorOffset: number } | undefined;
|
|
218
|
+
return {
|
|
219
|
+
get focused() {
|
|
220
|
+
return editor.focused;
|
|
221
|
+
},
|
|
222
|
+
set focused(value: boolean) {
|
|
223
|
+
editor.focused = value;
|
|
224
|
+
},
|
|
225
|
+
get capturesViewportInput() {
|
|
226
|
+
return true;
|
|
227
|
+
},
|
|
228
|
+
render(width: number) {
|
|
229
|
+
layout = undefined;
|
|
230
|
+
if (editorSignal.aborted || !Number.isFinite(width) || width <= 0) return [];
|
|
231
|
+
const terminalRows = Number.isFinite(tui.terminal.rows) ? Math.floor(tui.terminal.rows) : 24;
|
|
232
|
+
const rows = Math.max(1, terminalRows - 3);
|
|
233
|
+
const border = rows >= 5 ? rule.render(width) : [];
|
|
234
|
+
const editorRows = editor.render(width).slice(1, -1);
|
|
235
|
+
const header = [
|
|
236
|
+
theme.fg("accent", theme.bold("Edit ignore rules")),
|
|
237
|
+
muted("Submit to review; cancel to discard."),
|
|
238
|
+
...[path, ...(sharing ? [sharing] : [])].flatMap((line) =>
|
|
239
|
+
hardWrapTerminalDocument(line, width).map(muted),
|
|
240
|
+
),
|
|
241
|
+
].slice(0, rows - 2 * border.length - 1);
|
|
242
|
+
const available = rows - 2 * border.length - header.length;
|
|
243
|
+
const cursorRow = editorRows.findIndex((line) => line.includes(CURSOR_MARKER));
|
|
244
|
+
const offset = Math.max(0, cursorRow - available + 1);
|
|
245
|
+
const body = editorRows.slice(offset, offset + available);
|
|
246
|
+
layout = { width, first: border.length + header.length, count: body.length, editorOffset: offset + 1 };
|
|
247
|
+
return [...border, ...header, ...body, ...border].map((line) => truncateToWidth(line, width, ""));
|
|
248
|
+
},
|
|
249
|
+
invalidate() {
|
|
250
|
+
layout = undefined;
|
|
251
|
+
rule.invalidate();
|
|
252
|
+
editor.invalidate();
|
|
253
|
+
},
|
|
254
|
+
handleInput(data: string) {
|
|
255
|
+
if (editorSignal.aborted || isKeyRelease(data)) return;
|
|
256
|
+
if (matchesKey(data, Key.ctrl("c")) || keybindings.matches(data, "tui.select.cancel")) {
|
|
257
|
+
complete({ kind: "cancelled" });
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
editor.handleInput(data);
|
|
261
|
+
if (!editorSignal.aborted) tui.requestRender();
|
|
262
|
+
},
|
|
263
|
+
handleMouse(event: Parameters<Editor["handleMouse"]>[0]) {
|
|
264
|
+
if (editorSignal.aborted || !layout || layout.width !== event.width) return;
|
|
265
|
+
const y = event.y - layout.first;
|
|
266
|
+
if (y >= 0 && y < layout.count) return editor.handleMouse({ ...event, y: y + layout.editorOffset });
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { piDaemonClient } from "../daemon/pi-client.js";
|
|
3
|
+
import { ignoreFileSettingsAvailable, showIgnoreFileAction } from "./ignore-file-ui.js";
|
|
4
|
+
import { safeTerminalText } from "./terminal-text.js";
|
|
5
|
+
|
|
6
|
+
const reviewNow = "Review migration now";
|
|
7
|
+
const notNow = "Not now";
|
|
8
|
+
|
|
9
|
+
export async function showIgnoreMigrationPrompt(
|
|
10
|
+
ctx: ExtensionCommandContext,
|
|
11
|
+
setup: string,
|
|
12
|
+
signal: AbortSignal,
|
|
13
|
+
isCurrent: () => boolean,
|
|
14
|
+
): Promise<boolean> {
|
|
15
|
+
if (ctx.mode !== "tui" || !ctx.hasUI || signal.aborted || !isCurrent()) return false;
|
|
16
|
+
if (!(await ignoreFileSettingsAvailable(ctx, signal)) || signal.aborted || !isCurrent()) return false;
|
|
17
|
+
|
|
18
|
+
let shown = false;
|
|
19
|
+
try {
|
|
20
|
+
const client = piDaemonClient(ctx);
|
|
21
|
+
const valid = () => {
|
|
22
|
+
if (signal.aborted || !isCurrent()) return false;
|
|
23
|
+
client.validate();
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
const offer = await client.run("ignore.migration-offer", { setup }, signal, ctx);
|
|
27
|
+
if (!valid()) return false;
|
|
28
|
+
const token = readOfferToken(offer);
|
|
29
|
+
if (!token) return false;
|
|
30
|
+
|
|
31
|
+
shown = true;
|
|
32
|
+
const choice = await ctx.ui.select(
|
|
33
|
+
[
|
|
34
|
+
`Review migration for sync setup “${safeTerminalText(setup)}”?`,
|
|
35
|
+
"Your current rules still apply. Review the paths that would change before deciding.",
|
|
36
|
+
"Migration does not start a transfer. You can review it later in Pi Sync Settings.",
|
|
37
|
+
].join("\n\n"),
|
|
38
|
+
[reviewNow, notNow],
|
|
39
|
+
{ signal },
|
|
40
|
+
);
|
|
41
|
+
if (!valid()) return true;
|
|
42
|
+
if (choice === notNow) {
|
|
43
|
+
await client.run("ignore.migration-defer", { setup, token }, signal, ctx);
|
|
44
|
+
} else if (choice === reviewNow) {
|
|
45
|
+
await showIgnoreFileAction(ctx, setup, "migrate", ".syncignore", signal, token);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!signal.aborted && isCurrent()) {
|
|
49
|
+
ctx.ui.notify(
|
|
50
|
+
`Pi Sync migration prompt: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
|
|
51
|
+
"warning",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return shown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function readOfferToken(value: unknown) {
|
|
59
|
+
if (value === null) return undefined;
|
|
60
|
+
const token = (value as { token?: unknown } | undefined)?.token;
|
|
61
|
+
if (typeof token !== "string" || !/^[0-9a-f]{64}$/u.test(token)) {
|
|
62
|
+
throw new Error("Invalid migration offer from the daemon.");
|
|
63
|
+
}
|
|
64
|
+
return token;
|
|
65
|
+
}
|
package/src/ui/manager-state.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
2
|
-
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
3
|
-
import { activeLocalConfigPath } from "../settings/config-file.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { isCloudflareR2Endpoint, ownRecord } from "../settings/settings-validation.js";
|
|
2
|
+
import { configFromSettings, loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
3
|
+
import { activeLocalConfigPath, readActiveLocalConfigDocumentForRepair } from "../settings/config-file.js";
|
|
4
|
+
import type { AnySyncConfig, PiSyncSettingsV3 } from "../settings/settings-types.js";
|
|
5
|
+
import { isCloudflareR2Endpoint, validateSettingsDocument } from "../settings/settings-validation.js";
|
|
7
6
|
import {
|
|
8
7
|
inspectOperationAvailability,
|
|
9
8
|
type OperationAvailability,
|
|
@@ -39,6 +38,7 @@ export interface ManagerDescription {
|
|
|
39
38
|
title: string;
|
|
40
39
|
actions: string[];
|
|
41
40
|
configReview?: { setupName: string; fingerprint: string };
|
|
41
|
+
settingsReview?: { setupName: string; fingerprint: string };
|
|
42
42
|
operation?: OperationAvailability;
|
|
43
43
|
attention?: SyncAttentionState;
|
|
44
44
|
observation?: StartupObservation;
|
|
@@ -52,10 +52,13 @@ export async function describeManagerState(
|
|
|
52
52
|
inspectOperation: () => Promise<OperationAvailability> = inspectOperationAvailability,
|
|
53
53
|
observation?: StartupObservation,
|
|
54
54
|
): Promise<ManagerDescription> {
|
|
55
|
-
let raw:
|
|
55
|
+
let raw: PiSyncSettingsV3 | undefined;
|
|
56
56
|
try {
|
|
57
|
-
|
|
57
|
+
const document = await readActiveLocalConfigDocumentForRepair();
|
|
58
|
+
signal?.throwIfAborted();
|
|
59
|
+
if (document) raw = validateSettingsDocument(document.parsed);
|
|
58
60
|
} catch (error) {
|
|
61
|
+
if (signal?.aborted) throw error;
|
|
59
62
|
return {
|
|
60
63
|
title: [
|
|
61
64
|
"Manage sync",
|
|
@@ -75,12 +78,8 @@ export async function describeManagerState(
|
|
|
75
78
|
actions: ["Set up sync", "Help"],
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
|
-
const configuredTargets =
|
|
79
|
-
if (
|
|
80
|
-
(raw.version === 3 || raw.version === 4 || raw.version === 5 || raw.version === 6 || raw.version === 7) &&
|
|
81
|
-
configuredTargets &&
|
|
82
|
-
Object.keys(configuredTargets).length === 0
|
|
83
|
-
) {
|
|
81
|
+
const configuredTargets = raw.syncSetups;
|
|
82
|
+
if (Object.keys(configuredTargets).length === 0) {
|
|
84
83
|
return {
|
|
85
84
|
title: [
|
|
86
85
|
"Manage sync",
|
|
@@ -94,6 +93,21 @@ export async function describeManagerState(
|
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
95
|
try {
|
|
96
|
+
const settingsConfig = configFromSettings(raw);
|
|
97
|
+
if (settingsConfig.reservedIgnoreNames !== undefined) {
|
|
98
|
+
return {
|
|
99
|
+
title: [
|
|
100
|
+
"Manage sync",
|
|
101
|
+
`Current sync setup: ${safeTerminalText(settingsConfig.setupName)}`,
|
|
102
|
+
"Transfers are unavailable while ignore-file setups are configured.",
|
|
103
|
+
].join("\n"),
|
|
104
|
+
actions: ["Settings", "Sync setups…", "Storage connections…", "Help"],
|
|
105
|
+
settingsReview: {
|
|
106
|
+
setupName: settingsConfig.setupName,
|
|
107
|
+
fingerprint: syncCheckConfigFingerprint(settingsConfig),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
97
111
|
const config = await loadConfig();
|
|
98
112
|
const operation = await inspectOperation();
|
|
99
113
|
const changesBlocked = operationBlocksChanges(operation);
|
package/src/ui/manager-ui.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { Component } from "@earendil-works/pi-tui";
|
|
3
3
|
import { type ActionMenuItem, defineMenu, type MenuDefinition, runDocumentReview, runMenu } from "@narumitw/pi-tui-kit";
|
|
4
|
-
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
|
+
import { loadConfig, loadSettingsConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { operationBlocksChanges } from "../state/operation-availability.js";
|
|
6
6
|
import { captureMutationOwner } from "../sync/sync-local.js";
|
|
7
7
|
import { type RunRoute, runCancellableOperation } from "./cancellable-operation.js";
|
|
8
|
+
import { showIgnoreMigrationPrompt } from "./ignore-migration-prompt.js";
|
|
8
9
|
import {
|
|
9
10
|
attentionMainMenuItems,
|
|
10
11
|
blockedSyncMenuItem,
|
|
@@ -180,8 +181,10 @@ export async function showSyncManager(
|
|
|
180
181
|
const result = await showSetupSwitcher(ctx, runRoute, undefined, sessionSignal);
|
|
181
182
|
return result === "pull-attempted" || result === "closed" ? { kind: "close" } : { kind: "stay" };
|
|
182
183
|
},
|
|
183
|
-
settings: async ({ state }) => {
|
|
184
|
-
const
|
|
184
|
+
settings: async ({ state, signal: actionSignal }) => {
|
|
185
|
+
const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
|
|
186
|
+
const review = state.manager.settingsReview ?? state.manager.configReview;
|
|
187
|
+
const result = await showSyncSettings(ctx, runRoute, signal, review?.setupName);
|
|
185
188
|
return { kind: result === "exit" ? "close" : "stay" };
|
|
186
189
|
},
|
|
187
190
|
pull: async ({ state }) => {
|
|
@@ -327,10 +330,11 @@ export async function showSyncManager(
|
|
|
327
330
|
const activate = menu.actions[action];
|
|
328
331
|
menu.actions[action] = async (invocation) => {
|
|
329
332
|
validateOwner();
|
|
330
|
-
const
|
|
333
|
+
const { configReview, settingsReview } = invocation.state.manager;
|
|
334
|
+
const review = action === "settings" ? (settingsReview ?? configReview) : configReview;
|
|
331
335
|
let current = false;
|
|
332
336
|
try {
|
|
333
|
-
const config = await loadConfig();
|
|
337
|
+
const config = await (action === "settings" ? loadSettingsConfig() : loadConfig());
|
|
334
338
|
validateOwner();
|
|
335
339
|
invocation.signal.throwIfAborted();
|
|
336
340
|
current = review?.fingerprint === syncCheckConfigFingerprint(config);
|
|
@@ -365,23 +369,38 @@ export async function showSyncManager(
|
|
|
365
369
|
}, customOptions),
|
|
366
370
|
},
|
|
367
371
|
};
|
|
372
|
+
let firstOpen = true;
|
|
373
|
+
const describe = async (signal: AbortSignal) => {
|
|
374
|
+
const pendingAttention = options.getAttention?.();
|
|
375
|
+
const observation = options.getObservation?.();
|
|
376
|
+
const manager = await describeManagerState(signal, pendingAttention, undefined, observation);
|
|
377
|
+
if (signal.aborted || !isCurrent()) return manager;
|
|
378
|
+
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
379
|
+
if (
|
|
380
|
+
observation &&
|
|
381
|
+
options.getObservation?.() === observation &&
|
|
382
|
+
!manager.observation &&
|
|
383
|
+
!(manager.operation && operationBlocksChanges(manager.operation))
|
|
384
|
+
) {
|
|
385
|
+
options.onObservationInvalidated?.();
|
|
386
|
+
}
|
|
387
|
+
if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
|
|
388
|
+
options.onSelectionResolved?.(pendingAttention);
|
|
389
|
+
}
|
|
390
|
+
return manager;
|
|
391
|
+
};
|
|
368
392
|
await runMenu(menuContext, menu, {
|
|
369
|
-
getState: async () => {
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (sessionSignal?.aborted) return { manager };
|
|
374
|
-
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
393
|
+
getState: async ({ signal }) => {
|
|
394
|
+
const offerOnOpen = firstOpen;
|
|
395
|
+
firstOpen = false;
|
|
396
|
+
let manager = await describe(signal);
|
|
375
397
|
if (
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
398
|
+
offerOnOpen &&
|
|
399
|
+
manager.operation?.kind === "free" &&
|
|
400
|
+
manager.configReview &&
|
|
401
|
+
(await showIgnoreMigrationPrompt(ctx, manager.configReview.setupName, signal, isCurrent))
|
|
380
402
|
) {
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
if (pendingAttention && options.getAttention?.() === pendingAttention && !manager.attention) {
|
|
384
|
-
options.onSelectionResolved?.(pendingAttention);
|
|
403
|
+
if (!signal.aborted && isCurrent()) manager = await describe(signal);
|
|
385
404
|
}
|
|
386
405
|
return { manager };
|
|
387
406
|
},
|