@narumitw/pi-sync 0.62.0 → 0.63.1
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 +26 -0
- package/README.md +40 -23
- package/dist/chunks/{chunk-MNYRU5U5.ts → chunk-27F5W7DX.ts} +3 -2
- package/dist/chunks/{chunk-MNYRU5U5.ts.map → chunk-27F5W7DX.ts.map} +2 -2
- package/dist/chunks/{chunk-INECVQNR.ts → chunk-B5F3JLD3.ts} +6 -4
- package/dist/chunks/chunk-B5F3JLD3.ts.map +7 -0
- package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
- package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
- package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
- package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
- package/dist/chunks/{chunk-6PFZUEUG.ts → chunk-EXDWEFIJ.ts} +52 -135
- package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
- package/dist/chunks/{chunk-NHFGAZEC.ts → chunk-HSCAFOT5.ts} +7 -7
- package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
- package/dist/chunks/{chunk-ZB3GNX3P.ts → chunk-LBNC5AOM.ts} +140 -13
- package/dist/chunks/chunk-LBNC5AOM.ts.map +7 -0
- package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
- package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
- package/dist/chunks/{chunk-GSQGBVKG.ts → chunk-POWOMJ7S.ts} +87 -50
- package/dist/chunks/chunk-POWOMJ7S.ts.map +7 -0
- package/dist/chunks/{chunk-PWESMTH6.ts → chunk-SXCH4Q5O.ts} +38 -20
- package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
- package/dist/chunks/{chunk-3E3TR3JE.ts → chunk-V76KCWHO.ts} +6 -4
- package/dist/chunks/{chunk-3E3TR3JE.ts.map → chunk-V76KCWHO.ts.map} +1 -1
- package/dist/chunks/{chunk-GSCZ4VXV.ts → chunk-VQ47JBLF.ts} +2 -2
- package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
- package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
- package/dist/chunks/{command-handler-6ATREPG7.ts → command-handler-GMRRFWOL.ts} +19 -36
- package/dist/chunks/command-handler-GMRRFWOL.ts.map +7 -0
- package/dist/chunks/{conflict-review-MAOGTIAI.ts → conflict-review-JWEA7DPQ.ts} +2 -2
- package/dist/chunks/{file-selection-QR2KZVGD.ts → file-selection-KID23GAD.ts} +15 -8
- package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-MC6EQOQY.ts → manager-result-dispatcher-GDB74IOP.ts} +6 -5
- package/dist/chunks/{manager-ui-AOFUNXAJ.ts → manager-ui-T5J5WG7T.ts} +227 -343
- package/dist/chunks/manager-ui-T5J5WG7T.ts.map +7 -0
- package/dist/chunks/{merge-review-SGDLMVS4.ts → merge-review-OQDXNTJU.ts} +2 -2
- package/dist/chunks/{remote-selection-ui-4BTP2OJR.ts → remote-selection-ui-GPITNEBF.ts} +5 -4
- package/dist/chunks/{setup-switch-Y6AMFFNK.ts → setup-switch-L54X5U5I.ts} +4 -4
- package/dist/chunks/{setup-wizard-5G426MOZ.ts → setup-wizard-LL6YMGUR.ts} +7 -3
- package/dist/chunks/{setup-wizard-5G426MOZ.ts.map → setup-wizard-LL6YMGUR.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-ITZ6Z4DE.ts → sync-inspection-SRU6HGGK.ts} +3 -3
- package/dist/chunks/{sync-operations-NMVKF7SE.ts → sync-operations-UGSCONZ7.ts} +2 -2
- package/dist/daemon/dist/cli.js +1 -1
- package/dist/daemon/dist/consent.js +134 -16
- package/dist/daemon/dist/engine/backends/git/git-backend.js +61 -30
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +142 -40
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +94 -26
- package/dist/daemon/dist/engine/ignore/ignore-source.js +1 -1
- package/dist/daemon/dist/engine/settings/config-file.js +1 -1
- package/dist/daemon/dist/engine/settings/config.js +71 -28
- package/dist/daemon/dist/engine/settings/settings-management.js +8 -2
- package/dist/daemon/dist/engine/snapshot/session-paths.js +7 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +37 -17
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +55 -13
- package/dist/daemon/dist/engine/sync/agent-plan.js +1 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +8 -1
- package/dist/daemon/dist/engine/sync/continuous-sync.js +32 -15
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +7 -4
- package/dist/daemon/dist/engine/sync/merge-journal.js +33 -14
- package/dist/daemon/dist/engine/sync/merged-sync.js +31 -39
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +17 -2
- package/dist/daemon/dist/engine/sync/session-push.js +20 -6
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +16 -3
- package/dist/daemon/dist/engine/sync/sync-mutations.js +75 -54
- package/dist/daemon/dist/engine/sync/sync-policy.js +28 -3
- package/dist/daemon/dist/engine/sync/sync-state.js +3 -8
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
- package/dist/daemon/dist/engine/ui/sync-format.js +23 -55
- package/dist/daemon/dist/engine/ui/transfer-review.js +3 -3
- package/dist/daemon/dist/engine-service.js +124 -27
- package/dist/daemon/dist/monitor.js +84 -32
- package/dist/daemon/dist/server.js +46 -5
- package/dist/daemon/dist/service-host.js +2 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +28 -25
- package/dist/index.ts.map +4 -4
- package/docs/tui-contract.md +1 -1
- package/package.json +3 -3
- package/skills/configure-pi-sync/SKILL.md +128 -74
- package/skills/configure-pi-sync/references/configuration.md +115 -45
- package/src/commands/command-execution.ts +12 -8
- package/src/commands/command-types.ts +1 -0
- package/src/daemon/pi-client.ts +4 -2
- package/src/settings/config.ts +1 -0
- package/src/sync/automatic-sync.ts +9 -2
- package/src/sync/setup-switch.ts +38 -15
- package/src/sync/startup-check.ts +7 -4
- package/src/ui/excluded-paths-ui.ts +2 -2
- package/src/ui/file-selection.ts +7 -2
- package/src/ui/ignore-file-guidance.ts +7 -0
- package/src/ui/ignore-file-ui.ts +28 -202
- package/src/ui/manager-state.ts +33 -18
- package/src/ui/manager-ui.ts +27 -18
- package/src/ui/merge-review.ts +28 -1
- package/src/ui/remote-selection-ui.ts +51 -24
- package/src/ui/settings-ui.ts +132 -81
- package/src/ui/setup/setup-actions.ts +16 -4
- package/src/ui/setup/setup-prompts.ts +55 -9
- package/src/ui/setup/setup-switcher.ts +24 -11
- package/src/ui/setup/webdav-ui.ts +1 -1
- package/src/ui/storage-connections-ui.ts +33 -11
- package/src/ui/sync-confirmation.ts +67 -48
- package/src/ui/sync-setups-ui.ts +24 -7
- package/dist/chunks/chunk-6PFZUEUG.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-GSQGBVKG.ts.map +0 -7
- package/dist/chunks/chunk-INECVQNR.ts.map +0 -7
- package/dist/chunks/chunk-NHFGAZEC.ts.map +0 -7
- package/dist/chunks/chunk-PWESMTH6.ts.map +0 -7
- package/dist/chunks/chunk-ZB3GNX3P.ts.map +0 -7
- package/dist/chunks/command-handler-6ATREPG7.ts.map +0 -7
- package/dist/chunks/file-selection-QR2KZVGD.ts.map +0 -7
- package/dist/chunks/manager-ui-AOFUNXAJ.ts.map +0 -7
- /package/dist/chunks/{chunk-GSCZ4VXV.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-MAOGTIAI.ts.map → conflict-review-JWEA7DPQ.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-MC6EQOQY.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{merge-review-SGDLMVS4.ts.map → merge-review-OQDXNTJU.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-4BTP2OJR.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-Y6AMFFNK.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-ITZ6Z4DE.ts.map → sync-inspection-SRU6HGGK.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-NMVKF7SE.ts.map → sync-operations-UGSCONZ7.ts.map} +0 -0
package/src/ui/manager-ui.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { loadConfig, loadSettingsConfig, syncCheckConfigFingerprint } from "../s
|
|
|
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 { ignoreFileSettingsAvailable } from "./ignore-file-ui.js";
|
|
8
9
|
import { showIgnoreMigrationPrompt } from "./ignore-migration-prompt.js";
|
|
9
10
|
import {
|
|
10
11
|
attentionMainMenuItems,
|
|
@@ -79,23 +80,29 @@ export async function showSyncManager(
|
|
|
79
80
|
>({
|
|
80
81
|
start: "main",
|
|
81
82
|
screens: {
|
|
82
|
-
main: ({ state }) =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
main: ({ state: { manager } }) => {
|
|
84
|
+
const [title = "Manage sync", ...lines] = manager.title.split("\n");
|
|
85
|
+
const setupName = ctx.mode === "tui" ? manager.configReview?.setupName : undefined;
|
|
86
|
+
const setup = setupName === undefined ? undefined : safeTerminalText(setupName);
|
|
87
|
+
const setupInHeading = setup !== undefined && lines[0] === `Current sync setup: ${setup}`;
|
|
88
|
+
return {
|
|
89
|
+
kind: "choice",
|
|
90
|
+
title: setupInHeading ? `${title} · ${setup}` : title,
|
|
91
|
+
lines: setupInHeading ? lines.slice(1) : lines,
|
|
92
|
+
items: menuItems(manager).map((item) => ({
|
|
93
|
+
id: item.id,
|
|
94
|
+
label: ctx.mode === "tui" && item.id === "sync" ? "Sync…" : item.label,
|
|
95
|
+
details: [item.description ?? "Review synced content."],
|
|
96
|
+
searchText: `${item.label} ${item.description ?? ""}`,
|
|
97
|
+
disabled: item.disabled,
|
|
98
|
+
disabledReason: item.disabledReason,
|
|
99
|
+
})),
|
|
100
|
+
action: "activate",
|
|
101
|
+
enableSearch: true,
|
|
102
|
+
viewportSize: 5,
|
|
103
|
+
hint: "close",
|
|
104
|
+
};
|
|
105
|
+
},
|
|
99
106
|
},
|
|
100
107
|
actions: {
|
|
101
108
|
activate: async (invocation) => {
|
|
@@ -373,7 +380,9 @@ export async function showSyncManager(
|
|
|
373
380
|
const describe = async (signal: AbortSignal) => {
|
|
374
381
|
const pendingAttention = options.getAttention?.();
|
|
375
382
|
const observation = options.getObservation?.();
|
|
376
|
-
const manager = await describeManagerState(signal, pendingAttention, undefined, observation)
|
|
383
|
+
const manager = await describeManagerState(signal, pendingAttention, undefined, observation, () =>
|
|
384
|
+
ignoreFileSettingsAvailable(ctx, signal),
|
|
385
|
+
);
|
|
377
386
|
if (signal.aborted || !isCurrent()) return manager;
|
|
378
387
|
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
379
388
|
if (
|
package/src/ui/merge-review.ts
CHANGED
|
@@ -23,6 +23,10 @@ export async function confirmMergeReview(
|
|
|
23
23
|
.map((line) => truncateToWidth(safeTerminalText(line), 100)),
|
|
24
24
|
"View details for the complete review.",
|
|
25
25
|
];
|
|
26
|
+
const tuiLines =
|
|
27
|
+
ctx.mode === "tui" && confirmationLabel === "apply reviewed transfer" && summaryLines?.join("\n") === content
|
|
28
|
+
? compactLegacyTransferSummary(lines)
|
|
29
|
+
: lines;
|
|
26
30
|
while (isCurrent() && !signal?.aborted) {
|
|
27
31
|
const choice: { value: "cancel" | "approve" | "details" } = { value: "cancel" };
|
|
28
32
|
const menu = defineMenu<undefined, "confirm", "choose", ReviewContext>({
|
|
@@ -53,7 +57,7 @@ export async function confirmMergeReview(
|
|
|
53
57
|
ctx.mode === "tui" && ctx.hasUI
|
|
54
58
|
? await runCustomInteraction<SyncConfirmationChoice, ReviewContext>(ctx, {
|
|
55
59
|
create: ({ tui, theme, keybindings, complete }) =>
|
|
56
|
-
createSyncConfirmation({ title, lines, confirmationLabel, tui, theme, keybindings, complete }),
|
|
60
|
+
createSyncConfirmation({ title, lines: tuiLines, confirmationLabel, tui, theme, keybindings, complete }),
|
|
57
61
|
signal,
|
|
58
62
|
isCurrent,
|
|
59
63
|
onError: () => {},
|
|
@@ -86,3 +90,26 @@ export async function confirmMergeReview(
|
|
|
86
90
|
}
|
|
87
91
|
return false;
|
|
88
92
|
}
|
|
93
|
+
|
|
94
|
+
function compactLegacyTransferSummary(lines: readonly string[]): string[] {
|
|
95
|
+
const result: string[] = [];
|
|
96
|
+
for (let index = 0; index < lines.length; index++) {
|
|
97
|
+
const line = lines[index] ?? "";
|
|
98
|
+
result.push(line);
|
|
99
|
+
const counts = /^Changes: (\d+) add · (\d+) update · (\d+) remove$/u.exec(line);
|
|
100
|
+
if (!counts) continue;
|
|
101
|
+
const expected = counts.slice(1).map(Number);
|
|
102
|
+
const actual = [0, 0, 0];
|
|
103
|
+
let side: string | undefined;
|
|
104
|
+
let end = index + 1;
|
|
105
|
+
for (; end < lines.length; end++) {
|
|
106
|
+
const row = /^(Add|Update|Remove) (locally|remotely): .+$/u.exec(lines[end] ?? "");
|
|
107
|
+
if (!row || (side && row[2] !== side)) break;
|
|
108
|
+
side = row[2];
|
|
109
|
+
const action = row[1] === "Add" ? 0 : row[1] === "Update" ? 1 : 2;
|
|
110
|
+
actual[action] = (actual[action] ?? 0) + 1;
|
|
111
|
+
}
|
|
112
|
+
if (actual.every((count, action) => count === expected[action])) index = end - 1;
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
3
3
|
import { createSyncBackend, type SyncBackendFactory } from "../backends/backend-factory.js";
|
|
4
4
|
import type { RemoteHead, SyncBackend } from "../backends/sync-backend.js";
|
|
5
|
-
import { loadConfig,
|
|
5
|
+
import { loadConfig, syncConfigReviewFingerprint, syncSettingsConfigFingerprint } from "../settings/config.js";
|
|
6
6
|
import { SyncSetupReviewChangedError, updateSyncSetup } from "../settings/settings-management.js";
|
|
7
7
|
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
8
8
|
import { sameSyncExclude } from "../sync/exclude-policy.js";
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
compareSyncInclude,
|
|
15
15
|
inspectRemoteSelection,
|
|
16
16
|
type RemoteSelectionDecision,
|
|
17
|
+
RemoteSelectionMismatchError,
|
|
17
18
|
type RemoteSelectionState,
|
|
18
19
|
sameSyncInclude,
|
|
19
20
|
syncDirectoryPolicyKey,
|
|
@@ -33,6 +34,7 @@ export interface RemoteSelectionReviewOptions {
|
|
|
33
34
|
decision?: RemoteSelectionDecision;
|
|
34
35
|
origin?: RemoteSelectionOrigin;
|
|
35
36
|
runRoute?: RunRoute;
|
|
37
|
+
readOnly?: boolean;
|
|
36
38
|
cancelLabel?: string;
|
|
37
39
|
/** The explicit mismatch is resolved or superseded; this does not imply file equality. */
|
|
38
40
|
onSelectionResolved?: () => void;
|
|
@@ -72,26 +74,33 @@ export async function showRemoteSelectionReview(
|
|
|
72
74
|
if (!inspected) return { kind: "stale" };
|
|
73
75
|
// A successful fresh read can supersede an old explicit mismatch without
|
|
74
76
|
// changing local settings. This is not user cancellation or proof of file equality.
|
|
75
|
-
if (inspected.kind === "empty" || inspected.state.kind !== "different") {
|
|
77
|
+
if (inspected.kind === "empty" || (inspected.kind === "selection" && inspected.state.kind !== "different")) {
|
|
76
78
|
options.onSelectionResolved?.();
|
|
77
79
|
}
|
|
78
80
|
if (inspected.kind === "empty") {
|
|
79
81
|
ctx.ui.notify("Remote storage has no snapshot or synced-content list yet.", "info");
|
|
80
82
|
return { kind: "back" };
|
|
81
83
|
}
|
|
82
|
-
if (inspected.
|
|
83
|
-
|
|
84
|
+
if (inspected.kind === "decision") {
|
|
85
|
+
decision = inspected.decision;
|
|
86
|
+
} else if (inspected.state.kind === "same") {
|
|
87
|
+
ctx.ui.notify(
|
|
88
|
+
inspected.state.ignorePolicyComparison === "match"
|
|
89
|
+
? "Remote ignore-file policy matches this device."
|
|
90
|
+
: "Remote synced content already matches this sync setup.",
|
|
91
|
+
"info",
|
|
92
|
+
);
|
|
84
93
|
return { kind: "back" };
|
|
85
|
-
}
|
|
86
|
-
if (inspected.state.kind === "legacy") {
|
|
94
|
+
} else if (inspected.state.kind === "legacy") {
|
|
87
95
|
if (ctx.mode !== "tui") {
|
|
88
96
|
ctx.ui.notify(formatLegacySummary(inspected.config, inspected.state.discovered), "info");
|
|
89
97
|
return { kind: "back" };
|
|
90
98
|
}
|
|
91
99
|
await showLegacyDiscovery(ctx, inspected.config, inspected.state.discovered, signal);
|
|
92
100
|
return signal?.aborted ? { kind: "stale" } : { kind: "back" };
|
|
101
|
+
} else {
|
|
102
|
+
decision = decisionFromState(inspected.config, inspected.state);
|
|
93
103
|
}
|
|
94
|
-
decision = decisionFromState(inspected.config, inspected.state);
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
if (ctx.mode !== "tui") {
|
|
@@ -132,6 +141,10 @@ export async function showRemoteSelectionReview(
|
|
|
132
141
|
ctx.ui.notify("Remote storage no longer has a snapshot or synced-content list.", "warning");
|
|
133
142
|
return { kind: "back" };
|
|
134
143
|
}
|
|
144
|
+
if (refreshed.kind === "decision") {
|
|
145
|
+
currentDecision = refreshed.decision;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
135
148
|
if (refreshed.state.kind !== "different") {
|
|
136
149
|
ctx.ui.notify(
|
|
137
150
|
refreshed.state.kind === "same"
|
|
@@ -162,7 +175,7 @@ async function showSelectionDifference(
|
|
|
162
175
|
runRoute: RunRoute | undefined,
|
|
163
176
|
sessionSignal: AbortSignal | undefined,
|
|
164
177
|
factory: SyncBackendFactory,
|
|
165
|
-
options: Pick<RemoteSelectionReviewOptions, "cancelLabel" | "onSelectionResolved" | "withStateAccess">,
|
|
178
|
+
options: Pick<RemoteSelectionReviewOptions, "readOnly" | "cancelLabel" | "onSelectionResolved" | "withStateAccess">,
|
|
166
179
|
validateOwner: () => void,
|
|
167
180
|
): Promise<DifferenceFlowResult> {
|
|
168
181
|
type Screen = "choice" | "review" | "saved";
|
|
@@ -195,7 +208,7 @@ async function showSelectionDifference(
|
|
|
195
208
|
: "Compare exact remote-only, device-only, and ordered lists.",
|
|
196
209
|
to: "review",
|
|
197
210
|
},
|
|
198
|
-
...(adoptionUnavailable(state.decision)
|
|
211
|
+
...(options.readOnly || adoptionUnavailable(state.decision)
|
|
199
212
|
? []
|
|
200
213
|
: [
|
|
201
214
|
{
|
|
@@ -205,7 +218,7 @@ async function showSelectionDifference(
|
|
|
205
218
|
action: "adopt" as const,
|
|
206
219
|
},
|
|
207
220
|
]),
|
|
208
|
-
...(!canPublishLocalPolicy(state.decision)
|
|
221
|
+
...(options.readOnly || !canPublishLocalPolicy(state.decision)
|
|
209
222
|
? []
|
|
210
223
|
: [
|
|
211
224
|
{
|
|
@@ -255,6 +268,7 @@ async function showSelectionDifference(
|
|
|
255
268
|
},
|
|
256
269
|
actions: {
|
|
257
270
|
adopt: async ({ state, signal: actionSignal }) => {
|
|
271
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
258
272
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
259
273
|
try {
|
|
260
274
|
const adoption = await runCancellableTask(
|
|
@@ -323,7 +337,7 @@ async function showSelectionDifference(
|
|
|
323
337
|
if (adoption.kind === "cancelled" || !adoption.value) return { kind: "stay" as const };
|
|
324
338
|
validateOwner();
|
|
325
339
|
options.onSelectionResolved?.();
|
|
326
|
-
continuationFingerprint =
|
|
340
|
+
continuationFingerprint = syncSettingsConfigFingerprint({
|
|
327
341
|
...adoption.value.config,
|
|
328
342
|
include: [...state.decision.remoteInclude],
|
|
329
343
|
exclude: adoptedExclude(state.decision),
|
|
@@ -345,6 +359,7 @@ async function showSelectionDifference(
|
|
|
345
359
|
}
|
|
346
360
|
},
|
|
347
361
|
keep: async ({ state, signal: actionSignal }) => {
|
|
362
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
348
363
|
if (!canPublishLocalPolicy(state.decision)) return { kind: "stay" as const };
|
|
349
364
|
if (!runRoute) {
|
|
350
365
|
ctx.ui.notify("The reviewed update-remote route is unavailable.", "error");
|
|
@@ -383,13 +398,14 @@ async function showSelectionDifference(
|
|
|
383
398
|
}
|
|
384
399
|
},
|
|
385
400
|
continue: async ({ state, signal: actionSignal }) => {
|
|
401
|
+
if (options.readOnly) return { kind: "rejected" };
|
|
386
402
|
if (!runRoute || !continuationFingerprint) return { kind: "stay" as const };
|
|
387
403
|
const signal = combineSignals(sessionSignal, actionSignal);
|
|
388
404
|
try {
|
|
389
405
|
const latest = await loadConfig(state.decision.setupName);
|
|
390
406
|
if (signal.aborted) return { kind: "close" as const };
|
|
391
407
|
validateOwner();
|
|
392
|
-
if (
|
|
408
|
+
if (syncSettingsConfigFingerprint(latest) !== continuationFingerprint) {
|
|
393
409
|
throw new StaleRemoteSelectionReviewError(
|
|
394
410
|
`Sync setup “${safeTerminalText(state.decision.setupName)}” changed after the remote content list was saved.`,
|
|
395
411
|
);
|
|
@@ -546,7 +562,7 @@ async function revalidateAndAdopt(
|
|
|
546
562
|
};
|
|
547
563
|
},
|
|
548
564
|
{
|
|
549
|
-
expectedConfigFingerprint:
|
|
565
|
+
expectedConfigFingerprint: syncSettingsConfigFingerprint(review.config),
|
|
550
566
|
expectedInclude: decision.localInclude,
|
|
551
567
|
upgradeExclude: adoptedExclude(decision) !== undefined,
|
|
552
568
|
signal,
|
|
@@ -563,6 +579,7 @@ async function inspectConfiguredRemoteSelection(
|
|
|
563
579
|
): Promise<
|
|
564
580
|
| { kind: "empty"; config: AnySyncConfig }
|
|
565
581
|
| { kind: "selection"; config: AnySyncConfig; state: RemoteSelectionState }
|
|
582
|
+
| { kind: "decision"; decision: RemoteSelectionDecision }
|
|
566
583
|
| undefined
|
|
567
584
|
> {
|
|
568
585
|
const config = await loadConfig(setupName);
|
|
@@ -576,14 +593,21 @@ async function inspectConfiguredRemoteSelection(
|
|
|
576
593
|
if (signal?.aborted) return undefined;
|
|
577
594
|
validateOwner();
|
|
578
595
|
if (!head) return { kind: "empty", config };
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
596
|
+
try {
|
|
597
|
+
const snapshot = await readSnapshotForHead(backend, head, signal, config);
|
|
598
|
+
if (signal?.aborted) return undefined;
|
|
599
|
+
validateOwner();
|
|
600
|
+
return {
|
|
601
|
+
kind: "selection",
|
|
602
|
+
config,
|
|
603
|
+
state: inspectRemoteSelection(config.include, snapshot, config.exclude, config),
|
|
604
|
+
};
|
|
605
|
+
} catch (error) {
|
|
606
|
+
if (signal?.aborted) return undefined;
|
|
607
|
+
validateOwner();
|
|
608
|
+
if (error instanceof RemoteSelectionMismatchError) return { kind: "decision", decision: error.decision };
|
|
609
|
+
throw error;
|
|
610
|
+
}
|
|
587
611
|
}
|
|
588
612
|
|
|
589
613
|
async function showLegacyDiscovery(
|
|
@@ -699,9 +723,12 @@ function selectionSummaryLines(decision: RemoteSelectionDecision) {
|
|
|
699
723
|
return [
|
|
700
724
|
`Sync setup: ${safeTerminalText(decision.setupName)}`,
|
|
701
725
|
adoptionUnavailable(decision) ?? "Nothing changed.",
|
|
702
|
-
decision.ignorePolicyComparison === "local-legacy-remote-ignore"
|
|
703
|
-
? "The remote uses an ignore policy
|
|
704
|
-
:
|
|
726
|
+
...(decision.ignorePolicyComparison === "local-legacy-remote-ignore"
|
|
727
|
+
? ["The remote uses an ignore-file policy; this device uses a legacy policy."]
|
|
728
|
+
: decision.ignorePolicyComparison === "local-ignore-remote-legacy"
|
|
729
|
+
? ["This device uses an ignore-file policy; the remote uses a legacy policy."]
|
|
730
|
+
: ["The ordered rules or session opt-in differ."]),
|
|
731
|
+
"No files or settings have changed.",
|
|
705
732
|
];
|
|
706
733
|
}
|
|
707
734
|
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|