@narumitw/pi-sync 0.60.0 → 0.60.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @narumitw/pi-sync
2
2
 
3
+ ## 0.60.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8482c1f: Simplify the sync manager into a searchable action palette with five visible choices, selected-action help, a compact review widget, and on-demand continuous diagnostics. Keep transfer authorization, safety reviews, and existing command routes unchanged.
8
+
3
9
  ## 0.60.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -70,26 +70,25 @@ WebDAV and R2/S3 store `latest.json`, `history.json`, and `snapshots/` directly
70
70
 
71
71
  ## 🧭 Manager, conflicts, and recovery
72
72
 
73
- The `/sync` manager shows local state without contacting remote storage:
73
+ The `/sync` manager opens a searchable action palette in TUI mode, with up to five visible choices and help for only the selected action. Its compact summary uses local state without contacting remote storage:
74
74
 
75
75
  ```text
76
76
  Current sync setup: home
77
77
  Storage: Cloudflare R2 · r2 · personal-pi
78
- Included: 5 built-in groups · 0 extra files · Sessions off
79
- Automatic sync: On (startup check; shutdown pushes selected content if sessions included)
80
78
  Remote status: Not checked
79
+ Last applied: Never synced
81
80
  ```
82
81
 
83
- Use **Sync now** for bidirectional merging, or **Pull from remote…** and **Push to remote…** for reviewed directional transfers. **Settings**, **History**, and **Diagnostics** are also directly available. Switching appears only when multiple valid setups exist; review and access-recovery actions appear when needed. Pull and Push do not implicitly force overwrites.
82
+ Use **Sync…** (**Sync now** in RPC) for bidirectional merging, or **Pull from remote…** and **Push to remote…** for reviewed directional transfers. Type to filter actions; navigation scrolls the list. **Settings**, **History**, and **Diagnostics** remain directly available. Switching appears only when multiple valid setups exist; review and access-recovery actions appear when needed. Pull and Push do not implicitly force overwrites. The palette does not change transfer authorization: Autonomous sync can still apply eligible transfers without another confirmation.
84
83
 
85
- The main summary separates current state from actions and uses local state and cached check-time observations, not a fresh remote comparison. Setup-specific actions stay bound to the displayed setup; if its configuration changes while the menu is open, review the refreshed setup before continuing. Choose **Check remote status** for a fresh read/check or **View differences** for file differences; `/sync status`, `/sync diff`, and `/sync help` remain available. Last applied shows a compact snapshot ID and states when application time is unavailable; History retains full IDs.
84
+ The summary distinguishes cached observations, recorded background state, and the last successful background transfer; none proves current remote equality. Missing or invalid background evidence is not shown as Waiting. Automatic-transfer permissions and possible AI costs remain visible when enabled; detailed preferences stay in Settings. Setup-specific actions stay bound to the displayed setup; if its configuration changes while the menu is open, review the refreshed setup before continuing. Choose **Check remote status** for a fresh check or **View differences** for file differences; `/sync status`, `/sync diff`, and `/sync help` remain available. Last applied shows a compact snapshot ID and states when application time is unavailable; History retains full IDs.
86
85
 
87
86
  After Pi Sync detects an included-content mismatch, the manager shows **Sync status: Review needed** and puts **Review synced content (recommended)** first.
88
87
  **Sync now** remains unavailable until you review the mismatch.
89
88
  Opening the manager does not make another remote request.
90
89
  **Settings** opens **Pi Sync Settings** directly: one searchable flat list with 17 rows and no category navigation or headings. **Included paths**, **Excluded paths**, and **Compare included paths** keep content policy together; comparison covers include/exclude rules, not file contents. **Storage location** edits only the current setup's bucket, branch, or path; it does not change the connection or included content. **Manage sync setups** and **Manage storage connections** open the existing catalogs. Connections hold reusable server addresses and sign-in details, and edits show every affected setup. Make another setup current before changing its preferences. Each description identifies the setup, device-wide, or shared-connection scope. Simple preferences report saving and durable save results; Back does not undo saved changes. Complex editors and risky changes retain their reviews. RPC reports the manual settings path and preserves catalog management without opening the TUI preference editor.
91
90
 
92
- **Diagnostics** (also `/sync doctor`) reports configuration and backend-specific access checks. S3/R2 performs a read-only request: success does not prove write access or snapshot validity, and an ambiguous 404 does not prove a bucket is missing. Check the indicated credentials, address, bucket, or path before retrying. Git checks remote reads and the local cache, not write access. WebDAV uses an isolated write/cleanup probe and repairs the active snapshot's history entry if missing. **History** opens the snapshot list directly for reviewed rollback. Recorded unresolved groups have a separate **Review unresolved conflicts** action.
91
+ With Continuous sync configured, **Diagnostics** first opens a scrollable local report containing scheduler ownership, request limits, accounting, and recovery guidance. Back returns without running backend checks; continuing retains a separate backend-check confirmation. RPC presents bounded report pages. `/sync doctor` remains the direct configuration and backend-check route. S3/R2 performs a read-only request: success does not prove write access or snapshot validity, and an ambiguous 404 does not prove a bucket is missing. Check the indicated credentials, address, bucket, or path before retrying. Git checks remote reads and the local cache, not write access. WebDAV uses an isolated write/cleanup probe and repairs the active snapshot's history entry if missing. **History** opens the snapshot list directly for reviewed rollback. Recorded unresolved groups have a separate **Review unresolved conflicts** action.
93
92
 
