gloomberb 0.10.4 → 0.11.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.
Files changed (555) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -3
  3. package/README.zh-CN.md +1 -1
  4. package/package.json +5 -5
  5. package/src/api-client/auth.ts +34 -0
  6. package/src/api-client/data.ts +25 -0
  7. package/src/api-client/index.test.ts +81 -0
  8. package/src/api-client/index.ts +37 -0
  9. package/src/api-client/request.test.ts +30 -0
  10. package/src/api-client/request.ts +44 -20
  11. package/src/api-client/socket-health.test.ts +79 -0
  12. package/src/api-client/socket.ts +108 -5
  13. package/src/api-client/types.ts +139 -0
  14. package/src/app/global-shortcuts.test.tsx +144 -9
  15. package/src/app/global-shortcuts.ts +33 -11
  16. package/src/app/runtime/broker-import.ts +39 -5
  17. package/src/app/runtime/startup.ts +7 -1
  18. package/src/app/runtime/update.ts +26 -1
  19. package/src/app.tsx +36 -19
  20. package/src/brokers/broker-ticker-sync.ts +3 -8
  21. package/src/brokers/sync-broker-instance.test.ts +59 -0
  22. package/src/brokers/sync-broker-instance.ts +37 -13
  23. package/src/capabilities/chart-series.ts +318 -0
  24. package/src/capabilities/factories.ts +46 -0
  25. package/src/capabilities/index.ts +1 -0
  26. package/src/capabilities/registry.test.ts +135 -0
  27. package/src/capabilities/registry.ts +31 -4
  28. package/src/capabilities/types.ts +52 -0
  29. package/src/cli/commands/overview.ts +2 -2
  30. package/src/cli/desktop-pane-shot.ts +2 -0
  31. package/src/cli/entry.ts +11 -1
  32. package/src/cli/native-smoke.ts +5 -0
  33. package/src/cli/pane-functions/catalog.ts +4 -0
  34. package/src/cli/pane-functions/data.ts +6 -1
  35. package/src/cli/pane-functions/discovery.ts +76 -10
  36. package/src/cli/pane-functions/report.test.ts +76 -0
  37. package/src/cli/pane-functions/report.ts +7 -1
  38. package/src/cli/pane-functions/resolver.ts +4 -1
  39. package/src/cli/pane-functions/screenshot.test.ts +56 -3
  40. package/src/cli/pane-functions/screenshot.ts +68 -5
  41. package/src/components/chart/composite/composite-chart.test.tsx +54 -0
  42. package/src/components/chart/composite/composite-chart.tsx +92 -15
  43. package/src/components/chart/composite/downsample.test.ts +136 -0
  44. package/src/components/chart/composite/downsample.ts +208 -0
  45. package/src/components/chart/composite/panel-series.test.ts +66 -0
  46. package/src/components/chart/composite/panel-series.ts +101 -0
  47. package/src/components/chart/multi-line/renderer.ts +1 -0
  48. package/src/components/chart/native/kitty/index.test.ts +25 -3
  49. package/src/components/chart/native/kitty/support.ts +37 -3
  50. package/src/components/chart/native/use-chart-text-fallback.ts +19 -0
  51. package/src/components/chart/static/chart/surface.tsx +43 -12
  52. package/src/components/chart/static/multi-line-chart-surface.tsx +41 -5
  53. package/src/components/command-bar/commands/direct/index.ts +18 -0
  54. package/src/components/command-bar/commands/registry.ts +14 -0
  55. package/src/components/command-bar/routes/root/article-results.test.ts +83 -0
  56. package/src/components/command-bar/routes/root/article-results.ts +55 -0
  57. package/src/components/command-bar/routes/root/command-items.ts +3 -0
  58. package/src/components/command-bar/routes/root/provider-search.ts +7 -3
  59. package/src/components/command-bar/routes/root/results.ts +38 -11
  60. package/src/components/command-bar/routes/root/runtime.ts +6 -2
  61. package/src/components/command-bar/routes/ticker-search/actions.ts +1 -1
  62. package/src/components/command-bar/routes/ticker-search/results.test.ts +34 -0
  63. package/src/components/command-bar/routes/ticker-search/results.ts +4 -6
  64. package/src/components/command-bar/routes/ticker-search/route.ts +2 -2
  65. package/src/components/command-bar/routing/list-state.ts +2 -1
  66. package/src/components/command-bar/surface/assist.test.tsx +13 -6
  67. package/src/components/command-bar/surface/index.test.tsx +65 -0
  68. package/src/components/command-bar/surface/index.tsx +35 -0
  69. package/src/components/command-bar/view-model.test.ts +43 -0
  70. package/src/components/command-bar/view-model.ts +41 -4
  71. package/src/components/command-bar/workflow/collection-actions.test.ts +94 -0
  72. package/src/components/command-bar/workflow/collection-actions.ts +14 -3
  73. package/src/components/command-bar/workflow/ops.test.ts +136 -0
  74. package/src/components/command-bar/workflow/ops.ts +71 -1
  75. package/src/components/index.ts +1 -1
  76. package/src/components/layout/header.test.tsx +35 -0
  77. package/src/components/layout/header.tsx +101 -9
  78. package/src/components/layout/pane/cycle-order.test.ts +0 -1
  79. package/src/components/layout/pane/footer/index.test.tsx +19 -19
  80. package/src/components/layout/pane/header.tsx +2 -13
  81. package/src/components/layout/shell/index.tsx +3 -0
  82. package/src/components/layout/status-bar.test.tsx +36 -1
  83. package/src/components/layout/status-bar.tsx +48 -2
  84. package/src/components/onboarding/account-step/chooser-panel.tsx +27 -50
  85. package/src/components/onboarding/account-step/form-panel.tsx +85 -29
  86. package/src/components/onboarding/account-step/index.tsx +10 -1
  87. package/src/components/onboarding/account-step/model.ts +3 -3
  88. package/src/components/onboarding/account-step/qr-panel.tsx +68 -0
  89. package/src/components/onboarding/account-step/signed-in-panel.tsx +4 -7
  90. package/src/components/onboarding/onboarding-frame.tsx +517 -0
  91. package/src/components/onboarding/onboarding-steps.tsx +0 -264
  92. package/src/components/onboarding/onboarding-wizard.test.tsx +626 -200
  93. package/src/components/onboarding/onboarding-wizard.tsx +848 -266
  94. package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +81 -51
  95. package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +14 -20
  96. package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +8 -11
  97. package/src/components/onboarding/portfolio-step/choose-panel.tsx +18 -22
  98. package/src/components/onboarding/portfolio-step/index.tsx +3 -0
  99. package/src/components/onboarding/portfolio-step/types.ts +3 -0
  100. package/src/components/onboarding/wizard-account.ts +38 -3
  101. package/src/components/onboarding/wizard-broker-sync.ts +45 -67
  102. package/src/components/onboarding/wizard-model.ts +18 -2
  103. package/src/components/ui/data-table/opentui/index.tsx +29 -9
  104. package/src/components/ui/data-table/types.ts +2 -0
  105. package/src/components/ui/external-link.tsx +4 -2
  106. package/src/components/ui/loading.tsx +1 -1
  107. package/src/components/ui/status.tsx +76 -4
  108. package/src/components/ui/table-layout.test.ts +24 -0
  109. package/src/components/ui/table-layout.ts +90 -23
  110. package/src/components/ui/tabs.tsx +86 -4
  111. package/src/core/app-services.ts +14 -3
  112. package/src/core/connection-health.test.ts +143 -0
  113. package/src/core/connection-health.ts +295 -0
  114. package/src/core/state/app/layout-reducer.ts +34 -0
  115. package/src/core/state/app/layout.ts +21 -0
  116. package/src/core/state/app/state.ts +10 -0
  117. package/src/core/state/app/types.ts +7 -1
  118. package/src/data/config/chart-settings.ts +11 -2
  119. package/src/data/config/store/index.test.ts +83 -9
  120. package/src/data/config/store/migrations.ts +16 -0
  121. package/src/data/config/store/normalize.ts +59 -1
  122. package/src/data/fred-series.ts +8 -2
  123. package/src/i18n/es.ts +126 -0
  124. package/src/i18n/ja.ts +126 -0
  125. package/src/i18n/ko.ts +126 -0
  126. package/src/i18n/zh-cn.ts +126 -0
  127. package/src/i18n/zh-tw.ts +126 -0
  128. package/src/market-data/coordinator/chart.ts +3 -2
  129. package/src/market-data/hooks.tsx +3 -2
  130. package/src/market-data/market/status.test.ts +12 -0
  131. package/src/market-data/market/status.ts +34 -17
  132. package/src/news/aggregator.test.ts +39 -0
  133. package/src/news/aggregator.ts +78 -22
  134. package/src/news/hooks.ts +4 -0
  135. package/src/notifications/app-notifier.test.ts +28 -6
  136. package/src/notifications/app-notifier.ts +24 -5
  137. package/src/plugins/broker-sync/broker-sync.test.ts +130 -0
  138. package/src/plugins/broker-sync/native-loader.ts +10 -0
  139. package/src/plugins/broker-sync/normalize.ts +271 -0
  140. package/src/plugins/broker-sync/public.ts +122 -0
  141. package/src/plugins/broker-sync/robinhood-native.ts +367 -0
  142. package/src/plugins/broker-sync/robinhood.ts +114 -0
  143. package/src/plugins/broker-sync/simplefin-native.ts +201 -0
  144. package/src/plugins/broker-sync/simplefin.ts +70 -0
  145. package/src/plugins/builtin/account-management/footer.ts +8 -19
  146. package/src/plugins/builtin/account-management/pane.tsx +13 -8
  147. package/src/plugins/builtin/ai/pi/host.ts +6 -5
  148. package/src/plugins/builtin/ai/providers.ts +1 -1
  149. package/src/plugins/builtin/ai/screener/footer.ts +0 -7
  150. package/src/plugins/builtin/ai/screener/pane.test.tsx +2 -1
  151. package/src/plugins/builtin/ai/screener/pane.tsx +3 -1
  152. package/src/plugins/builtin/ai/screener/results-view.tsx +8 -0
  153. package/src/plugins/builtin/ai/screener/runner.ts +7 -3
  154. package/src/plugins/builtin/ai/workspace/pane.tsx +13 -2
  155. package/src/plugins/builtin/alerts/alert-engine.ts +13 -0
  156. package/src/plugins/builtin/alerts/constants.ts +2 -1
  157. package/src/plugins/builtin/alerts/index.tsx +67 -36
  158. package/src/plugins/builtin/alerts/pane.tsx +17 -65
  159. package/src/plugins/builtin/analytics/index.tsx +24 -11
  160. package/src/plugins/builtin/analytics/pane-model.ts +48 -14
  161. package/src/plugins/builtin/analytics/portfolio-selection.ts +19 -0
  162. package/src/plugins/builtin/analytics/view.tsx +5 -3
  163. package/src/plugins/builtin/broker-manager/detail.tsx +7 -2
  164. package/src/plugins/builtin/broker-manager/footer.ts +4 -9
  165. package/src/plugins/builtin/broker-manager/index.tsx +1 -6
  166. package/src/plugins/builtin/buildout/detail/ui.tsx +15 -4
  167. package/src/plugins/builtin/buildout/pane/header.tsx +1 -0
  168. package/src/plugins/builtin/changelog/index.tsx +60 -45
  169. package/src/plugins/builtin/chart-composer/catalog-inventory.test.ts +97 -0
  170. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +366 -0
  171. package/src/plugins/builtin/chart-composer/chart-spec.ts +21 -1
  172. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +307 -0
  173. package/src/plugins/builtin/chart-composer/editor/controller.ts +1 -1
  174. package/src/plugins/builtin/chart-composer/index.tsx +45 -5
  175. package/src/plugins/builtin/chart-composer/pane.tsx +7 -88
  176. package/src/plugins/builtin/chart-composer/presets.test.ts +48 -0
  177. package/src/plugins/builtin/chart-composer/presets.ts +69 -3
  178. package/src/plugins/builtin/chart-composer/quick-add.tsx +8 -5
  179. package/src/plugins/builtin/chart-composer/semantic.ts +18 -14
  180. package/src/plugins/builtin/chart-composer/series-catalog.test.ts +39 -0
  181. package/src/plugins/builtin/chart-composer/series-catalog.ts +104 -3
  182. package/src/plugins/builtin/chart-composer/shortcuts.test.ts +10 -10
  183. package/src/plugins/builtin/chart-composer/shortcuts.ts +4 -12
  184. package/src/plugins/builtin/chart-composer/use-series-catalog.ts +230 -23
  185. package/src/plugins/builtin/chat/chat.test.tsx +22 -0
  186. package/src/plugins/builtin/chat/content/composer.tsx +6 -4
  187. package/src/plugins/builtin/chat/content/index.tsx +7 -0
  188. package/src/plugins/builtin/chat/content/snapshot.ts +9 -2
  189. package/src/plugins/builtin/chat/content/transcript.tsx +10 -0
  190. package/src/plugins/builtin/chat/controller/channel-actions.ts +11 -1
  191. package/src/plugins/builtin/chat/controller/channels.ts +13 -3
  192. package/src/plugins/builtin/chat/controller/index.ts +61 -7
  193. package/src/plugins/builtin/chat/controller/lifecycle.ts +3 -0
  194. package/src/plugins/builtin/chat/controller/message-loading.ts +5 -1
  195. package/src/plugins/builtin/chat/controller/messages.ts +3 -1
  196. package/src/plugins/builtin/chat/controller/notifications.ts +32 -11
  197. package/src/plugins/builtin/chat/controller/state.ts +7 -0
  198. package/src/plugins/builtin/chat/controller/view.ts +1 -0
  199. package/src/plugins/builtin/chat/controller.test.ts +117 -28
  200. package/src/plugins/builtin/cloud/auth-commands.ts +18 -0
  201. package/src/plugins/builtin/cloud/device-signin-dialog.tsx +243 -0
  202. package/src/plugins/builtin/cloud/device-signin.test.ts +217 -0
  203. package/src/plugins/builtin/cloud/device-signin.ts +240 -0
  204. package/src/plugins/builtin/cloud/plugin.tsx +7 -1
  205. package/src/plugins/builtin/cloud-tweets/table.tsx +57 -10
  206. package/src/plugins/builtin/composite-plugins.ts +39 -5
  207. package/src/plugins/builtin/congress-trades/detail.tsx +2 -4
  208. package/src/plugins/builtin/congress-trades/footer.ts +7 -16
  209. package/src/plugins/builtin/congress-trades/pane.tsx +12 -20
  210. package/src/plugins/builtin/connections/index.ts +53 -0
  211. package/src/plugins/builtin/connections/pane.test.tsx +79 -0
  212. package/src/plugins/builtin/connections/pane.tsx +258 -0
  213. package/src/plugins/builtin/correlation/index.test.tsx +2 -1
  214. package/src/plugins/builtin/correlation/index.tsx +58 -19
  215. package/src/plugins/builtin/correlation/matrix/model.ts +18 -7
  216. package/src/plugins/builtin/correlation/relationship/pane.tsx +43 -19
  217. package/src/plugins/builtin/correlation/settings.ts +1 -1
  218. package/src/plugins/builtin/credit-conditions/client.test.ts +80 -0
  219. package/src/plugins/builtin/credit-conditions/client.ts +105 -0
  220. package/src/plugins/builtin/credit-conditions/index.test.tsx +111 -0
  221. package/src/plugins/builtin/credit-conditions/index.tsx +227 -0
  222. package/src/plugins/builtin/credit-conditions/model.test.ts +43 -0
  223. package/src/plugins/builtin/credit-conditions/model.ts +64 -0
  224. package/src/plugins/builtin/debug/index.tsx +11 -6
  225. package/src/plugins/builtin/dividend-yield/client.test.ts +58 -0
  226. package/src/plugins/builtin/dividend-yield/client.ts +252 -0
  227. package/src/plugins/builtin/dividend-yield/index.tsx +61 -0
  228. package/src/plugins/builtin/dividend-yield/model.ts +83 -0
  229. package/src/plugins/builtin/dividend-yield/pane.tsx +305 -0
  230. package/src/plugins/builtin/dividend-yield/types.ts +22 -0
  231. package/src/plugins/builtin/earnings/data/cache.test.ts +10 -7
  232. package/src/plugins/builtin/earnings/data/cache.ts +23 -9
  233. package/src/plugins/builtin/earnings/index.tsx +57 -6
  234. package/src/plugins/builtin/econ/calendar-model.test.ts +37 -3
  235. package/src/plugins/builtin/econ/calendar-model.ts +32 -26
  236. package/src/plugins/builtin/econ/fred-cache.test.ts +8 -1
  237. package/src/plugins/builtin/econ/fred-series-map.ts +18 -0
  238. package/src/plugins/builtin/econ/index.test.tsx +105 -0
  239. package/src/plugins/builtin/econ/index.tsx +95 -52
  240. package/src/plugins/builtin/fear-greed/cache.test.ts +18 -3
  241. package/src/plugins/builtin/fear-greed/cache.ts +18 -6
  242. package/src/plugins/builtin/fear-greed/charts.tsx +9 -2
  243. package/src/plugins/builtin/fear-greed/format.ts +0 -9
  244. package/src/plugins/builtin/fear-greed/pane.tsx +21 -21
  245. package/src/plugins/builtin/futures/contracts.ts +100 -0
  246. package/src/plugins/builtin/futures/index.tsx +298 -0
  247. package/src/plugins/builtin/futures/model.test.ts +129 -0
  248. package/src/plugins/builtin/futures/model.ts +136 -0
  249. package/src/plugins/builtin/futures/pane.test.tsx +239 -0
  250. package/src/plugins/builtin/futures/table.test.ts +155 -0
  251. package/src/plugins/builtin/futures/table.tsx +241 -0
  252. package/src/plugins/builtin/fx-matrix/index.tsx +160 -134
  253. package/src/plugins/builtin/fx-matrix/pairs.ts +12 -1
  254. package/src/plugins/builtin/fx-matrix/pane.test.tsx +109 -0
  255. package/src/plugins/builtin/help/components.tsx +1 -30
  256. package/src/plugins/builtin/help/index.tsx +5 -25
  257. package/src/plugins/builtin/holders/pane.tsx +17 -12
  258. package/src/plugins/builtin/holders/treemap.tsx +4 -2
  259. package/src/plugins/builtin/insider/index.tsx +20 -10
  260. package/src/plugins/builtin/ipo-calendar/cache.ts +101 -0
  261. package/src/plugins/builtin/ipo-calendar/client.test.ts +31 -0
  262. package/src/plugins/builtin/ipo-calendar/client.ts +296 -0
  263. package/src/plugins/builtin/ipo-calendar/index.tsx +65 -0
  264. package/src/plugins/builtin/ipo-calendar/model.ts +145 -0
  265. package/src/plugins/builtin/ipo-calendar/pane.tsx +328 -0
  266. package/src/plugins/builtin/ipo-calendar/types.ts +19 -0
  267. package/src/plugins/builtin/kelly-sizer/index.test.tsx +3 -3
  268. package/src/plugins/builtin/kelly-sizer/model.ts +8 -1
  269. package/src/plugins/builtin/kelly-sizer/pane.tsx +33 -15
  270. package/src/plugins/builtin/kelly-sizer/view.tsx +12 -5
  271. package/src/plugins/builtin/market-halts/client.ts +114 -0
  272. package/src/plugins/builtin/market-halts/index.tsx +29 -0
  273. package/src/plugins/builtin/market-halts/model.test.ts +187 -0
  274. package/src/plugins/builtin/market-halts/model.ts +291 -0
  275. package/src/plugins/builtin/market-halts/pane.tsx +256 -0
  276. package/src/plugins/builtin/market-heatmap/data.test.ts +1 -0
  277. package/src/plugins/builtin/market-heatmap/data.ts +12 -3
  278. package/src/plugins/builtin/market-heatmap/index.tsx +131 -46
  279. package/src/plugins/builtin/market-movers/index.tsx +145 -63
  280. package/src/plugins/builtin/market-movers/model.ts +19 -3
  281. package/src/plugins/builtin/market-movers/screener.test.ts +108 -0
  282. package/src/plugins/builtin/market-movers/screener.ts +168 -10
  283. package/src/plugins/builtin/news/index.tsx +78 -99
  284. package/src/plugins/builtin/news/wire/article-search.test.ts +72 -0
  285. package/src/plugins/builtin/news/wire/article-search.ts +140 -0
  286. package/src/plugins/builtin/news/wire/breaking/pane.tsx +18 -8
  287. package/src/plugins/builtin/news/wire/categories.ts +35 -0
  288. package/src/plugins/builtin/news/wire/default-feeds.ts +47 -1
  289. package/src/plugins/builtin/news/wire/feed-config.test.ts +10 -5
  290. package/src/plugins/builtin/news/wire/index.tsx +41 -4
  291. package/src/plugins/builtin/news/wire/industry-pane.tsx +38 -19
  292. package/src/plugins/builtin/news/wire/news/detail-view.tsx +10 -5
  293. package/src/plugins/builtin/news/wire/news/footer.ts +1 -0
  294. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +15 -6
  295. package/src/plugins/builtin/news/wire/news/query-presets.ts +16 -2
  296. package/src/plugins/builtin/news/wire/news/table.test.tsx +54 -0
  297. package/src/plugins/builtin/news/wire/news/table.tsx +111 -17
  298. package/src/plugins/builtin/notes/files.test.ts +18 -0
  299. package/src/plugins/builtin/notes/files.ts +10 -4
  300. package/src/plugins/builtin/notes/index.tsx +4 -1
  301. package/src/plugins/builtin/notes/quick-notes-pane.test.tsx +182 -0
  302. package/src/plugins/builtin/notes/quick-notes-pane.tsx +74 -31
  303. package/src/plugins/builtin/notes/ticker-notes-tab.test.tsx +380 -0
  304. package/src/plugins/builtin/notes/ticker-notes-tab.tsx +97 -40
  305. package/src/plugins/builtin/options/calc-seed.test.ts +118 -0
  306. package/src/plugins/builtin/options/calc-seed.ts +52 -0
  307. package/src/plugins/builtin/options/footer.ts +4 -1
  308. package/src/plugins/builtin/options/index.tsx +22 -1
  309. package/src/plugins/builtin/options/live-quotes.ts +8 -0
  310. package/src/plugins/builtin/options/table.ts +3 -1
  311. package/src/plugins/builtin/options/view.test.tsx +5 -1
  312. package/src/plugins/builtin/options/view.tsx +112 -17
  313. package/src/plugins/builtin/options-calculator/index.tsx +35 -0
  314. package/src/plugins/builtin/options-calculator/model.test.ts +172 -0
  315. package/src/plugins/builtin/options-calculator/model.ts +273 -0
  316. package/src/plugins/builtin/options-calculator/pane.test.tsx +138 -0
  317. package/src/plugins/builtin/options-calculator/pane.tsx +218 -0
  318. package/src/plugins/builtin/plugin-module.test.ts +16 -2
  319. package/src/plugins/builtin/plugin-module.ts +5 -1
  320. package/src/plugins/builtin/polls/client.ts +57 -0
  321. package/src/plugins/builtin/polls/hooks.ts +20 -0
  322. package/src/plugins/builtin/polls/index.tsx +35 -0
  323. package/src/plugins/builtin/polls/normalize.test.ts +230 -0
  324. package/src/plugins/builtin/polls/normalize.ts +319 -0
  325. package/src/plugins/builtin/polls/pane.tsx +722 -0
  326. package/src/plugins/builtin/polls/types.ts +77 -0
  327. package/src/plugins/builtin/portfolio-list/header.tsx +15 -4
  328. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  329. package/src/plugins/builtin/portfolio-list/pane/supplemental.ts +1 -1
  330. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -0
  331. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -1
  332. package/src/plugins/builtin/research/analyst-pane.tsx +40 -67
  333. package/src/plugins/builtin/research/corporate-actions-pane.tsx +25 -19
  334. package/src/plugins/builtin/research/index.test.ts +6 -25
  335. package/src/plugins/builtin/research/index.tsx +11 -5
  336. package/src/plugins/builtin/research/relative-valuation-pane.tsx +86 -26
  337. package/src/plugins/builtin/scanner/denied.tsx +31 -0
  338. package/src/plugins/builtin/scanner/feed.ts +94 -0
  339. package/src/plugins/builtin/scanner/flow-model.test.ts +85 -0
  340. package/src/plugins/builtin/scanner/flow-model.ts +133 -0
  341. package/src/plugins/builtin/scanner/flow-pane.tsx +197 -0
  342. package/src/plugins/builtin/scanner/hilo-bars.tsx +121 -0
  343. package/src/plugins/builtin/scanner/hilo-model.test.ts +44 -0
  344. package/src/plugins/builtin/scanner/hilo-model.ts +75 -0
  345. package/src/plugins/builtin/scanner/hilo-pane.tsx +165 -0
  346. package/src/plugins/builtin/scanner/index.ts +109 -0
  347. package/src/plugins/builtin/scanner/waiting.tsx +11 -0
  348. package/src/plugins/builtin/sec/index.tsx +11 -7
  349. package/src/plugins/builtin/sectors/index.tsx +105 -81
  350. package/src/plugins/builtin/sectors/move-bar.tsx +43 -0
  351. package/src/plugins/builtin/sectors/sector-data.ts +18 -0
  352. package/src/plugins/builtin/sectors/sector-model.ts +13 -15
  353. package/src/plugins/builtin/shared/auto-refresh.ts +51 -0
  354. package/src/plugins/builtin/shared/cloud-upgrade.ts +29 -5
  355. package/src/plugins/builtin/shared/pane-footer.ts +16 -3
  356. package/src/plugins/builtin/shared/screener-live-quotes.test.ts +91 -0
  357. package/src/plugins/builtin/shared/screener-live-quotes.ts +134 -0
  358. package/src/plugins/builtin/shared/table-pane.ts +1 -5
  359. package/src/plugins/builtin/shared/use-quote-board.test.tsx +211 -0
  360. package/src/plugins/builtin/shared/use-quote-board.ts +195 -0
  361. package/src/plugins/builtin/short-interest/client.ts +124 -0
  362. package/src/plugins/builtin/short-interest/index.tsx +62 -0
  363. package/src/plugins/builtin/short-interest/model.ts +113 -0
  364. package/src/plugins/builtin/short-interest/pane.tsx +252 -0
  365. package/src/plugins/builtin/short-interest/types.ts +9 -0
  366. package/src/plugins/builtin/substack/article-detail.tsx +15 -1
  367. package/src/plugins/builtin/substack/pane-footer.ts +3 -22
  368. package/src/plugins/builtin/substack/pane.tsx +1 -2
  369. package/src/plugins/builtin/thirteenf/api.ts +4 -1
  370. package/src/plugins/builtin/thirteenf/model.ts +2 -0
  371. package/src/plugins/builtin/thirteenf/pane.tsx +6 -2
  372. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +10 -4
  373. package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +67 -11
  374. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +15 -8
  375. package/src/plugins/builtin/ticker-detail/index.tsx +5 -21
  376. package/src/plugins/builtin/ticker-detail/overview/components.tsx +72 -32
  377. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +0 -10
  378. package/src/plugins/builtin/ticker-detail/pane.tsx +4 -1
  379. package/src/plugins/builtin/ticker-detail/quote-monitor/card.test.tsx +70 -0
  380. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +34 -26
  381. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +96 -49
  382. package/src/plugins/builtin/ticker-detail/research-tabs.ts +32 -0
  383. package/src/plugins/builtin/ticker-research-backend-plugin.ts +2 -9
  384. package/src/plugins/builtin/ticker-research-plugin.ts +6 -0
  385. package/src/plugins/builtin/treasury-auctions/cache.test.ts +173 -0
  386. package/src/plugins/builtin/treasury-auctions/cache.ts +104 -0
  387. package/src/plugins/builtin/treasury-auctions/client.test.ts +181 -0
  388. package/src/plugins/builtin/treasury-auctions/client.ts +151 -0
  389. package/src/plugins/builtin/treasury-auctions/index.tsx +90 -0
  390. package/src/plugins/builtin/treasury-auctions/model.test.ts +147 -0
  391. package/src/plugins/builtin/treasury-auctions/model.ts +188 -0
  392. package/src/plugins/builtin/treasury-auctions/pane.test.tsx +170 -0
  393. package/src/plugins/builtin/treasury-auctions/pane.tsx +417 -0
  394. package/src/plugins/builtin/treasury-auctions/types.ts +59 -0
  395. package/src/plugins/builtin/tv/pane.tsx +67 -7
  396. package/src/plugins/builtin/tv/youtube-embed.test.ts +84 -0
  397. package/src/plugins/builtin/tv/youtube-embed.ts +173 -0
  398. package/src/plugins/builtin/tv/youtube-stream.ts +27 -2
  399. package/src/plugins/builtin/volatility/client.ts +87 -0
  400. package/src/plugins/builtin/volatility/index.test.tsx +107 -0
  401. package/src/plugins/builtin/volatility/index.tsx +193 -0
  402. package/src/plugins/builtin/volatility/model.test.ts +66 -0
  403. package/src/plugins/builtin/volatility/model.ts +113 -0
  404. package/src/plugins/builtin/world-indices/footer.ts +43 -23
  405. package/src/plugins/builtin/world-indices/index.tsx +44 -93
  406. package/src/plugins/builtin/world-indices/indices.ts +11 -2
  407. package/src/plugins/builtin/world-indices/model.ts +17 -24
  408. package/src/plugins/builtin/world-indices/pane.test.tsx +116 -0
  409. package/src/plugins/builtin/world-indices/table.tsx +82 -37
  410. package/src/plugins/builtin/yield-curve/index.tsx +16 -7
  411. package/src/plugins/builtin/yield-curve/treasury-data.test.ts +25 -0
  412. package/src/plugins/builtin/yield-curve/treasury-data.ts +16 -0
  413. package/src/plugins/catalog-backend.ts +8 -0
  414. package/src/plugins/catalog-ui.ts +8 -0
  415. package/src/plugins/event-bus.ts +1 -0
  416. package/src/plugins/ibkr/gateway/account-loaders.ts +1 -1
  417. package/src/plugins/ibkr/trade/tab/footer.ts +9 -23
  418. package/src/plugins/ibkr/trade/tab/index.tsx +1 -5
  419. package/src/plugins/ibkr/trading/pane-view.tsx +149 -87
  420. package/src/plugins/ibkr/trading/pane.tsx +2 -2
  421. package/src/plugins/ownership.ts +3 -0
  422. package/src/plugins/pane-manager/floating.ts +8 -2
  423. package/src/plugins/pane-manager.test.ts +13 -0
  424. package/src/plugins/prediction-markets/backend-plugin.ts +2 -0
  425. package/src/plugins/prediction-markets/capability.test.ts +281 -0
  426. package/src/plugins/prediction-markets/capability.ts +171 -0
  427. package/src/plugins/prediction-markets/chart.tsx +18 -26
  428. package/src/plugins/prediction-markets/columns.ts +3 -2
  429. package/src/plugins/prediction-markets/controller/catalog.ts +15 -12
  430. package/src/plugins/prediction-markets/controller/detail.ts +4 -0
  431. package/src/plugins/prediction-markets/controller/index.ts +0 -15
  432. package/src/plugins/prediction-markets/detail/book.tsx +3 -23
  433. package/src/plugins/prediction-markets/detail/overview.tsx +0 -18
  434. package/src/plugins/prediction-markets/detail/pane.tsx +36 -12
  435. package/src/plugins/prediction-markets/detail.test.tsx +1 -1
  436. package/src/plugins/prediction-markets/index.tsx +2 -0
  437. package/src/plugins/prediction-markets/metrics.ts +28 -18
  438. package/src/plugins/prediction-markets/navigation.ts +1 -0
  439. package/src/plugins/prediction-markets/pane.test.tsx +1 -1
  440. package/src/plugins/prediction-markets/pane.tsx +0 -1
  441. package/src/plugins/prediction-markets/services/fetch.ts +3 -2
  442. package/src/plugins/prediction-markets/services/kalshi/adapter.ts +82 -23
  443. package/src/plugins/prediction-markets/services/kalshi/normalize.ts +3 -1
  444. package/src/plugins/prediction-markets/services/kalshi/types.ts +14 -0
  445. package/src/plugins/prediction-markets/services/polymarket/adapter.ts +26 -14
  446. package/src/plugins/prediction-markets/services/polymarket/detail.ts +67 -18
  447. package/src/plugins/prediction-markets/test-helpers.tsx +0 -1
  448. package/src/plugins/prediction-markets/types.ts +3 -9
  449. package/src/plugins/registry/context.ts +6 -1
  450. package/src/plugins/registry/index.test.ts +2 -0
  451. package/src/plugins/registry/index.ts +53 -3
  452. package/src/plugins/runtime/context.tsx +4 -2
  453. package/src/plugins/runtime/index.tsx +9 -0
  454. package/src/remote/controller.test.ts +17 -4
  455. package/src/renderers/electrobun/bun/application-menu/index.ts +1 -1
  456. package/src/renderers/electrobun/bun/core-capabilities.ts +2 -2
  457. package/src/renderers/electrobun/bun/desktop/capability-bridge.test.ts +64 -0
  458. package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +41 -7
  459. package/src/renderers/electrobun/bun/desktop/host-requests.ts +5 -2
  460. package/src/renderers/electrobun/bun/desktop/http-fetch.test.ts +33 -0
  461. package/src/renderers/electrobun/bun/desktop/http-fetch.ts +53 -6
  462. package/src/renderers/electrobun/bun/desktop/initialization.test.ts +27 -0
  463. package/src/renderers/electrobun/bun/desktop/initialization.ts +6 -1
  464. package/src/renderers/electrobun/bun/index.ts +1 -0
  465. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  466. package/src/renderers/electrobun/view/app-services.ts +25 -2
  467. package/src/renderers/electrobun/view/build-assets.ts +5 -0
  468. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +186 -65
  469. package/src/renderers/electrobun/view/cli-pane-shot-health.test.ts +25 -0
  470. package/src/renderers/electrobun/view/cli-pane-shot-health.ts +31 -0
  471. package/src/renderers/electrobun/view/data-table/index.tsx +10 -11
  472. package/src/renderers/electrobun/view/data-table/row.tsx +2 -0
  473. package/src/renderers/electrobun/view/desktop/controls.test.tsx +68 -0
  474. package/src/renderers/electrobun/view/desktop/controls.tsx +25 -1
  475. package/src/renderers/electrobun/view/host/box.test.tsx +80 -0
  476. package/src/renderers/electrobun/view/host/media-surface.tsx +70 -3
  477. package/src/renderers/electrobun/view/host/tabs.tsx +97 -5
  478. package/src/renderers/electrobun/view/host/text.tsx +5 -2
  479. package/src/renderers/electrobun/view/input-host.test.tsx +140 -0
  480. package/src/renderers/electrobun/view/input-host.tsx +4 -2
  481. package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +19 -1
  482. package/src/renderers/electrobun/view/native-stubs/broker-sync-native-loader.ts +7 -0
  483. package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +10 -0
  484. package/src/renderers/electrobun/view/remote/capability-invoker.test.ts +46 -0
  485. package/src/renderers/electrobun/view/remote/capability-invoker.ts +34 -13
  486. package/src/renderers/electrobun/view/remote/connection-health-backend.ts +19 -0
  487. package/src/renderers/electrobun/view/remote/connection-health.test.ts +44 -0
  488. package/src/renderers/electrobun/view/remote/connection-health.ts +49 -0
  489. package/src/renderers/electrobun/view/styles.css +5 -0
  490. package/src/renderers/opentui/dialog-host.tsx +279 -80
  491. package/src/renderers/opentui/host.tsx +15 -1
  492. package/src/renderers/opentui/terminal-media.test.ts +102 -0
  493. package/src/renderers/opentui/terminal-media.ts +142 -0
  494. package/src/renderers/opentui/test-utils.tsx +9 -6
  495. package/src/renderers/opentui/toast-host.tsx +136 -7
  496. package/src/renderers/opentui/ui-host.tsx +19 -3
  497. package/src/sources/provider-router/connection-health.test.ts +28 -0
  498. package/src/sources/provider-router/connection-health.ts +47 -0
  499. package/src/sources/provider-router/history.test.ts +53 -4
  500. package/src/sources/provider-router/history.ts +119 -14
  501. package/src/sources/provider-router/index.ts +12 -1
  502. package/src/sources/yahoo-finance/history.ts +2 -9
  503. package/src/sources/yahoo-finance/http.ts +1 -1
  504. package/src/sources/yahoo-finance/symbols.ts +1 -1
  505. package/src/sources/yahoo-finance/types.ts +19 -0
  506. package/src/state/app/context/index.test.tsx +101 -0
  507. package/src/state/app/context/index.tsx +10 -0
  508. package/src/state/config-save-scheduler.ts +1 -6
  509. package/src/state/persist-scheduler.test.ts +31 -0
  510. package/src/state/persist-scheduler.ts +21 -8
  511. package/src/sync/auth-transition.test.ts +36 -0
  512. package/src/sync/auth-transition.ts +22 -0
  513. package/src/sync/core-contributors.test.ts +58 -1
  514. package/src/sync/core-contributors.ts +39 -2
  515. package/src/sync/react.ts +9 -0
  516. package/src/test-support/plugin-runtime.ts +3 -0
  517. package/src/theme/font-scale.test.ts +14 -0
  518. package/src/theme/font-scale.ts +69 -0
  519. package/src/tickers/search/index.test.ts +284 -2
  520. package/src/tickers/search/index.ts +55 -18
  521. package/src/tickers/search/ranking.ts +143 -18
  522. package/src/tickers/search/types.ts +1 -0
  523. package/src/time-series/alignment.ts +15 -11
  524. package/src/time-series/field-catalog.ts +10 -0
  525. package/src/time-series/fundamentals.ts +19 -11
  526. package/src/time-series/hooks.ts +8 -2
  527. package/src/time-series/parsed-history-cache.ts +35 -0
  528. package/src/time-series/resolution.ts +10 -0
  529. package/src/time-series/resolve.test.ts +332 -3
  530. package/src/time-series/resolve.ts +225 -25
  531. package/src/time-series/spec-studies.test.ts +23 -0
  532. package/src/time-series/spec.ts +21 -2
  533. package/src/time-series/transforms.test.ts +76 -1
  534. package/src/time-series/transforms.ts +39 -8
  535. package/src/time-series/types.ts +9 -2
  536. package/src/time-series/use-chart-resolution.test.tsx +105 -1
  537. package/src/time-series/use-chart-resolution.ts +67 -13
  538. package/src/types/config.ts +30 -27
  539. package/src/types/media.ts +2 -0
  540. package/src/types/plugin.ts +8 -1
  541. package/src/ui/host.tsx +4 -0
  542. package/src/ui/pointer-drag.ts +12 -0
  543. package/src/ui/qr.test.ts +79 -0
  544. package/src/ui/qr.ts +82 -0
  545. package/src/updater/github-releases.test.ts +3 -3
  546. package/src/updater/github-releases.ts +1 -1
  547. package/src/updater.test.ts +117 -16
  548. package/src/updater.ts +32 -5
  549. package/src/utils/exchanges.ts +1 -0
  550. package/src/utils/external-url.test.ts +32 -0
  551. package/src/utils/external-url.ts +23 -0
  552. package/src/utils/sort-values.ts +31 -0
  553. package/src/utils/zoned-date-time.ts +67 -0
  554. package/src/components/onboarding/wizard-keyboard.ts +0 -306
  555. package/src/plugins/builtin/chart-composer/date-window-dialog.tsx +0 -120
