synabun 2.4.1 → 2.4.2
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 +30 -0
- package/README.md +1 -1
- package/browser-extension/content.js +56 -14
- package/browser-extension/engine.js +158 -8
- package/browser-extension/manifest.json +3 -1
- package/browser-extension/protocol.js +91 -6
- package/browser-extension/service-worker.js +13 -5
- package/browser-extension/tokens.css +1 -1
- package/docs/browser-extension-bridge.md +24 -4
- package/lib/data-home-files.js +4 -2
- package/lib/first-launch-protection.js +8 -2
- package/lib/update-snapshot.js +11 -4
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +25 -2
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +62 -17
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-bench.d.ts +22 -22
- package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-maintenance.js +34 -45
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
- package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
- package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-copy.js +467 -0
- package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.js +60 -0
- package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-retrieval.js +188 -40
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
- package/mcp-server/dist/services/memory-schema.d.ts +58 -2
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-schema.js +190 -13
- package/mcp-server/dist/services/memory-schema.js.map +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +56 -20
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-verification.js +8 -5
- package/mcp-server/dist/services/memory-verification.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +5 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +19 -2
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.js +145 -0
- package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
- package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
- package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite-write.js +94 -0
- package/mcp-server/dist/services/sqlite-write.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +39 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
- package/mcp-server/dist/services/sqlite.js +249 -8
- package/mcp-server/dist/services/sqlite.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +32 -10
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe.js +9 -7
- package/mcp-server/dist/services/typesafe.js.map +1 -1
- package/mcp-server/dist/services/vector-cache.d.ts +32 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
- package/mcp-server/dist/services/vector-cache.js +161 -8
- package/mcp-server/dist/services/vector-cache.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +11 -7
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +27 -9
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +10 -3
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +6 -1
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +20 -2
- package/mcp-server/src/index.ts +59 -17
- package/mcp-server/src/services/memory-maintenance.ts +31 -28
- package/mcp-server/src/services/memory-migration-copy.ts +419 -0
- package/mcp-server/src/services/memory-migration-worker.ts +55 -0
- package/mcp-server/src/services/memory-retrieval.ts +173 -32
- package/mcp-server/src/services/memory-schema.ts +194 -12
- package/mcp-server/src/services/memory-sessions.ts +54 -21
- package/mcp-server/src/services/memory-verification.ts +7 -4
- package/mcp-server/src/services/neural-interface.ts +22 -2
- package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
- package/mcp-server/src/services/retrieval-reader.ts +131 -0
- package/mcp-server/src/services/sqlite-write.ts +60 -0
- package/mcp-server/src/services/sqlite.ts +246 -8
- package/mcp-server/src/services/typesafe-config.ts +25 -6
- package/mcp-server/src/services/typesafe.ts +9 -7
- package/mcp-server/src/services/vector-cache.ts +154 -9
- package/mcp-server/src/tools/agents.ts +26 -9
- package/mcp-server/src/tools/browser-advanced.ts +10 -3
- package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
- package/mcp-server/src/tools/browser-interact.ts +5 -1
- package/neural-interface/i18n/en.json +263 -1
- package/neural-interface/i18n/pt-BR.json +264 -2
- package/neural-interface/lib/agents/split.js +32 -4
- package/neural-interface/lib/assistant-api.js +19 -8
- package/neural-interface/lib/assistant-brains/claude.js +2 -0
- package/neural-interface/lib/assistant-catalog.js +2 -2
- package/neural-interface/lib/assistant-config.js +0 -7
- package/neural-interface/lib/assistant-dispatch.js +257 -95
- package/neural-interface/lib/assistant-persona.js +16 -4
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +131 -47
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +39 -33
- package/neural-interface/lib/backup-contents.js +158 -0
- package/neural-interface/lib/backup-crypto-io.js +330 -0
- package/neural-interface/lib/backup-crypto-worker.js +130 -0
- package/neural-interface/lib/backup-crypto.js +525 -0
- package/neural-interface/lib/backup-download.js +268 -0
- package/neural-interface/lib/backup-encryption.js +318 -0
- package/neural-interface/lib/backup-groups.js +287 -0
- package/neural-interface/lib/backup-restore-session.js +176 -0
- package/neural-interface/lib/backup-restore-stage.js +60 -0
- package/neural-interface/lib/backup-service.js +788 -233
- package/neural-interface/lib/backup-zip-reader.js +30 -18
- package/neural-interface/lib/backup-zip-writer.js +34 -10
- package/neural-interface/lib/browser-extension-adapter.js +89 -13
- package/neural-interface/lib/browser-extension-bridge.js +18 -7
- package/neural-interface/lib/claude-agent-bridge.js +1 -0
- package/neural-interface/lib/claude-session-cleanup.js +5 -1
- package/neural-interface/lib/cli-update-planner.js +105 -6
- package/neural-interface/lib/client-diagnostics.js +42 -0
- package/neural-interface/lib/confined-fs.js +7 -2
- package/neural-interface/lib/coordination/README.md +8 -2
- package/neural-interface/lib/coordination/contract.js +161 -0
- package/neural-interface/lib/coordination/database.js +999 -0
- package/neural-interface/lib/coordination/operations.js +436 -0
- package/neural-interface/lib/coordination/service.js +68 -537
- package/neural-interface/lib/coordination/storage-worker.js +101 -0
- package/neural-interface/lib/coordination/store.js +219 -1111
- package/neural-interface/lib/db.js +70 -32
- package/neural-interface/lib/health-count.js +37 -0
- package/neural-interface/lib/loop-stall.js +139 -0
- package/neural-interface/lib/maritaca/client.js +2 -2
- package/neural-interface/lib/maritaca/models.js +12 -17
- package/neural-interface/lib/maritaca/opencode.js +4 -2
- package/neural-interface/lib/memory-api.js +9 -1
- package/neural-interface/lib/memory-session-capture.js +42 -10
- package/neural-interface/lib/memory-store-gate.js +313 -0
- package/neural-interface/lib/memory-store-migrate.js +65 -0
- package/neural-interface/lib/memory-timers.js +7 -7
- package/neural-interface/lib/native-loop-providers.js +13 -16
- package/neural-interface/lib/native-loop-runtime.js +28 -7
- package/neural-interface/lib/opencode-build-preflight.js +18 -1
- package/neural-interface/lib/opencode-native-boundary.js +69 -8
- package/neural-interface/lib/opencode-provider-view.js +14 -3
- package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
- package/neural-interface/lib/opencode2-client.js +2 -1
- package/neural-interface/lib/recall-impact.js +122 -0
- package/neural-interface/lib/scratch-evidence.js +420 -0
- package/neural-interface/lib/scratch-process-guard.js +139 -0
- package/neural-interface/lib/scratch-references.js +279 -0
- package/neural-interface/lib/scratch-retention-core.js +385 -0
- package/neural-interface/lib/scratch-retention-worker.js +37 -0
- package/neural-interface/lib/scratch-retention.js +151 -0
- package/neural-interface/lib/session-cache-builder.js +31 -43
- package/neural-interface/lib/session-cache-worker.js +157 -0
- package/neural-interface/lib/session-indexer.js +28 -21
- package/neural-interface/lib/session-search-index.js +85 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
- package/neural-interface/lib/style-guide/store.js +43 -3
- package/neural-interface/lib/system-restore.js +50 -0
- package/neural-interface/lib/teams/api.js +15 -6
- package/neural-interface/lib/teams/claims.js +67 -31
- package/neural-interface/lib/teams/index.js +7 -7
- package/neural-interface/lib/teams/integration.js +40 -40
- package/neural-interface/lib/teams/landing.js +6 -6
- package/neural-interface/lib/teams/recovery.js +24 -23
- package/neural-interface/lib/teams/scheduler.js +194 -95
- package/neural-interface/lib/teams/state.js +14 -14
- package/neural-interface/lib/teams/worktrees.js +27 -27
- package/neural-interface/lib/whatsapp/bridge.js +2 -1
- package/neural-interface/lib/worker-confinement.js +47 -2
- package/neural-interface/lib/worker-mcp-channel.js +2 -0
- package/neural-interface/lib/worker-resume.js +5 -0
- package/neural-interface/lib/worker-stop.js +86 -0
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/index.html +233 -24
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
- package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
- package/neural-interface/public/shared/agy/agy-options.js +11 -0
- package/neural-interface/public/shared/agy/agy-panel.js +29 -10
- package/neural-interface/public/shared/agy/agy-styles.js +14 -12
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
- package/neural-interface/public/shared/api.js +1 -1
- package/neural-interface/public/shared/assistant/asst-api.js +3 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
- package/neural-interface/public/shared/assistant/asst-control.js +2 -0
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
- package/neural-interface/public/shared/assistant/asst-render.js +105 -38
- package/neural-interface/public/shared/assistant/asst-route.js +100 -21
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
- package/neural-interface/public/shared/assistant/asst-state.js +11 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
- package/neural-interface/public/shared/assistant/route-identity.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
- package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
- package/neural-interface/public/shared/client-diagnostics.js +94 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-styles.js +1 -1
- package/neural-interface/public/shared/effort-i18n.js +118 -0
- package/neural-interface/public/shared/html-shell.js +4 -52
- package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
- package/neural-interface/public/shared/memory-store-wait.js +52 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
- package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
- package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
- package/neural-interface/public/shared/output-format.js +294 -0
- package/neural-interface/public/shared/provider-icons.js +6 -0
- package/neural-interface/public/shared/schedules-view.js +2 -1
- package/neural-interface/public/shared/server-presence.js +77 -0
- package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
- package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
- package/neural-interface/public/shared/settings/settings-ia.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
- package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +341 -437
- package/neural-interface/public/shared/transcript-rows.js +28 -3
- package/neural-interface/public/shared/tray-auto-close.js +18 -5
- package/neural-interface/public/shared/ui-agents.js +1 -2
- package/neural-interface/public/shared/ui-automation-studio.js +168 -108
- package/neural-interface/public/shared/ui-claude-panel.js +42 -65
- package/neural-interface/public/shared/ui-loading.js +124 -17
- package/neural-interface/public/shared/ui-native-loop-router.js +10 -0
- package/neural-interface/public/shared/ui-navbar.js +2 -1
- package/neural-interface/public/shared/ui-output.js +533 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
- package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
- package/neural-interface/public/shared/ui-sessions.js +2 -2
- package/neural-interface/public/shared/ui-settings-entry.js +18 -0
- package/neural-interface/public/shared/ui-settings.js +224 -65
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-tooltip.js +16 -0
- package/neural-interface/public/shared/ui-tutorial.js +5 -6
- package/neural-interface/public/shared/ui-worker-end.js +27 -8
- package/neural-interface/public/shared/worker-end.js +9 -4
- package/neural-interface/public/variant/2d/main.js +5 -0
- package/neural-interface/public/variant/3d/app.js +10 -0
- package/neural-interface/public/variant/3d/main.js +5 -1
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +477 -139
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
|
@@ -1127,10 +1127,10 @@
|
|
|
1127
1127
|
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>
|
|
1128
1128
|
</svg>
|
|
1129
1129
|
</div>
|
|
1130
|
-
<div class="restore-dropzone-text">Drop your backup .zip here</div>
|
|
1130
|
+
<div class="restore-dropzone-text">Drop your backup .zip or .zip.enc here</div>
|
|
1131
1131
|
<div class="restore-dropzone-hint">or click to browse</div>
|
|
1132
1132
|
</div>
|
|
1133
|
-
<input type="file" id="onboardRestoreFile" accept=".zip" style="display:none">
|
|
1133
|
+
<input type="file" id="onboardRestoreFile" accept=".zip,.enc" style="display:none">
|
|
1134
1134
|
<div id="onboardRestoreStatus" style="display:none;margin-top:12px;font-size:12px;align-items:center;gap:8px">
|
|
1135
1135
|
<div class="wiz-status-dot spin" id="onboardRestoreDot"></div>
|
|
1136
1136
|
<span id="onboardRestoreText"></span>
|
|
@@ -1437,6 +1437,7 @@
|
|
|
1437
1437
|
</script>
|
|
1438
1438
|
|
|
1439
1439
|
<script type="module">
|
|
1440
|
+
import { applyEncryptedRestore, clearRestoreOutcome, describeEncryptedRestore, describeRestoreOutcome, discardEncryptedRestore, previewErrorMessage, readRestoreOutcome, restoreCanUnlock, restoreCatalogueUrl, restoreErrorMessage, restoreNeedsNewFile, restorePartialCodes, saveRestoreOutcome, unlockEncryptedRestore } from '/shared/settings/settings-backup-encryption.js';
|
|
1440
1441
|
import { waitForServerBack } from './shared/server-back.js';
|
|
1441
1442
|
|
|
1442
1443
|
// The rules step is the installer of Settings → AI connections: the same client calls and the same reading
|
|
@@ -1858,15 +1859,19 @@ function renderHappyBun() {}
|
|
|
1858
1859
|
// STEP 0: Welcome Choices (Fresh Install / Restore)
|
|
1859
1860
|
// ═══════════════════════════════════════════
|
|
1860
1861
|
|
|
1862
|
+
// A restore that finished with problems, shown again after a reload of this page (init, below).
|
|
1863
|
+
let resumeRestoreOutcome = null;
|
|
1864
|
+
|
|
1861
1865
|
(function initWelcomeChoices() {
|
|
1862
1866
|
const $choices = document.getElementById('welcomeChoices');
|
|
1863
1867
|
const $restorePanel = document.getElementById('welcomeRestorePanel');
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
const $
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1868
|
+
// These stand inside the panel, which resetRestorePanel builds again: it reads them again too.
|
|
1869
|
+
let $dropzone = document.getElementById('restoreDropzone');
|
|
1870
|
+
const $fileInput = document.getElementById('onboardRestoreFile');
|
|
1871
|
+
let $statusEl = document.getElementById('onboardRestoreStatus');
|
|
1872
|
+
let $statusDot = document.getElementById('onboardRestoreDot');
|
|
1873
|
+
let $statusText = document.getElementById('onboardRestoreText');
|
|
1874
|
+
let $backLink = document.getElementById('restoreBackLink');
|
|
1870
1875
|
|
|
1871
1876
|
// Fresh Install → proceed to step 1
|
|
1872
1877
|
document.getElementById('choiceFreshInstall').addEventListener('click', () => {
|
|
@@ -1905,7 +1910,7 @@ function renderHappyBun() {}
|
|
|
1905
1910
|
e.preventDefault();
|
|
1906
1911
|
$dropzone.classList.remove('dragover');
|
|
1907
1912
|
const file = e.dataTransfer.files[0];
|
|
1908
|
-
if (file && file.name
|
|
1913
|
+
if (file && /\.zip(?:\.enc)?$/i.test(file.name)) handleRestoreFile(file);
|
|
1909
1914
|
});
|
|
1910
1915
|
|
|
1911
1916
|
// File input change
|
|
@@ -1933,26 +1938,119 @@ function renderHappyBun() {}
|
|
|
1933
1938
|
body: file,
|
|
1934
1939
|
});
|
|
1935
1940
|
if (!previewRes.ok) {
|
|
1936
|
-
let
|
|
1937
|
-
try {
|
|
1938
|
-
|
|
1941
|
+
let body = null;
|
|
1942
|
+
try { body = await previewRes.json(); } catch {}
|
|
1943
|
+
// By the refusal's code, from the Settings strings; the server's sentence (it can name a path) is never shown.
|
|
1944
|
+
await loadRestoreStrings();
|
|
1945
|
+
throw Object.assign(new Error(previewErrorMessage(body, { tx: restoreTx, fallback: restoreCopy('invalidBackup2', 'Invalid backup file') })), { translated: true });
|
|
1946
|
+
}
|
|
1947
|
+
const preview = await previewRes.json();
|
|
1948
|
+
$statusEl.style.display = 'none';
|
|
1949
|
+
|
|
1950
|
+
// An encrypted backup: its password first. Nothing of what it holds is shown before that.
|
|
1951
|
+
if (preview.encrypted && preview.locked) {
|
|
1952
|
+
await loadRestoreStrings();
|
|
1953
|
+
// A server from before the finished encryption: no password is sent to it.
|
|
1954
|
+
if (!restoreCanUnlock(preview)) {
|
|
1955
|
+
discardEncryptedRestore((...args) => fetch(...args), preview.uploadId);
|
|
1956
|
+
throw Object.assign(new Error(restoreCopy('restoreEncNeedsRestart', 'This backup is encrypted. Restart SynaBun, then restore it. The password was not asked for and nothing was changed.')), { translated: true });
|
|
1957
|
+
}
|
|
1958
|
+
showRestoreUnlock(preview, file);
|
|
1959
|
+
return;
|
|
1939
1960
|
}
|
|
1940
|
-
const { manifest: m } = await previewRes.json();
|
|
1941
1961
|
|
|
1942
1962
|
// Show confirmation
|
|
1943
|
-
|
|
1944
|
-
showRestoreConfirm(m, file);
|
|
1963
|
+
showRestoreConfirm(preview.manifest, file);
|
|
1945
1964
|
|
|
1946
1965
|
} catch (err) {
|
|
1966
|
+
await loadRestoreStrings();
|
|
1967
|
+
$statusEl.style.display = 'flex';
|
|
1947
1968
|
$statusDot.className = 'wiz-status-dot red';
|
|
1948
|
-
$statusText.textContent = err.message;
|
|
1969
|
+
$statusText.textContent = err.translated ? err.message : restoreCopy('invalidBackup2', 'Invalid backup file');
|
|
1949
1970
|
$backLink.style.display = '';
|
|
1971
|
+
// A message can take several lines: the wizard's viewport follows it.
|
|
1972
|
+
resizeViewport(0);
|
|
1950
1973
|
}
|
|
1951
1974
|
}
|
|
1952
1975
|
|
|
1953
|
-
|
|
1954
|
-
|
|
1976
|
+
// The strings are the Settings ones (settings.redesign.server.*); the English stands in if they could not be read.
|
|
1977
|
+
const restoreCopy = (key, fallback) => {
|
|
1978
|
+
const value = restoreTx ? restoreTx(`settings.redesign.server.${key}`) : fallback;
|
|
1979
|
+
return value === `settings.redesign.server.${key}` ? fallback : value;
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
function showRestoreUnlock(locked, file) {
|
|
1983
|
+
const pageFetch = (...args) => fetch(...args);
|
|
1984
|
+
$restorePanel.innerHTML = `
|
|
1985
|
+
<form id="onboardUnlockForm" autocomplete="off" novalidate style="padding:20px 0;text-align:left;">
|
|
1986
|
+
<h3 style="font-size:16px;font-weight:600;color:var(--t-bright);margin-bottom:4px;">${esc(restoreCopy('restoreEncTitle', 'This backup is encrypted'))}</h3>
|
|
1987
|
+
<p style="font-size:11px;color:var(--t-muted);margin-bottom:14px;">${esc(restoreCopy('restoreEncHelp', 'Enter the password it was made with. Its contents are shown once it opens.'))}</p>
|
|
1988
|
+
<div class="field">
|
|
1989
|
+
<label for="onboardRestorePassword">${esc(restoreCopy('restoreEncPassword', 'Backup password'))}</label>
|
|
1990
|
+
<input type="password" id="onboardRestorePassword" autocomplete="current-password" spellcheck="false" autocapitalize="off" maxlength="1024">
|
|
1991
|
+
</div>
|
|
1992
|
+
<div id="onboardUnlockError" role="alert" style="display:none;font-size:12px;color:var(--accent-dim);margin:8px 0;"></div>
|
|
1993
|
+
<div style="display:flex;gap:10px;justify-content:center;margin-top:12px;">
|
|
1994
|
+
<button type="button" class="nav-btn" id="onboardUnlockCancel">${esc(restoreCopy('backupEncCancel', 'Cancel'))}</button>
|
|
1995
|
+
<button type="submit" class="nav-btn primary" id="onboardUnlockSubmit">${esc(restoreCopy('restoreEncUnlock', 'Unlock'))}</button>
|
|
1996
|
+
</div>
|
|
1997
|
+
</form>
|
|
1998
|
+
`;
|
|
1999
|
+
resizeViewport(0);
|
|
2000
|
+
const input = document.getElementById('onboardRestorePassword');
|
|
2001
|
+
const errorEl = document.getElementById('onboardUnlockError');
|
|
2002
|
+
const submit = document.getElementById('onboardUnlockSubmit');
|
|
2003
|
+
const cancel = document.getElementById('onboardUnlockCancel');
|
|
2004
|
+
input.focus();
|
|
2005
|
+
cancel.addEventListener('click', () => {
|
|
2006
|
+
input.value = '';
|
|
2007
|
+
discardEncryptedRestore(pageFetch, locked.uploadId);
|
|
2008
|
+
resetRestorePanel();
|
|
2009
|
+
});
|
|
2010
|
+
document.getElementById('onboardUnlockForm').addEventListener('submit', async (event) => {
|
|
2011
|
+
event.preventDefault();
|
|
2012
|
+
if (submit.disabled) return;
|
|
2013
|
+
if (!input.value) {
|
|
2014
|
+
errorEl.textContent = restoreCopy('backupEncErrRequired', 'Enter the password.');
|
|
2015
|
+
errorEl.style.display = '';
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
submit.disabled = true;
|
|
2019
|
+
cancel.disabled = true;
|
|
2020
|
+
submit.textContent = restoreCopy('restoreEncUnlocking', 'Checking…');
|
|
2021
|
+
errorEl.style.display = 'none';
|
|
2022
|
+
let answer;
|
|
2023
|
+
try { answer = await unlockEncryptedRestore(pageFetch, locked.uploadId, input.value); }
|
|
2024
|
+
catch { answer = { ok: false, body: null, failed: true }; }
|
|
2025
|
+
input.value = '';
|
|
2026
|
+
if (answer.ok && answer.body?.ok) {
|
|
2027
|
+
showRestoreConfirm(answer.body.manifest, file, locked.uploadId, answer.body);
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
cancel.disabled = false;
|
|
2031
|
+
submit.textContent = restoreCopy('restoreEncUnlock', 'Unlock');
|
|
2032
|
+
errorEl.textContent = answer.failed ? restoreCopy('backupEncErrFailed', 'That did not work. Nothing was changed.') : restoreErrorMessage(answer.body, { tx: restoreTx });
|
|
2033
|
+
errorEl.style.display = '';
|
|
2034
|
+
// The upload is gone, damaged or not one this SynaBun reads: another password cannot help.
|
|
2035
|
+
submit.disabled = restoreNeedsNewFile(answer.body?.code);
|
|
2036
|
+
input.disabled = submit.disabled;
|
|
2037
|
+
if (!submit.disabled) input.focus();
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
function showRestoreConfirm(m, file, stagedUploadId = null, unlocked = null) {
|
|
2042
|
+
// The server sends the count; one from before sends the whole file list.
|
|
2043
|
+
const fileCount = Number.isFinite(m.fileCount) ? m.fileCount : (m.files || []).length;
|
|
1955
2044
|
const hasDb = !!(m.database);
|
|
2045
|
+
// An encrypted backup: the date its header carries, which the password's keys vouched for.
|
|
2046
|
+
const madeFallback = { restoreEncMade: 'Encrypted backup made {date}. An older backup of yours opens with its password too, so check that this is the one you want.', restoreEncMadeUnknown: 'Encrypted backup. It does not say when it was made, so check that this is the one you want.' };
|
|
2047
|
+
const madeLine = unlocked ? describeEncryptedRestore(unlocked, {
|
|
2048
|
+
tx: (key, params = {}) => {
|
|
2049
|
+
const name = key.split('.').pop();
|
|
2050
|
+
const text = restoreTx ? restoreTx(key, params) : key;
|
|
2051
|
+
return text === key ? madeFallback[name].replace('{date}', params.date ?? '') : text;
|
|
2052
|
+
},
|
|
2053
|
+
}) : '';
|
|
1956
2054
|
|
|
1957
2055
|
$restorePanel.innerHTML = `
|
|
1958
2056
|
<div style="padding:20px 0;">
|
|
@@ -1960,6 +2058,7 @@ function renderHappyBun() {}
|
|
|
1960
2058
|
<p style="font-size:11px;color:var(--t-muted);margin-bottom:14px;">
|
|
1961
2059
|
Created: ${new Date(m.created).toLocaleString()} on ${esc(m.hostname || 'unknown')}
|
|
1962
2060
|
</p>
|
|
2061
|
+
${madeLine ? `<div id="onboardRestoreEncryptedMade" style="font-size:12px;color:var(--t-primary);margin-bottom:10px;">${esc(madeLine)}</div>` : ''}
|
|
1963
2062
|
<div style="font-size:12px;color:var(--t-primary);margin-bottom:6px;">
|
|
1964
2063
|
<strong>${fileCount}</strong> config files
|
|
1965
2064
|
</div>
|
|
@@ -1982,6 +2081,7 @@ function renderHappyBun() {}
|
|
|
1982
2081
|
resizeViewport(0);
|
|
1983
2082
|
|
|
1984
2083
|
document.getElementById('onboardRestoreCancel').addEventListener('click', () => {
|
|
2084
|
+
if (stagedUploadId) discardEncryptedRestore((...args) => fetch(...args), stagedUploadId);
|
|
1985
2085
|
// Reset to dropzone view
|
|
1986
2086
|
resetRestorePanel();
|
|
1987
2087
|
});
|
|
@@ -1999,18 +2099,50 @@ function renderHappyBun() {}
|
|
|
1999
2099
|
progressEl.style.display = 'flex';
|
|
2000
2100
|
progressDot.className = 'wiz-status-dot spin';
|
|
2001
2101
|
|
|
2102
|
+
// The words of a partial result are read now: a restore can restart the server right after it answers.
|
|
2103
|
+
const stringsReady = loadRestoreStrings().catch(() => null);
|
|
2002
2104
|
try {
|
|
2003
2105
|
progressText.textContent = 'Restoring backup...';
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2106
|
+
let restoreBody = null;
|
|
2107
|
+
if (stagedUploadId) {
|
|
2108
|
+
// The staged file is used once: after a failure the file is chosen again.
|
|
2109
|
+
const uploadId = stagedUploadId;
|
|
2110
|
+
stagedUploadId = null;
|
|
2111
|
+
const answer = await applyEncryptedRestore((...args) => fetch(...args), uploadId, 'full');
|
|
2112
|
+
if (!answer.ok) {
|
|
2113
|
+
const failure = new Error(restoreErrorMessage(answer.body, { tx: restoreTx }));
|
|
2114
|
+
failure.translated = true;
|
|
2115
|
+
failure.stagedUsed = true;
|
|
2116
|
+
throw failure;
|
|
2117
|
+
}
|
|
2118
|
+
restoreBody = answer.body;
|
|
2119
|
+
} else {
|
|
2120
|
+
const restoreRes = await fetch('/api/system/restore', {
|
|
2121
|
+
method: 'POST',
|
|
2122
|
+
headers: { 'Content-Type': 'application/zip' },
|
|
2123
|
+
body: file,
|
|
2124
|
+
});
|
|
2125
|
+
if (!restoreRes.ok) {
|
|
2126
|
+
// By the refusal's code: the server's sentence can hold a path. An old server sends none: the generic sentence.
|
|
2127
|
+
let body = null;
|
|
2128
|
+
try { body = await restoreRes.json(); } catch {}
|
|
2129
|
+
await loadRestoreStrings();
|
|
2130
|
+
throw Object.assign(new Error(restoreErrorMessage(body, { tx: restoreTx })), { translated: true });
|
|
2131
|
+
}
|
|
2132
|
+
// A 200 that cannot be read may still have written: it counts as a restore with problems, below.
|
|
2133
|
+
try { restoreBody = await restoreRes.json(); } catch {}
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
// A 200 can carry problems (results.errors): setup is not marked complete and the wizard stays here.
|
|
2137
|
+
const partialCodes = restorePartialCodes(restoreBody);
|
|
2138
|
+
if (partialCodes) {
|
|
2139
|
+
const outcome = { codes: partialCodes, restart: restoreBody?.restart === true };
|
|
2140
|
+
saveRestoreOutcome(outcome);
|
|
2141
|
+
await Promise.race([stringsReady, new Promise((done) => setTimeout(done, 2000))]);
|
|
2142
|
+
showRestoreOutcome(outcome, { restarting: outcome.restart, bootId: typeof restoreBody?.bootId === 'string' ? restoreBody.bootId : '' });
|
|
2143
|
+
return;
|
|
2013
2144
|
}
|
|
2145
|
+
clearRestoreOutcome();
|
|
2014
2146
|
|
|
2015
2147
|
progressDot.className = 'wiz-status-dot green';
|
|
2016
2148
|
progressText.textContent = 'Restore complete! Launching...';
|
|
@@ -2021,14 +2153,79 @@ function renderHappyBun() {}
|
|
|
2021
2153
|
setTimeout(() => { window.location.href = '/'; }, 1500);
|
|
2022
2154
|
|
|
2023
2155
|
} catch (err) {
|
|
2156
|
+
await loadRestoreStrings();
|
|
2024
2157
|
progressDot.className = 'wiz-status-dot red';
|
|
2025
|
-
progressText.textContent = err.message;
|
|
2158
|
+
progressText.textContent = err.translated ? err.message : restoreErrorMessage(null, { tx: restoreTx });
|
|
2026
2159
|
confirmBtn.textContent = 'Restore';
|
|
2027
|
-
confirmBtn.disabled =
|
|
2160
|
+
confirmBtn.disabled = !!err.stagedUsed;
|
|
2028
2161
|
cancelBtn.style.display = '';
|
|
2162
|
+
resizeViewport(0);
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
// The restore finished with problems: its messages, and the owner chooses what happens next. Nothing moves on alone.
|
|
2168
|
+
function showRestoreOutcome(outcome, { restarting = false, bootId = '' } = {}) {
|
|
2169
|
+
const words = describeRestoreOutcome(outcome, { tx: restoreTx, restarting });
|
|
2170
|
+
// The wizard's own Begin would walk past the message into a fresh setup: its two choices are the way forward.
|
|
2171
|
+
$nextBtn.style.display = 'none';
|
|
2172
|
+
$choices.style.display = 'none';
|
|
2173
|
+
$restorePanel.style.display = 'block';
|
|
2174
|
+
$restorePanel.classList.add('visible');
|
|
2175
|
+
const tryButton = `<button type="button" class="nav-btn${words.retryFirst ? ' primary' : ''}" id="onboardOutcomeRetry">${esc(words.tryAnother)}</button>`;
|
|
2176
|
+
const goButton = `<button type="button" class="nav-btn${words.retryFirst ? '' : ' primary'}" id="onboardOutcomeContinue">${esc(words.continueAnyway)}</button>`;
|
|
2177
|
+
$restorePanel.innerHTML = `
|
|
2178
|
+
<div id="onboardRestoreOutcome" role="alert" style="padding:20px 0;text-align:left;">
|
|
2179
|
+
<h3 style="font-size:16px;font-weight:600;color:var(--t-bright);margin-bottom:10px;">${esc(words.title)}</h3>
|
|
2180
|
+
<ul style="margin:0 0 14px;padding-left:18px;font-size:12px;line-height:1.45;color:var(--t-primary);">
|
|
2181
|
+
${words.messages.map((message) => `<li style="margin-bottom:6px;">${esc(message)}</li>`).join('')}
|
|
2182
|
+
</ul>
|
|
2183
|
+
${words.note ? `<p id="onboardOutcomeNote" style="font-size:11px;color:var(--t-muted);margin-bottom:14px;">${esc(words.note)}</p>` : ''}
|
|
2184
|
+
<div id="onboardOutcomeError" role="alert" style="display:none;font-size:12px;color:var(--accent-dim);margin-bottom:10px;"></div>
|
|
2185
|
+
<div style="display:flex;gap:10px;justify-content:center;">${words.retryFirst ? `${goButton}${tryButton}` : `${tryButton}${goButton}`}</div>
|
|
2186
|
+
</div>
|
|
2187
|
+
`;
|
|
2188
|
+
resizeViewport(0);
|
|
2189
|
+
const retry = document.getElementById('onboardOutcomeRetry');
|
|
2190
|
+
const go = document.getElementById('onboardOutcomeContinue');
|
|
2191
|
+
const errorEl = document.getElementById('onboardOutcomeError');
|
|
2192
|
+
retry.addEventListener('click', () => {
|
|
2193
|
+
clearRestoreOutcome();
|
|
2194
|
+
resetRestorePanel();
|
|
2195
|
+
updateNav();
|
|
2196
|
+
$choices.style.display = 'none';
|
|
2197
|
+
$restorePanel.style.display = 'block';
|
|
2198
|
+
$restorePanel.classList.add('visible');
|
|
2199
|
+
resizeViewport(0);
|
|
2200
|
+
});
|
|
2201
|
+
// Once per page: a server that did not come back in time is not waited for again on the next press.
|
|
2202
|
+
let awaitRestart = outcome.restart;
|
|
2203
|
+
go.addEventListener('click', async () => {
|
|
2204
|
+
retry.disabled = true;
|
|
2205
|
+
go.disabled = true;
|
|
2206
|
+
go.textContent = words.continuing;
|
|
2207
|
+
errorEl.style.display = 'none';
|
|
2208
|
+
try {
|
|
2209
|
+
if (awaitRestart) {
|
|
2210
|
+
awaitRestart = false;
|
|
2211
|
+
if (!(await waitForServerBack(bootId))) throw new Error('not back');
|
|
2212
|
+
}
|
|
2213
|
+
const res = await fetch('/api/setup/complete', { method: 'POST' });
|
|
2214
|
+
if (!res.ok) throw new Error('not completed');
|
|
2215
|
+
} catch {
|
|
2216
|
+
retry.disabled = false;
|
|
2217
|
+
go.disabled = false;
|
|
2218
|
+
go.textContent = words.continueAnyway;
|
|
2219
|
+
errorEl.textContent = words.continueFailed;
|
|
2220
|
+
errorEl.style.display = '';
|
|
2221
|
+
resizeViewport(0);
|
|
2222
|
+
return;
|
|
2029
2223
|
}
|
|
2224
|
+
clearRestoreOutcome();
|
|
2225
|
+
window.location.href = '/';
|
|
2030
2226
|
});
|
|
2031
2227
|
}
|
|
2228
|
+
resumeRestoreOutcome = showRestoreOutcome;
|
|
2032
2229
|
|
|
2033
2230
|
function resetRestorePanel() {
|
|
2034
2231
|
$restorePanel.classList.remove('visible');
|
|
@@ -2041,10 +2238,10 @@ function renderHappyBun() {}
|
|
|
2041
2238
|
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>
|
|
2042
2239
|
</svg>
|
|
2043
2240
|
</div>
|
|
2044
|
-
<div class="restore-dropzone-text">Drop your backup .zip here</div>
|
|
2241
|
+
<div class="restore-dropzone-text">Drop your backup .zip or .zip.enc here</div>
|
|
2045
2242
|
<div class="restore-dropzone-hint">or click to browse</div>
|
|
2046
2243
|
</div>
|
|
2047
|
-
<input type="file" id="onboardRestoreFile" accept=".zip" style="display:none">
|
|
2244
|
+
<input type="file" id="onboardRestoreFile" accept=".zip,.enc" style="display:none">
|
|
2048
2245
|
<div id="onboardRestoreStatus" style="display:none;margin-top:12px;font-size:12px;align-items:center;gap:8px">
|
|
2049
2246
|
<div class="wiz-status-dot spin" id="onboardRestoreDot"></div>
|
|
2050
2247
|
<span id="onboardRestoreText"></span>
|
|
@@ -2053,6 +2250,11 @@ function renderHappyBun() {}
|
|
|
2053
2250
|
<span class="restore-back-link" id="restoreBackLink">← Back to options</span>
|
|
2054
2251
|
</div>
|
|
2055
2252
|
`;
|
|
2253
|
+
$dropzone = document.getElementById('restoreDropzone');
|
|
2254
|
+
$statusEl = document.getElementById('onboardRestoreStatus');
|
|
2255
|
+
$statusDot = document.getElementById('onboardRestoreDot');
|
|
2256
|
+
$statusText = document.getElementById('onboardRestoreText');
|
|
2257
|
+
$backLink = $restorePanel.querySelector('.restore-back-link');
|
|
2056
2258
|
// Show the choices again
|
|
2057
2259
|
$choices.style.display = '';
|
|
2058
2260
|
resizeViewport(0);
|
|
@@ -2064,7 +2266,7 @@ function renderHappyBun() {}
|
|
|
2064
2266
|
function rewireDropzone() {
|
|
2065
2267
|
const dz = document.getElementById('restoreDropzone');
|
|
2066
2268
|
const fi = document.getElementById('onboardRestoreFile');
|
|
2067
|
-
const bl =
|
|
2269
|
+
const bl = $restorePanel.querySelector('.restore-back-link');
|
|
2068
2270
|
|
|
2069
2271
|
dz.addEventListener('click', () => fi.click());
|
|
2070
2272
|
dz.addEventListener('dragover', (e) => { e.preventDefault(); dz.classList.add('dragover'); });
|
|
@@ -2073,7 +2275,7 @@ function renderHappyBun() {}
|
|
|
2073
2275
|
e.preventDefault();
|
|
2074
2276
|
dz.classList.remove('dragover');
|
|
2075
2277
|
const file = e.dataTransfer.files[0];
|
|
2076
|
-
if (file && file.name
|
|
2278
|
+
if (file && /\.zip(?:\.enc)?$/i.test(file.name)) handleRestoreFile(file);
|
|
2077
2279
|
});
|
|
2078
2280
|
fi.addEventListener('change', (e) => {
|
|
2079
2281
|
const file = e.target.files[0];
|
|
@@ -2781,6 +2983,22 @@ async function loadRulesStrings() {
|
|
|
2781
2983
|
return rulesTx;
|
|
2782
2984
|
}
|
|
2783
2985
|
|
|
2986
|
+
// The restore's words, in the language the app would use (the rest of the wizard is English). English if that file
|
|
2987
|
+
// could not be read; null only when no strings could be read at all, and the messages then have an English fallback.
|
|
2988
|
+
let restoreTx = null;
|
|
2989
|
+
async function loadRestoreStrings() {
|
|
2990
|
+
if (restoreTx) return restoreTx;
|
|
2991
|
+
let saved = null;
|
|
2992
|
+
try { saved = localStorage.getItem('synabun-locale'); } catch { /* storage is not available */ }
|
|
2993
|
+
const url = restoreCatalogueUrl({ search: location.search, saved, languages: [navigator.language, ...(navigator.languages || [])] });
|
|
2994
|
+
try {
|
|
2995
|
+
const res = await fetch(url);
|
|
2996
|
+
if (res.ok) restoreTx = catalogueTranslator(await res.json());
|
|
2997
|
+
} catch { /* English, below */ }
|
|
2998
|
+
if (!restoreTx) restoreTx = await loadRulesStrings();
|
|
2999
|
+
return restoreTx;
|
|
3000
|
+
}
|
|
3001
|
+
|
|
2784
3002
|
// The rendered text for a host, from the rules route or the older read-only endpoint.
|
|
2785
3003
|
async function loadRulesText(host) {
|
|
2786
3004
|
if (!rulesTextCache[host]) rulesTextCache[host] = await fetchRulesTextWithFallback(host);
|
|
@@ -3060,10 +3278,13 @@ document.getElementById('launchBtn').addEventListener('click', async () => {
|
|
|
3060
3278
|
// ═══════════════════════════════════════════
|
|
3061
3279
|
|
|
3062
3280
|
async function init() {
|
|
3281
|
+
// A restore that finished with problems and was not answered yet. A restored .env can say setup is complete: the
|
|
3282
|
+
// wizard stays until the owner has read it.
|
|
3283
|
+
const waitingRestore = readRestoreOutcome();
|
|
3063
3284
|
try {
|
|
3064
3285
|
const res = await fetch('/api/setup/onboarding');
|
|
3065
3286
|
const data = await res.json();
|
|
3066
|
-
if (data.setupComplete) {
|
|
3287
|
+
if (data.setupComplete && !waitingRestore) {
|
|
3067
3288
|
window.location.href = '/';
|
|
3068
3289
|
return;
|
|
3069
3290
|
}
|
|
@@ -3087,6 +3308,10 @@ async function init() {
|
|
|
3087
3308
|
startMascot();
|
|
3088
3309
|
// Resize after mascot SVG is injected so scrollHeight includes it
|
|
3089
3310
|
requestAnimationFrame(() => resizeViewport(0));
|
|
3311
|
+
if (waitingRestore) {
|
|
3312
|
+
await Promise.race([loadRestoreStrings().catch(() => null), new Promise((done) => setTimeout(done, 2000))]);
|
|
3313
|
+
resumeRestoreOutcome(waitingRestore);
|
|
3314
|
+
}
|
|
3090
3315
|
}
|
|
3091
3316
|
|
|
3092
3317
|
init();
|
|
@@ -154,9 +154,3 @@ export function reviewCountOf(answer) {
|
|
|
154
154
|
if (!agents) return null;
|
|
155
155
|
return agents.filter((agent) => agent?.draft?.status === 'in_review').length;
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
/** The count badge's text: nothing for none, the number, "99+" above it. */
|
|
159
|
-
export function badgeText(count) {
|
|
160
|
-
if (!Number.isInteger(count) || count <= 0) return '';
|
|
161
|
-
return count > 99 ? '99+' : String(count);
|
|
162
|
-
}
|
|
@@ -28,7 +28,7 @@ import { createUnloadGuard } from '../../editor/editor-safety.js';
|
|
|
28
28
|
import { askInPanel, dialogOpen, closeDialog } from '../../skills/ss-dialog.js';
|
|
29
29
|
import { closeDropdowns } from '../../cc-dropdown.js';
|
|
30
30
|
import { frameRect } from '../../app-frame.js';
|
|
31
|
-
import { initialRect } from '../../skills/studio/sx-geometry.js';
|
|
31
|
+
import { initialRect, openRect } from '../../skills/studio/sx-geometry.js';
|
|
32
32
|
import { html, setHTML, ICONS, inTextField, focusableIn, trapIndex } from '../../skills/studio/sx-dom.js';
|
|
33
33
|
import { createAgentsApi } from './ax-api.js';
|
|
34
34
|
import { parseOpen, initialView, viewToSave, navigate, railModel, agentKeyText, capsFailure, PLACES } from './ax-views.js';
|
|
@@ -177,6 +177,7 @@ export async function openStudio(detail = {}) {
|
|
|
177
177
|
S.gen++;
|
|
178
178
|
S.opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
179
179
|
S.docked = storage.getItem(DOCK_KEY) === 'true';
|
|
180
|
+
S.floating = null;
|
|
180
181
|
S.dim = storage.getItem(DIM_KEY) === 'true' && !S.docked;
|
|
181
182
|
S.filters = cleanFilters(readJson(FILTERS_KEY, null));
|
|
182
183
|
S.view = initialView(readJson(VIEW_KEY, null));
|
|
@@ -226,13 +227,18 @@ export async function openStudio(detail = {}) {
|
|
|
226
227
|
focusPlace();
|
|
227
228
|
}
|
|
228
229
|
|
|
229
|
-
function placeWindow() {
|
|
230
|
+
function placeWindow(floating = null) {
|
|
230
231
|
const panel = S.panel;
|
|
231
232
|
if (S.docked) { panel.style.left = ''; panel.style.top = ''; panel.style.width = ''; panel.style.height = ''; return; }
|
|
232
|
-
|
|
233
|
-
let
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
const view = { vw: window.innerWidth, vh: window.innerHeight, frame: frameRect() };
|
|
234
|
+
let rect;
|
|
235
|
+
if (floating) rect = initialRect({ ...view, saved: floating }); // Undocked: the size it had before docking.
|
|
236
|
+
else {
|
|
237
|
+
// Opening: the shared size, at the position the panel system saved (ui-panels.js savePanelLayout).
|
|
238
|
+
let saved = null;
|
|
239
|
+
try { saved = JSON.parse(storage.getItem(`${KEYS.PANEL_PREFIX}${PANEL_ID}`) || 'null'); } catch { saved = null; }
|
|
240
|
+
rect = openRect({ ...view, saved });
|
|
241
|
+
}
|
|
236
242
|
Object.assign(panel.style, { left: `${rect.left}px`, top: `${rect.top}px`, width: `${rect.width}px`, height: `${rect.height}px` });
|
|
237
243
|
}
|
|
238
244
|
|
|
@@ -392,6 +398,7 @@ function onKeydown(e) {
|
|
|
392
398
|
}
|
|
393
399
|
|
|
394
400
|
function toggleDock() {
|
|
401
|
+
if (!S.docked) { const { left, top, width, height } = S.panel.style; S.floating = { left, top, width, height }; }
|
|
395
402
|
S.docked = !S.docked;
|
|
396
403
|
storage.setItem(DOCK_KEY, S.docked ? 'true' : 'false');
|
|
397
404
|
if (S.docked && S.dim) toggleDim(false);
|
|
@@ -402,7 +409,7 @@ function toggleDock() {
|
|
|
402
409
|
if (btn) { btn.setAttribute('aria-pressed', S.docked ? 'true' : 'false'); setHTML(btn, S.docked ? ICONS.undock : ICONS.dock); }
|
|
403
410
|
const dim = S.panel.querySelector('[data-act="dim"]');
|
|
404
411
|
if (dim) dim.disabled = S.docked;
|
|
405
|
-
placeWindow();
|
|
412
|
+
placeWindow(S.docked ? null : S.floating);
|
|
406
413
|
announce(t(S.docked ? 'agentsStudio.shell.docked' : 'agentsStudio.shell.undocked'));
|
|
407
414
|
}
|
|
408
415
|
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
// Nothing here keeps a list of its own: the pickers show what the session
|
|
10
10
|
// says, in its words, and write back the value it gave.
|
|
11
11
|
|
|
12
|
+
import { effortLabelFor } from '../effort-i18n.js';
|
|
13
|
+
|
|
12
14
|
/** The first select option of a category ('model', 'thought_level', 'mode'), or null. */
|
|
13
15
|
export function optionByCategory(configOptions, category) {
|
|
14
16
|
return (Array.isArray(configOptions) ? configOptions : []).find((option) => option && option.category === category && (option.type === 'select' || option.type === undefined)) || null;
|
|
@@ -32,6 +34,15 @@ export function dropdownEntries(option) {
|
|
|
32
34
|
}).filter(Boolean);
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The thinking picker's entries with the standard level names in the user's language (display only: `value` is
|
|
39
|
+
* what is sent back). A name Antigravity wrote itself, or an unknown level, stays as it came.
|
|
40
|
+
*/
|
|
41
|
+
export function localizeThinkingEntries(entries, t) {
|
|
42
|
+
const one = (entry) => (entry && typeof entry.value === 'string' ? { ...entry, label: effortLabelFor(entry.value, entry.label, t) } : entry);
|
|
43
|
+
return (Array.isArray(entries) ? entries : []).map((entry) => (entry && Array.isArray(entry.options) ? { ...entry, options: entry.options.map(one) } : one(entry)));
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
/** The label of an option's current value ('Gemini 3.8 Flash'), or the raw value. */
|
|
36
47
|
export function currentLabel(option) {
|
|
37
48
|
if (!option) return '';
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from './agy-events.js';
|
|
27
27
|
import {
|
|
28
28
|
dropdownEntries, elicitationContent, elicitationFields, modeEntries, optionByCategory, permissionCard, quickOption,
|
|
29
|
-
secondaryOptions, toggledValue, withValue,
|
|
29
|
+
localizeThinkingEntries, secondaryOptions, toggledValue, withValue,
|
|
30
30
|
} from './agy-options.js';
|
|
31
31
|
import {
|
|
32
32
|
attachmentProblem, attachmentType, automationEvent, MAX_TABS, newTab, openSessionRequest, promptRequest, restoreTabs, runGeminiDir, serializeTabs, sessionLoadNotice, stagedPicture, tabLabel,
|
|
@@ -47,6 +47,7 @@ import { dropdownHTML, setDropdownDisabled, setDropdownItems, wireDropdowns, clo
|
|
|
47
47
|
import { renderMarkdown } from '../cp/cp-markdown.js';
|
|
48
48
|
import { createKeyedHtmlList } from '../dom-morph.js';
|
|
49
49
|
import { watchTranscriptRows } from '../transcript-rows.js';
|
|
50
|
+
import { createStickyScrollController } from '../ui-scroll-follow.js';
|
|
50
51
|
import { fetchProjects } from '../api.js';
|
|
51
52
|
import { createCliInstallController } from '../cli-install-controller.js';
|
|
52
53
|
import { setCliInstallTranslator } from '../cli-install-view.js';
|
|
@@ -1023,7 +1024,7 @@ function closeTab(idx, { closeSession = true } = {}) {
|
|
|
1023
1024
|
if (tab.automationRunId) {
|
|
1024
1025
|
const runId = tab.automationRunId;
|
|
1025
1026
|
window.dispatchEvent(new CustomEvent('native-loop:dismissed', { detail: { runId } }));
|
|
1026
|
-
endWorkerRunOnClose(runId, () => fetch('/api/loop/stop', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ runId }) }).catch(() => {}), { busy: !!tab.running });
|
|
1027
|
+
endWorkerRunOnClose(runId, () => fetch('/api/loop/stop', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ runId, action: 'tab_close' }) }).catch(() => {}), { busy: !!tab.running });
|
|
1027
1028
|
forgetWorkerEnd(runId);
|
|
1028
1029
|
}
|
|
1029
1030
|
tab.pillEl?.remove();
|
|
@@ -1042,7 +1043,7 @@ function closeTab(idx, { closeSession = true } = {}) {
|
|
|
1042
1043
|
// ── Rendering ──
|
|
1043
1044
|
function scheduleRender(tab = null, { follow = false } = {}) {
|
|
1044
1045
|
if (tab && tab !== activeTab()) { renderPills(); return; }
|
|
1045
|
-
if (follow) { const rt = runtimeOf(activeTab()); if (rt) rt.scrolledUp = false; }
|
|
1046
|
+
if (follow) { const rt = runtimeOf(activeTab()); if (rt) rt.scrolledUp = false; _scroll?.setFollowing(true); }
|
|
1046
1047
|
// A closed panel draws nothing: a pass rebuilds the whole transcript and reads its layout, once per frame
|
|
1047
1048
|
// for as long as a session streams there. Its pill says what the session does; showing the panel draws
|
|
1048
1049
|
// everything (setVisible → renderAll), from the same state.
|
|
@@ -1185,7 +1186,7 @@ function renderPickers() {
|
|
|
1185
1186
|
modelInput.dataset.configId = model?.id || '';
|
|
1186
1187
|
}
|
|
1187
1188
|
if (thinkingInput) {
|
|
1188
|
-
const entries = thinking ? dropdownEntries(thinking) : [{ value: '', label: T('thinking'), selected: true }];
|
|
1189
|
+
const entries = thinking ? localizeThinkingEntries(dropdownEntries(thinking), t) : [{ value: '', label: T('thinking'), selected: true }];
|
|
1189
1190
|
setDropdownItems(thinkingInput, entries);
|
|
1190
1191
|
setDropdownDisabled(thinkingInput, locked || !thinking);
|
|
1191
1192
|
thinkingInput.dataset.configId = thinking?.id || '';
|
|
@@ -1278,6 +1279,12 @@ function renderQueue() {
|
|
|
1278
1279
|
// its whole transcript replaced on every frame; now it is the row being written.
|
|
1279
1280
|
let _transcriptList = null;
|
|
1280
1281
|
let _transcriptListBox = null;
|
|
1282
|
+
// The transcript's bottom follow (ui-scroll-follow.js): one controller over the one transcript element,
|
|
1283
|
+
// the panel's per-tab scrolledUp intent restored into it before a tab's rows are drawn (as Maritaca does).
|
|
1284
|
+
// It follows late layout and a message area whose height changes, which a write inside renderTranscript
|
|
1285
|
+
// alone never saw; its own scroll events never detach it.
|
|
1286
|
+
let _scroll = null;
|
|
1287
|
+
let _followTabId = null;
|
|
1281
1288
|
function transcriptList(box) {
|
|
1282
1289
|
if (_transcriptListBox !== box) { _transcriptList = createKeyedHtmlList(box); _transcriptListBox = box; }
|
|
1283
1290
|
return _transcriptList;
|
|
@@ -1316,8 +1323,10 @@ function renderTranscript() {
|
|
|
1316
1323
|
if (!box) return;
|
|
1317
1324
|
const tab = activeTab();
|
|
1318
1325
|
const rt = runtimeOf(tab);
|
|
1319
|
-
if (!tab || !rt) { box.innerHTML = ''; transcriptList(box).forget(); return; }
|
|
1320
|
-
|
|
1326
|
+
if (!tab || !rt) { box.innerHTML = ''; transcriptList(box).forget(); _followTabId = null; return; }
|
|
1327
|
+
// Another tab's rows are about to be drawn: restore this tab's follow intent into the shared controller
|
|
1328
|
+
// first (it cancels the preceding tab's queued scroll), as Maritaca's renderTranscript does.
|
|
1329
|
+
if (_followTabId !== tab.id) { _scroll?.setFollowing(!rt.scrolledUp); _followTabId = tab.id; }
|
|
1321
1330
|
const setup = currentSetup();
|
|
1322
1331
|
const rows = rt.transcript.rows;
|
|
1323
1332
|
const ctx = {
|
|
@@ -1353,11 +1362,20 @@ function renderTranscript() {
|
|
|
1353
1362
|
}
|
|
1354
1363
|
box._agyEmpty = null;
|
|
1355
1364
|
if (setupBlock) parts.unshift({ key: `${tab.id}:setup`, html: setupBlock });
|
|
1365
|
+
// Save the reader's scroll position before patching: replacing the streaming row in WebKit
|
|
1366
|
+
// briefly empties the flex scroller and resets scrollTop to 0 unless restored when not following.
|
|
1367
|
+
const prevScrollTop = box.scrollTop;
|
|
1356
1368
|
replaceKeepingFocus(box, parts, rt);
|
|
1357
1369
|
placeWorkerEnd(box, tab);
|
|
1358
1370
|
// A kept setup block keeps its classes: the nudge is set to what it is now, not only added.
|
|
1359
1371
|
box.querySelector('.agy-setup')?.classList.toggle('agy-nudge', !!_setup.nudge);
|
|
1360
|
-
|
|
1372
|
+
// The follow write is the controller's (instant, generation-checked): it also answers late layout and a
|
|
1373
|
+
// message-area height change between renders. force re-asserts the intent the tab was drawn with, so a
|
|
1374
|
+
// scroll event from the rows being replaced cannot detach it; a reader who scrolled up is left alone.
|
|
1375
|
+
const stick = _scroll?.isFollowing() ?? !rt.scrolledUp;
|
|
1376
|
+
rt.scrolledUp = !stick;
|
|
1377
|
+
if (stick) _scroll?.scrollToBottom({ force: true, immediate: true });
|
|
1378
|
+
else box.scrollTop = prevScrollTop;
|
|
1361
1379
|
const jump = $('.agy-jump');
|
|
1362
1380
|
if (jump) jump.hidden = !rt.scrolledUp;
|
|
1363
1381
|
}
|
|
@@ -1572,6 +1590,7 @@ function renderPills() {
|
|
|
1572
1590
|
const pill = document.createElement('div');
|
|
1573
1591
|
pill.className = 'term-minimized-pill agy-session-pill';
|
|
1574
1592
|
pill.dataset.tabId = tab.id;
|
|
1593
|
+
pill.getAutomationRunId = () => tab.automationRunId;
|
|
1575
1594
|
pill.tabIndex = 0;
|
|
1576
1595
|
pill.innerHTML = `<span class="term-minimized-pill-icon agy-mark">${ICON}</span><span class="term-minimized-pill-label"></span><button class="term-minimized-pill-close" data-tooltip="${esc(T('closeTab'))}" data-tooltip-pos="top">×</button>`;
|
|
1577
1596
|
const openIt = () => {
|
|
@@ -2263,8 +2282,7 @@ function wire() {
|
|
|
2263
2282
|
$('.agy-jump').addEventListener('click', () => {
|
|
2264
2283
|
const rt = runtimeOf(activeTab());
|
|
2265
2284
|
if (rt) rt.scrolledUp = false;
|
|
2266
|
-
|
|
2267
|
-
if (box) box.scrollTop = box.scrollHeight;
|
|
2285
|
+
_scroll?.scrollToBottom({ force: true, immediate: true });
|
|
2268
2286
|
$('.agy-jump').hidden = true;
|
|
2269
2287
|
});
|
|
2270
2288
|
const transcript = $('.agy-transcript');
|
|
@@ -2272,10 +2290,11 @@ function wire() {
|
|
|
2272
2290
|
// Rows far from the screen are skipped by the engine, at their exact size (transcript-rows.js). The rows
|
|
2273
2291
|
// stay the same nodes from one pass to the next now (transcriptList), so what is known of them holds.
|
|
2274
2292
|
watchTranscriptRows(transcript);
|
|
2293
|
+
_scroll = createStickyScrollController(transcript);
|
|
2275
2294
|
transcript.addEventListener('scroll', () => {
|
|
2276
2295
|
const rt = runtimeOf(activeTab());
|
|
2277
2296
|
if (!rt) return;
|
|
2278
|
-
rt.scrolledUp =
|
|
2297
|
+
rt.scrolledUp = !_scroll.isFollowing();
|
|
2279
2298
|
const jump = $('.agy-jump');
|
|
2280
2299
|
if (jump) jump.hidden = !rt.scrolledUp;
|
|
2281
2300
|
});
|