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
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
// open is the character on screen, its face a live rig (liveAsk,
|
|
45
45
|
// activateRigs); every other card's face is a painted still.
|
|
46
46
|
|
|
47
|
-
import { assistantEventKey, fmtCost, fmtElapsed, isRemovableRun, isTerminalRunStatus, modelShortName, providerShortLabel, routeTargetLabel, runTone, summarizeMailbox } from './asst-state.js';
|
|
48
|
-
import { createRouteLine } from './asst-route.js';
|
|
47
|
+
import { assistantEventKey, displayProvider, fmtCost, fmtElapsed, isRemovableRun, isTerminalRunStatus, modelShortName, providerShortLabel, routeTargetLabel, runTone, summarizeMailbox } from './asst-state.js';
|
|
48
|
+
import { createRouteLine, routeClassLabel } from './asst-route.js';
|
|
49
49
|
import { closeMenu, isMenuOpen } from './asst-menu.js';
|
|
50
50
|
import { computerToolName, describeComputerAction, frameUrls, markerPercent, openFrameLightbox, parseComputerResult, swapImage } from './asst-computer.js';
|
|
51
51
|
import * as mascotLib from '../synabun-mascot.js';
|
|
@@ -55,11 +55,12 @@ import { injectRackStyles } from './asst-rack-styles.js';
|
|
|
55
55
|
import { injectSceneStyles } from './asst-scene-styles.js';
|
|
56
56
|
import { activityScene, compactActivity, isLivePhase, runChip, sceneOfClass, sceneSvg, stagePhase } from './asst-scenes.js';
|
|
57
57
|
import { STAGE_TIMING, createWorkerStage } from './asst-run-stage.js';
|
|
58
|
-
import { createMotionGate } from './asst-motion-gate.js';
|
|
58
|
+
import { SETTLE_FRAMES, createMotionGate } from './asst-motion-gate.js';
|
|
59
59
|
import { createStyleCache } from './asst-style-cache.js';
|
|
60
60
|
import { formatRunTokens } from './asst-usage.js';
|
|
61
61
|
import { sanitizeHtmlString, sanitizeInto } from './asst-sanitize.js';
|
|
62
62
|
import { decorateCodeBlocks } from '../ui-code-copy.js';
|
|
63
|
+
import { decorateOutput } from '../ui-output.js';
|
|
63
64
|
import { renderStreamingMarkdown } from '../streaming-markdown.js';
|
|
64
65
|
import { automationView } from './asst-automation.js';
|
|
65
66
|
import { guessFollowups, splitFollowups } from './asst-followups.js';
|
|
@@ -70,7 +71,8 @@ import { createLimitDock } from './asst-limit-dock.js';
|
|
|
70
71
|
import { createLimitWait } from './asst-limit-wait.js';
|
|
71
72
|
import { synabunToolKey, synabunToolLabel } from '../synabun-tools.js';
|
|
72
73
|
import { normalizeToolHeartbeat } from '../tool-heartbeat.js';
|
|
73
|
-
import {
|
|
74
|
+
import { createStickyScrollController } from '../ui-scroll-follow.js';
|
|
75
|
+
import { createShownGate } from '../sidepanel-shown.js';
|
|
74
76
|
|
|
75
77
|
// ── Markdown (lazy marked, the vendored build the sidepanels use too) ───────────────
|
|
76
78
|
let _marked = null;
|
|
@@ -221,8 +223,9 @@ export function updateRunCard(card, run, opts = {}) {
|
|
|
221
223
|
const provider = run.provider || 'claude-code';
|
|
222
224
|
const icon = card.querySelector('.asst-run-icon');
|
|
223
225
|
if (icon) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
const brand = displayProvider(run) || provider;
|
|
227
|
+
icon.innerHTML = typeof opts.providerIcon === 'function' ? (opts.providerIcon(brand) || '') : '';
|
|
228
|
+
const color = typeof opts.providerColor === 'function' ? opts.providerColor(brand) : '';
|
|
226
229
|
if (color) card.style.setProperty('--asst-provider-color', color);
|
|
227
230
|
}
|
|
228
231
|
const title = card.querySelector('.asst-run-title');
|
|
@@ -254,9 +257,10 @@ export function updateRunCard(card, run, opts = {}) {
|
|
|
254
257
|
const usage = runTokens?.total > 0 || run.usageObserved ? formatRunTokens(runTokens, run.usageFidelity || run.tokens?.fidelity, t) : null;
|
|
255
258
|
if (usage) bits.push(`<span class="asst-usage-run-tokens" aria-label="${esc(usage.label)}">${esc(usage.text)}</span>`);
|
|
256
259
|
if (run.currentIteration > 1) bits.push(`<span>${esc(t('assistant.run.turn', 'turn {n}', { n: run.currentIteration }))}</span>`);
|
|
260
|
+
if (run.agentRef) bits.push(`<span>${esc(run.agentRef)}</span>`);
|
|
257
261
|
if (run.route && typeof run.route === 'object') {
|
|
258
262
|
const r = run.route;
|
|
259
|
-
const routeBits = [r.taskClassLabel || r.taskClass || t('assistant.routes.task', 'task')];
|
|
263
|
+
const routeBits = [(r.taskClass ? routeClassLabel(r.taskClass, r.taskClassLabel || r.taskClass, t) : r.taskClassLabel) || t('assistant.routes.task', 'task')];
|
|
260
264
|
if (r.status === 'pending') routeBits.push(t('assistant.routes.state.pending', 'waiting for your choice'));
|
|
261
265
|
else if (r.decidedBy === 'budget' || r.source === 'budget') routeBits.push(t('assistant.routes.budgetDecision', 'budget re-route'));
|
|
262
266
|
else if (r.decidedBy === 'user') routeBits.push(t('assistant.routes.youChose', 'you chose'));
|
|
@@ -510,7 +514,11 @@ const SUGGESTION_KINDS = { computer: 'computer', web: 'web', fix: 'edit', skill:
|
|
|
510
514
|
* ({ status, resetsAt } | null), brainProvider() → the brain's provider id, onLimitRetry(text)
|
|
511
515
|
* (Retry now on the Assistant's own limit card: send `text`), onSwitchProvider(anchorEl, { excludeProvider, retryText })
|
|
512
516
|
* (Continue with another provider on the Assistant's own limit card: the host opens its own
|
|
513
|
-
* provider picker anchored on anchorEl and decides what a pick does)
|
|
517
|
+
* provider picker anchored on anchorEl and decides what a pick does),
|
|
518
|
+
* onMotionMark(holderEl, off) (a holder's off-screen mark changed, asst-motion-gate.js: a host that
|
|
519
|
+
* skips far rows keeps the holder's row plain until the mark is styled),
|
|
520
|
+
* onRackFolded(rackRow) (a rack's stage has folded and its row was measured: `is-folding` just left
|
|
521
|
+
* the row, which a host that skips far rows kept plain while it carried it) }
|
|
514
522
|
*/
|
|
515
523
|
export function createRenderer(transcriptEl, hooks = {}) {
|
|
516
524
|
loadMarked();
|
|
@@ -529,8 +537,22 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
529
537
|
// The open card's slot under every row (asst-ask-tail.js): a card that waits on the user is drawn
|
|
530
538
|
// there, above the "Working…" row, until it is answered; rows appended meanwhile go above it.
|
|
531
539
|
const askTail = createAskTail($msgs, { anchor: () => (working?.parentNode === $msgs ? working : null) });
|
|
532
|
-
|
|
533
|
-
|
|
540
|
+
// The transcript follows its bottom through the shared sidepanel controller (ui-scroll-follow.js), as
|
|
541
|
+
// the Claude, Codex, OpenCode and Maritaca panels do: one follow state, detached only by a real upward
|
|
542
|
+
// movement or wheel/keyboard/touch intent (never by the controller's own scroll events), reattached at
|
|
543
|
+
// the bottom, and a MutationObserver/ResizeObserver watch that follows late layout (an image arriving, a
|
|
544
|
+
// font swap, a highlight pass) and a message area whose height changes. Its writes are instant: the
|
|
545
|
+
// transcript's smooth scroll-behavior is for the reader's own scrolling, not for the follow. A closed
|
|
546
|
+
// side panel's transcript is not laid out: the controller keeps the scroll until the panel is shown.
|
|
547
|
+
const scrollFollow = createStickyScrollController($msgs);
|
|
548
|
+
let followHeld = false; // the empty state is up: nothing follows (holdFollow)
|
|
549
|
+
// A cleared transcript's old offset outlives its rows until the next layout: an empty state drawn now would
|
|
550
|
+
// open part-way down, off its character. Back to the top, when the panel is shown if it is closed (no layout
|
|
551
|
+
// there); rows that arrived meanwhile are the follow's.
|
|
552
|
+
const topGate = createShownGate($msgs, () => {
|
|
553
|
+
if (!followHeld && $msgs.firstElementChild) return;
|
|
554
|
+
try { $msgs.scrollTo({ top: 0, behavior: 'instant' }); } catch { $msgs.scrollTop = 0; }
|
|
555
|
+
});
|
|
534
556
|
let emptyEl = null;
|
|
535
557
|
let hero = null; // the empty state's character: { rig, el, box, parked, leaving, held, dock, egg, target }
|
|
536
558
|
const mcpWarned = new Set();
|
|
@@ -588,7 +610,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
588
610
|
try { fontSet?.addEventListener?.('loadingdone', onFontsLoaded); } catch { /* no FontFaceSet events */ }
|
|
589
611
|
const stopFontWatch = () => { try { fontSet?.removeEventListener?.('loadingdone', onFontsLoaded); } catch { /* gone */ } };
|
|
590
612
|
// The transcript's loops run only while their holder is on screen (run cards, racks, route lines).
|
|
591
|
-
const motion = createMotionGate();
|
|
613
|
+
const motion = createMotionGate({ onMark: hooks.onMotionMark });
|
|
592
614
|
const stageResizes = typeof ResizeObserver === 'function' ? new ResizeObserver((entries) => {
|
|
593
615
|
for (const entry of entries) {
|
|
594
616
|
const seen = stageWidths.get(entry.target);
|
|
@@ -619,13 +641,6 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
619
641
|
const SEEN_MAX = 5000;
|
|
620
642
|
let snapshot = null;
|
|
621
643
|
|
|
622
|
-
$msgs.addEventListener('scroll', () => {
|
|
623
|
-
// Inside a closed side panel nobody scrolls: the follow stays what it was, and no height is read
|
|
624
|
-
// (reading it lays the hidden panel out; sidepanel-shown.js).
|
|
625
|
-
if (closedSidepanelOf($msgs)) return;
|
|
626
|
-
followTail = isNearBottom();
|
|
627
|
-
}, { passive: true });
|
|
628
|
-
|
|
629
644
|
const t = (key, fallback, params) => {
|
|
630
645
|
const v = typeof hooks.t === 'function' ? hooks.t(key, params) : undefined;
|
|
631
646
|
if (v && v !== key && typeof v === 'string') return v;
|
|
@@ -664,22 +679,23 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
664
679
|
return $msgs.scrollHeight - $msgs.scrollTop - $msgs.clientHeight < 48;
|
|
665
680
|
}
|
|
666
681
|
|
|
667
|
-
// The scroll to the newest row
|
|
668
|
-
//
|
|
669
|
-
//
|
|
670
|
-
|
|
671
|
-
if (scrollFrame) return;
|
|
672
|
-
scrollFrame = requestAnimationFrame(() => {
|
|
673
|
-
scrollFrame = 0;
|
|
674
|
-
if (closedSidepanelOf($msgs)) { endGate.request(); return; } // closed again before the frame
|
|
675
|
-
$msgs.scrollTop = $msgs.scrollHeight;
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
|
|
682
|
+
// The scroll to the newest row: the shared controller's follow write, on its generation-checked frame.
|
|
683
|
+
// A transcript inside a closed side panel has no layout: scrolling it there read its height, which made
|
|
684
|
+
// the engine lay the whole hidden panel out, at every load and for every row a session added meanwhile.
|
|
685
|
+
// The controller keeps the scroll and makes it when the panel is shown (ui-scroll-follow.js).
|
|
679
686
|
function scrollEnd(force = false) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
687
|
+
scrollFollow.scrollToBottom({ force });
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// The empty state is not a transcript to follow: its bottom is the starters, and following it when a long
|
|
691
|
+
// draft grows the composer pushed the character out of view (parkHero then has no hero to hand off). The
|
|
692
|
+
// controller is off while it is the only thing here, and the first real row starts the follow, whatever
|
|
693
|
+
// the reader did to the empty state's scroll meanwhile.
|
|
694
|
+
function holdFollow(held) {
|
|
695
|
+
if (followHeld === held) return;
|
|
696
|
+
followHeld = held;
|
|
697
|
+
if (!held) scrollFollow.setFollowing(true);
|
|
698
|
+
scrollFollow.setActive(!held);
|
|
683
699
|
}
|
|
684
700
|
|
|
685
701
|
function root() { return { container: $msgs, stream: null, key: null, msgId: null, lastAt: 0 }; }
|
|
@@ -709,6 +725,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
709
725
|
closeEmptyMenu();
|
|
710
726
|
emptyEl.remove();
|
|
711
727
|
emptyEl = null;
|
|
728
|
+
holdFollow(false);
|
|
712
729
|
}
|
|
713
730
|
|
|
714
731
|
/** A menu opened from the empty state's project picker does not outlive it. */
|
|
@@ -974,6 +991,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
974
991
|
mdInto(body, text);
|
|
975
992
|
// Every code block gets the shared Copy button (../ui-code-copy.js), also each piece a stream draws.
|
|
976
993
|
decorateCodeBlocks(body);
|
|
994
|
+
// The reading layer all six panels share (../ui-output.js): a table's frame, task items, a diff's lines.
|
|
995
|
+
decorateOutput(body);
|
|
977
996
|
body.querySelectorAll('pre code').forEach((code) => {
|
|
978
997
|
const lang = (code.className || '').replace('language-', '').trim();
|
|
979
998
|
if (lang) code.parentElement.dataset.lang = lang;
|
|
@@ -1641,7 +1660,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1641
1660
|
receipt: { btn: q('.asst-rack-receipt'), face: q('.asst-rack-receipt-face'), text: q('.asst-rack-receipt-text'), failed: q('.asst-rack-receipt-failed'), clock: q('.asst-rack-receipt-clock'), faceBuilt: false, pose: '', svg: null },
|
|
1642
1661
|
ledger: q('.asst-rack-ledger'), statusEl: q('.asst-rack-status'), alertEl: q('.asst-rack-alert'), timelineEl: null, timelineSig: '',
|
|
1643
1662
|
rig: null, target: null, held: false, holdUntil: 0, holdTimer: 0, pose: null, awake: null, awakeKey: null,
|
|
1644
|
-
bubble: { step: null, since: 0, key: '', open: false }, stageTimer: 0, clearTimer: 0,
|
|
1663
|
+
bubble: { step: null, since: 0, key: '', open: false }, stageTimer: 0, clearTimer: 0, foldFrame: 0,
|
|
1645
1664
|
sr: { last: 0, timer: 0, pending: '' },
|
|
1646
1665
|
};
|
|
1647
1666
|
row._rack = rack;
|
|
@@ -1867,6 +1886,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1867
1886
|
if (staged) {
|
|
1868
1887
|
clearTimeout(rack.clearTimer);
|
|
1869
1888
|
rack.clearTimer = 0;
|
|
1889
|
+
foldMeasured(rack, true); // a fold that was still being measured is over: the stage is back
|
|
1870
1890
|
rack.row.classList.add('is-staged');
|
|
1871
1891
|
watchStageWidth(rack, true);
|
|
1872
1892
|
if (!rack.rig) {
|
|
@@ -1881,6 +1901,11 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1881
1901
|
// Fold the stage into the receipt; a rack above the viewport folds at once and the scroll position absorbs it.
|
|
1882
1902
|
// Keyboard focus inside the stage (the bubble, its Copy) moves to the receipt, which takes the stage's place.
|
|
1883
1903
|
const row = rack.row;
|
|
1904
|
+
// From here until the fold has been measured (foldMeasured) the row is laid out for real, wherever it is.
|
|
1905
|
+
// A settled rack is skipped off screen (asst-rack-styles.js; as a transcript row, transcript-rows.js), and
|
|
1906
|
+
// a skipped box keeps the height it was skipped at: a rack that settled off screen, or left the screen
|
|
1907
|
+
// while it folded, stayed as tall as its stage (or half folded) until the reader came back to it.
|
|
1908
|
+
row.classList.add('is-folding');
|
|
1884
1909
|
const focused = rack.stage.el.contains(document.activeElement);
|
|
1885
1910
|
let above = false;
|
|
1886
1911
|
if (!calm() && row.isConnected) {
|
|
@@ -1893,7 +1918,14 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1893
1918
|
row.classList.remove('is-staged');
|
|
1894
1919
|
void row.offsetHeight; // apply without the transition
|
|
1895
1920
|
row.classList.remove('is-instant');
|
|
1896
|
-
if (h)
|
|
1921
|
+
if (h) {
|
|
1922
|
+
if (scrollFollow.isFollowing()) {
|
|
1923
|
+
scrollFollow.scrollToBottom({ immediate: true });
|
|
1924
|
+
} else {
|
|
1925
|
+
const top = Math.max(0, $msgs.scrollTop - h);
|
|
1926
|
+
try { $msgs.scrollTo({ top, behavior: 'instant' }); } catch { $msgs.scrollTop = top; }
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1897
1929
|
} else {
|
|
1898
1930
|
row.classList.remove('is-staged');
|
|
1899
1931
|
}
|
|
@@ -1936,6 +1968,34 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1936
1968
|
s.err.hidden = true;
|
|
1937
1969
|
s.bubble.querySelector('.asst-bubble-copy')?.remove();
|
|
1938
1970
|
rack.bubble = { step: null, since: 0, key: '', open: false };
|
|
1971
|
+
// A settled rack scrolled offscreen (content-visibility: auto) can freeze its
|
|
1972
|
+
// fold transitions in WebKit; clear any still-running fold transitions once folded.
|
|
1973
|
+
try {
|
|
1974
|
+
for (const a of rack.row.getAnimations?.() || []) a.cancel();
|
|
1975
|
+
for (const a of s.el.getAnimations?.() || []) a.cancel();
|
|
1976
|
+
} catch { /* ignore */ }
|
|
1977
|
+
foldMeasured(rack);
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* The fold is over. Its row stays laid out (`is-folding`) for SETTLE_FRAMES more frames: the first may be the
|
|
1982
|
+
* one the fold ended in, so by the last the folded height has been laid out and reported to whoever measures
|
|
1983
|
+
* rows (the size a skipped box is given). Then the mark goes and the host is told (`onRackFolded`), so a row
|
|
1984
|
+
* it kept plain meanwhile may be skipped again. `now`: the stage is back, the mark goes at once. Nothing is
|
|
1985
|
+
* read here, and a page that draws no frame keeps the row laid out until it draws again.
|
|
1986
|
+
*/
|
|
1987
|
+
function foldMeasured(rack, now = false) {
|
|
1988
|
+
if (rack.foldFrame) { cancelAnimationFrame(rack.foldFrame); rack.foldFrame = 0; }
|
|
1989
|
+
const { row } = rack;
|
|
1990
|
+
if (!row.classList.contains('is-folding')) return;
|
|
1991
|
+
let left = now || typeof requestAnimationFrame !== 'function' ? 0 : SETTLE_FRAMES;
|
|
1992
|
+
const frame = () => {
|
|
1993
|
+
rack.foldFrame = 0;
|
|
1994
|
+
if (left-- > 0) { rack.foldFrame = requestAnimationFrame(frame); return; }
|
|
1995
|
+
row.classList.remove('is-folding');
|
|
1996
|
+
if (typeof hooks.onRackFolded === 'function') { try { hooks.onRackFolded(row); } catch { /* the fold stands */ } }
|
|
1997
|
+
};
|
|
1998
|
+
frame();
|
|
1939
1999
|
}
|
|
1940
2000
|
|
|
1941
2001
|
/**
|
|
@@ -3002,6 +3062,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3002
3062
|
clearTimeout(rack.clearTimer);
|
|
3003
3063
|
clearTimeout(rack.sr.timer);
|
|
3004
3064
|
clearTimeout(rack.holdTimer);
|
|
3065
|
+
if (rack.foldFrame) cancelAnimationFrame(rack.foldFrame);
|
|
3066
|
+
rack.foldFrame = 0;
|
|
3005
3067
|
rack.stageTimer = 0;
|
|
3006
3068
|
rack.clearTimer = 0;
|
|
3007
3069
|
rack.sr.timer = 0;
|
|
@@ -3380,6 +3442,9 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3380
3442
|
function revealRun(runId) {
|
|
3381
3443
|
const card = runCards.get(runId);
|
|
3382
3444
|
if (!card?.isConnected) return false;
|
|
3445
|
+
// Leaving the bottom on purpose: detach first, so the follow does not read this jump's own mutations
|
|
3446
|
+
// as new content and write the bottom back over the smooth scroll before its first scroll event.
|
|
3447
|
+
scrollFollow.setFollowing(false);
|
|
3383
3448
|
const top = card.getBoundingClientRect().top - $msgs.getBoundingClientRect().top + $msgs.scrollTop - 16;
|
|
3384
3449
|
try { $msgs.scrollTo({ top: Math.max(0, top), behavior: calm() ? 'auto' : 'smooth' }); } catch { $msgs.scrollTop = Math.max(0, top); }
|
|
3385
3450
|
card.classList.remove('is-revealed');
|
|
@@ -3624,6 +3689,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3624
3689
|
if (ended) row.atEnd = true;
|
|
3625
3690
|
prune();
|
|
3626
3691
|
if (racks.size) syncRacks();
|
|
3692
|
+
holdFollow(false); // a real row, even when the empty state stays above it
|
|
3627
3693
|
scrollEnd();
|
|
3628
3694
|
}
|
|
3629
3695
|
return row.el;
|
|
@@ -3632,6 +3698,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3632
3698
|
// ── Empty state ──
|
|
3633
3699
|
function showEmpty() {
|
|
3634
3700
|
if (emptyEl || $msgs.querySelector(':scope > :not(.asst-working)')) return;
|
|
3701
|
+
holdFollow(true);
|
|
3635
3702
|
emptyEl = el('div', 'asst-empty');
|
|
3636
3703
|
// One column, one hierarchy: the character and the heading, the greeting when there is one,
|
|
3637
3704
|
// the starters, then the context line (Project · Budget). No lead: the starters say what it can do.
|
|
@@ -4165,7 +4232,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4165
4232
|
}
|
|
4166
4233
|
|
|
4167
4234
|
function clear() {
|
|
4168
|
-
|
|
4235
|
+
scrollFollow.setFollowing(true);
|
|
4169
4236
|
clearTimeout(recutTimer);
|
|
4170
4237
|
recutTimer = 0;
|
|
4171
4238
|
toRecut.clear();
|
|
@@ -4207,13 +4274,14 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4207
4274
|
closeEmptyMenu();
|
|
4208
4275
|
$msgs.innerHTML = '';
|
|
4209
4276
|
emptyEl = null;
|
|
4210
|
-
|
|
4277
|
+
holdFollow(false);
|
|
4278
|
+
topGate.request();
|
|
4211
4279
|
}
|
|
4212
4280
|
|
|
4213
4281
|
return {
|
|
4214
4282
|
el: $msgs,
|
|
4215
4283
|
clear,
|
|
4216
|
-
destroy: () => { clear();
|
|
4284
|
+
destroy: () => { clear(); scrollFollow.destroy(); topGate.cancel(); stageResizes?.disconnect(); limitDock.destroy(); stopFontWatch(); },
|
|
4217
4285
|
appendUser,
|
|
4218
4286
|
appendAssistantMarkdown,
|
|
4219
4287
|
appendStatus,
|
|
@@ -26,8 +26,11 @@ import { closeMenu, isMenuOpen, openMenu } from './asst-menu.js';
|
|
|
26
26
|
import { decorateControlHead } from './asst-control.js';
|
|
27
27
|
import { accountSummary } from '../account-view.js';
|
|
28
28
|
import { accountUsageText, autoAccountLabel } from '../account-usage.js';
|
|
29
|
+
import { registerLaunchPrefetch } from '../launch-prefetch.js';
|
|
30
|
+
import { createLazyModule } from '../lazy-module.js';
|
|
29
31
|
import {
|
|
30
32
|
DEFAULT_ROUTE_MODE,
|
|
33
|
+
displayProvider,
|
|
31
34
|
fmtConfidence,
|
|
32
35
|
modelShortName,
|
|
33
36
|
normalizeBrain,
|
|
@@ -89,6 +92,40 @@ function tf(t) {
|
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
/**
|
|
96
|
+
* A task class in the user's language, keyed by its id (`assistant.routes.taskClass.<id>`); the server's
|
|
97
|
+
* label (English) is the fallback. `lower` is the sentence form.
|
|
98
|
+
*/
|
|
99
|
+
export function routeClassLabel(taskClass, serverLabel, t, { lower = false } = {}) {
|
|
100
|
+
const tr = tf(t);
|
|
101
|
+
const id = str(taskClass);
|
|
102
|
+
const base = str(serverLabel) || humanizeClass(id);
|
|
103
|
+
const label = id ? tr(`assistant.routes.taskClass.${id}`, base) : base;
|
|
104
|
+
return lower ? label.toLowerCase() : label;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* An effort id in the user's language (`assistant.routes.effortWord.<id>`), for display only: the id that is
|
|
109
|
+
* sent back to the server never changes. A locale that only repeats the id (English), or has no key, and an
|
|
110
|
+
* id nothing names (an OpenCode variant) keep `fallback` (default: the card's own word, "none" → "off").
|
|
111
|
+
*/
|
|
112
|
+
export function routeEffortLabel(effort, t, fallback) {
|
|
113
|
+
const id = str(effort);
|
|
114
|
+
const raw = routeEffortWord(id);
|
|
115
|
+
const base = fallback == null ? raw : fallback;
|
|
116
|
+
if (!id) return base;
|
|
117
|
+
const v = tf(t)(`assistant.routes.effortWord.${id.toLowerCase()}`, '');
|
|
118
|
+
return v && v !== raw ? v : base;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A row's title with its trailing effort word in the user's language (the stored title stays English). */
|
|
122
|
+
export function routeTitleLocalized(o, t) {
|
|
123
|
+
const title = str(o?.title);
|
|
124
|
+
if (!o?.titleEffort || !o?.effort) return title;
|
|
125
|
+
const word = routeEffortLabel(o.effort, t);
|
|
126
|
+
return word === routeEffortWord(o.effort) ? title : `${routeTitleWithoutEffort(title, o.effort)} · ${word}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
92
129
|
function humanizeClass(value) {
|
|
93
130
|
const s = str(value).replace(/[_-]+/g, ' ');
|
|
94
131
|
return s ? s[0].toUpperCase() + s.slice(1) : 'General';
|
|
@@ -145,6 +182,7 @@ function normalizeRouteOption(o) {
|
|
|
145
182
|
vision: src.vision === true,
|
|
146
183
|
price: priceOf(src.price),
|
|
147
184
|
contextWindow: num(src.contextWindow),
|
|
185
|
+
...(src.agentRef ? { agentRef: str(src.agentRef) } : {}),
|
|
148
186
|
reason: str(src.reason),
|
|
149
187
|
warning: str(src.warning) || null,
|
|
150
188
|
budget: str(src.budget) || null,
|
|
@@ -196,6 +234,7 @@ export function normalizeRouteRequest(packet) {
|
|
|
196
234
|
needsVision: req.needsVision === true,
|
|
197
235
|
// Image / video creation: the medium the model must generate ('image' | 'video'), always on a worker.
|
|
198
236
|
requires: req.requires === 'image' || req.requires === 'video' ? req.requires : null,
|
|
237
|
+
needsHost: req.needsHost === true || req.sides?.dispatch?.code === 'host_only',
|
|
199
238
|
dispatchOnly: req.dispatchOnly === true,
|
|
200
239
|
// Design: only models that can see.
|
|
201
240
|
visionOnly: req.visionOnly === true,
|
|
@@ -358,6 +397,7 @@ export function routeOptions(n, { brainLabel = '', t = null } = {}) {
|
|
|
358
397
|
}
|
|
359
398
|
const kept = [];
|
|
360
399
|
for (const o of options) {
|
|
400
|
+
if (n.needsHost && o.kind !== 'direct') continue;
|
|
361
401
|
const twin = kept.find(k => sameRouteTarget(k, o));
|
|
362
402
|
if (twin) {
|
|
363
403
|
if (defaultId === o.id) defaultId = twin.id;
|
|
@@ -425,10 +465,13 @@ export function routeCardSides(n, options, { t = null } = {}) {
|
|
|
425
465
|
const usable = list.filter((o) => !o.disabled);
|
|
426
466
|
const said = server?.[kind] || null;
|
|
427
467
|
const out = { kind, options: list, available: usable.length > 0, reason: null, code: null, needsPick: false, defaultId: null };
|
|
468
|
+
if (kind === 'dispatch' && n?.needsHost) {
|
|
469
|
+
return { ...out, options: [], available: false, code: 'host_only', reason: tr('assistant.routes.side.hostOnly', 'This task requires host access in this conversation.') };
|
|
470
|
+
}
|
|
428
471
|
out.defaultId = (usable.find((o) => o.id === n?.defaultOptionId) || usable.find((o) => o.id === n?.defaults?.[kind]) || usable.find((o) => o.selected) || usable[0])?.id || null;
|
|
429
472
|
if (out.available) return out;
|
|
430
473
|
if (kind === 'direct' && n?.dispatchOnly) {
|
|
431
|
-
return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: n.
|
|
474
|
+
return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, t) }) };
|
|
432
475
|
}
|
|
433
476
|
if (kind === 'direct' && (said?.code === 'account_worker' || arr(options).some((o) => o.kind === 'dispatch' && o.accountKind === 'direct'))) {
|
|
434
477
|
return { ...out, code: 'account_worker', reason: tr('assistant.routes.side.accountWorker', "This conversation's account can't take it now, so it runs on a worker.") };
|
|
@@ -447,7 +490,7 @@ export function routeCardSides(n, options, { t = null } = {}) {
|
|
|
447
490
|
const chosen = arr(options).find((o) => o.selected && !o.disabled);
|
|
448
491
|
let initial = chosen ? (chosen.kind === 'direct' ? 'direct' : 'dispatch') : null;
|
|
449
492
|
if (!initial || !sides[initial].available) initial = sides.direct.available && sides.direct.defaultId ? 'direct' : 'dispatch';
|
|
450
|
-
return { initial, sides };
|
|
493
|
+
return { initial: n?.needsHost ? 'direct' : initial, sides };
|
|
451
494
|
}
|
|
452
495
|
|
|
453
496
|
/** control_response payload for a route card. `decline:true` is the Cancel answer. */
|
|
@@ -547,7 +590,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
547
590
|
const tr = tf(t);
|
|
548
591
|
const r = obj(route) || {};
|
|
549
592
|
const target = obj(r.target);
|
|
550
|
-
const cls = firstStr(r.taskClassLabel, r.taskClass) || tr('assistant.routes.task', 'task');
|
|
593
|
+
const cls = (r.taskClass ? routeClassLabel(r.taskClass, firstStr(r.taskClassLabel, r.taskClass), t) : firstStr(r.taskClassLabel)) || tr('assistant.routes.task', 'task');
|
|
551
594
|
const kind = target ? (str(target.kind) || 'direct') : '';
|
|
552
595
|
const effort = target ? str(target.effort) : '';
|
|
553
596
|
const confidence = fmtConfidence(r.confidence);
|
|
@@ -559,6 +602,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
559
602
|
state = str(r.needs) === 'vision' ? tr('assistant.routes.reason.noSeeingModel', 'no model can see images') : tr('assistant.routes.reason.noCapableModel', 'no model can make this');
|
|
560
603
|
}
|
|
561
604
|
else if (str(r.reasonCode) === 'budget_exhausted') state = routeBudgetReason({ dry: r.dry }, t);
|
|
605
|
+
else if (str(r.reasonCode) === 'BUDGET_UNPRICED') state = routeBudgetReason({ provider: r.provider, unpriced: true }, t);
|
|
562
606
|
else if (phase === 'declined') state = tr('assistant.routes.state.declined', 'declined');
|
|
563
607
|
else if (phase === 'cancelled') state = tr('assistant.routes.state.cancelled', 'cancelled');
|
|
564
608
|
let decided = '';
|
|
@@ -571,10 +615,11 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
571
615
|
default: decided = r.remembered ? tr('assistant.routes.remembered', 'your saved choice') : '';
|
|
572
616
|
}
|
|
573
617
|
const meta = [];
|
|
618
|
+
if (kind === 'dispatch' && r.agentRef) meta.push(r.agentRef);
|
|
574
619
|
if (r.plannedSplit?.workers) meta.push(tf(t)('assistant.routes.splitWorkers', '{count} workers planned', { count: r.plannedSplit.workers }));
|
|
575
620
|
const accountLabel = routeDisplayAccount(target, t);
|
|
576
621
|
if (accountLabel) meta.push(accountLabel);
|
|
577
|
-
if (effort && effort !== 'off') meta.push(
|
|
622
|
+
if (effort && effort !== 'off') meta.push(routeEffortLabel(effort, t));
|
|
578
623
|
if (confidence) meta.push(confidence);
|
|
579
624
|
return {
|
|
580
625
|
taskClass: cls,
|
|
@@ -605,6 +650,11 @@ function correctionText(c, tr) {
|
|
|
605
650
|
}
|
|
606
651
|
if (c.reason === 'remembered_route') return tr('assistant.routes.correction.remembered', 'your saved route {to} replaced {from}', { to: str(c.to), from: str(c.from) });
|
|
607
652
|
if (c.reason === 'remembered_disabled') return tr('assistant.routes.correction.rememberedDisabled', 'saved route {from} is disabled, kept the pick', { from: str(c.from) });
|
|
653
|
+
if (c.reason === 'remembered_host') return tr('assistant.routes.correction.rememberedHost', 'Skipped the saved route {from} because this task requires host access.', { from: str(c.from) });
|
|
654
|
+
if (c.reason === 'superseded_run_active' && arr(c.runs).length) {
|
|
655
|
+
const runs = c.runs.map(r => [str(r?.runId), str(r?.title)].filter(Boolean).join(' — ')).filter(Boolean).join(', ');
|
|
656
|
+
return tr('assistant.routes.correction.supersededRunActive', 'Workers from the previous dispatch are still active ({runs}).', { runs });
|
|
657
|
+
}
|
|
608
658
|
// A "here" pick that runs on a worker: another account, or another provider than this conversation's.
|
|
609
659
|
if (c.reason === 'account_worker') return tr('assistant.routes.correction.accountWorker', '{to}: runs on a worker, because this conversation belongs to another account', { to: str(c.to) });
|
|
610
660
|
if (c.reason === 'other_provider' && c.provider) return tr('assistant.routes.correction.otherProvider', "{provider} is not this conversation's provider, so it runs on a worker", { provider: providerLabel(c.provider) });
|
|
@@ -716,9 +766,10 @@ export function createRouteLine(route, opts = {}) {
|
|
|
716
766
|
arrow.hidden = !p.targetLabel && !p.pending && !p.kindLabel;
|
|
717
767
|
kindEl.textContent = p.kindLabel;
|
|
718
768
|
kindEl.hidden = !p.kindLabel;
|
|
719
|
-
|
|
769
|
+
const brand = displayProvider(current.route?.target) || p.provider;
|
|
770
|
+
iconEl.innerHTML = p.targetLabel ? providerIconHtml(brand, opts) : '';
|
|
720
771
|
iconEl.hidden = !iconEl.innerHTML;
|
|
721
|
-
if (p.provider) iconEl.style.color = providerColor(
|
|
772
|
+
if (p.provider) iconEl.style.color = providerColor(brand); else iconEl.style.color = '';
|
|
722
773
|
targetEl.textContent = p.targetLabel;
|
|
723
774
|
targetEl.hidden = !p.targetLabel;
|
|
724
775
|
metaEl.textContent = p.meta.length ? `· ${p.meta.join(' · ')}` : '';
|
|
@@ -901,7 +952,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
901
952
|
card.dataset.requestId = n.requestId;
|
|
902
953
|
card.dataset.routeId = n.routeId;
|
|
903
954
|
card.setAttribute('role', 'group');
|
|
904
|
-
const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: n.taskClassLabel });
|
|
955
|
+
const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, hooks.t) });
|
|
905
956
|
card.setAttribute('aria-label', heading);
|
|
906
957
|
|
|
907
958
|
const head = el('div', 'asst-control-head');
|
|
@@ -931,8 +982,9 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
931
982
|
const sidesEl = el('div', 'asst-route-sides');
|
|
932
983
|
sidesEl.setAttribute('role', 'radiogroup');
|
|
933
984
|
sidesEl.setAttribute('aria-label', tr('assistant.routes.side.label', 'Where it runs'));
|
|
985
|
+
const visibleSides = n.needsHost ? ['direct'] : ROUTE_SIDES;
|
|
934
986
|
const sideBtns = {};
|
|
935
|
-
for (const kind of
|
|
987
|
+
for (const kind of visibleSides) {
|
|
936
988
|
const btn = el('button', 'asst-route-side', kind === 'direct' ? tr('assistant.routes.side.here', 'Here') : tr('assistant.routes.side.dispatch', 'Dispatch'));
|
|
937
989
|
btn.type = 'button';
|
|
938
990
|
btn.dataset.side = kind;
|
|
@@ -951,6 +1003,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
951
1003
|
card.appendChild(list);
|
|
952
1004
|
|
|
953
1005
|
function optionRow(o) {
|
|
1006
|
+
const brand = displayProvider(o);
|
|
954
1007
|
const row = el('div', 'asst-route-option');
|
|
955
1008
|
row.setAttribute('role', 'radio');
|
|
956
1009
|
row.dataset.optionId = o.id;
|
|
@@ -958,17 +1011,17 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
958
1011
|
row.setAttribute('aria-disabled', o.disabled ? 'true' : 'false');
|
|
959
1012
|
row.tabIndex = -1;
|
|
960
1013
|
const kindWord = o.kind && o.kind !== 'direct' ? routeKindWord(o.kind, hooks.t) : '';
|
|
961
|
-
const sub = [kindWord, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ?
|
|
1014
|
+
const sub = [kindWord, o.agentRef, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ? routeEffortLabel(o.effort, hooks.t) : '', o.price ? priceText(o.price) : '', o.vision ? tr('assistant.brain.vision', 'vision') : '', o.reason].filter(Boolean).join(' · ');
|
|
962
1015
|
row.innerHTML = `
|
|
963
1016
|
<span class="asst-route-num" aria-hidden="true">${esc(o.number)}</span>
|
|
964
|
-
<span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(
|
|
1017
|
+
<span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(brand))}"` : ''}>${providerIconHtml(brand, hooks)}</span>
|
|
965
1018
|
<span class="asst-route-opt-main">
|
|
966
1019
|
<span class="asst-route-opt-title"></span>
|
|
967
1020
|
${sub ? '<span class="asst-route-opt-sub"></span>' : ''}
|
|
968
1021
|
${o.warning || (o.disabled && o.disabledReason) ? '<span class="asst-route-opt-warn"></span>' : ''}
|
|
969
1022
|
</span>
|
|
970
1023
|
${o.badgeText ? `<span class="asst-route-badge" data-badge="${esc(o.badge || '')}"></span>` : ''}`;
|
|
971
|
-
row.querySelector('.asst-route-opt-title').textContent = o.
|
|
1024
|
+
row.querySelector('.asst-route-opt-title').textContent = routeTitleLocalized(o, hooks.t);
|
|
972
1025
|
if (sub) row.querySelector('.asst-route-opt-sub').textContent = sub;
|
|
973
1026
|
const warn = row.querySelector('.asst-route-opt-warn');
|
|
974
1027
|
if (warn) warn.textContent = o.accountError ? routeAccountError(o.accountError, hooks.t) : o.disabled && o.disabledReason ? o.disabledReason : o.warning;
|
|
@@ -1011,7 +1064,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1011
1064
|
/** The switch, its note (why the other side is unavailable, what a worker side still needs, else what the side means) and the Run label. */
|
|
1012
1065
|
function syncSides() {
|
|
1013
1066
|
card.dataset.side = state.side;
|
|
1014
|
-
for (const kind of
|
|
1067
|
+
for (const kind of visibleSides) {
|
|
1015
1068
|
const btn = sideBtns[kind];
|
|
1016
1069
|
const side = view.sides[kind];
|
|
1017
1070
|
const on = state.side === kind;
|
|
@@ -1076,11 +1129,15 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1076
1129
|
}
|
|
1077
1130
|
function syncFields() {
|
|
1078
1131
|
const target = selected();
|
|
1079
|
-
|
|
1132
|
+
// The router's "Do it here with ‹model›" label reads in the user's language, like the list rows.
|
|
1133
|
+
const targetText = !target ? '' : target.kind === 'direct' && /^do it here with\s+/i.test(str(target.label))
|
|
1134
|
+
? tr('assistant.routes.doHere', 'Do it here with {model}', { model: routeHereModelLabel(target) || modelShortName(target.model) || target.id })
|
|
1135
|
+
: routeTargetLabel(target);
|
|
1136
|
+
setFieldLabel(otherBtn, target ? targetText : tr('assistant.routes.other', 'Other model…'));
|
|
1080
1137
|
otherBtn.setAttribute('aria-label', tr('assistant.brain.model', 'Model'));
|
|
1081
1138
|
otherBtn.disabled = busy();
|
|
1082
1139
|
setFieldLabel(effortBtn, !target?.effort ? tr('assistant.routes.editorEffortAuto', 'Auto')
|
|
1083
|
-
: target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : target.effort);
|
|
1140
|
+
: target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(target.effort, hooks.t, target.effort));
|
|
1084
1141
|
effortBtn.setAttribute('aria-label', tr('assistant.brain.effort', 'Thinking effort'));
|
|
1085
1142
|
setFieldLabel(accountBtn, routeDisplayAccount(target, hooks.t) || tr('assistant.routes.account.workersDefault', 'Workers default'));
|
|
1086
1143
|
accountBtn.setAttribute('aria-label', tr('assistant.brain.account', 'Account profile'));
|
|
@@ -1095,7 +1152,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1095
1152
|
const choices = routeEffortChoices(target.provider, catalogModelRow(target.provider, target.model));
|
|
1096
1153
|
openMenu(effortBtn, { title: tr('assistant.brain.effort', 'Thinking effort'), placement: 'auto', items: [
|
|
1097
1154
|
{ kind: 'radio', label: tr('assistant.routes.editorEffortAuto', 'Auto'), selected: !target.effort, onSelect: () => editTarget({ effort: null }) },
|
|
1098
|
-
...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : e.label, selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
|
|
1155
|
+
...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(e.id, hooks.t, e.label), selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
|
|
1099
1156
|
] });
|
|
1100
1157
|
});
|
|
1101
1158
|
accountBtn.addEventListener('click', async () => {
|
|
@@ -1174,7 +1231,9 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1174
1231
|
rememberInput.type = 'checkbox';
|
|
1175
1232
|
rememberInput.addEventListener('change', () => { state.remember = rememberInput.checked; });
|
|
1176
1233
|
// `remember.label` is the task-class label ("Code"), not a sentence.
|
|
1177
|
-
|
|
1234
|
+
// A key per class carries the whole phrase so the plural noun agrees ("tarefas rápidas"); the generic one is the fallback.
|
|
1235
|
+
const rememberClass = n.remember.taskClass || n.taskClass;
|
|
1236
|
+
const text = tr(`assistant.routes.rememberForClass.${rememberClass}`, '') || tr('assistant.routes.rememberFor', 'Use this choice for {taskClass} tasks', { taskClass: routeClassLabel(rememberClass, n.remember.label || n.taskClassLabel, hooks.t, { lower: true }) });
|
|
1178
1237
|
label.append(rememberInput, el('span', null, text));
|
|
1179
1238
|
if (n.remember.current) label.appendChild(el('span', 'asst-route-remember-current', tr('assistant.routes.rememberCurrent', 'now: {current}', { current: n.remember.current })));
|
|
1180
1239
|
card.appendChild(label);
|
|
@@ -1186,7 +1245,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1186
1245
|
card.appendChild(error);
|
|
1187
1246
|
|
|
1188
1247
|
const actions = el('div', 'asst-control-actions');
|
|
1189
|
-
const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', n.decline.label
|
|
1248
|
+
const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', (n.decline.label && n.decline.label !== 'Cancel' ? n.decline.label : tr('common.cancel', 'Cancel')));
|
|
1190
1249
|
cancelBtn.type = 'button';
|
|
1191
1250
|
// When the server does not accept a decline, the card can only be answered.
|
|
1192
1251
|
cancelBtn.hidden = !n.decline.allowed;
|
|
@@ -1386,11 +1445,13 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1386
1445
|
return collapse(phase, route);
|
|
1387
1446
|
},
|
|
1388
1447
|
/** ROUTE_INVALID: keep (or re-open) the card with the message. */
|
|
1389
|
-
fail(message) {
|
|
1448
|
+
fail(message, code) {
|
|
1390
1449
|
clearTimers();
|
|
1391
1450
|
restore();
|
|
1392
1451
|
setPending(false, '');
|
|
1393
|
-
error.textContent =
|
|
1452
|
+
error.textContent = n.needsHost && code === 'ROUTE_IS_DIRECT'
|
|
1453
|
+
? view.sides.dispatch.reason
|
|
1454
|
+
: message || tr('assistant.routes.invalid', 'That route is not available. Pick another option.');
|
|
1394
1455
|
error.hidden = false;
|
|
1395
1456
|
if (expires) { tick(); if (!state.expired) state.timer = setInterval(tick, 1000); }
|
|
1396
1457
|
entry.focus();
|
|
@@ -1401,8 +1462,28 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1401
1462
|
}
|
|
1402
1463
|
|
|
1403
1464
|
// ── Routes editor (draft, modes, task choices) ───────────────────────────────
|
|
1404
|
-
// Its model lists still come only through asst-route-models.js.
|
|
1405
|
-
|
|
1465
|
+
// Its model lists still come only through asst-route-models.js. The module loads in an idle moment after the page
|
|
1466
|
+
// is shown or at the first open, whichever comes first (lazy-module.js), so the page does not wait for it at boot.
|
|
1467
|
+
// A browser keeps a failed module address failed for the life of the page (a server restart can refuse the idle
|
|
1468
|
+
// load), so a later attempt asks under a new address. A failed load never ran, so there is still one editor.
|
|
1469
|
+
let routesEditorAttempts = 0;
|
|
1470
|
+
const routesEditorModule = createLazyModule(() => {
|
|
1471
|
+
const attempt = routesEditorAttempts++;
|
|
1472
|
+
return attempt ? import(`./asst-routes-editor.js?retry=${attempt}`) : import('./asst-routes-editor.js');
|
|
1473
|
+
}, { name: 'Routes editor' });
|
|
1474
|
+
if (typeof document !== 'undefined') registerLaunchPrefetch('assistant-routes-editor', () => routesEditorModule.load(), { order: 16 });
|
|
1475
|
+
|
|
1476
|
+
export function openRoutesEditor(hooks = {}) {
|
|
1477
|
+
const loaded = routesEditorModule.module;
|
|
1478
|
+
if (loaded) return loaded.openRoutesEditor(hooks);
|
|
1479
|
+
// Focus can move during the load: the control that opened the editor is the one it gives focus back to.
|
|
1480
|
+
const opened = { ...hooks, returnTo: hooks.returnTo ?? globalThis.document?.activeElement };
|
|
1481
|
+
return routesEditorModule.load().then(mod => mod.openRoutesEditor(opened), (err) => {
|
|
1482
|
+
const text = hooks.t?.('assistant.routes.loadFailed');
|
|
1483
|
+
hooks.onToast?.(typeof text === 'string' && text !== 'assistant.routes.loadFailed' ? text : 'Could not load model routes');
|
|
1484
|
+
throw err;
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1406
1487
|
|
|
1407
1488
|
// ── Models manager (Assistant → Models…) ───────────────────────────────────
|
|
1408
1489
|
|
|
@@ -96,7 +96,7 @@ export async function openRoutesEditor(hooks = {}) {
|
|
|
96
96
|
if (editor) { editor.focus(); return editor; }
|
|
97
97
|
const tr = translator(hooks.t);
|
|
98
98
|
const id = `asst-routes-${++uid}`;
|
|
99
|
-
const returnTo = document.activeElement;
|
|
99
|
+
const returnTo = hooks.returnTo ?? document.activeElement;
|
|
100
100
|
const overlay = el('div', 'asst-modal-overlay asst-routes-overlay');
|
|
101
101
|
overlay.setAttribute('role', 'dialog'); overlay.setAttribute('aria-modal', 'true'); overlay.setAttribute('aria-labelledby', `${id}-title`);
|
|
102
102
|
const modal = el('div', 'asst-modal asst-routes-modal');
|