@narumitw/pi-sync 0.67.2 → 0.68.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 +17 -0
- package/README.md +29 -49
- package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
- package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
- package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
- package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
- package/dist/chunks/{chunk-2MSJDLSM.ts → chunk-BCDBT4X3.ts} +7 -7
- package/dist/chunks/{chunk-GRXNUC6O.ts → chunk-FQKWGVMA.ts} +20 -54
- package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
- package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
- package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
- package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
- package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
- package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
- package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
- package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
- package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
- package/dist/chunks/{chunk-UF2HU2NM.ts → chunk-WCGLU526.ts} +39 -118
- package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{chunk-C3E75DXW.ts → chunk-YV2R5SJU.ts} +73 -85
- package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
- package/dist/chunks/{command-handler-HWRPH3K3.ts → command-handler-S6BRZMPW.ts} +117 -69
- package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
- package/dist/chunks/{conflict-review-OBBBSVQD.ts → conflict-review-3XMYDJIK.ts} +2 -2
- package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
- package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
- package/dist/chunks/{manager-ui-Z3B5ZTA6.ts → manager-ui-KHMCSLLV.ts} +114 -581
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
- package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
- package/dist/chunks/{remote-selection-ui-34WC7OFE.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
- package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
- package/dist/chunks/{setup-wizard-YOXLXLBY.ts → setup-wizard-2NRPR433.ts} +11 -16
- package/dist/chunks/{setup-wizard-YOXLXLBY.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-NIITROKS.ts → sync-inspection-QGM54YCM.ts} +5 -5
- package/dist/chunks/{sync-operations-FFI4ZZQL.ts → sync-operations-DTQMKVRQ.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -0
- package/dist/daemon/dist/build-version.js +24 -4
- package/dist/daemon/dist/cli.js +51 -67
- package/dist/daemon/dist/client-transport.js +15 -5
- package/dist/daemon/dist/client.js +2 -10
- package/dist/daemon/dist/consent.js +13 -126
- package/dist/daemon/dist/daemon-startup.js +135 -30
- package/dist/daemon/dist/daemon-status.js +56 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
- package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
- package/dist/daemon/dist/engine/settings/config.js +16 -149
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
- package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
- package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
- package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
- package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
- package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
- package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
- package/dist/daemon/dist/engine/sync/initialization.js +4 -15
- package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
- package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
- package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
- package/dist/daemon/dist/engine/sync/merged-sync.js +13 -70
- package/dist/daemon/dist/engine/sync/push-review.js +1 -16
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +26 -118
- package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
- package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
- package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
- package/dist/daemon/dist/engine-service.js +62 -205
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
- package/dist/daemon/dist/index.js +2 -0
- package/dist/daemon/dist/legacy-consent-guard.js +34 -0
- package/dist/daemon/dist/server.js +99 -11
- package/dist/daemon/dist/service-host.js +3 -9
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +49 -49
- package/dist/index.ts.map +3 -3
- package/docs/agent-continuous-hardening.md +2 -0
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +17 -15
- package/docs/tui-contract.md +4 -6
- package/package.json +2 -3
- package/skills/configure-pi-sync/SKILL.md +23 -78
- package/skills/configure-pi-sync/references/configuration.md +59 -76
- package/src/commands/command-execution.ts +15 -38
- package/src/commands/command-handler.ts +0 -4
- package/src/commands/command.ts +2 -1
- package/src/daemon/daemon-status-ui.ts +64 -0
- package/src/daemon/directional-recovery.ts +4 -33
- package/src/daemon/pi-client.ts +87 -94
- package/src/settings/config.ts +0 -1
- package/src/sync/setup-switch.ts +1 -4
- package/src/sync-extension.ts +14 -27
- package/src/ui/cancellable-operation.ts +2 -13
- package/src/ui/excluded-paths-ui.ts +1 -4
- package/src/ui/file-selection.ts +0 -5
- package/src/ui/manager-state.ts +12 -75
- package/src/ui/manager-ui.ts +7 -96
- package/src/ui/remote-selection-ui.ts +29 -130
- package/src/ui/settings-ui.ts +169 -388
- package/src/ui/setup/setup-actions.ts +4 -16
- package/src/ui/setup/setup-prompts.ts +12 -49
- package/src/ui/setup/setup-switcher.ts +8 -14
- package/src/ui/storage-connections-ui.ts +21 -32
- package/src/ui/sync-setups-ui.ts +27 -53
- package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
- package/dist/chunks/chunk-C3E75DXW.ts.map +0 -7
- package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
- package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
- package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
- package/dist/chunks/chunk-GRXNUC6O.ts.map +0 -7
- package/dist/chunks/chunk-I72HGZJJ.ts +0 -106
- package/dist/chunks/chunk-I72HGZJJ.ts.map +0 -7
- package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
- package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
- package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
- package/dist/chunks/chunk-UF2HU2NM.ts.map +0 -7
- package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
- package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
- package/dist/chunks/command-handler-HWRPH3K3.ts.map +0 -7
- package/dist/chunks/config-P54GGMXY.ts +0 -39
- package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
- package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
- package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
- package/dist/chunks/ignore-file-ui-5BWA6LBC.ts +0 -21
- package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +0 -7
- package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
- package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-34WC7OFE.ts.map +0 -7
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
- package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
- package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
- package/dist/daemon/dist/monitor.js +0 -344
- package/src/ui/agent-mode-setting.ts +0 -99
- package/src/ui/ignore-file-guidance.ts +0 -7
- package/src/ui/ignore-file-ui.ts +0 -105
- package/src/ui/ignore-migration-prompt.ts +0 -65
- package/src/ui/settings-review.ts +0 -26
- /package/dist/chunks/{chunk-2MSJDLSM.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
- /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
- /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-OBBBSVQD.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
- /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
- /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-5BWA6LBC.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-NIITROKS.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-FFI4ZZQL.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
package/src/ui/manager-state.ts
CHANGED
|
@@ -38,8 +38,6 @@ export interface ManagerDescription {
|
|
|
38
38
|
title: string;
|
|
39
39
|
actions: string[];
|
|
40
40
|
configReview?: { setupName: string; fingerprint: string };
|
|
41
|
-
recoveryPull?: true;
|
|
42
|
-
settingsReview?: { setupName: string; fingerprint: string };
|
|
43
41
|
operation?: OperationAvailability;
|
|
44
42
|
attention?: SyncAttentionState;
|
|
45
43
|
observation?: StartupObservation;
|
|
@@ -52,7 +50,6 @@ export async function describeManagerState(
|
|
|
52
50
|
attention?: SyncAttentionState,
|
|
53
51
|
inspectOperation: () => Promise<OperationAvailability> = inspectOperationAvailability,
|
|
54
52
|
observation?: StartupObservation,
|
|
55
|
-
canUseIgnoreSettings?: () => Promise<boolean>,
|
|
56
53
|
): Promise<ManagerDescription> {
|
|
57
54
|
signal?.throwIfAborted();
|
|
58
55
|
let document: LocalConfigDocument | undefined;
|
|
@@ -71,7 +68,7 @@ export async function describeManagerState(
|
|
|
71
68
|
`Error: ${safeTerminalText(errorMessage(error))}`,
|
|
72
69
|
...(document ? [`File: ${safeTerminalText(document.path)}`] : []),
|
|
73
70
|
"",
|
|
74
|
-
"
|
|
71
|
+
"Resolve the settings error, then reopen /sync.",
|
|
75
72
|
].join("\n"),
|
|
76
73
|
actions: ["Help"],
|
|
77
74
|
};
|
|
@@ -95,12 +92,7 @@ export async function describeManagerState(
|
|
|
95
92
|
actions: ["Sync setups…", "Storage connections…", "Help"],
|
|
96
93
|
};
|
|
97
94
|
}
|
|
98
|
-
let settingsConfig: AnySyncConfig | undefined;
|
|
99
95
|
try {
|
|
100
|
-
settingsConfig = view.metadata();
|
|
101
|
-
if (settingsConfig.reservedIgnoreNames && canUseIgnoreSettings && !(await canUseIgnoreSettings())) {
|
|
102
|
-
throw new Error("the connected daemon does not support ignore-file setups");
|
|
103
|
-
}
|
|
104
96
|
signal?.throwIfAborted();
|
|
105
97
|
const config = await view.observe(undefined, signal);
|
|
106
98
|
signal?.throwIfAborted();
|
|
@@ -150,25 +142,13 @@ export async function describeManagerState(
|
|
|
150
142
|
const canSwitch = !changesBlocked && (alternateUsable || (await hasAnotherSwitchableSetup(view, signal)));
|
|
151
143
|
signal?.throwIfAborted();
|
|
152
144
|
const mainActions: string[] = [...MAIN_MENU_ACTIONS];
|
|
153
|
-
if (config.agentMode && !noSyncedContent) mainActions.splice(1, 0, "Retry refused model result…");
|
|
154
145
|
if (canSwitch) mainActions.push("Switch sync setup");
|
|
155
146
|
if (syncState?.unresolved?.length) mainActions.unshift("Review unresolved conflicts");
|
|
156
|
-
const background = changesBlocked ? [] : await backgroundSummary(config);
|
|
157
|
-
signal?.throwIfAborted();
|
|
158
147
|
const ordinaryTitle = [
|
|
159
148
|
"Manage sync",
|
|
160
149
|
`Current sync setup: ${safeTerminalText(config.setupName)}`,
|
|
161
150
|
`Storage: ${backendStorageDescription(config)}`,
|
|
162
|
-
...(config.
|
|
163
|
-
? [
|
|
164
|
-
`Sync scope: Pi agent directory · ignore file: ${safeTerminalText(config.ignoreFile ?? ".syncignore")}`,
|
|
165
|
-
...(config.ignorePolicy?.matches(config.ignorePolicy.filename) === false
|
|
166
|
-
? ["New snapshots include this rule file and its comments in remote history."]
|
|
167
|
-
: []),
|
|
168
|
-
]
|
|
169
|
-
: config.scope
|
|
170
|
-
? ["Sync scope: Pi agent directory, with exclusions"]
|
|
171
|
-
: []),
|
|
151
|
+
...(config.scope ? ["Sync scope: Pi agent directory, with exclusions"] : []),
|
|
172
152
|
...(syncState?.unresolved?.length
|
|
173
153
|
? [`Unresolved: ${syncState.unresolved.length} dependency groups · review needed`]
|
|
174
154
|
: []),
|
|
@@ -177,26 +157,21 @@ export async function describeManagerState(
|
|
|
177
157
|
currentAttention.decision.setupName === config.setupName
|
|
178
158
|
? "Sync status: Review needed"
|
|
179
159
|
: `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
|
|
180
|
-
|
|
181
|
-
? "
|
|
182
|
-
:
|
|
183
|
-
?
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
: "Only the synced-content order differs."
|
|
188
|
-
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
160
|
+
attentionDirectoryPolicy
|
|
161
|
+
? "Sync scopes or directory rules differ."
|
|
162
|
+
: attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0
|
|
163
|
+
? attentionExclusionsDiffer
|
|
164
|
+
? "Synced-content exclusion rules differ."
|
|
165
|
+
: "Only the synced-content order differs."
|
|
166
|
+
: `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} · Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " · Exclusion rules differ." : ""}`,
|
|
189
167
|
]
|
|
190
168
|
: currentObservation
|
|
191
169
|
? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`]
|
|
192
170
|
: ["Remote status: Not checked"]),
|
|
193
171
|
`Last applied: ${lastAppliedSnapshot}`,
|
|
194
|
-
...(config.
|
|
195
|
-
? ["
|
|
196
|
-
:
|
|
197
|
-
? ["Automatic transfer permission: On · see Settings"]
|
|
198
|
-
: []),
|
|
199
|
-
...background,
|
|
172
|
+
...(config.automaticTransfer || (config.automatic && syncSessionsSelected(config))
|
|
173
|
+
? ["Automatic transfer permission: On · see Settings"]
|
|
174
|
+
: []),
|
|
200
175
|
...(noSyncedContent
|
|
201
176
|
? ["", "No included content is selected. Choose included content in Settings before syncing."]
|
|
202
177
|
: []),
|
|
@@ -205,7 +180,6 @@ export async function describeManagerState(
|
|
|
205
180
|
title: (changesBlocked ? ["Manage sync", ...operationStatusLines(operation)] : ordinaryTitle).join("\n"),
|
|
206
181
|
actions: operationActions(operation, noSyncedContent, canSwitch, mainActions),
|
|
207
182
|
configReview: { setupName: config.setupName, fingerprint: syncCheckConfigFingerprint(config) },
|
|
208
|
-
settingsReview: { setupName: settingsConfig.setupName, fingerprint: syncCheckConfigFingerprint(settingsConfig) },
|
|
209
183
|
operation,
|
|
210
184
|
...(currentObservation ? { observation: currentObservation } : {}),
|
|
211
185
|
...(currentAttention
|
|
@@ -218,20 +192,6 @@ export async function describeManagerState(
|
|
|
218
192
|
};
|
|
219
193
|
} catch (error) {
|
|
220
194
|
signal?.throwIfAborted();
|
|
221
|
-
if (settingsConfig?.reservedIgnoreNames !== undefined) {
|
|
222
|
-
return {
|
|
223
|
-
title: [
|
|
224
|
-
"Manage sync",
|
|
225
|
-
`Current sync setup: ${safeTerminalText(settingsConfig.setupName)}`,
|
|
226
|
-
`Transfers are unavailable: ${safeTerminalText(errorMessage(error))}`,
|
|
227
|
-
].join("\n"),
|
|
228
|
-
actions: ["Settings", "Sync setups…", "Storage connections…", "Help"],
|
|
229
|
-
settingsReview: {
|
|
230
|
-
setupName: settingsConfig.setupName,
|
|
231
|
-
fingerprint: syncCheckConfigFingerprint(settingsConfig),
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
195
|
return {
|
|
236
196
|
title: [
|
|
237
197
|
"Manage sync",
|
|
@@ -248,29 +208,6 @@ export async function describeManagerState(
|
|
|
248
208
|
}
|
|
249
209
|
}
|
|
250
210
|
|
|
251
|
-
async function backgroundSummary(config: AnySyncConfig): Promise<string[]> {
|
|
252
|
-
if (!config.continuous) return [];
|
|
253
|
-
if (!config.agentMode) return ["Background sync: Paused · enable Autonomous sync"];
|
|
254
|
-
try {
|
|
255
|
-
const { continuousBinding, readContinuousPrivateDocument } = await import("../sync/continuous-storage.js");
|
|
256
|
-
const recordApi: typeof import("../sync/continuous-record.js") = await import("../sync/continuous-record.js");
|
|
257
|
-
const binding = await continuousBinding(config);
|
|
258
|
-
const document = await readContinuousPrivateDocument(`${binding}.json`);
|
|
259
|
-
if (!document) return ["Background sync: Enabled · not yet observed"];
|
|
260
|
-
recordApi.validateContinuousRecord(document.value, binding);
|
|
261
|
-
const record = document.value;
|
|
262
|
-
const phases = { waiting: "Waiting", syncing: "Syncing", retry: "Retry", blocked: "Blocked" };
|
|
263
|
-
return [
|
|
264
|
-
`Background sync (recorded): ${phases[record.phase]}${record.error ? ` · ${record.error}` : ""}`,
|
|
265
|
-
...(record.transferred === undefined
|
|
266
|
-
? []
|
|
267
|
-
: [`Last background transfer: Success · ${new Date(record.transferred).toISOString()}`]),
|
|
268
|
-
];
|
|
269
|
-
} catch {
|
|
270
|
-
return ["Background sync: Unknown · open Diagnostics"];
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
211
|
function operationActions(
|
|
275
212
|
operation: OperationAvailability,
|
|
276
213
|
noSyncedContent: boolean,
|
package/src/ui/manager-ui.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { Component } from "@earendil-works/pi-tui";
|
|
3
|
-
import { type ActionMenuItem, defineMenu, type MenuDefinition,
|
|
3
|
+
import { type ActionMenuItem, defineMenu, type MenuDefinition, runMenu } from "@narumitw/pi-tui-kit";
|
|
4
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 { ignoreFileSettingsAvailable } from "./ignore-file-ui.js";
|
|
9
|
-
import { showIgnoreMigrationPrompt } from "./ignore-migration-prompt.js";
|
|
10
8
|
import {
|
|
11
9
|
attentionMainMenuItems,
|
|
12
10
|
blockedSyncMenuItem,
|
|
@@ -29,7 +27,6 @@ export async function showSyncManager(
|
|
|
29
27
|
sessionSignal?: AbortSignal,
|
|
30
28
|
options: SyncManagerAttentionOptions & {
|
|
31
29
|
needsDaemonRecovery?: () => boolean;
|
|
32
|
-
getPendingPullReview?: () => { setupName: string; fingerprint: string } | undefined;
|
|
33
30
|
} = {},
|
|
34
31
|
): Promise<void> {
|
|
35
32
|
if (!ctx.hasUI) {
|
|
@@ -49,7 +46,6 @@ export async function showSyncManager(
|
|
|
49
46
|
type Action =
|
|
50
47
|
| "activate"
|
|
51
48
|
| "review-attention"
|
|
52
|
-
| "retry-refusal"
|
|
53
49
|
| "sync"
|
|
54
50
|
| "switch"
|
|
55
51
|
| "settings"
|
|
@@ -83,7 +79,6 @@ export async function showSyncManager(
|
|
|
83
79
|
cancelledMessage: direction === "push" ? "Push cancellation requested." : "Pull cancellation requested.",
|
|
84
80
|
target: review.setupName,
|
|
85
81
|
directionalFingerprint: review.fingerprint,
|
|
86
|
-
requirePendingAdoption: state.manager.recoveryPull,
|
|
87
82
|
signal,
|
|
88
83
|
isCurrent,
|
|
89
84
|
},
|
|
@@ -190,35 +185,13 @@ export async function showSyncManager(
|
|
|
190
185
|
const disposition = await dispatchManagerResult(ctx, result, "sync", runRoute, sessionSignal);
|
|
191
186
|
return disposition.kind === "close" ? { kind: "close" } : { kind: "stay" };
|
|
192
187
|
},
|
|
193
|
-
"retry-refusal": async ({ state, signal: actionSignal }) => {
|
|
194
|
-
const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
|
|
195
|
-
const validate = captureMutationOwner(ctx, signal);
|
|
196
|
-
validate();
|
|
197
|
-
const retryRoute: RunRoute = (route, operationSignal, onCommit, target, onDialog) =>
|
|
198
|
-
runRoute(route, operationSignal, onCommit, target, onDialog, true);
|
|
199
|
-
const result = await runCancellableOperation(ctx, "Checking cached refusal…", "sync", retryRoute, {
|
|
200
|
-
commitAware: true,
|
|
201
|
-
cancelAcrossDialogs: true,
|
|
202
|
-
signal,
|
|
203
|
-
target: state.manager.configReview?.setupName,
|
|
204
|
-
cancelledMessage: "Model retry cancelled. Submitted requests and committed writes cannot be undone.",
|
|
205
|
-
});
|
|
206
|
-
if (signal.aborted) return { kind: "close" };
|
|
207
|
-
validate();
|
|
208
|
-
if (result.kind === "decision-required" || result.kind === "remote-selection-required")
|
|
209
|
-
ctx.ui.notify(
|
|
210
|
-
"Model retry needs an established source and matching synced content. Use Sync now to review changed selection or recovery before retrying.",
|
|
211
|
-
"warning",
|
|
212
|
-
);
|
|
213
|
-
return { kind: result.kind === "closed" ? "close" : "stay" };
|
|
214
|
-
},
|
|
215
188
|
switch: async () => {
|
|
216
189
|
const result = await showSetupSwitcher(ctx, runRoute, undefined, sessionSignal);
|
|
217
190
|
return result === "pull-attempted" || result === "closed" ? { kind: "close" } : { kind: "stay" };
|
|
218
191
|
},
|
|
219
192
|
settings: async ({ state, signal: actionSignal }) => {
|
|
220
193
|
const signal = sessionSignal ? AbortSignal.any([sessionSignal, actionSignal]) : actionSignal;
|
|
221
|
-
const review = state.manager.
|
|
194
|
+
const review = state.manager.configReview;
|
|
222
195
|
const result = await showSyncSettings(ctx, runRoute, signal, review?.setupName);
|
|
223
196
|
return { kind: result === "exit" ? "close" : "stay" };
|
|
224
197
|
},
|
|
@@ -261,30 +234,6 @@ export async function showSyncManager(
|
|
|
261
234
|
const validate = captureMutationOwner(ctx, signal);
|
|
262
235
|
const config = await loadConfig(state.manager.configReview?.setupName);
|
|
263
236
|
validate();
|
|
264
|
-
if (config.continuous) {
|
|
265
|
-
const { continuousStatusLines } = await import("../sync/continuous-record.js");
|
|
266
|
-
validate();
|
|
267
|
-
const lines = await continuousStatusLines(config);
|
|
268
|
-
validate();
|
|
269
|
-
const review = await runDocumentReview(ctx, {
|
|
270
|
-
title: "Sync diagnostics",
|
|
271
|
-
lines: [`Setup: ${safeTerminalText(config.setupName)} · local observations only`],
|
|
272
|
-
content: lines.join("\n"),
|
|
273
|
-
confirmation: { label: "Continue to backend checks…" },
|
|
274
|
-
hint: "back",
|
|
275
|
-
signal,
|
|
276
|
-
isCurrent,
|
|
277
|
-
});
|
|
278
|
-
validate();
|
|
279
|
-
if (review.kind === "cancelled") return { kind: review.reason === "close" ? "close" : "stay" };
|
|
280
|
-
if (review.kind !== "confirmed") return { kind: "stay" };
|
|
281
|
-
const current = await loadConfig();
|
|
282
|
-
validate();
|
|
283
|
-
if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(current)) {
|
|
284
|
-
ctx.ui.notify("Setup changed during diagnostics review; reopen Diagnostics.", "warning");
|
|
285
|
-
return { kind: "stay" };
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
237
|
const confirmed = await ctx.ui.confirm(
|
|
289
238
|
"Run diagnostics?",
|
|
290
239
|
`Setup: ${safeTerminalText(config.setupName)}\nStorage: ${backendStorageDescription(config)}\nS3/R2 reads the latest pointer without writing. Git reads remote snapshots and checks its cache. WebDAV probes conditional writes and cleanup, and can repair a missing history entry. Possible-secret checks still run. This is not the read-only Check remote status action.`,
|
|
@@ -338,7 +287,6 @@ export async function showSyncManager(
|
|
|
338
287
|
for (const action of [
|
|
339
288
|
"review-attention",
|
|
340
289
|
"sync",
|
|
341
|
-
"retry-refusal",
|
|
342
290
|
"settings",
|
|
343
291
|
"pull",
|
|
344
292
|
"push",
|
|
@@ -351,15 +299,7 @@ export async function showSyncManager(
|
|
|
351
299
|
const activate = menu.actions[action];
|
|
352
300
|
menu.actions[action] = async (invocation) => {
|
|
353
301
|
validateOwner();
|
|
354
|
-
const
|
|
355
|
-
if (action === "pull" && recoveryPull) {
|
|
356
|
-
if (options.getPendingPullReview?.() !== configReview) {
|
|
357
|
-
ctx.ui.notify("The original Pull is no longer available for automatic recovery.", "warning");
|
|
358
|
-
return { kind: "stay" };
|
|
359
|
-
}
|
|
360
|
-
return activate(invocation);
|
|
361
|
-
}
|
|
362
|
-
const review = action === "settings" ? (settingsReview ?? configReview) : configReview;
|
|
302
|
+
const review = invocation.state.manager.configReview;
|
|
363
303
|
let current = false;
|
|
364
304
|
try {
|
|
365
305
|
const config = await (action === "settings" ? loadSettingsConfig() : loadConfig());
|
|
@@ -397,31 +337,18 @@ export async function showSyncManager(
|
|
|
397
337
|
}, customOptions),
|
|
398
338
|
},
|
|
399
339
|
};
|
|
400
|
-
let firstOpen = true;
|
|
401
340
|
const recovery: State["manager"] = {
|
|
402
341
|
title:
|
|
403
342
|
"Pi Sync recovery required\nDaemon cleanup could not be confirmed. Stop the daemon before retrying a transfer.",
|
|
404
343
|
actions: ["Stop daemon for recovery…", "Help"],
|
|
405
344
|
};
|
|
406
|
-
const describeRecovery = (): State["manager"] => {
|
|
407
|
-
const configReview = options.getPendingPullReview?.();
|
|
408
|
-
if (!configReview) return recovery;
|
|
409
|
-
return {
|
|
410
|
-
title: "Pi Sync recovery required\nPull can try to recover the daemon and review the pending transfer.",
|
|
411
|
-
actions: ["Pull from remote", ...recovery.actions],
|
|
412
|
-
configReview,
|
|
413
|
-
recoveryPull: true,
|
|
414
|
-
};
|
|
415
|
-
};
|
|
416
345
|
const describe = async (signal: AbortSignal) => {
|
|
417
|
-
if (options.needsDaemonRecovery?.()) return
|
|
346
|
+
if (options.needsDaemonRecovery?.()) return recovery;
|
|
418
347
|
const pendingAttention = options.getAttention?.();
|
|
419
348
|
const observation = options.getObservation?.();
|
|
420
|
-
const manager = await describeManagerState(signal, pendingAttention, undefined, observation
|
|
421
|
-
ignoreFileSettingsAvailable(ctx, signal),
|
|
422
|
-
);
|
|
349
|
+
const manager = await describeManagerState(signal, pendingAttention, undefined, observation);
|
|
423
350
|
if (signal.aborted || !isCurrent()) return manager;
|
|
424
|
-
if (options.needsDaemonRecovery?.()) return
|
|
351
|
+
if (options.needsDaemonRecovery?.()) return recovery;
|
|
425
352
|
// A busy operation suppresses baseline reads, not the stored check-time hint.
|
|
426
353
|
if (
|
|
427
354
|
observation &&
|
|
@@ -437,20 +364,7 @@ export async function showSyncManager(
|
|
|
437
364
|
return manager;
|
|
438
365
|
};
|
|
439
366
|
await runMenu(menuContext, menu, {
|
|
440
|
-
getState: async ({ signal }) => {
|
|
441
|
-
const offerOnOpen = firstOpen;
|
|
442
|
-
firstOpen = false;
|
|
443
|
-
let manager = await describe(signal);
|
|
444
|
-
if (
|
|
445
|
-
offerOnOpen &&
|
|
446
|
-
manager.operation?.kind === "free" &&
|
|
447
|
-
manager.configReview &&
|
|
448
|
-
(await showIgnoreMigrationPrompt(ctx, manager.configReview.setupName, signal, isCurrent))
|
|
449
|
-
) {
|
|
450
|
-
if (!signal.aborted && isCurrent()) manager = await describe(signal);
|
|
451
|
-
}
|
|
452
|
-
return { manager };
|
|
453
|
-
},
|
|
367
|
+
getState: async ({ signal }) => ({ manager: await describe(signal) }),
|
|
454
368
|
signal: sessionSignal,
|
|
455
369
|
isCurrent,
|
|
456
370
|
});
|
|
@@ -461,7 +375,6 @@ function syncMainMenuItem(
|
|
|
461
375
|
): ActionMenuItem<
|
|
462
376
|
"main",
|
|
463
377
|
| "sync"
|
|
464
|
-
| "retry-refusal"
|
|
465
378
|
| "pull"
|
|
466
379
|
| "push"
|
|
467
380
|
| "diff"
|
|
@@ -481,7 +394,6 @@ function syncMainMenuItem(
|
|
|
481
394
|
> {
|
|
482
395
|
const actions = {
|
|
483
396
|
"Sync now": "sync",
|
|
484
|
-
"Retry refused model result…": "retry-refusal",
|
|
485
397
|
"Pull from remote": "pull",
|
|
486
398
|
"Push to remote": "push",
|
|
487
399
|
"View differences": "diff",
|
|
@@ -508,7 +420,6 @@ function syncMainMenuItem(
|
|
|
508
420
|
action,
|
|
509
421
|
description: {
|
|
510
422
|
sync: "Merge changes on both sides.",
|
|
511
|
-
"retry-refusal": "Retry model; may incur costs.",
|
|
512
423
|
pull: "Remote → this device; replaces conflicting local files.",
|
|
513
424
|
push: "This device → remote; replaces conflicting remote files.",
|
|
514
425
|
diff: "Inspect changes; no transfer.",
|