@@ -2,18 +2,79 @@ import { useCallback, useEffect, useMemo, type ReactNode } from "react";
2
2
  import { TextAttributes } from "../../../../../ui";
3
3
  import {
4
4
  DataTableStackView,
5
+ PaneStatusBody,
5
6
  TickerBadgeList,
6
7
  sortStackItems,
7
8
  type DataTableCell,
8
9
  type DataTableColumn,
9
10
  type StackSortPreference,
10
11
  } from "../../../../../components";
12
+ import { TABLE_COLUMN_GAP, tableColumnWidth } from "../../../../../components/ui/table-layout";
11
13
  import type { MarketNewsItem } from "../../../../../types/news-source";
12
14
  import { colors } from "../../../../../theme/colors";
13
15
  import { collectNewsDisplayTickers } from "../../../../../news/ticker-symbols";
14
16
  import { formatRelativeTime } from "../../../../../utils/datetime-format";
17
+ import { truncateWithEllipsis } from "../../../../../utils/text-wrap";
18
+ import { formatNewsCategory } from "../categories";
15
19
 
16
- export type NewsColumnId = "rank" | "time" | "source" | "title" | "tickers" | "categories" | "importance";
20
+ export type NewsColumnId =
21
+ | "rank"
22
+ | "time"
23
+ | "source"
24
+ | "title"
25
+ | "tickers"
26
+ | "categories"
27
+ | "sentiment"
28
+ | "importance";
29
+
30
+ const SENTIMENT_ORDER: Record<string, number> = { negative: -1, neutral: 0, positive: 1 };
31
+
32
+ /**
33
+ * Ticker badges are laid out by content, so a column that cannot fit them all
34
+ * bleeds stray characters into the next column. Keep only the badges that fit.
35
+ */
36
+ function fitTickerSymbols(symbols: string[], width: number): string[] {
37
+ const fitted: string[] = [];
38
+ let used = 0;
39
+ for (const symbol of symbols) {
40
+ const badgeWidth = symbol.length + 3;
41
+ if (used + badgeWidth > width) break;
42
+ used += badgeWidth;
43
+ fitted.push(symbol);
44
+ }
45
+ return fitted;
46
+ }
47
+
48
+ /**
49
+ * Body for a table with no rows yet: loading while the query is in flight, the
50
+ * failure when the sources errored, and the empty state otherwise. Always own
51
+ * the body rather than falling back to the table's built-in empty state, whose
52
+ * desktop markup runs the title and the hint together on one line.
53
+ */
54
+ export function newsTableStatusContent({
55
+ loading,
56
+ error,
57
+ subject,
58
+ emptyTitle,
59
+ emptyMessage,
60
+ }: {
61
+ loading: boolean;
62
+ error?: string | null;
63
+ subject: string;
64
+ emptyTitle: string;
65
+ emptyMessage?: string;
66
+ }): ReactNode {
67
+ return (
68
+ <PaneStatusBody
69
+ loading={loading}
70
+ error={error}
71
+ empty
72
+ subject={subject}
73
+ emptyTitle={emptyTitle}
74
+ emptyMessage={emptyMessage}
75
+ />
76
+ );
77
+ }
17
78
 
