@schlessera/brain-ui-react 0.34.1 → 0.36.0
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/README.md +89 -4
- package/dist/components/activity/activity-page.d.ts +17 -5
- package/dist/components/activity/activity-page.d.ts.map +1 -1
- package/dist/components/activity/activity-page.js +144 -50
- package/dist/components/activity/activity-page.js.map +1 -1
- package/dist/components/activity/activity-run-detail.d.ts +16 -1
- package/dist/components/activity/activity-run-detail.d.ts.map +1 -1
- package/dist/components/activity/activity-run-detail.js +47 -4
- package/dist/components/activity/activity-run-detail.js.map +1 -1
- package/dist/components/activity/activity-run-list.d.ts +7 -1
- package/dist/components/activity/activity-run-list.d.ts.map +1 -1
- package/dist/components/activity/activity-run-list.js +16 -8
- package/dist/components/activity/activity-run-list.js.map +1 -1
- package/dist/components/activity/activity-views.d.ts +63 -0
- package/dist/components/activity/activity-views.d.ts.map +1 -0
- package/dist/components/activity/activity-views.js +52 -0
- package/dist/components/activity/activity-views.js.map +1 -0
- package/dist/components/activity/approval-card.d.ts +11 -0
- package/dist/components/activity/approval-card.d.ts.map +1 -0
- package/dist/components/activity/approval-card.js +46 -0
- package/dist/components/activity/approval-card.js.map +1 -0
- package/dist/components/activity/digest-card.d.ts +3 -0
- package/dist/components/activity/digest-card.d.ts.map +1 -1
- package/dist/components/activity/digest-card.js +20 -16
- package/dist/components/activity/digest-card.js.map +1 -1
- package/dist/components/activity/digest-summary.d.ts +19 -0
- package/dist/components/activity/digest-summary.d.ts.map +1 -0
- package/dist/components/activity/digest-summary.js +20 -0
- package/dist/components/activity/digest-summary.js.map +1 -0
- package/dist/components/activity/push-switch.d.ts +25 -0
- package/dist/components/activity/push-switch.d.ts.map +1 -0
- package/dist/components/activity/push-switch.js +14 -0
- package/dist/components/activity/push-switch.js.map +1 -0
- package/dist/components/activity/push-toggle.d.ts +7 -0
- package/dist/components/activity/push-toggle.d.ts.map +1 -1
- package/dist/components/activity/push-toggle.js +72 -47
- package/dist/components/activity/push-toggle.js.map +1 -1
- package/dist/components/activity/span-bits.d.ts.map +1 -1
- package/dist/components/activity/span-bits.js +9 -7
- package/dist/components/activity/span-bits.js.map +1 -1
- package/dist/components/chat/ask-user-card.d.ts +76 -3
- package/dist/components/chat/ask-user-card.d.ts.map +1 -1
- package/dist/components/chat/ask-user-card.js +208 -149
- package/dist/components/chat/ask-user-card.js.map +1 -1
- package/dist/components/chat/ask-user-typed.d.ts +42 -0
- package/dist/components/chat/ask-user-typed.d.ts.map +1 -0
- package/dist/components/chat/ask-user-typed.js +60 -0
- package/dist/components/chat/ask-user-typed.js.map +1 -0
- package/dist/components/chat/brain-markdown-links.d.ts +2 -1
- package/dist/components/chat/brain-markdown-links.d.ts.map +1 -1
- package/dist/components/chat/brain-markdown-links.js +3 -4
- package/dist/components/chat/brain-markdown-links.js.map +1 -1
- package/dist/components/chat/brain-markdown.d.ts.map +1 -1
- package/dist/components/chat/brain-markdown.js +4 -2
- package/dist/components/chat/brain-markdown.js.map +1 -1
- package/dist/components/chat/chat-page.d.ts.map +1 -1
- package/dist/components/chat/chat-page.js +24 -9
- package/dist/components/chat/chat-page.js.map +1 -1
- package/dist/components/chat/composer-view.d.ts +75 -0
- package/dist/components/chat/composer-view.d.ts.map +1 -0
- package/dist/components/chat/composer-view.js +31 -0
- package/dist/components/chat/composer-view.js.map +1 -0
- package/dist/components/chat/composer.d.ts +4 -0
- package/dist/components/chat/composer.d.ts.map +1 -1
- package/dist/components/chat/composer.js +76 -59
- package/dist/components/chat/composer.js.map +1 -1
- package/dist/components/chat/markdown-content.d.ts +16 -1
- package/dist/components/chat/markdown-content.d.ts.map +1 -1
- package/dist/components/chat/markdown-content.js +47 -3
- package/dist/components/chat/markdown-content.js.map +1 -1
- package/dist/components/chat/mermaid-block.d.ts +4 -0
- package/dist/components/chat/mermaid-block.d.ts.map +1 -1
- package/dist/components/chat/mermaid-block.js +13 -5
- package/dist/components/chat/mermaid-block.js.map +1 -1
- package/dist/components/chat/mermaid-share.d.ts +2 -1
- package/dist/components/chat/mermaid-share.d.ts.map +1 -1
- package/dist/components/chat/mermaid-share.js +7 -8
- package/dist/components/chat/mermaid-share.js.map +1 -1
- package/dist/components/chat/mermaid-viewer.d.ts.map +1 -1
- package/dist/components/chat/mermaid-viewer.js +3 -1
- package/dist/components/chat/mermaid-viewer.js.map +1 -1
- package/dist/components/chat/message-bubble.d.ts +8 -1
- package/dist/components/chat/message-bubble.d.ts.map +1 -1
- package/dist/components/chat/message-bubble.js +53 -24
- package/dist/components/chat/message-bubble.js.map +1 -1
- package/dist/components/chat/message-share.d.ts +2 -1
- package/dist/components/chat/message-share.d.ts.map +1 -1
- package/dist/components/chat/message-share.js +6 -7
- package/dist/components/chat/message-share.js.map +1 -1
- package/dist/components/chat/renderers/bind.d.ts +39 -0
- package/dist/components/chat/renderers/bind.d.ts.map +1 -0
- package/dist/components/chat/renderers/bind.js +43 -0
- package/dist/components/chat/renderers/bind.js.map +1 -0
- package/dist/components/chat/renderers/brain-ui-tools.d.ts +3 -0
- package/dist/components/chat/renderers/brain-ui-tools.d.ts.map +1 -0
- package/dist/components/chat/renderers/brain-ui-tools.js +41 -0
- package/dist/components/chat/renderers/brain-ui-tools.js.map +1 -0
- package/dist/components/chat/renderers/claude-tools.d.ts.map +1 -1
- package/dist/components/chat/renderers/claude-tools.js +3 -2
- package/dist/components/chat/renderers/claude-tools.js.map +1 -1
- package/dist/components/chat/renderers/index.d.ts +10 -2
- package/dist/components/chat/renderers/index.d.ts.map +1 -1
- package/dist/components/chat/renderers/index.js +15 -10
- package/dist/components/chat/renderers/index.js.map +1 -1
- package/dist/components/chat/session-drawer.d.ts +4 -0
- package/dist/components/chat/session-drawer.d.ts.map +1 -1
- package/dist/components/chat/session-drawer.js +55 -40
- package/dist/components/chat/session-drawer.js.map +1 -1
- package/dist/components/chat/session-list.d.ts +41 -0
- package/dist/components/chat/session-list.d.ts.map +1 -0
- package/dist/components/chat/session-list.js +10 -0
- package/dist/components/chat/session-list.js.map +1 -0
- package/dist/components/chat/share-block.d.ts.map +1 -1
- package/dist/components/chat/share-block.js +12 -11
- package/dist/components/chat/share-block.js.map +1 -1
- package/dist/components/chat/share-card.js +2 -2
- package/dist/components/chat/share-card.js.map +1 -1
- package/dist/components/chat/subagent-view.js +1 -1
- package/dist/components/chat/subagent-view.js.map +1 -1
- package/dist/components/chat/tool-call-timeline.d.ts.map +1 -1
- package/dist/components/chat/tool-call-timeline.js +37 -12
- package/dist/components/chat/tool-call-timeline.js.map +1 -1
- package/dist/components/chat/tool-cards/block-card.d.ts +28 -0
- package/dist/components/chat/tool-cards/block-card.d.ts.map +1 -0
- package/dist/components/chat/tool-cards/block-card.js +103 -0
- package/dist/components/chat/tool-cards/block-card.js.map +1 -0
- package/dist/components/chat/tool-cards/image-mask-card.d.ts +70 -0
- package/dist/components/chat/tool-cards/image-mask-card.d.ts.map +1 -0
- package/dist/components/chat/tool-cards/image-mask-card.js +142 -0
- package/dist/components/chat/tool-cards/image-mask-card.js.map +1 -0
- package/dist/components/chat/tool-cards/location-card.d.ts +45 -0
- package/dist/components/chat/tool-cards/location-card.d.ts.map +1 -0
- package/dist/components/chat/tool-cards/location-card.js +128 -0
- package/dist/components/chat/tool-cards/location-card.js.map +1 -0
- package/dist/components/chat/tool-views.d.ts +15 -4
- package/dist/components/chat/tool-views.d.ts.map +1 -1
- package/dist/components/chat/tool-views.js +22 -38
- package/dist/components/chat/tool-views.js.map +1 -1
- package/dist/components/chat/transcript-turn.d.ts +45 -0
- package/dist/components/chat/transcript-turn.d.ts.map +1 -0
- package/dist/components/chat/transcript-turn.js +25 -0
- package/dist/components/chat/transcript-turn.js.map +1 -0
- package/dist/components/chat/use-chat-commands.d.ts.map +1 -1
- package/dist/components/chat/use-chat-commands.js +13 -16
- package/dist/components/chat/use-chat-commands.js.map +1 -1
- package/dist/components/chat/welcome-state.d.ts +7 -0
- package/dist/components/chat/welcome-state.d.ts.map +1 -1
- package/dist/components/chat/welcome-state.js +13 -5
- package/dist/components/chat/welcome-state.js.map +1 -1
- package/dist/components/connectivity/connection-gate.d.ts.map +1 -1
- package/dist/components/connectivity/connection-gate.js +64 -6
- package/dist/components/connectivity/connection-gate.js.map +1 -1
- package/dist/components/connectivity/login-form.d.ts +31 -0
- package/dist/components/connectivity/login-form.d.ts.map +1 -0
- package/dist/components/connectivity/login-form.js +19 -0
- package/dist/components/connectivity/login-form.js.map +1 -0
- package/dist/components/connectivity/login-screen.d.ts +5 -2
- package/dist/components/connectivity/login-screen.d.ts.map +1 -1
- package/dist/components/connectivity/login-screen.js +41 -31
- package/dist/components/connectivity/login-screen.js.map +1 -1
- package/dist/components/dev/share-harness.js +1 -1
- package/dist/components/dev/share-harness.js.map +1 -1
- package/dist/components/files/file-panel.d.ts +1 -1
- package/dist/components/files/file-panel.d.ts.map +1 -1
- package/dist/components/files/file-panel.js +74 -0
- package/dist/components/files/file-panel.js.map +1 -1
- package/dist/components/files/file-tree-view.d.ts +45 -0
- package/dist/components/files/file-tree-view.d.ts.map +1 -0
- package/dist/components/files/file-tree-view.js +51 -0
- package/dist/components/files/file-tree-view.js.map +1 -0
- package/dist/components/files/file-tree.d.ts +6 -0
- package/dist/components/files/file-tree.d.ts.map +1 -1
- package/dist/components/files/file-tree.js +39 -43
- package/dist/components/files/file-tree.js.map +1 -1
- package/dist/components/files/file-viewer-binary.d.ts.map +1 -1
- package/dist/components/files/file-viewer-binary.js +3 -2
- package/dist/components/files/file-viewer-binary.js.map +1 -1
- package/dist/components/files/file-viewer-frame.d.ts +36 -0
- package/dist/components/files/file-viewer-frame.d.ts.map +1 -0
- package/dist/components/files/file-viewer-frame.js +26 -0
- package/dist/components/files/file-viewer-frame.js.map +1 -0
- package/dist/components/files/file-viewer.d.ts +5 -0
- package/dist/components/files/file-viewer.d.ts.map +1 -1
- package/dist/components/files/file-viewer.js +26 -32
- package/dist/components/files/file-viewer.js.map +1 -1
- package/dist/components/files/frontmatter-chips.d.ts +18 -0
- package/dist/components/files/frontmatter-chips.d.ts.map +1 -0
- package/dist/components/files/frontmatter-chips.js +11 -0
- package/dist/components/files/frontmatter-chips.js.map +1 -0
- package/dist/components/files/frontmatter-panel.d.ts +5 -1
- package/dist/components/files/frontmatter-panel.d.ts.map +1 -1
- package/dist/components/files/frontmatter-panel.js +7 -6
- package/dist/components/files/frontmatter-panel.js.map +1 -1
- package/dist/components/files/staleness.d.ts +18 -0
- package/dist/components/files/staleness.d.ts.map +1 -0
- package/dist/components/files/staleness.js +27 -0
- package/dist/components/files/staleness.js.map +1 -0
- package/dist/components/graph/graph-canvas.d.ts.map +1 -1
- package/dist/components/graph/graph-canvas.js +24 -1
- package/dist/components/graph/graph-canvas.js.map +1 -1
- package/dist/components/graph/graph-controls-column.d.ts +14 -0
- package/dist/components/graph/graph-controls-column.d.ts.map +1 -0
- package/dist/components/graph/graph-controls-column.js +44 -0
- package/dist/components/graph/graph-controls-column.js.map +1 -0
- package/dist/components/graph/graph-controls.d.ts +20 -5
- package/dist/components/graph/graph-controls.d.ts.map +1 -1
- package/dist/components/graph/graph-controls.js +58 -37
- package/dist/components/graph/graph-controls.js.map +1 -1
- package/dist/components/graph/graph-form.d.ts +82 -0
- package/dist/components/graph/graph-form.d.ts.map +1 -0
- package/dist/components/graph/graph-form.js +69 -0
- package/dist/components/graph/graph-form.js.map +1 -0
- package/dist/components/graph/graph-maintenance.d.ts.map +1 -1
- package/dist/components/graph/graph-maintenance.js +6 -10
- package/dist/components/graph/graph-maintenance.js.map +1 -1
- package/dist/components/graph/graph-node-rail.d.ts +13 -0
- package/dist/components/graph/graph-node-rail.d.ts.map +1 -0
- package/dist/components/graph/graph-node-rail.js +92 -0
- package/dist/components/graph/graph-node-rail.js.map +1 -0
- package/dist/components/graph/graph-page.d.ts +7 -0
- package/dist/components/graph/graph-page.d.ts.map +1 -1
- package/dist/components/graph/graph-page.js +102 -12
- package/dist/components/graph/graph-page.js.map +1 -1
- package/dist/components/graph/graph-scene.d.ts.map +1 -1
- package/dist/components/graph/graph-scene.js +100 -24
- package/dist/components/graph/graph-scene.js.map +1 -1
- package/dist/components/graph/lib/graph-helpers.d.ts +42 -12
- package/dist/components/graph/lib/graph-helpers.d.ts.map +1 -1
- package/dist/components/graph/lib/graph-helpers.js +33 -41
- package/dist/components/graph/lib/graph-helpers.js.map +1 -1
- package/dist/components/graph/node-card.d.ts +28 -0
- package/dist/components/graph/node-card.d.ts.map +1 -0
- package/dist/components/graph/node-card.js +7 -0
- package/dist/components/graph/node-card.js.map +1 -0
- package/dist/components/graph/node-popover.d.ts +6 -2
- package/dist/components/graph/node-popover.d.ts.map +1 -1
- package/dist/components/graph/node-popover.js +13 -31
- package/dist/components/graph/node-popover.js.map +1 -1
- package/dist/components/graph/use-graph-theme.d.ts +32 -4
- package/dist/components/graph/use-graph-theme.d.ts.map +1 -1
- package/dist/components/graph/use-graph-theme.js +44 -32
- package/dist/components/graph/use-graph-theme.js.map +1 -1
- package/dist/components/graph/use-node-actions.d.ts +26 -0
- package/dist/components/graph/use-node-actions.d.ts.map +1 -0
- package/dist/components/graph/use-node-actions.js +54 -0
- package/dist/components/graph/use-node-actions.js.map +1 -0
- package/dist/components/images/image-share.d.ts +2 -1
- package/dist/components/images/image-share.d.ts.map +1 -1
- package/dist/components/images/image-share.js +3 -3
- package/dist/components/images/image-share.js.map +1 -1
- package/dist/components/images/image-viewer.d.ts.map +1 -1
- package/dist/components/images/image-viewer.js +3 -1
- package/dist/components/images/image-viewer.js.map +1 -1
- package/dist/components/images/mask-editor.d.ts.map +1 -1
- package/dist/components/images/mask-editor.js +7 -5
- package/dist/components/images/mask-editor.js.map +1 -1
- package/dist/components/layout/app-shell.d.ts.map +1 -1
- package/dist/components/layout/app-shell.js +5 -1
- package/dist/components/layout/app-shell.js.map +1 -1
- package/dist/components/layout/desktop-palette.d.ts +23 -0
- package/dist/components/layout/desktop-palette.d.ts.map +1 -0
- package/dist/components/layout/desktop-palette.js +132 -0
- package/dist/components/layout/desktop-palette.js.map +1 -0
- package/dist/components/layout/key-cap.d.ts +9 -0
- package/dist/components/layout/key-cap.d.ts.map +1 -0
- package/dist/components/layout/key-cap.js +10 -0
- package/dist/components/layout/key-cap.js.map +1 -0
- package/dist/components/layout/mobile-tab-bar.d.ts +13 -0
- package/dist/components/layout/mobile-tab-bar.d.ts.map +1 -1
- package/dist/components/layout/mobile-tab-bar.js +58 -47
- package/dist/components/layout/mobile-tab-bar.js.map +1 -1
- package/dist/components/layout/shortcut-switch.d.ts +13 -0
- package/dist/components/layout/shortcut-switch.d.ts.map +1 -0
- package/dist/components/layout/shortcut-switch.js +22 -0
- package/dist/components/layout/shortcut-switch.js.map +1 -0
- package/dist/components/layout/side-rail.d.ts +24 -0
- package/dist/components/layout/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail.js +65 -27
- package/dist/components/layout/side-rail.js.map +1 -1
- package/dist/components/layout/slide-panel.d.ts +12 -2
- package/dist/components/layout/slide-panel.d.ts.map +1 -1
- package/dist/components/layout/slide-panel.js +11 -2
- package/dist/components/layout/slide-panel.js.map +1 -1
- package/dist/components/layout/theme.d.ts +22 -0
- package/dist/components/layout/theme.d.ts.map +1 -0
- package/dist/components/layout/theme.js +44 -0
- package/dist/components/layout/theme.js.map +1 -0
- package/dist/components/quick-actions/add-form.d.ts +44 -0
- package/dist/components/quick-actions/add-form.d.ts.map +1 -0
- package/dist/components/quick-actions/add-form.js +30 -0
- package/dist/components/quick-actions/add-form.js.map +1 -0
- package/dist/components/quick-actions/add-modal.d.ts +7 -0
- package/dist/components/quick-actions/add-modal.d.ts.map +1 -1
- package/dist/components/quick-actions/add-modal.js +66 -20
- package/dist/components/quick-actions/add-modal.js.map +1 -1
- package/dist/components/quick-actions/search-modal.d.ts.map +1 -1
- package/dist/components/quick-actions/search-modal.js +48 -19
- package/dist/components/quick-actions/search-modal.js.map +1 -1
- package/dist/components/quick-actions/streaming-modal.d.ts +6 -0
- package/dist/components/quick-actions/streaming-modal.d.ts.map +1 -1
- package/dist/components/quick-actions/streaming-modal.js +42 -17
- package/dist/components/quick-actions/streaming-modal.js.map +1 -1
- package/dist/components/quick-actions/streaming-output.d.ts +38 -0
- package/dist/components/quick-actions/streaming-output.d.ts.map +1 -0
- package/dist/components/quick-actions/streaming-output.js +22 -0
- package/dist/components/quick-actions/streaming-output.js.map +1 -0
- package/dist/components/quick-actions/whatsup-modal.d.ts +5 -0
- package/dist/components/quick-actions/whatsup-modal.d.ts.map +1 -1
- package/dist/components/quick-actions/whatsup-modal.js +36 -10
- package/dist/components/quick-actions/whatsup-modal.js.map +1 -1
- package/dist/components/settings/devices-agents-tab.d.ts +10 -0
- package/dist/components/settings/devices-agents-tab.d.ts.map +1 -0
- package/dist/components/settings/devices-agents-tab.js +131 -0
- package/dist/components/settings/devices-agents-tab.js.map +1 -0
- package/dist/components/settings/models-list.d.ts +39 -0
- package/dist/components/settings/models-list.d.ts.map +1 -0
- package/dist/components/settings/models-list.js +72 -0
- package/dist/components/settings/models-list.js.map +1 -0
- package/dist/components/settings/models-tab.d.ts +4 -0
- package/dist/components/settings/models-tab.d.ts.map +1 -1
- package/dist/components/settings/models-tab.js +52 -102
- package/dist/components/settings/models-tab.js.map +1 -1
- package/dist/components/settings/one-time-agent-credential.d.ts +3 -0
- package/dist/components/settings/one-time-agent-credential.d.ts.map +1 -0
- package/dist/components/settings/one-time-agent-credential.js +55 -0
- package/dist/components/settings/one-time-agent-credential.js.map +1 -0
- package/dist/components/settings/passkey-list.d.ts +35 -0
- package/dist/components/settings/passkey-list.d.ts.map +1 -0
- package/dist/components/settings/passkey-list.js +34 -0
- package/dist/components/settings/passkey-list.js.map +1 -0
- package/dist/components/settings/passkey-tab.d.ts +3 -0
- package/dist/components/settings/passkey-tab.d.ts.map +1 -1
- package/dist/components/settings/passkey-tab.js +53 -45
- package/dist/components/settings/passkey-tab.js.map +1 -1
- package/dist/components/settings/pi-accounts-list.d.ts +27 -0
- package/dist/components/settings/pi-accounts-list.d.ts.map +1 -0
- package/dist/components/settings/pi-accounts-list.js +15 -0
- package/dist/components/settings/pi-accounts-list.js.map +1 -0
- package/dist/components/settings/pi-accounts.d.ts +3 -0
- package/dist/components/settings/pi-accounts.d.ts.map +1 -1
- package/dist/components/settings/pi-accounts.js +73 -55
- package/dist/components/settings/pi-accounts.js.map +1 -1
- package/dist/components/settings/principal-list.d.ts +37 -0
- package/dist/components/settings/principal-list.d.ts.map +1 -0
- package/dist/components/settings/principal-list.js +18 -0
- package/dist/components/settings/principal-list.js.map +1 -0
- package/dist/components/settings/settings-panel.d.ts +10 -3
- package/dist/components/settings/settings-panel.d.ts.map +1 -1
- package/dist/components/settings/settings-panel.js +80 -6
- package/dist/components/settings/settings-panel.js.map +1 -1
- package/dist/components/settings/skills-list.d.ts +53 -0
- package/dist/components/settings/skills-list.d.ts.map +1 -0
- package/dist/components/settings/skills-list.js +28 -0
- package/dist/components/settings/skills-list.js.map +1 -0
- package/dist/components/settings/skills-tab.d.ts.map +1 -1
- package/dist/components/settings/skills-tab.js +65 -38
- package/dist/components/settings/skills-tab.js.map +1 -1
- package/dist/components/settings/tool-permissions-list.d.ts +18 -0
- package/dist/components/settings/tool-permissions-list.d.ts.map +1 -0
- package/dist/components/settings/tool-permissions-list.js +6 -0
- package/dist/components/settings/tool-permissions-list.js.map +1 -0
- package/dist/components/settings/tool-permissions.d.ts +2 -1
- package/dist/components/settings/tool-permissions.d.ts.map +1 -1
- package/dist/components/settings/tool-permissions.js +33 -16
- package/dist/components/settings/tool-permissions.js.map +1 -1
- package/dist/components/settings/web-search-chain.d.ts +41 -0
- package/dist/components/settings/web-search-chain.d.ts.map +1 -0
- package/dist/components/settings/web-search-chain.js +47 -0
- package/dist/components/settings/web-search-chain.js.map +1 -0
- package/dist/components/settings/web-search-settings.d.ts +4 -7
- package/dist/components/settings/web-search-settings.d.ts.map +1 -1
- package/dist/components/settings/web-search-settings.js +54 -76
- package/dist/components/settings/web-search-settings.js.map +1 -1
- package/dist/components/share/share-menu.d.ts.map +1 -1
- package/dist/components/share/share-menu.js +24 -4
- package/dist/components/share/share-menu.js.map +1 -1
- package/dist/components/voice/dictation-sheet.js +3 -3
- package/dist/components/voice/dictation-sheet.js.map +1 -1
- package/dist/components/voice/mic-button.js +1 -1
- package/dist/components/voice/mic-button.js.map +1 -1
- package/dist/components/voice/review-card.js +1 -1
- package/dist/components/voice/review-card.js.map +1 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -5
- package/dist/config.js.map +1 -1
- package/dist/connection.d.ts +12 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +421 -0
- package/dist/connection.js.map +1 -0
- package/dist/default-root.d.ts +3 -0
- package/dist/default-root.d.ts.map +1 -0
- package/dist/default-root.js +16 -0
- package/dist/default-root.js.map +1 -0
- package/dist/hooks/use-color-scheme.d.ts +14 -0
- package/dist/hooks/use-color-scheme.d.ts.map +1 -0
- package/dist/hooks/use-color-scheme.js +37 -0
- package/dist/hooks/use-color-scheme.js.map +1 -0
- package/dist/hooks/use-hash-routes.d.ts.map +1 -1
- package/dist/hooks/use-hash-routes.js +4 -2
- package/dist/hooks/use-hash-routes.js.map +1 -1
- package/dist/hooks/use-media-query.d.ts +7 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +34 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-share-intake.d.ts.map +1 -1
- package/dist/hooks/use-share-intake.js +37 -12
- package/dist/hooks/use-share-intake.js.map +1 -1
- package/dist/hooks/use-vpn-status.d.ts +1 -1
- package/dist/hooks/use-vpn-status.d.ts.map +1 -1
- package/dist/hooks/use-vpn-status.js +20 -16
- package/dist/hooks/use-vpn-status.js.map +1 -1
- package/dist/hooks/use-websocket.d.ts +5 -24
- package/dist/hooks/use-websocket.d.ts.map +1 -1
- package/dist/hooks/use-websocket.js +11 -382
- package/dist/hooks/use-websocket.js.map +1 -1
- package/dist/hooks/websocket-handlers/activity.d.ts +2 -2
- package/dist/hooks/websocket-handlers/activity.d.ts.map +1 -1
- package/dist/hooks/websocket-handlers/activity.js +4 -5
- package/dist/hooks/websocket-handlers/activity.js.map +1 -1
- package/dist/hooks/websocket-handlers/chat.d.ts +1 -0
- package/dist/hooks/websocket-handlers/chat.d.ts.map +1 -1
- package/dist/hooks/websocket-handlers/chat.js +27 -5
- package/dist/hooks/websocket-handlers/chat.js.map +1 -1
- package/dist/hooks/websocket-handlers/connection.d.ts.map +1 -1
- package/dist/hooks/websocket-handlers/connection.js +4 -6
- package/dist/hooks/websocket-handlers/connection.js.map +1 -1
- package/dist/hooks/websocket-handlers/mask.d.ts +1 -1
- package/dist/hooks/websocket-handlers/mask.d.ts.map +1 -1
- package/dist/hooks/websocket-handlers/mask.js +2 -3
- package/dist/hooks/websocket-handlers/mask.js.map +1 -1
- package/dist/hooks/websocket-handlers/provider.d.ts.map +1 -1
- package/dist/hooks/websocket-handlers/provider.js +4 -6
- package/dist/hooks/websocket-handlers/provider.js.map +1 -1
- package/dist/hooks/websocket-handlers/types.d.ts +6 -2
- package/dist/hooks/websocket-handlers/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/api-client.d.ts +321 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +243 -213
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/backend.d.ts +19 -2
- package/dist/lib/backend.d.ts.map +1 -1
- package/dist/lib/backend.js +15 -9
- package/dist/lib/backend.js.map +1 -1
- package/dist/lib/diff.d.ts +8 -10
- package/dist/lib/diff.d.ts.map +1 -1
- package/dist/lib/diff.js +26 -53
- package/dist/lib/diff.js.map +1 -1
- package/dist/lib/format-time.d.ts +3 -0
- package/dist/lib/format-time.d.ts.map +1 -0
- package/dist/lib/format-time.js +25 -0
- package/dist/lib/format-time.js.map +1 -0
- package/dist/lib/light-dark.d.ts +37 -0
- package/dist/lib/light-dark.d.ts.map +1 -0
- package/dist/lib/light-dark.js +83 -0
- package/dist/lib/light-dark.js.map +1 -0
- package/dist/lib/mermaid-theme.d.ts +7 -2
- package/dist/lib/mermaid-theme.d.ts.map +1 -1
- package/dist/lib/mermaid-theme.js +125 -203
- package/dist/lib/mermaid-theme.js.map +1 -1
- package/dist/lib/passkeys.d.ts +6 -3
- package/dist/lib/passkeys.d.ts.map +1 -1
- package/dist/lib/passkeys.js +10 -4
- package/dist/lib/passkeys.js.map +1 -1
- package/dist/lib/push-registration.d.ts +10 -0
- package/dist/lib/push-registration.d.ts.map +1 -0
- package/dist/lib/push-registration.js +44 -0
- package/dist/lib/push-registration.js.map +1 -0
- package/dist/lib/share-intake.d.ts +2 -1
- package/dist/lib/share-intake.d.ts.map +1 -1
- package/dist/lib/share-intake.js +3 -3
- package/dist/lib/share-intake.js.map +1 -1
- package/dist/lib/share.d.ts +4 -3
- package/dist/lib/share.d.ts.map +1 -1
- package/dist/lib/share.js +6 -7
- package/dist/lib/share.js.map +1 -1
- package/dist/lib/single-key.d.ts +30 -0
- package/dist/lib/single-key.d.ts.map +1 -0
- package/dist/lib/single-key.js +45 -0
- package/dist/lib/single-key.js.map +1 -0
- package/dist/lib/tool-names.d.ts +8 -6
- package/dist/lib/tool-names.d.ts.map +1 -1
- package/dist/lib/tool-names.js +17 -7
- package/dist/lib/tool-names.js.map +1 -1
- package/dist/root-context.d.ts +229 -0
- package/dist/root-context.d.ts.map +1 -0
- package/dist/root-context.js +33 -0
- package/dist/root-context.js.map +1 -0
- package/dist/root.d.ts +38 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +47 -0
- package/dist/root.js.map +1 -0
- package/dist/stores/activity-state.d.ts +29 -0
- package/dist/stores/activity-state.d.ts.map +1 -0
- package/dist/stores/activity-state.js +282 -0
- package/dist/stores/activity-state.js.map +1 -0
- package/dist/stores/activity-store.d.ts +10 -41
- package/dist/stores/activity-store.d.ts.map +1 -1
- package/dist/stores/activity-store.js +9 -271
- package/dist/stores/activity-store.js.map +1 -1
- package/dist/stores/chat-state.d.ts +212 -0
- package/dist/stores/chat-state.d.ts.map +1 -0
- package/dist/stores/chat-state.js +466 -0
- package/dist/stores/chat-state.js.map +1 -0
- package/dist/stores/chat-store.d.ts +4 -162
- package/dist/stores/chat-store.d.ts.map +1 -1
- package/dist/stores/chat-store.js +7 -418
- package/dist/stores/chat-store.js.map +1 -1
- package/dist/stores/connection-state.d.ts +40 -0
- package/dist/stores/connection-state.d.ts.map +1 -0
- package/dist/stores/connection-state.js +30 -0
- package/dist/stores/connection-state.js.map +1 -0
- package/dist/stores/connection-store.d.ts +4 -40
- package/dist/stores/connection-store.d.ts.map +1 -1
- package/dist/stores/connection-store.js +7 -27
- package/dist/stores/connection-store.js.map +1 -1
- package/dist/stores/create-stores.d.ts +23 -0
- package/dist/stores/create-stores.d.ts.map +1 -0
- package/dist/stores/create-stores.js +28 -0
- package/dist/stores/create-stores.js.map +1 -0
- package/dist/stores/file-state.d.ts +53 -0
- package/dist/stores/file-state.d.ts.map +1 -0
- package/dist/stores/file-state.js +341 -0
- package/dist/stores/file-state.js.map +1 -0
- package/dist/stores/file-store.d.ts +4 -52
- package/dist/stores/file-store.d.ts.map +1 -1
- package/dist/stores/file-store.js +7 -300
- package/dist/stores/file-store.js.map +1 -1
- package/dist/stores/graph-state.d.ts +95 -0
- package/dist/stores/graph-state.d.ts.map +1 -0
- package/dist/stores/graph-state.js +252 -0
- package/dist/stores/graph-state.js.map +1 -0
- package/dist/stores/graph-store.d.ts +7 -83
- package/dist/stores/graph-store.d.ts.map +1 -1
- package/dist/stores/graph-store.js +8 -249
- package/dist/stores/graph-store.js.map +1 -1
- package/dist/stores/mask-state.d.ts +21 -0
- package/dist/stores/mask-state.d.ts.map +1 -0
- package/dist/stores/mask-state.js +9 -0
- package/dist/stores/mask-state.js.map +1 -0
- package/dist/stores/mask-store.d.ts +4 -21
- package/dist/stores/mask-store.d.ts.map +1 -1
- package/dist/stores/mask-store.js +7 -6
- package/dist/stores/mask-store.js.map +1 -1
- package/dist/stores/principal-state.d.ts +16 -0
- package/dist/stores/principal-state.d.ts.map +1 -0
- package/dist/stores/principal-state.js +31 -0
- package/dist/stores/principal-state.js.map +1 -0
- package/dist/stores/principal-store.d.ts +5 -0
- package/dist/stores/principal-store.d.ts.map +1 -0
- package/dist/stores/principal-store.js +8 -0
- package/dist/stores/principal-store.js.map +1 -0
- package/dist/stores/provider-state.d.ts +24 -0
- package/dist/stores/provider-state.d.ts.map +1 -0
- package/dist/stores/provider-state.js +68 -0
- package/dist/stores/provider-state.js.map +1 -0
- package/dist/stores/provider-store.d.ts +4 -23
- package/dist/stores/provider-store.d.ts.map +1 -1
- package/dist/stores/provider-store.js +7 -64
- package/dist/stores/provider-store.js.map +1 -1
- package/dist/stores/share-state.d.ts +29 -0
- package/dist/stores/share-state.d.ts.map +1 -0
- package/dist/stores/share-state.js +21 -0
- package/dist/stores/share-state.js.map +1 -0
- package/dist/stores/share-store.d.ts +4 -28
- package/dist/stores/share-store.d.ts.map +1 -1
- package/dist/stores/share-store.js +7 -18
- package/dist/stores/share-store.js.map +1 -1
- package/dist/stores/store-environment.d.ts +10 -0
- package/dist/stores/store-environment.d.ts.map +1 -0
- package/dist/stores/store-environment.js +2 -0
- package/dist/stores/store-environment.js.map +1 -0
- package/dist/stores/ui-state.d.ts +71 -0
- package/dist/stores/ui-state.d.ts.map +1 -0
- package/dist/stores/ui-state.js +58 -0
- package/dist/stores/ui-state.js.map +1 -0
- package/dist/stores/ui-store.d.ts +4 -45
- package/dist/stores/ui-store.d.ts.map +1 -1
- package/dist/stores/ui-store.js +7 -36
- package/dist/stores/ui-store.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +150 -97
- package/dist/voice/asr-clients.d.ts +2 -1
- package/dist/voice/asr-clients.d.ts.map +1 -1
- package/dist/voice/asr-clients.js +16 -17
- package/dist/voice/asr-clients.js.map +1 -1
- package/dist/voice/use-dictation.d.ts.map +1 -1
- package/dist/voice/use-dictation.js +12 -8
- package/dist/voice/use-dictation.js.map +1 -1
- package/dist/voice/voice-state.d.ts +25 -0
- package/dist/voice/voice-state.d.ts.map +1 -0
- package/dist/voice/voice-state.js +29 -0
- package/dist/voice/voice-state.js.map +1 -0
- package/dist/voice/voice-store.d.ts +4 -25
- package/dist/voice/voice-store.d.ts.map +1 -1
- package/dist/voice/voice-store.js +7 -26
- package/dist/voice/voice-store.js.map +1 -1
- package/package.json +3 -2
- package/src/components/activity/activity-page.tsx +334 -160
- package/src/components/activity/activity-run-detail.tsx +81 -47
- package/src/components/activity/activity-run-list.tsx +27 -59
- package/src/components/activity/activity-views.tsx +155 -0
- package/src/components/activity/approval-card.tsx +80 -0
- package/src/components/activity/digest-card.tsx +25 -61
- package/src/components/activity/digest-summary.tsx +52 -0
- package/src/components/activity/push-switch.tsx +62 -0
- package/src/components/activity/push-toggle.tsx +51 -81
- package/src/components/activity/span-bits.tsx +8 -7
- package/src/components/chat/ask-user-card.tsx +292 -356
- package/src/components/chat/ask-user-typed.ts +77 -0
- package/src/components/chat/brain-markdown-links.tsx +4 -4
- package/src/components/chat/brain-markdown.tsx +4 -2
- package/src/components/chat/chat-page.tsx +38 -9
- package/src/components/chat/composer-view.tsx +194 -0
- package/src/components/chat/composer.tsx +117 -296
- package/src/components/chat/markdown-content.tsx +53 -2
- package/src/components/chat/mermaid-block.tsx +13 -5
- package/src/components/chat/mermaid-share.ts +8 -7
- package/src/components/chat/mermaid-viewer.tsx +3 -1
- package/src/components/chat/message-bubble.tsx +78 -94
- package/src/components/chat/message-share.ts +7 -7
- package/src/components/chat/renderers/bind.tsx +94 -0
- package/src/components/chat/renderers/brain-ui-tools.tsx +56 -0
- package/src/components/chat/renderers/claude-tools.tsx +3 -2
- package/src/components/chat/renderers/index.ts +15 -10
- package/src/components/chat/session-drawer.tsx +60 -138
- package/src/components/chat/session-list.tsx +113 -0
- package/src/components/chat/share-block.tsx +16 -12
- package/src/components/chat/share-card.tsx +2 -2
- package/src/components/chat/subagent-view.tsx +4 -4
- package/src/components/chat/tool-call-timeline.tsx +59 -22
- package/src/components/chat/tool-cards/block-card.tsx +145 -0
- package/src/components/chat/tool-cards/image-mask-card.tsx +214 -0
- package/src/components/chat/tool-cards/location-card.tsx +159 -0
- package/src/components/chat/tool-views.tsx +23 -73
- package/src/components/chat/transcript-turn.tsx +108 -0
- package/src/components/chat/use-chat-commands.ts +14 -16
- package/src/components/chat/welcome-state.tsx +36 -91
- package/src/components/connectivity/connection-gate.tsx +80 -9
- package/src/components/connectivity/login-form.tsx +122 -0
- package/src/components/connectivity/login-screen.tsx +45 -100
- package/src/components/dev/share-harness.tsx +2 -2
- package/src/components/files/file-panel.tsx +168 -0
- package/src/components/files/file-tree-view.tsx +127 -0
- package/src/components/files/file-tree.tsx +55 -109
- package/src/components/files/file-viewer-binary.tsx +3 -2
- package/src/components/files/file-viewer-frame.tsx +113 -0
- package/src/components/files/file-viewer.tsx +40 -95
- package/src/components/files/frontmatter-chips.tsx +42 -0
- package/src/components/files/frontmatter-panel.tsx +6 -71
- package/src/components/files/staleness.ts +29 -0
- package/src/components/graph/graph-canvas.tsx +24 -1
- package/src/components/graph/graph-controls-column.tsx +92 -0
- package/src/components/graph/graph-controls.tsx +83 -127
- package/src/components/graph/graph-form.tsx +183 -0
- package/src/components/graph/graph-maintenance.tsx +9 -14
- package/src/components/graph/graph-node-rail.tsx +147 -0
- package/src/components/graph/graph-page.tsx +189 -49
- package/src/components/graph/graph-scene.tsx +200 -30
- package/src/components/graph/lib/graph-helpers.ts +65 -43
- package/src/components/graph/node-card.tsx +64 -0
- package/src/components/graph/node-popover.tsx +28 -117
- package/src/components/graph/use-graph-theme.ts +69 -32
- package/src/components/graph/use-node-actions.ts +56 -0
- package/src/components/images/image-share.ts +4 -2
- package/src/components/images/image-viewer.tsx +3 -1
- package/src/components/images/mask-editor.tsx +7 -4
- package/src/components/layout/app-shell.tsx +7 -1
- package/src/components/layout/desktop-palette.tsx +151 -0
- package/src/components/layout/key-cap.tsx +15 -0
- package/src/components/layout/mobile-tab-bar.tsx +80 -157
- package/src/components/layout/shortcut-switch.tsx +32 -0
- package/src/components/layout/side-rail.tsx +70 -150
- package/src/components/layout/slide-panel.tsx +29 -2
- package/src/components/layout/theme.tsx +67 -0
- package/src/components/quick-actions/add-form.tsx +188 -0
- package/src/components/quick-actions/add-modal.tsx +68 -144
- package/src/components/quick-actions/search-modal.tsx +49 -19
- package/src/components/quick-actions/streaming-modal.tsx +44 -71
- package/src/components/quick-actions/streaming-output.tsx +112 -0
- package/src/components/quick-actions/whatsup-modal.tsx +38 -60
- package/src/components/settings/devices-agents-tab.tsx +139 -0
- package/src/components/settings/models-list.tsx +299 -0
- package/src/components/settings/models-tab.tsx +63 -337
- package/src/components/settings/one-time-agent-credential.tsx +131 -0
- package/src/components/settings/passkey-list.tsx +201 -0
- package/src/components/settings/passkey-tab.tsx +53 -197
- package/src/components/settings/pi-accounts-list.tsx +128 -0
- package/src/components/settings/pi-accounts.tsx +71 -170
- package/src/components/settings/principal-list.tsx +172 -0
- package/src/components/settings/settings-panel.tsx +245 -19
- package/src/components/settings/skills-list.tsx +276 -0
- package/src/components/settings/skills-tab.tsx +82 -269
- package/src/components/settings/tool-permissions-list.tsx +54 -0
- package/src/components/settings/tool-permissions.tsx +27 -46
- package/src/components/settings/web-search-chain.tsx +300 -0
- package/src/components/settings/web-search-settings.tsx +58 -328
- package/src/components/share/share-menu.tsx +19 -4
- package/src/components/voice/dictation-sheet.tsx +5 -5
- package/src/components/voice/mic-button.tsx +1 -1
- package/src/components/voice/review-card.tsx +1 -1
- package/src/config.ts +21 -7
- package/src/connection.ts +443 -0
- package/src/default-root.ts +16 -0
- package/src/hooks/use-color-scheme.ts +36 -0
- package/src/hooks/use-hash-routes.ts +4 -2
- package/src/hooks/use-media-query.ts +32 -0
- package/src/hooks/use-share-intake.ts +32 -12
- package/src/hooks/use-vpn-status.ts +23 -15
- package/src/hooks/use-websocket.ts +12 -426
- package/src/hooks/websocket-handlers/activity.ts +4 -5
- package/src/hooks/websocket-handlers/chat.ts +26 -5
- package/src/hooks/websocket-handlers/connection.ts +4 -6
- package/src/hooks/websocket-handlers/mask.ts +2 -3
- package/src/hooks/websocket-handlers/provider.ts +4 -6
- package/src/hooks/websocket-handlers/types.ts +6 -2
- package/src/index.ts +7 -3
- package/src/lib/api-client.ts +446 -365
- package/src/lib/backend.ts +20 -10
- package/src/lib/diff.ts +28 -62
- package/src/lib/format-time.ts +20 -0
- package/src/lib/light-dark.ts +83 -0
- package/src/lib/mermaid-theme.ts +183 -214
- package/src/lib/passkeys.ts +12 -4
- package/src/lib/push-registration.ts +46 -0
- package/src/lib/share-intake.ts +6 -3
- package/src/lib/share.ts +7 -4
- package/src/lib/single-key.ts +47 -0
- package/src/lib/tool-names.ts +31 -8
- package/src/root-context.tsx +40 -0
- package/src/root.ts +83 -0
- package/src/stores/activity-state.ts +295 -0
- package/src/stores/activity-store.ts +11 -285
- package/src/stores/chat-state.ts +795 -0
- package/src/stores/chat-store.ts +11 -705
- package/src/stores/connection-state.ts +78 -0
- package/src/stores/connection-store.ts +11 -76
- package/src/stores/create-stores.ts +31 -0
- package/src/stores/file-state.ts +399 -0
- package/src/stores/file-store.ts +9 -360
- package/src/stores/graph-state.ts +368 -0
- package/src/stores/graph-store.ts +10 -355
- package/src/stores/mask-state.ts +30 -0
- package/src/stores/mask-store.ts +10 -27
- package/src/stores/principal-state.ts +42 -0
- package/src/stores/principal-store.ts +11 -0
- package/src/stores/provider-state.ts +103 -0
- package/src/stores/provider-store.ts +10 -95
- package/src/stores/share-state.ts +56 -0
- package/src/stores/share-store.ts +11 -54
- package/src/stores/store-environment.ts +10 -0
- package/src/stores/ui-state.ts +143 -0
- package/src/stores/ui-store.ts +11 -93
- package/src/styles.css +4 -1
- package/src/theme.css +150 -97
- package/src/voice/asr-clients.ts +17 -17
- package/src/voice/use-dictation.ts +11 -8
- package/src/voice/voice-state.ts +57 -0
- package/src/voice/voice-store.ts +11 -55
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultRoot } from "../default-root.js";
|
|
2
|
+
import { useBrainUiRoot } from "../root-context.js";
|
|
3
|
+
import type { BrainUiRoot } from "../root.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
2
5
|
import {
|
|
3
|
-
useConnectionStore,
|
|
4
6
|
type VpnStatus,
|
|
5
7
|
} from "../stores/connection-store.js";
|
|
6
|
-
import { getBackendUrl } from "../lib/backend.js";
|
|
7
8
|
|
|
8
9
|
const POLL_INTERVAL = 15_000;
|
|
9
10
|
// Tighter cadence while offline so recovery is near-immediate
|
|
10
11
|
const OFFLINE_POLL_INTERVAL = 3_000;
|
|
11
12
|
const TIMEOUT_MS = 5_000;
|
|
12
|
-
let activeRecheck: (() => void) | null = null;
|
|
13
13
|
|
|
14
|
-
async function fetchVpnStatus(): Promise<VpnStatus> {
|
|
14
|
+
async function fetchVpnStatus(root: BrainUiRoot): Promise<VpnStatus> {
|
|
15
15
|
const controller = new AbortController();
|
|
16
16
|
const timeout = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
17
17
|
try {
|
|
18
|
-
const res = await
|
|
18
|
+
const res = await root.request(root.backendUrl("/api/vpn-check"), {
|
|
19
19
|
signal: controller.signal,
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -35,10 +35,13 @@ async function fetchVpnStatus(): Promise<VpnStatus> {
|
|
|
35
35
|
* the only writer of vpnStatus and serializes this with its scheduled checks.
|
|
36
36
|
*/
|
|
37
37
|
export function recheckVpnStatus(): void {
|
|
38
|
-
|
|
38
|
+
defaultRoot.recheckVpn?.();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function useVpnStatus() {
|
|
42
|
+
const root = useBrainUiRoot();
|
|
43
|
+
const [successfulProbe, setSuccessfulProbe] = useState({ root, count: 0 });
|
|
44
|
+
|
|
42
45
|
useEffect(() => {
|
|
43
46
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
44
47
|
let inFlight = false;
|
|
@@ -52,18 +55,21 @@ export function useVpnStatus() {
|
|
|
52
55
|
return;
|
|
53
56
|
}
|
|
54
57
|
inFlight = true;
|
|
55
|
-
const opensAtStart =
|
|
58
|
+
const opensAtStart = root.stores.connection.getState().socketOpens;
|
|
56
59
|
try {
|
|
57
|
-
const status = await fetchVpnStatus();
|
|
60
|
+
const status = await fetchVpnStatus(root);
|
|
58
61
|
// A socket that reached `open` while this probe was in flight is newer
|
|
59
62
|
// reachability evidence than a failure the probe was started for.
|
|
60
63
|
// Counting opens rather than sampling wsStatus twice also catches a
|
|
61
64
|
// drop and a replacement open inside one probe, where both samples
|
|
62
65
|
// read "connected".
|
|
63
66
|
const socketOpenedDuringCheck =
|
|
64
|
-
|
|
67
|
+
root.stores.connection.getState().socketOpens !== opensAtStart;
|
|
65
68
|
if (!disposed && !(socketOpenedDuringCheck && status !== "connected")) {
|
|
66
|
-
|
|
69
|
+
root.stores.connection.getState().setVpnStatus(status);
|
|
70
|
+
if (status === "connected") {
|
|
71
|
+
setSuccessfulProbe((previous) => ({ root, count: previous.root === root ? previous.count + 1 : 1 }));
|
|
72
|
+
}
|
|
67
73
|
}
|
|
68
74
|
} finally {
|
|
69
75
|
inFlight = false;
|
|
@@ -73,7 +79,7 @@ export function useVpnStatus() {
|
|
|
73
79
|
recheckRequested = false;
|
|
74
80
|
void check();
|
|
75
81
|
} else {
|
|
76
|
-
const status =
|
|
82
|
+
const status = root.stores.connection.getState().vpnStatus;
|
|
77
83
|
// Auth required but no valid session is still a reachable server.
|
|
78
84
|
const reachable = status === "connected" || status === "unauthorized";
|
|
79
85
|
timer = setTimeout(
|
|
@@ -88,7 +94,7 @@ export function useVpnStatus() {
|
|
|
88
94
|
// Re-check immediately when the network returns or the PWA is foregrounded
|
|
89
95
|
// instead of waiting out the poll interval.
|
|
90
96
|
const recheckNow = () => void check();
|
|
91
|
-
|
|
97
|
+
const removeRecheck = root.registerVpnRecheck(recheckNow);
|
|
92
98
|
const onVisible = () => {
|
|
93
99
|
if (document.visibilityState === "visible") void check();
|
|
94
100
|
};
|
|
@@ -100,9 +106,11 @@ export function useVpnStatus() {
|
|
|
100
106
|
return () => {
|
|
101
107
|
disposed = true;
|
|
102
108
|
clearTimeout(timer);
|
|
103
|
-
|
|
109
|
+
removeRecheck();
|
|
104
110
|
window.removeEventListener("online", recheckNow);
|
|
105
111
|
document.removeEventListener("visibilitychange", onVisible);
|
|
106
112
|
};
|
|
107
|
-
}, []);
|
|
113
|
+
}, [root]);
|
|
114
|
+
|
|
115
|
+
return successfulProbe.root === root ? successfulProbe.count : 0;
|
|
108
116
|
}
|
|
@@ -1,432 +1,18 @@
|
|
|
1
|
-
import { useEffect,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "@schlessera/brain-ui-sdk/client";
|
|
6
|
-
import { useConnectionStore } from "../stores/connection-store.js";
|
|
7
|
-
import { useChatStore, activeChat, type ChatKey } from "../stores/chat-store.js";
|
|
8
|
-
import { useActivityStore, loadSessionActivityHistory } from "../stores/activity-store.js";
|
|
9
|
-
import { getWsUrl } from "../lib/backend.js";
|
|
10
|
-
import type {
|
|
11
|
-
ServerMessage,
|
|
12
|
-
ClientMessage,
|
|
13
|
-
ServerLocationRequest,
|
|
14
|
-
} from "@schlessera/brain-ui-sdk/protocol";
|
|
15
|
-
import { dispatchServerMessage } from "./websocket-handlers/index.js";
|
|
16
|
-
import { runStateForFrame } from "./websocket-handlers/chat.js";
|
|
17
|
-
import { recheckVpnStatus } from "./use-vpn-status.js";
|
|
18
|
-
import { REFUSAL_ATTEMPTS } from "../components/connectivity/connection-state.js";
|
|
19
|
-
|
|
1
|
+
import { useEffect, useCallback } from "react";
|
|
2
|
+
import type { ClientMessage, ServerMessage } from "@schlessera/brain-ui-sdk/protocol";
|
|
3
|
+
import { defaultRoot } from "../default-root.js";
|
|
4
|
+
import { useBrainUiRoot } from "../root-context.js";
|
|
20
5
|
export { runStateForFrame } from "./websocket-handlers/chat.js";
|
|
21
6
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* adopted whichever arrived first — an older background turn finishing, or
|
|
28
|
-
* another client's new session, would capture the user's draft and bind it to
|
|
29
|
-
* a transcript they never wrote. `draftId` is minted per draft turn and echoed
|
|
30
|
-
* on `session_info`, so a match is proof.
|
|
31
|
-
*
|
|
32
|
-
* A server too old to echo it sends no `draftId`, and the pre-existing
|
|
33
|
-
* behaviour applies rather than the draft never binding at all: correctness
|
|
34
|
-
* where the information exists, compatibility where it does not.
|
|
35
|
-
*/
|
|
36
|
-
function isOurDraftAnnouncement(
|
|
37
|
-
state: ReturnType<typeof useChatStore.getState>,
|
|
38
|
-
msg: ServerMessage
|
|
39
|
-
): boolean {
|
|
40
|
-
if (msg.type !== "session_info" && msg.type !== "result") return false;
|
|
41
|
-
const pending = state.pendingDraftId;
|
|
42
|
-
if (msg.type === "session_info" && msg.draftId) return msg.draftId === pending;
|
|
43
|
-
// No echo to compare against.
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Lazily open a session-scoped activity subscription (live subagent rows,
|
|
49
|
-
* server-stamped tool timing). Idempotent per connection; the subscribed set
|
|
50
|
-
* resets when a new socket's server_hello arrives.
|
|
51
|
-
*/
|
|
52
|
-
function ensureActivitySubscription(sessionId: string | null | undefined): void {
|
|
53
|
-
if (!sessionId) return;
|
|
54
|
-
const activity = useActivityStore.getState();
|
|
55
|
-
if (!activity.supported || activity.subscribed[sessionId]) return;
|
|
56
|
-
activity.markSubscribed(sessionId);
|
|
57
|
-
wsClient?.send({ type: "activity_subscribe", view: "session", sessionId });
|
|
58
|
-
// The subscription snapshot carries OPEN runs; finished runs (history
|
|
59
|
-
// timing, past fan-outs) come from the REST side.
|
|
60
|
-
void loadSessionActivityHistory(sessionId);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Text and thinking deltas waiting to be applied, per buffer.
|
|
65
|
-
*
|
|
66
|
-
* A model streams tokens far faster than the display refreshes, and each socket
|
|
67
|
-
* frame arrives in its own macrotask, so React cannot batch them: one token was
|
|
68
|
-
* one store write, one render and one markdown re-parse of the growing message.
|
|
69
|
-
* Coalescing a frame's worth of tokens into a single write costs nothing
|
|
70
|
-
* visually — the screen could not have shown the intermediate states anyway.
|
|
71
|
-
*
|
|
72
|
-
* Consecutive same-kind chunks merge, so a burst of text becomes ONE appendText
|
|
73
|
-
* rather than one per token. Kind changes start a new chunk, which is what keeps
|
|
74
|
-
* interleaved thinking and text in their true chronological order.
|
|
75
|
-
*/
|
|
76
|
-
type PendingDelta = { kind: "text" | "thinking"; text: string };
|
|
77
|
-
const pendingDeltas = new Map<ChatKey, PendingDelta[]>();
|
|
78
|
-
let flushScheduled = false;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Apply every buffered delta, in arrival order, and clear the buffer.
|
|
82
|
-
*
|
|
83
|
-
* Exported so tests can force the frame rather than wait for one; production
|
|
84
|
-
* code never needs to call it, because every path that reads the transcript
|
|
85
|
-
* flushes first.
|
|
86
|
-
*/
|
|
87
|
-
export function flushChatDeltas(): void {
|
|
88
|
-
flushDeltas();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function flushDeltas(): void {
|
|
92
|
-
flushScheduled = false;
|
|
93
|
-
if (pendingDeltas.size === 0) return;
|
|
94
|
-
const batches = [...pendingDeltas.entries()];
|
|
95
|
-
pendingDeltas.clear();
|
|
96
|
-
const state = useChatStore.getState();
|
|
97
|
-
for (const [key, chunks] of batches) {
|
|
98
|
-
for (const chunk of chunks) {
|
|
99
|
-
if (chunk.kind === "text") state.appendText(key, chunk.text);
|
|
100
|
-
else state.appendThinking(key, chunk.text);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function enqueueDelta(key: ChatKey, kind: PendingDelta["kind"], text: string): void {
|
|
106
|
-
const chunks = pendingDeltas.get(key);
|
|
107
|
-
if (!chunks) {
|
|
108
|
-
pendingDeltas.set(key, [{ kind, text }]);
|
|
109
|
-
} else {
|
|
110
|
-
const last = chunks[chunks.length - 1];
|
|
111
|
-
if (last.kind === kind) last.text += text;
|
|
112
|
-
else chunks.push({ kind, text });
|
|
113
|
-
}
|
|
114
|
-
// Outside a browser (unit tests, SSR) there is no frame to wait for, so apply
|
|
115
|
-
// straight away and keep the handler's behaviour synchronous.
|
|
116
|
-
if (typeof requestAnimationFrame !== "function") {
|
|
117
|
-
flushDeltas();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (!flushScheduled) {
|
|
121
|
-
flushScheduled = true;
|
|
122
|
-
requestAnimationFrame(flushDeltas);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function handleServerMessage(msg: ServerMessage) {
|
|
127
|
-
// Every frame that is not itself a delta must see the transcript fully
|
|
128
|
-
// applied: the demux below reads buffer state, and the store records parts in
|
|
129
|
-
// arrival order, so a tool call landing ahead of buffered text would reorder
|
|
130
|
-
// the message.
|
|
131
|
-
if (msg.type !== "text_delta" && msg.type !== "thinking_delta") flushDeltas();
|
|
132
|
-
|
|
133
|
-
const state = useChatStore.getState();
|
|
134
|
-
|
|
135
|
-
// Activity stream frames feed their own store and never touch chat state.
|
|
136
|
-
if (
|
|
137
|
-
msg.type === "server_hello" ||
|
|
138
|
-
msg.type === "activity_snapshot" ||
|
|
139
|
-
msg.type === "activity_delta"
|
|
140
|
-
) {
|
|
141
|
-
const key = state.activeSessionId;
|
|
142
|
-
dispatchServerMessage(msg, {
|
|
143
|
-
state,
|
|
144
|
-
frameSessionId: undefined,
|
|
145
|
-
key,
|
|
146
|
-
buffer: () => (key === null ? state.draft : state.buffers[key]),
|
|
147
|
-
enqueueDelta,
|
|
148
|
-
ensureActivitySubscription,
|
|
149
|
-
requestBrowserLocation,
|
|
150
|
-
resyncIfNeeded,
|
|
151
|
-
coldResumeIfNeeded,
|
|
152
|
-
markHistoryReplaced,
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Parallel-session demux (per-session buffers). Every frame is scoped by
|
|
158
|
-
// sessionId; a scoped frame lands in ITS session's buffer, so a background
|
|
159
|
-
// session's transcript keeps accumulating while another one is in view.
|
|
160
|
-
// Frames without a sessionId (legacy single-session servers, or a new
|
|
161
|
-
// session's pre-binding frames) apply to the buffer in view.
|
|
162
|
-
const frameSessionId = (msg as { sessionId?: string }).sessionId;
|
|
163
|
-
if (frameSessionId) {
|
|
164
|
-
// `detail` on a queued status is the host's queue-pressure note; it rides
|
|
165
|
-
// along so the session's badge can show WHY it is queued deep.
|
|
166
|
-
const queueNote =
|
|
167
|
-
msg.type === "status" && msg.status === "queued" ? msg.detail : undefined;
|
|
168
|
-
state.setRunState(frameSessionId, runStateForFrame(msg), queueNote);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Resolve the target buffer key for this frame.
|
|
172
|
-
let key: ChatKey;
|
|
173
|
-
if (!frameSessionId) {
|
|
174
|
-
key = state.activeSessionId; // null = the draft view
|
|
175
|
-
} else if (state.buffers[frameSessionId]) {
|
|
176
|
-
key = frameSessionId;
|
|
177
|
-
} else if (state.draft && isOurDraftAnnouncement(state, msg)) {
|
|
178
|
-
// A draft run just got its server identity: adopt the draft buffer.
|
|
179
|
-
state.bindDraftSession(frameSessionId);
|
|
180
|
-
key = frameSessionId;
|
|
181
|
-
} else if (msg.type === "session_info" && frameSessionId === state.activeSessionId) {
|
|
182
|
-
// The ACTIVE session announced itself but has no buffer yet — the cold
|
|
183
|
-
// reattach case (PWA relaunch mid-turn; the server may skip the history
|
|
184
|
-
// frame when a first turn has no history yet). Materialize the buffer so
|
|
185
|
-
// this session_info and every following delta land instead of vanishing.
|
|
186
|
-
state.setActiveSession(frameSessionId);
|
|
187
|
-
key = frameSessionId;
|
|
188
|
-
} else if (msg.type === "session_history") {
|
|
189
|
-
// History replay may create a buffer (cold resume / reattach).
|
|
190
|
-
key = frameSessionId;
|
|
191
|
-
} else {
|
|
192
|
-
// Scoped frame for a session with no buffer (never opened, or evicted):
|
|
193
|
-
// the badge above is all we track. The transcript heals via
|
|
194
|
-
// session_resume when the user opens it.
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const buffer = () => {
|
|
199
|
-
const s = useChatStore.getState();
|
|
200
|
-
return key === null ? s.draft : s.buffers[key];
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
dispatchServerMessage(msg, {
|
|
204
|
-
state,
|
|
205
|
-
frameSessionId,
|
|
206
|
-
key,
|
|
207
|
-
buffer,
|
|
208
|
-
enqueueDelta,
|
|
209
|
-
ensureActivitySubscription,
|
|
210
|
-
requestBrowserLocation,
|
|
211
|
-
resyncIfNeeded,
|
|
212
|
-
coldResumeIfNeeded,
|
|
213
|
-
markHistoryReplaced,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* The server asked the browser for its location (the agent called
|
|
219
|
-
* `get_current_location`). Read `navigator.geolocation` and reply over the same
|
|
220
|
-
* requestId. The browser shows its own permission prompt on first use; a denial,
|
|
221
|
-
* timeout, or unavailable position comes back as a `location_error` that the
|
|
222
|
-
* server turns into a tool error for the agent.
|
|
223
|
-
*/
|
|
224
|
-
function requestBrowserLocation(msg: ServerLocationRequest) {
|
|
225
|
-
const { requestId } = msg;
|
|
226
|
-
if (typeof navigator === "undefined" || !navigator.geolocation) {
|
|
227
|
-
wsClient?.send({
|
|
228
|
-
type: "location_error",
|
|
229
|
-
requestId,
|
|
230
|
-
code: 0,
|
|
231
|
-
message: "Geolocation is not available in this browser.",
|
|
232
|
-
});
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const opts = msg.options ?? {};
|
|
236
|
-
navigator.geolocation.getCurrentPosition(
|
|
237
|
-
(pos) => {
|
|
238
|
-
wsClient?.send({
|
|
239
|
-
type: "location_response",
|
|
240
|
-
requestId,
|
|
241
|
-
coords: {
|
|
242
|
-
latitude: pos.coords.latitude,
|
|
243
|
-
longitude: pos.coords.longitude,
|
|
244
|
-
accuracy: pos.coords.accuracy,
|
|
245
|
-
altitude: pos.coords.altitude,
|
|
246
|
-
altitudeAccuracy: pos.coords.altitudeAccuracy,
|
|
247
|
-
heading: pos.coords.heading,
|
|
248
|
-
speed: pos.coords.speed,
|
|
249
|
-
},
|
|
250
|
-
timestamp: pos.timestamp,
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
(err) => {
|
|
254
|
-
wsClient?.send({
|
|
255
|
-
type: "location_error",
|
|
256
|
-
requestId,
|
|
257
|
-
code: err.code,
|
|
258
|
-
message: err.message || "Failed to retrieve location.",
|
|
259
|
-
});
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
enableHighAccuracy: opts.enableHighAccuracy ?? false,
|
|
263
|
-
timeout: opts.timeoutMs ?? 15000,
|
|
264
|
-
maximumAge: opts.maximumAgeMs ?? 60000,
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Reconnection bookkeeping: after a WS drop, the rendered transcript may have
|
|
270
|
-
// gaps (deltas streamed while offline are lost). We heal by replaying the
|
|
271
|
-
// authoritative session history — immediately if nothing is streaming, or
|
|
272
|
-
// once the in-flight turn settles (result / idle status). The pending resync
|
|
273
|
-
// is keyed to the session that needs healing (the one that was active at the
|
|
274
|
-
// reconnect), so a background session settling first cannot consume it.
|
|
275
|
-
let wasDisconnected = false;
|
|
276
|
-
let resyncSessionId: string | null = null;
|
|
277
|
-
|
|
278
|
-
function handleSocketClose(close: WebSocketClose): void {
|
|
279
|
-
const connection = useConnectionStore.getState();
|
|
280
|
-
connection.recordWsClose(close.opened, close.code);
|
|
281
|
-
if (
|
|
282
|
-
!close.opened &&
|
|
283
|
-
useConnectionStore.getState().handshakeFailures >= REFUSAL_ATTEMPTS
|
|
284
|
-
) {
|
|
285
|
-
recheckVpnStatus();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function resyncIfNeeded(sessionId: string | null) {
|
|
290
|
-
if (!resyncSessionId || !sessionId || sessionId !== resyncSessionId) return;
|
|
291
|
-
resyncSessionId = null;
|
|
292
|
-
wsClient?.send({ type: "session_resume", sessionId });
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// A cold page / PWA relaunch restores only the stored session id, not the
|
|
296
|
-
// transcript. The server pushes a snapshot on connect only while a session is
|
|
297
|
-
// actively running; when it's idle (the common "agent finished while the phone
|
|
298
|
-
// slept" case) nothing arrives, so the client must fetch the finished
|
|
299
|
-
// session's history itself. Guarded to fire at most once per session id per
|
|
300
|
-
// connection — an empty session would otherwise re-trigger on every idle
|
|
301
|
-
// status and loop.
|
|
302
|
-
let coldResumedSessionId: string | null = null;
|
|
303
|
-
|
|
304
|
-
function markHistoryReplaced(key: ChatKey): void {
|
|
305
|
-
if (key !== null && key === resyncSessionId) resyncSessionId = null;
|
|
306
|
-
coldResumedSessionId = key;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function coldResumeIfNeeded(sessionId: string | null, messageCount: number) {
|
|
310
|
-
if (!sessionId || messageCount > 0) return;
|
|
311
|
-
if (coldResumedSessionId === sessionId) return;
|
|
312
|
-
coldResumedSessionId = sessionId;
|
|
313
|
-
wsClient?.send({ type: "session_resume", sessionId });
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function handleStatusChange(status: "connecting" | "connected" | "disconnected") {
|
|
317
|
-
useConnectionStore.getState().setWsStatus(status);
|
|
318
|
-
|
|
319
|
-
if (status === "connected") {
|
|
320
|
-
useConnectionStore.getState().noteSocketOpen();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// A status change can be followed by a history replay that rewrites the
|
|
324
|
-
// buffer, so land whatever is still buffered before anything reads it. In a
|
|
325
|
-
// hidden tab requestAnimationFrame does not run at all, which is exactly the
|
|
326
|
-
// case where deltas could otherwise sit unapplied across a reconnect.
|
|
327
|
-
flushDeltas();
|
|
328
|
-
|
|
329
|
-
if (status === "disconnected") {
|
|
330
|
-
wasDisconnected = true;
|
|
331
|
-
// Allow a fresh cold-resume attempt after we reconnect.
|
|
332
|
-
coldResumedSessionId = null;
|
|
333
|
-
} else if (status === "connected" && wasDisconnected) {
|
|
334
|
-
wasDisconnected = false;
|
|
335
|
-
const chat = useChatStore.getState();
|
|
336
|
-
const active = activeChat(chat);
|
|
337
|
-
if (chat.activeSessionId && active.messages.length > 0) {
|
|
338
|
-
resyncSessionId = chat.activeSessionId;
|
|
339
|
-
// Not mid-stream: replay right away. Mid-stream: the flag holds until
|
|
340
|
-
// the running turn finishes (result or idle status).
|
|
341
|
-
if (!active.isStreaming) {
|
|
342
|
-
resyncIfNeeded(chat.activeSessionId);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Singleton client - survives React re-renders
|
|
349
|
-
let wsClient: BrainUiClient | null = null;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Send on the live socket from outside a component.
|
|
353
|
-
*
|
|
354
|
-
* `useWebSocket()` OWNS the socket — its construction guard is a per-instance
|
|
355
|
-
* ref, so a second caller would build a second client, overwrite this
|
|
356
|
-
* singleton, and orphan the first; unmounting either one would then close the
|
|
357
|
-
* socket for both. Anything that needs to send but not to own (the share
|
|
358
|
-
* intake) goes through here instead of calling the hook again.
|
|
359
|
-
*
|
|
360
|
-
* Returns false when there is no open socket: `send` drops silently in that
|
|
361
|
-
* case and a caller that just staged an upload needs to know.
|
|
362
|
-
*/
|
|
363
|
-
export function sendClientMessage(msg: ClientMessage): boolean {
|
|
364
|
-
if (!wsClient) return false;
|
|
365
|
-
if (useConnectionStore.getState().wsStatus !== "connected") return false;
|
|
366
|
-
wsClient.send(msg);
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/** Retry the singleton socket immediately, skipping any remaining backoff. */
|
|
371
|
-
export function reconnectWebSocketNow(): void {
|
|
372
|
-
wsClient?.reconnectNow();
|
|
373
|
-
}
|
|
7
|
+
/** Default-app entry points for callers outside React. */
|
|
8
|
+
export function handleServerMessage(message: ServerMessage) { defaultRoot.connection.handleServerMessage(message); }
|
|
9
|
+
export function flushChatDeltas() { defaultRoot.connection.flushChatDeltas(); }
|
|
10
|
+
export function sendClientMessage(message: ClientMessage) { return defaultRoot.connection.send(message); }
|
|
11
|
+
export function reconnectWebSocketNow() { defaultRoot.connection.reconnectNow(); }
|
|
374
12
|
|
|
375
13
|
export function useWebSocket() {
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (initialized.current) return;
|
|
380
|
-
initialized.current = true;
|
|
381
|
-
let disposed = false;
|
|
382
|
-
useConnectionStore.getState().noteSocketOpen();
|
|
383
|
-
|
|
384
|
-
wsClient = new BrainUiClient({
|
|
385
|
-
url: getWsUrl(),
|
|
386
|
-
// One handler with a shared preamble, rather than sixteen copies of the
|
|
387
|
-
// session-buffer demux — see handleServerMessage.
|
|
388
|
-
handlers: { onAny: handleServerMessage },
|
|
389
|
-
onStatusChange: handleStatusChange,
|
|
390
|
-
onClose: (close) => {
|
|
391
|
-
if (!disposed) handleSocketClose(close);
|
|
392
|
-
},
|
|
393
|
-
// A frame the SDK refused. Surfaced rather than logged into a console
|
|
394
|
-
// nobody is attached to; the server-side counterpart is the
|
|
395
|
-
// ws.frames.dropped counter.
|
|
396
|
-
onProtocolError: (err) => {
|
|
397
|
-
useConnectionStore
|
|
398
|
-
.getState()
|
|
399
|
-
.reportError(
|
|
400
|
-
"PROTOCOL_ERROR",
|
|
401
|
-
err.frameType
|
|
402
|
-
? `Dropped a ${err.frameType} frame: ${err.detail}`
|
|
403
|
-
: `Dropped an unreadable frame: ${err.detail}`
|
|
404
|
-
);
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
wsClient.connect();
|
|
408
|
-
|
|
409
|
-
// Skip the exponential backoff when the network demonstrably returns.
|
|
410
|
-
const reconnectNow = () => wsClient?.reconnectNow();
|
|
411
|
-
const onVisible = () => {
|
|
412
|
-
if (document.visibilityState === "visible") wsClient?.reconnectNow();
|
|
413
|
-
};
|
|
414
|
-
window.addEventListener("online", reconnectNow);
|
|
415
|
-
document.addEventListener("visibilitychange", onVisible);
|
|
416
|
-
|
|
417
|
-
return () => {
|
|
418
|
-
disposed = true;
|
|
419
|
-
window.removeEventListener("online", reconnectNow);
|
|
420
|
-
document.removeEventListener("visibilitychange", onVisible);
|
|
421
|
-
wsClient?.close();
|
|
422
|
-
wsClient = null;
|
|
423
|
-
initialized.current = false;
|
|
424
|
-
};
|
|
425
|
-
}, []);
|
|
426
|
-
|
|
427
|
-
const send = useCallback((msg: ClientMessage) => {
|
|
428
|
-
wsClient?.send(msg);
|
|
429
|
-
}, []);
|
|
430
|
-
|
|
14
|
+
const root = useBrainUiRoot();
|
|
15
|
+
useEffect(() => root.connection.connect(), [root]);
|
|
16
|
+
const send = useCallback((message: ClientMessage) => root.connection.send(message), [root]);
|
|
431
17
|
return { send };
|
|
432
18
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useActivityStore } from "../../stores/activity-store.js";
|
|
2
1
|
import type { ServerMessageHandlerMap } from "./types.js";
|
|
3
2
|
|
|
4
3
|
type ActivityFrame = "activity_snapshot" | "activity_delta";
|
|
5
4
|
|
|
6
5
|
export const activityFrameHandlers = {
|
|
7
|
-
activity_snapshot: (msg) => {
|
|
8
|
-
|
|
6
|
+
activity_snapshot: (msg, context) => {
|
|
7
|
+
context.stores.activity.getState().applySnapshot(msg);
|
|
9
8
|
},
|
|
10
|
-
activity_delta: (msg) => {
|
|
11
|
-
|
|
9
|
+
activity_delta: (msg, context) => {
|
|
10
|
+
context.stores.activity.getState().applyDelta(msg);
|
|
12
11
|
},
|
|
13
12
|
} satisfies ServerMessageHandlerMap<ActivityFrame>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activeChat
|
|
1
|
+
import { activeChat } from "../../stores/chat-state.js";
|
|
2
2
|
import type { ChatMessage, ToolCall, AskUserExchange } from "../../stores/chat-store.js";
|
|
3
3
|
import type {
|
|
4
4
|
AskUserQuestion,
|
|
@@ -18,6 +18,7 @@ type ChatFrame =
|
|
|
18
18
|
| "tool_result"
|
|
19
19
|
| "ask_user_request"
|
|
20
20
|
| "result"
|
|
21
|
+
| "message_blocks"
|
|
21
22
|
| "session_history"
|
|
22
23
|
| "status";
|
|
23
24
|
|
|
@@ -56,10 +57,20 @@ function convertHistoryMessage(msg: SessionHistoryMessage): ChatMessage {
|
|
|
56
57
|
timestamp: Date.now(),
|
|
57
58
|
...(askUserExchanges ? { askUserExchanges } : {}),
|
|
58
59
|
...(msg.attachmentCount ? { attachmentCount: msg.attachmentCount } : {}),
|
|
60
|
+
...(msg.blocks && msg.blocks.length > 0 ? { blocks: msg.blocks } : {}),
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Rebuild ask_user exchanges from a resumed message's tool calls.
|
|
66
|
+
*
|
|
67
|
+
* The persisted tool output is `{answers, annotations}` (Claude) or the bare
|
|
68
|
+
* answers map (pi). Neither carries whether the answer was chosen from the
|
|
69
|
+
* options or typed into the composer (`AskUserExchange.typed`), nor when it
|
|
70
|
+
* was given, so a resumed exchange comes back as a plain `answered` one with
|
|
71
|
+
* no time. Carrying `typed` would mean widening the `ask_user` response —
|
|
72
|
+
* a `CONTRACT:` change — not guessing here.
|
|
73
|
+
*/
|
|
63
74
|
function isBareAnswersMap(v: unknown): v is Record<string, string> {
|
|
64
75
|
return (
|
|
65
76
|
!!v &&
|
|
@@ -117,14 +128,16 @@ export const chatFrameHandlers = {
|
|
|
117
128
|
// Opening the bubble stays immediate — the first token should show a
|
|
118
129
|
// message starting, and every later delta needs isStreaming to be true.
|
|
119
130
|
if (!context.buffer()?.isStreaming) {
|
|
120
|
-
context.state.startAssistantMessage(context.key);
|
|
131
|
+
context.state.startAssistantMessage(context.key, context.frameTurnId);
|
|
121
132
|
}
|
|
133
|
+
if (context.frameTurnId) context.state.stampTurn(context.key, context.frameTurnId);
|
|
122
134
|
context.enqueueDelta(context.key, "text", msg.text);
|
|
123
135
|
},
|
|
124
136
|
thinking_delta: (msg, context) => {
|
|
125
137
|
if (!context.buffer()?.isStreaming) {
|
|
126
|
-
context.state.startAssistantMessage(context.key);
|
|
138
|
+
context.state.startAssistantMessage(context.key, context.frameTurnId);
|
|
127
139
|
}
|
|
140
|
+
if (context.frameTurnId) context.state.stampTurn(context.key, context.frameTurnId);
|
|
128
141
|
context.enqueueDelta(context.key, "thinking", msg.text);
|
|
129
142
|
},
|
|
130
143
|
tool_use_start: (msg, context) => {
|
|
@@ -169,6 +182,14 @@ export const chatFrameHandlers = {
|
|
|
169
182
|
context.state.finishAssistantMessage(context.key);
|
|
170
183
|
context.resyncIfNeeded(msg.sessionId);
|
|
171
184
|
},
|
|
185
|
+
message_blocks: (msg, context) => {
|
|
186
|
+
// Arrives after `result`, for the turn's own assistant message. An
|
|
187
|
+
// answer never waits on it: the markdown is already on screen, and this
|
|
188
|
+
// only says which spans to draw as blocks (D42). Targeted by the turn
|
|
189
|
+
// the frame belongs to: a queued follow-up may already have opened a
|
|
190
|
+
// newer assistant message by the time the pass returns.
|
|
191
|
+
context.state.setMessageBlocks(context.key, msg.blocks, context.frameTurnId);
|
|
192
|
+
},
|
|
172
193
|
session_history: (msg, context) => {
|
|
173
194
|
const converted = msg.messages.map(convertHistoryMessage);
|
|
174
195
|
if (msg.append) {
|
|
@@ -194,7 +215,7 @@ export const chatFrameHandlers = {
|
|
|
194
215
|
// THIS frame's session: a background session settling must not consume
|
|
195
216
|
// (or trigger) the active session's pending resync.
|
|
196
217
|
if (msg.status === "idle" || msg.status === "cancelled") {
|
|
197
|
-
const current =
|
|
218
|
+
const current = context.stores.chat.getState();
|
|
198
219
|
context.resyncIfNeeded(context.frameSessionId ?? current.activeSessionId);
|
|
199
220
|
// Cold load: we hold a stored session id but an empty transcript and
|
|
200
221
|
// the server is idle (so it sent no snapshot). Fetch the history.
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { useActivityStore } from "../../stores/activity-store.js";
|
|
2
|
-
import { useConnectionStore } from "../../stores/connection-store.js";
|
|
3
1
|
import type { ServerMessageHandlerMap } from "./types.js";
|
|
4
2
|
|
|
5
3
|
type ConnectionFrame = "server_hello" | "location_request" | "error";
|
|
6
4
|
|
|
7
5
|
export const connectionFrameHandlers = {
|
|
8
6
|
server_hello: (msg, context) => {
|
|
9
|
-
|
|
7
|
+
context.stores.activity.getState().setSupported(msg.capabilities?.activity === true);
|
|
10
8
|
// A new hello means a new connection: server-side subscriptions are gone.
|
|
11
|
-
|
|
9
|
+
context.stores.activity.getState().resetSubscriptions();
|
|
12
10
|
// …and view-owned subscriptions (the Activity index) must re-send too.
|
|
13
|
-
|
|
11
|
+
context.stores.activity.getState().bumpConnectionEpoch();
|
|
14
12
|
context.ensureActivitySubscription(context.state.activeSessionId);
|
|
15
13
|
},
|
|
16
14
|
location_request: (msg, context) => {
|
|
@@ -21,7 +19,7 @@ export const connectionFrameHandlers = {
|
|
|
21
19
|
// message is streaming, and this used to be the whole handler — so an
|
|
22
20
|
// error arriving between turns (a rejected frame, a failed resume) was
|
|
23
21
|
// dropped as silently on the client as it was on the server.
|
|
24
|
-
|
|
22
|
+
context.stores.connection.getState().reportError(msg.code, msg.message);
|
|
25
23
|
if (context.buffer()?.isStreaming) {
|
|
26
24
|
context.state.appendText(context.key, `\n\n**Error:** ${msg.message}`);
|
|
27
25
|
context.state.finishAssistantMessage(context.key);
|