94
93
  On secondary menus, **Back** and Escape return to the previous screen. In setup inputs and save reviews, cancellation (including Ctrl+C) discards the current unsaved draft and returns to its owning menu. Session replacement or shutdown closes the owning flow.
95
94
  Specialized operation and masked-credential prompts show the effective cancellation bindings and keep Ctrl+C as a hard-cancel input when Back is remapped.
@@ -152,7 +151,7 @@ Then choose one reviewed direction:
152
151
  Cancelling a preparation or confirmation returns to conflict resolution with no side effects.
153
152
  Back returns to the sync manager, and Ctrl+C closes the complete flow.
154
153
 
155
- Startup checks never open a dialog. While checking, TUI and RPC status show **sync ...**. With a sync baseline and no content-list mismatch, they use **sync ⇡** for local changes to push and **sync ⇣** for remote changes to pull. Review conditions use **sync ⇕**; in TUI, a persistent widget above the editor also identifies both sides changing, first sync with an existing remote snapshot, a differing content list (including order-only differences), or a missing remote snapshot despite an existing baseline. Both sides changing is a reason to review, not a confirmed file conflict.
154
+ Startup checks never open a dialog. While checking, TUI and RPC status show **sync ...**. With a sync baseline and no content-list mismatch, they use **sync ⇡** for local changes to push and **sync ⇣** for remote changes to pull. Review conditions use **sync ⇕**; in TUI, a compact widget shows **Sync · Needs review** and one line directing you to `/sync` for the named setup. The manager retains the reason: both sides changed, first sync with an existing remote snapshot, a differing content list (including order-only differences), or a missing remote snapshot despite an existing baseline. Both sides changing is a reason to review, not a confirmed file conflict.
156
155
  No selected content and first sync with an empty remote stay quiet outside `/sync`, which provides setup or initialization guidance. Legacy remote metadata without an authoritative content list does not independently trigger a widget for observation-only checks. With **Startup transfer** enabled, an established legacy remote instead shows review attention and requires an explicit direction to adopt the content policy; no automatic transfer runs. An included-content mismatch puts **Review synced content (recommended)** in the manager, where a fresh review verifies the remote snapshot before offering changes.
157
156
  Check results are advisory observations against the last sync baseline, not proof of a file conflict or current equality. Opening the manager uses local information and shows when the check completed; it does not contact remote storage. Transfer actions recheck current content.
158
157
  In fullscreen TUI mode, click anywhere in **Sync** to collapse or expand the widget without moving keyboard focus. Attention updates keep the collapse state. Open and close `/sync` to restore the body with the keyboard; a new session resets the state.
@@ -14,7 +14,6 @@ import {
14
14
  safeTerminalText
15
15
  } from "./chunk-2JNFEZ3V.ts";
16
16
  import {
17
- compareSyncInclude,
18
17
  sameSyncInclude
19
18
  } from "./chunk-JKBUYCPC.ts";
20
19
 
@@ -100,10 +99,10 @@ function createSyncAttentionController() {
100
99
  });
101
100
  return;
102
101
  }
103
- const presentation = state ? attentionPresentation(state.decision) : observationPresentation(observation);
102
+ const setupName = safeTerminalText(state?.decision.setupName ?? observation?.setupName ?? "");
104
103
  if (ctx.mode !== "tui") {
105
104
  ctx.ui.setWidget(WIDGET_KEY, void 0);
106
- setSyncStatus(ctx, presentation.status, { activity: "review" });
105
+ setSyncStatus(ctx, "sync \u21D5", { activity: "review" });
107
106
  return;
108
107
  }
109
108
  const { EditorStatusWidget } = await import("./attention-widget-Z7G3SYYJ.ts").catch((error) => {
@@ -111,7 +110,7 @@ function createSyncAttentionController() {
111
110
  throw error;
112
111
  });
113
112
  if (generation !== currentGeneration || signal?.aborted) return;
114
- setSyncStatus(ctx, presentation.status, { activity: "review" });
113
+ setSyncStatus(ctx, "sync \u21D5", { activity: "review" });
115
114
  const presentationState = widgetState;
116
115
  ctx.ui.setWidget(
117
116
  WIDGET_KEY,
@@ -120,44 +119,14 @@ function createSyncAttentionController() {
120
119
  name: "Sync",
121
120
  summary: "Needs review",
122
121
  state: presentationState,
123
- renderBody: (width) => presentation.lines.map(
124
- (line, index) => width === 0 ? "" : truncateToWidth(theme.fg(index === 0 ? "warning" : "muted", line), width, "\u2026")
125
- )
122
+ renderBody: (width) => [
123
+ width === 0 ? "" : truncateToWidth(theme.fg("muted", `Open /sync to review \xB7 ${setupName}`), width, "\u2026")
124
+ ]
126
125
  })
127
126
  );
