@narumitw/pi-sync 0.66.0 → 0.67.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +11 -2
  3. package/dist/chunks/{chunk-BYVHABNR.ts → chunk-2MUAR5GH.ts} +2 -2
  4. package/dist/chunks/{chunk-5YOLQKNZ.ts → chunk-3CO7QIYB.ts} +14 -14
  5. package/dist/chunks/{chunk-DAZZ5BEJ.ts → chunk-3NS4PMCI.ts} +6 -2
  6. package/dist/chunks/{chunk-FI2F5JBS.ts → chunk-3Q3DMMID.ts} +8 -8
  7. package/dist/chunks/{chunk-BESRBKVO.ts → chunk-CQXGMESM.ts} +7 -7
  8. package/dist/chunks/{chunk-SZJOUVCL.ts → chunk-DGVZYS7T.ts} +5 -5
  9. package/dist/chunks/{chunk-WJQ4TGN5.ts → chunk-ECUCXF5Y.ts} +2 -2
  10. package/dist/chunks/{chunk-Z5JMOXJM.ts → chunk-JNTDIVP6.ts} +5 -5
  11. package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-PUSMSKIM.ts} +11 -2
  12. package/dist/chunks/chunk-PUSMSKIM.ts.map +7 -0
  13. package/dist/chunks/{chunk-ASU3GZPW.ts → chunk-W7DSN33J.ts} +6 -6
  14. package/dist/chunks/{chunk-JQ5BAWW2.ts → chunk-XPKHWTGT.ts} +77 -16
  15. package/dist/chunks/chunk-XPKHWTGT.ts.map +7 -0
  16. package/dist/chunks/{command-handler-44EFGPWH.ts → command-handler-H5X3BX5D.ts} +40 -32
  17. package/dist/chunks/command-handler-H5X3BX5D.ts.map +7 -0
  18. package/dist/chunks/config-P54GGMXY.ts +39 -0
  19. package/dist/chunks/{conflict-review-J7L7S4AR.ts → conflict-review-SSY37F4P.ts} +2 -2
  20. package/dist/chunks/{file-selection-XWACUTAH.ts → file-selection-GASCVN45.ts} +6 -6
  21. package/dist/chunks/{ignore-file-ui-OHFISFVC.ts → ignore-file-ui-UY2TEK4C.ts} +5 -5
  22. package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts → manager-result-dispatcher-PEVIGLOS.ts} +7 -7
  23. package/dist/chunks/{manager-ui-CVZLMXJ5.ts → manager-ui-R5XHYRXK.ts} +165 -34
  24. package/dist/chunks/manager-ui-R5XHYRXK.ts.map +7 -0
  25. package/dist/chunks/{merge-review-AAC674C6.ts → merge-review-C2KETZKY.ts} +3 -3
  26. package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts → remote-selection-ui-WFLX6MAJ.ts} +6 -6
  27. package/dist/chunks/{setup-switch-644T6KHG.ts → setup-switch-JZDFQPVW.ts} +4 -4
  28. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +7 -0
  29. package/dist/chunks/{setup-wizard-IEW56AZE.ts → setup-wizard-5OMFSFPJ.ts} +9 -9
  30. package/dist/chunks/{sync-inspection-NBBTSMKR.ts → sync-inspection-S2GHDBAD.ts} +5 -5
  31. package/dist/chunks/{sync-operations-AIEM2KL2.ts → sync-operations-LQ63CU2T.ts} +2 -2
  32. package/dist/daemon/dist/client.js +32 -18
  33. package/dist/daemon/dist/daemon-recovery.js +5 -3
  34. package/dist/daemon/dist/engine/ignore/adoption-journal.js +6 -3
  35. package/dist/daemon/dist/engine/ignore/ignore-edit.js +2 -2
  36. package/dist/daemon/dist/engine/ignore/ignore-settings.js +2 -1
  37. package/dist/daemon/dist/engine/settings/config-file.js +3 -0
  38. package/dist/daemon/dist/engine/settings/config.js +5 -5
  39. package/dist/daemon/dist/engine/settings/settings-management.js +6 -1
  40. package/dist/daemon/dist/engine/settings/settings-validation.js +21 -2
  41. package/dist/daemon/dist/engine/sync/continuous-errors.js +6 -0
  42. package/dist/daemon/dist/engine/sync/continuous-sync.js +4 -2
  43. package/dist/daemon/dist/engine/sync/ignore-adoption.js +17 -2
  44. package/dist/daemon/dist/engine/sync/merge-apply.js +18 -1
  45. package/dist/daemon/dist/engine/sync/merged-sync.js +36 -4
  46. package/dist/daemon/dist/engine/sync/push-review.js +33 -0
  47. package/dist/daemon/dist/engine/sync/sync-mutations.js +42 -49
  48. package/dist/daemon/dist/engine/sync/sync-rollback.js +16 -2
  49. package/dist/daemon/dist/engine/sync/transfer-freshness.js +3 -2
  50. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +92 -0
  51. package/dist/daemon/dist/engine-service.js +22 -6
  52. package/dist/daemon/dist/foreground-queue-outcome.js +4 -0
  53. package/dist/daemon/dist/server.js +2 -1
  54. package/dist/daemon/dist/service-host.js +7 -2
  55. package/dist/daemon/package.json +1 -1
  56. package/dist/index.ts +41 -32
  57. package/dist/index.ts.map +2 -2
  58. package/docs/daemon-migration.md +8 -0
  59. package/docs/tui-contract.md +4 -3
  60. package/package.json +2 -2
  61. package/skills/configure-pi-sync/SKILL.md +1 -1
  62. package/skills/configure-pi-sync/references/configuration.md +33 -6
  63. package/src/commands/command-execution.ts +10 -1
  64. package/src/commands/command-handler.ts +4 -0
  65. package/src/daemon/directional-recovery.ts +35 -5
  66. package/src/daemon/pi-client.ts +82 -12
  67. package/src/sync-extension.ts +17 -9
  68. package/src/ui/cancellable-operation.ts +13 -2
  69. package/src/ui/manager-state.ts +1 -0
  70. package/src/ui/manager-ui.ts +25 -4
  71. package/src/ui/settings-ui.ts +128 -4
  72. package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
  73. package/dist/chunks/chunk-JQ5BAWW2.ts.map +0 -7
  74. package/dist/chunks/command-handler-44EFGPWH.ts.map +0 -7
  75. package/dist/chunks/manager-ui-CVZLMXJ5.ts.map +0 -7
  76. /package/dist/chunks/{chunk-BYVHABNR.ts.map → chunk-2MUAR5GH.ts.map} +0 -0
  77. /package/dist/chunks/{chunk-5YOLQKNZ.ts.map → chunk-3CO7QIYB.ts.map} +0 -0
  78. /package/dist/chunks/{chunk-DAZZ5BEJ.ts.map → chunk-3NS4PMCI.ts.map} +0 -0
  79. /package/dist/chunks/{chunk-FI2F5JBS.ts.map → chunk-3Q3DMMID.ts.map} +0 -0
  80. /package/dist/chunks/{chunk-BESRBKVO.ts.map → chunk-CQXGMESM.ts.map} +0 -0
  81. /package/dist/chunks/{chunk-SZJOUVCL.ts.map → chunk-DGVZYS7T.ts.map} +0 -0
  82. /package/dist/chunks/{chunk-WJQ4TGN5.ts.map → chunk-ECUCXF5Y.ts.map} +0 -0
  83. /package/dist/chunks/{chunk-Z5JMOXJM.ts.map → chunk-JNTDIVP6.ts.map} +0 -0
  84. /package/dist/chunks/{chunk-ASU3GZPW.ts.map → chunk-W7DSN33J.ts.map} +0 -0
  85. /package/dist/chunks/{ignore-file-ui-OHFISFVC.ts.map → config-P54GGMXY.ts.map} +0 -0
  86. /package/dist/chunks/{conflict-review-J7L7S4AR.ts.map → conflict-review-SSY37F4P.ts.map} +0 -0
  87. /package/dist/chunks/{file-selection-XWACUTAH.ts.map → file-selection-GASCVN45.ts.map} +0 -0
  88. /package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts.map → ignore-file-ui-UY2TEK4C.ts.map} +0 -0
  89. /package/dist/chunks/{merge-review-AAC674C6.ts.map → manager-result-dispatcher-PEVIGLOS.ts.map} +0 -0
  90. /package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts.map → merge-review-C2KETZKY.ts.map} +0 -0
  91. /package/dist/chunks/{setup-switch-644T6KHG.ts.map → remote-selection-ui-WFLX6MAJ.ts.map} +0 -0
  92. /package/dist/chunks/{setup-wizard-IEW56AZE.ts.map → setup-wizard-5OMFSFPJ.ts.map} +0 -0
  93. /package/dist/chunks/{sync-inspection-NBBTSMKR.ts.map → sync-inspection-S2GHDBAD.ts.map} +0 -0
  94. /package/dist/chunks/{sync-operations-AIEM2KL2.ts.map → sync-operations-LQ63CU2T.ts.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  showDirectoryScope
5
- } from "./chunk-BYVHABNR.ts";
5
+ } from "./chunk-2MUAR5GH.ts";
6
6
  import {
7
7
  manualIgnoreFileGuidance
8
8
  } from "./chunk-EJDDRS6O.ts";
