@schlessera/brain-ui-react 0.35.0 → 0.37.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 +82 -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 +148 -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 +29 -0
- package/dist/components/activity/approval-card.d.ts.map +1 -0
- package/dist/components/activity/approval-card.js +73 -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 +11 -0
- package/dist/components/activity/span-bits.d.ts.map +1 -1
- package/dist/components/activity/span-bits.js +50 -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 +27 -11
- 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 +32 -32
- 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 +45 -14
- 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 +19 -2
- package/dist/components/chat/tool-views.d.ts.map +1 -1
- package/dist/components/chat/tool-views.js +28 -22
- 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 +27 -21
- 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 +4 -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 +28 -0
- package/dist/components/layout/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail.js +72 -27
- package/dist/components/layout/side-rail.js.map +1 -1
- package/dist/components/layout/slide-panel.d.ts +25 -2
- package/dist/components/layout/slide-panel.d.ts.map +1 -1
- package/dist/components/layout/slide-panel.js +13 -4
- 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 +32 -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 +23 -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 +8 -5
- 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 +53 -18
- 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 +51 -10
- package/dist/components/quick-actions/whatsup-modal.js.map +1 -1
- package/dist/components/settings/devices-agents-tab.d.ts +6 -1
- package/dist/components/settings/devices-agents-tab.d.ts.map +1 -1
- package/dist/components/settings/devices-agents-tab.js +55 -20
- package/dist/components/settings/devices-agents-tab.js.map +1 -1
- 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.js +1 -1
- package/dist/components/settings/one-time-agent-credential.js.map +1 -1
- 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 +71 -10
- 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-fine-pointer.d.ts +12 -0
- package/dist/hooks/use-fine-pointer.d.ts.map +1 -0
- package/dist/hooks/use-fine-pointer.js +15 -0
- package/dist/hooks/use-fine-pointer.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 +9 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +38 -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.map +1 -1
- package/dist/hooks/use-vpn-status.js +17 -18
- 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 -384
- 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 +28 -6
- 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 +289 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +243 -224
- 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/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 +4 -1
- package/dist/lib/push-registration.d.ts.map +1 -1
- package/dist/lib/push-registration.js +20 -2
- package/dist/lib/push-registration.js.map +1 -1
- 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 +233 -0
- package/dist/stores/chat-state.d.ts.map +1 -0
- package/dist/stores/chat-state.js +477 -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 -336
- 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 +4 -15
- package/dist/stores/principal-store.d.ts.map +1 -1
- package/dist/stores/principal-store.js +7 -28
- package/dist/stores/principal-store.js.map +1 -1
- 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 +341 -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 +117 -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 +60 -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 +41 -11
- 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 +41 -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 +75 -26
- 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 +30 -60
- 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 +32 -24
- 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 +5 -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 +77 -150
- package/src/components/layout/slide-panel.tsx +49 -6
- package/src/components/layout/theme.tsx +67 -0
- package/src/components/quick-actions/add-form.tsx +196 -0
- package/src/components/quick-actions/add-modal.tsx +32 -153
- package/src/components/quick-actions/search-modal.tsx +15 -5
- package/src/components/quick-actions/streaming-modal.tsx +57 -72
- package/src/components/quick-actions/streaming-output.tsx +112 -0
- package/src/components/quick-actions/whatsup-modal.tsx +53 -59
- package/src/components/settings/devices-agents-tab.tsx +60 -152
- 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 +1 -1
- 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 +239 -25
- 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-fine-pointer.ts +15 -0
- package/src/hooks/use-hash-routes.ts +4 -2
- package/src/hooks/use-media-query.ts +35 -0
- package/src/hooks/use-share-intake.ts +32 -12
- package/src/hooks/use-vpn-status.ts +18 -17
- package/src/hooks/use-websocket.ts +12 -428
- package/src/hooks/websocket-handlers/activity.ts +4 -5
- package/src/hooks/websocket-handlers/chat.ts +28 -6
- 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 +426 -384
- package/src/lib/backend.ts +20 -10
- package/src/lib/diff.ts +28 -62
- 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 +19 -2
- 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 +822 -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 -390
- 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 +10 -37
- 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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createStore } from "zustand/vanilla";
|
|
2
|
+
|
|
3
|
+
export type WsStatus = "connecting" | "connected" | "disconnected";
|
|
4
|
+
export type VpnStatus =
|
|
5
|
+
| "connected"
|
|
6
|
+
| "forbidden"
|
|
7
|
+
| "unauthorized"
|
|
8
|
+
| "unreachable"
|
|
9
|
+
| "checking";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The last thing that went wrong, whether or not a turn was running.
|
|
13
|
+
*
|
|
14
|
+
* Before this existed, a `error` frame was only surfaced when a message was
|
|
15
|
+
* mid-stream: it was appended to the streaming transcript, and outside a turn
|
|
16
|
+
* it went nowhere at all — no console, no store, no UI. A PARSE_ERROR between
|
|
17
|
+
* turns was dropped on the client as silently as it was on the server.
|
|
18
|
+
* Protocol-level drops from the SDK client land here too.
|
|
19
|
+
*/
|
|
20
|
+
export interface ConnectionError {
|
|
21
|
+
code: string;
|
|
22
|
+
message: string;
|
|
23
|
+
/** Epoch millis, so a view can decide whether this is still interesting. */
|
|
24
|
+
at: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ConnectionState {
|
|
28
|
+
wsStatus: WsStatus;
|
|
29
|
+
vpnStatus: VpnStatus;
|
|
30
|
+
handshakeFailures: number;
|
|
31
|
+
lastCloseCode: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Monotonic count of sockets that reached `open`. A probe started before a
|
|
34
|
+
* socket opened compares this to decide whether its answer is still the
|
|
35
|
+
* newest evidence — comparing wsStatus twice cannot see a drop and a
|
|
36
|
+
* replacement open that both land inside one probe.
|
|
37
|
+
*/
|
|
38
|
+
socketOpens: number;
|
|
39
|
+
lastError: ConnectionError | null;
|
|
40
|
+
setWsStatus: (status: WsStatus) => void;
|
|
41
|
+
setVpnStatus: (status: VpnStatus) => void;
|
|
42
|
+
recordWsClose: (opened: boolean, code: number) => void;
|
|
43
|
+
/** A socket reached `open`: the refusal evidence so far is spent. */
|
|
44
|
+
noteSocketOpen: () => void;
|
|
45
|
+
reportError: (code: string, message: string) => void;
|
|
46
|
+
clearError: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function createConnectionStore() {
|
|
50
|
+
return createStore<ConnectionState>((set) => ({
|
|
51
|
+
wsStatus: "disconnected",
|
|
52
|
+
vpnStatus: "checking",
|
|
53
|
+
handshakeFailures: 0,
|
|
54
|
+
lastCloseCode: null,
|
|
55
|
+
socketOpens: 0,
|
|
56
|
+
lastError: null,
|
|
57
|
+
setWsStatus: (wsStatus) => set({ wsStatus }),
|
|
58
|
+
setVpnStatus: (vpnStatus) => set({ vpnStatus }),
|
|
59
|
+
recordWsClose: (opened, lastCloseCode) =>
|
|
60
|
+
set((state) => ({
|
|
61
|
+
lastCloseCode,
|
|
62
|
+
handshakeFailures: opened
|
|
63
|
+
? state.handshakeFailures
|
|
64
|
+
: state.handshakeFailures + 1,
|
|
65
|
+
})),
|
|
66
|
+
noteSocketOpen: () =>
|
|
67
|
+
set((state) => ({
|
|
68
|
+
handshakeFailures: 0,
|
|
69
|
+
// Cleared here, not on the next close: the server accepts the upgrade and
|
|
70
|
+
// THEN closes with 4008 when it is at its connection cap, so the code
|
|
71
|
+
// must survive an open to be read, and must not outlive the next one.
|
|
72
|
+
lastCloseCode: null,
|
|
73
|
+
socketOpens: state.socketOpens + 1,
|
|
74
|
+
})),
|
|
75
|
+
reportError: (code, message) => set({ lastError: { code, message, at: Date.now() } }),
|
|
76
|
+
clearError: () => set({ lastError: null }),
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
@@ -1,76 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* The last thing that went wrong, whether or not a turn was running.
|
|
13
|
-
*
|
|
14
|
-
* Before this existed, a `error` frame was only surfaced when a message was
|
|
15
|
-
* mid-stream: it was appended to the streaming transcript, and outside a turn
|
|
16
|
-
* it went nowhere at all — no console, no store, no UI. A PARSE_ERROR between
|
|
17
|
-
* turns was dropped on the client as silently as it was on the server.
|
|
18
|
-
* Protocol-level drops from the SDK client land here too.
|
|
19
|
-
*/
|
|
20
|
-
export interface ConnectionError {
|
|
21
|
-
code: string;
|
|
22
|
-
message: string;
|
|
23
|
-
/** Epoch millis, so a view can decide whether this is still interesting. */
|
|
24
|
-
at: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface ConnectionState {
|
|
28
|
-
wsStatus: WsStatus;
|
|
29
|
-
vpnStatus: VpnStatus;
|
|
30
|
-
handshakeFailures: number;
|
|
31
|
-
lastCloseCode: number | null;
|
|
32
|
-
/**
|
|
33
|
-
* Monotonic count of sockets that reached `open`. A probe started before a
|
|
34
|
-
* socket opened compares this to decide whether its answer is still the
|
|
35
|
-
* newest evidence — comparing wsStatus twice cannot see a drop and a
|
|
36
|
-
* replacement open that both land inside one probe.
|
|
37
|
-
*/
|
|
38
|
-
socketOpens: number;
|
|
39
|
-
lastError: ConnectionError | null;
|
|
40
|
-
setWsStatus: (status: WsStatus) => void;
|
|
41
|
-
setVpnStatus: (status: VpnStatus) => void;
|
|
42
|
-
recordWsClose: (opened: boolean, code: number) => void;
|
|
43
|
-
/** A socket reached `open`: the refusal evidence so far is spent. */
|
|
44
|
-
noteSocketOpen: () => void;
|
|
45
|
-
reportError: (code: string, message: string) => void;
|
|
46
|
-
clearError: () => void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const useConnectionStore = create<ConnectionState>((set) => ({
|
|
50
|
-
wsStatus: "disconnected",
|
|
51
|
-
vpnStatus: "checking",
|
|
52
|
-
handshakeFailures: 0,
|
|
53
|
-
lastCloseCode: null,
|
|
54
|
-
socketOpens: 0,
|
|
55
|
-
lastError: null,
|
|
56
|
-
setWsStatus: (wsStatus) => set({ wsStatus }),
|
|
57
|
-
setVpnStatus: (vpnStatus) => set({ vpnStatus }),
|
|
58
|
-
recordWsClose: (opened, lastCloseCode) =>
|
|
59
|
-
set((state) => ({
|
|
60
|
-
lastCloseCode,
|
|
61
|
-
handshakeFailures: opened
|
|
62
|
-
? state.handshakeFailures
|
|
63
|
-
: state.handshakeFailures + 1,
|
|
64
|
-
})),
|
|
65
|
-
noteSocketOpen: () =>
|
|
66
|
-
set((state) => ({
|
|
67
|
-
handshakeFailures: 0,
|
|
68
|
-
// Cleared here, not on the next close: the server accepts the upgrade and
|
|
69
|
-
// THEN closes with 4008 when it is at its connection cap, so the code
|
|
70
|
-
// must survive an open to be read, and must not outlive the next one.
|
|
71
|
-
lastCloseCode: null,
|
|
72
|
-
socketOpens: state.socketOpens + 1,
|
|
73
|
-
})),
|
|
74
|
-
reportError: (code, message) => set({ lastError: { code, message, at: Date.now() } }),
|
|
75
|
-
clearError: () => set({ lastError: null }),
|
|
76
|
-
}));
|
|
1
|
+
import { useRootStore } from "../root-context.js";
|
|
2
|
+
import { defaultRoot } from "../default-root.js";
|
|
3
|
+
export * from "./connection-state.js";
|
|
4
|
+
|
|
5
|
+
/** Hook reads the current provider. Statics address the default app only. */
|
|
6
|
+
export const useConnectionStore = Object.assign(
|
|
7
|
+
function useConnectionStore<T>(selector: (state: ReturnType<typeof defaultRoot.stores.connection.getState>) => T): T {
|
|
8
|
+
return useRootStore("connection", selector);
|
|
9
|
+
},
|
|
10
|
+
defaultRoot.stores.connection,
|
|
11
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createUIStore } from "./ui-state.js";
|
|
2
|
+
import { createConnectionStore } from "./connection-state.js";
|
|
3
|
+
import { createProviderStore } from "./provider-state.js";
|
|
4
|
+
import { createChatStore } from "./chat-state.js";
|
|
5
|
+
import { createFileStore } from "./file-state.js";
|
|
6
|
+
import { createGraphStore } from "./graph-state.js";
|
|
7
|
+
import { createActivityStore } from "./activity-state.js";
|
|
8
|
+
import { createPrincipalStore } from "./principal-state.js";
|
|
9
|
+
import { createMaskStore } from "./mask-state.js";
|
|
10
|
+
import { createShareStore } from "./share-state.js";
|
|
11
|
+
import { createVoiceStore } from "../voice/voice-state.js";
|
|
12
|
+
import type { StoreEnvironment } from "./store-environment.js";
|
|
13
|
+
|
|
14
|
+
export function createBrainStores(env: StoreEnvironment) {
|
|
15
|
+
const provider = createProviderStore(env);
|
|
16
|
+
return {
|
|
17
|
+
provider,
|
|
18
|
+
chat: createChatStore(env, provider),
|
|
19
|
+
ui: createUIStore(env),
|
|
20
|
+
connection: createConnectionStore(),
|
|
21
|
+
file: createFileStore(env),
|
|
22
|
+
graph: createGraphStore(env),
|
|
23
|
+
activity: createActivityStore(env),
|
|
24
|
+
principal: createPrincipalStore(env),
|
|
25
|
+
mask: createMaskStore(),
|
|
26
|
+
share: createShareStore(),
|
|
27
|
+
voice: createVoiceStore(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type BrainStores = ReturnType<typeof createBrainStores>;
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { createStore } from "zustand/vanilla";
|
|
2
|
+
import type {
|
|
3
|
+
FileEntry,
|
|
4
|
+
FileContentResponse,
|
|
5
|
+
FileResolveResponse,
|
|
6
|
+
WikilinkMapResponse,
|
|
7
|
+
} from "@schlessera/brain-ui-sdk/protocol";
|
|
8
|
+
import { FILE_SIZE_CAP_BYTES } from "@schlessera/brain-ui-sdk/protocol";
|
|
9
|
+
import type { StoreEnvironment } from "./store-environment.js";
|
|
10
|
+
import { isMermaidPath } from "../lib/mermaid.js";
|
|
11
|
+
|
|
12
|
+
export interface FileState {
|
|
13
|
+
// Tree state
|
|
14
|
+
dirCache: Record<string, FileEntry[]>;
|
|
15
|
+
loadingDirs: Set<string>;
|
|
16
|
+
dirErrors: Record<string, string>;
|
|
17
|
+
expandedDirs: Set<string>;
|
|
18
|
+
|
|
19
|
+
// Viewer state
|
|
20
|
+
currentPath: string | null;
|
|
21
|
+
currentContent: FileContentResponse | null;
|
|
22
|
+
contentLoading: boolean;
|
|
23
|
+
contentError: string | null;
|
|
24
|
+
viewMode: ViewMode;
|
|
25
|
+
treeExpanded: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the frontmatter table at the top of markdown files is collapsed.
|
|
28
|
+
* Persisted in localStorage so the preference carries across files.
|
|
29
|
+
*/
|
|
30
|
+
frontmatterCollapsed: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Directory most recently navigated to via openDir. Used by the tree to
|
|
33
|
+
* apply a brief highlight + scroll the node into view. Cleared shortly
|
|
34
|
+
* after by openDir itself.
|
|
35
|
+
*/
|
|
36
|
+
highlightedDir: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Lowercase slug -> repo-relative .md path. Lazily loaded the first
|
|
39
|
+
* time a markdown surface needs to resolve a [[wikilink]].
|
|
40
|
+
*/
|
|
41
|
+
wikilinkMap: Record<string, string>;
|
|
42
|
+
wikilinkLoaded: boolean;
|
|
43
|
+
wikilinkLoading: boolean;
|
|
44
|
+
|
|
45
|
+
// Actions
|
|
46
|
+
loadDir: (path: string) => Promise<void>;
|
|
47
|
+
toggleDir: (path: string) => Promise<void>;
|
|
48
|
+
setExpanded: (path: string, expanded: boolean) => void;
|
|
49
|
+
openFile: (path: string) => Promise<void>;
|
|
50
|
+
openDir: (path: string) => Promise<void>;
|
|
51
|
+
closeFile: () => void;
|
|
52
|
+
setViewMode: (mode: ViewMode) => void;
|
|
53
|
+
setTreeExpanded: (expanded: boolean) => void;
|
|
54
|
+
toggleFrontmatter: () => void;
|
|
55
|
+
setHighlightedDir: (path: string | null) => void;
|
|
56
|
+
ensureWikilinks: () => Promise<void>;
|
|
57
|
+
reset: () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type ViewMode = "preview" | "raw";
|
|
61
|
+
|
|
62
|
+
/** Kinds/paths the viewer can render as a preview (vs raw text only). */
|
|
63
|
+
function hasPreview(content: FileContentResponse): boolean {
|
|
64
|
+
return (
|
|
65
|
+
content.kind === "markdown" ||
|
|
66
|
+
content.kind === "html" ||
|
|
67
|
+
(content.kind === "text" && isMermaidPath(content.path))
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function createFileStore(env: StoreEnvironment) {
|
|
72
|
+
const apiBase = env.apiBase;
|
|
73
|
+
const fetch = env.request;
|
|
74
|
+
const FRONTMATTER_COLLAPSED_KEY = env.storageKey("brain-ui:frontmatter-collapsed");
|
|
75
|
+
|
|
76
|
+
function readFrontmatterCollapsed(): boolean {
|
|
77
|
+
const storage = env.storage();
|
|
78
|
+
if (!storage) return false;
|
|
79
|
+
return env.storage()?.getItem(FRONTMATTER_COLLAPSED_KEY) === "1";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
async function fetchTree(path: string): Promise<FileEntry[]> {
|
|
84
|
+
const url = `${apiBase()}/files/tree${path ? `?path=${encodeURIComponent(path)}` : ""}`;
|
|
85
|
+
const res = await fetch(url);
|
|
86
|
+
if (!res.ok) {
|
|
87
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
88
|
+
throw new Error(body.error || `HTTP ${res.status}`);
|
|
89
|
+
}
|
|
90
|
+
const data = await res.json();
|
|
91
|
+
return data.entries;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function fetchContent(path: string, signal: AbortSignal): Promise<FileContentResponse> {
|
|
95
|
+
const res = await fetch(`${apiBase()}/files/content?path=${encodeURIComponent(path)}`, { signal });
|
|
96
|
+
if (!res.ok) {
|
|
97
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
98
|
+
const err = new Error(body.error || `HTTP ${res.status}`);
|
|
99
|
+
(err as Error & { status: number; size?: number }).status = res.status;
|
|
100
|
+
if (body.size) (err as Error & { status: number; size?: number }).size = body.size;
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
return res.json();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function fetchResolve(path: string, signal: AbortSignal): Promise<FileResolveResponse> {
|
|
107
|
+
const res = await fetch(`${apiBase()}/files/resolve?path=${encodeURIComponent(path)}`, { signal });
|
|
108
|
+
if (!res.ok) {
|
|
109
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
110
|
+
throw new Error(body.error || `HTTP ${res.status}`);
|
|
111
|
+
}
|
|
112
|
+
return res.json();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function fetchWikilinks(): Promise<WikilinkMapResponse> {
|
|
116
|
+
const res = await fetch(`${apiBase()}/files/wikilinks`);
|
|
117
|
+
if (!res.ok) {
|
|
118
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
119
|
+
throw new Error(body.error || `HTTP ${res.status}`);
|
|
120
|
+
}
|
|
121
|
+
return res.json();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let fileRequest: AbortController | null = null;
|
|
125
|
+
let directoryRequest: AbortController | null = null;
|
|
126
|
+
let cacheEpoch = 0;
|
|
127
|
+
|
|
128
|
+
return createStore<FileState>((set, get) => ({
|
|
129
|
+
dirCache: {},
|
|
130
|
+
loadingDirs: new Set(),
|
|
131
|
+
dirErrors: {},
|
|
132
|
+
expandedDirs: new Set([""]),
|
|
133
|
+
|
|
134
|
+
currentPath: null,
|
|
135
|
+
currentContent: null,
|
|
136
|
+
contentLoading: false,
|
|
137
|
+
contentError: null,
|
|
138
|
+
viewMode: "preview",
|
|
139
|
+
treeExpanded: true,
|
|
140
|
+
frontmatterCollapsed: readFrontmatterCollapsed(),
|
|
141
|
+
highlightedDir: null,
|
|
142
|
+
wikilinkMap: {},
|
|
143
|
+
wikilinkLoaded: false,
|
|
144
|
+
wikilinkLoading: false,
|
|
145
|
+
|
|
146
|
+
loadDir: async (path) => {
|
|
147
|
+
const epoch = cacheEpoch;
|
|
148
|
+
const { dirCache, loadingDirs } = get();
|
|
149
|
+
if (dirCache[path] || loadingDirs.has(path)) return;
|
|
150
|
+
const next = new Set(loadingDirs);
|
|
151
|
+
next.add(path);
|
|
152
|
+
set({ loadingDirs: next });
|
|
153
|
+
try {
|
|
154
|
+
const entries = await fetchTree(path);
|
|
155
|
+
if (epoch !== cacheEpoch) return;
|
|
156
|
+
set((s) => {
|
|
157
|
+
const loading = new Set(s.loadingDirs);
|
|
158
|
+
loading.delete(path);
|
|
159
|
+
const errors = { ...s.dirErrors };
|
|
160
|
+
delete errors[path];
|
|
161
|
+
return {
|
|
162
|
+
dirCache: { ...s.dirCache, [path]: entries },
|
|
163
|
+
loadingDirs: loading,
|
|
164
|
+
dirErrors: errors,
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
} catch (err) {
|
|
168
|
+
if (epoch !== cacheEpoch) return;
|
|
169
|
+
set((s) => {
|
|
170
|
+
const loading = new Set(s.loadingDirs);
|
|
171
|
+
loading.delete(path);
|
|
172
|
+
return {
|
|
173
|
+
loadingDirs: loading,
|
|
174
|
+
dirErrors: { ...s.dirErrors, [path]: err instanceof Error ? err.message : "load_failed" },
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
toggleDir: async (path) => {
|
|
181
|
+
const { expandedDirs } = get();
|
|
182
|
+
if (expandedDirs.has(path)) {
|
|
183
|
+
const next = new Set(expandedDirs);
|
|
184
|
+
next.delete(path);
|
|
185
|
+
set({ expandedDirs: next });
|
|
186
|
+
} else {
|
|
187
|
+
const next = new Set(expandedDirs);
|
|
188
|
+
next.add(path);
|
|
189
|
+
set({ expandedDirs: next });
|
|
190
|
+
await get().loadDir(path);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
setExpanded: (path, expanded) => {
|
|
195
|
+
set((s) => {
|
|
196
|
+
const next = new Set(s.expandedDirs);
|
|
197
|
+
if (expanded) next.add(path);
|
|
198
|
+
else next.delete(path);
|
|
199
|
+
return { expandedDirs: next };
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
openFile: async (path) => {
|
|
204
|
+
fileRequest?.abort();
|
|
205
|
+
directoryRequest?.abort();
|
|
206
|
+
const request = new AbortController();
|
|
207
|
+
fileRequest = request;
|
|
208
|
+
const ownsRequest = () => fileRequest === request && !request.signal.aborted;
|
|
209
|
+
const normalized = path.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
210
|
+
set({ currentPath: normalized, contentLoading: true, contentError: null, currentContent: null, treeExpanded: false });
|
|
211
|
+
|
|
212
|
+
// Fire-and-await: load ancestor chain then content in parallel
|
|
213
|
+
const ancestorsPromise = (async () => {
|
|
214
|
+
try {
|
|
215
|
+
const r = await fetchResolve(normalized, request.signal);
|
|
216
|
+
if (!ownsRequest()) return;
|
|
217
|
+
// Expand each ancestor and root, load their contents
|
|
218
|
+
const dirsToLoad = ["", ...r.ancestors];
|
|
219
|
+
set((s) => {
|
|
220
|
+
const next = new Set(s.expandedDirs);
|
|
221
|
+
for (const d of dirsToLoad) next.add(d);
|
|
222
|
+
return { expandedDirs: next };
|
|
223
|
+
});
|
|
224
|
+
await Promise.all(dirsToLoad.map((d) => get().loadDir(d)));
|
|
225
|
+
} catch {
|
|
226
|
+
// Tree expansion best-effort
|
|
227
|
+
}
|
|
228
|
+
})();
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
const content = await fetchContent(normalized, request.signal);
|
|
232
|
+
// Drop a response the user has already navigated away from. Two rapid
|
|
233
|
+
// clicks race, and without this the SLOWER fetch wins: the viewer showed
|
|
234
|
+
// the newer file's path with the older file's content, which reads as
|
|
235
|
+
// corruption rather than as a stale load.
|
|
236
|
+
if (!ownsRequest()) return;
|
|
237
|
+
set({ currentContent: content, contentLoading: false });
|
|
238
|
+
// Default mode: prefer preview when available; persist otherwise
|
|
239
|
+
const { viewMode } = get();
|
|
240
|
+
if (!hasPreview(content) && viewMode === "preview") {
|
|
241
|
+
set({ viewMode: "raw" });
|
|
242
|
+
} else if (hasPreview(content) && viewMode === "raw") {
|
|
243
|
+
// Keep raw if user toggled — but on a fresh open default back to preview
|
|
244
|
+
set({ viewMode: "preview" });
|
|
245
|
+
}
|
|
246
|
+
} catch (err) {
|
|
247
|
+
const e = err as Error & { status?: number; size?: number };
|
|
248
|
+
let msg = e.message || "load_failed";
|
|
249
|
+
if (e.status === 413 && e.size) msg = `File too large (${(e.size / 1024 / 1024).toFixed(2)} MB; cap ${(FILE_SIZE_CAP_BYTES / 1024 / 1024).toFixed(0)} MB).`;
|
|
250
|
+
else if (e.status === 404) msg = "File not found.";
|
|
251
|
+
else if (e.message === "invalid_path") msg = "Invalid path.";
|
|
252
|
+
// Same guard: a failure for a file the user already left must not
|
|
253
|
+
// replace the file they are now looking at with an error.
|
|
254
|
+
if (!ownsRequest()) return;
|
|
255
|
+
set({ contentError: msg, contentLoading: false });
|
|
256
|
+
} finally {
|
|
257
|
+
await ancestorsPromise;
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
closeFile: () => {
|
|
262
|
+
fileRequest?.abort();
|
|
263
|
+
fileRequest = null;
|
|
264
|
+
set({ currentPath: null, currentContent: null, contentError: null, contentLoading: false, treeExpanded: true });
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
openDir: async (path) => {
|
|
268
|
+
directoryRequest?.abort();
|
|
269
|
+
const request = new AbortController();
|
|
270
|
+
directoryRequest = request;
|
|
271
|
+
const normalized = path
|
|
272
|
+
.replace(/^\/+/, "")
|
|
273
|
+
.replace(/\\/g, "/")
|
|
274
|
+
.replace(/\/+$/, "");
|
|
275
|
+
if (!normalized) {
|
|
276
|
+
// Just expand the root view
|
|
277
|
+
set({ treeExpanded: true });
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// Make the tree visible even if a file is currently open.
|
|
281
|
+
set({ treeExpanded: true, highlightedDir: normalized });
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
const r = await fetchResolve(normalized, request.signal);
|
|
285
|
+
if (directoryRequest !== request || request.signal.aborted) return;
|
|
286
|
+
const dirs = ["", ...r.ancestors, normalized];
|
|
287
|
+
set((s) => {
|
|
288
|
+
const next = new Set(s.expandedDirs);
|
|
289
|
+
for (const d of dirs) next.add(d);
|
|
290
|
+
return { expandedDirs: next };
|
|
291
|
+
});
|
|
292
|
+
await Promise.all(dirs.map((d) => get().loadDir(d)));
|
|
293
|
+
} catch {
|
|
294
|
+
// Best-effort expansion — failure surfaces via per-dir error state
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
setViewMode: (mode) => set({ viewMode: mode }),
|
|
299
|
+
|
|
300
|
+
setTreeExpanded: (expanded) => set({ treeExpanded: expanded }),
|
|
301
|
+
|
|
302
|
+
setHighlightedDir: (path) => set({ highlightedDir: path }),
|
|
303
|
+
|
|
304
|
+
ensureWikilinks: async () => {
|
|
305
|
+
const epoch = cacheEpoch;
|
|
306
|
+
const { wikilinkLoaded, wikilinkLoading } = get();
|
|
307
|
+
if (wikilinkLoaded || wikilinkLoading) return;
|
|
308
|
+
set({ wikilinkLoading: true });
|
|
309
|
+
try {
|
|
310
|
+
const data = await fetchWikilinks();
|
|
311
|
+
if (epoch !== cacheEpoch) return;
|
|
312
|
+
set({
|
|
313
|
+
wikilinkMap: data.slugs,
|
|
314
|
+
wikilinkLoaded: true,
|
|
315
|
+
wikilinkLoading: false,
|
|
316
|
+
});
|
|
317
|
+
} catch {
|
|
318
|
+
// Soft-fail — leave the map empty; wikilinks will render as plain text
|
|
319
|
+
if (epoch !== cacheEpoch) return;
|
|
320
|
+
set({ wikilinkLoading: false });
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
toggleFrontmatter: () =>
|
|
325
|
+
set((s) => {
|
|
326
|
+
const next = !s.frontmatterCollapsed;
|
|
327
|
+
if (env.storage() !== null) {
|
|
328
|
+
if (next) env.storage()?.setItem(FRONTMATTER_COLLAPSED_KEY, "1");
|
|
329
|
+
else env.storage()?.removeItem(FRONTMATTER_COLLAPSED_KEY);
|
|
330
|
+
}
|
|
331
|
+
return { frontmatterCollapsed: next };
|
|
332
|
+
}),
|
|
333
|
+
|
|
334
|
+
reset: () => {
|
|
335
|
+
fileRequest?.abort();
|
|
336
|
+
directoryRequest?.abort();
|
|
337
|
+
fileRequest = null;
|
|
338
|
+
directoryRequest = null;
|
|
339
|
+
cacheEpoch++;
|
|
340
|
+
set({
|
|
341
|
+
dirCache: {}, loadingDirs: new Set(), dirErrors: {}, expandedDirs: new Set([""]),
|
|
342
|
+
highlightedDir: null, wikilinkMap: {}, wikilinkLoaded: false, wikilinkLoading: false,
|
|
343
|
+
currentPath: null,
|
|
344
|
+
currentContent: null,
|
|
345
|
+
contentLoading: false,
|
|
346
|
+
contentError: null,
|
|
347
|
+
viewMode: "preview",
|
|
348
|
+
treeExpanded: true,
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Heuristics: is this string a plausible repo-relative path reference?
|
|
357
|
+
*
|
|
358
|
+
* Files require a trailing `.ext` (1-8 alphanumeric chars). Directories
|
|
359
|
+
* require at least one `/` segment and a trailing `/`. Neither may look
|
|
360
|
+
* like a URL, an absolute path, or a version number.
|
|
361
|
+
*/
|
|
362
|
+
const FILE_REF_RE = /^[a-z0-9_.-]+(\/[a-z0-9_.-]+)*\.[a-z0-9]{1,8}$/i;
|
|
363
|
+
const DIR_REF_RE = /^[a-z0-9_.-]+(\/[a-z0-9_.-]+)+\/$/i;
|
|
364
|
+
const URL_LIKE_RE = /^(?:https?:|mailto:|tel:|#|\/)/i;
|
|
365
|
+
const VERSION_RE = /^\d+(\.\d+){1,3}$/;
|
|
366
|
+
|
|
367
|
+
function rejectsCommonNonPath(href: string): boolean {
|
|
368
|
+
if (URL_LIKE_RE.test(href)) return true;
|
|
369
|
+
if (VERSION_RE.test(href)) return true;
|
|
370
|
+
if (href.includes(" ")) return true;
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function isInternalRepoPath(href: string | undefined): href is string {
|
|
375
|
+
if (!href) return false;
|
|
376
|
+
if (rejectsCommonNonPath(href)) return false;
|
|
377
|
+
return FILE_REF_RE.test(href);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function isInternalRepoDir(href: string | undefined): href is string {
|
|
381
|
+
if (!href) return false;
|
|
382
|
+
if (rejectsCommonNonPath(href)) return false;
|
|
383
|
+
return DIR_REF_RE.test(href);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export type RepoPathKind = "file" | "dir";
|
|
387
|
+
|
|
388
|
+
export function classifyRepoPath(
|
|
389
|
+
href: string | undefined
|
|
390
|
+
): RepoPathKind | null {
|
|
391
|
+
if (isInternalRepoPath(href)) return "file";
|
|
392
|
+
if (isInternalRepoDir(href)) return "dir";
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** Normalize a directory ref by trimming the trailing slash. */
|
|
397
|
+
export function normalizeDirPath(path: string): string {
|
|
398
|
+
return path.replace(/\/+$/, "");
|
|
399
|
+
}
|