128
127
  }
129
128
  };
130
129
  }
131
- function attentionPresentation(decision) {
132
- const setupName = safeTerminalText(decision.setupName);
133
- const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
134
- return {
135
- status: "sync \u21D5",
136
- lines: [
137
- `Setup: ${setupName}`,
138
- selectionDifference({
139
- ...comparison,
140
- excludeChanged: !sameSyncExclude(decision.localExclude, decision.remoteExclude)
141
- }),
142
- "No transfer performed \xB7 Run /sync to review"
143
- ]
144
- };
145
- }
146
- function selectionDifference(comparison) {
147
- if (comparison.excludeChanged) return "Selection: excluded paths differ; review needed";
148
- return comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0 ? "Selection: only list order differs" : `Selection: ${comparison.remoteOnly.length} remote-only \xB7 ${comparison.localOnly.length} device-only`;
149
- }
150
- function observationPresentation(observation) {
151
- const selection = observation.inspection.selectionState;
152
- return {
153
- status: "sync \u21D5",
154
- lines: [
155
- `Setup: ${safeTerminalText(observation.setupName)}`,
156
- selection?.kind === "different" ? selectionDifference(selection) : observationSummary(observation),
157
- "No transfer performed \xB7 Run /sync to review"
158
- ]
159
- };
160
- }
161
130
  function observationMatchesConfig(observation, config) {
162
131
  return observation.configIdentity === syncCheckConfigFingerprint(config);
163
132
  }
@@ -210,4 +179,4 @@ export {
210
179
  observationMatchesConfig,
211
180
  observationSummary
212
181
  };