18
79
  export type NewsSortPreference = StackSortPreference<NewsColumnId>;
19
80
 
@@ -59,6 +120,8 @@ function compareArticle(a: MarketNewsItem, b: MarketNewsItem, columnId: NewsColu
59
120
  );
60
121
  case "categories":
61
122
  return compareText(a.categories.join(" "), b.categories.join(" "));
123
+ case "sentiment":
124
+ return (SENTIMENT_ORDER[a.sentiment ?? ""] ?? 0) - (SENTIMENT_ORDER[b.sentiment ?? ""] ?? 0);
62
125
  }
63
126
  }
64
127
 
@@ -83,7 +146,9 @@ function nextSortPreference(current: NewsSortPreference, columnId: NewsColumnId)
83
146
  }
84
147
  return {
85
148
  columnId,
86
- direction: columnId === "title" || columnId === "source" || columnId === "categories" ? "asc" : "desc",
149
+ direction: columnId === "title" || columnId === "source" || columnId === "categories"
150
+ ? "asc"
151
+ : "desc",
87
152
  };
88
153
  }
89
154
 
@@ -91,26 +156,35 @@ function buildColumns(width: number, columnIds: NewsColumnId[]): NewsTableColumn
91
156
  const fixedWidths: Record<Exclude<NewsColumnId, "title">, number> = {
92
157
  rank: 4,
93
158
  time: 4,
94
- source: 10,
95
- tickers: 24,
159
+ source: 12,
160
+ tickers: 18,
96
161
  categories: 10,
97
- importance: 5,
162
+ sentiment: 4,
163
+ // Wide enough to keep the sort indicator next to the label.
164
+ importance: 7,
98
165
  };