@@ -20,16 +20,16 @@ import {
20
20
  agentDir
21
21
  } from "./chunk-P4GI7LTT.ts";
22
22
  import "./chunk-ZO52JM4H.ts";
23
- import {
24
- loadSettingsConfig,
25
- syncCheckConfigFingerprint
26
- } from "./chunk-DAZZ5BEJ.ts";
27
23
  import {
28
24
  BUILT_IN_SYNC_ROOTS,
29
25
  isSafeCustomIncludePath,
30
26
  normalizeSyncInclude,
31
27
  syncIncludeSelection
32
28
  } from "./chunk-R3SAMXB6.ts";
29
+ import {
30
+ loadSettingsConfig,
31
+ syncCheckConfigFingerprint
32
+ } from "./chunk-3NS4PMCI.ts";
33
33
  import "./chunk-2JNFEZ3V.ts";
34
34
 
35
35
  // src/ui/file-selection.ts
@@ -300,4 +300,4 @@ function safeTerminalText(value) {
300
300
  export {
301
301
  showFileSelection
302
302
  };
303
- //# sourceMappingURL=file-selection-XWACUTAH.ts.map
303
+ //# sourceMappingURL=file-selection-GASCVN45.ts.map
@@ -4,13 +4,13 @@ import {
4
4
  ignoreFileSettingsAvailable,
5
5
  portableIgnoreRulesAvailable,
6
6
  showIgnoreFileAction
7
- } from "./chunk-Z5JMOXJM.ts";
7
+ } from "./chunk-JNTDIVP6.ts";
8
8
  import "./chunk-KNEUL4XN.ts";