213
- //# sourceMappingURL=chunk-MIXZVHFR.ts.map
182
+ //# sourceMappingURL=chunk-6LHIRS5R.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/state/sync-state-store.ts", "../../src/ui/sync-attention.ts"],
4
+ "sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/state/sync-state-store\";\nexport {\n ensureStateDir,\n lockPath,\n readState,\n readStateForConfig,\n statePathForConfig,\n syncStateFingerprint,\n writeState,\n writeStateForConfig,\n} from \"@narumitw/sync-daemon/engine/state/sync-state-store\";\n", "import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { EditorStatusWidgetState } from \"@narumitw/pi-tui-kit/editor-status-widget\";\nimport { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { sameSyncExclude } from \"../sync/exclude-policy.js\";\nimport type { StartupObservation } from \"../sync/sync-inspection.js\";\nimport { type RemoteSelectionDecision, sameSyncInclude } from \"../sync/sync-policy.js\";\nimport { setSyncStatus } from \"./sync-status.js\";\nimport { safeTerminalText } from \"./terminal-text.js\";\n\nconst WIDGET_KEY = \"sync:attention\";\n\nexport type SyncAttentionOrigin = \"sync\" | \"pull\" | \"push\";\n\nexport interface SyncAttentionState {\n decision: RemoteSelectionDecision;\n origin: SyncAttentionOrigin;\n offered: boolean;\n}\n\nexport function syncAttentionMatchesConfig(attention: SyncAttentionState, config: AnySyncConfig) {\n return (\n attention.decision.setupName === config.setupName &&\n attention.decision.configIdentity === syncConfigReviewFingerprint(config) &&\n sameSyncInclude(attention.decision.localInclude, config.include) &&\n sameSyncExclude(attention.decision.localExclude, config.exclude)\n );\n}\n\nexport interface SyncAttentionController {\n observe(observation: StartupObservation): void;\n observation(): StartupObservation | undefined;\n clearObservation(): void;\n notifyObservation(ctx: ExtensionContext): void;\n set(decision: RemoteSelectionDecision, origin: SyncAttentionOrigin): void;\n current(): SyncAttentionState | undefined;\n markOffered(): boolean;\n clear(ctx: ExtensionContext): void;\n reset(ctx: ExtensionContext): void;\n expand(): void;\n publish(ctx: ExtensionContext, signal?: AbortSignal): Promise<void>;\n}\n\nexport function createSyncAttentionController(): SyncAttentionController {\n let state: SyncAttentionState | undefined;\n let observation: StartupObservation | undefined;\n let generation = 0;\n let widgetState: EditorStatusWidgetState = { collapsed: false };\n\n return {\n observe(value) {\n generation++;\n observation = value;\n },\n observation() {\n return observation;\n },\n clearObservation() {\n generation++;\n observation = undefined;\n },\n notifyObservation(ctx) {\n if (ctx.hasUI && observation && observationNeedsAttention(observation)) {\n ctx.ui.notify(observationLines(observation).join(\"\\n\"), \"warning\");\n }\n },\n set(decision, origin) {\n generation++;\n state = { decision, origin, offered: false };\n },\n current() {\n return state;\n },\n markOffered() {\n if (!state || state.offered) return false;\n state = { ...state, offered: true };\n return true;\n },\n clear(ctx) {\n generation++;\n state = undefined;\n clearAttentionPresentation(ctx);\n },\n reset(ctx) {\n generation++;\n state = undefined;\n observation = undefined;\n widgetState = { collapsed: false };\n clearAttentionPresentation(ctx);\n },\n expand() {\n widgetState.collapsed = false;\n },\n async publish(ctx, signal) {\n const currentGeneration = ++generation;\n if (signal?.aborted || !ctx.hasUI) return;\n const classification = observation ? classifyObservation(observation) : \"none\";\n if (!state && (classification === \"none\" || classification === \"guidance\")) {\n clearAttentionPresentation(ctx);\n return;\n }\n if (!state && classification === \"status\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, observation?.inspection.remoteChanged ? \"sync \u21E3\" : \"sync \u21E1\", {\n activity: observation?.inspection.remoteChanged ? \"remote-change\" : \"local-change\",\n });\n return;\n }\n const setupName = safeTerminalText(state?.decision.setupName ?? observation?.setupName ?? \"\");\n if (ctx.mode !== \"tui\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, \"sync \u21D5\", { activity: \"review\" });\n return;\n }\n // Keep Kit outside the eager startup graph; module loading owns no cancellable resources.\n const { EditorStatusWidget } = await import(\"./attention-widget.js\").catch((error) => {\n if (generation === currentGeneration && !signal?.aborted) clearAttentionPresentation(ctx);\n throw error;\n });\n if (generation !== currentGeneration || signal?.aborted) return;\n setSyncStatus(ctx, \"sync \u21D5\", { activity: \"review\" });\n const presentationState = widgetState;\n ctx.ui.setWidget(\n WIDGET_KEY,\n (_tui, theme) =>\n new EditorStatusWidget({\n theme,\n name: \"Sync\",\n summary: \"Needs review\",\n state: presentationState,\n renderBody: (width) => [\n width === 0 ? \"\" : truncateToWidth(theme.fg(\"muted\", `Open /sync to review \u00B7 ${setupName}`), width, \"\u2026\"),\n ],\n }),\n );\n },\n };\n}\n\nexport function observationMatchesConfig(observation: StartupObservation, config: AnySyncConfig) {\n return observation.configIdentity === syncCheckConfigFingerprint(config);\n}\n\nexport function observationSummary(observation: StartupObservation) {\n const result = observation.inspection;\n if (result.emptyInclude) return \"No included content selected\";\n if (result.selectionState?.kind === \"different\") return \"Synced-content list differs; review needed\";\n if (result.firstSync)\n return result.head ? \"No sync baseline; review remote and local content\" : \"Remote empty; no sync baseline\";\n if (!result.head) return \"Remote snapshot missing; review needed\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\")\n return \"Legacy remote has no authoritative content list; review /sync and choose an explicit direction to adopt policy\";\n if (result.localChanged && result.remoteChanged) return \"Local and remote changed since last sync; review needed\";\n if (result.remoteChanged) return \"Remote changed since last sync\";\n if (result.localChanged) return \"Local content changed since last sync\";\n if (result.selectionState?.kind === \"legacy\") return \"Legacy remote has no authoritative content list\";\n return \"No changes detected since last sync\";\n}\n\nexport type ObservationClassification = \"none\" | \"guidance\" | \"status\" | \"review\";\n\n/** Presentation only: never discard an observation or authorize a transfer here. */\nexport function classifyObservation(observation: StartupObservation): ObservationClassification {\n const result = observation.inspection;\n // Sync now exits before reading remote content when nothing is selected.\n if (result.emptyInclude) return \"guidance\";\n // Ordering is part of the existing transfer policy, not merely display order.\n if (result.selectionState?.kind === \"different\") return \"review\";\n if (result.firstSync) return result.head ? \"review\" : \"guidance\";\n if (!result.head || (result.localChanged && result.remoteChanged)) return \"review\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\") return \"review\";\n if (result.localChanged || result.remoteChanged) return \"status\";\n // Legacy metadata alone requires no scope confirmation in transfer operations.\n return \"none\";\n}\n\nexport function observationNeedsAttention(observation: StartupObservation) {\n return classifyObservation(observation) === \"review\";\n}\n\nfunction observationLines(observation: StartupObservation) {\n return [\n `Pi Sync check \u00B7 ${safeTerminalText(observation.setupName)}`,\n observationSummary(observation),\n \"No startup transfer \u00B7 Run /sync to review\",\n ];\n}\n\nfunction clearAttentionPresentation(ctx: ExtensionContext) {\n if (!ctx.hasUI) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,SAAS,uBAAuB;AAUhC,IAAM,aAAa;AAUZ,SAAS,2BAA2B,WAA+B,QAAuB;AAC/F,SACE,UAAU,SAAS,cAAc,OAAO,aACxC,UAAU,SAAS,mBAAmB,4BAA4B,MAAM,KACxE,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO,KAC/D,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO;AAEnE;AAgBO,SAAS,gCAAyD;AACvE,MAAI;AACJ,MAAI;AACJ,MAAI,aAAa;AACjB,MAAI,cAAuC,EAAE,WAAW,MAAM;AAE9D,SAAO;AAAA,IACL,QAAQ,OAAO;AACb;AACA,oBAAc;AAAA,IAChB;AAAA,IACA,cAAc;AACZ,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB;AACjB;AACA,oBAAc;AAAA,IAChB;AAAA,IACA,kBAAkB,KAAK;AACrB,UAAI,IAAI,SAAS,eAAe,0BAA0B,WAAW,GAAG;AACtE,YAAI,GAAG,OAAO,iBAAiB,WAAW,EAAE,KAAK,IAAI,GAAG,SAAS;AAAA,MACnE;AAAA,IACF;AAAA,IACA,IAAI,UAAU,QAAQ;AACpB;AACA,cAAQ,EAAE,UAA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qBAAqB,OAAO,gBAAgB,SAAS,SAAU,QAAO;AACtF,MAAI,OAAO,gBAAgB,OAAO,cAAe,QAAO;AAExD,SAAO;AACT;AAEO,SAAS,0BAA0B,aAAiC;AACzE,SAAO,oBAAoB,WAAW,MAAM;AAC9C;AAEA,SAAS,iBAAiB,aAAiC;AACzD,SAAO;AAAA,IACL,sBAAmB,iBAAiB,YAAY,SAAS,CAAC;AAAA,IAC1D,mBAAmB,WAAW;AAAA,IAC9B;AAAA,EACF;AACF;AAEA,SAAS,2BAA2B,KAAuB;AACzD,MAAI,CAAC,IAAI,MAAO;AAChB,gBAAc,KAAK,MAAS;AAC5B,MAAI,GAAG,UAAU,YAAY,MAAS;AACxC;",
6
+ "names": []
7
+ }
@@ -5,7 +5,7 @@ import {
5
5
  readStateForConfig,
6
6
  syncAttentionMatchesConfig,
7
7
  syncStateFingerprint
8
- } from "./chunk-MIXZVHFR.ts";
8
+ } from "./chunk-6LHIRS5R.ts";
9
9
  import "./chunk-NPT2G4FU.ts";
