gloomberb 0.7.5 → 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 +107 -1487
- 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 +2 -76
- package/src/plugins/builtin/holders/index.tsx +3 -959
- 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 +79 -4
- package/src/plugins/pane-manager.ts +57 -1061
- 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 +165 -1001
- 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 +1 -1
- package/src/renderers/electrobun/view/app-services.ts +4 -375
- 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 +2 -2
- 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 +8 -3
- 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 +43 -0
- 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 -5886
- 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 -1453
- package/src/components/layout/shell.tsx +0 -1960
- 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 -926
- 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
|
@@ -0,0 +1,1302 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import type { AppNotificationRequest } from "../../../types/plugin";
|
|
3
|
+
import { MemoryPluginPersistence as MemoryPersistence } from "../../../test-support/plugin-persistence";
|
|
4
|
+
import { apiClient, type ChatChannel, type ChatMessage, type ChatNotification } from "../../../api-client";
|
|
5
|
+
import { ChatController } from "./controller";
|
|
6
|
+
|
|
7
|
+
const TRANSCRIPT_KIND = "channel-transcript";
|
|
8
|
+
const TRANSCRIPT_KEY = "everyone";
|
|
9
|
+
const TRANSCRIPT_SOURCE = "server";
|
|
10
|
+
const TRANSCRIPT_SCHEMA_VERSION = 2;
|
|
11
|
+
const originalConnectChannel = apiClient.connectChannel.bind(apiClient);
|
|
12
|
+
const originalGetSession = apiClient.getSession.bind(apiClient);
|
|
13
|
+
const originalGetMessages = apiClient.getMessages.bind(apiClient);
|
|
14
|
+
const originalGetChannels = apiClient.getChannels.bind(apiClient);
|
|
15
|
+
const originalGetChatPresence = apiClient.getChatPresence.bind(apiClient);
|
|
16
|
+
const originalGetChatState = apiClient.getChatState.bind(apiClient);
|
|
17
|
+
const originalUpdateChatChannelState = apiClient.updateChatChannelState.bind(apiClient);
|
|
18
|
+
const originalMarkChatNotificationsDelivered = apiClient.markChatNotificationsDelivered.bind(apiClient);
|
|
19
|
+
const originalSubscribeChatNotifications = apiClient.subscribeChatNotifications.bind(apiClient);
|
|
20
|
+
const originalSubscribeChatPresence = apiClient.subscribeChatPresence.bind(apiClient);
|
|
21
|
+
|
|
22
|
+
const SERVER_CHAT_CHANNELS: ChatChannel[] = [
|
|
23
|
+
{ id: "everyone", name: "everyone", created_at: "2026-03-26T12:10:05.684Z" },
|
|
24
|
+
{ id: "equities", name: "equities", created_at: "2026-05-09T00:00:00.000Z" },
|
|
25
|
+
{ id: "options", name: "options", created_at: "2026-05-09T00:00:00.000Z" },
|
|
26
|
+
{ id: "help", name: "help", created_at: "2026-05-09T00:00:00.000Z" },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
async function flushMicrotasks() {
|
|
30
|
+
await Promise.resolve();
|
|
31
|
+
await Promise.resolve();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class TrackingPersistence extends MemoryPersistence {
|
|
35
|
+
stateWrites = 0;
|
|
36
|
+
|
|
37
|
+
override setState(key: string, value: unknown, options?: { schemaVersion?: number }): void {
|
|
38
|
+
this.stateWrites += 1;
|
|
39
|
+
super.setState(key, value, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
apiClient.getChatPresence = async () => ({ onlineCount: 0 });
|
|
45
|
+
apiClient.getChatState = async () => ({
|
|
46
|
+
channels: SERVER_CHAT_CHANNELS,
|
|
47
|
+
onlineCount: 0,
|
|
48
|
+
channelStates: SERVER_CHAT_CHANNELS.map((channel) => ({
|
|
49
|
+
channelId: channel.id,
|
|
50
|
+
notificationsEnabled: false,
|
|
51
|
+
lastReadMessageId: null,
|
|
52
|
+
unreadCount: 0,
|
|
53
|
+
})),
|
|
54
|
+
notifications: [],
|
|
55
|
+
});
|
|
56
|
+
apiClient.updateChatChannelState = async (channelId, body) => ({
|
|
57
|
+
channelId,
|
|
58
|
+
notificationsEnabled: body.notificationsEnabled ?? false,
|
|
59
|
+
lastReadMessageId: body.readThroughMessageId ?? null,
|
|
60
|
+
unreadCount: 0,
|
|
61
|
+
});
|
|
62
|
+
apiClient.markChatNotificationsDelivered = async () => ({ delivered: 1 });
|
|
63
|
+
apiClient.subscribeChatNotifications = () => () => {};
|
|
64
|
+
apiClient.subscribeChatPresence = () => () => {};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
afterEach(() => {
|
|
68
|
+
apiClient.dispose();
|
|
69
|
+
apiClient.setSessionToken(null);
|
|
70
|
+
apiClient.connectChannel = originalConnectChannel;
|
|
71
|
+
apiClient.getSession = originalGetSession;
|
|
72
|
+
apiClient.getMessages = originalGetMessages;
|
|
73
|
+
apiClient.getChannels = originalGetChannels;
|
|
74
|
+
apiClient.getChatPresence = originalGetChatPresence;
|
|
75
|
+
apiClient.getChatState = originalGetChatState;
|
|
76
|
+
apiClient.updateChatChannelState = originalUpdateChatChannelState;
|
|
77
|
+
apiClient.markChatNotificationsDelivered = originalMarkChatNotificationsDelivered;
|
|
78
|
+
apiClient.subscribeChatNotifications = originalSubscribeChatNotifications;
|
|
79
|
+
apiClient.subscribeChatPresence = originalSubscribeChatPresence;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("ChatController", () => {
|
|
83
|
+
test("hydrates cached session, draft, and transcript from plugin persistence", () => {
|
|
84
|
+
const persistence = new MemoryPersistence();
|
|
85
|
+
const controller = new ChatController();
|
|
86
|
+
const message: ChatMessage = {
|
|
87
|
+
id: "m1",
|
|
88
|
+
channelId: "everyone",
|
|
89
|
+
content: "hello",
|
|
90
|
+
replyToId: null,
|
|
91
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
92
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
persistence.setState("session", {
|
|
96
|
+
sessionToken: "token-123",
|
|
97
|
+
user: { id: "u1", username: "vince" },
|
|
98
|
+
}, { schemaVersion: 1 });
|
|
99
|
+
persistence.setState("channel:everyone", {
|
|
100
|
+
draft: "cached draft",
|
|
101
|
+
replyToId: "m1",
|
|
102
|
+
lastCursor: "2026-03-28T00:00:00.000Z",
|
|
103
|
+
lastViewedMessageId: "m1",
|
|
104
|
+
}, { schemaVersion: 1 });
|
|
105
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
106
|
+
messages: [message],
|
|
107
|
+
}, {
|
|
108
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
109
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
110
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
controller.attachPersistence(persistence);
|
|
114
|
+
|
|
115
|
+
const snapshot = controller.getSnapshot();
|
|
116
|
+
expect(apiClient.getSessionToken()).toBe("token-123");
|
|
117
|
+
expect(snapshot.user?.username).toBe("vince");
|
|
118
|
+
expect(snapshot.draft).toBe("cached draft");
|
|
119
|
+
expect(snapshot.replyToId).toBe("m1");
|
|
120
|
+
expect(snapshot.messages.map((entry) => entry.id)).toEqual(["m1"]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("rejects unknown shortcut channels after the server list loads", async () => {
|
|
124
|
+
const controller = new ChatController();
|
|
125
|
+
apiClient.getChannels = async () => SERVER_CHAT_CHANNELS;
|
|
126
|
+
|
|
127
|
+
await expect(controller.resolveRequiredChannelId("help")).resolves.toBe("help");
|
|
128
|
+
await expect(controller.resolveRequiredChannelId("made-up")).rejects.toThrow(
|
|
129
|
+
'Unknown chat channel "#made-up".',
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("hydrates a cached verified user into the api client for offline use", async () => {
|
|
134
|
+
const persistence = new MemoryPersistence();
|
|
135
|
+
const controller = new ChatController();
|
|
136
|
+
|
|
137
|
+
persistence.setState("session", {
|
|
138
|
+
sessionToken: "token-123",
|
|
139
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
140
|
+
}, { schemaVersion: 1 });
|
|
141
|
+
|
|
142
|
+
controller.attachPersistence(persistence);
|
|
143
|
+
|
|
144
|
+
expect(apiClient.getCurrentUser()).toMatchObject({
|
|
145
|
+
id: "u1",
|
|
146
|
+
username: "vince",
|
|
147
|
+
emailVerified: true,
|
|
148
|
+
});
|
|
149
|
+
await expect(apiClient.ensureVerifiedSession()).resolves.toMatchObject({
|
|
150
|
+
id: "u1",
|
|
151
|
+
username: "vince",
|
|
152
|
+
emailVerified: true,
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("does not restore persisted websocket tokens", () => {
|
|
157
|
+
const persistence = new MemoryPersistence();
|
|
158
|
+
const controller = new ChatController();
|
|
159
|
+
|
|
160
|
+
persistence.setState("session", {
|
|
161
|
+
sessionToken: "token-123",
|
|
162
|
+
websocketToken: "stale-ws-token",
|
|
163
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
164
|
+
}, { schemaVersion: 1 });
|
|
165
|
+
|
|
166
|
+
controller.attachPersistence(persistence);
|
|
167
|
+
|
|
168
|
+
expect(apiClient.getSessionToken()).toBe("token-123");
|
|
169
|
+
expect(apiClient.getWebSocketToken()).toBeNull();
|
|
170
|
+
expect(apiClient.getCurrentUser()).toMatchObject({
|
|
171
|
+
id: "u1",
|
|
172
|
+
username: "vince",
|
|
173
|
+
emailVerified: true,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("reset clears persisted chat state and session token", () => {
|
|
178
|
+
const persistence = new MemoryPersistence();
|
|
179
|
+
const controller = new ChatController();
|
|
180
|
+
|
|
181
|
+
persistence.setState("session", {
|
|
182
|
+
sessionToken: "token-123",
|
|
183
|
+
user: { id: "u1", username: "vince" },
|
|
184
|
+
}, { schemaVersion: 1 });
|
|
185
|
+
persistence.setState("channel:everyone", {
|
|
186
|
+
draft: "cached draft",
|
|
187
|
+
replyToId: null,
|
|
188
|
+
lastCursor: null,
|
|
189
|
+
lastViewedMessageId: null,
|
|
190
|
+
}, { schemaVersion: 1 });
|
|
191
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
192
|
+
messages: [],
|
|
193
|
+
}, {
|
|
194
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
195
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
196
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
controller.attachPersistence(persistence);
|
|
200
|
+
controller.reset(true);
|
|
201
|
+
|
|
202
|
+
expect(apiClient.getSessionToken()).toBeNull();
|
|
203
|
+
expect(persistence.getState("session", { schemaVersion: 1 })).toBeNull();
|
|
204
|
+
expect(persistence.getResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
205
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
206
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
207
|
+
})).toBeNull();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("defers draft persistence and subscriber sync until the user pauses or leaves", () => {
|
|
211
|
+
const persistence = new TrackingPersistence();
|
|
212
|
+
const controller = new ChatController();
|
|
213
|
+
const draftSnapshots: string[] = [];
|
|
214
|
+
|
|
215
|
+
controller.attachPersistence(persistence);
|
|
216
|
+
const unsubscribe = controller.subscribe((snapshot) => {
|
|
217
|
+
draftSnapshots.push(snapshot.draft);
|
|
218
|
+
});
|
|
219
|
+
draftSnapshots.length = 0;
|
|
220
|
+
persistence.stateWrites = 0;
|
|
221
|
+
|
|
222
|
+
controller.setDraft("h");
|
|
223
|
+
controller.setDraft("he");
|
|
224
|
+
|
|
225
|
+
expect(controller.getSnapshot().draft).toBe("he");
|
|
226
|
+
expect(draftSnapshots).toEqual([]);
|
|
227
|
+
expect(persistence.stateWrites).toBe(0);
|
|
228
|
+
expect(persistence.getState("channel:everyone", { schemaVersion: 1 })).toBeNull();
|
|
229
|
+
|
|
230
|
+
unsubscribe();
|
|
231
|
+
controller.dispose();
|
|
232
|
+
|
|
233
|
+
expect(persistence.getState<{ draft: string }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
234
|
+
draft: "he",
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test("pauses verification polling while the app is backgrounded", () => {
|
|
239
|
+
const controller = new ChatController();
|
|
240
|
+
|
|
241
|
+
apiClient.setSessionToken("token-123");
|
|
242
|
+
(controller as any).sessionToken = "token-123";
|
|
243
|
+
(controller as any).user = { id: "u1", username: "vince", emailVerified: false };
|
|
244
|
+
|
|
245
|
+
controller.setAppActive(false);
|
|
246
|
+
(controller as any).realtime.syncVerificationPolling();
|
|
247
|
+
expect((controller as any).realtime.verificationPollTimer).toBeNull();
|
|
248
|
+
|
|
249
|
+
controller.setAppActive(true);
|
|
250
|
+
expect((controller as any).realtime.verificationPollTimer).not.toBeNull();
|
|
251
|
+
|
|
252
|
+
controller.reset(true);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("dispose stops verification polling and closes the live connection", () => {
|
|
256
|
+
const controller = new ChatController();
|
|
257
|
+
let closed = false;
|
|
258
|
+
|
|
259
|
+
apiClient.setSessionToken("token-123");
|
|
260
|
+
(controller as any).sessionToken = "token-123";
|
|
261
|
+
(controller as any).user = { id: "u1", username: "vince", emailVerified: false };
|
|
262
|
+
(controller as any).realtime.syncVerificationPolling();
|
|
263
|
+
expect((controller as any).realtime.verificationPollTimer).not.toBeNull();
|
|
264
|
+
|
|
265
|
+
(controller as any).user = { id: "u1", username: "vince", emailVerified: true };
|
|
266
|
+
apiClient.connectChannel = () => ({
|
|
267
|
+
send: async () => {
|
|
268
|
+
throw new Error("not implemented");
|
|
269
|
+
},
|
|
270
|
+
close: () => {
|
|
271
|
+
closed = true;
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
controller.ensureConnection();
|
|
276
|
+
|
|
277
|
+
controller.dispose();
|
|
278
|
+
|
|
279
|
+
expect(closed).toBe(true);
|
|
280
|
+
expect((controller as any).realtime.verificationPollTimer).toBeNull();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("runs a quiet safety refresh while the live connection is active", async () => {
|
|
284
|
+
const persistence = new MemoryPersistence();
|
|
285
|
+
const controller = new ChatController();
|
|
286
|
+
const originalSetInterval = globalThis.setInterval;
|
|
287
|
+
const originalClearInterval = globalThis.clearInterval;
|
|
288
|
+
const intervalCallbacks: Array<() => void> = [];
|
|
289
|
+
const intervalHandle = { unref: () => {} };
|
|
290
|
+
let cleared = false;
|
|
291
|
+
let getMessagesCalls = 0;
|
|
292
|
+
const loadingSnapshots: boolean[] = [];
|
|
293
|
+
|
|
294
|
+
persistence.setState("session", {
|
|
295
|
+
sessionToken: "token-123",
|
|
296
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
297
|
+
}, { schemaVersion: 1 });
|
|
298
|
+
|
|
299
|
+
(globalThis as any).setInterval = (callback: () => void, timeout: number) => {
|
|
300
|
+
expect(timeout).toBe(30_000);
|
|
301
|
+
intervalCallbacks.push(callback);
|
|
302
|
+
return intervalHandle;
|
|
303
|
+
};
|
|
304
|
+
(globalThis as any).clearInterval = (handle: unknown) => {
|
|
305
|
+
if (handle === intervalHandle) {
|
|
306
|
+
cleared = true;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
apiClient.getMessages = async () => {
|
|
312
|
+
getMessagesCalls += 1;
|
|
313
|
+
return [];
|
|
314
|
+
};
|
|
315
|
+
apiClient.connectChannel = () => ({
|
|
316
|
+
send: async () => {
|
|
317
|
+
throw new Error("not implemented");
|
|
318
|
+
},
|
|
319
|
+
close: () => {},
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
controller.attachPersistence(persistence);
|
|
323
|
+
controller.ensureConnection();
|
|
324
|
+
await flushMicrotasks();
|
|
325
|
+
|
|
326
|
+
expect(intervalCallbacks).toHaveLength(1);
|
|
327
|
+
expect(getMessagesCalls).toBe(1);
|
|
328
|
+
expect(controller.getSnapshot().loading).toBe(false);
|
|
329
|
+
|
|
330
|
+
controller.subscribe((snapshot) => {
|
|
331
|
+
loadingSnapshots.push(snapshot.loading);
|
|
332
|
+
});
|
|
333
|
+
loadingSnapshots.length = 0;
|
|
334
|
+
|
|
335
|
+
intervalCallbacks[0]!();
|
|
336
|
+
await flushMicrotasks();
|
|
337
|
+
|
|
338
|
+
expect(getMessagesCalls).toBe(2);
|
|
339
|
+
expect(loadingSnapshots).toEqual([false]);
|
|
340
|
+
|
|
341
|
+
controller.clearSession();
|
|
342
|
+
expect((controller as any).realtime.safetyRefreshTimer).toBeNull();
|
|
343
|
+
expect(cleared).toBe(true);
|
|
344
|
+
} finally {
|
|
345
|
+
controller.dispose();
|
|
346
|
+
(globalThis as any).setInterval = originalSetInterval;
|
|
347
|
+
(globalThis as any).clearInterval = originalClearInterval;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test("keeps the cached session when session refresh fails transiently", async () => {
|
|
352
|
+
const persistence = new MemoryPersistence();
|
|
353
|
+
const controller = new ChatController();
|
|
354
|
+
|
|
355
|
+
persistence.setState("session", {
|
|
356
|
+
sessionToken: "token-123",
|
|
357
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
358
|
+
}, { schemaVersion: 1 });
|
|
359
|
+
|
|
360
|
+
controller.attachPersistence(persistence);
|
|
361
|
+
apiClient.getSession = async () => {
|
|
362
|
+
throw new Error("network down");
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
await expect(controller.refreshSession()).rejects.toThrow("network down");
|
|
366
|
+
expect(apiClient.getSessionToken()).toBe("token-123");
|
|
367
|
+
expect(persistence.getState<{
|
|
368
|
+
sessionToken: string;
|
|
369
|
+
user: { id: string; username: string; emailVerified: boolean };
|
|
370
|
+
}>("session", { schemaVersion: 1 })).toEqual({
|
|
371
|
+
sessionToken: "token-123",
|
|
372
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
373
|
+
});
|
|
374
|
+
expect(controller.getSnapshot().user).toEqual({
|
|
375
|
+
id: "u1",
|
|
376
|
+
username: "vince",
|
|
377
|
+
emailVerified: true,
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
test("refreshes the public transcript without requiring a session", async () => {
|
|
382
|
+
const persistence = new MemoryPersistence();
|
|
383
|
+
const controller = new ChatController();
|
|
384
|
+
const message: ChatMessage = {
|
|
385
|
+
id: "m1",
|
|
386
|
+
channelId: "everyone",
|
|
387
|
+
content: "hello from the lobby",
|
|
388
|
+
replyToId: null,
|
|
389
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
390
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
controller.attachPersistence(persistence);
|
|
394
|
+
apiClient.getMessages = async () => [message];
|
|
395
|
+
|
|
396
|
+
await controller.refreshMessages();
|
|
397
|
+
|
|
398
|
+
expect(controller.getSnapshot().messages).toEqual([message]);
|
|
399
|
+
expect(persistence.getResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
400
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
401
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
402
|
+
})?.value).toEqual({
|
|
403
|
+
messages: [message],
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
test("keeps per-channel drafts and transcripts isolated", () => {
|
|
408
|
+
const persistence = new MemoryPersistence();
|
|
409
|
+
const controller = new ChatController();
|
|
410
|
+
const everyoneMessage: ChatMessage = {
|
|
411
|
+
id: "m1",
|
|
412
|
+
channelId: "everyone",
|
|
413
|
+
content: "general",
|
|
414
|
+
replyToId: null,
|
|
415
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
416
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
417
|
+
};
|
|
418
|
+
const optionsMessage: ChatMessage = {
|
|
419
|
+
id: "m2",
|
|
420
|
+
channelId: "options",
|
|
421
|
+
content: "options note",
|
|
422
|
+
replyToId: null,
|
|
423
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
424
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
persistence.setState("channel:everyone", {
|
|
428
|
+
draft: "general draft",
|
|
429
|
+
replyToId: null,
|
|
430
|
+
lastCursor: "m1",
|
|
431
|
+
lastViewedMessageId: "m1",
|
|
432
|
+
}, { schemaVersion: 1 });
|
|
433
|
+
persistence.setState("channel:options", {
|
|
434
|
+
draft: "options draft",
|
|
435
|
+
replyToId: null,
|
|
436
|
+
lastCursor: "m2",
|
|
437
|
+
lastViewedMessageId: "m2",
|
|
438
|
+
}, { schemaVersion: 1 });
|
|
439
|
+
persistence.setResource(TRANSCRIPT_KIND, "everyone", { messages: [everyoneMessage] }, {
|
|
440
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
441
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
442
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
443
|
+
});
|
|
444
|
+
persistence.setResource(TRANSCRIPT_KIND, "options", { messages: [optionsMessage] }, {
|
|
445
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
446
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
447
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
controller.attachPersistence(persistence);
|
|
451
|
+
controller.setChannelDraft("options", "updated options");
|
|
452
|
+
|
|
453
|
+
expect(controller.getSnapshot().messages.map((entry) => entry.content)).toEqual(["general"]);
|
|
454
|
+
expect(controller.getSnapshot().draft).toBe("general draft");
|
|
455
|
+
expect(controller.getSnapshot("options").messages.map((entry) => entry.content)).toEqual(["options note"]);
|
|
456
|
+
expect(controller.getSnapshot("options").draft).toBe("updated options");
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
test("stores the latest message id as the incremental cursor", async () => {
|
|
460
|
+
const persistence = new MemoryPersistence();
|
|
461
|
+
const controller = new ChatController();
|
|
462
|
+
const initial: ChatMessage = {
|
|
463
|
+
id: "m1",
|
|
464
|
+
channelId: "everyone",
|
|
465
|
+
content: "hello",
|
|
466
|
+
replyToId: null,
|
|
467
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
468
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
469
|
+
};
|
|
470
|
+
const next: ChatMessage = {
|
|
471
|
+
id: "m2",
|
|
472
|
+
channelId: "everyone",
|
|
473
|
+
content: "new message",
|
|
474
|
+
replyToId: null,
|
|
475
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
476
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
persistence.setState("channel:everyone", {
|
|
480
|
+
draft: "",
|
|
481
|
+
replyToId: null,
|
|
482
|
+
lastCursor: "m1",
|
|
483
|
+
lastViewedMessageId: "m1",
|
|
484
|
+
}, { schemaVersion: 1 });
|
|
485
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
486
|
+
messages: [initial],
|
|
487
|
+
}, {
|
|
488
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
489
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
490
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
controller.attachPersistence(persistence);
|
|
494
|
+
|
|
495
|
+
const calls: Array<{ channelId: string; opts?: { after?: string; before?: string; limit?: number } }> = [];
|
|
496
|
+
apiClient.getMessages = async (channelId, opts) => {
|
|
497
|
+
calls.push({ channelId, opts });
|
|
498
|
+
return opts?.after === "m1" ? [next] : [];
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
await controller.refreshMessages();
|
|
502
|
+
|
|
503
|
+
expect(calls).toEqual([{
|
|
504
|
+
channelId: "everyone",
|
|
505
|
+
opts: { limit: 50, after: "m1" },
|
|
506
|
+
}]);
|
|
507
|
+
expect(controller.getSnapshot().messages.map((entry) => entry.id)).toEqual(["m1", "m2"]);
|
|
508
|
+
expect(persistence.getState<{ lastCursor: string }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
509
|
+
lastCursor: "m2",
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test("hydrates missing transcript cache without marking history unread", async () => {
|
|
514
|
+
const persistence = new MemoryPersistence();
|
|
515
|
+
const controller = new ChatController();
|
|
516
|
+
const notifications: AppNotificationRequest[] = [];
|
|
517
|
+
const history: ChatMessage = {
|
|
518
|
+
id: "m1",
|
|
519
|
+
channelId: "everyone",
|
|
520
|
+
content: "already seen",
|
|
521
|
+
replyToId: null,
|
|
522
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
523
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
persistence.setState("session", {
|
|
527
|
+
sessionToken: "token-123",
|
|
528
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
529
|
+
}, { schemaVersion: 1 });
|
|
530
|
+
persistence.setState("channel:everyone", {
|
|
531
|
+
draft: "",
|
|
532
|
+
replyToId: null,
|
|
533
|
+
lastCursor: "m1",
|
|
534
|
+
lastViewedMessageId: "m1",
|
|
535
|
+
}, { schemaVersion: 1 });
|
|
536
|
+
|
|
537
|
+
controller.setNotifier((notification) => {
|
|
538
|
+
notifications.push(notification);
|
|
539
|
+
});
|
|
540
|
+
controller.attachPersistence(persistence);
|
|
541
|
+
|
|
542
|
+
const calls: Array<{ channelId: string; opts?: { after?: string; before?: string; limit?: number } }> = [];
|
|
543
|
+
apiClient.getMessages = async (channelId, opts) => {
|
|
544
|
+
calls.push({ channelId, opts });
|
|
545
|
+
return opts?.after ? [] : [history];
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
await controller.refreshMessages();
|
|
549
|
+
|
|
550
|
+
expect(calls).toEqual([{
|
|
551
|
+
channelId: "everyone",
|
|
552
|
+
opts: { limit: 50, after: undefined },
|
|
553
|
+
}]);
|
|
554
|
+
expect(controller.getSnapshot().messages).toEqual([history]);
|
|
555
|
+
expect(controller.getSnapshot().channelStates.find((entry) => entry.channelId === "everyone")).toMatchObject({
|
|
556
|
+
unreadCount: 0,
|
|
557
|
+
});
|
|
558
|
+
expect(notifications).toEqual([]);
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
test("backfills from cached transcript when persisted cursor is ahead of the cache", async () => {
|
|
562
|
+
const persistence = new MemoryPersistence();
|
|
563
|
+
const controller = new ChatController();
|
|
564
|
+
const cached: ChatMessage = {
|
|
565
|
+
id: "m1",
|
|
566
|
+
channelId: "everyone",
|
|
567
|
+
content: "cached",
|
|
568
|
+
replyToId: null,
|
|
569
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
570
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
571
|
+
};
|
|
572
|
+
const fresh: ChatMessage = {
|
|
573
|
+
id: "m2",
|
|
574
|
+
channelId: "everyone",
|
|
575
|
+
content: "fresh",
|
|
576
|
+
replyToId: null,
|
|
577
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
578
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
persistence.setState("channel:everyone", {
|
|
582
|
+
draft: "",
|
|
583
|
+
replyToId: null,
|
|
584
|
+
lastCursor: "m99",
|
|
585
|
+
lastViewedMessageId: "m1",
|
|
586
|
+
}, { schemaVersion: 1 });
|
|
587
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
588
|
+
messages: [cached],
|
|
589
|
+
}, {
|
|
590
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
591
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
592
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
controller.attachPersistence(persistence);
|
|
596
|
+
|
|
597
|
+
const calls: Array<{ channelId: string; opts?: { after?: string; before?: string; limit?: number } }> = [];
|
|
598
|
+
apiClient.getMessages = async (channelId, opts) => {
|
|
599
|
+
calls.push({ channelId, opts });
|
|
600
|
+
return opts?.after === "m1" ? [fresh] : [];
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
await controller.refreshMessages();
|
|
604
|
+
|
|
605
|
+
expect(calls).toEqual([{
|
|
606
|
+
channelId: "everyone",
|
|
607
|
+
opts: { limit: 50, after: "m1" },
|
|
608
|
+
}]);
|
|
609
|
+
expect(controller.getSnapshot().messages.map((entry) => entry.id)).toEqual(["m1", "m2"]);
|
|
610
|
+
expect(persistence.getState<{ lastCursor: string }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
611
|
+
lastCursor: "m2",
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
test("shows a pending message immediately and replaces it when the send succeeds", async () => {
|
|
616
|
+
const persistence = new MemoryPersistence();
|
|
617
|
+
const controller = new ChatController();
|
|
618
|
+
const replyTarget: ChatMessage = {
|
|
619
|
+
id: "m1",
|
|
620
|
+
channelId: "everyone",
|
|
621
|
+
content: "first",
|
|
622
|
+
replyToId: null,
|
|
623
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
624
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
625
|
+
};
|
|
626
|
+
const sentMessage: ChatMessage = {
|
|
627
|
+
id: "m2",
|
|
628
|
+
channelId: "everyone",
|
|
629
|
+
content: "hello",
|
|
630
|
+
replyToId: "m1",
|
|
631
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
632
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
633
|
+
replyTo: { content: "first", user: { username: "bob" } },
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
persistence.setState("session", {
|
|
637
|
+
sessionToken: "token-123",
|
|
638
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
639
|
+
}, { schemaVersion: 1 });
|
|
640
|
+
persistence.setState("channel:everyone", {
|
|
641
|
+
draft: "hello",
|
|
642
|
+
replyToId: "m1",
|
|
643
|
+
lastCursor: "m1",
|
|
644
|
+
lastViewedMessageId: "m1",
|
|
645
|
+
}, { schemaVersion: 1 });
|
|
646
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
647
|
+
messages: [replyTarget],
|
|
648
|
+
}, {
|
|
649
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
650
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
651
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
controller.attachPersistence(persistence);
|
|
655
|
+
|
|
656
|
+
let resolveSend: (message: ChatMessage) => void = () => {
|
|
657
|
+
throw new Error("send resolver was not captured");
|
|
658
|
+
};
|
|
659
|
+
apiClient.connectChannel = () => ({
|
|
660
|
+
send: () => new Promise<ChatMessage>((resolve) => {
|
|
661
|
+
resolveSend = resolve;
|
|
662
|
+
}),
|
|
663
|
+
close: () => {},
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
controller.send("hello", "m1");
|
|
667
|
+
|
|
668
|
+
let snapshot = controller.getSnapshot();
|
|
669
|
+
expect(snapshot.draft).toBe("");
|
|
670
|
+
expect(snapshot.replyToId).toBeNull();
|
|
671
|
+
expect(snapshot.messages.map((message) => message.id)).toEqual(["m1", snapshot.messages[1]!.id]);
|
|
672
|
+
expect(snapshot.messages[1]).toMatchObject({
|
|
673
|
+
content: "hello",
|
|
674
|
+
replyToId: "m1",
|
|
675
|
+
clientStatus: "sending",
|
|
676
|
+
replyTo: { content: "first", user: { username: "bob" } },
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
resolveSend?.(sentMessage);
|
|
680
|
+
await flushMicrotasks();
|
|
681
|
+
|
|
682
|
+
snapshot = controller.getSnapshot();
|
|
683
|
+
expect(snapshot.messages).toEqual([replyTarget, sentMessage]);
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
test("sends one idempotency key while the same message is pending", () => {
|
|
687
|
+
const persistence = new MemoryPersistence();
|
|
688
|
+
const controller = new ChatController();
|
|
689
|
+
const clientMessageIds: Array<string | undefined> = [];
|
|
690
|
+
|
|
691
|
+
persistence.setState("session", {
|
|
692
|
+
sessionToken: "token-123",
|
|
693
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
694
|
+
}, { schemaVersion: 1 });
|
|
695
|
+
|
|
696
|
+
controller.attachPersistence(persistence);
|
|
697
|
+
apiClient.getMessages = async () => [];
|
|
698
|
+
apiClient.connectChannel = () => ({
|
|
699
|
+
send: (_content, _replyToId, clientMessageId) => {
|
|
700
|
+
clientMessageIds.push(clientMessageId);
|
|
701
|
+
return new Promise<ChatMessage>(() => {});
|
|
702
|
+
},
|
|
703
|
+
close: () => {},
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
const detachFirstView = controller.attachChannelView("everyone");
|
|
707
|
+
const detachSecondView = controller.attachChannelView("everyone");
|
|
708
|
+
|
|
709
|
+
controller.sendToChannel("everyone", " hello ");
|
|
710
|
+
controller.sendToChannel("everyone", "hello");
|
|
711
|
+
|
|
712
|
+
expect(clientMessageIds).toHaveLength(1);
|
|
713
|
+
expect(clientMessageIds[0]).toBeTruthy();
|
|
714
|
+
expect(controller.getSnapshot("everyone").messages).toHaveLength(1);
|
|
715
|
+
|
|
716
|
+
detachFirstView();
|
|
717
|
+
detachSecondView();
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
test("marks a pending message as failed when sending errors", async () => {
|
|
721
|
+
const persistence = new MemoryPersistence();
|
|
722
|
+
const controller = new ChatController();
|
|
723
|
+
const notifications: AppNotificationRequest[] = [];
|
|
724
|
+
|
|
725
|
+
persistence.setState("session", {
|
|
726
|
+
sessionToken: "token-123",
|
|
727
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
728
|
+
}, { schemaVersion: 1 });
|
|
729
|
+
|
|
730
|
+
controller.setNotifier((notification) => {
|
|
731
|
+
notifications.push(notification);
|
|
732
|
+
});
|
|
733
|
+
controller.attachPersistence(persistence);
|
|
734
|
+
|
|
735
|
+
apiClient.connectChannel = () => ({
|
|
736
|
+
send: async () => {
|
|
737
|
+
throw new Error("server offline");
|
|
738
|
+
},
|
|
739
|
+
close: () => {},
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
controller.send("hello");
|
|
743
|
+
await flushMicrotasks();
|
|
744
|
+
|
|
745
|
+
const snapshot = controller.getSnapshot();
|
|
746
|
+
expect(snapshot.messages).toHaveLength(1);
|
|
747
|
+
expect(snapshot.messages[0]).toMatchObject({
|
|
748
|
+
content: "hello",
|
|
749
|
+
clientStatus: "failed",
|
|
750
|
+
clientError: "server offline",
|
|
751
|
+
});
|
|
752
|
+
expect(notifications).toEqual([{ body: "server offline", type: "error" }]);
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
test("tracks unread mentions from fetched messages without issuing local notifications", () => {
|
|
756
|
+
const persistence = new MemoryPersistence();
|
|
757
|
+
const controller = new ChatController();
|
|
758
|
+
const notifications: AppNotificationRequest[] = [];
|
|
759
|
+
const message: ChatMessage = {
|
|
760
|
+
id: "m1",
|
|
761
|
+
channelId: "everyone",
|
|
762
|
+
content: "hey @Vince can you take a look?",
|
|
763
|
+
replyToId: null,
|
|
764
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
765
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
persistence.setState("session", {
|
|
769
|
+
sessionToken: "token-123",
|
|
770
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
771
|
+
}, { schemaVersion: 1 });
|
|
772
|
+
|
|
773
|
+
controller.setNotifier((notification) => {
|
|
774
|
+
notifications.push(notification);
|
|
775
|
+
});
|
|
776
|
+
controller.attachPersistence(persistence);
|
|
777
|
+
|
|
778
|
+
(controller as any).mergeMessages([message]);
|
|
779
|
+
|
|
780
|
+
expect(controller.getSnapshot().unreadMentionCount).toBe(1);
|
|
781
|
+
expect(notifications).toEqual([]);
|
|
782
|
+
expect(persistence.getState<{ lastCursor: string | null; lastViewedMessageId: string | null }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
783
|
+
lastCursor: "m1",
|
|
784
|
+
lastViewedMessageId: null,
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
test("displays server-issued mention notifications while the app is backgrounded", () => {
|
|
789
|
+
const persistence = new MemoryPersistence();
|
|
790
|
+
const controller = new ChatController();
|
|
791
|
+
const notifications: AppNotificationRequest[] = [];
|
|
792
|
+
const message: ChatMessage = {
|
|
793
|
+
id: "m1",
|
|
794
|
+
channelId: "everyone",
|
|
795
|
+
content: "hey @vince",
|
|
796
|
+
replyToId: null,
|
|
797
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
798
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
persistence.setState("session", {
|
|
802
|
+
sessionToken: "token-123",
|
|
803
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
804
|
+
}, { schemaVersion: 1 });
|
|
805
|
+
|
|
806
|
+
controller.setNotifier((notification) => {
|
|
807
|
+
notifications.push(notification);
|
|
808
|
+
});
|
|
809
|
+
controller.attachPersistence(persistence);
|
|
810
|
+
controller.setAppActive(false);
|
|
811
|
+
|
|
812
|
+
(controller as any).handleChatNotification({
|
|
813
|
+
id: "n1",
|
|
814
|
+
type: "mention",
|
|
815
|
+
channelId: "everyone",
|
|
816
|
+
messageId: "m1",
|
|
817
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
818
|
+
message,
|
|
819
|
+
} satisfies ChatNotification);
|
|
820
|
+
|
|
821
|
+
expect(notifications).toEqual([{
|
|
822
|
+
title: "Gloomberb chat",
|
|
823
|
+
subtitle: "#everyone",
|
|
824
|
+
body: "@bob mentioned you: hey @vince",
|
|
825
|
+
type: "info",
|
|
826
|
+
desktop: "when-inactive",
|
|
827
|
+
}]);
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
test("marks mentions viewed when a chat view opens", () => {
|
|
831
|
+
const persistence = new MemoryPersistence();
|
|
832
|
+
const controller = new ChatController();
|
|
833
|
+
const notifications: AppNotificationRequest[] = [];
|
|
834
|
+
const message: ChatMessage = {
|
|
835
|
+
id: "m1",
|
|
836
|
+
channelId: "everyone",
|
|
837
|
+
content: "hey @vince",
|
|
838
|
+
replyToId: null,
|
|
839
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
840
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
persistence.setState("session", {
|
|
844
|
+
sessionToken: "token-123",
|
|
845
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
846
|
+
}, { schemaVersion: 1 });
|
|
847
|
+
|
|
848
|
+
controller.setNotifier((notification) => {
|
|
849
|
+
notifications.push(notification);
|
|
850
|
+
});
|
|
851
|
+
controller.attachPersistence(persistence);
|
|
852
|
+
|
|
853
|
+
(controller as any).mergeMessages([message]);
|
|
854
|
+
|
|
855
|
+
expect(controller.getSnapshot().unreadMentionCount).toBe(1);
|
|
856
|
+
|
|
857
|
+
const detachView = controller.attachView();
|
|
858
|
+
|
|
859
|
+
expect(controller.getSnapshot().unreadMentionCount).toBe(0);
|
|
860
|
+
expect(notifications).toEqual([]);
|
|
861
|
+
expect(persistence.getState<{ lastViewedMessageId: string | null }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
862
|
+
lastViewedMessageId: "m1",
|
|
863
|
+
});
|
|
864
|
+
detachView();
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
test("does not keep mentions unread while a chat view is already open", () => {
|
|
868
|
+
const persistence = new MemoryPersistence();
|
|
869
|
+
const controller = new ChatController();
|
|
870
|
+
const notifications: AppNotificationRequest[] = [];
|
|
871
|
+
const message: ChatMessage = {
|
|
872
|
+
id: "m1",
|
|
873
|
+
channelId: "everyone",
|
|
874
|
+
content: "hey @vince",
|
|
875
|
+
replyToId: null,
|
|
876
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
877
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
persistence.setState("session", {
|
|
881
|
+
sessionToken: "token-123",
|
|
882
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
883
|
+
}, { schemaVersion: 1 });
|
|
884
|
+
|
|
885
|
+
controller.setNotifier((notification) => {
|
|
886
|
+
notifications.push(notification);
|
|
887
|
+
});
|
|
888
|
+
controller.attachPersistence(persistence);
|
|
889
|
+
const detachView = controller.attachView();
|
|
890
|
+
|
|
891
|
+
(controller as any).mergeMessages([message]);
|
|
892
|
+
|
|
893
|
+
expect(controller.getSnapshot().unreadMentionCount).toBe(0);
|
|
894
|
+
expect(notifications).toEqual([]);
|
|
895
|
+
expect(persistence.getState<{ lastViewedMessageId: string | null }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
896
|
+
lastViewedMessageId: "m1",
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
detachView();
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
test("loads server chat state, pending reply notifications, and acks delivery", async () => {
|
|
903
|
+
const persistence = new MemoryPersistence();
|
|
904
|
+
const controller = new ChatController();
|
|
905
|
+
const notifications: AppNotificationRequest[] = [];
|
|
906
|
+
const deliveredIds: string[][] = [];
|
|
907
|
+
|
|
908
|
+
persistence.setState("session", {
|
|
909
|
+
sessionToken: "token-123",
|
|
910
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
911
|
+
}, { schemaVersion: 1 });
|
|
912
|
+
apiClient.getSession = async () => ({
|
|
913
|
+
id: "u1",
|
|
914
|
+
name: "Vince",
|
|
915
|
+
email: "vince@example.com",
|
|
916
|
+
username: "vince",
|
|
917
|
+
emailVerified: true,
|
|
918
|
+
image: null,
|
|
919
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
920
|
+
updatedAt: "2026-01-01T00:00:00.000Z",
|
|
921
|
+
});
|
|
922
|
+
apiClient.getChatState = async () => ({
|
|
923
|
+
channels: SERVER_CHAT_CHANNELS,
|
|
924
|
+
onlineCount: 7,
|
|
925
|
+
channelStates: [{
|
|
926
|
+
channelId: "options",
|
|
927
|
+
notificationsEnabled: true,
|
|
928
|
+
lastReadMessageId: "m1",
|
|
929
|
+
unreadCount: 3,
|
|
930
|
+
}],
|
|
931
|
+
notifications: [{
|
|
932
|
+
id: "n1",
|
|
933
|
+
type: "reply",
|
|
934
|
+
channelId: "options",
|
|
935
|
+
messageId: "m2",
|
|
936
|
+
createdAt: "2026-03-28T00:02:00.000Z",
|
|
937
|
+
message: {
|
|
938
|
+
id: "m2",
|
|
939
|
+
channelId: "options",
|
|
940
|
+
content: "answering you",
|
|
941
|
+
replyToId: "m1",
|
|
942
|
+
createdAt: "2026-03-28T00:02:00.000Z",
|
|
943
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
944
|
+
replyTo: { content: "question", user: { id: "u1", username: "vince" } },
|
|
945
|
+
},
|
|
946
|
+
}],
|
|
947
|
+
});
|
|
948
|
+
apiClient.markChatNotificationsDelivered = async (ids) => {
|
|
949
|
+
deliveredIds.push(ids);
|
|
950
|
+
return { delivered: ids.length };
|
|
951
|
+
};
|
|
952
|
+
apiClient.connectChannel = () => ({
|
|
953
|
+
send: async () => {
|
|
954
|
+
throw new Error("not implemented");
|
|
955
|
+
},
|
|
956
|
+
close: () => {},
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
controller.setNotifier((notification) => {
|
|
960
|
+
notifications.push(notification);
|
|
961
|
+
});
|
|
962
|
+
controller.attachPersistence(persistence);
|
|
963
|
+
|
|
964
|
+
await controller.refreshSession();
|
|
965
|
+
|
|
966
|
+
expect(controller.getSnapshot("options").onlineCount).toBe(7);
|
|
967
|
+
expect(controller.getSnapshot("options").channelStates.find((entry) => entry.channelId === "options")).toMatchObject({
|
|
968
|
+
notificationsEnabled: true,
|
|
969
|
+
unreadCount: 3,
|
|
970
|
+
});
|
|
971
|
+
expect(notifications).toEqual([{
|
|
972
|
+
title: "Gloomberb chat",
|
|
973
|
+
subtitle: "#options",
|
|
974
|
+
body: "@bob replied to you: answering you",
|
|
975
|
+
type: "info",
|
|
976
|
+
desktop: "when-inactive",
|
|
977
|
+
}]);
|
|
978
|
+
expect(deliveredIds).toEqual([["n1"]]);
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
test("toggles channel notifications optimistically and keeps the channel connected", async () => {
|
|
982
|
+
const persistence = new MemoryPersistence();
|
|
983
|
+
const controller = new ChatController();
|
|
984
|
+
const connectedChannels: string[] = [];
|
|
985
|
+
|
|
986
|
+
persistence.setState("session", {
|
|
987
|
+
sessionToken: "token-123",
|
|
988
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
989
|
+
}, { schemaVersion: 1 });
|
|
990
|
+
apiClient.updateChatChannelState = async (channelId, body) => ({
|
|
991
|
+
channelId,
|
|
992
|
+
notificationsEnabled: body.notificationsEnabled === true,
|
|
993
|
+
lastReadMessageId: null,
|
|
994
|
+
unreadCount: 0,
|
|
995
|
+
});
|
|
996
|
+
apiClient.connectChannel = (channelId) => {
|
|
997
|
+
connectedChannels.push(channelId);
|
|
998
|
+
return {
|
|
999
|
+
send: async () => {
|
|
1000
|
+
throw new Error("not implemented");
|
|
1001
|
+
},
|
|
1002
|
+
close: () => {},
|
|
1003
|
+
};
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
controller.attachPersistence(persistence);
|
|
1007
|
+
controller.setChannelNotificationsEnabled("options", true);
|
|
1008
|
+
await flushMicrotasks();
|
|
1009
|
+
|
|
1010
|
+
expect(controller.getSnapshot("options").channelStates.find((entry) => entry.channelId === "options")).toMatchObject({
|
|
1011
|
+
notificationsEnabled: true,
|
|
1012
|
+
});
|
|
1013
|
+
expect(connectedChannels).toContain("options");
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
test("dedupes reply notifications by message id", () => {
|
|
1017
|
+
const persistence = new MemoryPersistence();
|
|
1018
|
+
const controller = new ChatController();
|
|
1019
|
+
const notifications: AppNotificationRequest[] = [];
|
|
1020
|
+
const notification: ChatNotification = {
|
|
1021
|
+
id: "n1",
|
|
1022
|
+
type: "reply",
|
|
1023
|
+
channelId: "everyone",
|
|
1024
|
+
messageId: "m2",
|
|
1025
|
+
createdAt: "2026-03-28T00:02:00.000Z",
|
|
1026
|
+
message: {
|
|
1027
|
+
id: "m2",
|
|
1028
|
+
channelId: "everyone",
|
|
1029
|
+
content: "same reply",
|
|
1030
|
+
replyToId: "m1",
|
|
1031
|
+
createdAt: "2026-03-28T00:02:00.000Z",
|
|
1032
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1033
|
+
replyTo: { content: "question", user: { id: "u1", username: "vince" } },
|
|
1034
|
+
},
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
persistence.setState("session", {
|
|
1038
|
+
sessionToken: "token-123",
|
|
1039
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
1040
|
+
}, { schemaVersion: 1 });
|
|
1041
|
+
controller.setNotifier((entry) => {
|
|
1042
|
+
notifications.push(entry);
|
|
1043
|
+
});
|
|
1044
|
+
controller.attachPersistence(persistence);
|
|
1045
|
+
|
|
1046
|
+
(controller as any).handleChatNotification(notification);
|
|
1047
|
+
(controller as any).handleChatNotification({ ...notification, id: "n2" });
|
|
1048
|
+
|
|
1049
|
+
expect(notifications).toHaveLength(1);
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
test("displays server-issued channel notifications", () => {
|
|
1053
|
+
const persistence = new MemoryPersistence();
|
|
1054
|
+
const controller = new ChatController();
|
|
1055
|
+
const notifications: AppNotificationRequest[] = [];
|
|
1056
|
+
const message: ChatMessage = {
|
|
1057
|
+
id: "m1",
|
|
1058
|
+
channelId: "options",
|
|
1059
|
+
content: "new option flow",
|
|
1060
|
+
replyToId: null,
|
|
1061
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1062
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
persistence.setState("session", {
|
|
1066
|
+
sessionToken: "token-123",
|
|
1067
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
1068
|
+
}, { schemaVersion: 1 });
|
|
1069
|
+
controller.setNotifier((entry) => {
|
|
1070
|
+
notifications.push(entry);
|
|
1071
|
+
});
|
|
1072
|
+
controller.attachPersistence(persistence);
|
|
1073
|
+
|
|
1074
|
+
(controller as any).handleChatNotification({
|
|
1075
|
+
id: "n1",
|
|
1076
|
+
type: "channel",
|
|
1077
|
+
channelId: "options",
|
|
1078
|
+
messageId: "m1",
|
|
1079
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1080
|
+
message,
|
|
1081
|
+
} satisfies ChatNotification);
|
|
1082
|
+
|
|
1083
|
+
expect(notifications).toEqual([{
|
|
1084
|
+
title: "Gloomberb chat",
|
|
1085
|
+
subtitle: "#options",
|
|
1086
|
+
body: "#options @bob: new option flow",
|
|
1087
|
+
type: "info",
|
|
1088
|
+
desktop: "when-inactive",
|
|
1089
|
+
}]);
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
test("tracks unread channel messages and clears them when the channel opens", () => {
|
|
1093
|
+
const persistence = new MemoryPersistence();
|
|
1094
|
+
const controller = new ChatController();
|
|
1095
|
+
const message: ChatMessage = {
|
|
1096
|
+
id: "m1",
|
|
1097
|
+
channelId: "options",
|
|
1098
|
+
content: "new option flow",
|
|
1099
|
+
replyToId: null,
|
|
1100
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1101
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
persistence.setState("session", {
|
|
1105
|
+
sessionToken: "token-123",
|
|
1106
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
1107
|
+
}, { schemaVersion: 1 });
|
|
1108
|
+
controller.attachPersistence(persistence);
|
|
1109
|
+
|
|
1110
|
+
(controller as any).mergeMessages("options", [message]);
|
|
1111
|
+
|
|
1112
|
+
expect(controller.getSnapshot("options").channelStates.find((entry) => entry.channelId === "options")).toMatchObject({
|
|
1113
|
+
unreadCount: 1,
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
const detachView = controller.attachChannelView("options");
|
|
1117
|
+
|
|
1118
|
+
expect(controller.getSnapshot("options").channelStates.find((entry) => entry.channelId === "options")).toMatchObject({
|
|
1119
|
+
unreadCount: 0,
|
|
1120
|
+
});
|
|
1121
|
+
detachView();
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
test("server reply notifications fire even when channel notifications are disabled", () => {
|
|
1125
|
+
const persistence = new MemoryPersistence();
|
|
1126
|
+
const controller = new ChatController();
|
|
1127
|
+
const notifications: AppNotificationRequest[] = [];
|
|
1128
|
+
const message: ChatMessage = {
|
|
1129
|
+
id: "m2",
|
|
1130
|
+
channelId: "options",
|
|
1131
|
+
content: "reply without channel notify",
|
|
1132
|
+
replyToId: "m1",
|
|
1133
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1134
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1135
|
+
replyTo: { content: "question", user: { id: "u1", username: "vince" } },
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
persistence.setState("session", {
|
|
1139
|
+
sessionToken: "token-123",
|
|
1140
|
+
user: { id: "u1", username: "vince", emailVerified: true },
|
|
1141
|
+
}, { schemaVersion: 1 });
|
|
1142
|
+
controller.setNotifier((notification) => {
|
|
1143
|
+
notifications.push(notification);
|
|
1144
|
+
});
|
|
1145
|
+
controller.attachPersistence(persistence);
|
|
1146
|
+
|
|
1147
|
+
(controller as any).handleChatNotification({
|
|
1148
|
+
id: "n1",
|
|
1149
|
+
type: "reply",
|
|
1150
|
+
channelId: "options",
|
|
1151
|
+
messageId: "m2",
|
|
1152
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1153
|
+
message,
|
|
1154
|
+
} satisfies ChatNotification);
|
|
1155
|
+
|
|
1156
|
+
expect(notifications).toEqual([{
|
|
1157
|
+
title: "Gloomberb chat",
|
|
1158
|
+
subtitle: "#options",
|
|
1159
|
+
body: "@bob replied to you: reply without channel notify",
|
|
1160
|
+
type: "info",
|
|
1161
|
+
desktop: "when-inactive",
|
|
1162
|
+
}]);
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
test("recovers from a legacy timestamp cursor by falling back to a full transcript fetch", async () => {
|
|
1166
|
+
const persistence = new MemoryPersistence();
|
|
1167
|
+
const controller = new ChatController();
|
|
1168
|
+
const cached: ChatMessage = {
|
|
1169
|
+
id: "m1",
|
|
1170
|
+
channelId: "everyone",
|
|
1171
|
+
content: "cached",
|
|
1172
|
+
replyToId: null,
|
|
1173
|
+
createdAt: "2026-03-28T00:00:00.000Z",
|
|
1174
|
+
user: { id: "u1", username: "vince", displayName: "Vince" },
|
|
1175
|
+
};
|
|
1176
|
+
const fullTranscript: ChatMessage[] = [
|
|
1177
|
+
cached,
|
|
1178
|
+
{
|
|
1179
|
+
id: "m2",
|
|
1180
|
+
channelId: "everyone",
|
|
1181
|
+
content: "fresh",
|
|
1182
|
+
replyToId: null,
|
|
1183
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
1184
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1185
|
+
},
|
|
1186
|
+
];
|
|
1187
|
+
|
|
1188
|
+
persistence.setState("channel:everyone", {
|
|
1189
|
+
draft: "",
|
|
1190
|
+
replyToId: null,
|
|
1191
|
+
lastCursor: "2026-03-28T00:00:00.000Z",
|
|
1192
|
+
lastViewedMessageId: "m1",
|
|
1193
|
+
}, { schemaVersion: 1 });
|
|
1194
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
1195
|
+
messages: [cached],
|
|
1196
|
+
}, {
|
|
1197
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
1198
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
1199
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
controller.attachPersistence(persistence);
|
|
1203
|
+
|
|
1204
|
+
const calls: Array<{ channelId: string; opts?: { after?: string; before?: string; limit?: number } }> = [];
|
|
1205
|
+
apiClient.getMessages = async (channelId, opts) => {
|
|
1206
|
+
calls.push({ channelId, opts });
|
|
1207
|
+
return opts?.after ? [] : fullTranscript;
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
await controller.refreshMessages();
|
|
1211
|
+
|
|
1212
|
+
expect(calls).toEqual([
|
|
1213
|
+
{
|
|
1214
|
+
channelId: "everyone",
|
|
1215
|
+
opts: { limit: 50, after: "2026-03-28T00:00:00.000Z" },
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
channelId: "everyone",
|
|
1219
|
+
opts: { limit: 50 },
|
|
1220
|
+
},
|
|
1221
|
+
]);
|
|
1222
|
+
expect(controller.getSnapshot().messages.map((entry) => entry.id)).toEqual(["m1", "m2"]);
|
|
1223
|
+
expect(persistence.getState<{ lastCursor: string }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
1224
|
+
lastCursor: "m2",
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
test("loads older messages before the oldest cached message without moving the latest cursor", async () => {
|
|
1229
|
+
const persistence = new MemoryPersistence();
|
|
1230
|
+
const controller = new ChatController();
|
|
1231
|
+
const cached: ChatMessage[] = [
|
|
1232
|
+
{
|
|
1233
|
+
id: "m3",
|
|
1234
|
+
channelId: "everyone",
|
|
1235
|
+
content: "cached older",
|
|
1236
|
+
replyToId: null,
|
|
1237
|
+
createdAt: "2026-03-28T00:03:00.000Z",
|
|
1238
|
+
user: { id: "u3", username: "cara", displayName: "Cara" },
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
id: "m4",
|
|
1242
|
+
channelId: "everyone",
|
|
1243
|
+
content: "cached newer",
|
|
1244
|
+
replyToId: null,
|
|
1245
|
+
createdAt: "2026-03-28T00:04:00.000Z",
|
|
1246
|
+
user: { id: "u4", username: "drew", displayName: "Drew" },
|
|
1247
|
+
},
|
|
1248
|
+
];
|
|
1249
|
+
const older: ChatMessage[] = [
|
|
1250
|
+
{
|
|
1251
|
+
id: "m1",
|
|
1252
|
+
channelId: "everyone",
|
|
1253
|
+
content: "oldest",
|
|
1254
|
+
replyToId: null,
|
|
1255
|
+
createdAt: "2026-03-28T00:01:00.000Z",
|
|
1256
|
+
user: { id: "u1", username: "alice", displayName: "Alice" },
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
id: "m2",
|
|
1260
|
+
channelId: "everyone",
|
|
1261
|
+
content: "older",
|
|
1262
|
+
replyToId: null,
|
|
1263
|
+
createdAt: "2026-03-28T00:02:00.000Z",
|
|
1264
|
+
user: { id: "u2", username: "bob", displayName: "Bob" },
|
|
1265
|
+
},
|
|
1266
|
+
];
|
|
1267
|
+
|
|
1268
|
+
persistence.setState("channel:everyone", {
|
|
1269
|
+
draft: "",
|
|
1270
|
+
replyToId: null,
|
|
1271
|
+
lastCursor: "m4",
|
|
1272
|
+
lastViewedMessageId: "m4",
|
|
1273
|
+
}, { schemaVersion: 1 });
|
|
1274
|
+
persistence.setResource(TRANSCRIPT_KIND, TRANSCRIPT_KEY, {
|
|
1275
|
+
messages: cached,
|
|
1276
|
+
}, {
|
|
1277
|
+
sourceKey: TRANSCRIPT_SOURCE,
|
|
1278
|
+
schemaVersion: TRANSCRIPT_SCHEMA_VERSION,
|
|
1279
|
+
cachePolicy: { staleMs: 1_000, expireMs: 2_000 },
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
controller.attachPersistence(persistence);
|
|
1283
|
+
|
|
1284
|
+
const calls: Array<{ channelId: string; opts?: { after?: string; before?: string; limit?: number } }> = [];
|
|
1285
|
+
apiClient.getMessages = async (channelId, opts) => {
|
|
1286
|
+
calls.push({ channelId, opts });
|
|
1287
|
+
return opts?.before === "m3" ? older : [];
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
await controller.loadOlderMessages();
|
|
1291
|
+
|
|
1292
|
+
expect(calls).toEqual([{
|
|
1293
|
+
channelId: "everyone",
|
|
1294
|
+
opts: { limit: 50, before: "m3" },
|
|
1295
|
+
}]);
|
|
1296
|
+
expect(controller.getSnapshot().messages.map((entry) => entry.id)).toEqual(["m1", "m2", "m3", "m4"]);
|
|
1297
|
+
expect(controller.getSnapshot().hasOlderMessages).toBe(false);
|
|
1298
|
+
expect(persistence.getState<{ lastCursor: string }>("channel:everyone", { schemaVersion: 1 })).toMatchObject({
|
|
1299
|
+
lastCursor: "m4",
|
|
1300
|
+
});
|
|
1301
|
+
});
|
|
1302
|
+
});
|