9
- import "./chunk-AYGMIMCV.ts";
10
- import "./chunk-GELYN4UC.ts";
11
- import "./chunk-JQ5BAWW2.ts";
9
+ import "./chunk-XPKHWTGT.ts";
12
10
  import "./chunk-H7VOTY5N.ts";
11
+ import "./chunk-PUSMSKIM.ts";
13
12
  import "./chunk-6YKOHBSC.ts";
13
+ import "./chunk-GELYN4UC.ts";
14
14
  import "./chunk-R3SAMXB6.ts";
15
15
  import "./chunk-2JNFEZ3V.ts";
16
16
  export {
@@ -18,4 +18,4 @@ export {
18
18
  portableIgnoreRulesAvailable,
19
19
  showIgnoreFileAction
20
20
  };
21
- //# sourceMappingURL=ignore-file-ui-OHFISFVC.ts.map
21
+ //# sourceMappingURL=ignore-file-ui-UY2TEK4C.ts.map
@@ -2,19 +2,19 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  dispatchManagerResult
5
- } from "./chunk-BESRBKVO.ts";
6
- import "./chunk-5YOLQKNZ.ts";
5
+ } from "./chunk-CQXGMESM.ts";
6
+ import "./chunk-3CO7QIYB.ts";
7
7
  import "./chunk-UMPA5S7X.ts";
8
- import "./chunk-AYGMIMCV.ts";
8
+ import "./chunk-H7VOTY5N.ts";
9
+ import "./chunk-PUSMSKIM.ts";
10
+ import "./chunk-6YKOHBSC.ts";
9
11
  import "./chunk-NXWHPVXR.ts";