10
10
  import {
11
11
  loadConfig,
@@ -411,7 +411,7 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
411
411
  if (!rawArgs.trim()) {
412
412
  attention.expand();
413
413
  try {
414
- const { showSyncManager } = await import("./manager-ui-SJOBTJLY.ts");
414
+ const { showSyncManager } = await import("./manager-ui-AY5ZU6B4.ts");
415
415
  if (sessionSignal.aborted) return;
416
416
  await showSyncManager(ctx, run, sessionSignal, {
417
417
  getAttention: () => attention.current(),
@@ -542,4 +542,4 @@ export {
542
542
  handleCommand,
543
543
  resolveSelectionAttention
544
544
  };
545
- //# sourceMappingURL=command-handler-3O76V7Q5.ts.map
545
+ //# sourceMappingURL=command-handler-FO4XBBHF.ts.map
@@ -0,0 +1,27 @@
1
+ // @generated by scripts/build-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
+
4
+ // src/sync/continuous-storage.ts
5
+ import {
6
+ CONTINUOUS_RECORD_MAX_BYTES,
7
+ checkContinuousRoot,
8
+ continuousBinding,
9
+ continuousRoot,
10
+ hashContinuous,
11
+ prepareContinuousRoot,
12
+ readContinuousPrivate,
13
+ readContinuousPrivateDocument,
14
+ writeContinuousPrivate
15
+ } from "@narumitw/sync-daemon/engine/sync/continuous-storage";
16
+ export {
17
+ CONTINUOUS_RECORD_MAX_BYTES,
18
+ checkContinuousRoot,
19
+ continuousBinding,
20
+ continuousRoot,
21
+ hashContinuous,
22
+ prepareContinuousRoot,
23
+ readContinuousPrivate,
24
+ readContinuousPrivateDocument,
25
+ writeContinuousPrivate
26
+ };
27
+ //# sourceMappingURL=continuous-storage-SQBAXACF.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/sync/continuous-storage.ts"],
4
+ "sourcesContent": ["export type * from \"@narumitw/sync-daemon/engine/sync/continuous-storage\";\nexport {\n CONTINUOUS_RECORD_MAX_BYTES,\n checkContinuousRoot,\n continuousBinding,\n continuousRoot,\n hashContinuous,\n prepareContinuousRoot,\n readContinuousPrivate,\n readContinuousPrivateDocument,\n writeContinuousPrivate,\n} from \"@narumitw/sync-daemon/engine/sync/continuous-storage\";\n"],
5
+ "mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
6
+ "names": []
7
+ }
@@ -20,7 +20,7 @@ import {
20
20
  readStateForConfig,
21
21
  syncAttentionMatchesConfig,
22
22
  syncStateFingerprint
23
- } from "./chunk-MIXZVHFR.ts";
23
+ } from "./chunk-6LHIRS5R.ts";
24
24
  import {
25
25
  normalizeSyncExclude,
26
26
  sameSyncExclude
@@ -104,7 +104,7 @@ import {
104
104
  } from "./chunk-JKBUYCPC.ts";
105
105
 
106
106
  // src/ui/manager-ui.ts
107
- import { defineMenu as defineMenu6, runMenu as runMenu6 } from "@narumitw/pi-tui-kit";
107
+ import { defineMenu as defineMenu6, runDocumentReview, runMenu as runMenu6 } from "@narumitw/pi-tui-kit";
108
108
 
109
109
  // src/state/operation-availability.ts
110
110
  import {
@@ -469,7 +469,6 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
469
469
  const config = await loadConfig();
470
470
  const operation = await inspectOperation();
471
471
  const changesBlocked = operationBlocksChanges(operation);
472
- const selection = syncIncludeSelection(config.include);
473
472
  let currentAttention;
474
473
  if (attention) {
475
474
  try {
@@ -485,39 +484,27 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
485
484
  const noSyncedContent = config.include.length === 0;
486
485
  const syncState = changesBlocked ? void 0 : await readStateForConfig(config).catch(() => void 0);
487
486
  const currentObservation = observation && observationMatchesConfig(observation, config) && syncState && syncStateFingerprint(syncState) === observation.inspection.stateIdentity ? observation : void 0;
488
- const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot), 20, "\u2026")} (application time unavailable; full ID in History)` : syncState ? "Never synced" : "Unavailable";
487
+ const lastAppliedSnapshot = changesBlocked ? "Unavailable while operations are locked" : syncState?.lastAppliedSnapshot ? `${truncateToWidth(safeTerminalText(syncState.lastAppliedSnapshot), 12, "\u2026")} \xB7 application time unavailable` : syncState ? "Never synced" : "Unavailable";
489
488
  const canSwitch = await countValidSyncSetups(configuredTargets, signal) > 1;
490
489
  const mainActions = [...MAIN_MENU_ACTIONS];
491
490
  if (config.agentMode && !noSyncedContent) mainActions.splice(1, 0, "Retry refused model result\u2026");
492
491
  if (canSwitch) mainActions.push("Switch sync setup");
493
492
  if (syncState?.unresolved?.length) mainActions.unshift("Review unresolved conflicts");
493
+ const background = changesBlocked ? [] : await backgroundSummary(config);
494
+ signal?.throwIfAborted();
494
495
  const ordinaryTitle = [
495
496
  "Manage sync",
496
- "",
497
497
  `Current sync setup: ${safeTerminalText(config.setupName)}`,
498
498
  `Storage: ${backendStorageDescription(config)}`,
499
- "CURRENT STATE",
500
- ...syncState?.unresolved?.length ? [
501
- `Unresolved: ${syncState.unresolved.length} dependency groups \xB7 choose Review unresolved conflicts`,
502
- `Last observed: ${safeTerminalText(syncState.lastObservedSnapshot ?? "unknown")}`
503
- ] : [],
499
+ ...syncState?.unresolved?.length ? [`Unresolved: ${syncState.unresolved.length} dependency groups \xB7 review needed`] : [],
504
500
  ...currentAttention ? [
505
501
  currentAttention.decision.setupName === config.setupName ? "Sync status: Review needed" : `Sync status: Review needed for setup ${safeTerminalText(currentAttention.decision.setupName)}`,
506
- attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`,
507
- "Nothing has been changed."
508
- ] : currentObservation ? [
509
- `Startup check (${safeTerminalText(currentObservation.checkedAt)}): ${observationSummary(currentObservation)}`,
510
- "Check-time observation only; synchronization rechecks current content."
511
- ] : ["Remote status: Not checked"],
512
- `Included: ${selection.builtIns.length} built-in group${selection.builtIns.length === 1 ? "" : "s"} \xB7 ${selection.custom.length} extra path${selection.custom.length === 1 ? "" : "s"} \xB7 Sessions ${syncSessionsSelected(config) ? "on" : "off"}`,
513
- `Automatic sync: ${automaticSyncSummary(config.automatic)}`,
514
- `Startup transfer: ${startupTransferSummary(config)}`,
515
- `Autonomous sync: ${config.agentMode ? "On (autonomous merged sync)" : "Off"}`,
516
- ...config.continuous ? await (await import("./continuous-record-ZHUXVO4E.ts")).continuousStatusLines(config) : [],
502
+ attentionComparison?.remoteOnly.length === 0 && attentionComparison.localOnly.length === 0 ? attentionExclusionsDiffer ? "Synced-content exclusion rules differ." : "Only the synced-content order differs." : `Remote-only paths: ${attentionComparison?.remoteOnly.length ?? 0} \xB7 Device-only paths: ${attentionComparison?.localOnly.length ?? 0}${attentionExclusionsDiffer ? " \xB7 Exclusion rules differ." : ""}`
503
+ ] : currentObservation ? [`Observed ${safeTerminalText(currentObservation.checkedAt)}: ${observationSummary(currentObservation)}`] : ["Remote status: Not checked"],
517
504
  `Last applied: ${lastAppliedSnapshot}`,
518
- ...noSyncedContent ? ["", "No included content is selected. Choose included content in Settings before syncing."] : [],
519
- "",
520
- "ACTIONS \xB7 transfer, inspect, or manage"
505
+ ...config.agentMode ? ["Auto-apply: On \xB7 AI requests may incur costs"] : config.automaticTransfer || config.automatic && syncSessionsSelected(config) ? ["Automatic transfer permission: On \xB7 see Settings"] : [],
506
+ ...background,
507
+ ...noSyncedContent ? ["", "No included content is selected. Choose included content in Settings before syncing."] : []
521
508
  ];
522
509
  return {
523
510
  title: (changesBlocked ? ["Manage sync", ...operationStatusLines(operation)] : ordinaryTitle).join("\n"),
@@ -548,6 +535,26 @@ async function describeManagerState(signal, attention, inspectOperation = inspec
548
535
  };
549
536
  }
550
537
  }