99
166
  const labels: Record<NewsColumnId, string> = {
100
167
  rank: "#",
101
- time: "Time",
102
- source: "Source",
103
- title: "Headline",
104
- tickers: "Tickers",
105
- categories: "Category",
106
- importance: "Score",
168
+ time: "TIME",
169
+ source: "SOURCE",
170
+ title: "HEADLINE",
171
+ tickers: "TICKERS",
172
+ categories: "CATEGORY",
173
+ sentiment: "SENT",
174
+ importance: "SCORE",
107
175
  };
108
176
 
177
+ // A column occupies its header-floored width plus the gap, and the table adds
178
+ // one cell of padding on each side. Anything the fixed columns do not take is
179
+ // the headline's, so the last column never falls off the right edge.
109
180
  const fixedTotal = columnIds
110
181
  .filter((id) => id !== "title")
111
- .reduce((sum, id) => sum + fixedWidths[id as Exclude<NewsColumnId, "title">] + 1, 0);
182
+ .reduce((sum, id) => sum + tableColumnWidth({
183
+ width: fixedWidths[id as Exclude<NewsColumnId, "title">],
184
+ label: labels[id],
185
+ }) + TABLE_COLUMN_GAP, 0);
112
186
  const tablePadding = 2;
113
- const titleWidth = Math.max(16, width - fixedTotal - tablePadding - 1);
187
+ const titleWidth = Math.max(16, width - fixedTotal - tablePadding - TABLE_COLUMN_GAP);
114
188
 