10
12
  import "./chunk-GELYN4UC.ts";
11
13
  import "./chunk-ZO52JM4H.ts";
12
- import "./chunk-DAZZ5BEJ.ts";
13
- import "./chunk-H7VOTY5N.ts";
14
- import "./chunk-6YKOHBSC.ts";
15
14
  import "./chunk-R3SAMXB6.ts";
15
+ import "./chunk-3NS4PMCI.ts";
16
16
  import "./chunk-2JNFEZ3V.ts";
17
17
  export {
18
18
  dispatchManagerResult
19
19
  };
20
- //# sourceMappingURL=manager-result-dispatcher-WXE2BAQO.ts.map
20
+ //# sourceMappingURL=manager-result-dispatcher-PEVIGLOS.ts.map
@@ -18,26 +18,26 @@ import {
18
18
  showEditS3Target,
19
19
  showEditWebDavStorageProfile,
20
20
  showEditWebDavTarget
21
- } from "./chunk-ASU3GZPW.ts";
21
+ } from "./chunk-W7DSN33J.ts";
22
22
  import {
23
23
  automaticSyncSummary
24
24
  } from "./chunk-ECYCNZOE.ts";
25
25
  import {
26
26
  ignoreFileSettingsAvailable,
27
27
  showIgnoreFileAction
28
- } from "./chunk-Z5JMOXJM.ts";
28
+ } from "./chunk-JNTDIVP6.ts";
29
29
  import "./chunk-KNEUL4XN.ts";
30
30
  import {
31
31
  dispatchManagerResult
32
- } from "./chunk-BESRBKVO.ts";
33
- import "./chunk-5YOLQKNZ.ts";
32
+ } from "./chunk-CQXGMESM.ts";
33
+ import "./chunk-3CO7QIYB.ts";
34
34
  import {
35
35
  SETUP_SWITCH_ACTION_OPTIONS,
36
36
  saveOnSwitch,
37
37
  setupSwitchActionFromLabel,
38
38
  setupSwitchActionLabel,
39
39
  useSyncSetup
40
- } from "./chunk-SZJOUVCL.ts";
40
+ } from "./chunk-DGVZYS7T.ts";
41
41
  import {
42
42
  isCloudflareR2Endpoint,
43
43
  normalizeS3Endpoint,
@@ -59,10 +59,16 @@ import {
59
59
  readStateForConfig,
60
60
  syncAttentionMatchesConfig,
61
61
  syncStateFingerprint
62
- } from "./chunk-FI2F5JBS.ts";
62
+ } from "./chunk-3Q3DMMID.ts";
63
+ import {
64
+ piDaemonClient
65
+ } from "./chunk-XPKHWTGT.ts";
63
66
  import {
64
67
  throwIfAborted
65
68
  } from "./chunk-UMPA5S7X.ts";
69
+ import {
70
+ configureSyncStatus
71
+ } from "./chunk-H7VOTY5N.ts";
66
72
  import {
67
73
  AUTOMATIC_SYNC_DESCRIPTION,
68
74
  STARTUP_TRANSFER_DESCRIPTION,
@@ -70,14 +76,17 @@ import {
70
76
  } from "./chunk-XUZV4OGI.ts";
71
77
  import {
72
78
  confirmMergeReview
73
- } from "./chunk-WJQ4TGN5.ts";
79
+ } from "./chunk-ECUCXF5Y.ts";
74
80
  import {
75
81
  runCancellableOperation
76
- } from "./chunk-AYGMIMCV.ts";
82
+ } from "./chunk-PUSMSKIM.ts";
83
+ import {
84
+ errorMessage
85
+ } from "./chunk-6YKOHBSC.ts";
77
86
  import {
78
87
  directoryScopeSummary,
79
88
  showExcludedPaths
80
- } from "./chunk-BYVHABNR.ts";
89
+ } from "./chunk-2MUAR5GH.ts";
81
90
  import {
82
91
  manualIgnoreFileGuidance
83
92
  } from "./chunk-EJDDRS6O.ts";