538
+ async function backgroundSummary(config) {
539
+ if (!config.continuous) return [];
540
+ if (!config.agentMode) return ["Background sync: Paused \xB7 enable Autonomous sync"];
541
+ try {
542
+ const { continuousBinding, readContinuousPrivateDocument } = await import("./continuous-storage-SQBAXACF.ts");
543
+ const recordApi = await import("./continuous-record-ZHUXVO4E.ts");
544
+ const binding = await continuousBinding(config);
545
+ const document = await readContinuousPrivateDocument(`${binding}.json`);
546
+ if (!document) return ["Background sync: Enabled \xB7 not yet observed"];
547
+ recordApi.validateContinuousRecord(document.value, binding);
548
+ const record = document.value;
549
+ const phases = { waiting: "Waiting", syncing: "Syncing", retry: "Retry", blocked: "Blocked" };
550
+ return [
551
+ `Background sync (recorded): ${phases[record.phase]}${record.error ? ` \xB7 ${record.error}` : ""}`,
552
+ ...record.transferred === void 0 ? [] : [`Last background transfer: Success \xB7 ${new Date(record.transferred).toISOString()}`]
553
+ ];
554
+ } catch {
555
+ return ["Background sync: Unknown \xB7 open Diagnostics"];
556
+ }
557
+ }
551
558
  function operationActions(operation, noSyncedContent, canSwitch, mainActions) {
552
559
  if (operationCanRecover(operation)) {
553
560
  return ["Restore sync access\u2026 (recommended)", "History", "Help"];
@@ -1924,29 +1931,39 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
1924
1931
  return false;
1925
1932
  }
1926
1933
  };
