synabun 2.4.0 → 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 +47 -0
- package/README.md +1 -1
- package/browser-extension/content.js +73 -11
- package/browser-extension/engine.js +196 -15
- package/browser-extension/manifest.json +4 -2
- package/browser-extension/popup-strings.js +10 -4
- package/browser-extension/popup-view.js +1 -1
- package/browser-extension/popup.css +1 -0
- package/browser-extension/popup.html +4 -1
- package/browser-extension/popup.js +22 -10
- package/browser-extension/protocol.js +102 -11
- package/browser-extension/service-worker.js +20 -4
- package/browser-extension/tokens.css +1 -1
- package/docs/browser-extension-bridge.md +25 -5
- package/lib/data-home-files.js +47 -0
- package/lib/data-home-migration.js +34 -58
- 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 +6 -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 +13 -8
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +35 -15
- 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 +23 -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 +33 -14
- 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 +266 -2
- package/neural-interface/i18n/pt-BR.json +267 -3
- package/neural-interface/lib/agents/builtins.json +207 -0
- package/neural-interface/lib/agents/registry.js +60 -15
- package/neural-interface/lib/agents/resolve.js +69 -10
- 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-brains/opencode.js +60 -11
- 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 +384 -119
- package/neural-interface/lib/assistant-persona.js +17 -5
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +181 -54
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +48 -34
- 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 +836 -322
- 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 +109 -24
- package/neural-interface/lib/browser-extension-bridge.js +42 -8
- 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 +34 -14
- package/neural-interface/lib/opencode-build-preflight.js +30 -8
- 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/peer-identity.js +13 -8
- 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 +70 -44
- 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 +196 -97
- package/neural-interface/lib/teams/schema.js +1 -1
- 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 +260 -0
- package/neural-interface/public/offline.html +4 -3
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
- 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/agents/studio/ax-ui.js +2 -2
- 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 +3 -2
- 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 +106 -38
- package/neural-interface/public/shared/assistant/asst-route.js +102 -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/cc-dropdown.js +21 -15
- 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 -51
- 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/owner-authority-view.js +4 -10
- package/neural-interface/public/shared/page-session.js +1 -1
- 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-ai-browser.js +5 -5
- 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/start-bridge.js +2 -2
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +354 -438
- 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 +185 -25
- package/neural-interface/public/shared/ui-native-loop-router.js +59 -20
- 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-owner-authority.js +48 -25
- 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 +234 -67
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-sync.js +1 -0
- 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/sw.js +4 -3
- 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 +17 -4
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +507 -160
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sessionProjectItems } from './session-project-items.js';
|
|
2
2
|
import { t } from './i18n.js';
|
|
3
|
+
import { thinkToggleText } from './effort-i18n.js';
|
|
3
4
|
import { answerWorkerQuestion, syncWorkerQuestionQueue } from './worker-questions.js';
|
|
4
5
|
import { providerAuthSnapshot } from './ui-provider-auth.js';
|
|
5
6
|
import { mountProviderTerminalAuth, providerApiKeyRequest, startProviderTerminalLogin } from './ui-provider-terminal-auth.js';
|
|
@@ -29,6 +30,7 @@ import { isFarRowStyleRecord, watchTranscriptRows } from './transcript-rows.js';
|
|
|
29
30
|
import { requestGeneratedSessionTitle } from './session-title.js';
|
|
30
31
|
import { wireFileLinks } from './ui-file-links.js';
|
|
31
32
|
import { decorateCodeBlocks, installCodeCopy } from './ui-code-copy.js';
|
|
33
|
+
import { decorateOutput, installOutput } from './ui-output.js';
|
|
32
34
|
import { WORKER_END_CLASS, buildWorkerEndCard, endWorkerRunOnClose, forgetWorkerEnd, leaveWorkerTab, trackWorkerEnd, updateWorkerEndBusy } from './ui-worker-end.js';
|
|
33
35
|
import { isDispatchedRun, isEndOfRunAbort, workerEndView } from './worker-end.js';
|
|
34
36
|
import { runAwaitsAnswer, runTurnLive } from './sidepanel-session-status.js';
|
|
@@ -673,67 +675,9 @@ function injectStyles() {
|
|
|
673
675
|
}
|
|
674
676
|
.cp-messages .msg-avatar svg { width: 14px; height: 14px; }
|
|
675
677
|
.cp-messages .msg-content { flex: 1; min-width: 0; }
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
font-family: 'Inter', -apple-system, sans-serif;
|
|
680
|
-
}
|
|
681
|
-
.cp-messages .msg-body p { margin: 0 0 0.5em; }
|
|
682
|
-
.cp-messages .msg-body p:last-child { margin-bottom: 0; }
|
|
683
|
-
.cp-messages .msg-body h1,.cp-messages .msg-body h2,.cp-messages .msg-body h3 {
|
|
684
|
-
color: var(--t-bright); margin: 0.7em 0 0.25em; font-weight: 600;
|
|
685
|
-
}
|
|
686
|
-
.cp-messages .msg-body h1 { font-size: 14px; }
|
|
687
|
-
.cp-messages .msg-body h2 { font-size: 13px; }
|
|
688
|
-
.cp-messages .msg-body h3 { font-size: 12px; }
|
|
689
|
-
.cp-messages .msg-body code:not(pre code) {
|
|
690
|
-
background: var(--s-subtle); border: 1px solid var(--b-subtle);
|
|
691
|
-
border-radius: 4px; padding: 1px 5px; font-family: 'JetBrains Mono', monospace;
|
|
692
|
-
font-size: 0.88em; color: var(--t-bright);
|
|
693
|
-
}
|
|
694
|
-
.cp-messages .msg-body pre {
|
|
695
|
-
background: rgba(0,0,0,0.3); border: 1px solid var(--b-subtle);
|
|
696
|
-
border-radius: 8px; padding: 10px; overflow-x: auto; margin: 0.5em 0;
|
|
697
|
-
position: relative;
|
|
698
|
-
}
|
|
699
|
-
.cp-messages .msg-body pre code {
|
|
700
|
-
font-family: 'JetBrains Mono', monospace; font-size: 11px;
|
|
701
|
-
color: var(--t-primary); background: none; border: none; padding: 0;
|
|
702
|
-
}
|
|
703
|
-
/* A block's Copy button is the shared one (../code-copy.js, ui-code-copy.js): its styles come with it. */
|
|
704
|
-
.cp-messages .msg-body a { color: var(--t-bright); text-decoration: none; }
|
|
705
|
-
.cp-messages .msg-body a:hover { text-decoration: underline; }
|
|
706
|
-
.cp-messages .msg-body strong { color: var(--t-bright); }
|
|
707
|
-
.cp-messages .msg-body ul, .cp-messages .msg-body ol { padding-left: 1.3em; margin: 0.3em 0; }
|
|
708
|
-
.cp-messages .msg-body ul { list-style: none; }
|
|
709
|
-
.cp-messages .msg-body ul li { position: relative; }
|
|
710
|
-
.cp-messages .msg-body ul li::before {
|
|
711
|
-
content: ''; position: absolute; left: -1em; top: 0.6em;
|
|
712
|
-
width: 4px; height: 4px; border-radius: 50%;
|
|
713
|
-
background: rgba(255,255,255,0.2);
|
|
714
|
-
}
|
|
715
|
-
.cp-messages .msg-body ol li { color: var(--t-primary); }
|
|
716
|
-
.cp-messages .msg-body ol li::marker { color: var(--t-faint); font-size: 11px; }
|
|
717
|
-
.cp-messages .msg-body blockquote {
|
|
718
|
-
margin: 0.5em 0; padding: 4px 0 4px 12px;
|
|
719
|
-
border-left: 2px solid rgba(200,160,80,0.3);
|
|
720
|
-
color: var(--t-secondary); font-style: italic;
|
|
721
|
-
}
|
|
722
|
-
.cp-messages .msg-body hr {
|
|
723
|
-
border: none; height: 1px; margin: 0.8em 0;
|
|
724
|
-
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08) 20%, rgba(255,255,255,0.08) 80%, transparent);
|
|
725
|
-
}
|
|
726
|
-
.cp-messages .msg-body table {
|
|
727
|
-
width: 100%; border-collapse: collapse; margin: 0.5em 0; font-size: 11px;
|
|
728
|
-
}
|
|
729
|
-
.cp-messages .msg-body th {
|
|
730
|
-
text-align: left; padding: 4px 8px; font-weight: 600; color: var(--t-bright);
|
|
731
|
-
background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.08);
|
|
732
|
-
}
|
|
733
|
-
.cp-messages .msg-body td {
|
|
734
|
-
padding: 3px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--t-primary);
|
|
735
|
-
}
|
|
736
|
-
.cp-messages .msg-body tr:hover td { background: rgba(255,255,255,0.02); }
|
|
678
|
+
/* An answer's prose, tables and code are the shared reading layer (./ui-output.js): one system for the six
|
|
679
|
+
side panels. A tag is never styled here again; this panel's own voice is its font. */
|
|
680
|
+
.cp-messages .msg-body { font-family: 'Inter', -apple-system, sans-serif; }
|
|
737
681
|
|
|
738
682
|
/* ── Tool cards ── */
|
|
739
683
|
.cp-messages .tool-card {
|
|
@@ -2664,10 +2608,39 @@ function injectStyles() {
|
|
|
2664
2608
|
/* Queue send icon */
|
|
2665
2609
|
.cp-send.queue-mode { }
|
|
2666
2610
|
.cp-send.queue-mode svg { opacity: 0.9; }
|
|
2611
|
+
|
|
2612
|
+
/* ── Reading pass (2026-11-21): what the agent did is legible and quiet, what it answered leads ──
|
|
2613
|
+
An answer's prose, tables and code are ./ui-output.js. This block is the rest of the transcript: tool rows,
|
|
2614
|
+
thinking, notices and the turn's footer were 8.5–10.5px at 20–30% white. They keep their mono voice, their
|
|
2615
|
+
place and every control; the sizes are 11px (9.5px for the small-caps label) and the faint text is the
|
|
2616
|
+
secondary token. Nothing moved and nothing was removed. */
|
|
2617
|
+
.cp-messages .msg-bubble { font-size: 13px; }
|
|
2618
|
+
.cp-messages .tool-name { font-size: 11px; }
|
|
2619
|
+
.cp-messages .tool-detail { font-size: 11px; color: var(--t-secondary); }
|
|
2620
|
+
.cp-messages .tool-section-label { font-size: 9.5px; color: var(--t-secondary); letter-spacing: 0.08em; }
|
|
2621
|
+
.cp-messages .tool-section { font-size: 11px; color: var(--t-primary); word-break: normal; overflow-wrap: anywhere; }
|
|
2622
|
+
.cp-messages .cp-bash-cmd, .cp-messages .cp-bash-out, .cp-messages .cp-result-text { font-size: 11px; word-break: normal; overflow-wrap: anywhere; }
|
|
2623
|
+
.msg-thinking-content { font-size: 11px; color: var(--t-secondary); line-height: 1.6; }
|
|
2624
|
+
.cp-messages .msg-status { font-size: 11px; color: var(--t-secondary); }
|
|
2625
|
+
.cp-messages .msg-error, .cp-messages .msg-warn { font-size: 11px; }
|
|
2626
|
+
.cp-messages .msg-tools-summary { font-size: 10.5px; color: var(--t-secondary); }
|
|
2627
|
+
.cp-messages .cp-turn-footer { font-size: 10.5px; color: var(--t-secondary); }
|
|
2628
|
+
.cp-messages .cp-msg-note { font-size: 11px; color: var(--t-secondary); }
|
|
2629
|
+
.cp-messages .cp-tool-group-text { color: var(--t-primary); }
|
|
2630
|
+
/* What the agent says while it works (a reply with tool calls under it) is secondary text; its answer is
|
|
2631
|
+
primary. Colour only: nothing moves when a tool call joins a reply. */
|
|
2632
|
+
.cp-messages .msg-content:has(> .tool-card, > .cp-tool-group) > .msg-body { --sbo-text: var(--t-primary); --sbo-strong: var(--t-bright); }
|
|
2633
|
+
/* The answer after the work: a hairline at the top of its row, drawn when the turn's footer lands. It is a
|
|
2634
|
+
background, so it takes no room and nothing moves when it appears. */
|
|
2635
|
+
.cp-messages .msg-assistant:has(.tool-card, .cp-tool-group) + .msg-assistant:has(+ .cp-turn-footer) {
|
|
2636
|
+
background: linear-gradient(var(--b-light), var(--b-light)) no-repeat 48px 0 / calc(100% - 62px) 1px;
|
|
2637
|
+
}
|
|
2667
2638
|
`;
|
|
2668
2639
|
document.head.appendChild(style);
|
|
2669
2640
|
// The Copy button of every code block: its stylesheet and its one click listener, in this document.
|
|
2670
2641
|
installCodeCopy(document);
|
|
2642
|
+
// The reading layer of an agent's answer (prose, tables, code): one stylesheet for the six panels.
|
|
2643
|
+
installOutput(document);
|
|
2671
2644
|
}
|
|
2672
2645
|
|
|
2673
2646
|
// ── Custom dropdown helpers ──
|
|
@@ -2807,10 +2780,10 @@ function _setEffort(btn, level) {
|
|
|
2807
2780
|
if (!btn) return;
|
|
2808
2781
|
btn.dataset.effort = level;
|
|
2809
2782
|
const label = btn.querySelector('.cp-think-label');
|
|
2810
|
-
if (label) label.textContent =
|
|
2783
|
+
if (label) label.textContent = thinkToggleText('label', level, t);
|
|
2811
2784
|
// On a model that always thinks the first stop is the model's default, never "Thinking off".
|
|
2812
2785
|
const view = thinkToggleView(level, _getSelectedModel());
|
|
2813
|
-
btn.setAttribute('data-tooltip', view.corrected ? view.title : (
|
|
2786
|
+
btn.setAttribute('data-tooltip', view.corrected ? view.title : thinkToggleText('title', level, t));
|
|
2814
2787
|
// Light up dots based on level
|
|
2815
2788
|
const dots = btn.querySelectorAll('.cp-think-dots i');
|
|
2816
2789
|
const count = { off: 0, low: 1, medium: 2, high: 3, xhigh: 4, max: 5 }[level] || 0;
|
|
@@ -3213,7 +3186,7 @@ function closeTab(idx, { detachAutomation = false } = {}) {
|
|
|
3213
3186
|
endWorkerRunOnClose(runId, () => fetch('/api/loop/stop', {
|
|
3214
3187
|
method: 'POST',
|
|
3215
3188
|
headers: { 'Content-Type': 'application/json' },
|
|
3216
|
-
body: JSON.stringify({ runId }),
|
|
3189
|
+
body: JSON.stringify({ runId, action: 'tab_close' }),
|
|
3217
3190
|
}).catch(() => {}), { busy: hasLiveBackgroundWork(tab) });
|
|
3218
3191
|
}
|
|
3219
3192
|
if (tab.automationRunId) forgetWorkerEnd(tab.automationRunId);
|
|
@@ -3276,6 +3249,7 @@ function _createTrayPill(tab) {
|
|
|
3276
3249
|
const pill = document.createElement('div');
|
|
3277
3250
|
pill.className = 'term-minimized-pill cp-session-pill';
|
|
3278
3251
|
pill.dataset.tabId = tab.id;
|
|
3252
|
+
pill.getAutomationRunId = () => tab.automationRunId;
|
|
3279
3253
|
pill.innerHTML = `
|
|
3280
3254
|
<span class="cp-pill-ring" aria-hidden="true"><i></i></span>
|
|
3281
3255
|
<span class="term-minimized-pill-icon">${_CP_ICON_SVG}</span>
|
|
@@ -5311,6 +5285,9 @@ async function _loadSessionHistoryNow(sid, $msgs, ownerTab, stale, ticket) {
|
|
|
5311
5285
|
// from a snapshot works as it is.
|
|
5312
5286
|
function addCopyButtons(el) {
|
|
5313
5287
|
decorateCodeBlocks(el);
|
|
5288
|
+
// An answer put back from a snapshot saved before the reading layer gets its tables framed (ui-output.js).
|
|
5289
|
+
// Markdown bodies only; a diff's lines are coloured just below.
|
|
5290
|
+
(el.matches?.('.msg-body') ? [el] : el.querySelectorAll?.('.msg-body') || []).forEach((body) => decorateOutput(body, { diff: false }));
|
|
5314
5291
|
el.querySelectorAll('pre').forEach(pre => {
|
|
5315
5292
|
// Colorize diff lines inline when the code block is a diff
|
|
5316
5293
|
const code = pre.querySelector('code');
|
|
@@ -9785,7 +9762,7 @@ function send({ shift = false } = {}) {
|
|
|
9785
9762
|
fetch('/api/loop/stop', {
|
|
9786
9763
|
method: 'POST',
|
|
9787
9764
|
headers: { 'Content-Type': 'application/json' },
|
|
9788
|
-
body: JSON.stringify({ runId: tab.automationRunId }),
|
|
9765
|
+
body: JSON.stringify({ runId: tab.automationRunId, action: 'stop' }),
|
|
9789
9766
|
}).then(async (res) => {
|
|
9790
9767
|
if (res.ok) { setRunning(tab, false); return; }
|
|
9791
9768
|
let reason = '';
|
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
// nothing more can be fetched, and that is exactly when the overlay wants it.
|
|
17
17
|
import { createMascot } from './synabun-mascot.js';
|
|
18
18
|
import { isDesktopApp } from './desktop-bridge.js';
|
|
19
|
+
import { createServerPresence, probeFailureKind } from './server-presence.js';
|
|
19
20
|
|
|
20
21
|
const $ = (id) => document.getElementById(id);
|
|
22
|
+
const diagnose = (event, data) => window.synabunLoadingDiagnostics?.record(event, data);
|
|
21
23
|
|
|
22
24
|
// ── Internal refs (resolved once on init) ──
|
|
23
25
|
let _statusDot = null;
|
|
@@ -32,6 +34,9 @@ let _mascot = null;
|
|
|
32
34
|
// held (sockets, terminals, panel sessions) was the old server's, so once the
|
|
33
35
|
// server is back the page loads again instead of carrying on.
|
|
34
36
|
let _restartShown = false;
|
|
37
|
+
let currentBoot = '';
|
|
38
|
+
let appWasVisible = false;
|
|
39
|
+
let reloadPending = false;
|
|
35
40
|
// The tab's title from before the restart, for when it is refused.
|
|
36
41
|
let _restartTitle = null;
|
|
37
42
|
|
|
@@ -81,6 +86,12 @@ export function showLoadingError(title, sub, canStart, serverOffline) {
|
|
|
81
86
|
const $overlay = $('loading-overlay');
|
|
82
87
|
if (!$overlay) return;
|
|
83
88
|
|
|
89
|
+
if (window.synabunLoadingDiagnostics) {
|
|
90
|
+
// A title from any other caller stays out of diagnostics, as do all subtitles.
|
|
91
|
+
const known = ['loading.serverOffline', 'loading.connectionFailed', 'loading.health.databaseUnreachable.title',
|
|
92
|
+
'loading.health.remoteUnreachable.title', 'loading.health.authError.title', 'loading.health.connectionError.title'];
|
|
93
|
+
diagnose('overlay-error', { title: known.find(key => t(key) === title) || 'other', serverOffline: !!serverOffline });
|
|
94
|
+
}
|
|
84
95
|
$overlay.classList.add('error');
|
|
85
96
|
if (serverOffline) $overlay.classList.add('server-offline');
|
|
86
97
|
else $overlay.classList.remove('server-offline');
|
|
@@ -128,7 +139,26 @@ export function showLoadingError(title, sub, canStart, serverOffline) {
|
|
|
128
139
|
*/
|
|
129
140
|
export function hideLoading(delay = 400) {
|
|
130
141
|
const $overlay = $('loading-overlay');
|
|
131
|
-
if ($overlay) setTimeout(() => {
|
|
142
|
+
if ($overlay) setTimeout(() => {
|
|
143
|
+
if (_offlineBridge) {
|
|
144
|
+
diagnose('hide-skipped', { state: _offlineBridge.state });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
diagnose('overlay-conceal', { reason: 'hide' });
|
|
148
|
+
markOnce(OVERLAY_HIDDEN_MARK);
|
|
149
|
+
dropOtherOverlays($overlay);
|
|
150
|
+
concealOverlay($overlay);
|
|
151
|
+
}, delay);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The page has one loading overlay, the one this module drives (the first in the document). A first frame and a
|
|
156
|
+
* shell of different versions (one of them from a cache) can leave a second one over the app: it goes.
|
|
157
|
+
*/
|
|
158
|
+
function dropOtherOverlays($overlay) {
|
|
159
|
+
const others = [...document.querySelectorAll('[id="loading-overlay"]')].filter(el => el !== $overlay);
|
|
160
|
+
for (const el of others) el.remove();
|
|
161
|
+
if (others.length) diagnose('overlay-dedupe', { removed: Math.min(others.length, 20) });
|
|
132
162
|
}
|
|
133
163
|
|
|
134
164
|
/** The moment the overlay started to fade for the first time on this page (the time the user waited). */
|
|
@@ -147,7 +177,10 @@ function markOnce(name) {
|
|
|
147
177
|
*/
|
|
148
178
|
export function showLoading() {
|
|
149
179
|
const $overlay = $('loading-overlay');
|
|
150
|
-
if ($overlay)
|
|
180
|
+
if ($overlay) {
|
|
181
|
+
diagnose('overlay-reveal', { reason: 'show' });
|
|
182
|
+
revealOverlay($overlay);
|
|
183
|
+
}
|
|
151
184
|
}
|
|
152
185
|
|
|
153
186
|
/**
|
|
@@ -165,11 +198,13 @@ function resetLoadingToConnecting() {
|
|
|
165
198
|
const $sub = $('loading-sub');
|
|
166
199
|
const $action = $('loading-action');
|
|
167
200
|
const $actionStatus = $('loading-action-status');
|
|
201
|
+
const $retryStatus = $('loading-retry-status');
|
|
168
202
|
|
|
169
203
|
if ($text) $text.textContent = t('loading.connecting');
|
|
170
204
|
if ($sub) $sub.textContent = t('loading.initializingNeural');
|
|
171
205
|
if ($action) $action.style.display = 'none';
|
|
172
206
|
if ($actionStatus) $actionStatus.textContent = '';
|
|
207
|
+
if ($retryStatus) $retryStatus.textContent = '';
|
|
173
208
|
clearStartStatus();
|
|
174
209
|
clearRestartLook();
|
|
175
210
|
if (_statusDot) _statusDot.classList.remove('error');
|
|
@@ -186,6 +221,10 @@ function resetLoadingToConnecting() {
|
|
|
186
221
|
*/
|
|
187
222
|
export function rememberHealth(health) {
|
|
188
223
|
if (!health) return;
|
|
224
|
+
if (!currentBoot && health.bootId) {
|
|
225
|
+
currentBoot = health.bootId;
|
|
226
|
+
window.synabunLoadingDiagnostics?.setBoot(currentBoot);
|
|
227
|
+
}
|
|
189
228
|
try {
|
|
190
229
|
if (health.projectDir) {
|
|
191
230
|
localStorage.setItem('synabun-project-dir', health.projectDir);
|
|
@@ -248,7 +287,10 @@ function updateCmdText(projectDir) {
|
|
|
248
287
|
// ═══════════════════════════════════════════
|
|
249
288
|
|
|
250
289
|
function stopWatchingForServer() {
|
|
251
|
-
if (_offlineBridge)
|
|
290
|
+
if (_offlineBridge) {
|
|
291
|
+
diagnose('bridge-stopped', { state: _offlineBridge.state });
|
|
292
|
+
_offlineBridge.stop();
|
|
293
|
+
}
|
|
252
294
|
_offlineBridge = null;
|
|
253
295
|
poseMascot('asleep');
|
|
254
296
|
}
|
|
@@ -282,6 +324,12 @@ function mountMascot() {
|
|
|
282
324
|
try {
|
|
283
325
|
const still = host.querySelector('svg');
|
|
284
326
|
_mascot = createMascot(host, { width: 160, height: 80, pose: 'sleep', active: false });
|
|
327
|
+
// The rig already paints a vector face for every pose. Show it until the
|
|
328
|
+
// current raster artwork loads, and again if the next pose cannot load.
|
|
329
|
+
const svg = _mascot.el;
|
|
330
|
+
const art = svg?.querySelector('.syna-art');
|
|
331
|
+
art?.addEventListener('load', () => svg.classList.add('art-ready'));
|
|
332
|
+
art?.addEventListener('error', () => svg.classList.remove('art-ready'));
|
|
285
333
|
if (still && still !== _mascot.el) still.style.display = 'none';
|
|
286
334
|
} catch {
|
|
287
335
|
_mascot = null;
|
|
@@ -403,45 +451,83 @@ function watchForServer() {
|
|
|
403
451
|
* Is the server answering, which server is it (`bootId`), and does it say it
|
|
404
452
|
* is on its way out for a restart. One that predates those two says neither.
|
|
405
453
|
*/
|
|
406
|
-
async function probeServer() {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
454
|
+
async function probeServer(observe) {
|
|
455
|
+
let health;
|
|
456
|
+
try { health = await fetchHealth(); }
|
|
457
|
+
catch (error) { observe?.('unreachable', ''); throw error; }
|
|
458
|
+
const seen = {
|
|
459
|
+
up: health?.ok === true,
|
|
410
460
|
boot: typeof health?.bootId === 'string' ? health.bootId : '',
|
|
411
461
|
stopping: health?.restarting === true,
|
|
412
462
|
};
|
|
463
|
+
observe?.(!seen.up ? 'unhealthy' : seen.stopping ? 'stopping' : 'healthy', seen.boot);
|
|
464
|
+
return seen;
|
|
413
465
|
}
|
|
414
466
|
|
|
415
467
|
/** The bridge behind the overlay, for either reason it is up: the server is offline, or it is being restarted. */
|
|
416
468
|
function openBridge() {
|
|
417
469
|
mountMascot();
|
|
418
470
|
const beaconAt = startBeaconTarget(window.location);
|
|
471
|
+
let lastProbe;
|
|
472
|
+
function observeProbe(result, boot) {
|
|
473
|
+
if (_offlineBridge !== bridge || (lastProbe?.result === result && lastProbe.boot === boot)) return;
|
|
474
|
+
lastProbe = { result, boot };
|
|
475
|
+
diagnose('bridge-probe', { result, seenBoot: boot });
|
|
476
|
+
}
|
|
477
|
+
let previousRestart = '';
|
|
478
|
+
function observeRestart({ restart }) {
|
|
479
|
+
if (!restart) return;
|
|
480
|
+
const flags = { asked: restart.asked, accepted: restart.acceptedAt !== null, down: restart.downAt !== null, refused: !!restart.refused };
|
|
481
|
+
const key = JSON.stringify(flags);
|
|
482
|
+
if (key !== previousRestart) diagnose('restart-snapshot', flags);
|
|
483
|
+
previousRestart = key;
|
|
484
|
+
}
|
|
419
485
|
const bridge = createStartBridge({
|
|
420
|
-
probe: probeServer,
|
|
486
|
+
probe: () => probeServer(observeProbe),
|
|
421
487
|
launch: () => openStartLink({ document, location: window.location, userAgent: navigator.userAgent }),
|
|
422
488
|
beacon: beaconAt ? () => fetchStartBeacon(beaconAt) : null,
|
|
423
489
|
port: beaconAt ? beaconAt.port : 0,
|
|
424
490
|
onUpdate(snap) {
|
|
425
491
|
if (_offlineBridge !== bridge) return;
|
|
492
|
+
observeRestart(snap);
|
|
426
493
|
renderStart(snap);
|
|
427
494
|
},
|
|
428
|
-
onState(state) {
|
|
495
|
+
onState(state, { boot }) {
|
|
429
496
|
if (_offlineBridge !== bridge) return;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
setTimeout(() => window.location.reload(), START_LIMITS.reloadDelayMs);
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
resetLoadingToConnecting();
|
|
437
|
-
emit('loading:retried');
|
|
438
|
-
if (_initCallback) _initCallback();
|
|
497
|
+
diagnose('bridge-state', { state });
|
|
498
|
+
observeRestart(bridge.snapshot());
|
|
499
|
+
if (state === 'online') recoverConnection(boot);
|
|
439
500
|
},
|
|
440
501
|
});
|
|
441
502
|
_offlineBridge = bridge;
|
|
503
|
+
diagnose('bridge-created', { reason: _restartShown ? 'restart' : 'offline', state: bridge.state });
|
|
442
504
|
return bridge;
|
|
443
505
|
}
|
|
444
506
|
|
|
507
|
+
/** Complete a healthy retry, whether the person pressed Retry or the bridge saw it first. */
|
|
508
|
+
function recoverConnection(boot) {
|
|
509
|
+
// Older servers have no boot ID. A running page then needs a fresh session
|
|
510
|
+
// after an outage, while an unfinished first boot can retry initialization.
|
|
511
|
+
const needsReload = currentBoot && boot ? currentBoot !== boot : appWasVisible;
|
|
512
|
+
diagnose('recover', { seenBoot: boot, needsReload, appWasVisible, restartShown: _restartShown, reloadPending });
|
|
513
|
+
if (reloadPending) return;
|
|
514
|
+
if (_restartShown || needsReload) {
|
|
515
|
+
reloadPending = true;
|
|
516
|
+
diagnose('reload-scheduled', { reason: _restartShown ? 'restart' : currentBoot && boot ? 'boot-changed' : 'unknown-boot' });
|
|
517
|
+
setTimeout(() => window.location.reload(), START_LIMITS.reloadDelayMs);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
resetLoadingToConnecting();
|
|
521
|
+
if (appWasVisible) {
|
|
522
|
+
appWasVisible = false;
|
|
523
|
+
diagnose('overlay-conceal', { reason: 'recovered' });
|
|
524
|
+
concealOverlay($('loading-overlay'));
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
emit('loading:retried');
|
|
528
|
+
if (_initCallback) _initCallback();
|
|
529
|
+
}
|
|
530
|
+
|
|
445
531
|
// ═══════════════════════════════════════════
|
|
446
532
|
// Restart Server
|
|
447
533
|
// ═══════════════════════════════════════════
|
|
@@ -475,6 +561,7 @@ async function postRestart() {
|
|
|
475
561
|
* every window that it is restarting (`announced`, over the sync socket).
|
|
476
562
|
*/
|
|
477
563
|
function beginRestart({ request = null, announced = false, boot = '' } = {}) {
|
|
564
|
+
diagnose('restart-request', { asked: !!request, announced, restartShown: _restartShown, hasBridge: !!_offlineBridge });
|
|
478
565
|
// Already on screen (this window asked, and here is the server saying so too).
|
|
479
566
|
if (_restartShown && _offlineBridge) {
|
|
480
567
|
_offlineBridge.restart({ announced, boot });
|
|
@@ -491,6 +578,7 @@ function beginRestart({ request = null, announced = false, boot = '' } = {}) {
|
|
|
491
578
|
_offlineTitle = t('loading.serverOffline');
|
|
492
579
|
// `over-app`: no fade-in and above whatever is open. The screen is there in the frame of the click.
|
|
493
580
|
$overlay.classList.add('over-app', 'error', 'server-offline');
|
|
581
|
+
diagnose('overlay-reveal', { reason: 'restart' });
|
|
494
582
|
revealOverlay($overlay);
|
|
495
583
|
// Nothing behind the screen keeps the keyboard (a terminal, an editor).
|
|
496
584
|
try { document.activeElement?.blur?.(); } catch {}
|
|
@@ -515,7 +603,10 @@ function dismissRestart() {
|
|
|
515
603
|
if (_restartTitle !== null) document.title = _restartTitle;
|
|
516
604
|
_restartTitle = null;
|
|
517
605
|
const $overlay = $('loading-overlay');
|
|
518
|
-
if ($overlay)
|
|
606
|
+
if ($overlay) {
|
|
607
|
+
diagnose('overlay-conceal', { reason: 'dismissed' });
|
|
608
|
+
concealOverlay($overlay);
|
|
609
|
+
}
|
|
519
610
|
}
|
|
520
611
|
|
|
521
612
|
// ═══════════════════════════════════════════
|
|
@@ -583,24 +674,23 @@ function handleCopyCommand() {
|
|
|
583
674
|
* Pings /api/health and re-triggers init on success.
|
|
584
675
|
*/
|
|
585
676
|
async function handleRetryConnection() {
|
|
677
|
+
const bridge = _offlineBridge;
|
|
586
678
|
const $status = $('loading-retry-status');
|
|
587
679
|
if ($status) $status.textContent = t('loading.checking');
|
|
588
680
|
|
|
589
681
|
try {
|
|
590
682
|
const health = await fetchHealth();
|
|
683
|
+
if (_offlineBridge !== bridge) return;
|
|
591
684
|
// fetchHealth uses AbortSignal.timeout(3000) internally
|
|
592
|
-
if (health && health.
|
|
685
|
+
if (health?.ok === true && !health.restarting && !_restartShown) {
|
|
593
686
|
if ($status) $status.textContent = t('loading.connectedLoading');
|
|
594
|
-
|
|
595
|
-
if (_restartShown) { window.location.reload(); return; }
|
|
596
|
-
resetLoadingToConnecting();
|
|
597
|
-
emit('loading:retried');
|
|
598
|
-
if (_initCallback) _initCallback();
|
|
687
|
+
recoverConnection(health.bootId);
|
|
599
688
|
} else {
|
|
600
689
|
if ($status) $status.textContent = t('loading.notReadyYet');
|
|
601
690
|
setTimeout(() => { if ($status) $status.textContent = ''; }, 3000);
|
|
602
691
|
}
|
|
603
692
|
} catch {
|
|
693
|
+
if (_offlineBridge !== bridge) return;
|
|
604
694
|
if ($status) $status.textContent = t('loading.stillOffline');
|
|
605
695
|
setTimeout(() => { if ($status) $status.textContent = ''; }, 3000);
|
|
606
696
|
}
|
|
@@ -624,6 +714,8 @@ async function handleRetryConnection() {
|
|
|
624
714
|
export function initLoading({ onInit } = {}) {
|
|
625
715
|
_initCallback = onInit || null;
|
|
626
716
|
_statusDot = $('status-dot');
|
|
717
|
+
diagnose('overlay-reveal', { reason: 'init' });
|
|
718
|
+
if ($('loading-overlay')) dropOtherOverlays($('loading-overlay'));
|
|
627
719
|
|
|
628
720
|
// ── Populate command with cached path ──
|
|
629
721
|
const cached = localStorage.getItem('synabun-project-dir');
|
|
@@ -641,6 +733,74 @@ export function initLoading({ onInit } = {}) {
|
|
|
641
733
|
const retryBtn = $('loading-retry-btn');
|
|
642
734
|
if (retryBtn) retryBtn.addEventListener('click', handleRetryConnection);
|
|
643
735
|
|
|
736
|
+
// Not answering in time is not being gone (server-presence.js): a refused
|
|
737
|
+
// connection is offline after one confirmation, an unanswered one only once
|
|
738
|
+
// it has lasted, and never in a hidden tab.
|
|
739
|
+
const presence = createServerPresence();
|
|
740
|
+
let probing = false;
|
|
741
|
+
let heldSaid = '';
|
|
742
|
+
async function checkConnection() {
|
|
743
|
+
if (probing || _offlineBridge) return;
|
|
744
|
+
probing = true;
|
|
745
|
+
try {
|
|
746
|
+
const hidden = () => document.visibilityState === 'hidden';
|
|
747
|
+
let kind = '';
|
|
748
|
+
const ask = () => probeServer().catch((error) => { kind = probeFailureKind(error); return null; });
|
|
749
|
+
let seen = await ask();
|
|
750
|
+
let verdict = '';
|
|
751
|
+
let confirm = false;
|
|
752
|
+
if (!seen) {
|
|
753
|
+
diagnose('probe-miss', { reason: 'unreachable', confirmation: false });
|
|
754
|
+
verdict = presence.missed(kind, { hidden: hidden() });
|
|
755
|
+
// A close or a refused request after sleep can precede a healthy
|
|
756
|
+
// answer. Confirm the miss immediately, without waiting for another interval.
|
|
757
|
+
if (verdict === 'confirm' && !_offlineBridge) {
|
|
758
|
+
confirm = true;
|
|
759
|
+
seen = await ask();
|
|
760
|
+
if (!seen) {
|
|
761
|
+
diagnose('probe-miss', { reason: 'unreachable', confirmation: true });
|
|
762
|
+
verdict = presence.missed(kind, { hidden: hidden(), confirmed: kind !== 'timeout' });
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
if (_offlineBridge) { presence.reset(); return; }
|
|
767
|
+
if (!seen && verdict !== 'offline') {
|
|
768
|
+
// Slow, or a hidden tab that cannot tell: nothing is shown. Said once per row and again when its reason changes.
|
|
769
|
+
const row = presence.snapshot();
|
|
770
|
+
if (row && heldSaid !== `${row.held}`) { heldSaid = `${row.held}`; diagnose('probe-held', { reason: row.held === 'hidden' ? 'hidden' : 'slow', misses: Math.min(20, row.misses) }); }
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (seen) {
|
|
774
|
+
const row = presence.answered();
|
|
775
|
+
if (row.recovered && heldSaid) diagnose('probe-answered', { misses: Math.min(20, row.misses), seconds: Math.min(3600, Math.round(row.ms / 1000)) });
|
|
776
|
+
heldSaid = '';
|
|
777
|
+
} else {
|
|
778
|
+
presence.reset();
|
|
779
|
+
heldSaid = '';
|
|
780
|
+
}
|
|
781
|
+
if (seen?.up && !seen.stopping && !(currentBoot && seen.boot && currentBoot !== seen.boot)) {
|
|
782
|
+
if (!currentBoot) {
|
|
783
|
+
currentBoot = seen.boot;
|
|
784
|
+
window.synabunLoadingDiagnostics?.setBoot(currentBoot);
|
|
785
|
+
}
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (seen) diagnose('probe-miss', { reason: !seen.up ? 'unhealthy' : seen.stopping ? 'stopping' : 'boot-changed', confirmation: confirm });
|
|
789
|
+
// Preserve a specific startup database error until the app actually ran.
|
|
790
|
+
const overlay = $('loading-overlay');
|
|
791
|
+
if (!overlay || (seen && !seen.up && overlay.classList.contains('error') && !overlay.classList.contains('hidden'))) return;
|
|
792
|
+
appWasVisible = overlay.classList.contains('hidden');
|
|
793
|
+
diagnose('overlay-reveal', { reason: 'probe' });
|
|
794
|
+
revealOverlay(overlay);
|
|
795
|
+
showLoadingError(t('loading.serverOffline'), t('loading.serverNotRunning'), false, true);
|
|
796
|
+
if (appWasVisible) overlay.classList.add('over-app');
|
|
797
|
+
} finally { probing = false; }
|
|
798
|
+
}
|
|
799
|
+
setInterval(checkConnection, 3000);
|
|
800
|
+
on('sync:disconnected', checkConnection);
|
|
801
|
+
// A tab that was hidden could not tell slow from gone; it looks the moment it is shown.
|
|
802
|
+
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') checkConnection(); });
|
|
803
|
+
|
|
644
804
|
// ── The server says it is restarting (ui-sync.js): every window shows it ──
|
|
645
805
|
on('server:restarting', (msg) => beginRestart({ announced: true, boot: typeof msg?.bootId === 'string' ? msg.bootId : '' }));
|
|
646
806
|
}
|