@@ -103,6 +112,12 @@ import {
103
112
  import {
104
113
  sameSyncExclude
105
114
  } from "./chunk-ZO52JM4H.ts";
115
+ import {
116
+ compareSyncInclude,
117
+ syncIncludeSelection,
118
+ syncSelectionHasContent,
119
+ syncSessionsSelected
120
+ } from "./chunk-R3SAMXB6.ts";
106
121
  import {
107
122
  configFromSettings,
108
123
  createSettingsConfigView,
@@ -112,22 +127,7 @@ import {
112
127
  loadSettingsConfig,
113
128
  syncCheckConfigFingerprint,
114
129
  syncConfigReviewIdentity
115
- } from "./chunk-DAZZ5BEJ.ts";
116
- import {
117
- piDaemonClient
118
- } from "./chunk-JQ5BAWW2.ts";
119
- import {
120
- configureSyncStatus
121
- } from "./chunk-H7VOTY5N.ts";
122
- import {
123
- errorMessage
124
- } from "./chunk-6YKOHBSC.ts";
125
- import {
126
- compareSyncInclude,
127
- syncIncludeSelection,
128
- syncSelectionHasContent,
129
- syncSessionsSelected
130
- } from "./chunk-R3SAMXB6.ts";
130
+ } from "./chunk-3NS4PMCI.ts";
131
131
  import {
132
132
  safeTerminalText
133
133
  } from "./chunk-2JNFEZ3V.ts";
@@ -224,7 +224,7 @@ function blockedSyncMenuItem(label, manager) {
224
224
  };
225
225
  }
226
226
  async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
227
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
227
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-WFLX6MAJ.ts");
228
228
  if (signal?.aborted) return "close";
229
229
  const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
230
230
  decision: attention.decision,
@@ -774,6 +774,7 @@ function backendStorageDescription(config) {
774
774
  }
775
775
 
776
776
  // src/ui/settings-ui.ts
777
+ import { isKeyRelease, Key, matchesKey } from "@earendil-works/pi-tui";
777
778
  import { defineMenu as defineMenu4, runMenu as runMenu4 } from "@narumitw/pi-tui-kit";
778
779
 
779
780
  // src/sync/local-fields.ts
@@ -1484,6 +1485,18 @@ async function showRemoveTarget(ctx, name, signal) {
1484
1485
  }
1485
1486
 
1486
1487
  // src/ui/settings-ui.ts
1488
+ var transferSizeLimits = [
1489
+ {
1490
+ field: "maxFileSizeMiB",
1491
+ label: "Max file size",
1492
+ description: "Block a transfer when an included file exceeds this uncompressed size."
1493
+ },
1494
+ {
1495
+ field: "maxDirectorySizeMiB",
1496
+ label: "Max directory size",
1497
+ description: "Block a transfer when a directory below the sync root exceeds this total uncompressed size, counting included files in its subdirectories too."
1498
+ }
1499
+ ];
1487
1500
  async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1488
1501
  let disposition = "back";
1489
1502
  const exitSettings = () => {
@@ -1516,6 +1529,10 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1516
1529
  [
1517
1530
  document === null ? "Could not read the active pi-sync settings file. Check file access or repair the JSON before reopening /sync." : `Edit pi-sync settings manually: ${safeTerminalText(settingsPath)}`,
1518
1531
  ...limited ? [IGNORE_SETUP_MANAGEMENT_LIMIT, ...ignoreSetupRecovery(settingsPath)] : [],
1532
+ ...!limited && config ? [
1533
+ "In the active entry in syncSetups, set sync.maxFileSizeMiB or sync.maxDirectorySizeMiB to a positive whole number of MiB with a safe byte count. Remove a field to turn that limit Off.",
1534
+ "A limit requires settings version 9. Upgrade all Pi Sync clients and daemons that share this agent directory before enabling a limit. Keep version 9 even if both limits are later Off."
1535
+ ] : [],
1519
1536
  ...!limited && config?.reservedIgnoreNames !== void 0 ? ["Use TUI Settings \u2192 Review automatic transfers to approve the current setup separately."] : [],
1520
1537
  ...config?.pathPolicy === "ignore-file" ? [manualIgnoreFileGuidance(config.ignoreFile ?? ".syncignore")] : config?.scope === "agent-directory" ? directoryScopeSummary(config) : []
1521
1538
  ].join("\n"),
@@ -1622,6 +1639,13 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1622
1639
  currentValue: `${state.localFields?.length ?? 0} fields \xB7 Edit`,
1623
1640
  action: "local-fields"
1624
1641
  },