1934
+ const menuItems = (manager) => {
1935
+ const attentionItems = attentionMainMenuItems(manager);
1936
+ const managerItems = manager.actions.map((label) => blockedSyncMenuItem(label, manager) ?? syncMainMenuItem(label));
1937
+ const operationFirst = manager.operation !== void 0 && manager.operation.kind !== "free";
1938
+ return operationFirst ? [...managerItems, ...attentionItems] : [...attentionItems, ...managerItems];
1939
+ };
1927
1940
  const menu = defineMenu6({
1928
1941
  start: "main",
1929
1942
  screens: {
1930
- main: ({ state }) => {
1931
- const attentionItems = attentionMainMenuItems(state.manager);
1932
- const managerItems = state.manager.actions.map(
1933
- (label) => blockedSyncMenuItem(label, state.manager) ?? syncMainMenuItem(label)
1934
- );
1935
- const operationFirst = state.manager.operation !== void 0 && state.manager.operation.kind !== "free";
1936
- return {
1937
- kind: "actions",
1938
- title: "Manage sync",
1939
- // Frequent transfers stay visible; status is advisory and Help remains a direct route.
1940
- lines: [
1941
- ...state.manager.title.split("\n").slice(1),
1942
- "Help: /sync help \xB7 Fresh status: /sync status \xB7 Differences: /sync diff"
1943
- ],
1944
- items: operationFirst ? [...managerItems, ...attentionItems] : [...attentionItems, ...managerItems],
1945
- hint: "close"
1946
- };
1947
- }
1943
+ main: ({ state }) => ({
1944
+ kind: "choice",
1945
+ title: "Manage sync",
1946
+ lines: state.manager.title.split("\n").slice(1),
1947
+ items: menuItems(state.manager).map((item) => ({
1948
+ id: item.id,
1949
+ label: ctx.mode === "tui" && item.id === "sync" ? "Sync\u2026" : item.label,
1950
+ details: [item.description ?? "Review synced content."],
1951
+ searchText: `${item.label} ${item.description ?? ""}`,
1952
+ disabled: item.disabled,
1953
+ disabledReason: item.disabledReason
1954
+ })),
1955
+ action: "activate",
1956
+ enableSearch: true,
1957
+ viewportSize: 5,
1958
+ hint: "close"
1959
+ })
1948
1960
  },
1949
1961
  actions: {
1962
+ activate: async (invocation) => {
1963
+ const item = menuItems(invocation.state.manager).find((candidate) => candidate.id === invocation.itemId);
1964
+ if (!item || item.disabled || !("action" in item) || !item.action) return { kind: "stay" };
1965
+ return menu.actions[item.action](invocation);
1966
+ },
1950
1967
  "review-attention": async ({ state }) => {
1951
1968
  const attention = state.manager.attention;
1952
1969
  if (attention && options.getAttention?.() !== attention) return { kind: "stay" };
@@ -2084,6 +2101,30 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
2084
2101
  const validate = captureMutationOwner(ctx, signal);
2085
2102
  const config = await loadConfig(state.manager.configReview?.setupName);
2086
2103
  validate();
2104
+ if (config.continuous) {
2105
+ const { continuousStatusLines } = await import("./continuous-record-ZHUXVO4E.ts");
2106
+ validate();
2107
+ const lines = await continuousStatusLines(config);
2108
+ validate();
2109
+ const review = await runDocumentReview(ctx, {
2110
+ title: "Sync diagnostics",
2111
+ lines: [`Setup: ${safeTerminalText(config.setupName)} \xB7 local observations only`],
2112
+ content: lines.join("\n"),
2113
+ confirmation: { label: "Continue to backend checks\u2026" },
2114
+ hint: "back",
2115
+ signal,
2116
+ isCurrent
2117
+ });
2118
+ validate();
2119
+ if (review.kind === "cancelled") return { kind: review.reason === "close" ? "close" : "stay" };
2120
+ if (review.kind !== "confirmed") return { kind: "stay" };
2121
+ const current = await loadConfig();
2122
+ validate();
2123
+ if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(current)) {
2124
+ ctx.ui.notify("Setup changed during diagnostics review; reopen Diagnostics.", "warning");
2125
+ return { kind: "stay" };
2126
+ }
2127
+ }
2087
2128
  const confirmed = await ctx.ui.confirm(
2088
2129
  "Run diagnostics?",
2089
2130
  `Setup: ${safeTerminalText(config.setupName)}
@@ -2226,10 +2267,28 @@ function syncMainMenuItem(label) {
2226
2267
  id: action,
2227
2268
  label,
2228
2269
  action,
2229
- description: action === "retry-refusal" ? "Transfer: confirm one fresh model request for a current cached refusal; may incur costs." : action === "doctor" ? "Manage: review backend checks before running." : action === "settings" || action === "history" || action === "switch" ? "Manage" : action === "sync" ? "Transfer: choose a safe direction or review conflicts." : action === "pull" ? "Transfer: remote \u2192 local; review writes and removals." : action === "push" ? "Transfer: local \u2192 remote active snapshot; review publication." : action === "status" || action === "diff" ? "Inspect: read current local and remote state without transferring files." : void 0
2270
+ description: {
2271
+ sync: "Merge changes on both sides.",
2272
+ "retry-refusal": "Retry model; may incur costs.",
2273
+ pull: "Remote \u2192 this device.",
2274
+ push: "This device \u2192 remote snapshot.",
2275
+ diff: "Inspect changes; no transfer.",
2276
+ status: "Check remote; no transfer.",
2277
+ settings: "Change sync settings.",
2278
+ history: "Review snapshots and rollback.",
2279
+ doctor: "Review backend diagnostics.",
2280
+ switch: "Choose another sync setup.",
2281
+ conflicts: "Review unresolved file groups.",
2282
+ recover: "Review local lock recovery.",
2283
+ refresh: "Recheck the operation lock.",
2284
+ setups: "Manage sync setups.",
2285
+ connections: "Manage storage connections.",
2286
+ help: "Read sync commands and safety.",
2287
+ init: "Configure a sync setup."
2288
+ }[action]
2230
2289
  };
2231
2290
  }
2232
2291
  export {
2233
2292
  showSyncManager
2234
2293
  };
2235
- //# sourceMappingURL=manager-ui-SJOBTJLY.ts.map
2294
+ //# sourceMappingURL=manager-ui-AY5ZU6B4.ts.map