115
189
  return columnIds.map((id) => ({
116
190
  id,
@@ -194,17 +268,20 @@ export function NewsArticleStackView({
194
268
  case "time":
195
269
  return { text: formatRelativeTime(item.publishedAt), color: selectedColor ?? colors.textDim };
196
270
  case "source":
197
- return { text: item.source, color: selectedColor ?? colors.textMuted };
271
+ return {
272
+ text: truncateWithEllipsis(item.source, column.width),
273
+ color: selectedColor ?? colors.textMuted,
274
+ };
198
275
  case "title":
199
276
  return {
200
- text: titleForArticle?.(item) ?? item.title,
277
+ text: truncateWithEllipsis(titleForArticle?.(item) ?? item.title, column.width),
201
278
  color: selectedColor ?? colors.text,
202
279
  attributes: readArticleIds?.has(item.id)
203
280
  ? TextAttributes.NONE
204
281
  : TextAttributes.BOLD,
205
282
  };
206
283
  case "tickers": {
207
- const tickers = collectNewsDisplayTickers(item.tickers);
284
+ const tickers = fitTickerSymbols(collectNewsDisplayTickers(item.tickers), column.width);
208
285
  return {
209
286
  text: tickers.join(" "),
210
287
  content: (
@@ -212,13 +289,30 @@ export function NewsArticleStackView({
212
289
  symbols={tickers}
213
290
  width={column.width}
214
291
  fallbackColor={selectedColor ?? colors.textBright}
292
+ liveQuote={false}
215
293
  />
216
294
  ),
217
295
  color: selectedColor ?? colors.textBright,
218
296
  };
219
297
  }
220
298
  case "categories":
221
- return { text: item.categories[0] ?? "—", color: selectedColor ?? colors.textDim };
299
+ return {
300
+ text: truncateWithEllipsis(formatNewsCategory(item.categories[0]) || "-", column.width),
301
+ color: selectedColor ?? colors.textDim,
302
+ };
303
+ case "sentiment": {
304
+ const sentiment = item.sentiment;
305
+ return {
306
+ text: sentiment ? sentiment.slice(0, 3) : "-",
307
+ color: selectedColor ?? (
308
+ sentiment === "positive"
309
+ ? colors.positive
310
+ : sentiment === "negative"
311
+ ? colors.negative
312
+ : colors.textDim
313
+ ),
314
+ };
315
+ }
222
316
  case "importance":
223
317
  return {
224
318
  text: String(item.importance),
@@ -0,0 +1,18 @@
1
+ import { expect, test } from "bun:test";
2
+ import { mkdirSync, mkdtempSync, rmSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import { join } from "path";
5
+ import { NotesFiles } from "./files";
6
+
7
+ test("NotesFiles.delete ignores only missing files", async () => {
8
+ const dataDir = mkdtempSync(join(tmpdir(), "gloomberb-notes-"));
9
+ const notes = new NotesFiles(dataDir);
10
+ mkdirSync(join(dataDir, "blocked.md"));
11
+
12
+ try {
13
+ await expect(notes.delete("missing")).resolves.toBeUndefined();
14
+ await expect(notes.delete("blocked")).rejects.toBeDefined();
15
+ } finally {
16
+ rmSync(dataDir, { recursive: true, force: true });
17
+ }
18
+ });
@@ -56,11 +56,17 @@ export class NotesFiles {
56
56
  return joinPath(this.dataDir, `${symbol}.md`);
57
57
  }
58
58
 
59
+ /**
60
+ * A note that was never written is empty, but any other read failure is
61
+ * rethrown: an unreadable note must not present itself as an empty editable
62
+ * one, or the next save silently overwrites real content.
63
+ */
59
64
  async load(symbol: string): Promise<string> {
60
65
  try {
61
66
  return await readTextFile(this.pathFor(symbol));
62
- } catch {
63
- return "";
67
+ } catch (error) {
68
+ if ((error as NodeJS.ErrnoException)?.code === "ENOENT") return "";
69
+ throw error;
64
70
  }
65
71
  }
66
72
 
@@ -71,8 +77,8 @@ export class NotesFiles {
71
77
  async delete(symbol: string): Promise<void> {
72
78
  try {
73
79
  await deleteTextFile(this.pathFor(symbol));
74
- } catch {
75
- // ignore missing files
80
+ } catch (error) {
81
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
76
82
  }
77
83
  }
78
84
 
@@ -16,7 +16,10 @@ export const notesPlugin: GloomPlugin = {
16
16
  const QuickNotesPane = createQuickNotesPane(notesFiles);
17
17
 
18
18
  ctx.on("ticker:removed", ({ symbol }) => {
19
- notesFiles.delete(symbol).catch(() => {});
19
+ notesFiles.delete(symbol).catch((error) => {
20
+ console.error("[notes] Failed to delete ticker note:", error);
21
+ ctx.notify({ body: "Failed to delete note. Check disk space and permissions.", type: "error" });
22
+ });
20
23
  });
21
24
 
22
25
  ctx.registerTickerResearchTab({
@@ -0,0 +1,182 @@
1
+ import { afterEach, describe, expect, test } from "bun:test";
2
+ import { act, useState } from "react";
3
+ import { PaneFooterProvider } from "../../../components/layout/pane/footer";
4
+ import { TestDialogProvider, testRender } from "../../../renderers/opentui/test-utils";
5
+ import { createTestPluginRuntime } from "../../../test-support/plugin-runtime";
6
+ import { Box, Text } from "../../../ui";
7
+ import { PluginRenderProvider } from "../../runtime";
8
+ import { createQuickNotesPane } from "./quick-notes-pane";
9
+ import type { NotesFiles } from "./files";
10
+ import type { QuickNoteEntry } from "./model";
11
+
12
+ let testSetup: Awaited<ReturnType<typeof testRender>> | undefined;
13
+
14
+ const TAB_A = "tab-a";
15
+ const TAB_B = "tab-b";
16
+
17
+ function createMockNotesFiles(options?: { loadDelayMs?: number }) {
18
+ const saves: Array<{ key: string; text: string }> = [];
19
+ const notes = new Map<string, string>([
20
+ [TAB_A, ""],
21
+ [TAB_B, "beta-note"],
22
+ ]);
23
+ const index: QuickNoteEntry[] = [
24
+ { id: TAB_A, title: "Alpha" },
25
+ { id: TAB_B, title: "Beta" },
26
+ ];
27
+ const loadDelayMs = options?.loadDelayMs ?? 0;
28
+
29
+ return {
30
+ saves,
31
+ async load(key: string) {
32
+ if (loadDelayMs > 0) {
33
+ await new Promise((resolve) => setTimeout(resolve, loadDelayMs));
34
+ }
35
+ return notes.get(key) ?? "";
36
+ },
37
+ async save(key: string, text: string) {
38
+ saves.push({ key, text });
39
+ notes.set(key, text);
40
+ },
41
+ async delete() {},
42
+ quickNoteKey(id: string) {
43
+ return id;
44
+ },
45
+ async loadQuickNotesIndex() {
46
+ return index;
47
+ },
48
+ async saveQuickNotesIndex() {},
49
+ } as unknown as NotesFiles & { saves: Array<{ key: string; text: string }> };
50
+ }
51
+
52
+ function QuickNotesHarness({
53
+ QuickNotesPane,
54
+ }: {
55
+ QuickNotesPane: ReturnType<typeof createQuickNotesPane>;
56
+ }) {
57
+ const [focused, setFocused] = useState(true);
58
+
59
+ return (
60
+ <TestDialogProvider>
61
+ <PluginRenderProvider pluginId="notes" runtime={createTestPluginRuntime()}>
62
+ <Box flexDirection="column" width={80} height={24}>
63
+ <PaneFooterProvider>
64
+ {() => (
65
+ <>
66
+ <QuickNotesPane focused={focused} width={78} height={20} />
67
+ <Text onMouseDown={() => setFocused(false)}>blur-pane</Text>
68
+ </>
69
+ )}
70
+ </PaneFooterProvider>
71
+ </Box>
72
+ </PluginRenderProvider>
73
+ </TestDialogProvider>
74
+ );
75
+ }
76
+
77
+ afterEach(async () => {
78
+ if (testSetup) {
79
+ await act(async () => {
80
+ testSetup!.renderer.destroy();
81
+ });
82
+ testSetup = undefined;
83
+ }
84
+ });
85
+
86
+ describe("createQuickNotesPane", () => {
87
+ test("does not save stale buffer text to a new tab before its notes load", async () => {
88
+ const notesFiles = createMockNotesFiles({ loadDelayMs: 50 });
89
+ const QuickNotesPane = createQuickNotesPane(notesFiles);
90
+
91
+ testSetup = await testRender(
92
+ <QuickNotesHarness QuickNotesPane={QuickNotesPane} />,
93
+ { width: 80, height: 24 },
94
+ );
95
+ await testSetup.renderOnce();
96
+
97
+ await act(async () => {
98
+ await new Promise((resolve) => setTimeout(resolve, 0));
99
+ await testSetup!.renderOnce();
100
+ });
101
+ let frame = testSetup.captureCharFrame();
102
+ expect(frame).toContain("Alpha");
103
+
104
+ const placeholderRow = frame.split("\n").findIndex((line) => line.includes("Write notes"));
105
+ const placeholderCol = frame.split("\n")[placeholderRow]?.indexOf("Write notes") ?? -1;
106
+
107
+ await act(async () => {
108
+ await testSetup!.mockMouse.click(placeholderCol + 1, placeholderRow);
109
+ await testSetup!.renderOnce();
110
+ });
111
+
112
+ await act(async () => {
113
+ await testSetup!.mockInput.typeText("alpha-note");
114
+ await testSetup!.renderOnce();
115
+ });
116
+
117
+ frame = testSetup.captureCharFrame();
118
+ expect(frame).toContain("alpha-note");
119
+
120
+ const betaRow = frame.split("\n").findIndex((line) => line.includes("Beta"));
121
+ const betaCol = frame.split("\n")[betaRow]?.indexOf("Beta") ?? -1;
122
+
123
+ await act(async () => {
124
+ await testSetup!.mockMouse.click(betaCol + 1, betaRow);
125
+ await testSetup!.renderOnce();
126
+ });
127
+
128
+ frame = testSetup.captureCharFrame();
129
+ const blurRow = frame.split("\n").findIndex((line) => line.includes("blur-pane"));
130
+ const blurCol = frame.split("\n")[blurRow]?.indexOf("blur-pane") ?? -1;
131
+
132
+ await act(async () => {
133
+ await testSetup!.mockMouse.click(blurCol + 1, blurRow);
134
+ await testSetup!.renderOnce();
135
+ });
136
+
137
+ expect(notesFiles.saves).toEqual([{ key: TAB_A, text: "alpha-note" }]);
138
+ });
139
+
140
+ test("never presents an unreadable note as an empty editable one", async () => {
141
+ const notesFiles = createMockNotesFiles();
142
+ const failing = {
143
+ ...notesFiles,
144
+ async load() {
145
+ throw new Error("EACCES: permission denied");
146
+ },
147
+ } as unknown as NotesFiles & { saves: Array<{ key: string; text: string }> };
148
+ const QuickNotesPane = createQuickNotesPane(failing);
149
+
150
+ testSetup = await testRender(
151
+ <QuickNotesHarness QuickNotesPane={QuickNotesPane} />,
152
+ { width: 80, height: 24 },
153
+ );
154
+ for (let attempt = 0; attempt < 5; attempt++) {
155
+ await act(async () => {
156
+ await new Promise((resolve) => setTimeout(resolve, 0));
157
+ await testSetup!.renderOnce();
158
+ });
159
+ if (testSetup.captureCharFrame().includes("could not be read")) break;
160
+ }
161
+
162
+ const frame = testSetup.captureCharFrame();
163
+ expect(frame).toContain("could not be read");
164
+ expect(frame).not.toContain("Write notes");
165
+
166
+ // Clicking the body must not open an editor over content we failed to read.
167
+ const errorRow = frame.split("\n").findIndex((line) => line.includes("could not be read"));
168
+ await act(async () => {
169
+ await testSetup!.mockMouse.click(2, errorRow);
170
+ await testSetup!.mockInput.typeText("clobber");
171
+ await testSetup!.renderOnce();
172
+ });
173
+
174
+ const blurRow = testSetup.captureCharFrame().split("\n").findIndex((line) => line.includes("blur-pane"));
175
+ await act(async () => {
176
+ await testSetup!.mockMouse.click(2, blurRow);
177
+ await testSetup!.renderOnce();
178
+ });
179
+
180
+ expect(notesFiles.saves).toEqual([]);
181
+ });
182
+ });
@@ -4,8 +4,9 @@ import { useShortcut } from "../../../react/input";
4
4
  import type { PaneProps } from "../../../types/plugin";
5
5
  import { colors } from "../../../theme/colors";
6
6
  import { MarkdownEditor } from "../../../components/markdown-editor";
7
- import { ConfirmDialog, Tabs, usePaneFooter } from "../../../components";
7
+ import { ConfirmDialog, EmptyState, Tabs, usePaneFooter } from "../../../components";
8
8
  import { type PromptContext, useDialog } from "../../../ui/dialog";
9
+ import { usePluginAppActions } from "../../runtime";
9
10
  import type { NotesFiles } from "./files";
10
11
  import { MarkdownNotePreview } from "./markdown-note-preview";
11
12
  import {
@@ -19,35 +20,53 @@ import { useSyncedText } from "./text-state";
19
20
  export function createQuickNotesPane(notesFiles: NotesFiles) {
20
21
  return function QuickNotesPane({ focused, width }: PaneProps) {
21
22
  const dialog = useDialog();
23
+ const { notify } = usePluginAppActions();
22
24
  const textareaRef = useRef<TextareaRenderable | null>(null);
23
25
  const [editing, setEditing] = useState(false);
24
26
  const [tabs, setTabs] = useState<QuickNoteEntry[]>([]);
25
27
  const [activeTabId, setActiveTabId] = useState<string | null>(null);
26
28
  const [renaming, setRenaming] = useState(false);
27
29
  const [renameValue, setRenameValue] = useState("");
30
+ const [loadError, setLoadError] = useState<string | null>(null);
28
31
  const { text: noteText, textRef: noteTextRef, setText: setNoteText } = useSyncedText("");
29
32
  const renameInputRef = useRef<InputRenderable>(null);
30
33
  const prevTabRef = useRef<string | null>(null);
31
34
  const lastSavedTextRef = useRef<Map<string, string>>(new Map());
35
+ const loadedTabIdRef = useRef<string | null>(null);
32
36
  const loadedRef = useRef(false);
33
37
  const activeTab = tabs.find((tab) => tab.id === activeTabId);
34
38
 
35
39
  const saveQuickNotesIndex = useCallback((entries: QuickNoteEntry[]) => {
36
- notesFiles.saveQuickNotesIndex(entries).catch(() => {});
37
- }, [notesFiles]);
40
+ notesFiles.saveQuickNotesIndex(entries).catch((error) => {
41
+ console.error("[notes] Failed to save notes index:", error);
42
+ notify({ body: "Failed to save notes index. Check disk space and permissions.", type: "error" });
43
+ });
44
+ }, [notesFiles, notify]);
38
45
 
39
46
  const readActiveNoteText = useCallback(() => (
40
47
  textareaRef.current?.editBuffer.getText() ?? noteTextRef.current
41
48
  ), [noteTextRef]);
42
49
 
50
+ const handleNoteChange = useCallback((value: string) => {
51
+ if (activeTabId) {
52
+ loadedTabIdRef.current = activeTabId;
53
+ }
54
+ setNoteText(value);
55
+ }, [activeTabId, setNoteText]);
56
+
43
57
  const saveTab = useCallback((tabId: string | null) => {
44
58
  if (!tabId) return;
45
- if (!lastSavedTextRef.current.has(tabId)) return;
46
- const text = tabId === activeTabId ? readActiveNoteText() : noteTextRef.current;
59
+ const isActive = tabId === activeTabId;
60
+ if (isActive && loadedTabIdRef.current !== activeTabId) return;
61
+ if (!isActive && !lastSavedTextRef.current.has(tabId)) return;
62
+ const text = isActive ? readActiveNoteText() : noteTextRef.current;
47
63
  if (lastSavedTextRef.current.get(tabId) === text) return;
48
64
 
49
65
  lastSavedTextRef.current.set(tabId, text);
50
- notesFiles.save(notesFiles.quickNoteKey(tabId), text).catch(() => {});
66
+ notesFiles.save(notesFiles.quickNoteKey(tabId), text).catch((error) => {
67
+ console.error("[notes] Failed to save note:", error);
68
+ notify({ body: "Failed to save note. Check disk space and permissions.", type: "error" });
69
+ });
51
70
 
52
71
  const updatedAt = Date.now();
53
72
  setTabs((prev) => {
@@ -56,7 +75,7 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
56
75
  saveQuickNotesIndex(next);
57
76
  return next;
58
77
  });
59
- }, [activeTabId, noteTextRef, notesFiles, readActiveNoteText, saveQuickNotesIndex]);
78
+ }, [activeTabId, noteTextRef, notesFiles, notify, readActiveNoteText, saveQuickNotesIndex]);
60
79
 
61
80
  useEffect(() => {
62
81
  if (loadedRef.current) return;
@@ -78,21 +97,29 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
78
97
 
79
98
  useEffect(() => {
80
99
  if (!activeTabId) {
100
+ loadedTabIdRef.current = null;
81
101
  setNoteText("");
82
102
  return;
83
103
  }
84
104
  prevTabRef.current = activeTabId;
105
+ loadedTabIdRef.current = null;
106
+ setNoteText("");
107
+ setLoadError(null);
108
+ textareaRef.current?.setText("");
85
109
  let cancelled = false;
86
- notesFiles.load(notesFiles.quickNoteKey(activeTabId)).then((text) => {
87
- if (cancelled) return;
110
+ // The user can start typing before a slow load resolves; handleNoteChange
111
+ // marks the buffer as owning this tab, and applying the loaded text then
112
+ // would silently wipe what was typed.
113
+ const applyLoaded = (text: string) => {
114
+ if (cancelled || loadedTabIdRef.current === activeTabId) return;
115
+ loadedTabIdRef.current = activeTabId;
88
116
  lastSavedTextRef.current.set(activeTabId, text);
89
117
  setNoteText(text);
90
118
  textareaRef.current?.setText(text);
91
- }).catch(() => {
92
- if (cancelled) return;
93
- lastSavedTextRef.current.set(activeTabId, "");
94
- setNoteText("");
95
- textareaRef.current?.setText("");
119
+ };
120
+ notesFiles.load(notesFiles.quickNoteKey(activeTabId)).then(applyLoaded, (error: unknown) => {
121
+ // Leave the tab unloaded so nothing can save over content we failed to read.
122
+ if (!cancelled) setLoadError(error instanceof Error ? error.message : String(error));
96
123
  });
97
124
  return () => {
98
125
  cancelled = true;
@@ -103,6 +130,10 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
103
130
  if (!editing) saveTab(activeTabId);
104
131
  }, [activeTabId, editing, saveTab]);
105
132
 
133
+ useEffect(() => {
134
+ if (!focused && editing) setEditing(false);
135
+ }, [editing, focused]);
136
+
106
137
  const addTab = useCallback(() => {
107
138
  saveTab(activeTabId);
108
139
  const id = generateNoteId();
@@ -143,10 +174,13 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
143
174
  }
144
175
  return next;
145
176
  });
146
- notesFiles.delete(notesFiles.quickNoteKey(id)).catch(() => {});
177
+ notesFiles.delete(notesFiles.quickNoteKey(id)).catch((error) => {
178
+ console.error("[notes] Failed to delete note:", error);
179
+ notify({ body: "Failed to delete note. Check disk space and permissions.", type: "error" });
180
+ });
147
181
  setEditing(false);
148
182
  setRenaming(false);
149
- }, [activeTabId, notesFiles, saveQuickNotesIndex, setNoteText]);
183
+ }, [activeTabId, notesFiles, notify, saveQuickNotesIndex, setNoteText]);
150
184
 
151
185
  const requestRemoveTab = useCallback(async (id: string) => {
152
186
  const tab = tabs.find((entry) => entry.id === id);
@@ -204,11 +238,11 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
204
238
  }
205
239
  setTabs((prev) => {
206
240
  const next = prev.map((t) => (t.id === activeTabId ? { ...t, title: value } : t));
207
- notesFiles.saveQuickNotesIndex(next).catch(() => {});
241
+ saveQuickNotesIndex(next);
208
242
  return next;
209
243
  });
210
244
  setRenaming(false);
211
- }, [activeTabId, notesFiles, renameValue]);
245
+ }, [activeTabId, renameValue, saveQuickNotesIndex]);
212
246
 
213
247
  useShortcut((event) => {
214
248
  if (!focused) return;
@@ -235,7 +269,7 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
235
269
  return;
236
270
  }
237
271
  if (!editing) {
238
- if (event.name === "n" || event.name === "t") {
272
+ if (event.name === "n") {
239
273
  addTab();
240
274
  return;
241
275
  }
@@ -243,7 +277,8 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
243
277
  if (activeTabId) void requestRemoveTab(activeTabId);
244
278
  return;
245
279
  }
246
- if (event.name === "r") {
280
+ // Not `r`: that is the app-wide refresh key.
281
+ if (event.name === "t") {
247
282
  startRename();
248
283
  return;
249
284
  }
@@ -260,16 +295,18 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
260
295
  }, { allowEditable: true });
261
296
 
262
297
  usePaneFooter("quick-notes", () => ({
263
- info: [
264
- { id: "edited", parts: [{ text: editing || renaming ? "editing" : formatLastEdited(activeTab?.updatedAt), tone: "muted" }] },
265
- ],
298
+ info: loadError
299
+ ? [{ id: "load-error", parts: [{ text: loadError, tone: "warning" as const }] }]
300
+ : [
301
+ { id: "edited", parts: [{ text: editing || renaming ? "editing" : formatLastEdited(activeTab?.updatedAt), tone: "muted" as const }] },
302
+ ],
266
303
  hints: editing || renaming
267
304
  ? []
268
305
  : [
269
306
  { id: "new", key: "n", label: "ew", onPress: addTab },
270
- { id: "rename", key: "r", label: "ename", onPress: startRename, disabled: !activeTabId },
307
+ { id: "title", key: "t", label: "itle", onPress: startRename, disabled: !activeTabId },
271
308
  ],
272
- }), [activeTab, activeTabId, addTab, editing, renaming, startRename]);
309
+ }), [activeTab, activeTabId, addTab, editing, loadError, renaming, startRename]);
273
310
 
274
311
  return (
275
312
  <Box flexDirection="column" flexGrow={1}>
@@ -309,22 +346,28 @@ export function createQuickNotesPane(notesFiles: NotesFiles) {
309
346
  />
310
347
  </Box>
311
348
  )}
312
- <Box flexGrow={1} minHeight={0} paddingX={1} onMouseDown={() => { if (!editing && !renaming) setEditing(true); }}>
313
- {editing && !renaming ? (
349
+ <Box flexGrow={1} minHeight={0} paddingX={1} onMouseDown={() => { if (!editing && !renaming && !loadError) setEditing(true); }}>
350
+ {loadError ? (
351
+ <EmptyState
352
+ title="This note could not be read."
353
+ message={loadError}
354
+ hint="Editing is disabled so the saved note is not overwritten. Fix the file, then reopen the pane."
355
+ />
356
+ ) : editing && !renaming ? (
314
357
  <MarkdownEditor
315
- textareaKey={activeTabId ?? "none"}
316
- focused
358
+ textareaKey="editing"
359
+ focused={focused}
317
360
  initialValue={noteText}
318
361
  placeholder="Write notes..."
319
362
  onRef={(ref) => { textareaRef.current = ref; }}
320
- onChange={setNoteText}
363
+ onChange={handleNoteChange}
321
364
  />
322
365
  ) : (
323
366
  <MarkdownNotePreview
324
367
  text={noteText}
325
368
  width={width}
326
369
  placeholder="Write notes..."
327
- onActivate={() => { if (!renaming) setEditing(true); }}
370
+ onActivate={() => { if (!renaming && !loadError) setEditing(true); }}
328
371
  />
329
372
  )}
330
373
  </Box>