1642
+ ...transferSizeLimits.map(({ field, label, description }) => ({
1643
+ id: field,
1644
+ label,
1645
+ description: `This setup: ${description} Also applies to automatic transfers. Saving starts no transfer.`,
1646
+ currentValue: transferSizeLimitLabel(state[field]),
1647
+ action: field
1648
+ })),
1625
1649
  {
1626
1650
  id: "storageLocation",
1627
1651
  label: "Storage location",
@@ -1738,6 +1762,8 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1738
1762
  })
1739
1763
  },
1740
1764
  actions: {
1765
+ maxFileSizeMiB: transferSizeLimitAction(transferSizeLimits[0]),
1766
+ maxDirectorySizeMiB: transferSizeLimitAction(transferSizeLimits[1]),
1741
1767
  "storage-location": async ({ signal: actionSignal }) => {
1742
1768
  const editorSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
1743
1769
  await showEditSyncSetupStorage(ctx, setupName, editorSignal);
@@ -1763,7 +1789,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1763
1789
  const partialSync = value === "Partial only" || value === "Merge + partial";
1764
1790
  if (!await ctx.ui.confirm(
1765
1791
  "Save content policy?",
1766
- `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and publishes snapshot version 7; upgrade older clients first." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
1792
+ `${previous.pathPolicy === "ignore-file" ? `Ignore-file policy keeps settings version ${previous.settingsVersion} and publishes snapshot version 7; upgrade older clients first.` : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5; older clients must refuse it." : "This explicitly upgrades settings to at least version 5; partial snapshots use version 3, or version 4 with exclusions, and older clients must refuse them."} Text/session merge is conservative. Partial sync preserves withheld versions and old baselines. Disabling does not clear unresolved groups or recovery evidence. Review a directional migration first if portable policy changes.`,
1767
1793
  { signal: mutationSignal }
1768
1794
  ))
1769
1795
  return { kind: "rejected" };
@@ -1833,7 +1859,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
1833
1859
  if (sameLocalFields(previous.localFields, fields)) return { kind: "stay" };
1834
1860
  const confirmed = await ctx.ui.confirm(
1835
1861
  "Save portable field policy?",
1836
- `${previous.pathPolicy === "ignore-file" ? "Ignore-file policy keeps settings version 8 and publishes snapshot version 7." : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
1862
+ `${previous.pathPolicy === "ignore-file" ? `Ignore-file policy keeps settings version ${previous.settingsVersion} and publishes snapshot version 7.` : previous.scope === "agent-directory" ? "Agent directory scope uses snapshot version 5." : "This opts into at least settings/snapshot version 4/2; exclude-enabled setups retain snapshot version 4."} Older clients must refuse unsupported formats. Future snapshots omit these fields, but old remote history is NOT erased. Review an explicit force push/pull migration before further sync. Removed rules can expose or replace local-only values.`,
1837
1863
  { signal: mutationSignal }
1838
1864
  );
1839
1865
  validate();
@@ -2046,7 +2072,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
2046
2072
  "remote-include": async ({ state, signal: actionSignal }) => {
2047
2073
  if (state.reservedIgnoreNames !== void 0 && !ignoreAvailable) return { kind: "rejected" };
2048
2074
  const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
2049
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
2075
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-WFLX6MAJ.ts");
2050
2076
  if (reviewSignal.aborted) return { kind: "rejected" };
2051
2077
  const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
2052
2078
  origin: "settings",
@@ -2097,6 +2123,81 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
2097
2123
  return result;
2098
2124
  };
2099
2125
  }
2126
+ function transferSizeLimitAction({ field, label }) {
2127
+ return async ({ state, signal: actionSignal }) => {
2128
+ const cancel = new AbortController();
2129
+ const mutationSignal = AbortSignal.any([actionSignal, cancel.signal, ...signal ? [signal] : []]);
2130
+ const validate = captureMutationOwner(ctx, mutationSignal);
2131
+ const rejected = { kind: "rejected" };
2132
+ const stay = { kind: "stay" };
2133
+ const setupLabel = safeTerminalText(setupName);
2134
+ let limit;
2135
+ try {
2136
+ const expectedConfigFingerprint = syncCheckConfigFingerprint(state);
2137
+ const active = await loadSettingsConfig();
2138
+ validate();
2139
+ if (active.setupName !== setupName || syncCheckConfigFingerprint(active) !== expectedConfigFingerprint) {
2140
+ throw new Error("Current sync setup changed while Settings was open; reopen Settings.");
2141
+ }
2142
+ const stop = ctx.ui.onTerminalInput((data) => {
2143
+ if (!isKeyRelease(data) && matchesKey(data, Key.ctrl("c"))) {
2144
+ cancel.abort();
2145
+ return { consume: true };
2146
+ }
2147
+ });
2148
+ try {
2149
+ const input = await ctx.ui.input(
2150
+ `${label} for \u201C${setupLabel}\u201D (current: ${transferSizeLimitLabel(state[field])})
2151
+ Enter Off or a positive whole number of MiB.`,
2152
+ void 0,
2153
+ { signal: mutationSignal }
2154
+ );
2155
+ validate();
2156
+ if (input === void 0) return rejected;
2157
+ limit = parseTransferSizeLimit(input);
2158
+ if (limit === state[field]) return stay;
2159
+ if (limit !== void 0 && active.settingsVersion < 9) {
2160
+ const confirmed = await ctx.ui.confirm(
2161
+ "Upgrade Pi Sync settings to version 9?",
2162
+ `${label} for \u201C${setupLabel}\u201D: ${transferSizeLimitLabel(limit)}. Older Pi Sync clients and daemons cannot read this settings file for any setup. Upgrade all processes that share this agent directory before continuing. Turning both limits Off later does not downgrade the file. Remote snapshots are unchanged.`,
2163
+ { signal: mutationSignal }
2164
+ );
2165
+ validate();
2166
+ if (!confirmed) return rejected;
2167
+ }
2168
+ } finally {
2169
+ stop();
2170
+ }
2171
+ validate();
2172
+ ctx.ui.notify("Saving Pi Sync setting\u2026", "info");
2173
+ await updateSyncSetup(
2174
+ setupName,
2175
+ (setup) => {
2176
+ validate();
2177
+ if (limit === void 0) delete setup.sync[field];
2178
+ else setup.sync[field] = limit;
2179
+ return setup;
2180
+ },
2181
+ { expectedActiveSetup: true, expectedConfigFingerprint, signal: mutationSignal }
2182
+ );
2183
+ } catch (error) {
2184
+ if (cancel.signal.aborted) return exitSettings();
2185
+ if (!mutationSignal.aborted && isCurrent()) notifySaveFailure(ctx, error);
2186
+ return rejected;
2187
+ }
2188
+ try {
2189
+ validate();
2190
+ const approval = state.reservedIgnoreNames !== void 0 && (startupTransferEnabled(state) || state.automatic && syncSessionsSelected(state)) ? " Use Review automatic transfers to approve this policy separately." : "";
2191
+ ctx.ui.notify(
2192
+ `Saved. ${label} for \u201C${setupLabel}\u201D: ${transferSizeLimitLabel(limit)}. Applies to subsequent transfers; no transfer started.${approval}`,
2193
+ "info"
2194
+ );
2195
+ } catch {
2196
+ return stay;
2197
+ }
2198
+ return stay;
2199
+ };
2200
+ }
2100
2201
  function ignoreAction(action) {
2101
2202
  return async ({ state, signal: actionSignal }) => {
2102
2203
  if (!ignoreAvailable || state.pathPolicy === "ignore-file" === (action === "migrate"))
@@ -2129,6 +2230,18 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
2129
2230
  });
2130
2231
  return disposition;
2131
2232
  }
2233
+ function transferSizeLimitLabel(limit) {
2234
+ return limit === void 0 ? "Off" : `${limit} MiB`;
2235
+ }
2236
+ function parseTransferSizeLimit(input) {
2237
+ const value = input.trim();
2238
+ if (value.toLowerCase() === "off") return void 0;
2239
+ const limit = Number(value);
2240
+ if (!/^[0-9]+$/u.test(value) || limit <= 0 || !Number.isSafeInteger(limit * 1048576)) {
2241
+ throw new Error("Enter Off or a positive whole number of MiB that fits in a safe byte count.");
2242
+ }
2243
+ return limit;
2244
+ }
2132
2245
  function notifySaveFailure(ctx, error) {
2133
2246
  ctx.ui.notify(
2134
2247
  `Pi Sync settings save failed: ${safeTerminalText(error instanceof Error ? error.message : String(error))}`,
@@ -2164,6 +2277,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2164
2277
  cancelledMessage: direction === "push" ? "Push cancellation requested." : "Pull cancellation requested.",
2165
2278
  target: review.setupName,
2166
2279
  directionalFingerprint: review.fingerprint,
2280
+ requirePendingAdoption: state.manager.recoveryPull,
2167
2281
  signal,
2168
2282
  isCurrent
2169
2283
  }
@@ -2216,7 +2330,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2216
2330
  if (!attention) {
2217
2331
  const observation = state.manager.observation;
2218
2332
  if (!observation) return { kind: "stay" };
2219
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-E4XZCQ7A.ts");
2333
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-WFLX6MAJ.ts");
2220
2334
  if (sessionSignal?.aborted) return { kind: "close" };
2221
2335
  const config = await loadConfig();
2222
2336
  if (sessionSignal?.aborted) return { kind: "close" };
@@ -2421,7 +2535,14 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2421
2535
  const activate = menu.actions[action];
2422
2536
  menu.actions[action] = async (invocation) => {
2423
2537
  validateOwner();
2424
- const { configReview, settingsReview } = invocation.state.manager;
2538
+ const { configReview, settingsReview, recoveryPull } = invocation.state.manager;
2539
+ if (action === "pull" && recoveryPull) {
2540
+ if (options.getPendingPullReview?.() !== configReview) {
2541
+ ctx.ui.notify("The original Pull is no longer available for automatic recovery.", "warning");
2542
+ return { kind: "stay" };
2543
+ }
2544
+ return activate(invocation);
2545
+ }
2425
2546
  const review = action === "settings" ? settingsReview ?? configReview : configReview;
2426
2547
  let current = false;
2427
2548
  try {
@@ -2462,8 +2583,18 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2462
2583
  title: "Pi Sync recovery required\nDaemon cleanup could not be confirmed. Stop the daemon before retrying a transfer.",
2463
2584
  actions: ["Stop daemon for recovery\u2026", "Help"]
2464
2585
  };
2586
+ const describeRecovery = () => {
2587
+ const configReview = options.getPendingPullReview?.();
2588
+ if (!configReview) return recovery;
2589
+ return {
2590
+ title: "Pi Sync recovery required\nPull can try to recover the daemon and review the pending transfer.",
2591
+ actions: ["Pull from remote", ...recovery.actions],
2592
+ configReview,
2593
+ recoveryPull: true
2594
+ };
2595
+ };
2465
2596
  const describe = async (signal) => {
2466
- if (options.needsDaemonRecovery?.()) return recovery;
2597
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
2467
2598
  const pendingAttention = options.getAttention?.();
2468
2599
  const observation = options.getObservation?.();
2469
2600
  const manager = await describeManagerState(
@@ -2474,7 +2605,7 @@ S3/R2 reads the latest pointer without writing. Git reads remote snapshots and c
2474
2605
  () => ignoreFileSettingsAvailable(ctx, signal)
2475
2606
  );
2476
2607
  if (signal.aborted || !isCurrent()) return manager;
2477
- if (options.needsDaemonRecovery?.()) return recovery;
2608
+ if (options.needsDaemonRecovery?.()) return describeRecovery();
2478
2609
  if (observation && options.getObservation?.() === observation && !manager.observation && !(manager.operation && operationBlocksChanges(manager.operation))) {
2479
2610
  options.onObservationInvalidated?.();
2480
2611
  }
@@ -2550,4 +2681,4 @@ function syncMainMenuItem(label) {
2550
2681
  export {
2551
2682
  showSyncManager
2552
2683
  };
2553
- //# sourceMappingURL=manager-ui-CVZLMXJ5.ts.map
2684
+ //# sourceMappingURL=manager-ui-R5XHYRXK.ts.map