gloomberb 0.7.4 → 0.8.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 +27 -6
- package/package.json +2 -3
- package/src/api-client/auth.ts +167 -0
- package/src/api-client/chat.ts +116 -0
- package/src/api-client/data.ts +177 -0
- package/src/api-client/errors.ts +28 -0
- package/src/api-client/index.test.ts +675 -0
- package/src/api-client/index.ts +384 -0
- package/src/api-client/normalizers.ts +61 -0
- package/src/api-client/paths.ts +173 -0
- package/src/api-client/request.ts +124 -0
- package/src/api-client/socket.ts +483 -0
- package/src/api-client/types.ts +490 -0
- package/src/app/app-bootstrap-state.test.ts +157 -0
- package/src/app/app-bootstrap-state.ts +134 -0
- package/src/app/global-shortcuts.test.tsx +166 -0
- package/src/app/global-shortcuts.ts +126 -0
- package/src/app/pane-runtime/index.tsx +297 -0
- package/src/app/pane-runtime/layout-placement.ts +73 -0
- package/src/app/pane-runtime/pane-settings-runtime.tsx +67 -0
- package/src/app/pane-runtime/pane-template-runtime.ts +110 -0
- package/src/app/pane-runtime/plugin-bindings.ts +231 -0
- package/src/app/pane-runtime/ticker-inspector-runtime.ts +167 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +144 -0
- package/src/app/pane-template-dialog-wizard.tsx +52 -0
- package/src/app/runtime/broker-import.ts +109 -0
- package/src/app/runtime/desktop-menu.ts +74 -0
- package/src/app/runtime/plugin-bindings.ts +246 -0
- package/src/app/runtime/startup.ts +126 -0
- package/src/app/runtime/ticker-refresh.ts +249 -0
- package/src/app/runtime/update.ts +86 -0
- package/src/app.tsx +110 -1461
- package/src/brokers/broker-portfolio-sync.ts +186 -0
- package/src/brokers/broker-ticker-sync.ts +141 -0
- package/src/brokers/profile-form.ts +2 -2
- package/src/brokers/remote-broker-adapter.ts +3 -2
- package/src/brokers/sync-broker-instance.test.ts +140 -0
- package/src/brokers/sync-broker-instance.ts +60 -181
- package/src/capabilities/types.ts +4 -4
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -3
- package/src/cli/context.ts +1 -1
- package/src/cli/desktop-pane-shot.ts +305 -0
- package/src/cli/helpers.ts +1 -1
- package/src/cli/index.ts +34 -0
- package/src/cli/pane-functions/catalog.ts +243 -0
- package/src/cli/pane-functions/data.ts +78 -0
- package/src/cli/pane-functions/discovery.ts +113 -0
- package/src/cli/pane-functions/index.test.ts +114 -0
- package/src/cli/pane-functions/index.ts +112 -0
- package/src/cli/pane-functions/options.ts +249 -0
- package/src/cli/pane-functions/report.ts +180 -0
- package/src/cli/pane-functions/resolver.ts +96 -0
- package/src/cli/pane-functions/screenshot.ts +113 -0
- package/src/cli/registry.ts +3 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli.test.ts +1 -1
- package/src/components/chart/bar-chart-renderer.test.ts +53 -0
- package/src/components/chart/bar-chart-renderer.ts +190 -0
- package/src/components/chart/comparison/data.test.ts +105 -0
- package/src/components/chart/comparison/data.ts +279 -0
- package/src/components/chart/comparison/renderer.test.ts +187 -0
- package/src/components/chart/comparison/renderer.ts +283 -0
- package/src/components/chart/comparison/scene.ts +178 -0
- package/src/components/chart/comparison-stock-chart/axis-width.ts +99 -0
- package/src/components/chart/comparison-stock-chart/canvas.ts +148 -0
- package/src/components/chart/comparison-stock-chart/controls.ts +252 -0
- package/src/components/chart/comparison-stock-chart/helpers.ts +133 -0
- package/src/components/chart/comparison-stock-chart/interactions.ts +202 -0
- package/src/components/chart/comparison-stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/comparison-stock-chart/layout.tsx +155 -0
- package/src/components/chart/comparison-stock-chart/legend.tsx +73 -0
- package/src/components/chart/comparison-stock-chart/native-surfaces.ts +89 -0
- package/src/components/chart/comparison-stock-chart/render-data.ts +198 -0
- package/src/components/chart/comparison-stock-chart/render-output.ts +145 -0
- package/src/components/chart/comparison-stock-chart/selection-runtime.ts +111 -0
- package/src/components/chart/comparison-stock-chart/sources.ts +47 -0
- package/src/components/chart/comparison-stock-chart/surface-runtime.ts +159 -0
- package/src/components/chart/comparison-stock-chart/toolbar.tsx +107 -0
- package/src/components/chart/comparison-stock-chart/types.ts +22 -0
- package/src/components/chart/comparison-stock-chart/view.tsx +524 -0
- package/src/components/chart/comparison-stock-chart/viewport-runtime.ts +239 -0
- package/src/components/chart/comparison-stock-chart.tsx +12 -2028
- package/src/components/chart/core/axis-format.ts +147 -0
- package/src/components/chart/core/axis-measure.ts +33 -0
- package/src/components/chart/core/controller.test.ts +157 -0
- package/src/components/chart/core/controller.ts +349 -0
- package/src/components/chart/core/data.ts +94 -0
- package/src/components/chart/core/date-window.ts +392 -0
- package/src/components/chart/core/index.test.ts +1007 -0
- package/src/components/chart/core/indicator-selector.tsx +75 -0
- package/src/components/chart/core/keyboard.ts +15 -0
- package/src/components/chart/core/palette.ts +60 -0
- package/src/components/chart/core/pane-settings.test.ts +25 -0
- package/src/components/chart/core/pane-settings.ts +82 -0
- package/src/components/chart/core/pointer.ts +292 -0
- package/src/components/chart/core/projection.ts +333 -0
- package/src/components/chart/core/render-utils.ts +4 -0
- package/src/components/chart/core/renderer.ts +249 -0
- package/src/components/chart/core/resolution.test.ts +99 -0
- package/src/components/chart/core/resolution.ts +380 -0
- package/src/components/chart/core/scene.ts +180 -0
- package/src/components/chart/core/scroll.test.ts +70 -0
- package/src/components/chart/core/scroll.ts +104 -0
- package/src/components/chart/core/time-axis.ts +330 -0
- package/src/components/chart/core/types.ts +124 -0
- package/src/components/chart/core/viewport.test.ts +29 -0
- package/src/components/chart/core/viewport.ts +51 -0
- package/src/components/chart/core/window-viewport.test.ts +69 -0
- package/src/components/chart/core/window-viewport.ts +162 -0
- package/src/components/chart/display-cursor.ts +153 -0
- package/src/components/chart/market-session.ts +1 -1
- package/src/components/chart/multi-line/renderer.test.ts +83 -0
- package/src/components/chart/multi-line/renderer.ts +160 -0
- package/src/components/chart/multi-line/scene.ts +188 -0
- package/src/components/chart/native/canvas-bitmaps.ts +140 -0
- package/src/components/chart/native/chart-rasterizer.ts +18 -865
- package/src/components/chart/native/kitty/adapter.ts +9 -0
- package/src/components/chart/native/kitty/index.test.ts +752 -0
- package/src/components/chart/native/kitty/manager.ts +142 -0
- package/src/components/chart/native/kitty/support.ts +70 -0
- package/src/components/chart/native/raster/comparison-chart.ts +162 -0
- package/src/components/chart/native/raster/crosshair.ts +51 -0
- package/src/components/chart/native/raster/layout.ts +136 -0
- package/src/components/chart/native/raster/placement.ts +132 -0
- package/src/components/chart/native/raster/price-chart.ts +244 -0
- package/src/components/chart/native/raster/primitives.ts +154 -0
- package/src/components/chart/native/raster/types.ts +41 -0
- package/src/components/chart/native/renderer-selection.ts +81 -1
- package/src/components/chart/native/surface/hooks.ts +137 -0
- package/src/components/chart/native/surface/manager.ts +225 -0
- package/src/components/chart/native/surface/rendering.ts +211 -0
- package/src/components/chart/native/surface/sync.ts +34 -0
- package/src/components/chart/native/surface/visibility.ts +48 -0
- package/src/components/chart/price-axis-labels.tsx +4 -4
- package/src/components/chart/rendering/chart-draw.ts +270 -0
- package/src/components/chart/rendering/geometry.ts +95 -0
- package/src/components/chart/rendering/pixel-buffer.ts +267 -0
- package/src/components/chart/scatter-chart-renderer.test.ts +31 -0
- package/src/components/chart/scatter-chart-renderer.ts +223 -0
- package/src/components/chart/static/bar-chart-surface.tsx +85 -0
- package/src/components/chart/static/chart/bitmap.ts +50 -0
- package/src/components/chart/static/chart/surface.test.tsx +51 -0
- package/src/components/chart/static/chart/surface.tsx +181 -0
- package/src/components/chart/static/multi-line-chart-surface.tsx +180 -0
- package/src/components/chart/static/scatter-chart-surface.tsx +83 -0
- package/src/components/chart/stock-chart/auto.ts +216 -0
- package/src/components/chart/stock-chart/axis-width.ts +146 -0
- package/src/components/chart/stock-chart/bitmaps.ts +22 -0
- package/src/components/chart/stock-chart/canvas.ts +202 -0
- package/src/components/chart/stock-chart/controls.tsx +149 -0
- package/src/components/chart/stock-chart/cursor.ts +60 -0
- package/src/components/chart/stock-chart/data-runtime.ts +129 -0
- package/src/components/chart/stock-chart/footer.ts +248 -0
- package/src/components/chart/stock-chart/geometry.ts +160 -0
- package/src/components/chart/stock-chart/index.test.ts +500 -0
- package/src/components/chart/stock-chart/index.tsx +29 -0
- package/src/components/chart/stock-chart/indicators.ts +226 -0
- package/src/components/chart/stock-chart/interaction-runtime.ts +44 -0
- package/src/components/chart/stock-chart/interactions.ts +300 -0
- package/src/components/chart/stock-chart/keyboard.ts +373 -0
- package/src/components/chart/stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/stock-chart/layout.tsx +177 -0
- package/src/components/chart/stock-chart/native-surfaces.ts +121 -0
- package/src/components/chart/stock-chart/presentation.ts +67 -0
- package/src/components/chart/stock-chart/renderer-switch.test.tsx +263 -0
- package/src/components/chart/stock-chart/rendering/bounds.ts +116 -0
- package/src/components/chart/stock-chart/rendering/candidates.ts +145 -0
- package/src/components/chart/stock-chart/rendering/data.ts +370 -0
- package/src/components/chart/stock-chart/rendering/invalidation.ts +68 -0
- package/src/components/chart/stock-chart/rendering/output.ts +304 -0
- package/src/components/chart/stock-chart/rendering/planning.ts +122 -0
- package/src/components/chart/stock-chart/rendering/projection.test.tsx +98 -0
- package/src/components/chart/stock-chart/rendering/projection.ts +112 -0
- package/src/components/chart/stock-chart/rendering/state.test.ts +70 -0
- package/src/components/chart/stock-chart/rendering/state.ts +283 -0
- package/src/components/chart/stock-chart/requests.ts +337 -0
- package/src/components/chart/stock-chart/resolution-support.ts +96 -0
- package/src/components/chart/stock-chart/resolved/runtime.ts +289 -0
- package/src/components/chart/stock-chart/resolved.tsx +345 -0
- package/src/components/chart/stock-chart/settings.ts +77 -0
- package/src/components/chart/stock-chart/surface-runtime.ts +62 -0
- package/src/components/chart/stock-chart/types.ts +25 -0
- package/src/components/chart/stock-chart/view.tsx +155 -0
- package/src/components/chart/stock-chart/viewport/effects.ts +296 -0
- package/src/components/chart/stock-chart/viewport/index.ts +144 -0
- package/src/components/chart/stock-chart/viewport/runtime.ts +375 -0
- package/src/components/chart/time-axis-label.tsx +4 -3
- package/src/components/command-bar/action-runtime.ts +326 -0
- package/src/components/command-bar/commands/collection.ts +214 -0
- package/src/components/command-bar/commands/direct/index.ts +266 -0
- package/src/components/command-bar/commands/direct/runtime.ts +168 -0
- package/src/components/command-bar/commands/plugin/actions.ts +171 -0
- package/src/components/command-bar/commands/plugin/items.ts +166 -0
- package/src/components/command-bar/commands/registry.ts +263 -0
- package/src/components/command-bar/helpers.test.ts +13 -21
- package/src/components/command-bar/helpers.ts +51 -272
- package/src/components/command-bar/keyboard-handlers.ts +306 -0
- package/src/components/command-bar/keyboard-shortcuts.ts +204 -0
- package/src/components/command-bar/layout-items/current-layout.ts +120 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +143 -0
- package/src/components/command-bar/layout-items/types.ts +25 -0
- package/src/components/command-bar/layout-items/window-mode.ts +72 -0
- package/src/components/command-bar/layout-items.ts +93 -0
- package/src/components/command-bar/list/model.ts +81 -0
- package/src/components/command-bar/list/navigation.ts +125 -0
- package/src/components/command-bar/list/view.tsx +316 -0
- package/src/components/command-bar/multi-select-picker.tsx +219 -0
- package/src/components/command-bar/multi-select-runtime.ts +91 -0
- package/src/components/command-bar/pane-actions.ts +124 -0
- package/src/components/command-bar/pane-settings.ts +227 -0
- package/src/components/command-bar/pane-templates/items.ts +203 -0
- package/src/components/command-bar/pane-templates/workflow-route.ts +81 -0
- package/src/components/command-bar/pane-templates/workflow.ts +282 -0
- package/src/components/command-bar/panel/body.tsx +311 -0
- package/src/components/command-bar/panel/index.tsx +196 -0
- package/src/components/command-bar/panel/layout.ts +117 -0
- package/src/components/command-bar/panel/runtime.ts +280 -0
- package/src/components/command-bar/panel/state.ts +138 -0
- package/src/components/command-bar/panel/types.ts +78 -0
- package/src/components/command-bar/picker-activation.ts +126 -0
- package/src/components/command-bar/routes/root/command-items.ts +176 -0
- package/src/components/command-bar/routes/root/provider-search.ts +200 -0
- package/src/components/command-bar/routes/root/results.ts +233 -0
- package/src/components/command-bar/routes/root/runtime.ts +315 -0
- package/src/components/command-bar/routes/root/selection.ts +228 -0
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +108 -0
- package/src/components/command-bar/routes/root/shortcut-items.ts +159 -0
- package/src/components/command-bar/routes/root/shortcuts.test.ts +151 -0
- package/src/components/command-bar/routes/root/shortcuts.ts +188 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +142 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +94 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +151 -0
- package/src/components/command-bar/routing/actions.ts +299 -0
- package/src/components/command-bar/routing/confirm.ts +91 -0
- package/src/components/command-bar/routing/effects.ts +82 -0
- package/src/components/command-bar/routing/launch-request.ts +59 -0
- package/src/components/command-bar/routing/list-state.ts +242 -0
- package/src/components/command-bar/routing/navigation-state.ts +147 -0
- package/src/components/command-bar/selection-runtime.ts +291 -0
- package/src/components/command-bar/surface/environment.ts +124 -0
- package/src/components/command-bar/surface/index.test.tsx +864 -0
- package/src/components/command-bar/surface/index.tsx +344 -0
- package/src/components/command-bar/surface/pane.test.tsx +703 -0
- package/src/components/command-bar/surface/portfolio.test.tsx +452 -0
- package/src/components/command-bar/surface/test-harness.tsx +403 -0
- package/src/components/command-bar/theme-preview.ts +84 -0
- package/src/components/command-bar/view-model.test.ts +3 -3
- package/src/components/command-bar/view-model.ts +7 -6
- package/src/components/command-bar/workflow/alert.ts +164 -0
- package/src/components/command-bar/workflow/body.tsx +179 -0
- package/src/components/command-bar/workflow/broker.ts +158 -0
- package/src/components/command-bar/workflow/builtin.ts +134 -0
- package/src/components/command-bar/workflow/collection-actions.ts +257 -0
- package/src/components/command-bar/workflow/coordinator.ts +193 -0
- package/src/components/command-bar/workflow/field-row.tsx +214 -0
- package/src/components/command-bar/workflow/fields.ts +230 -0
- package/src/components/command-bar/workflow/ops.test.ts +197 -0
- package/src/components/command-bar/workflow/ops.ts +268 -0
- package/src/components/command-bar/workflow/route-actions.ts +232 -0
- package/src/components/command-bar/workflow/route-builder.ts +56 -0
- package/src/components/command-bar/workflow/runtime.ts +234 -0
- package/src/components/command-bar/workflow/submit.ts +213 -0
- package/src/components/command-bar/workflow/tickers.ts +214 -0
- package/src/components/command-bar/workflow/types.ts +127 -0
- package/src/components/data-table/stack-view.test.tsx +218 -0
- package/src/components/data-table/stack-view.tsx +59 -0
- package/src/components/data-table/view.test.tsx +254 -0
- package/src/components/data-table/view.tsx +306 -0
- package/src/components/feed-data-table/stack-view.test.tsx +148 -0
- package/src/components/feed-data-table/stack-view.tsx +359 -0
- package/src/components/index.ts +14 -14
- package/src/components/input-search-bar.tsx +94 -0
- package/src/components/layout/detached-pane-shell.tsx +22 -16
- package/src/components/layout/floating-pane.tsx +19 -24
- package/src/components/layout/header.tsx +9 -21
- package/src/components/layout/pane/content.test.tsx +64 -0
- package/src/components/layout/pane/content.tsx +44 -0
- package/src/components/layout/pane/cycle-order.test.ts +30 -0
- package/src/components/layout/pane/cycle-order.ts +32 -0
- package/src/components/layout/pane/footer/index.test.tsx +131 -0
- package/src/components/layout/pane/footer/index.tsx +246 -0
- package/src/components/layout/pane/footer/model.ts +99 -0
- package/src/components/layout/pane/footer/registration.tsx +114 -0
- package/src/components/layout/pane/frame.tsx +55 -0
- package/src/components/layout/pane/header.test.tsx +39 -0
- package/src/components/layout/pane/header.tsx +252 -0
- package/src/components/layout/pane/index.tsx +105 -0
- package/src/components/layout/pane/keyboard-scroll.test.tsx +146 -0
- package/src/components/layout/pane/sizing.ts +66 -0
- package/src/components/layout/pane/title.ts +38 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +72 -0
- package/src/components/layout/shell/active-drag.ts +221 -0
- package/src/components/layout/shell/chrome.ts +8 -0
- package/src/components/layout/shell/drag/index.ts +432 -0
- package/src/components/layout/shell/drag/overlays.tsx +78 -0
- package/src/components/layout/shell/drag/runtime.ts +264 -0
- package/src/components/layout/shell/index.test.tsx +788 -0
- package/src/components/layout/shell/index.tsx +451 -0
- package/src/components/layout/shell/layout-state.ts +97 -0
- package/src/components/layout/shell/menu.ts +152 -0
- package/src/components/layout/shell/native/pointer-runtime.ts +184 -0
- package/src/components/layout/shell/native/surfaces.ts +127 -0
- package/src/components/layout/shell/native/window-state.ts +208 -0
- package/src/components/layout/shell/pane/actions.ts +129 -0
- package/src/components/layout/shell/pane/layers.tsx +234 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +114 -0
- package/src/components/layout/shell/shortcuts.ts +47 -0
- package/src/components/layout/shell/terminal-pointer-runtime.ts +326 -0
- package/src/components/layout/shell/window-mode/index.ts +253 -0
- package/src/components/layout/shell/window-mode/overlays.tsx +208 -0
- package/src/components/layout/status-bar.test.tsx +1 -101
- package/src/components/layout/status-bar.tsx +1 -1
- package/src/components/layout/window-edit/mode.test.ts +55 -0
- package/src/components/layout/window-edit/mode.ts +422 -0
- package/src/components/layout/window-edit/presentation.ts +123 -0
- package/src/components/layout/window-edit/status.tsx +101 -0
- package/src/components/markdown-text.tsx +3 -3
- package/src/components/onboarding/onboarding-steps.tsx +248 -0
- package/src/components/onboarding/onboarding-wizard.tsx +97 -1035
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +144 -0
- package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +97 -0
- package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/choose-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/index.tsx +70 -0
- package/src/components/onboarding/portfolio-step/manual-name-panel.tsx +62 -0
- package/src/components/onboarding/portfolio-step/types.ts +25 -0
- package/src/components/onboarding/portfolio-step/utils.ts +15 -0
- package/src/components/onboarding/wizard-broker-sync.ts +230 -0
- package/src/components/onboarding/wizard-keyboard.ts +264 -0
- package/src/components/onboarding/wizard-model.ts +21 -0
- package/src/components/pane-settings-dialog/desktop.tsx +315 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +213 -0
- package/src/components/pane-settings-dialog/tui.tsx +73 -0
- package/src/components/pane-settings-dialog/value.ts +36 -0
- package/src/components/pane-settings-dialog.tsx +18 -622
- package/src/components/pane-template-wizard.tsx +1 -1
- package/src/components/price-selector-dialog.tsx +2 -2
- package/src/components/price-sparkline/bitmap.ts +150 -0
- package/src/components/price-sparkline/index.ts +46 -0
- package/src/components/price-sparkline/model.ts +119 -0
- package/src/components/price-sparkline/view.tsx +214 -0
- package/src/components/quote-flash.ts +103 -0
- package/src/components/speedometer-gauge/desktop.tsx +151 -0
- package/src/components/speedometer-gauge/index.tsx +44 -0
- package/src/components/speedometer-gauge/model.ts +60 -0
- package/src/components/speedometer-gauge/terminal.tsx +261 -0
- package/src/components/ticker/badge/format.ts +42 -0
- package/src/components/ticker/badge/index.tsx +100 -0
- package/src/components/ticker/badge/list.tsx +57 -0
- package/src/components/ticker/badge/text.test.tsx +223 -0
- package/src/components/ticker/badge/text.tsx +156 -0
- package/src/components/ticker/list-table-view.tsx +297 -0
- package/src/components/ticker/list-table.test.tsx +177 -0
- package/src/components/toggle-list.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +26 -0
- package/src/components/ui/data-table/opentui/index.tsx +467 -0
- package/src/components/ui/data-table/opentui/model.test.ts +47 -0
- package/src/components/ui/data-table/opentui/model.ts +66 -0
- package/src/components/ui/data-table/types.ts +81 -0
- package/src/components/ui/index.ts +1 -3
- package/src/components/ui/multi-select/dialog.tsx +336 -0
- package/src/components/ui/native-select.tsx +1 -1
- package/src/components/ui/shortcut-hint.tsx +1 -1
- package/src/components/ui/tabs.tsx +11 -5
- package/src/components/ui/toggle.tsx +1 -1
- package/src/components/ui/ui.test.tsx +3 -75
- package/src/components/use-external-link-footer.ts +1 -1
- package/src/core/app-services.ts +3 -0
- package/src/core/state/app/layout-reducer.ts +196 -0
- package/src/core/state/app/layout.ts +406 -0
- package/src/core/state/app/state.ts +340 -0
- package/src/core/state/app/types.ts +116 -0
- package/src/core/state/session-persistence.ts +1 -1
- package/src/data/app-persistence.ts +1 -1
- package/src/data/config/layout.ts +227 -0
- package/src/data/config/store/index.test.ts +500 -0
- package/src/data/config/store/index.ts +64 -0
- package/src/data/config/store/node.ts +101 -0
- package/src/data/config/store/normalize.ts +403 -0
- package/src/data/plugin-state-store.ts +3 -3
- package/src/data/resource-store.ts +3 -3
- package/src/data/session-store.ts +3 -3
- package/src/data/sqlite/cache.test.ts +151 -0
- package/src/data/sqlite/database.ts +68 -0
- package/src/data/sqlite/json.ts +16 -0
- package/src/data/sqlite/retry.test.ts +63 -0
- package/src/data/ticker-repository.ts +1 -1
- package/src/data/ticker-store.ts +2 -2
- package/src/market-data/coordinator/auxiliary.ts +252 -0
- package/src/market-data/coordinator/chart.ts +141 -0
- package/src/market-data/coordinator/entries.ts +129 -0
- package/src/market-data/coordinator/events.ts +74 -0
- package/src/market-data/coordinator/financials.ts +281 -0
- package/src/market-data/coordinator/index.test.ts +840 -0
- package/src/market-data/coordinator/index.ts +388 -0
- package/src/market-data/coordinator/quotes.ts +329 -0
- package/src/market-data/coordinator/subscriptions.test.ts +209 -0
- package/src/market-data/hooks.test.tsx +42 -1
- package/src/market-data/hooks.tsx +83 -18
- package/src/market-data/market/format.test.ts +109 -0
- package/src/market-data/market/format.ts +293 -0
- package/src/market-data/market/freshness.ts +140 -0
- package/src/market-data/market/status.ts +112 -0
- package/src/market-data/quotes/contributions.ts +194 -0
- package/src/market-data/quotes/freshness.test.ts +150 -0
- package/src/market-data/quotes/freshness.ts +36 -0
- package/src/market-data/quotes/resolution.test.ts +277 -0
- package/src/market-data/quotes/resolution.ts +468 -0
- package/src/market-data/quotes/time.test.ts +34 -0
- package/src/market-data/quotes/time.ts +59 -0
- package/src/market-data/request-types.ts +10 -3
- package/src/market-data/result-types.ts +3 -3
- package/src/market-data/selectors.ts +2 -2
- package/src/news/aggregator.ts +29 -219
- package/src/news/news-model.ts +208 -0
- package/src/news/ticker-symbols.ts +1 -1
- package/src/news/types.ts +3 -3
- package/src/plugins/builtin/account-management/footer.ts +39 -0
- package/src/plugins/builtin/account-management/form-components.tsx +162 -0
- package/src/plugins/builtin/account-management/keyboard.ts +90 -0
- package/src/plugins/builtin/account-management/model.ts +97 -0
- package/src/plugins/builtin/account-management/pane.tsx +389 -0
- package/src/plugins/builtin/account-management/password-dialog.tsx +125 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +6 -6
- package/src/plugins/builtin/ai/ask-ai.test.tsx +305 -0
- package/src/plugins/builtin/ai/index.tsx +4 -4
- package/src/plugins/builtin/ai/providers.ts +1 -1
- package/src/plugins/builtin/ai/runner.ts +1 -0
- package/src/plugins/builtin/ai/screener/action-bar.tsx +58 -0
- package/src/plugins/builtin/ai/screener/contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener/contract.ts +174 -0
- package/src/plugins/builtin/ai/screener/editor-runtime.ts +110 -0
- package/src/plugins/builtin/ai/screener/editor.tsx +125 -0
- package/src/plugins/builtin/ai/screener/footer.ts +93 -0
- package/src/plugins/builtin/ai/screener/keyboard.ts +90 -0
- package/src/plugins/builtin/ai/screener/market-runtime.ts +99 -0
- package/src/plugins/builtin/ai/screener/model.ts +107 -0
- package/src/plugins/builtin/ai/screener/pane.test.tsx +348 -0
- package/src/plugins/builtin/ai/screener/pane.tsx +412 -0
- package/src/plugins/builtin/ai/screener/results-view.tsx +169 -0
- package/src/plugins/builtin/ai/screener/results.ts +139 -0
- package/src/plugins/builtin/ai/screener/runner.ts +144 -0
- package/src/plugins/builtin/ai/screener/tabs-bar.tsx +65 -0
- package/src/plugins/builtin/ai/settings.ts +3 -3
- package/src/plugins/builtin/ai/ticker-context.ts +1 -1
- package/src/plugins/builtin/alerts/command.ts +86 -0
- package/src/plugins/builtin/alerts/constants.ts +3 -0
- package/src/plugins/builtin/alerts/format.ts +68 -0
- package/src/plugins/builtin/alerts/index.test.tsx +5 -4
- package/src/plugins/builtin/alerts/index.tsx +18 -473
- package/src/plugins/builtin/alerts/pane.tsx +304 -0
- package/src/plugins/builtin/alerts/quotes.ts +57 -0
- package/src/plugins/builtin/alerts/storage.ts +20 -0
- package/src/plugins/builtin/analytics/broker-performance.ts +142 -0
- package/src/plugins/builtin/analytics/display.ts +44 -0
- package/src/plugins/builtin/analytics/index.test.tsx +144 -5
- package/src/plugins/builtin/analytics/index.tsx +108 -468
- package/src/plugins/builtin/analytics/metrics.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +297 -0
- package/src/plugins/builtin/analytics/portfolio-selection.ts +10 -0
- package/src/plugins/builtin/analytics/sector-model.ts +172 -0
- package/src/plugins/builtin/analytics/view.tsx +207 -0
- package/src/plugins/builtin/broker-manager/detail.tsx +232 -0
- package/src/plugins/builtin/broker-manager/footer.ts +62 -0
- package/src/plugins/builtin/broker-manager/index.test.tsx +3 -3
- package/src/plugins/builtin/broker-manager/index.tsx +125 -527
- package/src/plugins/builtin/broker-manager/keyboard.ts +104 -0
- package/src/plugins/builtin/broker-manager/model.test.ts +39 -1
- package/src/plugins/builtin/broker-manager/model.ts +14 -8
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +181 -0
- package/src/plugins/builtin/broker-manager/table.ts +86 -0
- package/src/plugins/builtin/buildout/cells.tsx +203 -0
- package/src/plugins/builtin/buildout/data-runtime.ts +238 -0
- package/src/plugins/builtin/buildout/detail/company.tsx +219 -0
- package/src/plugins/builtin/buildout/detail/index.tsx +105 -0
- package/src/plugins/builtin/buildout/detail/intel.tsx +61 -0
- package/src/plugins/builtin/buildout/detail/satellite-images.tsx +80 -0
- package/src/plugins/builtin/buildout/detail/site.tsx +142 -0
- package/src/plugins/builtin/buildout/detail/ui.tsx +355 -0
- package/src/plugins/builtin/buildout/detail/values.ts +67 -0
- package/src/plugins/builtin/buildout/format.ts +163 -0
- package/src/plugins/builtin/buildout/model/index.ts +135 -0
- package/src/plugins/builtin/buildout/model/normalizers.ts +396 -0
- package/src/plugins/builtin/buildout/model/types.ts +318 -0
- package/src/plugins/builtin/buildout/pane/header.tsx +55 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +405 -0
- package/src/plugins/builtin/buildout/pane/status.tsx +84 -0
- package/src/plugins/builtin/buildout/table-model.ts +367 -0
- package/src/plugins/builtin/changelog/index.tsx +370 -0
- package/src/plugins/builtin/chat/channels.ts +157 -0
- package/src/plugins/builtin/chat/chat.test.tsx +1048 -0
- package/src/plugins/builtin/chat/composer-commands.test.ts +30 -0
- package/src/plugins/builtin/chat/composer-commands.ts +34 -0
- package/src/plugins/builtin/chat/content/channel-navigation.ts +157 -0
- package/src/plugins/builtin/chat/content/composer-runtime.ts +251 -0
- package/src/plugins/builtin/chat/content/composer.tsx +148 -0
- package/src/plugins/builtin/chat/content/index.tsx +407 -0
- package/src/plugins/builtin/chat/content/layout-metrics.ts +72 -0
- package/src/plugins/builtin/chat/content/scroll.ts +278 -0
- package/src/plugins/builtin/chat/content/selection-runtime.ts +66 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +212 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +154 -0
- package/src/plugins/builtin/chat/content/transcript.tsx +155 -0
- package/src/plugins/builtin/chat/content/types.ts +26 -0
- package/src/plugins/builtin/chat/content/user-map.ts +21 -0
- package/src/plugins/builtin/chat/controller/channel-actions.ts +87 -0
- package/src/plugins/builtin/chat/controller/channels.ts +159 -0
- package/src/plugins/builtin/chat/controller/connections.ts +90 -0
- package/src/plugins/builtin/chat/controller/draft-sync.ts +41 -0
- package/src/plugins/builtin/chat/controller/fetch.ts +83 -0
- package/src/plugins/builtin/chat/controller/index.ts +488 -0
- package/src/plugins/builtin/chat/controller/lifecycle.ts +141 -0
- package/src/plugins/builtin/chat/controller/message-loading.ts +97 -0
- package/src/plugins/builtin/chat/controller/messages.ts +173 -0
- package/src/plugins/builtin/chat/controller/notifications.ts +56 -0
- package/src/plugins/builtin/chat/controller/persistence.ts +166 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +91 -0
- package/src/plugins/builtin/chat/controller/send.ts +89 -0
- package/src/plugins/builtin/chat/controller/session-runtime.ts +156 -0
- package/src/plugins/builtin/chat/controller/session.ts +39 -0
- package/src/plugins/builtin/chat/controller/state.ts +162 -0
- package/src/plugins/builtin/chat/controller/storage.ts +136 -0
- package/src/plugins/builtin/chat/controller/utils.ts +75 -0
- package/src/plugins/builtin/chat/controller/view.ts +96 -0
- package/src/plugins/builtin/chat/controller.test.ts +1302 -0
- package/src/plugins/builtin/chat/index.tsx +4 -0
- package/src/plugins/builtin/chat/layout.ts +330 -0
- package/src/plugins/builtin/chat/message/action-chip.tsx +38 -0
- package/src/plugins/builtin/chat/message/desktop.tsx +158 -0
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +118 -0
- package/src/plugins/builtin/chat/message/profile-popover.tsx +72 -0
- package/src/plugins/builtin/chat/message/render-state.ts +67 -0
- package/src/plugins/builtin/chat/message/terminal.tsx +132 -0
- package/src/plugins/builtin/chat/message/types.ts +18 -0
- package/src/plugins/builtin/chat/pane.tsx +100 -0
- package/src/plugins/builtin/chat/profile-popover.ts +49 -0
- package/src/plugins/builtin/chat/sidebar.test.tsx +455 -0
- package/src/plugins/builtin/chat/sidebar.tsx +296 -0
- package/src/plugins/builtin/chat/status-widget.tsx +103 -0
- package/src/plugins/builtin/chat/test-harness.tsx +212 -0
- package/src/plugins/builtin/cloud/auth-actions.tsx +72 -0
- package/src/plugins/builtin/cloud/auth-commands.ts +115 -0
- package/src/plugins/builtin/cloud/index.tsx +11 -0
- package/src/plugins/builtin/cloud/plugin.tsx +185 -0
- package/src/plugins/builtin/cloud-tweets/footer.ts +40 -0
- package/src/plugins/builtin/cloud-tweets/index.ts +1 -0
- package/src/plugins/builtin/cloud-tweets/keyboard.ts +65 -0
- package/src/plugins/builtin/cloud-tweets/model.ts +257 -0
- package/src/plugins/builtin/cloud-tweets/pane.tsx +318 -0
- package/src/plugins/builtin/cloud-tweets/registration.ts +87 -0
- package/src/plugins/builtin/cloud-tweets/search-bar.tsx +49 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +331 -0
- package/src/plugins/builtin/comparison-chart/index.test.tsx +645 -0
- package/src/plugins/builtin/comparison-chart/index.tsx +194 -0
- package/src/plugins/builtin/congress-trades/detail.tsx +154 -0
- package/src/plugins/builtin/congress-trades/footer.ts +67 -0
- package/src/plugins/builtin/congress-trades/keyboard.ts +112 -0
- package/src/plugins/builtin/congress-trades/model.ts +224 -0
- package/src/plugins/builtin/congress-trades/pane.tsx +331 -0
- package/src/plugins/builtin/congress-trades/table.tsx +84 -0
- package/src/plugins/builtin/correlation/compute.ts +0 -7
- package/src/plugins/builtin/correlation/index.test.tsx +5 -5
- package/src/plugins/builtin/correlation/index.tsx +36 -208
- package/src/plugins/builtin/correlation/matrix/model.ts +155 -0
- package/src/plugins/builtin/correlation/matrix/symbol-cell.tsx +56 -0
- package/src/plugins/builtin/correlation/relationship/controls.tsx +53 -0
- package/src/plugins/builtin/correlation/relationship/history.ts +72 -0
- package/src/plugins/builtin/correlation/relationship/model.ts +279 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +359 -0
- package/src/plugins/builtin/correlation/relationship/view-model.ts +120 -0
- package/src/plugins/builtin/correlation/settings.ts +6 -6
- package/src/plugins/builtin/debug/index.tsx +365 -0
- package/src/plugins/builtin/earnings/data/cache.test.ts +94 -0
- package/src/plugins/builtin/earnings/data/cache.ts +145 -0
- package/src/plugins/builtin/earnings/data/data.test.ts +90 -0
- package/src/plugins/builtin/earnings/data/data.ts +115 -0
- package/src/plugins/builtin/earnings/index.test.ts +12 -0
- package/src/plugins/builtin/earnings/index.tsx +74 -266
- package/src/plugins/builtin/earnings/model.ts +82 -0
- package/src/plugins/builtin/earnings/table.ts +206 -0
- package/src/plugins/builtin/econ/calendar-model.test.ts +48 -0
- package/src/plugins/builtin/econ/calendar-model.ts +217 -0
- package/src/plugins/builtin/econ/calendar-source.ts +1 -1
- package/src/plugins/builtin/econ/detail-view.tsx +319 -0
- package/src/plugins/builtin/econ/fred-cache.test.ts +58 -0
- package/src/plugins/builtin/econ/fred-cache.ts +106 -0
- package/src/plugins/builtin/econ/fred-series-map.ts +0 -4
- package/src/plugins/builtin/econ/index.tsx +46 -474
- package/src/plugins/builtin/fear-greed/cache.test.ts +75 -0
- package/src/plugins/builtin/fear-greed/cache.ts +142 -0
- package/src/plugins/builtin/fear-greed/charts.tsx +305 -0
- package/src/plugins/builtin/fear-greed/data.test.ts +72 -0
- package/src/plugins/builtin/fear-greed/data.ts +370 -0
- package/src/plugins/builtin/fear-greed/format.ts +96 -0
- package/src/plugins/builtin/fear-greed/index.tsx +13 -555
- package/src/plugins/builtin/fear-greed/pane.tsx +169 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/pairs.ts +0 -22
- package/src/plugins/builtin/help/components.tsx +92 -0
- package/src/plugins/builtin/help/index.test.tsx +167 -0
- package/src/plugins/builtin/help/index.tsx +256 -0
- package/src/plugins/builtin/help/shortcut-model.ts +145 -0
- package/src/plugins/builtin/holders/format.ts +44 -0
- package/src/plugins/builtin/holders/index.test.ts +1 -46
- package/src/plugins/builtin/holders/index.tsx +3 -955
- package/src/plugins/builtin/holders/pane.tsx +331 -0
- package/src/plugins/builtin/holders/table-model.ts +84 -0
- package/src/plugins/builtin/holders/thirteenf-match.ts +76 -0
- package/src/plugins/builtin/holders/treemap-layout.ts +231 -0
- package/src/plugins/builtin/holders/treemap.tsx +318 -0
- package/src/plugins/builtin/holders/types.ts +51 -0
- package/src/plugins/builtin/insider/index.tsx +5 -5
- package/src/plugins/builtin/layout-manager/index.tsx +247 -0
- package/src/plugins/builtin/market-movers/index.tsx +44 -282
- package/src/plugins/builtin/market-movers/model.ts +146 -0
- package/src/plugins/builtin/market-movers/screener.test.ts +31 -1
- package/src/plugins/builtin/market-movers/screener.ts +106 -12
- package/src/plugins/builtin/market-movers/table.ts +95 -0
- package/src/plugins/builtin/news/index.tsx +194 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.test.ts +98 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.ts +110 -0
- package/src/plugins/builtin/news/wire/breaking/pane.test.tsx +156 -0
- package/src/plugins/builtin/news/wire/breaking/pane.tsx +68 -0
- package/src/plugins/builtin/news/wire/categories.ts +114 -0
- package/src/plugins/builtin/news/wire/default-feeds.ts +3 -0
- package/src/plugins/builtin/news/wire/feed-config.test.ts +90 -0
- package/src/plugins/builtin/news/wire/feed-config.ts +216 -0
- package/src/plugins/builtin/news/wire/index.tsx +129 -0
- package/src/plugins/builtin/news/wire/industry-pane.tsx +126 -0
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +306 -0
- package/src/plugins/builtin/news/wire/news/footer.ts +77 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +98 -0
- package/src/plugins/builtin/news/wire/news/query-presets.ts +40 -0
- package/src/plugins/builtin/news/wire/news/table.test.tsx +157 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +270 -0
- package/src/plugins/builtin/news/wire/persisted-articles.ts +98 -0
- package/src/plugins/builtin/news/wire/read-state.ts +76 -0
- package/src/plugins/builtin/news/wire/rss/parser.test.ts +116 -0
- package/src/plugins/builtin/news/wire/rss/parser.ts +213 -0
- package/src/plugins/builtin/news/wire/rss/source.test.ts +104 -0
- package/src/plugins/builtin/news/wire/rss/source.ts +181 -0
- package/src/plugins/builtin/notes/index.tsx +49 -0
- package/src/plugins/builtin/notes/markdown-note-preview.tsx +39 -0
- package/src/plugins/builtin/notes/model.ts +36 -0
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +334 -0
- package/src/plugins/builtin/notes/text-state.ts +11 -0
- package/src/plugins/builtin/notes/ticker-notes-tab.tsx +112 -0
- package/src/plugins/builtin/options/index.tsx +44 -0
- package/src/plugins/builtin/options/table.ts +209 -0
- package/src/plugins/builtin/options/types.ts +33 -0
- package/src/plugins/builtin/options/view.test.tsx +185 -0
- package/src/plugins/builtin/options/view.tsx +264 -0
- package/src/plugins/builtin/plugin-groups.ts +25 -5
- package/src/plugins/builtin/portfolio-list/account-metrics.test.ts +50 -0
- package/src/plugins/builtin/portfolio-list/account-metrics.ts +46 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +203 -0
- package/src/plugins/builtin/portfolio-list/cli/shared.ts +21 -0
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/column-values.ts +284 -0
- package/src/plugins/builtin/portfolio-list/command-bar.ts +1 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +7 -98
- package/src/plugins/builtin/portfolio-list/index.test.ts +133 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/metrics.test.ts +242 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +5 -462
- package/src/plugins/builtin/portfolio-list/pane/data.ts +171 -0
- package/src/plugins/builtin/portfolio-list/pane/index.test.tsx +1267 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +385 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +159 -0
- package/src/plugins/builtin/portfolio-list/position-metrics.ts +123 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +326 -0
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +135 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +5 -3
- package/src/plugins/builtin/portfolio-list/summary/index.test.ts +126 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +392 -0
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +86 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/use-throttled-cursor-symbol.ts +1 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +383 -0
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +413 -0
- package/src/plugins/builtin/research/index.test.ts +248 -2
- package/src/plugins/builtin/research/index.tsx +30 -760
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +189 -0
- package/src/plugins/builtin/sec/filing-display.tsx +84 -0
- package/src/plugins/builtin/sec/index.tsx +342 -0
- package/src/plugins/builtin/sectors/index.tsx +27 -234
- package/src/plugins/builtin/sectors/sector-data.ts +0 -2
- package/src/plugins/builtin/sectors/sector-model.ts +221 -0
- package/src/plugins/builtin/shared/table-pane.ts +31 -0
- package/src/plugins/builtin/shared/ticker-request.ts +70 -0
- package/src/plugins/builtin/shared/ticker-surface.test.ts +57 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +113 -0
- package/src/plugins/builtin/thirteenf/api.test.ts +58 -0
- package/src/plugins/builtin/thirteenf/api.ts +375 -0
- package/src/plugins/builtin/thirteenf/data.test.ts +95 -0
- package/src/plugins/builtin/thirteenf/data.ts +210 -0
- package/src/plugins/builtin/thirteenf/format.ts +55 -0
- package/src/plugins/builtin/thirteenf/index.tsx +80 -0
- package/src/plugins/builtin/thirteenf/model.test.ts +156 -0
- package/src/plugins/builtin/thirteenf/model.ts +618 -0
- package/src/plugins/builtin/thirteenf/pane.test.tsx +328 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +826 -0
- package/src/plugins/builtin/thirteenf/table.ts +212 -0
- package/src/plugins/builtin/thirteenf/types.ts +187 -0
- package/src/plugins/builtin/ticker-detail/chart-pane.tsx +91 -0
- package/src/plugins/builtin/ticker-detail/chart-tab-switch.test.tsx +282 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +3 -5
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/content.tsx +158 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/data.ts +62 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/model.ts +234 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/settings.ts +44 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/types.ts +51 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph.tsx +135 -0
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +192 -0
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +172 -0
- package/src/plugins/builtin/ticker-detail/data-panes.test.ts +110 -0
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +203 -0
- package/src/plugins/builtin/ticker-detail/financials/model.test.ts +84 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +364 -0
- package/src/plugins/builtin/ticker-detail/financials/pane.tsx +27 -0
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +392 -0
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +438 -0
- package/src/plugins/builtin/ticker-detail/index.test.tsx +780 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +174 -17
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +240 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +168 -0
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -0
- package/src/plugins/builtin/ticker-detail/overview/types.ts +17 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +27 -392
- package/src/plugins/builtin/ticker-detail/pane.tsx +24 -136
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +330 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.test.tsx +292 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +180 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +39 -33
- package/src/plugins/builtin/world-indices/footer.ts +28 -0
- package/src/plugins/builtin/world-indices/index.tsx +25 -218
- package/src/plugins/builtin/world-indices/model.ts +120 -0
- package/src/plugins/builtin/world-indices/table.tsx +96 -0
- package/src/plugins/builtin/yahoo/index.ts +72 -0
- package/src/plugins/builtin/yield-curve/index.tsx +5 -5
- package/src/plugins/builtin/yield-curve/treasury-data.ts +1 -1
- package/src/plugins/catalog-ui.ts +7 -9
- package/src/plugins/catalog.ts +1 -1
- package/src/plugins/ibkr/account-cache.ts +2 -10
- package/src/plugins/ibkr/broker-adapter.ts +10 -4
- package/src/plugins/ibkr/config.ts +5 -24
- package/src/plugins/ibkr/dialogs.tsx +0 -1
- package/src/plugins/ibkr/flex/index.test.ts +236 -0
- package/src/plugins/ibkr/flex/index.ts +337 -0
- package/src/plugins/ibkr/flex/statement-client.ts +181 -0
- package/src/plugins/ibkr/gateway/account-loaders.ts +266 -0
- package/src/plugins/ibkr/gateway/account-summary.ts +163 -0
- package/src/plugins/ibkr/gateway/client-lock.ts +154 -0
- package/src/plugins/ibkr/gateway/connection-events.ts +114 -0
- package/src/plugins/ibkr/gateway/connection.ts +152 -0
- package/src/plugins/ibkr/gateway/contracts.ts +132 -0
- package/src/plugins/ibkr/gateway/fundamentals.ts +83 -0
- package/src/plugins/ibkr/gateway/helpers.ts +33 -0
- package/src/plugins/ibkr/gateway/history-requests.ts +158 -0
- package/src/plugins/ibkr/gateway/history.ts +120 -0
- package/src/plugins/ibkr/gateway/instrument-lookup.ts +117 -0
- package/src/plugins/ibkr/gateway/market-data.ts +338 -0
- package/src/plugins/ibkr/gateway/order-execution.ts +218 -0
- package/src/plugins/ibkr/gateway/orders.ts +63 -0
- package/src/plugins/ibkr/gateway/price-normalization.test.ts +44 -0
- package/src/plugins/ibkr/gateway/price-normalization.ts +50 -0
- package/src/plugins/ibkr/gateway/quote-stream-controller.ts +203 -0
- package/src/plugins/ibkr/gateway/quote-stream.ts +171 -0
- package/src/plugins/ibkr/gateway/selection.ts +51 -0
- package/src/plugins/ibkr/gateway/service/index.test.ts +614 -0
- package/src/plugins/ibkr/gateway/service/index.ts +432 -0
- package/src/plugins/ibkr/gateway/service/lifecycle.ts +191 -0
- package/src/plugins/ibkr/gateway/service/manager.ts +52 -0
- package/src/plugins/ibkr/gateway/service/market-data.ts +48 -0
- package/src/plugins/ibkr/gateway/service/native.ts +543 -0
- package/src/plugins/ibkr/gateway/timeouts.ts +13 -0
- package/src/plugins/ibkr/gateway/types.ts +27 -0
- package/src/plugins/ibkr/hash.ts +8 -0
- package/src/plugins/ibkr/index.test.tsx +1 -12
- package/src/plugins/ibkr/index.tsx +8 -9
- package/src/plugins/ibkr/instance-selection.test.ts +2 -2
- package/src/plugins/ibkr/instance-selection.ts +1 -1
- package/src/plugins/ibkr/portfolio-performance.test.ts +32 -0
- package/src/plugins/ibkr/portfolio-performance.ts +129 -0
- package/src/plugins/ibkr/trade/badge.tsx +28 -0
- package/src/plugins/ibkr/trade/dialogs.tsx +44 -0
- package/src/plugins/ibkr/trade/preview-panel.tsx +130 -0
- package/src/plugins/ibkr/trade/tab/actions.tsx +443 -0
- package/src/plugins/ibkr/trade/tab/field-editors.tsx +79 -0
- package/src/plugins/ibkr/trade/tab/footer.ts +67 -0
- package/src/plugins/ibkr/trade/tab/header.tsx +167 -0
- package/src/plugins/ibkr/trade/tab/index.test.tsx +178 -0
- package/src/plugins/ibkr/trade/tab/index.tsx +302 -0
- package/src/plugins/ibkr/trade/tab/model.ts +159 -0
- package/src/plugins/ibkr/trade/tab/order-request.ts +64 -0
- package/src/plugins/ibkr/trade/tab/shortcuts.ts +89 -0
- package/src/plugins/ibkr/trade/tab/state-sync.ts +86 -0
- package/src/plugins/ibkr/trade/ticket-panel.tsx +301 -0
- package/src/plugins/ibkr/trade/utils.test.ts +175 -0
- package/src/plugins/ibkr/trade/utils.ts +150 -0
- package/src/plugins/ibkr/trading/pane-view.tsx +175 -0
- package/src/plugins/ibkr/trading/pane.tsx +332 -0
- package/src/plugins/ibkr/trading/state.test.ts +109 -0
- package/src/plugins/ibkr/trading/state.ts +335 -0
- package/src/plugins/pane-manager/dock-tree.ts +282 -0
- package/src/plugins/pane-manager/docking.ts +202 -0
- package/src/plugins/pane-manager/floating-actions.ts +158 -0
- package/src/plugins/pane-manager/floating.ts +76 -0
- package/src/plugins/pane-manager/gridlock-inference.ts +126 -0
- package/src/plugins/pane-manager/gridlock.ts +34 -0
- package/src/plugins/pane-manager/layout-state.ts +160 -0
- package/src/plugins/pane-manager/queries.ts +75 -0
- package/src/plugins/pane-manager/types.ts +24 -0
- package/src/plugins/pane-manager.test.ts +110 -4
- package/src/plugins/pane-manager.ts +57 -1035
- package/src/plugins/prediction-markets/chart.test.tsx +2 -2
- package/src/plugins/prediction-markets/controller/catalog.ts +317 -0
- package/src/plugins/prediction-markets/controller/data.ts +171 -0
- package/src/plugins/prediction-markets/controller/detail.ts +243 -0
- package/src/plugins/prediction-markets/controller/effects.ts +253 -0
- package/src/plugins/prediction-markets/controller/index.ts +374 -0
- package/src/plugins/prediction-markets/controller/keyboard.ts +220 -0
- package/src/plugins/prediction-markets/controller/live-updates.ts +85 -0
- package/src/plugins/prediction-markets/controller/selection.ts +59 -0
- package/src/plugins/prediction-markets/controller/status.ts +104 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +1 -1
- package/src/plugins/prediction-markets/metrics.ts +4 -14
- package/src/plugins/prediction-markets/navigation.ts +0 -13
- package/src/plugins/prediction-markets/pane.test.tsx +2 -198
- package/src/plugins/prediction-markets/plugin.test.tsx +2 -2
- package/src/plugins/prediction-markets/services/fetch.ts +1 -5
- package/src/plugins/prediction-markets/services/kalshi/adapter.ts +299 -0
- package/src/plugins/prediction-markets/services/kalshi/normalize.ts +209 -0
- package/src/plugins/prediction-markets/services/kalshi/types.ts +89 -0
- package/src/plugins/prediction-markets/services/polymarket/adapter.ts +134 -0
- package/src/plugins/prediction-markets/services/polymarket/detail.ts +307 -0
- package/src/plugins/prediction-markets/services/polymarket/normalize.ts +239 -0
- package/src/plugins/prediction-markets/services/polymarket/types.ts +66 -0
- package/src/plugins/prediction-markets/services/polymarket/ws.ts +128 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +12 -76
- package/src/plugins/prediction-markets/types.ts +2 -2
- package/src/plugins/registry/context-menu.ts +36 -0
- package/src/plugins/registry/context.ts +196 -0
- package/src/plugins/registry/contributions.ts +174 -0
- package/src/plugins/registry/index.test.ts +362 -0
- package/src/plugins/registry/index.ts +474 -0
- package/src/plugins/registry/pane-settings.ts +105 -0
- package/src/plugins/registry/plugin-state.ts +123 -0
- package/src/plugins/registry/shared.ts +34 -0
- package/src/plugins/registry/slots.ts +70 -0
- package/src/plugins/runtime/context.tsx +115 -0
- package/src/plugins/runtime/index.test.tsx +328 -0
- package/src/plugins/runtime/index.tsx +111 -0
- package/src/plugins/runtime/state.ts +275 -0
- package/src/plugins/ticker-navigation.test.ts +23 -2
- package/src/plugins/ticker-navigation.ts +9 -3
- package/src/react/input.test.ts +29 -0
- package/src/react/input.ts +9 -0
- package/src/renderers/electrobun/bun/application-menu/click.test.ts +50 -0
- package/src/renderers/electrobun/bun/application-menu/click.ts +58 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +123 -0
- package/src/renderers/electrobun/bun/context-menu/click.test.ts +67 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.test.ts +52 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.ts +67 -0
- package/src/renderers/electrobun/bun/core-capabilities.ts +3 -0
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +163 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +93 -0
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +263 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +114 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +56 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +139 -0
- package/src/renderers/electrobun/bun/desktop/plugin-state.ts +92 -0
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +48 -0
- package/src/renderers/electrobun/bun/desktop/rpc-registry.ts +43 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +76 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +162 -0
- package/src/renderers/electrobun/bun/desktop/window-events.ts +49 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.test.ts +63 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +180 -0
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +97 -0
- package/src/renderers/electrobun/bun/index.ts +191 -947
- package/src/renderers/electrobun/bun/tui-entry.ts +6 -0
- package/src/renderers/electrobun/bun/window/focus.ts +37 -0
- package/src/renderers/electrobun/bun/window/frame.test.ts +40 -0
- package/src/renderers/electrobun/shared/protocol.ts +9 -2
- package/src/renderers/electrobun/view/app-services.ts +4 -375
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -0
- package/src/renderers/electrobun/view/build-assets.ts +117 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +398 -0
- package/src/renderers/electrobun/view/config-host.ts +1 -1
- package/src/renderers/electrobun/view/context-menu.test.ts +10 -4
- package/src/renderers/electrobun/view/context-menu.ts +1 -1
- package/src/renderers/electrobun/view/data-table/dom.ts +211 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +358 -0
- package/src/renderers/electrobun/view/data-table/row.tsx +335 -0
- package/src/renderers/electrobun/view/desktop/control-styles.ts +77 -0
- package/src/renderers/electrobun/view/desktop/controls.tsx +421 -0
- package/src/renderers/electrobun/view/desktop/list-view.tsx +200 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +70 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.test.ts +57 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.ts +41 -0
- package/src/renderers/electrobun/view/fatal-screen.tsx +118 -0
- package/src/renderers/electrobun/view/host/box.tsx +160 -0
- package/src/renderers/electrobun/view/host/chart-surface.tsx +142 -0
- package/src/renderers/electrobun/view/host/input.tsx +294 -0
- package/src/renderers/electrobun/view/host/mouse.ts +139 -0
- package/src/renderers/electrobun/view/host/native.ts +49 -0
- package/src/renderers/electrobun/view/host/scroll-box.tsx +276 -0
- package/src/renderers/electrobun/view/host/style.ts +124 -0
- package/src/renderers/electrobun/view/host/tabs.tsx +255 -0
- package/src/renderers/electrobun/view/host/text.tsx +121 -0
- package/src/renderers/electrobun/view/http-fetch.ts +1 -1
- package/src/renderers/electrobun/view/input-host.tsx +12 -1
- package/src/renderers/electrobun/view/main.tsx +45 -26
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +59 -0
- package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +9 -0
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +201 -0
- package/src/renderers/electrobun/view/remote/persistence.ts +158 -0
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +26 -0
- package/src/renderers/electrobun/view/styles.css +91 -4
- package/src/renderers/electrobun/view/ui-host.tsx +22 -1469
- package/src/renderers/opentui/chart-surface.tsx +4 -5
- package/src/renderers/opentui/host.tsx +30 -4
- package/src/renderers/opentui/image/loader.test.ts +25 -0
- package/src/renderers/opentui/image/loader.ts +105 -0
- package/src/renderers/opentui/image/surface.tsx +266 -0
- package/src/renderers/opentui/input-host.tsx +12 -1
- package/src/renderers/opentui/start.tsx +2 -2
- package/src/renderers/opentui/test-utils.tsx +2 -2
- package/src/renderers/opentui/ui-host.tsx +1 -1
- package/src/sources/gloomberb-cloud/index.test.ts +660 -0
- package/src/sources/gloomberb-cloud/index.ts +444 -0
- package/src/sources/gloomberb-cloud/news.ts +127 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +354 -0
- package/src/sources/provider-errors.ts +8 -2
- package/src/sources/provider-router/batches.ts +170 -0
- package/src/sources/provider-router/brokers.ts +114 -0
- package/src/sources/provider-router/cache.ts +171 -0
- package/src/sources/provider-router/cached-financials.test.ts +498 -0
- package/src/sources/provider-router/document-routes.ts +153 -0
- package/src/sources/provider-router/financial-routes.ts +225 -0
- package/src/sources/provider-router/financials.ts +259 -0
- package/src/sources/provider-router/history.test.ts +383 -0
- package/src/sources/provider-router/history.ts +448 -0
- package/src/sources/provider-router/index.test.ts +1438 -0
- package/src/sources/provider-router/index.ts +389 -0
- package/src/sources/provider-router/news.ts +36 -0
- package/src/sources/provider-router/primary.ts +164 -0
- package/src/sources/provider-router/route-types.ts +34 -0
- package/src/sources/provider-router/routing.ts +58 -0
- package/src/sources/provider-router/search.ts +183 -0
- package/src/sources/provider-router/sources.ts +55 -0
- package/src/sources/provider-router/streaming.ts +92 -0
- package/src/sources/provider-router/supplemental.ts +373 -0
- package/src/sources/provider-router/test-support.ts +136 -0
- package/src/sources/sec-edgar/content.ts +211 -0
- package/src/sources/sec-edgar.ts +9 -217
- package/src/sources/yahoo-finance/financials.ts +339 -0
- package/src/sources/yahoo-finance/history.ts +106 -0
- package/src/sources/yahoo-finance/http.ts +100 -0
- package/src/sources/yahoo-finance/mappers.ts +409 -0
- package/src/sources/yahoo-finance/options.ts +134 -0
- package/src/sources/yahoo-finance/quote-summary.ts +210 -0
- package/src/sources/yahoo-finance/requests.ts +192 -0
- package/src/sources/yahoo-finance/snapshots.ts +236 -0
- package/src/sources/yahoo-finance/symbols.ts +102 -0
- package/src/sources/yahoo-finance/types.ts +167 -0
- package/src/sources/yahoo-finance.test.ts +116 -12
- package/src/sources/yahoo-finance.ts +115 -1408
- package/src/state/app/activity.test.ts +41 -0
- package/src/state/app/activity.ts +106 -0
- package/src/state/app/bootstrap.test.ts +498 -0
- package/src/state/app/bootstrap.ts +412 -0
- package/src/state/app/context/index.test.ts +564 -0
- package/src/state/app/context/index.test.tsx +193 -0
- package/src/state/app/context/index.tsx +476 -0
- package/src/state/app/context/selector.test.tsx +291 -0
- package/src/state/config-save-scheduler.ts +2 -6
- package/src/state/hooks/inline-tickers.test.tsx +123 -0
- package/src/state/hooks/inline-tickers.ts +212 -0
- package/src/state/hooks/quote-streaming.test.ts +31 -0
- package/src/state/hooks/quote-streaming.test.tsx +70 -0
- package/src/state/hooks/quote-streaming.ts +92 -0
- package/src/state/hooks/session-snapshot.ts +99 -0
- package/src/state/pane-scroll-registry.tsx +1 -1
- package/src/state/selectors-ui.ts +1 -1
- package/src/state/selectors.ts +1 -1
- package/src/test-support/plugin-persistence.ts +112 -0
- package/src/test-support/plugin-runtime.ts +2 -1
- package/src/theme/colors.ts +23 -9
- package/src/theme/themes.test.ts +15 -0
- package/src/tickers/list.test.ts +16 -0
- package/src/tickers/open-target.ts +77 -0
- package/src/tickers/search/index.test.ts +252 -0
- package/src/tickers/search/index.ts +367 -0
- package/src/tickers/search/ranking.ts +387 -0
- package/src/tickers/search/result.ts +27 -0
- package/src/tickers/search/types.ts +41 -0
- package/src/tickers/search/upsert.ts +91 -0
- package/src/tickers/tokenizer.test.ts +31 -0
- package/src/tickers/tokenizer.ts +37 -0
- package/src/types/broker.ts +12 -4
- package/src/types/config.ts +42 -23
- package/src/types/context-menu.ts +1 -1
- package/src/types/data-provider.ts +2 -2
- package/src/types/desktop-window.ts +1 -1
- package/src/types/financials.ts +109 -4
- package/src/types/news-source.ts +0 -1
- package/src/types/persistence.ts +1 -1
- package/src/types/plugin.ts +37 -21
- package/src/types/ticker.ts +1 -0
- package/src/types/trading.ts +23 -1
- package/src/ui/context-menu.tsx +6 -5
- package/src/ui/dialog.tsx +6 -3
- package/src/ui/host.tsx +10 -10
- package/src/ui/index.tsx +14 -33
- package/src/updater/github-releases.test.ts +41 -0
- package/src/updater/github-releases.ts +73 -0
- package/src/updater.test.ts +21 -0
- package/src/updater.ts +10 -3
- package/src/utils/back-navigation.ts +2 -2
- package/src/utils/cli-output.ts +4 -4
- package/src/utils/currency-units.test.ts +23 -1
- package/src/utils/currency-units.ts +56 -0
- package/src/utils/datetime-format.ts +40 -0
- package/src/utils/dom-screenshot.ts +2 -2
- package/src/utils/double-escape-close.ts +1 -1
- package/src/utils/exchanges.ts +2 -2
- package/src/utils/format.ts +0 -7
- package/src/utils/fuzzy-search.ts +1 -1
- package/src/utils/inline-content-tokenizer.test.ts +11 -2
- package/src/utils/inline-content-tokenizer.ts +33 -12
- package/src/utils/keyboard.ts +1 -1
- package/src/utils/link-tokenizer.ts +2 -2
- package/src/utils/options.ts +1 -1
- package/src/utils/price-history.test.ts +20 -0
- package/src/utils/price-history.ts +24 -2
- package/src/utils/relative-time.ts +8 -0
- package/src/utils/selection-clipboard.ts +1 -1
- package/src/utils/shortcut-labels.ts +2 -2
- package/src/utils/sort-values.ts +17 -0
- package/src/utils/terminal-input-reset.ts +1 -1
- package/src/utils/text-wrap.ts +20 -0
- package/src/version.ts +1 -1
- package/src/components/chart/chart-controller.test.ts +0 -110
- package/src/components/chart/chart-controller.ts +0 -650
- package/src/components/chart/chart-data.ts +0 -350
- package/src/components/chart/chart-indicator-selector.tsx +0 -75
- package/src/components/chart/chart-pane-settings.ts +0 -37
- package/src/components/chart/chart-renderer.ts +0 -1562
- package/src/components/chart/chart-resolution.test.ts +0 -87
- package/src/components/chart/chart-resolution.ts +0 -405
- package/src/components/chart/chart-scroll.test.ts +0 -70
- package/src/components/chart/chart-scroll.ts +0 -104
- package/src/components/chart/chart-types.ts +0 -119
- package/src/components/chart/chart-viewport.test.ts +0 -29
- package/src/components/chart/chart-viewport.ts +0 -50
- package/src/components/chart/chart.test.ts +0 -922
- package/src/components/chart/comparison-chart-data.test.ts +0 -105
- package/src/components/chart/comparison-chart-data.ts +0 -292
- package/src/components/chart/comparison-chart-renderer.test.ts +0 -187
- package/src/components/chart/comparison-chart-renderer.ts +0 -437
- package/src/components/chart/native/kitty-adapter.ts +0 -9
- package/src/components/chart/native/kitty-manager.ts +0 -142
- package/src/components/chart/native/kitty-support.ts +0 -71
- package/src/components/chart/native/kitty.test.ts +0 -728
- package/src/components/chart/native/surface-manager.ts +0 -225
- package/src/components/chart/native/surface-sync.ts +0 -34
- package/src/components/chart/native/surface-visibility.ts +0 -48
- package/src/components/chart/static-chart-surface.test.tsx +0 -51
- package/src/components/chart/static-chart-surface.tsx +0 -217
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +0 -1323
- package/src/components/chart/stock-chart.test.ts +0 -330
- package/src/components/chart/stock-chart.tsx +0 -4148
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +0 -109
- package/src/components/command-bar/command-bar.test.tsx +0 -3244
- package/src/components/command-bar/command-bar.tsx +0 -5868
- package/src/components/command-bar/command-registry.ts +0 -267
- package/src/components/command-bar/confirm-body.tsx +0 -51
- package/src/components/command-bar/list-model.ts +0 -80
- package/src/components/command-bar/pane-template-display.ts +0 -8
- package/src/components/command-bar/root-shortcuts.ts +0 -188
- package/src/components/command-bar/workflow-ops.test.ts +0 -144
- package/src/components/command-bar/workflow-ops.ts +0 -459
- package/src/components/command-bar/workflow-types.ts +0 -127
- package/src/components/data-table-stack-view.test.tsx +0 -241
- package/src/components/data-table-stack-view.tsx +0 -59
- package/src/components/data-table-view.test.tsx +0 -211
- package/src/components/data-table-view.tsx +0 -244
- package/src/components/feed-data-table-stack-view.test.tsx +0 -225
- package/src/components/feed-data-table-stack-view.tsx +0 -359
- package/src/components/layout/pane-content.test.tsx +0 -64
- package/src/components/layout/pane-content.tsx +0 -44
- package/src/components/layout/pane-cycle-order.test.ts +0 -30
- package/src/components/layout/pane-cycle-order.ts +0 -32
- package/src/components/layout/pane-footer.test.tsx +0 -195
- package/src/components/layout/pane-footer.tsx +0 -432
- package/src/components/layout/pane-header.test.tsx +0 -39
- package/src/components/layout/pane-header.tsx +0 -248
- package/src/components/layout/pane-keyboard-scroll.test.tsx +0 -226
- package/src/components/layout/pane-sizing.ts +0 -34
- package/src/components/layout/pane-title.ts +0 -38
- package/src/components/layout/pane.tsx +0 -129
- package/src/components/layout/shell.test.tsx +0 -1427
- package/src/components/layout/shell.tsx +0 -1912
- package/src/components/price-sparkline-view.tsx +0 -463
- package/src/components/price-sparkline.ts +0 -46
- package/src/components/speedometer-gauge.test.tsx +0 -45
- package/src/components/speedometer-gauge.tsx +0 -562
- package/src/components/ticker-badge-list.tsx +0 -53
- package/src/components/ticker-badge-text.test.tsx +0 -253
- package/src/components/ticker-badge-text.tsx +0 -113
- package/src/components/ticker-badge.tsx +0 -109
- package/src/components/ticker-list-table-view.tsx +0 -233
- package/src/components/ticker-list-table.test.tsx +0 -210
- package/src/components/ticker-list-table.tsx +0 -458
- package/src/components/ui/data-table.tsx +0 -522
- package/src/components/ui/multi-select-dialog.tsx +0 -336
- package/src/core/state/app-state.ts +0 -1009
- package/src/data/config-layout.ts +0 -225
- package/src/data/config-store-node.ts +0 -478
- package/src/data/config-store.test.ts +0 -481
- package/src/data/config-store.ts +0 -64
- package/src/data/sqlite-cache.test.ts +0 -151
- package/src/data/sqlite-database.ts +0 -68
- package/src/data/sqlite-json.ts +0 -16
- package/src/data/sqlite-retry.test.ts +0 -63
- package/src/market-data/coordinator-subscriptions.test.ts +0 -209
- package/src/market-data/coordinator.test.ts +0 -830
- package/src/market-data/coordinator.ts +0 -1155
- package/src/plugins/builtin/ai/screener-contract.test.ts +0 -117
- package/src/plugins/builtin/ai/screener-contract.ts +0 -174
- package/src/plugins/builtin/ai/screener-pane.test.tsx +0 -348
- package/src/plugins/builtin/ai/screener-pane.tsx +0 -1118
- package/src/plugins/builtin/ai/utils.ts +0 -1
- package/src/plugins/builtin/ask-ai.test.tsx +0 -348
- package/src/plugins/builtin/chat-controller.test.ts +0 -1376
- package/src/plugins/builtin/chat-controller.ts +0 -1248
- package/src/plugins/builtin/chat.test.tsx +0 -2245
- package/src/plugins/builtin/chat.tsx +0 -2267
- package/src/plugins/builtin/cloud-auth-actions.tsx +0 -72
- package/src/plugins/builtin/cloud-tweets.tsx +0 -896
- package/src/plugins/builtin/comparison-chart.test.tsx +0 -532
- package/src/plugins/builtin/comparison-chart.tsx +0 -194
- package/src/plugins/builtin/debug.tsx +0 -365
- package/src/plugins/builtin/earnings/earnings-cache.test.ts +0 -181
- package/src/plugins/builtin/earnings/earnings-cache.ts +0 -145
- package/src/plugins/builtin/earnings/earnings-data.test.ts +0 -90
- package/src/plugins/builtin/earnings/earnings-data.ts +0 -115
- package/src/plugins/builtin/fear-greed/fear-greed-data.test.ts +0 -72
- package/src/plugins/builtin/fear-greed/fear-greed-data.ts +0 -366
- package/src/plugins/builtin/help.test.tsx +0 -166
- package/src/plugins/builtin/help.tsx +0 -450
- package/src/plugins/builtin/layout-manager.tsx +0 -247
- package/src/plugins/builtin/manual-entry.tsx +0 -25
- package/src/plugins/builtin/news-wire/breaking-notifications.test.ts +0 -98
- package/src/plugins/builtin/news-wire/breaking-notifications.ts +0 -110
- package/src/plugins/builtin/news-wire/breaking-pane.test.tsx +0 -156
- package/src/plugins/builtin/news-wire/breaking-pane.tsx +0 -68
- package/src/plugins/builtin/news-wire/categories.ts +0 -114
- package/src/plugins/builtin/news-wire/default-feeds.ts +0 -3
- package/src/plugins/builtin/news-wire/feed-config.test.ts +0 -90
- package/src/plugins/builtin/news-wire/feed-config.ts +0 -216
- package/src/plugins/builtin/news-wire/index.tsx +0 -129
- package/src/plugins/builtin/news-wire/industry-pane.tsx +0 -126
- package/src/plugins/builtin/news-wire/news-detail-view.tsx +0 -299
- package/src/plugins/builtin/news-wire/news-footer.ts +0 -28
- package/src/plugins/builtin/news-wire/news-preset-pane.tsx +0 -98
- package/src/plugins/builtin/news-wire/news-query-presets.ts +0 -40
- package/src/plugins/builtin/news-wire/news-table.test.tsx +0 -206
- package/src/plugins/builtin/news-wire/news-table.tsx +0 -296
- package/src/plugins/builtin/news-wire/persisted-articles.ts +0 -98
- package/src/plugins/builtin/news-wire/read-state.ts +0 -76
- package/src/plugins/builtin/news-wire/rss-parser.test.ts +0 -184
- package/src/plugins/builtin/news-wire/rss-parser.ts +0 -213
- package/src/plugins/builtin/news-wire/rss-source.test.ts +0 -159
- package/src/plugins/builtin/news-wire/rss-source.ts +0 -181
- package/src/plugins/builtin/news.tsx +0 -194
- package/src/plugins/builtin/notes.tsx +0 -561
- package/src/plugins/builtin/options.test.tsx +0 -241
- package/src/plugins/builtin/options.tsx +0 -542
- package/src/plugins/builtin/portfolio-list/cli/commands.ts +0 -657
- package/src/plugins/builtin/portfolio-list/pane.tsx +0 -724
- package/src/plugins/builtin/portfolio-list/quick-add.tsx +0 -422
- package/src/plugins/builtin/portfolio-list/summary.tsx +0 -275
- package/src/plugins/builtin/portfolio-list.test.ts +0 -133
- package/src/plugins/builtin/portfolio-list.test.tsx +0 -1535
- package/src/plugins/builtin/portfolio-metrics.test.ts +0 -236
- package/src/plugins/builtin/quote-monitor.test.tsx +0 -222
- package/src/plugins/builtin/sec-filing-display.tsx +0 -84
- package/src/plugins/builtin/sec.tsx +0 -342
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +0 -461
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +0 -479
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +0 -269
- package/src/plugins/builtin/ticker-detail.test.tsx +0 -888
- package/src/plugins/builtin/ticker-surface.ts +0 -68
- package/src/plugins/builtin/yahoo.ts +0 -72
- package/src/plugins/catalog-ui.test.ts +0 -24
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +0 -35
- package/src/plugins/ibkr/flex.test.ts +0 -162
- package/src/plugins/ibkr/flex.ts +0 -371
- package/src/plugins/ibkr/gateway-helpers.ts +0 -33
- package/src/plugins/ibkr/gateway-selection.ts +0 -51
- package/src/plugins/ibkr/gateway-service-native.ts +0 -2377
- package/src/plugins/ibkr/gateway-service.test.ts +0 -584
- package/src/plugins/ibkr/gateway-service.ts +0 -433
- package/src/plugins/ibkr/gateway-types.ts +0 -27
- package/src/plugins/ibkr/price-normalization.test.ts +0 -33
- package/src/plugins/ibkr/price-normalization.ts +0 -60
- package/src/plugins/ibkr/trade-badge.tsx +0 -28
- package/src/plugins/ibkr/trade-tab.test.tsx +0 -276
- package/src/plugins/ibkr/trade-tab.tsx +0 -1117
- package/src/plugins/ibkr/trade-utils.test.ts +0 -175
- package/src/plugins/ibkr/trade-utils.ts +0 -150
- package/src/plugins/ibkr/trading-pane.tsx +0 -474
- package/src/plugins/ibkr/trading-state.test.ts +0 -109
- package/src/plugins/ibkr/trading-state.ts +0 -339
- package/src/plugins/plugin-runtime.test.tsx +0 -323
- package/src/plugins/plugin-runtime.tsx +0 -433
- package/src/plugins/prediction-markets/controller-data.ts +0 -785
- package/src/plugins/prediction-markets/controller.ts +0 -659
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +0 -572
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +0 -696
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +0 -128
- package/src/plugins/registry.test.ts +0 -362
- package/src/plugins/registry.ts +0 -854
- package/src/renderers/electrobun/bun/application-menu-click.test.ts +0 -50
- package/src/renderers/electrobun/bun/application-menu-click.ts +0 -58
- package/src/renderers/electrobun/bun/application-menu.ts +0 -123
- package/src/renderers/electrobun/bun/context-menu-click.test.ts +0 -67
- package/src/renderers/electrobun/bun/context-menu-normalize.test.ts +0 -52
- package/src/renderers/electrobun/bun/context-menu-normalize.ts +0 -67
- package/src/renderers/electrobun/bun/desktop-workspace.test.ts +0 -63
- package/src/renderers/electrobun/bun/desktop-workspace.ts +0 -180
- package/src/renderers/electrobun/bun/window-focus.ts +0 -37
- package/src/renderers/electrobun/bun/window-frame.test.ts +0 -40
- package/src/renderers/electrobun/view/data-table.tsx +0 -810
- package/src/renderers/electrobun/view/desktop-controls.tsx +0 -673
- package/src/renderers/electrobun/view/desktop-window-bridge.ts +0 -70
- package/src/renderers/electrobun/view/desktop-window-snapshot.test.ts +0 -57
- package/src/renderers/electrobun/view/desktop-window-snapshot.ts +0 -41
- package/src/renderers/electrobun/view/native-stubs/chart-kitty-support.ts +0 -9
- package/src/renderers/opentui/image-loader.test.ts +0 -25
- package/src/renderers/opentui/image-loader.ts +0 -105
- package/src/renderers/opentui/image-surface.tsx +0 -266
- package/src/sources/gloomberb-cloud.test.ts +0 -637
- package/src/sources/gloomberb-cloud.ts +0 -828
- package/src/sources/provider-router.test.ts +0 -2600
- package/src/sources/provider-router.ts +0 -2231
- package/src/state/app-activity.test.ts +0 -41
- package/src/state/app-activity.ts +0 -106
- package/src/state/app-bootstrap.test.ts +0 -498
- package/src/state/app-bootstrap.ts +0 -411
- package/src/state/app-context-selector.test.tsx +0 -369
- package/src/state/app-context.test.ts +0 -670
- package/src/state/app-context.test.tsx +0 -193
- package/src/state/app-context.tsx +0 -485
- package/src/state/use-inline-tickers.test.tsx +0 -73
- package/src/state/use-inline-tickers.ts +0 -188
- package/src/state/use-quote-streaming.test.ts +0 -31
- package/src/state/use-quote-streaming.test.tsx +0 -70
- package/src/state/use-quote-streaming.ts +0 -92
- package/src/state/use-session-snapshot.ts +0 -99
- package/src/utils/api-client.test.ts +0 -603
- package/src/utils/api-client.ts +0 -1379
- package/src/utils/market-format.test.ts +0 -109
- package/src/utils/market-format.ts +0 -299
- package/src/utils/market-status.ts +0 -141
- package/src/utils/quote-freshness.test.ts +0 -150
- package/src/utils/quote-freshness.ts +0 -145
- package/src/utils/quote-resolution.test.ts +0 -277
- package/src/utils/quote-resolution.ts +0 -642
- package/src/utils/quote-time.test.ts +0 -34
- package/src/utils/quote-time.ts +0 -59
- package/src/utils/ticker-list.test.ts +0 -16
- package/src/utils/ticker-search.test.ts +0 -227
- package/src/utils/ticker-search.ts +0 -855
- package/src/utils/ticker-tokenizer.test.ts +0 -31
- package/src/utils/ticker-tokenizer.ts +0 -37
- /package/src/components/chart/native/{kitty-protocol.ts → kitty/protocol.ts} +0 -0
- /package/src/components/ui/{multi-select.ts → multi-select/index.ts} +0 -0
- /package/src/data/{sqlite-retry.ts → sqlite/retry.ts} +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/hash.ts +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/read-state.test.ts +0 -0
- /package/src/plugins/builtin/{notes-files.ts → notes/files.ts} +0 -0
- /package/src/renderers/electrobun/bun/{context-menu-click.ts → context-menu/click.ts} +0 -0
- /package/src/renderers/electrobun/bun/{window-frame.ts → window/frame.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-manager.ts → chart/surface-manager.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-sync.ts → chart/surface-sync.ts} +0 -0
- /package/src/{utils/ticker-list.ts → tickers/list.ts} +0 -0
- /package/src/{utils/ticker-metadata.ts → tickers/metadata.ts} +0 -0
|
@@ -1,2267 +0,0 @@
|
|
|
1
|
-
import { Box, ScrollBox, Span, Text, useUiCapabilities } from "../../ui";
|
|
2
|
-
import { memo, useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
3
|
-
import { useShortcut } from "../../react/input";
|
|
4
|
-
import { TextAttributes, type ScrollBoxRenderable, type TextareaRenderable } from "../../ui";
|
|
5
|
-
import type { GloomPlugin, PaneProps } from "../../types/plugin";
|
|
6
|
-
import { syncConfigActiveLayoutState, useAppDispatch, useAppSelector, useAppStateRef, usePaneInstance, usePaneInstanceId } from "../../state/app-context";
|
|
7
|
-
import { useInlineTickers, type InlineTickerCatalogEntry } from "../../state/use-inline-tickers";
|
|
8
|
-
import { ExternalLinkText, getMessageComposerBlockHeight, MessageComposer } from "../../components/ui";
|
|
9
|
-
import { TickerBadgeText } from "../../components/ticker-badge-text";
|
|
10
|
-
import { TickerBadge } from "../../components/ticker-badge";
|
|
11
|
-
import { blendHex, colors, hoverBg } from "../../theme/colors";
|
|
12
|
-
import { apiClient, type ChatChannel, type ChatMessage } from "../../utils/api-client";
|
|
13
|
-
import { formatTimeAgo } from "../../utils/format";
|
|
14
|
-
import { tokenizeInlineContent } from "../../utils/inline-content-tokenizer";
|
|
15
|
-
import { isPlainKey } from "../../utils/keyboard";
|
|
16
|
-
import { getSharedRegistry } from "../../plugins/registry";
|
|
17
|
-
import { usePluginAppActions } from "../../plugins/plugin-runtime";
|
|
18
|
-
import { setPaneSetting } from "../../pane-settings";
|
|
19
|
-
import { scheduleConfigSave } from "../../state/config-save-scheduler";
|
|
20
|
-
import { chatController, type ChatController } from "./chat-controller";
|
|
21
|
-
import { createGloomberbCloudCapabilities, createGloomberbCloudProvider } from "../../sources/gloomberb-cloud";
|
|
22
|
-
import { InlineAuthActions } from "./cloud-auth-actions";
|
|
23
|
-
import { TwitterFeedPane, TwitterTickerTab } from "./cloud-tweets";
|
|
24
|
-
|
|
25
|
-
interface ChatContentProps {
|
|
26
|
-
width: number;
|
|
27
|
-
height: number;
|
|
28
|
-
focused: boolean;
|
|
29
|
-
close?: () => void;
|
|
30
|
-
channelId?: string;
|
|
31
|
-
onChannelChange?: (channelId: string) => void;
|
|
32
|
-
controller?: Pick<
|
|
33
|
-
ChatController,
|
|
34
|
-
| "attachView"
|
|
35
|
-
| "attachChannelView"
|
|
36
|
-
| "getSnapshot"
|
|
37
|
-
| "refreshChannels"
|
|
38
|
-
| "refreshChatState"
|
|
39
|
-
| "refreshPresence"
|
|
40
|
-
| "loadOlderMessages"
|
|
41
|
-
| "loadOlderChannelMessages"
|
|
42
|
-
| "refreshMessages"
|
|
43
|
-
| "refreshChannelMessages"
|
|
44
|
-
| "refreshSession"
|
|
45
|
-
| "send"
|
|
46
|
-
| "sendToChannel"
|
|
47
|
-
| "setDraft"
|
|
48
|
-
| "setChannelDraft"
|
|
49
|
-
| "setChannelNotificationsEnabled"
|
|
50
|
-
| "setReplyToId"
|
|
51
|
-
| "setChannelReplyToId"
|
|
52
|
-
| "subscribe"
|
|
53
|
-
>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface ChatStatusWidgetProps {
|
|
57
|
-
controller?: Pick<ChatController, "getSnapshot" | "refreshSession" | "subscribe">;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const MESSAGE_GROUP_THRESHOLD_MS = 5 * 60 * 1000;
|
|
61
|
-
const CHAT_COMPOSER_MAX_ROWS = 5;
|
|
62
|
-
const MESSAGE_ACTION_WIDTH = 9;
|
|
63
|
-
const COMPOSER_ACTION_WIDTH = 10;
|
|
64
|
-
const MESSAGE_SELECTION_BOTTOM_INSET = 1;
|
|
65
|
-
const DESKTOP_MESSAGE_RIGHT_PADDING = 2;
|
|
66
|
-
const CHANNEL_SIDEBAR_MIN_WIDTH = 18;
|
|
67
|
-
const CHANNEL_SIDEBAR_MAX_WIDTH = 24;
|
|
68
|
-
const DESKTOP_CHANNEL_SIDEBAR_MIN_WIDTH = 14;
|
|
69
|
-
const DESKTOP_CHANNEL_SIDEBAR_MAX_WIDTH = 19;
|
|
70
|
-
const DESKTOP_CHANNEL_SIDEBAR_WIDTH_RATIO = 0.192;
|
|
71
|
-
const CHANNEL_SIDEBAR_BREAKPOINT = 72;
|
|
72
|
-
const DESKTOP_NOTIFICATION_ICON_WIDTH = 3;
|
|
73
|
-
const DESKTOP_ONLINE_COUNT_PADDING_X = 1;
|
|
74
|
-
const DESKTOP_CHAT_INPUT_TOP_MARGIN_PX = 6;
|
|
75
|
-
const DEFAULT_CHAT_CHANNEL_ID = "everyone";
|
|
76
|
-
const LAST_VISITED_CHAT_CHANNEL_KEY = "lastChatChannelId";
|
|
77
|
-
const CHAT_CHANNEL_MOUSE_HANDLED = "__gloomberbChatChannelHandled";
|
|
78
|
-
const SCROLL_BOTTOM_THRESHOLD_PX = 2;
|
|
79
|
-
|
|
80
|
-
function isGroupedWithPrevious(messages: ChatMessage[], index: number) {
|
|
81
|
-
if (index === 0) return false;
|
|
82
|
-
const prev = messages[index - 1]!;
|
|
83
|
-
const curr = messages[index]!;
|
|
84
|
-
if (prev.user.id !== curr.user.id) return false;
|
|
85
|
-
return new Date(curr.createdAt).getTime() - new Date(prev.createdAt).getTime() < MESSAGE_GROUP_THRESHOLD_MS;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function normalizeInlinePreview(text: string) {
|
|
89
|
-
return text.replace(/\s+/g, " ").trim();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function truncateInlinePreview(text: string, width: number) {
|
|
93
|
-
if (width <= 0) return "";
|
|
94
|
-
if (text.length <= width) return text;
|
|
95
|
-
if (width <= 3) return text.slice(0, width);
|
|
96
|
-
return `${text.slice(0, width - 3)}...`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function formatInlinePreview(text: string, width: number) {
|
|
100
|
-
return truncateInlinePreview(normalizeInlinePreview(text), width);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function wrapTextLines(text: string, width: number) {
|
|
104
|
-
const safeWidth = Math.max(width, 1);
|
|
105
|
-
const lines: string[] = [];
|
|
106
|
-
|
|
107
|
-
for (const paragraph of text.split("\n")) {
|
|
108
|
-
let remaining = paragraph;
|
|
109
|
-
if (remaining.length === 0) {
|
|
110
|
-
lines.push("");
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
while (remaining.length > safeWidth) {
|
|
115
|
-
const candidate = remaining.slice(0, safeWidth + 1);
|
|
116
|
-
const breakAt = candidate.lastIndexOf(" ");
|
|
117
|
-
const lineEnd = breakAt > 0 ? breakAt : safeWidth;
|
|
118
|
-
lines.push(remaining.slice(0, lineEnd).trimEnd());
|
|
119
|
-
remaining = remaining.slice(lineEnd).trimStart();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
lines.push(remaining);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return lines.length > 0 ? lines : [""];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getMessageBodyLines(message: ChatMessage, width: number) {
|
|
129
|
-
const contentLineWidth = Math.max(width - 4, 1);
|
|
130
|
-
return wrapTextLines(message.content, contentLineWidth);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function estimateMessageHeight(message: ChatMessage, width: number, grouped = false) {
|
|
134
|
-
const headerHeight = grouped ? 0 : 1;
|
|
135
|
-
return headerHeight + (message.replyTo ? 1 : 0) + getMessageBodyLines(message, width).length;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function estimateComposerHeight(text: string, width: number) {
|
|
139
|
-
return Math.max(1, Math.min(CHAT_COMPOSER_MAX_ROWS, wrapTextLines(text, width).length));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getMessageTopOffset(messages: ChatMessage[], index: number, width: number) {
|
|
143
|
-
let offset = 0;
|
|
144
|
-
for (let i = 0; i < index; i += 1) {
|
|
145
|
-
offset += estimateMessageHeight(messages[i]!, width, isGroupedWithPrevious(messages, i));
|
|
146
|
-
}
|
|
147
|
-
return offset;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function hasPixelScrollMetrics(scrollBox: ScrollBoxRenderable | null) {
|
|
151
|
-
return !!scrollBox?.scrollToPixels && typeof scrollBox.scrollHeightPx === "number" && !!scrollBox.viewportPx;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function getScrollTop(scrollBox: ScrollBoxRenderable, preferPixels: boolean) {
|
|
155
|
-
return preferPixels && typeof scrollBox.scrollTopPx === "number" ? scrollBox.scrollTopPx : scrollBox.scrollTop;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getScrollHeight(scrollBox: ScrollBoxRenderable, preferPixels: boolean) {
|
|
159
|
-
return preferPixels && typeof scrollBox.scrollHeightPx === "number" ? scrollBox.scrollHeightPx : scrollBox.scrollHeight;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function getViewportHeight(scrollBox: ScrollBoxRenderable, preferPixels: boolean) {
|
|
163
|
-
return preferPixels && scrollBox.viewportPx ? scrollBox.viewportPx.height : scrollBox.viewport?.height ?? 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function scrollToPosition(scrollBox: ScrollBoxRenderable, target: number, preferPixels: boolean) {
|
|
167
|
-
if (preferPixels && scrollBox.scrollToPixels) {
|
|
168
|
-
scrollBox.scrollToPixels(target);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
scrollBox.scrollTo(target);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function scrollToBottom(scrollBox: ScrollBoxRenderable | null, preferPixels = false) {
|
|
175
|
-
if (!scrollBox) return;
|
|
176
|
-
const exactPixels = preferPixels && hasPixelScrollMetrics(scrollBox);
|
|
177
|
-
scrollToPosition(
|
|
178
|
-
scrollBox,
|
|
179
|
-
Math.max(0, getScrollHeight(scrollBox, exactPixels) - getViewportHeight(scrollBox, exactPixels)),
|
|
180
|
-
exactPixels,
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function isScrolledToBottom(scrollBox: ScrollBoxRenderable | null, preferPixels = false) {
|
|
185
|
-
if (!scrollBox) return true;
|
|
186
|
-
const exactPixels = preferPixels && hasPixelScrollMetrics(scrollBox);
|
|
187
|
-
const scrollTop = getScrollTop(scrollBox, exactPixels);
|
|
188
|
-
const maxScrollTop = Math.max(0, getScrollHeight(scrollBox, exactPixels) - getViewportHeight(scrollBox, exactPixels));
|
|
189
|
-
const threshold = exactPixels ? SCROLL_BOTTOM_THRESHOLD_PX : 0;
|
|
190
|
-
return maxScrollTop - scrollTop <= threshold;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function runAfterLayout(callback: () => void) {
|
|
194
|
-
if (typeof requestAnimationFrame === "function") {
|
|
195
|
-
requestAnimationFrame(callback);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
queueMicrotask(callback);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function getScrollTopForElementIntoView({
|
|
202
|
-
scrollTop,
|
|
203
|
-
viewportHeight,
|
|
204
|
-
elementTop,
|
|
205
|
-
elementHeight,
|
|
206
|
-
bottomInset = 0,
|
|
207
|
-
}: {
|
|
208
|
-
scrollTop: number;
|
|
209
|
-
viewportHeight: number;
|
|
210
|
-
elementTop: number;
|
|
211
|
-
elementHeight: number;
|
|
212
|
-
bottomInset?: number;
|
|
213
|
-
}) {
|
|
214
|
-
const visibleHeight = Math.max(viewportHeight - bottomInset, 1);
|
|
215
|
-
const elementBottom = elementTop + elementHeight;
|
|
216
|
-
if (elementTop < scrollTop || elementHeight >= visibleHeight) return elementTop;
|
|
217
|
-
if (elementBottom > scrollTop + visibleHeight) return elementBottom - visibleHeight;
|
|
218
|
-
return scrollTop;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function scrollElementIntoScrollBoxView(scrollBox: ScrollBoxRenderable | null, node: unknown) {
|
|
222
|
-
const nodeRect = (node as { getBoundingClientRect?: () => { x?: number; y?: number; top?: number; width?: number; height?: number } } | null)
|
|
223
|
-
?.getBoundingClientRect?.();
|
|
224
|
-
const scrollRect = scrollBox?.getBoundingClientRect?.() as { x?: number; y?: number; top?: number; width?: number; height?: number } | undefined;
|
|
225
|
-
if (
|
|
226
|
-
scrollBox &&
|
|
227
|
-
nodeRect &&
|
|
228
|
-
scrollRect &&
|
|
229
|
-
scrollBox.scrollToPixels &&
|
|
230
|
-
typeof scrollBox.scrollTopPx === "number" &&
|
|
231
|
-
scrollBox.viewportPx
|
|
232
|
-
) {
|
|
233
|
-
const nodeY = nodeRect.y ?? nodeRect.top ?? 0;
|
|
234
|
-
const scrollY = scrollRect.y ?? scrollRect.top ?? 0;
|
|
235
|
-
const elementTop = scrollBox.scrollTopPx + nodeY - scrollY;
|
|
236
|
-
const nextScrollTop = getScrollTopForElementIntoView({
|
|
237
|
-
scrollTop: scrollBox.scrollTopPx,
|
|
238
|
-
viewportHeight: scrollBox.viewportPx.height,
|
|
239
|
-
elementTop,
|
|
240
|
-
elementHeight: Math.max(nodeRect.height ?? 0, 1),
|
|
241
|
-
});
|
|
242
|
-
if (nextScrollTop !== scrollBox.scrollTopPx) {
|
|
243
|
-
scrollBox.scrollToPixels(nextScrollTop);
|
|
244
|
-
}
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const scrollIntoView = (node as { scrollIntoView?: (options?: unknown) => void } | null)?.scrollIntoView;
|
|
249
|
-
if (typeof scrollIntoView !== "function") return false;
|
|
250
|
-
scrollIntoView.call(node, { block: "nearest", inline: "nearest" });
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function normalizeChannelId(channelId: string | null | undefined) {
|
|
255
|
-
const trimmed = channelId?.trim();
|
|
256
|
-
return trimmed || DEFAULT_CHAT_CHANNEL_ID;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function normalizeShortcutChannelId(channelId: string | null | undefined) {
|
|
260
|
-
const trimmed = channelId?.trim().replace(/^#+/, "");
|
|
261
|
-
return normalizeChannelId(trimmed?.toLowerCase());
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function getLastVisitedChatChannelId(config: { pluginConfig: Record<string, Record<string, unknown>> }) {
|
|
265
|
-
return normalizeChannelId(config.pluginConfig["gloomberb-cloud"]?.[LAST_VISITED_CHAT_CHANNEL_KEY] as string | undefined);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function formatChannelLabel(channel: ChatChannel | undefined, fallbackId: string) {
|
|
269
|
-
return channel?.name?.trim() || fallbackId;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function truncateChannelLabel(label: string, width: number) {
|
|
273
|
-
if (width <= 0) return "";
|
|
274
|
-
if (label.length <= width) return label;
|
|
275
|
-
if (width <= 1) return label.slice(0, width);
|
|
276
|
-
if (width <= 3) return label.slice(0, width);
|
|
277
|
-
return `${label.slice(0, width - 3)}...`;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export function getSelectedMessageScrollTop({
|
|
281
|
-
scrollTop,
|
|
282
|
-
viewportHeight,
|
|
283
|
-
top,
|
|
284
|
-
rowHeight,
|
|
285
|
-
bottomInset = MESSAGE_SELECTION_BOTTOM_INSET,
|
|
286
|
-
}: {
|
|
287
|
-
scrollTop: number;
|
|
288
|
-
viewportHeight: number;
|
|
289
|
-
top: number;
|
|
290
|
-
rowHeight: number;
|
|
291
|
-
bottomInset?: number;
|
|
292
|
-
}) {
|
|
293
|
-
const safeViewportHeight = Math.max(viewportHeight, 1);
|
|
294
|
-
const visibleMessageRows = Math.max(safeViewportHeight - bottomInset, 1);
|
|
295
|
-
if (top < scrollTop) return top;
|
|
296
|
-
if (top + rowHeight > scrollTop + visibleMessageRows) {
|
|
297
|
-
return Math.max(top + rowHeight - visibleMessageRows, 0);
|
|
298
|
-
}
|
|
299
|
-
return scrollTop;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function CloudStatusIcon() {
|
|
303
|
-
const { nativePaneChrome } = useUiCapabilities();
|
|
304
|
-
if (!nativePaneChrome) {
|
|
305
|
-
return <Text fg={colors.textDim}>☁ </Text>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return (
|
|
309
|
-
<Span
|
|
310
|
-
fg={colors.textDim}
|
|
311
|
-
style={{
|
|
312
|
-
display: "inline-flex",
|
|
313
|
-
alignItems: "center",
|
|
314
|
-
justifyContent: "center",
|
|
315
|
-
width: 14,
|
|
316
|
-
height: 14,
|
|
317
|
-
marginRight: 4,
|
|
318
|
-
color: colors.textDim,
|
|
319
|
-
}}
|
|
320
|
-
>
|
|
321
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" aria-hidden="true">
|
|
322
|
-
<path
|
|
323
|
-
d="M7.5 18.5h9.1a4.4 4.4 0 0 0 .8-8.7 6.1 6.1 0 0 0-11.7 1.7A3.6 3.6 0 0 0 7.5 18.5Z"
|
|
324
|
-
stroke="currentColor"
|
|
325
|
-
strokeWidth="1.8"
|
|
326
|
-
strokeLinecap="round"
|
|
327
|
-
strokeLinejoin="round"
|
|
328
|
-
/>
|
|
329
|
-
</svg>
|
|
330
|
-
</Span>
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function ChannelNotificationIcon({
|
|
335
|
-
enabled,
|
|
336
|
-
onMouseDown,
|
|
337
|
-
}: {
|
|
338
|
-
enabled: boolean;
|
|
339
|
-
onMouseDown?: (event: any) => void;
|
|
340
|
-
}) {
|
|
341
|
-
const { nativePaneChrome } = useUiCapabilities();
|
|
342
|
-
const iconColor = enabled ? colors.positive : colors.textMuted;
|
|
343
|
-
|
|
344
|
-
if (!nativePaneChrome) {
|
|
345
|
-
return (
|
|
346
|
-
<Text fg={iconColor} selectable={false} onMouseDown={onMouseDown}>
|
|
347
|
-
{enabled ? "◖)" : "◖·"}
|
|
348
|
-
</Text>
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<Span
|
|
354
|
-
fg={iconColor}
|
|
355
|
-
onMouseDown={onMouseDown}
|
|
356
|
-
style={{
|
|
357
|
-
color: iconColor,
|
|
358
|
-
display: "inline-flex",
|
|
359
|
-
alignItems: "center",
|
|
360
|
-
justifyContent: "center",
|
|
361
|
-
width: 16,
|
|
362
|
-
height: 16,
|
|
363
|
-
}}
|
|
364
|
-
>
|
|
365
|
-
<svg viewBox="0 0 24 24" width="15" height="15" fill="none" aria-hidden="true">
|
|
366
|
-
<path
|
|
367
|
-
d="M4.5 9.5v5h3.2l4.8 4v-13l-4.8 4H4.5Z"
|
|
368
|
-
stroke="currentColor"
|
|
369
|
-
strokeWidth="1.8"
|
|
370
|
-
strokeLinecap="round"
|
|
371
|
-
strokeLinejoin="round"
|
|
372
|
-
/>
|
|
373
|
-
{enabled ? (
|
|
374
|
-
<>
|
|
375
|
-
<path
|
|
376
|
-
d="M16 8.5a5 5 0 0 1 0 7"
|
|
377
|
-
stroke="currentColor"
|
|
378
|
-
strokeWidth="1.8"
|
|
379
|
-
strokeLinecap="round"
|
|
380
|
-
/>
|
|
381
|
-
<path
|
|
382
|
-
d="M18.8 5.8a9 9 0 0 1 0 12.4"
|
|
383
|
-
stroke="currentColor"
|
|
384
|
-
strokeWidth="1.8"
|
|
385
|
-
strokeLinecap="round"
|
|
386
|
-
/>
|
|
387
|
-
</>
|
|
388
|
-
) : (
|
|
389
|
-
<path
|
|
390
|
-
d="M19 5 5 19"
|
|
391
|
-
stroke="currentColor"
|
|
392
|
-
strokeWidth="1.8"
|
|
393
|
-
strokeLinecap="round"
|
|
394
|
-
/>
|
|
395
|
-
)}
|
|
396
|
-
</svg>
|
|
397
|
-
</Span>
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function ChatActionChip({
|
|
402
|
-
label,
|
|
403
|
-
width,
|
|
404
|
-
emphasized = false,
|
|
405
|
-
onPress,
|
|
406
|
-
}: {
|
|
407
|
-
label: string;
|
|
408
|
-
width: number;
|
|
409
|
-
emphasized?: boolean;
|
|
410
|
-
onPress: () => void;
|
|
411
|
-
}) {
|
|
412
|
-
return (
|
|
413
|
-
<Box
|
|
414
|
-
width={width}
|
|
415
|
-
height={1}
|
|
416
|
-
backgroundColor={emphasized ? colors.borderFocused : colors.panel}
|
|
417
|
-
onMouseDown={(event: any) => {
|
|
418
|
-
event?.preventDefault?.();
|
|
419
|
-
event?.stopPropagation?.();
|
|
420
|
-
onPress();
|
|
421
|
-
}}
|
|
422
|
-
>
|
|
423
|
-
<Text
|
|
424
|
-
fg={emphasized ? colors.bg : colors.text}
|
|
425
|
-
attributes={emphasized ? TextAttributes.BOLD : 0}
|
|
426
|
-
onMouseDown={(event: any) => {
|
|
427
|
-
event?.preventDefault?.();
|
|
428
|
-
event?.stopPropagation?.();
|
|
429
|
-
onPress();
|
|
430
|
-
}}
|
|
431
|
-
>
|
|
432
|
-
{` ${label} `}
|
|
433
|
-
</Text>
|
|
434
|
-
</Box>
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
interface ChatMessageRenderState {
|
|
439
|
-
isSelected: boolean;
|
|
440
|
-
isHovered: boolean;
|
|
441
|
-
grouped: boolean;
|
|
442
|
-
showReplyAction: boolean;
|
|
443
|
-
bgColor: string | undefined;
|
|
444
|
-
selectedTextColor: string;
|
|
445
|
-
replyMetaColor: string;
|
|
446
|
-
replyAuthorColor: string;
|
|
447
|
-
headerStatus: string;
|
|
448
|
-
headerStatusColor: string;
|
|
449
|
-
authorColor: string;
|
|
450
|
-
authorAttributes: number;
|
|
451
|
-
bodyColor: string;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
function getChatMessageRenderState({
|
|
455
|
-
msg,
|
|
456
|
-
index,
|
|
457
|
-
messages,
|
|
458
|
-
selectedIdx,
|
|
459
|
-
hoveredIdx,
|
|
460
|
-
canSend,
|
|
461
|
-
}: {
|
|
462
|
-
msg: ChatMessage;
|
|
463
|
-
index: number;
|
|
464
|
-
messages: ChatMessage[];
|
|
465
|
-
selectedIdx: number;
|
|
466
|
-
hoveredIdx: number | null;
|
|
467
|
-
canSend: boolean;
|
|
468
|
-
}): ChatMessageRenderState {
|
|
469
|
-
const isSelected = index === selectedIdx;
|
|
470
|
-
const isHovered = index === hoveredIdx && !isSelected;
|
|
471
|
-
const grouped = isGroupedWithPrevious(messages, index);
|
|
472
|
-
const isSending = msg.clientStatus === "sending";
|
|
473
|
-
const hasFailed = msg.clientStatus === "failed";
|
|
474
|
-
const selectedTextColor = hasFailed ? colors.negative : colors.selectedText;
|
|
475
|
-
const headerStatus = isSending ? "sending..." : hasFailed ? "failed" : formatTimeAgo(msg.createdAt);
|
|
476
|
-
|
|
477
|
-
return {
|
|
478
|
-
isSelected,
|
|
479
|
-
isHovered,
|
|
480
|
-
grouped,
|
|
481
|
-
showReplyAction: canSend && (isSelected || hoveredIdx === index),
|
|
482
|
-
bgColor: isSelected ? colors.selected : isHovered ? hoverBg() : undefined,
|
|
483
|
-
selectedTextColor,
|
|
484
|
-
replyMetaColor: isSelected ? selectedTextColor : colors.textMuted,
|
|
485
|
-
replyAuthorColor: isSelected ? selectedTextColor : colors.textDim,
|
|
486
|
-
headerStatus,
|
|
487
|
-
headerStatusColor: isSelected
|
|
488
|
-
? selectedTextColor
|
|
489
|
-
: isSending
|
|
490
|
-
? colors.textDim
|
|
491
|
-
: hasFailed
|
|
492
|
-
? colors.negative
|
|
493
|
-
: colors.textMuted,
|
|
494
|
-
authorColor: isSelected ? selectedTextColor : hasFailed ? colors.negative : colors.positive,
|
|
495
|
-
authorAttributes: (isSending ? TextAttributes.DIM : 0) | TextAttributes.BOLD,
|
|
496
|
-
bodyColor: isSelected ? selectedTextColor : hasFailed ? colors.negative : isSending ? colors.textDim : colors.text,
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function ResponsiveTickerBadgeText({
|
|
501
|
-
text,
|
|
502
|
-
catalog,
|
|
503
|
-
textColor,
|
|
504
|
-
openTicker,
|
|
505
|
-
}: {
|
|
506
|
-
text: string;
|
|
507
|
-
catalog: Record<string, InlineTickerCatalogEntry>;
|
|
508
|
-
textColor: string;
|
|
509
|
-
openTicker: (symbol: string) => void;
|
|
510
|
-
}) {
|
|
511
|
-
const [hoveredSymbol, setHoveredSymbol] = useState<string | null>(null);
|
|
512
|
-
const tokens = useMemo(() => tokenizeInlineContent(text), [text]);
|
|
513
|
-
|
|
514
|
-
return (
|
|
515
|
-
<Box
|
|
516
|
-
flexDirection="row"
|
|
517
|
-
flexWrap="wrap"
|
|
518
|
-
flexGrow={1}
|
|
519
|
-
style={{ minWidth: 0, width: "100%" }}
|
|
520
|
-
>
|
|
521
|
-
{tokens.map((token, index) => {
|
|
522
|
-
if (token.kind === "text") {
|
|
523
|
-
if (!token.value) return null;
|
|
524
|
-
return (
|
|
525
|
-
<Text
|
|
526
|
-
key={`text:${index}`}
|
|
527
|
-
fg={textColor}
|
|
528
|
-
wrapText
|
|
529
|
-
style={{
|
|
530
|
-
minWidth: 0,
|
|
531
|
-
whiteSpace: "pre-wrap",
|
|
532
|
-
overflowWrap: "anywhere",
|
|
533
|
-
}}
|
|
534
|
-
>
|
|
535
|
-
{token.value}
|
|
536
|
-
</Text>
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (token.kind === "link") {
|
|
541
|
-
return (
|
|
542
|
-
<ExternalLinkText
|
|
543
|
-
key={`link:${index}`}
|
|
544
|
-
url={token.url}
|
|
545
|
-
label={token.value}
|
|
546
|
-
color={textColor}
|
|
547
|
-
/>
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const entry = catalog[token.symbol];
|
|
552
|
-
if (!entry || entry.status === "missing") {
|
|
553
|
-
return <Text key={`raw:${index}`} fg={textColor}>{token.value}</Text>;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
return (
|
|
557
|
-
<TickerBadge
|
|
558
|
-
key={`badge:${index}:${token.symbol}`}
|
|
559
|
-
symbol={token.symbol}
|
|
560
|
-
status={entry.status}
|
|
561
|
-
quote={entry.quote}
|
|
562
|
-
hovered={hoveredSymbol === token.symbol}
|
|
563
|
-
onHoverStart={() => setHoveredSymbol(token.symbol)}
|
|
564
|
-
onHoverEnd={() => {
|
|
565
|
-
setHoveredSymbol((current) => (current === token.symbol ? null : current));
|
|
566
|
-
}}
|
|
567
|
-
onOpen={openTicker}
|
|
568
|
-
/>
|
|
569
|
-
);
|
|
570
|
-
})}
|
|
571
|
-
</Box>
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
interface ChatMessageBaseProps {
|
|
576
|
-
msg: ChatMessage;
|
|
577
|
-
index: number;
|
|
578
|
-
messages: ChatMessage[];
|
|
579
|
-
selectedIdx: number;
|
|
580
|
-
hoveredIdx: number | null;
|
|
581
|
-
canSend: boolean;
|
|
582
|
-
catalog: Record<string, InlineTickerCatalogEntry>;
|
|
583
|
-
openTicker: (symbol: string) => void;
|
|
584
|
-
beginReplyTo: (index: number, options?: { deferFocus?: boolean }) => void;
|
|
585
|
-
jumpToMessage: (messageId: string) => void;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
interface TerminalChatMessageProps extends ChatMessageBaseProps {
|
|
589
|
-
contentWidth: number;
|
|
590
|
-
messageBodyWidth: number;
|
|
591
|
-
setHoveredIdx: (updater: (current: number | null) => number | null) => void;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
function TerminalChatMessage({
|
|
595
|
-
msg,
|
|
596
|
-
index,
|
|
597
|
-
messages,
|
|
598
|
-
selectedIdx,
|
|
599
|
-
hoveredIdx,
|
|
600
|
-
canSend,
|
|
601
|
-
contentWidth,
|
|
602
|
-
messageBodyWidth,
|
|
603
|
-
catalog,
|
|
604
|
-
openTicker,
|
|
605
|
-
beginReplyTo,
|
|
606
|
-
jumpToMessage,
|
|
607
|
-
setHoveredIdx,
|
|
608
|
-
}: TerminalChatMessageProps) {
|
|
609
|
-
const state = getChatMessageRenderState({ msg, index, messages, selectedIdx, hoveredIdx, canSend });
|
|
610
|
-
const bodyLines = getMessageBodyLines(msg, contentWidth);
|
|
611
|
-
const showInlineReplyAction = !state.grouped && state.showReplyAction;
|
|
612
|
-
const showGroupedReplyAction = state.grouped && state.showReplyAction;
|
|
613
|
-
const setHovered = () => setHoveredIdx((current) => (current === index ? current : index));
|
|
614
|
-
const clearHovered = () => setHoveredIdx((current) => (current === index ? null : current));
|
|
615
|
-
const messageRowProps = {
|
|
616
|
-
width: contentWidth,
|
|
617
|
-
backgroundColor: state.bgColor,
|
|
618
|
-
onMouseMove: setHovered,
|
|
619
|
-
onMouseOut: clearHovered,
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
return (
|
|
623
|
-
<Box key={msg.id} width={contentWidth} flexDirection="column">
|
|
624
|
-
{msg.replyTo && (
|
|
625
|
-
<Box
|
|
626
|
-
{...messageRowProps}
|
|
627
|
-
flexDirection="row"
|
|
628
|
-
height={1}
|
|
629
|
-
paddingLeft={2}
|
|
630
|
-
onMouseDown={() => {
|
|
631
|
-
if (msg.replyToId) jumpToMessage(msg.replyToId);
|
|
632
|
-
}}
|
|
633
|
-
>
|
|
634
|
-
<Text fg={state.replyMetaColor}>reply </Text>
|
|
635
|
-
<Text fg={state.replyAuthorColor}>{msg.replyTo.user.username}: </Text>
|
|
636
|
-
<Text fg={state.replyMetaColor}>
|
|
637
|
-
{formatInlinePreview(
|
|
638
|
-
msg.replyTo.content,
|
|
639
|
-
Math.max(messageBodyWidth - `reply ${msg.replyTo.user.username}: `.length, 0),
|
|
640
|
-
)}
|
|
641
|
-
</Text>
|
|
642
|
-
</Box>
|
|
643
|
-
)}
|
|
644
|
-
{!state.grouped && (
|
|
645
|
-
<Box
|
|
646
|
-
{...messageRowProps}
|
|
647
|
-
flexDirection="row"
|
|
648
|
-
height={1}
|
|
649
|
-
paddingLeft={1}
|
|
650
|
-
>
|
|
651
|
-
<Text fg={state.authorColor} attributes={state.authorAttributes}>
|
|
652
|
-
{msg.user.username ?? "anon"}
|
|
653
|
-
</Text>
|
|
654
|
-
<Text fg={state.headerStatusColor}> {state.headerStatus}</Text>
|
|
655
|
-
{showInlineReplyAction && (
|
|
656
|
-
<>
|
|
657
|
-
<Text fg={state.headerStatusColor}> </Text>
|
|
658
|
-
<Box width={MESSAGE_ACTION_WIDTH} height={1}>
|
|
659
|
-
<ChatActionChip
|
|
660
|
-
label="Reply"
|
|
661
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
662
|
-
emphasized={state.isSelected}
|
|
663
|
-
onPress={() => beginReplyTo(index)}
|
|
664
|
-
/>
|
|
665
|
-
</Box>
|
|
666
|
-
</>
|
|
667
|
-
)}
|
|
668
|
-
</Box>
|
|
669
|
-
)}
|
|
670
|
-
{bodyLines.map((line, lineIndex) => (
|
|
671
|
-
<Box
|
|
672
|
-
key={`${msg.id}:body:${lineIndex}`}
|
|
673
|
-
{...messageRowProps}
|
|
674
|
-
paddingLeft={3}
|
|
675
|
-
height={1}
|
|
676
|
-
flexDirection="row"
|
|
677
|
-
position={state.grouped ? "relative" : undefined}
|
|
678
|
-
>
|
|
679
|
-
<Box width={messageBodyWidth} height={1}>
|
|
680
|
-
<TickerBadgeText
|
|
681
|
-
text={line}
|
|
682
|
-
lineWidth={messageBodyWidth}
|
|
683
|
-
catalog={catalog}
|
|
684
|
-
textColor={state.bodyColor}
|
|
685
|
-
openTicker={openTicker}
|
|
686
|
-
/>
|
|
687
|
-
</Box>
|
|
688
|
-
{lineIndex === 0 && showGroupedReplyAction && (
|
|
689
|
-
<Box position="absolute" top={0} right={0} width={MESSAGE_ACTION_WIDTH} height={1}>
|
|
690
|
-
<ChatActionChip
|
|
691
|
-
label="Reply"
|
|
692
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
693
|
-
emphasized={state.isSelected}
|
|
694
|
-
onPress={() => beginReplyTo(index)}
|
|
695
|
-
/>
|
|
696
|
-
</Box>
|
|
697
|
-
)}
|
|
698
|
-
</Box>
|
|
699
|
-
))}
|
|
700
|
-
</Box>
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
const DesktopChatMessage = memo(function DesktopChatMessage({
|
|
705
|
-
msg,
|
|
706
|
-
index,
|
|
707
|
-
messages,
|
|
708
|
-
selectedIdx,
|
|
709
|
-
hoveredIdx,
|
|
710
|
-
canSend,
|
|
711
|
-
catalog,
|
|
712
|
-
openTicker,
|
|
713
|
-
beginReplyTo,
|
|
714
|
-
jumpToMessage,
|
|
715
|
-
registerMessageElement,
|
|
716
|
-
}: ChatMessageBaseProps & {
|
|
717
|
-
registerMessageElement: (messageId: string, node: unknown | null) => void;
|
|
718
|
-
}) {
|
|
719
|
-
const state = getChatMessageRenderState({ msg, index, messages, selectedIdx, hoveredIdx, canSend });
|
|
720
|
-
const showInlineReplyAction = !state.grouped && canSend;
|
|
721
|
-
const showGroupedReplyAction = state.grouped && canSend;
|
|
722
|
-
const rowProps = {
|
|
723
|
-
width: "100%",
|
|
724
|
-
paddingRight: DESKTOP_MESSAGE_RIGHT_PADDING,
|
|
725
|
-
backgroundColor: state.bgColor,
|
|
726
|
-
"data-gloom-role": "chat-message-row",
|
|
727
|
-
"data-selected": state.isSelected ? "true" : "false",
|
|
728
|
-
style: { minWidth: 0 },
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
return (
|
|
732
|
-
<Box
|
|
733
|
-
key={msg.id}
|
|
734
|
-
ref={(node: unknown | null) => registerMessageElement(msg.id, node)}
|
|
735
|
-
width="100%"
|
|
736
|
-
flexDirection="column"
|
|
737
|
-
data-gloom-role="chat-message"
|
|
738
|
-
data-gloom-chat-message-id={msg.id}
|
|
739
|
-
data-selected={state.isSelected ? "true" : "false"}
|
|
740
|
-
style={{ "--chat-hover-bg": hoverBg(), minWidth: 0 }}
|
|
741
|
-
>
|
|
742
|
-
{msg.replyTo && (
|
|
743
|
-
<Box
|
|
744
|
-
{...rowProps}
|
|
745
|
-
flexDirection="row"
|
|
746
|
-
paddingLeft={2}
|
|
747
|
-
onMouseDown={() => {
|
|
748
|
-
if (msg.replyToId) jumpToMessage(msg.replyToId);
|
|
749
|
-
}}
|
|
750
|
-
style={{ minWidth: 0, alignItems: "flex-start", cursor: "pointer" }}
|
|
751
|
-
>
|
|
752
|
-
<Text
|
|
753
|
-
fg={state.replyMetaColor}
|
|
754
|
-
wrapText
|
|
755
|
-
style={{
|
|
756
|
-
minWidth: 0,
|
|
757
|
-
width: "100%",
|
|
758
|
-
display: "-webkit-box",
|
|
759
|
-
WebkitBoxOrient: "vertical",
|
|
760
|
-
WebkitLineClamp: 2,
|
|
761
|
-
overflow: "hidden",
|
|
762
|
-
textOverflow: "ellipsis",
|
|
763
|
-
whiteSpace: "normal",
|
|
764
|
-
overflowWrap: "anywhere",
|
|
765
|
-
}}
|
|
766
|
-
>
|
|
767
|
-
<Span fg={state.replyMetaColor}>reply </Span>
|
|
768
|
-
<Span fg={state.replyAuthorColor}>{msg.replyTo.user.username}: </Span>
|
|
769
|
-
<Span fg={state.replyMetaColor}>{normalizeInlinePreview(msg.replyTo.content)}</Span>
|
|
770
|
-
</Text>
|
|
771
|
-
</Box>
|
|
772
|
-
)}
|
|
773
|
-
{!state.grouped && (
|
|
774
|
-
<Box
|
|
775
|
-
{...rowProps}
|
|
776
|
-
flexDirection="row"
|
|
777
|
-
height={1}
|
|
778
|
-
paddingLeft={1}
|
|
779
|
-
>
|
|
780
|
-
<Text fg={state.authorColor} attributes={state.authorAttributes}>
|
|
781
|
-
{msg.user.username ?? "anon"}
|
|
782
|
-
</Text>
|
|
783
|
-
<Text fg={state.headerStatusColor}> {state.headerStatus}</Text>
|
|
784
|
-
{showInlineReplyAction && (
|
|
785
|
-
<>
|
|
786
|
-
<Text fg={state.headerStatusColor}> </Text>
|
|
787
|
-
<Box
|
|
788
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
789
|
-
height={1}
|
|
790
|
-
data-gloom-role="chat-message-reply-action"
|
|
791
|
-
>
|
|
792
|
-
<ChatActionChip
|
|
793
|
-
label="Reply"
|
|
794
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
795
|
-
emphasized={state.isSelected}
|
|
796
|
-
onPress={() => beginReplyTo(index)}
|
|
797
|
-
/>
|
|
798
|
-
</Box>
|
|
799
|
-
</>
|
|
800
|
-
)}
|
|
801
|
-
</Box>
|
|
802
|
-
)}
|
|
803
|
-
<Box
|
|
804
|
-
{...rowProps}
|
|
805
|
-
paddingLeft={3}
|
|
806
|
-
flexDirection="row"
|
|
807
|
-
position={state.grouped ? "relative" : undefined}
|
|
808
|
-
style={{ minWidth: 0, alignItems: "flex-start" }}
|
|
809
|
-
>
|
|
810
|
-
<Box flexGrow={1} style={{ minWidth: 0 }}>
|
|
811
|
-
<ResponsiveTickerBadgeText
|
|
812
|
-
text={msg.content}
|
|
813
|
-
catalog={catalog}
|
|
814
|
-
textColor={state.bodyColor}
|
|
815
|
-
openTicker={openTicker}
|
|
816
|
-
/>
|
|
817
|
-
</Box>
|
|
818
|
-
{showGroupedReplyAction && (
|
|
819
|
-
<Box
|
|
820
|
-
position="absolute"
|
|
821
|
-
top={0}
|
|
822
|
-
right={0}
|
|
823
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
824
|
-
height={1}
|
|
825
|
-
data-gloom-role="chat-message-reply-action"
|
|
826
|
-
>
|
|
827
|
-
<ChatActionChip
|
|
828
|
-
label="Reply"
|
|
829
|
-
width={MESSAGE_ACTION_WIDTH}
|
|
830
|
-
emphasized={state.isSelected}
|
|
831
|
-
onPress={() => beginReplyTo(index)}
|
|
832
|
-
/>
|
|
833
|
-
</Box>
|
|
834
|
-
)}
|
|
835
|
-
</Box>
|
|
836
|
-
</Box>
|
|
837
|
-
);
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
function ChannelSidebar({
|
|
841
|
-
channels,
|
|
842
|
-
channelStates,
|
|
843
|
-
activeChannelId,
|
|
844
|
-
onlineCount,
|
|
845
|
-
width,
|
|
846
|
-
height,
|
|
847
|
-
focused,
|
|
848
|
-
keyboardFocused,
|
|
849
|
-
loading,
|
|
850
|
-
canManageNotifications,
|
|
851
|
-
onSelect,
|
|
852
|
-
onFocusRequest,
|
|
853
|
-
onToggleNotifications,
|
|
854
|
-
}: {
|
|
855
|
-
channels: ChatChannel[];
|
|
856
|
-
channelStates: ReturnType<ChatController["getSnapshot"]>["channelStates"];
|
|
857
|
-
activeChannelId: string;
|
|
858
|
-
onlineCount: number;
|
|
859
|
-
width: number;
|
|
860
|
-
height: number;
|
|
861
|
-
focused: boolean;
|
|
862
|
-
keyboardFocused: boolean;
|
|
863
|
-
loading: boolean;
|
|
864
|
-
canManageNotifications: boolean;
|
|
865
|
-
onSelect?: (channelId: string) => void;
|
|
866
|
-
onFocusRequest?: () => void;
|
|
867
|
-
onToggleNotifications?: (channelId: string, enabled: boolean) => void;
|
|
868
|
-
}) {
|
|
869
|
-
const { nativePaneChrome } = useUiCapabilities();
|
|
870
|
-
const borderWidth = nativePaneChrome ? 0 : width > 1 ? 1 : 0;
|
|
871
|
-
const listWidth = Math.max(width - borderWidth, 1);
|
|
872
|
-
const notificationWidth = canManageNotifications ? (nativePaneChrome ? DESKTOP_NOTIFICATION_ICON_WIDTH : 2) : 0;
|
|
873
|
-
const onlineCountPaddingX = nativePaneChrome ? DESKTOP_ONLINE_COUNT_PADDING_X : 0;
|
|
874
|
-
const labelWidth = Math.max(listWidth - 3 - notificationWidth, 1);
|
|
875
|
-
const dividerColor = focused ? colors.borderFocused : colors.border;
|
|
876
|
-
const sidebarBg = keyboardFocused ? blendHex(colors.panel, colors.borderFocused, 0.18) : colors.panel;
|
|
877
|
-
const activeBg = keyboardFocused
|
|
878
|
-
? blendHex(colors.selected, colors.borderFocused, 0.32)
|
|
879
|
-
: blendHex(colors.panel, colors.selected, 0.35);
|
|
880
|
-
const [hoveredChannelId, setHoveredChannelId] = useState<string | null>(null);
|
|
881
|
-
const channelStateById = useMemo(() => new Map(channelStates.map((state) => [state.channelId, state])), [channelStates]);
|
|
882
|
-
const sidebarLayoutHeight = nativePaneChrome ? "100%" : height;
|
|
883
|
-
const nativeFillStyle = nativePaneChrome ? { minHeight: 0 } : undefined;
|
|
884
|
-
const sidebarBorder = borderWidth > 0
|
|
885
|
-
? (
|
|
886
|
-
<Box width={1} height={height} flexDirection="column">
|
|
887
|
-
{Array.from({ length: height }, (_, index) => (
|
|
888
|
-
<Text key={index} fg={dividerColor} selectable={false}>│</Text>
|
|
889
|
-
))}
|
|
890
|
-
</Box>
|
|
891
|
-
)
|
|
892
|
-
: null;
|
|
893
|
-
|
|
894
|
-
return (
|
|
895
|
-
<Box
|
|
896
|
-
width={width}
|
|
897
|
-
height={sidebarLayoutHeight}
|
|
898
|
-
flexDirection="row"
|
|
899
|
-
position="relative"
|
|
900
|
-
style={nativeFillStyle}
|
|
901
|
-
>
|
|
902
|
-
<Box
|
|
903
|
-
width={listWidth}
|
|
904
|
-
height={sidebarLayoutHeight}
|
|
905
|
-
flexDirection="column"
|
|
906
|
-
backgroundColor={sidebarBg}
|
|
907
|
-
style={nativeFillStyle}
|
|
908
|
-
>
|
|
909
|
-
{channels.map((channel) => {
|
|
910
|
-
const active = channel.id === activeChannelId;
|
|
911
|
-
const channelState = channelStateById.get(channel.id);
|
|
912
|
-
const notificationsEnabled = channelState?.notificationsEnabled === true;
|
|
913
|
-
const unread = (channelState?.unreadCount ?? 0) > 0;
|
|
914
|
-
const hovered = hoveredChannelId === channel.id && !active;
|
|
915
|
-
const fg = active ? colors.selectedText : keyboardFocused ? colors.text : colors.textDim;
|
|
916
|
-
const bg = active ? activeBg : hovered ? hoverBg() : sidebarBg;
|
|
917
|
-
const label = formatChannelLabel(channel, channel.id);
|
|
918
|
-
const selectChannel = (event: any) => {
|
|
919
|
-
if (event) {
|
|
920
|
-
event.preventDefault?.();
|
|
921
|
-
event.stopPropagation?.();
|
|
922
|
-
if (event[CHAT_CHANNEL_MOUSE_HANDLED]) return;
|
|
923
|
-
event[CHAT_CHANNEL_MOUSE_HANDLED] = true;
|
|
924
|
-
}
|
|
925
|
-
onFocusRequest?.();
|
|
926
|
-
onSelect?.(channel.id);
|
|
927
|
-
};
|
|
928
|
-
const toggleNotifications = (event: any) => {
|
|
929
|
-
event?.preventDefault?.();
|
|
930
|
-
event?.stopPropagation?.();
|
|
931
|
-
if (event) {
|
|
932
|
-
event[CHAT_CHANNEL_MOUSE_HANDLED] = true;
|
|
933
|
-
}
|
|
934
|
-
onToggleNotifications?.(channel.id, !notificationsEnabled);
|
|
935
|
-
};
|
|
936
|
-
return (
|
|
937
|
-
<Box
|
|
938
|
-
key={channel.id}
|
|
939
|
-
height={1}
|
|
940
|
-
width={listWidth}
|
|
941
|
-
flexDirection="row"
|
|
942
|
-
backgroundColor={bg}
|
|
943
|
-
onMouseDown={selectChannel}
|
|
944
|
-
onMouseMove={() => setHoveredChannelId((current) => (current === channel.id ? current : channel.id))}
|
|
945
|
-
onMouseOut={() => setHoveredChannelId((current) => (current === channel.id ? null : current))}
|
|
946
|
-
style={{ cursor: "pointer" }}
|
|
947
|
-
>
|
|
948
|
-
<Text fg={fg} selectable={false} onMouseDown={selectChannel}> </Text>
|
|
949
|
-
<Text fg={fg} attributes={unread ? TextAttributes.BOLD : 0} selectable={false} onMouseDown={selectChannel}>{active ? "#" : " "}</Text>
|
|
950
|
-
<Text fg={fg} attributes={unread ? TextAttributes.BOLD : 0} selectable={false} onMouseDown={selectChannel}>{truncateChannelLabel(label, labelWidth)}</Text>
|
|
951
|
-
<Box flexGrow={1} onMouseDown={selectChannel} />
|
|
952
|
-
{canManageNotifications && (
|
|
953
|
-
<Box
|
|
954
|
-
width={notificationWidth}
|
|
955
|
-
height={1}
|
|
956
|
-
alignItems="center"
|
|
957
|
-
justifyContent="center"
|
|
958
|
-
onMouseDown={toggleNotifications}
|
|
959
|
-
style={{ cursor: "pointer" }}
|
|
960
|
-
>
|
|
961
|
-
<ChannelNotificationIcon enabled={notificationsEnabled} onMouseDown={toggleNotifications} />
|
|
962
|
-
</Box>
|
|
963
|
-
)}
|
|
964
|
-
</Box>
|
|
965
|
-
);
|
|
966
|
-
})}
|
|
967
|
-
<Box flexGrow={1} />
|
|
968
|
-
{loading && focused && (
|
|
969
|
-
<Box height={1} width={listWidth} flexDirection="row">
|
|
970
|
-
<Text fg={colors.textDim}> syncing</Text>
|
|
971
|
-
</Box>
|
|
972
|
-
)}
|
|
973
|
-
<Box height={1} width={listWidth} flexDirection="row" paddingX={onlineCountPaddingX}>
|
|
974
|
-
<Text fg={colors.positive}>●</Text>
|
|
975
|
-
<Text fg={colors.textDim}>
|
|
976
|
-
{` ${truncateChannelLabel(`${onlineCount} online`, Math.max(listWidth - 2 - onlineCountPaddingX * 2, 1))}`}
|
|
977
|
-
</Text>
|
|
978
|
-
</Box>
|
|
979
|
-
</Box>
|
|
980
|
-
{sidebarBorder}
|
|
981
|
-
{nativePaneChrome && (
|
|
982
|
-
<Box
|
|
983
|
-
position="absolute"
|
|
984
|
-
top={0}
|
|
985
|
-
right={0}
|
|
986
|
-
width={1}
|
|
987
|
-
height={sidebarLayoutHeight}
|
|
988
|
-
style={{
|
|
989
|
-
width: 1,
|
|
990
|
-
height: "100%",
|
|
991
|
-
backgroundColor: dividerColor,
|
|
992
|
-
pointerEvents: "none",
|
|
993
|
-
}}
|
|
994
|
-
/>
|
|
995
|
-
)}
|
|
996
|
-
</Box>
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
export function ChatContent({
|
|
1001
|
-
width,
|
|
1002
|
-
height,
|
|
1003
|
-
focused,
|
|
1004
|
-
close,
|
|
1005
|
-
channelId: rawChannelId,
|
|
1006
|
-
onChannelChange,
|
|
1007
|
-
controller = chatController,
|
|
1008
|
-
}: ChatContentProps) {
|
|
1009
|
-
const dispatch = useAppDispatch();
|
|
1010
|
-
const channelId = normalizeChannelId(rawChannelId);
|
|
1011
|
-
const channelIdRef = useRef(channelId);
|
|
1012
|
-
channelIdRef.current = channelId;
|
|
1013
|
-
const initialSnapshot = controller.getSnapshot(channelId);
|
|
1014
|
-
const { nativePaneChrome } = useUiCapabilities();
|
|
1015
|
-
const [channels, setChannels] = useState<ChatChannel[]>(initialSnapshot.channels);
|
|
1016
|
-
const [channelsLoading, setChannelsLoading] = useState(initialSnapshot.channelsLoading);
|
|
1017
|
-
const showChannelSidebar = channels.length > 1 && width >= CHANNEL_SIDEBAR_BREAKPOINT && height >= 8;
|
|
1018
|
-
const sidebarMinWidth = nativePaneChrome ? DESKTOP_CHANNEL_SIDEBAR_MIN_WIDTH : CHANNEL_SIDEBAR_MIN_WIDTH;
|
|
1019
|
-
const sidebarMaxWidth = nativePaneChrome ? DESKTOP_CHANNEL_SIDEBAR_MAX_WIDTH : CHANNEL_SIDEBAR_MAX_WIDTH;
|
|
1020
|
-
const sidebarWidthRatio = nativePaneChrome ? DESKTOP_CHANNEL_SIDEBAR_WIDTH_RATIO : 0.24;
|
|
1021
|
-
const channelSidebarWidth = showChannelSidebar
|
|
1022
|
-
? Math.min(sidebarMaxWidth, Math.max(sidebarMinWidth, Math.floor(width * sidebarWidthRatio)))
|
|
1023
|
-
: 0;
|
|
1024
|
-
const chatWidth = Math.max(width - channelSidebarWidth, 1);
|
|
1025
|
-
const contentWidth = Math.max(chatWidth - 2, 1);
|
|
1026
|
-
const composerPrefixWidth = nativePaneChrome ? 0 : 3;
|
|
1027
|
-
const composerTextWidth = Math.max(contentWidth - composerPrefixWidth, 1);
|
|
1028
|
-
const inputValueRef = useRef(initialSnapshot.draft);
|
|
1029
|
-
const [messages, setMessages] = useState<ChatMessage[]>(initialSnapshot.messages);
|
|
1030
|
-
const [channelStates, setChannelStates] = useState(initialSnapshot.channelStates);
|
|
1031
|
-
const [onlineCount, setOnlineCount] = useState(initialSnapshot.onlineCount);
|
|
1032
|
-
const [hasSavedSession, setHasSavedSession] = useState(initialSnapshot.hasSavedSession);
|
|
1033
|
-
const [user, setUser] = useState<{ id: string; username: string; emailVerified: boolean } | null>(initialSnapshot.user);
|
|
1034
|
-
const [loading, setLoading] = useState(initialSnapshot.loading);
|
|
1035
|
-
const [loadingOlderMessages, setLoadingOlderMessages] = useState(initialSnapshot.loadingOlderMessages);
|
|
1036
|
-
const [hasOlderMessages, setHasOlderMessages] = useState(initialSnapshot.hasOlderMessages);
|
|
1037
|
-
const [inputFocused, setInputFocused] = useState(false);
|
|
1038
|
-
const [composerRows, setComposerRows] = useState(() => estimateComposerHeight(initialSnapshot.draft, composerTextWidth));
|
|
1039
|
-
const [selectedIdx, setSelectedIdx] = useState(-1);
|
|
1040
|
-
const [hoveredIdx, setHoveredIdx] = useState<number | null>(null);
|
|
1041
|
-
const [sidebarFocused, setSidebarFocusedState] = useState(false);
|
|
1042
|
-
const sidebarFocusedRef = useRef(false);
|
|
1043
|
-
const setSidebarFocused = useCallback((nextFocused: boolean) => {
|
|
1044
|
-
sidebarFocusedRef.current = nextFocused;
|
|
1045
|
-
setSidebarFocusedState((current) => (current === nextFocused ? current : nextFocused));
|
|
1046
|
-
}, []);
|
|
1047
|
-
const [followMessages, setFollowMessages] = useState(true);
|
|
1048
|
-
const [replyTo, setReplyTo] = useState<ChatMessage | null>(() => (
|
|
1049
|
-
initialSnapshot.replyToId ? initialSnapshot.messages.find((message) => message.id === initialSnapshot.replyToId) ?? null : null
|
|
1050
|
-
));
|
|
1051
|
-
const inputRef = useRef<TextareaRenderable>(null);
|
|
1052
|
-
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
1053
|
-
const messageElementsRef = useRef(new Map<string, unknown>());
|
|
1054
|
-
const applyingExternalDraftRef = useRef(false);
|
|
1055
|
-
const prependAnchorRef = useRef<{
|
|
1056
|
-
oldestMessageId: string | null;
|
|
1057
|
-
scrollHeight: number;
|
|
1058
|
-
scrollTop: number;
|
|
1059
|
-
selectedMessageId: string | null;
|
|
1060
|
-
} | null>(null);
|
|
1061
|
-
const canSend = !!user?.emailVerified;
|
|
1062
|
-
const useDefaultControllerChannel = channelId === DEFAULT_CHAT_CHANNEL_ID && !onChannelChange;
|
|
1063
|
-
const messageBodyWidth = Math.max(contentWidth - 4, 1);
|
|
1064
|
-
const composerHeight = canSend
|
|
1065
|
-
? nativePaneChrome
|
|
1066
|
-
? Math.min(CHAT_COMPOSER_MAX_ROWS + 1, Math.max(2, composerRows + 1))
|
|
1067
|
-
: composerRows
|
|
1068
|
-
: 0;
|
|
1069
|
-
const selectionActive = selectedIdx >= 0 && selectedIdx < messages.length;
|
|
1070
|
-
const stickyTranscript = followMessages && !selectionActive;
|
|
1071
|
-
const latestMessageId = messages[messages.length - 1]?.id ?? null;
|
|
1072
|
-
const updateComposerRows = useCallback((draft: string) => {
|
|
1073
|
-
const nextRows = estimateComposerHeight(draft, composerTextWidth);
|
|
1074
|
-
setComposerRows((current) => (current === nextRows ? current : nextRows));
|
|
1075
|
-
}, [composerTextWidth]);
|
|
1076
|
-
|
|
1077
|
-
useEffect(() => {
|
|
1078
|
-
return useDefaultControllerChannel ? controller.attachView() : controller.attachChannelView(channelId);
|
|
1079
|
-
}, [channelId, controller, useDefaultControllerChannel]);
|
|
1080
|
-
|
|
1081
|
-
useEffect(() => {
|
|
1082
|
-
updateComposerRows(inputValueRef.current);
|
|
1083
|
-
}, [updateComposerRows]);
|
|
1084
|
-
|
|
1085
|
-
useEffect(() => {
|
|
1086
|
-
void controller.refreshChannels().catch(() => {});
|
|
1087
|
-
void controller.refreshPresence().catch(() => {});
|
|
1088
|
-
void controller.refreshSession().catch(() => {});
|
|
1089
|
-
}, [controller]);
|
|
1090
|
-
|
|
1091
|
-
useEffect(() => {
|
|
1092
|
-
setSelectedIdx(-1);
|
|
1093
|
-
setFollowMessages(true);
|
|
1094
|
-
prependAnchorRef.current = null;
|
|
1095
|
-
const snapshot = controller.getSnapshot(channelId);
|
|
1096
|
-
setMessages(snapshot.messages);
|
|
1097
|
-
setChannels(snapshot.channels);
|
|
1098
|
-
setChannelStates(snapshot.channelStates);
|
|
1099
|
-
setOnlineCount(snapshot.onlineCount);
|
|
1100
|
-
setChannelsLoading(snapshot.channelsLoading);
|
|
1101
|
-
setHasSavedSession(snapshot.hasSavedSession);
|
|
1102
|
-
setUser(snapshot.user);
|
|
1103
|
-
setLoading(snapshot.loading);
|
|
1104
|
-
setLoadingOlderMessages(snapshot.loadingOlderMessages);
|
|
1105
|
-
setHasOlderMessages(snapshot.hasOlderMessages);
|
|
1106
|
-
inputValueRef.current = snapshot.draft;
|
|
1107
|
-
updateComposerRows(snapshot.draft);
|
|
1108
|
-
const textarea = inputRef.current;
|
|
1109
|
-
if (textarea && textarea.editBuffer.getText() !== snapshot.draft) {
|
|
1110
|
-
applyingExternalDraftRef.current = true;
|
|
1111
|
-
textarea.setText(snapshot.draft);
|
|
1112
|
-
applyingExternalDraftRef.current = false;
|
|
1113
|
-
}
|
|
1114
|
-
setReplyTo(snapshot.replyToId
|
|
1115
|
-
? snapshot.messages.find((message) => message.id === snapshot.replyToId) ?? null
|
|
1116
|
-
: null);
|
|
1117
|
-
|
|
1118
|
-
const unsubscribe = useDefaultControllerChannel
|
|
1119
|
-
? controller.subscribe(handleSnapshot)
|
|
1120
|
-
: controller.subscribe(channelId, handleSnapshot);
|
|
1121
|
-
|
|
1122
|
-
function handleSnapshot(snapshot: ReturnType<ChatController["getSnapshot"]>) {
|
|
1123
|
-
setMessages(snapshot.messages);
|
|
1124
|
-
setChannels(snapshot.channels);
|
|
1125
|
-
setChannelStates(snapshot.channelStates);
|
|
1126
|
-
setOnlineCount(snapshot.onlineCount);
|
|
1127
|
-
setChannelsLoading(snapshot.channelsLoading);
|
|
1128
|
-
setHasSavedSession(snapshot.hasSavedSession);
|
|
1129
|
-
setUser(snapshot.user);
|
|
1130
|
-
setLoading(snapshot.loading);
|
|
1131
|
-
setLoadingOlderMessages(snapshot.loadingOlderMessages);
|
|
1132
|
-
setHasOlderMessages(snapshot.hasOlderMessages);
|
|
1133
|
-
if (inputValueRef.current !== snapshot.draft) {
|
|
1134
|
-
inputValueRef.current = snapshot.draft;
|
|
1135
|
-
updateComposerRows(snapshot.draft);
|
|
1136
|
-
}
|
|
1137
|
-
const textarea = inputRef.current;
|
|
1138
|
-
if (textarea && textarea.editBuffer.getText() !== snapshot.draft) {
|
|
1139
|
-
applyingExternalDraftRef.current = true;
|
|
1140
|
-
textarea.setText(snapshot.draft);
|
|
1141
|
-
applyingExternalDraftRef.current = false;
|
|
1142
|
-
}
|
|
1143
|
-
setReplyTo(snapshot.replyToId
|
|
1144
|
-
? snapshot.messages.find((message) => message.id === snapshot.replyToId) ?? null
|
|
1145
|
-
: null);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
void (useDefaultControllerChannel ? controller.refreshMessages() : controller.refreshChannelMessages(channelId)).catch(() => {});
|
|
1149
|
-
return unsubscribe;
|
|
1150
|
-
}, [channelId, controller, updateComposerRows, useDefaultControllerChannel]);
|
|
1151
|
-
|
|
1152
|
-
const messageContents = useMemo(() => messages.map((message) => message.content), [messages]);
|
|
1153
|
-
const { catalog, openTicker } = useInlineTickers(messageContents);
|
|
1154
|
-
|
|
1155
|
-
const replyToRef = useRef(replyTo);
|
|
1156
|
-
replyToRef.current = replyTo;
|
|
1157
|
-
const pendingJumpMessageIdRef = useRef<string | null>(null);
|
|
1158
|
-
|
|
1159
|
-
const registerMessageElement = useCallback((messageId: string, node: unknown | null) => {
|
|
1160
|
-
if (node) {
|
|
1161
|
-
messageElementsRef.current.set(messageId, node);
|
|
1162
|
-
} else {
|
|
1163
|
-
messageElementsRef.current.delete(messageId);
|
|
1164
|
-
}
|
|
1165
|
-
}, []);
|
|
1166
|
-
|
|
1167
|
-
const focusInput = useCallback(() => {
|
|
1168
|
-
setSidebarFocused(false);
|
|
1169
|
-
setInputFocused(true);
|
|
1170
|
-
dispatch({ type: "SET_INPUT_CAPTURED", captured: true });
|
|
1171
|
-
inputRef.current?.focus?.();
|
|
1172
|
-
}, [dispatch, setSidebarFocused]);
|
|
1173
|
-
|
|
1174
|
-
const focusComposer = useCallback(() => {
|
|
1175
|
-
setSelectedIdx(-1);
|
|
1176
|
-
setFollowMessages(true);
|
|
1177
|
-
focusInput();
|
|
1178
|
-
}, [focusInput]);
|
|
1179
|
-
|
|
1180
|
-
const blurInput = useCallback(() => {
|
|
1181
|
-
setInputFocused(false);
|
|
1182
|
-
dispatch({ type: "SET_INPUT_CAPTURED", captured: false });
|
|
1183
|
-
}, [dispatch]);
|
|
1184
|
-
|
|
1185
|
-
const clearReplyTarget = useCallback(() => {
|
|
1186
|
-
setReplyTo(null);
|
|
1187
|
-
if (useDefaultControllerChannel) {
|
|
1188
|
-
controller.setReplyToId(null);
|
|
1189
|
-
} else {
|
|
1190
|
-
controller.setChannelReplyToId(channelId, null);
|
|
1191
|
-
}
|
|
1192
|
-
}, [channelId, controller, useDefaultControllerChannel]);
|
|
1193
|
-
|
|
1194
|
-
const beginReplyTo = useCallback((index: number, options?: { deferFocus?: boolean }) => {
|
|
1195
|
-
if (!canSend || index < 0 || index >= messages.length) return;
|
|
1196
|
-
const nextReplyTo = messages[index] ?? null;
|
|
1197
|
-
if (!nextReplyTo) return;
|
|
1198
|
-
setSelectedIdx(index);
|
|
1199
|
-
setFollowMessages(index === messages.length - 1);
|
|
1200
|
-
setReplyTo(nextReplyTo);
|
|
1201
|
-
if (useDefaultControllerChannel) {
|
|
1202
|
-
controller.setReplyToId(nextReplyTo.id);
|
|
1203
|
-
} else {
|
|
1204
|
-
controller.setChannelReplyToId(channelId, nextReplyTo.id);
|
|
1205
|
-
}
|
|
1206
|
-
if (options?.deferFocus) {
|
|
1207
|
-
queueMicrotask(() => focusInput());
|
|
1208
|
-
} else {
|
|
1209
|
-
focusInput();
|
|
1210
|
-
}
|
|
1211
|
-
}, [canSend, channelId, controller, focusInput, messages, useDefaultControllerChannel]);
|
|
1212
|
-
|
|
1213
|
-
const returnToComposer = useCallback(() => {
|
|
1214
|
-
setSelectedIdx(-1);
|
|
1215
|
-
setFollowMessages(true);
|
|
1216
|
-
if (canSend) {
|
|
1217
|
-
queueMicrotask(() => focusInput());
|
|
1218
|
-
}
|
|
1219
|
-
}, [canSend, focusInput]);
|
|
1220
|
-
|
|
1221
|
-
const moveMessageSelection = useCallback((direction: "up" | "down") => {
|
|
1222
|
-
if (messages.length === 0) return false;
|
|
1223
|
-
|
|
1224
|
-
let next: number;
|
|
1225
|
-
if (selectedIdx < 0) {
|
|
1226
|
-
if (direction === "down") return false;
|
|
1227
|
-
next = messages.length - 1;
|
|
1228
|
-
} else if (direction === "down") {
|
|
1229
|
-
next = Math.min(selectedIdx + 1, messages.length - 1);
|
|
1230
|
-
} else {
|
|
1231
|
-
next = Math.max(selectedIdx - 1, 0);
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
setSelectedIdx(next);
|
|
1235
|
-
setFollowMessages(next === messages.length - 1);
|
|
1236
|
-
return true;
|
|
1237
|
-
}, [messages.length, selectedIdx]);
|
|
1238
|
-
|
|
1239
|
-
const shouldLeaveComposerForSelection = useCallback((direction: "up" | "down") => {
|
|
1240
|
-
const textarea = inputRef.current;
|
|
1241
|
-
if (!textarea || textarea.hasSelection()) return false;
|
|
1242
|
-
|
|
1243
|
-
const visualLineCount = Math.max(textarea.virtualLineCount, 1);
|
|
1244
|
-
if (direction === "up") {
|
|
1245
|
-
return textarea.visualCursor.visualRow <= 0;
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
return textarea.visualCursor.visualRow >= visualLineCount - 1;
|
|
1249
|
-
}, []);
|
|
1250
|
-
|
|
1251
|
-
const clearLocalComposer = useCallback(() => {
|
|
1252
|
-
inputValueRef.current = "";
|
|
1253
|
-
updateComposerRows("");
|
|
1254
|
-
const textarea = inputRef.current;
|
|
1255
|
-
if (textarea && textarea.editBuffer.getText() !== "") {
|
|
1256
|
-
applyingExternalDraftRef.current = true;
|
|
1257
|
-
try {
|
|
1258
|
-
textarea.setText("");
|
|
1259
|
-
} finally {
|
|
1260
|
-
applyingExternalDraftRef.current = false;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
}, [updateComposerRows]);
|
|
1264
|
-
|
|
1265
|
-
const sendMessage = useCallback(() => {
|
|
1266
|
-
const content = inputValueRef.current.trim();
|
|
1267
|
-
if (!content) return;
|
|
1268
|
-
const accepted = useDefaultControllerChannel
|
|
1269
|
-
? controller.send(content, replyToRef.current?.id)
|
|
1270
|
-
: controller.sendToChannel(channelId, content, replyToRef.current?.id);
|
|
1271
|
-
if (!accepted) return;
|
|
1272
|
-
clearLocalComposer();
|
|
1273
|
-
setSelectedIdx(-1);
|
|
1274
|
-
setFollowMessages(true);
|
|
1275
|
-
}, [channelId, clearLocalComposer, controller, useDefaultControllerChannel]);
|
|
1276
|
-
|
|
1277
|
-
const requestOlderMessages = useCallback(() => {
|
|
1278
|
-
const scrollBox = scrollRef.current;
|
|
1279
|
-
if (!scrollBox || loadingOlderMessages || !hasOlderMessages || messages.length === 0) return;
|
|
1280
|
-
const exactPixels = nativePaneChrome === true && hasPixelScrollMetrics(scrollBox);
|
|
1281
|
-
|
|
1282
|
-
prependAnchorRef.current = {
|
|
1283
|
-
oldestMessageId: messages[0]?.id ?? null,
|
|
1284
|
-
scrollHeight: getScrollHeight(scrollBox, exactPixels),
|
|
1285
|
-
scrollTop: getScrollTop(scrollBox, exactPixels),
|
|
1286
|
-
selectedMessageId: selectedIdx >= 0 ? messages[selectedIdx]?.id ?? null : messages[0]?.id ?? null,
|
|
1287
|
-
};
|
|
1288
|
-
setFollowMessages(false);
|
|
1289
|
-
const request = useDefaultControllerChannel
|
|
1290
|
-
? controller.loadOlderMessages()
|
|
1291
|
-
: controller.loadOlderChannelMessages(channelId);
|
|
1292
|
-
void request.catch(() => {
|
|
1293
|
-
prependAnchorRef.current = null;
|
|
1294
|
-
});
|
|
1295
|
-
}, [channelId, controller, hasOlderMessages, loadingOlderMessages, messages, nativePaneChrome, selectedIdx, useDefaultControllerChannel]);
|
|
1296
|
-
|
|
1297
|
-
const requestOlderMessagesIfNeeded = useCallback(() => {
|
|
1298
|
-
const scrollBox = scrollRef.current;
|
|
1299
|
-
if (!scrollBox || scrollBox.scrollTop > 1) return;
|
|
1300
|
-
requestOlderMessages();
|
|
1301
|
-
}, [requestOlderMessages]);
|
|
1302
|
-
|
|
1303
|
-
const handleTranscriptScrollActivity = useCallback((event?: { scroll?: { direction?: "up" | "down" | "left" | "right" } }) => {
|
|
1304
|
-
const direction = event?.scroll?.direction;
|
|
1305
|
-
runAfterLayout(() => {
|
|
1306
|
-
requestOlderMessagesIfNeeded();
|
|
1307
|
-
|
|
1308
|
-
const scrollBox = scrollRef.current;
|
|
1309
|
-
if (!scrollBox) return;
|
|
1310
|
-
const atBottom = isScrolledToBottom(scrollBox, nativePaneChrome);
|
|
1311
|
-
if (direction === "up" && !atBottom) {
|
|
1312
|
-
setFollowMessages(false);
|
|
1313
|
-
return;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
setFollowMessages(atBottom);
|
|
1317
|
-
});
|
|
1318
|
-
}, [nativePaneChrome, requestOlderMessagesIfNeeded]);
|
|
1319
|
-
|
|
1320
|
-
const scrollToLoadedMessage = useCallback((messageId: string) => {
|
|
1321
|
-
const targetIndex = messages.findIndex((message) => message.id === messageId);
|
|
1322
|
-
if (targetIndex < 0) return false;
|
|
1323
|
-
|
|
1324
|
-
setSelectedIdx(targetIndex);
|
|
1325
|
-
setFollowMessages(false);
|
|
1326
|
-
prependAnchorRef.current = null;
|
|
1327
|
-
runAfterLayout(() => {
|
|
1328
|
-
if (nativePaneChrome && scrollElementIntoScrollBoxView(scrollRef.current, messageElementsRef.current.get(messageId))) return;
|
|
1329
|
-
const scrollBox = scrollRef.current;
|
|
1330
|
-
if (!scrollBox) return;
|
|
1331
|
-
scrollBox.scrollTo(getMessageTopOffset(messages, targetIndex, contentWidth));
|
|
1332
|
-
});
|
|
1333
|
-
return true;
|
|
1334
|
-
}, [contentWidth, messages, nativePaneChrome]);
|
|
1335
|
-
|
|
1336
|
-
const jumpToMessage = useCallback((messageId: string) => {
|
|
1337
|
-
if (scrollToLoadedMessage(messageId)) return;
|
|
1338
|
-
pendingJumpMessageIdRef.current = messageId;
|
|
1339
|
-
if (hasOlderMessages && !loadingOlderMessages) {
|
|
1340
|
-
requestOlderMessages();
|
|
1341
|
-
} else {
|
|
1342
|
-
pendingJumpMessageIdRef.current = null;
|
|
1343
|
-
}
|
|
1344
|
-
}, [hasOlderMessages, loadingOlderMessages, requestOlderMessages, scrollToLoadedMessage]);
|
|
1345
|
-
|
|
1346
|
-
useEffect(() => {
|
|
1347
|
-
const pendingId = pendingJumpMessageIdRef.current;
|
|
1348
|
-
if (!pendingId) return;
|
|
1349
|
-
if (scrollToLoadedMessage(pendingId)) {
|
|
1350
|
-
pendingJumpMessageIdRef.current = null;
|
|
1351
|
-
prependAnchorRef.current = null;
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
if (hasOlderMessages && !loadingOlderMessages) {
|
|
1355
|
-
requestOlderMessages();
|
|
1356
|
-
} else {
|
|
1357
|
-
pendingJumpMessageIdRef.current = null;
|
|
1358
|
-
}
|
|
1359
|
-
}, [hasOlderMessages, loadingOlderMessages, messages, requestOlderMessages, scrollToLoadedMessage]);
|
|
1360
|
-
|
|
1361
|
-
const changeChannel = useCallback((nextChannelId: string) => {
|
|
1362
|
-
const normalized = normalizeChannelId(nextChannelId);
|
|
1363
|
-
if (normalized === channelIdRef.current) return;
|
|
1364
|
-
channelIdRef.current = normalized;
|
|
1365
|
-
setSelectedIdx(-1);
|
|
1366
|
-
setFollowMessages(true);
|
|
1367
|
-
onChannelChange?.(normalized);
|
|
1368
|
-
}, [onChannelChange]);
|
|
1369
|
-
|
|
1370
|
-
useEffect(() => {
|
|
1371
|
-
if (!onChannelChange || channelsLoading || channels.length === 0) return;
|
|
1372
|
-
if (channels.some((channel) => channel.id === channelId)) return;
|
|
1373
|
-
const fallbackChannelId = channels.find((channel) => channel.id === DEFAULT_CHAT_CHANNEL_ID)?.id
|
|
1374
|
-
?? channels[0]?.id;
|
|
1375
|
-
if (fallbackChannelId) {
|
|
1376
|
-
changeChannel(fallbackChannelId);
|
|
1377
|
-
}
|
|
1378
|
-
}, [changeChannel, channelId, channels, channelsLoading, onChannelChange]);
|
|
1379
|
-
|
|
1380
|
-
const cycleChannel = useCallback((direction: 1 | -1) => {
|
|
1381
|
-
if (channels.length <= 1 || !onChannelChange) return false;
|
|
1382
|
-
const currentIndex = Math.max(0, channels.findIndex((channel) => channel.id === channelIdRef.current));
|
|
1383
|
-
const nextIndex = (currentIndex + direction + channels.length) % channels.length;
|
|
1384
|
-
const nextChannel = channels[nextIndex];
|
|
1385
|
-
if (!nextChannel) return false;
|
|
1386
|
-
changeChannel(nextChannel.id);
|
|
1387
|
-
return true;
|
|
1388
|
-
}, [changeChannel, channels, onChannelChange]);
|
|
1389
|
-
|
|
1390
|
-
const focusChannelSidebar = useCallback(() => {
|
|
1391
|
-
if (!showChannelSidebar || !onChannelChange) return false;
|
|
1392
|
-
if (inputFocused) {
|
|
1393
|
-
blurInput();
|
|
1394
|
-
}
|
|
1395
|
-
setSelectedIdx(-1);
|
|
1396
|
-
setSidebarFocused(true);
|
|
1397
|
-
return true;
|
|
1398
|
-
}, [blurInput, inputFocused, onChannelChange, setSidebarFocused, showChannelSidebar]);
|
|
1399
|
-
|
|
1400
|
-
const focusChatContent = useCallback(() => {
|
|
1401
|
-
if (!showChannelSidebar) return false;
|
|
1402
|
-
setSidebarFocused(false);
|
|
1403
|
-
return true;
|
|
1404
|
-
}, [setSidebarFocused, showChannelSidebar]);
|
|
1405
|
-
|
|
1406
|
-
const moveSidebarChannelSelection = useCallback((direction: "up" | "down") => {
|
|
1407
|
-
if (!showChannelSidebar || channels.length <= 1 || !onChannelChange) return false;
|
|
1408
|
-
const currentIndex = channels.findIndex((channel) => channel.id === channelIdRef.current);
|
|
1409
|
-
const baseIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
1410
|
-
const nextIndex = direction === "down"
|
|
1411
|
-
? Math.min(baseIndex + 1, channels.length - 1)
|
|
1412
|
-
: Math.max(baseIndex - 1, 0);
|
|
1413
|
-
const nextChannel = channels[nextIndex];
|
|
1414
|
-
if (!nextChannel || nextIndex === baseIndex) return true;
|
|
1415
|
-
changeChannel(nextChannel.id);
|
|
1416
|
-
return true;
|
|
1417
|
-
}, [changeChannel, channels, onChannelChange, showChannelSidebar]);
|
|
1418
|
-
|
|
1419
|
-
useEffect(() => {
|
|
1420
|
-
if (focused && showChannelSidebar) return;
|
|
1421
|
-
setSidebarFocused(false);
|
|
1422
|
-
}, [focused, setSidebarFocused, showChannelSidebar]);
|
|
1423
|
-
|
|
1424
|
-
useEffect(() => {
|
|
1425
|
-
if (!canSend && inputFocused) {
|
|
1426
|
-
blurInput();
|
|
1427
|
-
}
|
|
1428
|
-
}, [blurInput, canSend, inputFocused]);
|
|
1429
|
-
|
|
1430
|
-
useEffect(() => {
|
|
1431
|
-
if (!focused && inputFocused) {
|
|
1432
|
-
blurInput();
|
|
1433
|
-
}
|
|
1434
|
-
}, [blurInput, focused, inputFocused]);
|
|
1435
|
-
|
|
1436
|
-
useEffect(() => {
|
|
1437
|
-
if (focused && inputFocused) {
|
|
1438
|
-
inputRef.current?.focus?.();
|
|
1439
|
-
}
|
|
1440
|
-
}, [focused, inputFocused]);
|
|
1441
|
-
|
|
1442
|
-
const commitLocalDraft = useCallback((draft: string) => {
|
|
1443
|
-
if (applyingExternalDraftRef.current) return;
|
|
1444
|
-
inputValueRef.current = draft;
|
|
1445
|
-
updateComposerRows(draft);
|
|
1446
|
-
if (useDefaultControllerChannel) {
|
|
1447
|
-
controller.setDraft(draft);
|
|
1448
|
-
} else {
|
|
1449
|
-
controller.setChannelDraft(channelId, draft);
|
|
1450
|
-
}
|
|
1451
|
-
}, [channelId, controller, updateComposerRows, useDefaultControllerChannel]);
|
|
1452
|
-
|
|
1453
|
-
useEffect(() => {
|
|
1454
|
-
const textarea = inputRef.current;
|
|
1455
|
-
if (!textarea) return;
|
|
1456
|
-
|
|
1457
|
-
textarea.onContentChange = () => {
|
|
1458
|
-
commitLocalDraft(textarea.editBuffer.getText());
|
|
1459
|
-
};
|
|
1460
|
-
|
|
1461
|
-
return () => {
|
|
1462
|
-
if (textarea) {
|
|
1463
|
-
textarea.onContentChange = undefined;
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
}, [commitLocalDraft]);
|
|
1467
|
-
|
|
1468
|
-
useEffect(() => {
|
|
1469
|
-
if (canSend || !replyTo) return;
|
|
1470
|
-
clearReplyTarget();
|
|
1471
|
-
}, [canSend, clearReplyTarget, replyTo]);
|
|
1472
|
-
|
|
1473
|
-
useShortcut((event) => {
|
|
1474
|
-
if (!focused) return;
|
|
1475
|
-
const isEnterKey = event.name === "return" || event.name === "enter";
|
|
1476
|
-
|
|
1477
|
-
if (sidebarFocusedRef.current && showChannelSidebar) {
|
|
1478
|
-
if (isPlainKey(event, "left")) {
|
|
1479
|
-
event.preventDefault?.();
|
|
1480
|
-
event.stopPropagation?.();
|
|
1481
|
-
return;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
if (isPlainKey(event, "right")) {
|
|
1485
|
-
event.preventDefault?.();
|
|
1486
|
-
event.stopPropagation?.();
|
|
1487
|
-
focusChatContent();
|
|
1488
|
-
return;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
if (isPlainKey(event, "up", "down")) {
|
|
1492
|
-
event.preventDefault?.();
|
|
1493
|
-
event.stopPropagation?.();
|
|
1494
|
-
moveSidebarChannelSelection(event.name);
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
if (
|
|
1500
|
-
isPlainKey(event, "left") &&
|
|
1501
|
-
showChannelSidebar &&
|
|
1502
|
-
(!inputFocused || inputValueRef.current.length === 0) &&
|
|
1503
|
-
focusChannelSidebar()
|
|
1504
|
-
) {
|
|
1505
|
-
event.preventDefault?.();
|
|
1506
|
-
event.stopPropagation?.();
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
if (inputFocused) {
|
|
1511
|
-
if (event.name === "escape") {
|
|
1512
|
-
event.preventDefault?.();
|
|
1513
|
-
event.stopPropagation?.();
|
|
1514
|
-
if (replyTo) {
|
|
1515
|
-
clearReplyTarget();
|
|
1516
|
-
} else {
|
|
1517
|
-
blurInput();
|
|
1518
|
-
}
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
if (isPlainKey(event, "up", "down") && shouldLeaveComposerForSelection(event.name)) {
|
|
1523
|
-
const moved = moveMessageSelection(event.name);
|
|
1524
|
-
if (moved) {
|
|
1525
|
-
event.preventDefault?.();
|
|
1526
|
-
event.stopPropagation?.();
|
|
1527
|
-
blurInput();
|
|
1528
|
-
return;
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
return;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
if (isPlainKey(event, "]") && cycleChannel(1)) {
|
|
1536
|
-
event.preventDefault?.();
|
|
1537
|
-
event.stopPropagation?.();
|
|
1538
|
-
return;
|
|
1539
|
-
}
|
|
1540
|
-
if (isPlainKey(event, "[") && cycleChannel(-1)) {
|
|
1541
|
-
event.preventDefault?.();
|
|
1542
|
-
event.stopPropagation?.();
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
if (canSend && isEnterKey && selectedIdx >= 0 && selectedIdx < messages.length) {
|
|
1547
|
-
event.preventDefault?.();
|
|
1548
|
-
event.stopPropagation?.();
|
|
1549
|
-
beginReplyTo(selectedIdx, { deferFocus: true });
|
|
1550
|
-
return;
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
if ((isEnterKey || isPlainKey(event, "i")) && canSend) {
|
|
1554
|
-
event.preventDefault?.();
|
|
1555
|
-
event.stopPropagation?.();
|
|
1556
|
-
queueMicrotask(() => focusComposer());
|
|
1557
|
-
return;
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
if (event.name === "escape") {
|
|
1561
|
-
event.preventDefault?.();
|
|
1562
|
-
event.stopPropagation?.();
|
|
1563
|
-
if (selectedIdx >= 0) {
|
|
1564
|
-
setSelectedIdx(-1);
|
|
1565
|
-
setFollowMessages(true);
|
|
1566
|
-
}
|
|
1567
|
-
return;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
if (isPlainKey(event, "j", "down")) {
|
|
1571
|
-
event.preventDefault?.();
|
|
1572
|
-
event.stopPropagation?.();
|
|
1573
|
-
if (selectedIdx === messages.length - 1) {
|
|
1574
|
-
returnToComposer();
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
moveMessageSelection("down");
|
|
1578
|
-
return;
|
|
1579
|
-
}
|
|
1580
|
-
if (isPlainKey(event, "k", "up")) {
|
|
1581
|
-
event.preventDefault?.();
|
|
1582
|
-
event.stopPropagation?.();
|
|
1583
|
-
if (selectedIdx === 0 && hasOlderMessages && !loadingOlderMessages) {
|
|
1584
|
-
requestOlderMessages();
|
|
1585
|
-
return;
|
|
1586
|
-
}
|
|
1587
|
-
moveMessageSelection("up");
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
if (canSend && isPlainKey(event, "r") && selectedIdx >= 0 && selectedIdx < messages.length) {
|
|
1592
|
-
event.preventDefault?.();
|
|
1593
|
-
event.stopPropagation?.();
|
|
1594
|
-
beginReplyTo(selectedIdx, { deferFocus: true });
|
|
1595
|
-
return;
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
if (isPlainKey(event, "g")) {
|
|
1599
|
-
event.preventDefault?.();
|
|
1600
|
-
event.stopPropagation?.();
|
|
1601
|
-
setSelectedIdx(0);
|
|
1602
|
-
setFollowMessages(false);
|
|
1603
|
-
scrollRef.current?.scrollTo(0);
|
|
1604
|
-
queueMicrotask(requestOlderMessagesIfNeeded);
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
if (event.name === "g" && event.shift) {
|
|
1608
|
-
event.preventDefault?.();
|
|
1609
|
-
event.stopPropagation?.();
|
|
1610
|
-
setSelectedIdx(messages.length - 1);
|
|
1611
|
-
setFollowMessages(true);
|
|
1612
|
-
queueMicrotask(() => scrollToBottom(scrollRef.current, nativePaneChrome));
|
|
1613
|
-
return;
|
|
1614
|
-
}
|
|
1615
|
-
});
|
|
1616
|
-
|
|
1617
|
-
const inputMetaHeight = canSend && replyTo ? 1 : 0;
|
|
1618
|
-
const composerBlockHeight = canSend
|
|
1619
|
-
? getMessageComposerBlockHeight({ height: composerHeight, nativePaneChrome })
|
|
1620
|
-
: 0;
|
|
1621
|
-
const inputAreaHeight = canSend ? composerBlockHeight + inputMetaHeight : 2;
|
|
1622
|
-
const topSeparatorHeight = nativePaneChrome ? 0 : 1;
|
|
1623
|
-
const footerSeparatorHeight = !nativePaneChrome && !canSend ? 1 : 0;
|
|
1624
|
-
const messageAreaHeight = Math.max(1, height - topSeparatorHeight - footerSeparatorHeight - inputAreaHeight);
|
|
1625
|
-
const composerWidth = nativePaneChrome ? chatWidth : contentWidth;
|
|
1626
|
-
|
|
1627
|
-
useEffect(() => {
|
|
1628
|
-
if (selectedIdx < messages.length) return;
|
|
1629
|
-
setSelectedIdx(messages.length - 1);
|
|
1630
|
-
}, [messages.length, selectedIdx]);
|
|
1631
|
-
|
|
1632
|
-
useEffect(() => {
|
|
1633
|
-
if (!stickyTranscript) return;
|
|
1634
|
-
queueMicrotask(() => scrollToBottom(scrollRef.current, nativePaneChrome));
|
|
1635
|
-
}, [channelId, contentWidth, height, latestMessageId, messageAreaHeight, nativePaneChrome, stickyTranscript]);
|
|
1636
|
-
|
|
1637
|
-
useEffect(() => {
|
|
1638
|
-
const anchor = prependAnchorRef.current;
|
|
1639
|
-
if (!anchor || loadingOlderMessages) return;
|
|
1640
|
-
|
|
1641
|
-
const currentAnchor = anchor;
|
|
1642
|
-
const scrollBox = scrollRef.current;
|
|
1643
|
-
if (!scrollBox) return;
|
|
1644
|
-
if (pendingJumpMessageIdRef.current) {
|
|
1645
|
-
prependAnchorRef.current = null;
|
|
1646
|
-
return;
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
const previousOldestIndex = currentAnchor.oldestMessageId
|
|
1650
|
-
? messages.findIndex((message) => message.id === currentAnchor.oldestMessageId)
|
|
1651
|
-
: -1;
|
|
1652
|
-
const exactPixels = nativePaneChrome === true && hasPixelScrollMetrics(scrollBox);
|
|
1653
|
-
const addedRows = !exactPixels && previousOldestIndex > 0
|
|
1654
|
-
? getMessageTopOffset(messages, previousOldestIndex, contentWidth)
|
|
1655
|
-
: Math.max(0, getScrollHeight(scrollBox, exactPixels) - currentAnchor.scrollHeight);
|
|
1656
|
-
scrollToPosition(scrollBox, currentAnchor.scrollTop + addedRows, exactPixels);
|
|
1657
|
-
if (currentAnchor.selectedMessageId) {
|
|
1658
|
-
const selectedMessageIndex = messages.findIndex((message) => message.id === currentAnchor.selectedMessageId);
|
|
1659
|
-
if (selectedMessageIndex >= 0) {
|
|
1660
|
-
setSelectedIdx(selectedMessageIndex);
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
queueMicrotask(() => {
|
|
1664
|
-
if (prependAnchorRef.current === currentAnchor) {
|
|
1665
|
-
prependAnchorRef.current = null;
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1668
|
-
}, [contentWidth, loadingOlderMessages, messages, nativePaneChrome]);
|
|
1669
|
-
|
|
1670
|
-
useEffect(() => {
|
|
1671
|
-
if (!focused || !stickyTranscript) return;
|
|
1672
|
-
queueMicrotask(() => scrollToBottom(scrollRef.current, nativePaneChrome));
|
|
1673
|
-
}, [focused, nativePaneChrome, stickyTranscript]);
|
|
1674
|
-
|
|
1675
|
-
useEffect(() => {
|
|
1676
|
-
const sb = scrollRef.current;
|
|
1677
|
-
if (!sb) return;
|
|
1678
|
-
if (!selectionActive) return;
|
|
1679
|
-
if (prependAnchorRef.current) return;
|
|
1680
|
-
if (nativePaneChrome) {
|
|
1681
|
-
const selectedMessageId = messages[selectedIdx]?.id ?? "";
|
|
1682
|
-
runAfterLayout(() => scrollElementIntoScrollBoxView(scrollRef.current, messageElementsRef.current.get(selectedMessageId)));
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
|
-
const top = getMessageTopOffset(messages, selectedIdx, contentWidth);
|
|
1686
|
-
const rowHeight = estimateMessageHeight(messages[selectedIdx]!, contentWidth, isGroupedWithPrevious(messages, selectedIdx));
|
|
1687
|
-
const nextScrollTop = getSelectedMessageScrollTop({
|
|
1688
|
-
scrollTop: sb.scrollTop,
|
|
1689
|
-
viewportHeight: sb.viewport?.height ?? 0,
|
|
1690
|
-
top,
|
|
1691
|
-
rowHeight,
|
|
1692
|
-
});
|
|
1693
|
-
if (nextScrollTop !== sb.scrollTop) {
|
|
1694
|
-
sb.scrollTo(nextScrollTop);
|
|
1695
|
-
}
|
|
1696
|
-
}, [contentWidth, messages, nativePaneChrome, selectedIdx, selectionActive]);
|
|
1697
|
-
|
|
1698
|
-
const replyPreview = replyTo
|
|
1699
|
-
? formatInlinePreview(
|
|
1700
|
-
replyTo.content,
|
|
1701
|
-
Math.max(contentWidth - ` replying to @${replyTo.user.username}: `.length - COMPOSER_ACTION_WIDTH - 1, 0),
|
|
1702
|
-
)
|
|
1703
|
-
: "";
|
|
1704
|
-
const inputPlaceholder = replyTo ? `Reply to @${replyTo.user.username}...` : "Type a message...";
|
|
1705
|
-
const chatContentBg = focused && showChannelSidebar && !sidebarFocused
|
|
1706
|
-
? blendHex(colors.bg, colors.borderFocused, 0.08)
|
|
1707
|
-
: undefined;
|
|
1708
|
-
const chatLayoutHeight = nativePaneChrome ? "100%" : height;
|
|
1709
|
-
const nativeFillStyle = nativePaneChrome ? { minHeight: 0 } : undefined;
|
|
1710
|
-
|
|
1711
|
-
return (
|
|
1712
|
-
<Box
|
|
1713
|
-
flexDirection="row"
|
|
1714
|
-
width={width}
|
|
1715
|
-
height={chatLayoutHeight}
|
|
1716
|
-
flexGrow={nativePaneChrome ? 1 : undefined}
|
|
1717
|
-
style={nativeFillStyle}
|
|
1718
|
-
>
|
|
1719
|
-
{showChannelSidebar && (
|
|
1720
|
-
<ChannelSidebar
|
|
1721
|
-
channels={channels}
|
|
1722
|
-
channelStates={channelStates}
|
|
1723
|
-
activeChannelId={channelId}
|
|
1724
|
-
onlineCount={onlineCount}
|
|
1725
|
-
width={channelSidebarWidth}
|
|
1726
|
-
height={height}
|
|
1727
|
-
focused={focused}
|
|
1728
|
-
keyboardFocused={sidebarFocused}
|
|
1729
|
-
loading={channelsLoading}
|
|
1730
|
-
canManageNotifications={!!user?.emailVerified}
|
|
1731
|
-
onSelect={changeChannel}
|
|
1732
|
-
onFocusRequest={() => setSidebarFocused(true)}
|
|
1733
|
-
onToggleNotifications={(nextChannelId, enabled) => {
|
|
1734
|
-
controller.setChannelNotificationsEnabled(nextChannelId, enabled);
|
|
1735
|
-
}}
|
|
1736
|
-
/>
|
|
1737
|
-
)}
|
|
1738
|
-
|
|
1739
|
-
<Box
|
|
1740
|
-
flexDirection="column"
|
|
1741
|
-
width={chatWidth}
|
|
1742
|
-
height={chatLayoutHeight}
|
|
1743
|
-
flexGrow={nativePaneChrome ? 1 : undefined}
|
|
1744
|
-
backgroundColor={chatContentBg}
|
|
1745
|
-
onMouseDown={() => setSidebarFocused(false)}
|
|
1746
|
-
style={nativeFillStyle}
|
|
1747
|
-
>
|
|
1748
|
-
{!nativePaneChrome && (
|
|
1749
|
-
<Box height={1} width={contentWidth}>
|
|
1750
|
-
<Text fg={colors.border}>{"-".repeat(contentWidth)}</Text>
|
|
1751
|
-
</Box>
|
|
1752
|
-
)}
|
|
1753
|
-
|
|
1754
|
-
<ScrollBox
|
|
1755
|
-
ref={scrollRef}
|
|
1756
|
-
height={nativePaneChrome ? undefined : messageAreaHeight}
|
|
1757
|
-
flexGrow={nativePaneChrome ? 1 : undefined}
|
|
1758
|
-
scrollY
|
|
1759
|
-
focusable={false}
|
|
1760
|
-
stickyScroll={stickyTranscript}
|
|
1761
|
-
stickyStart="bottom"
|
|
1762
|
-
onMouseScroll={handleTranscriptScrollActivity}
|
|
1763
|
-
style={nativePaneChrome ? { minHeight: 0 } : undefined}
|
|
1764
|
-
>
|
|
1765
|
-
{loadingOlderMessages && (
|
|
1766
|
-
<Box alignItems="center" justifyContent="center" height={1} width={contentWidth}>
|
|
1767
|
-
<Text fg={colors.textDim}>Loading earlier messages...</Text>
|
|
1768
|
-
</Box>
|
|
1769
|
-
)}
|
|
1770
|
-
{loading && messages.length === 0 ? (
|
|
1771
|
-
<Box alignItems="center" justifyContent="center" flexGrow={1}>
|
|
1772
|
-
<Text fg={colors.textDim}>Loading...</Text>
|
|
1773
|
-
</Box>
|
|
1774
|
-
) : messages.length === 0 && (
|
|
1775
|
-
<Box alignItems="center" justifyContent="center" flexGrow={1}>
|
|
1776
|
-
<Text fg={colors.textDim}>No messages yet. Be the first to say something!</Text>
|
|
1777
|
-
</Box>
|
|
1778
|
-
)}
|
|
1779
|
-
{messages.map((msg, index) => (
|
|
1780
|
-
nativePaneChrome ? (
|
|
1781
|
-
<DesktopChatMessage
|
|
1782
|
-
key={msg.id}
|
|
1783
|
-
msg={msg}
|
|
1784
|
-
index={index}
|
|
1785
|
-
messages={messages}
|
|
1786
|
-
selectedIdx={selectedIdx}
|
|
1787
|
-
hoveredIdx={hoveredIdx}
|
|
1788
|
-
canSend={canSend}
|
|
1789
|
-
catalog={catalog}
|
|
1790
|
-
openTicker={openTicker}
|
|
1791
|
-
beginReplyTo={beginReplyTo}
|
|
1792
|
-
jumpToMessage={jumpToMessage}
|
|
1793
|
-
registerMessageElement={registerMessageElement}
|
|
1794
|
-
/>
|
|
1795
|
-
) : (
|
|
1796
|
-
<TerminalChatMessage
|
|
1797
|
-
key={msg.id}
|
|
1798
|
-
msg={msg}
|
|
1799
|
-
index={index}
|
|
1800
|
-
messages={messages}
|
|
1801
|
-
selectedIdx={selectedIdx}
|
|
1802
|
-
hoveredIdx={hoveredIdx}
|
|
1803
|
-
canSend={canSend}
|
|
1804
|
-
contentWidth={contentWidth}
|
|
1805
|
-
messageBodyWidth={messageBodyWidth}
|
|
1806
|
-
catalog={catalog}
|
|
1807
|
-
openTicker={openTicker}
|
|
1808
|
-
beginReplyTo={beginReplyTo}
|
|
1809
|
-
jumpToMessage={jumpToMessage}
|
|
1810
|
-
setHoveredIdx={setHoveredIdx}
|
|
1811
|
-
/>
|
|
1812
|
-
)
|
|
1813
|
-
))}
|
|
1814
|
-
</ScrollBox>
|
|
1815
|
-
|
|
1816
|
-
{!nativePaneChrome && !canSend && (
|
|
1817
|
-
<Box height={1} width={contentWidth}>
|
|
1818
|
-
<Text fg={colors.border}>{"-".repeat(contentWidth)}</Text>
|
|
1819
|
-
</Box>
|
|
1820
|
-
)}
|
|
1821
|
-
|
|
1822
|
-
{canSend ? (
|
|
1823
|
-
<>
|
|
1824
|
-
{nativePaneChrome && (
|
|
1825
|
-
<Box
|
|
1826
|
-
width={composerWidth}
|
|
1827
|
-
style={{
|
|
1828
|
-
flex: `0 0 ${DESKTOP_CHAT_INPUT_TOP_MARGIN_PX}px`,
|
|
1829
|
-
height: DESKTOP_CHAT_INPUT_TOP_MARGIN_PX,
|
|
1830
|
-
minHeight: DESKTOP_CHAT_INPUT_TOP_MARGIN_PX,
|
|
1831
|
-
}}
|
|
1832
|
-
/>
|
|
1833
|
-
)}
|
|
1834
|
-
|
|
1835
|
-
{replyTo && (
|
|
1836
|
-
<Box height={1} width={contentWidth} flexDirection="row">
|
|
1837
|
-
<Text fg={colors.textMuted}> replying to </Text>
|
|
1838
|
-
<Text fg={colors.positive} attributes={TextAttributes.BOLD}>{`@${replyTo.user.username}`}</Text>
|
|
1839
|
-
<Text fg={colors.textDim}>{replyPreview ? `: ${replyPreview}` : ""}</Text>
|
|
1840
|
-
<Box flexGrow={1} />
|
|
1841
|
-
<ChatActionChip
|
|
1842
|
-
label="Cancel"
|
|
1843
|
-
width={COMPOSER_ACTION_WIDTH}
|
|
1844
|
-
onPress={clearReplyTarget}
|
|
1845
|
-
/>
|
|
1846
|
-
</Box>
|
|
1847
|
-
)}
|
|
1848
|
-
|
|
1849
|
-
<MessageComposer
|
|
1850
|
-
inputRef={inputRef}
|
|
1851
|
-
initialValue={inputValueRef.current}
|
|
1852
|
-
focused={inputFocused && focused}
|
|
1853
|
-
placeholder={inputPlaceholder}
|
|
1854
|
-
terminalPrefix=" > "
|
|
1855
|
-
width={composerWidth}
|
|
1856
|
-
height={composerHeight}
|
|
1857
|
-
onFocusRequest={focusComposer}
|
|
1858
|
-
onInput={commitLocalDraft}
|
|
1859
|
-
keyBindings={[
|
|
1860
|
-
{ name: "return", action: "submit" },
|
|
1861
|
-
{ name: "linefeed", action: "submit" },
|
|
1862
|
-
{ name: "return", shift: true, action: "newline" },
|
|
1863
|
-
{ name: "linefeed", shift: true, action: "newline" },
|
|
1864
|
-
{ name: "return", meta: true, action: "submit" },
|
|
1865
|
-
{ name: "linefeed", meta: true, action: "submit" },
|
|
1866
|
-
]}
|
|
1867
|
-
onSubmit={() => {
|
|
1868
|
-
if (inputValueRef.current.trim()) {
|
|
1869
|
-
sendMessage();
|
|
1870
|
-
}
|
|
1871
|
-
}}
|
|
1872
|
-
wrapText
|
|
1873
|
-
/>
|
|
1874
|
-
</>
|
|
1875
|
-
) : (
|
|
1876
|
-
<Box width={contentWidth} height={2} flexDirection="column">
|
|
1877
|
-
{!user && !hasSavedSession ? (
|
|
1878
|
-
<>
|
|
1879
|
-
<Text fg={colors.textDim}>Read-only chat. Log in or sign up to send.</Text>
|
|
1880
|
-
<InlineAuthActions />
|
|
1881
|
-
</>
|
|
1882
|
-
) : !user ? (
|
|
1883
|
-
<>
|
|
1884
|
-
<Text fg={colors.positive}>Saved login found. Log in again to send.</Text>
|
|
1885
|
-
<InlineAuthActions showSignup={false} />
|
|
1886
|
-
</>
|
|
1887
|
-
) : (
|
|
1888
|
-
<>
|
|
1889
|
-
<Text fg={colors.positive}>Verify your email to send messages.</Text>
|
|
1890
|
-
<Text fg={colors.textDim}>Ctrl+P, then Resend Verification Email</Text>
|
|
1891
|
-
</>
|
|
1892
|
-
)}
|
|
1893
|
-
</Box>
|
|
1894
|
-
)}
|
|
1895
|
-
</Box>
|
|
1896
|
-
</Box>
|
|
1897
|
-
);
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
function ChatPane({ focused, width, height, close }: PaneProps) {
|
|
1901
|
-
const dispatch = useAppDispatch();
|
|
1902
|
-
const stateRef = useAppStateRef();
|
|
1903
|
-
const paneId = usePaneInstanceId();
|
|
1904
|
-
const pane = usePaneInstance();
|
|
1905
|
-
const rawPaneChannelId = typeof pane?.settings?.channelId === "string" ? pane.settings.channelId : null;
|
|
1906
|
-
const lastVisitedChannelId = useAppSelector((state) => (
|
|
1907
|
-
(state.config.pluginConfig["gloomberb-cloud"]?.[LAST_VISITED_CHAT_CHANNEL_KEY] as string | undefined) ??
|
|
1908
|
-
DEFAULT_CHAT_CHANNEL_ID
|
|
1909
|
-
));
|
|
1910
|
-
const initialChannelIdRef = useRef(normalizeChannelId(rawPaneChannelId ?? lastVisitedChannelId));
|
|
1911
|
-
const persistedChannelId = normalizeChannelId(rawPaneChannelId ?? initialChannelIdRef.current);
|
|
1912
|
-
const persistChannelId = useCallback((nextChannelId: string) => {
|
|
1913
|
-
const currentState = stateRef.current;
|
|
1914
|
-
const layout = setPaneSetting(currentState.config.layout, paneId, "channelId", nextChannelId);
|
|
1915
|
-
const pluginConfig = {
|
|
1916
|
-
...currentState.config.pluginConfig,
|
|
1917
|
-
"gloomberb-cloud": {
|
|
1918
|
-
...(currentState.config.pluginConfig["gloomberb-cloud"] ?? {}),
|
|
1919
|
-
[LAST_VISITED_CHAT_CHANNEL_KEY]: nextChannelId,
|
|
1920
|
-
},
|
|
1921
|
-
};
|
|
1922
|
-
const nextConfig = {
|
|
1923
|
-
...currentState.config,
|
|
1924
|
-
layout,
|
|
1925
|
-
pluginConfig,
|
|
1926
|
-
};
|
|
1927
|
-
const syncedConfig = syncConfigActiveLayoutState(
|
|
1928
|
-
nextConfig,
|
|
1929
|
-
currentState.paneState,
|
|
1930
|
-
currentState.focusedPaneId,
|
|
1931
|
-
currentState.activePanel,
|
|
1932
|
-
);
|
|
1933
|
-
dispatch({ type: "SET_CONFIG", config: syncedConfig });
|
|
1934
|
-
scheduleConfigSave(syncedConfig);
|
|
1935
|
-
}, [dispatch, paneId, stateRef]);
|
|
1936
|
-
const [channelId, setLocalChannelId] = useState(initialChannelIdRef.current);
|
|
1937
|
-
const pendingChannelIdRef = useRef<string | null>(null);
|
|
1938
|
-
|
|
1939
|
-
useEffect(() => {
|
|
1940
|
-
if (rawPaneChannelId) return;
|
|
1941
|
-
persistChannelId(initialChannelIdRef.current);
|
|
1942
|
-
}, [persistChannelId, rawPaneChannelId]);
|
|
1943
|
-
|
|
1944
|
-
useEffect(() => {
|
|
1945
|
-
const normalizedPersisted = normalizeChannelId(persistedChannelId);
|
|
1946
|
-
if (pendingChannelIdRef.current) {
|
|
1947
|
-
if (pendingChannelIdRef.current === normalizedPersisted) {
|
|
1948
|
-
pendingChannelIdRef.current = null;
|
|
1949
|
-
}
|
|
1950
|
-
return;
|
|
1951
|
-
}
|
|
1952
|
-
setLocalChannelId((current) => (current === normalizedPersisted ? current : normalizedPersisted));
|
|
1953
|
-
}, [persistedChannelId]);
|
|
1954
|
-
|
|
1955
|
-
const setChannelId = useCallback((nextChannelId: string) => {
|
|
1956
|
-
const normalized = normalizeChannelId(nextChannelId);
|
|
1957
|
-
pendingChannelIdRef.current = normalized;
|
|
1958
|
-
setLocalChannelId((current) => (current === normalized ? current : normalized));
|
|
1959
|
-
persistChannelId(normalized);
|
|
1960
|
-
}, [persistChannelId]);
|
|
1961
|
-
|
|
1962
|
-
return (
|
|
1963
|
-
<ChatContent
|
|
1964
|
-
width={width}
|
|
1965
|
-
height={height}
|
|
1966
|
-
focused={focused}
|
|
1967
|
-
close={close}
|
|
1968
|
-
channelId={channelId}
|
|
1969
|
-
onChannelChange={setChannelId}
|
|
1970
|
-
/>
|
|
1971
|
-
);
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
export function ChatStatusWidget({ controller = chatController }: ChatStatusWidgetProps) {
|
|
1975
|
-
const { showPane } = usePluginAppActions();
|
|
1976
|
-
const cloudPluginDisabled = useAppSelector((state) => state.config.disabledPlugins.includes("gloomberb-cloud"));
|
|
1977
|
-
const initialSnapshot = controller.getSnapshot();
|
|
1978
|
-
const [username, setUsername] = useState<string | null>(initialSnapshot.user?.username ?? null);
|
|
1979
|
-
const [hasSavedSession, setHasSavedSession] = useState(initialSnapshot.hasSavedSession);
|
|
1980
|
-
const [unreadMentionCount, setUnreadMentionCount] = useState(initialSnapshot.unreadMentionCount);
|
|
1981
|
-
const [hovered, setHovered] = useState(false);
|
|
1982
|
-
|
|
1983
|
-
const openChat = (event?: { preventDefault?: () => void; stopPropagation?: () => void }) => {
|
|
1984
|
-
event?.preventDefault?.();
|
|
1985
|
-
event?.stopPropagation?.();
|
|
1986
|
-
showPane("chat");
|
|
1987
|
-
};
|
|
1988
|
-
|
|
1989
|
-
useEffect(() => {
|
|
1990
|
-
const unsubscribe = controller.subscribe((snapshot) => {
|
|
1991
|
-
setUsername(snapshot.user?.username ?? null);
|
|
1992
|
-
setHasSavedSession(snapshot.hasSavedSession);
|
|
1993
|
-
setUnreadMentionCount(snapshot.unreadMentionCount);
|
|
1994
|
-
});
|
|
1995
|
-
void controller.refreshSession().catch(() => {});
|
|
1996
|
-
return unsubscribe;
|
|
1997
|
-
}, [controller]);
|
|
1998
|
-
|
|
1999
|
-
if (cloudPluginDisabled) return null;
|
|
2000
|
-
|
|
2001
|
-
return (
|
|
2002
|
-
<Box flexDirection="row" paddingRight={1}>
|
|
2003
|
-
{!username && !hasSavedSession ? (
|
|
2004
|
-
<>
|
|
2005
|
-
<CloudStatusIcon />
|
|
2006
|
-
<InlineAuthActions showSignup={false} />
|
|
2007
|
-
</>
|
|
2008
|
-
) : (
|
|
2009
|
-
<Box
|
|
2010
|
-
flexDirection="row"
|
|
2011
|
-
backgroundColor={hovered ? hoverBg() : undefined}
|
|
2012
|
-
onMouseMove={() => setHovered((current) => (current ? current : true))}
|
|
2013
|
-
onMouseOut={() => setHovered((current) => (current ? false : current))}
|
|
2014
|
-
onMouseDown={openChat}
|
|
2015
|
-
>
|
|
2016
|
-
<Text fg={unreadMentionCount > 0 ? colors.text : colors.textDim}>
|
|
2017
|
-
<Span fg={colors.positive}>@</Span>
|
|
2018
|
-
{username ? (
|
|
2019
|
-
<>
|
|
2020
|
-
{" "}
|
|
2021
|
-
<Span fg={colors.positive}>{username}</Span>
|
|
2022
|
-
</>
|
|
2023
|
-
) : null}
|
|
2024
|
-
</Text>
|
|
2025
|
-
{unreadMentionCount > 0 ? (
|
|
2026
|
-
<Text fg={colors.positive} attributes={TextAttributes.BOLD}>{` [${unreadMentionCount}]`}</Text>
|
|
2027
|
-
) : null}
|
|
2028
|
-
</Box>
|
|
2029
|
-
)}
|
|
2030
|
-
</Box>
|
|
2031
|
-
);
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
export const gloomberbCloudPlugin: GloomPlugin = {
|
|
2035
|
-
id: "gloomberb-cloud",
|
|
2036
|
-
name: "Gloomberb Cloud",
|
|
2037
|
-
version: "1.0.0",
|
|
2038
|
-
description: "Free market, macro, and chat services. Chat requires signup.",
|
|
2039
|
-
toggleable: true,
|
|
2040
|
-
order: 10,
|
|
2041
|
-
capabilities: createGloomberbCloudCapabilities(createGloomberbCloudProvider()),
|
|
2042
|
-
paneTemplates: [
|
|
2043
|
-
{
|
|
2044
|
-
id: "new-chat-pane",
|
|
2045
|
-
paneId: "chat",
|
|
2046
|
-
label: "New Chat Pane",
|
|
2047
|
-
description: "Open another floating chat window",
|
|
2048
|
-
keywords: ["new", "chat", "pane", "message"],
|
|
2049
|
-
shortcut: { prefix: "CHAT", argPlaceholder: "channel", argKind: "text" },
|
|
2050
|
-
createInstance: async (context, options) => {
|
|
2051
|
-
const channelId = options?.arg
|
|
2052
|
-
? await chatController.resolveRequiredChannelId(normalizeShortcutChannelId(options.arg))
|
|
2053
|
-
: await chatController.resolvePreferredChannelId(getLastVisitedChatChannelId(context.config));
|
|
2054
|
-
return {
|
|
2055
|
-
placement: "floating",
|
|
2056
|
-
settings: { channelId },
|
|
2057
|
-
};
|
|
2058
|
-
},
|
|
2059
|
-
},
|
|
2060
|
-
],
|
|
2061
|
-
|
|
2062
|
-
slots: {
|
|
2063
|
-
"status:widget": () => <ChatStatusWidget />,
|
|
2064
|
-
},
|
|
2065
|
-
|
|
2066
|
-
setup(ctx) {
|
|
2067
|
-
chatController.attachPersistence(ctx.persistence, ctx.resume);
|
|
2068
|
-
chatController.setNotifier(ctx.notify);
|
|
2069
|
-
|
|
2070
|
-
ctx.registerPane({
|
|
2071
|
-
id: "chat",
|
|
2072
|
-
name: "Chat",
|
|
2073
|
-
icon: "C",
|
|
2074
|
-
component: ChatPane,
|
|
2075
|
-
defaultPosition: "right",
|
|
2076
|
-
defaultMode: "floating",
|
|
2077
|
-
defaultFloatingSize: { width: 80, height: 30 },
|
|
2078
|
-
});
|
|
2079
|
-
|
|
2080
|
-
ctx.registerDetailTab({
|
|
2081
|
-
id: "ticker-tweets",
|
|
2082
|
-
name: "Tweets",
|
|
2083
|
-
order: 38,
|
|
2084
|
-
component: TwitterTickerTab,
|
|
2085
|
-
isVisible: ({ ticker }) => !!ticker,
|
|
2086
|
-
});
|
|
2087
|
-
|
|
2088
|
-
ctx.registerPane({
|
|
2089
|
-
id: "twitter-feed",
|
|
2090
|
-
name: "X Feed",
|
|
2091
|
-
icon: "X",
|
|
2092
|
-
component: TwitterFeedPane,
|
|
2093
|
-
defaultPosition: "right",
|
|
2094
|
-
defaultMode: "floating",
|
|
2095
|
-
defaultFloatingSize: { width: 94, height: 28 },
|
|
2096
|
-
});
|
|
2097
|
-
|
|
2098
|
-
ctx.registerPaneTemplate({
|
|
2099
|
-
id: "twitter-feed-pane",
|
|
2100
|
-
paneId: "twitter-feed",
|
|
2101
|
-
label: "X Feed",
|
|
2102
|
-
description: "Create a reusable X advanced-search feed.",
|
|
2103
|
-
keywords: ["twitter", "x", "tweet", "tweets", "feed", "social"],
|
|
2104
|
-
shortcut: { prefix: "TWIT", argPlaceholder: "query", argKind: "text" },
|
|
2105
|
-
wizard: [
|
|
2106
|
-
{
|
|
2107
|
-
key: "query",
|
|
2108
|
-
label: "Search Query",
|
|
2109
|
-
type: "textarea",
|
|
2110
|
-
placeholder: "$AAPL -filter:replies",
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
key: "queryType",
|
|
2114
|
-
label: "Mode",
|
|
2115
|
-
type: "select",
|
|
2116
|
-
defaultValue: "Latest",
|
|
2117
|
-
options: [
|
|
2118
|
-
{ label: "Latest", value: "Latest" },
|
|
2119
|
-
{ label: "Top", value: "Top" },
|
|
2120
|
-
],
|
|
2121
|
-
},
|
|
2122
|
-
],
|
|
2123
|
-
createInstance: (_context, options) => {
|
|
2124
|
-
const query = options?.values?.query?.trim() || options?.arg?.trim() || "";
|
|
2125
|
-
if (!query) return null;
|
|
2126
|
-
return {
|
|
2127
|
-
title: "X Feed",
|
|
2128
|
-
placement: "floating",
|
|
2129
|
-
params: {
|
|
2130
|
-
query,
|
|
2131
|
-
queryType: options?.values?.queryType === "Top" ? "Top" : "Latest",
|
|
2132
|
-
},
|
|
2133
|
-
};
|
|
2134
|
-
},
|
|
2135
|
-
});
|
|
2136
|
-
|
|
2137
|
-
ctx.registerShortcut({
|
|
2138
|
-
id: "toggle-chat",
|
|
2139
|
-
key: "c",
|
|
2140
|
-
shift: true,
|
|
2141
|
-
description: "Toggle chat",
|
|
2142
|
-
execute: () => {
|
|
2143
|
-
const registry = getSharedRegistry();
|
|
2144
|
-
if (registry?.isPaneFloating("chat")) {
|
|
2145
|
-
ctx.hidePane("chat");
|
|
2146
|
-
} else {
|
|
2147
|
-
ctx.showPane("chat");
|
|
2148
|
-
}
|
|
2149
|
-
},
|
|
2150
|
-
});
|
|
2151
|
-
|
|
2152
|
-
ctx.registerCommand({
|
|
2153
|
-
id: "auth-login",
|
|
2154
|
-
label: "Log In",
|
|
2155
|
-
description: "Log in to your Gloomberb account",
|
|
2156
|
-
keywords: ["login", "sign in", "auth", "account"],
|
|
2157
|
-
category: "config",
|
|
2158
|
-
wizardLayout: "form",
|
|
2159
|
-
hidden: () => !!apiClient.getSessionToken(),
|
|
2160
|
-
wizard: [
|
|
2161
|
-
{ key: "email", label: "Email", type: "text", placeholder: "email@example.com" },
|
|
2162
|
-
{ key: "password", label: "Password", type: "password", placeholder: "Your password" },
|
|
2163
|
-
{ key: "_validate", label: "Signing in...", type: "info", body: ["Connecting to Gloomberb...", "Logged in successfully!"] },
|
|
2164
|
-
],
|
|
2165
|
-
execute: async (values) => {
|
|
2166
|
-
if (!values?.email || !values?.password) {
|
|
2167
|
-
throw new Error("Email and password are required");
|
|
2168
|
-
}
|
|
2169
|
-
const user = await apiClient.signIn(values.email, values.password);
|
|
2170
|
-
if (!user.emailVerified) {
|
|
2171
|
-
await apiClient.sendVerification().catch(() => {});
|
|
2172
|
-
}
|
|
2173
|
-
chatController.clearSession();
|
|
2174
|
-
await chatController.refreshSession();
|
|
2175
|
-
ctx.showPane("chat");
|
|
2176
|
-
},
|
|
2177
|
-
});
|
|
2178
|
-
|
|
2179
|
-
ctx.registerCommand({
|
|
2180
|
-
id: "auth-signup",
|
|
2181
|
-
label: "Sign Up",
|
|
2182
|
-
description: "Create a Gloomberb account",
|
|
2183
|
-
keywords: ["signup", "register", "create account"],
|
|
2184
|
-
category: "config",
|
|
2185
|
-
wizardLayout: "form",
|
|
2186
|
-
hidden: () => !!apiClient.getSessionToken(),
|
|
2187
|
-
wizard: [
|
|
2188
|
-
{ key: "email", label: "Email", type: "text", placeholder: "email@example.com" },
|
|
2189
|
-
{
|
|
2190
|
-
key: "username",
|
|
2191
|
-
label: "Username",
|
|
2192
|
-
type: "text",
|
|
2193
|
-
placeholder: "3-30 chars, starts with letter",
|
|
2194
|
-
body: ["Choose a username (3-30 characters, starts with a letter, alphanumeric and underscore only)"],
|
|
2195
|
-
},
|
|
2196
|
-
{ key: "password", label: "Password", type: "password", placeholder: "Min 8 characters" },
|
|
2197
|
-
{ key: "confirmPassword", label: "Confirm Password", type: "password", placeholder: "Re-enter password" },
|
|
2198
|
-
{ key: "_validate", label: "Creating account...", type: "info", body: ["Registering with Gloomberb...", "Account created! Welcome to Gloomberb."] },
|
|
2199
|
-
],
|
|
2200
|
-
execute: async (values) => {
|
|
2201
|
-
if (!values?.email || !values?.username || !values?.password) {
|
|
2202
|
-
throw new Error("All fields are required");
|
|
2203
|
-
}
|
|
2204
|
-
if (values.password !== values.confirmPassword) {
|
|
2205
|
-
throw new Error("Passwords do not match");
|
|
2206
|
-
}
|
|
2207
|
-
await apiClient.signUp(values.email, values.username, values.username, values.password);
|
|
2208
|
-
await apiClient.sendVerification();
|
|
2209
|
-
chatController.clearSession();
|
|
2210
|
-
await chatController.refreshSession();
|
|
2211
|
-
ctx.showPane("chat");
|
|
2212
|
-
},
|
|
2213
|
-
});
|
|
2214
|
-
|
|
2215
|
-
ctx.registerCommand({
|
|
2216
|
-
id: "auth-resend-verification",
|
|
2217
|
-
label: "Resend Verification Email",
|
|
2218
|
-
description: "Send another Gloomberb Cloud verification email",
|
|
2219
|
-
keywords: ["verify", "verification", "resend", "email"],
|
|
2220
|
-
category: "config",
|
|
2221
|
-
hidden: () => {
|
|
2222
|
-
const user = chatController.getSnapshot().user;
|
|
2223
|
-
return !apiClient.getSessionToken() || !user || user.emailVerified;
|
|
2224
|
-
},
|
|
2225
|
-
execute: async () => {
|
|
2226
|
-
await apiClient.sendVerification();
|
|
2227
|
-
ctx.notify({ body: "Verification email sent.", type: "success" });
|
|
2228
|
-
},
|
|
2229
|
-
});
|
|
2230
|
-
|
|
2231
|
-
if (apiClient.getSessionToken()) {
|
|
2232
|
-
void chatController.refreshSession().catch(() => {});
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
ctx.registerCommand({
|
|
2236
|
-
id: "auth-logout",
|
|
2237
|
-
label: "Logout",
|
|
2238
|
-
description: "Log out of your Gloomberb account",
|
|
2239
|
-
keywords: ["logout", "sign out"],
|
|
2240
|
-
category: "config",
|
|
2241
|
-
execute: async () => {
|
|
2242
|
-
if (!apiClient.getSessionToken()) {
|
|
2243
|
-
ctx.notify({ body: "Not logged in.", type: "error" });
|
|
2244
|
-
return;
|
|
2245
|
-
}
|
|
2246
|
-
let signOutError: unknown = null;
|
|
2247
|
-
try {
|
|
2248
|
-
await apiClient.signOut();
|
|
2249
|
-
} catch (error) {
|
|
2250
|
-
signOutError = error;
|
|
2251
|
-
}
|
|
2252
|
-
await chatController.refreshSession();
|
|
2253
|
-
await chatController.refreshMessages();
|
|
2254
|
-
ctx.notify({
|
|
2255
|
-
body: signOutError ? "Logged out locally. Cloud sign-out did not complete." : "Logged out.",
|
|
2256
|
-
type: "info",
|
|
2257
|
-
});
|
|
2258
|
-
},
|
|
2259
|
-
hidden: () => !apiClient.getSessionToken(),
|
|
2260
|
-
});
|
|
2261
|
-
},
|
|
2262
|
-
|
|
2263
|
-
dispose() {
|
|
2264
|
-
chatController.dispose();
|
|
2265
|
-
apiClient.dispose();
|
|
2266
|
-
},
|
|
2267
|
-
};
|