@gloom-sh/terminal 0.20.22 → 0.20.23

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 (195) hide show
  1. package/package.json +1 -1
  2. package/src/account/heard-from-question.tsx +6 -4
  3. package/src/account/heard-from.ts +3 -4
  4. package/src/api-client/exchange-announcements.ts +2 -2
  5. package/src/api-client/heard-from.ts +5 -7
  6. package/src/api-client/ownership-disclosures.ts +38 -5
  7. package/src/api-client/types/ticker-data.ts +3 -1
  8. package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
  9. package/src/cli/commands/market.ts +5 -3
  10. package/src/cli/commands/overview.ts +7 -9
  11. package/src/cli/listing-arg.ts +45 -18
  12. package/src/cli/pane-functions/catalog-snapshot.json +2 -2
  13. package/src/cli/pane-functions/data.ts +3 -1
  14. package/src/cli/pane-functions/freshness.ts +6 -1
  15. package/src/cli/pane-functions/function-help.ts +0 -2
  16. package/src/cli/pane-functions/market-session.ts +12 -2
  17. package/src/cli/pane-functions/screenshot-payload.ts +3 -1
  18. package/src/cli/symbol-list.ts +52 -14
  19. package/src/cli/ticker-resolution.ts +133 -38
  20. package/src/components/chart/composite/composite-chart.tsx +12 -0
  21. package/src/components/chart/composite/types.ts +18 -0
  22. package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
  23. package/src/components/chart-table/header.tsx +11 -5
  24. package/src/components/chart-table/selection.ts +20 -1
  25. package/src/components/data-table/view.tsx +2 -0
  26. package/src/components/feed-data-table/stack-view.tsx +85 -5
  27. package/src/components/layout/pane/header.tsx +12 -30
  28. package/src/components/ticker/badge/index.tsx +9 -4
  29. package/src/components/ticker/badge/list.tsx +3 -1
  30. package/src/components/ui/data-table/index.tsx +7 -1
  31. package/src/components/ui/data-table/muted-row.tsx +47 -0
  32. package/src/components/ui/data-table/opentui/index.tsx +42 -11
  33. package/src/components/ui/data-table/spill.ts +36 -0
  34. package/src/components/ui/data-table/types.ts +17 -1
  35. package/src/components/ui/data-table/use-column-order.ts +11 -0
  36. package/src/components/ui/icon.tsx +50 -3
  37. package/src/components/ui/list-view.tsx +2 -2
  38. package/src/components/ui/table-layout.ts +32 -0
  39. package/src/components/ui/terminal-hover-label.tsx +49 -0
  40. package/src/components/use-pinned-moment.ts +222 -13
  41. package/src/core/state/app/state.ts +11 -2
  42. package/src/core/state/app/types.ts +2 -1
  43. package/src/data/sqlite/access.ts +14 -1
  44. package/src/data/sqlite/checkpointer.ts +2 -2
  45. package/src/data/sqlite/database.ts +4 -0
  46. package/src/docs/snapshot.json +180 -26
  47. package/src/i18n/es.ts +1 -0
  48. package/src/i18n/ja.ts +1 -0
  49. package/src/i18n/ko.ts +1 -0
  50. package/src/i18n/zh-cn.ts +1 -0
  51. package/src/i18n/zh-tw.ts +1 -0
  52. package/src/market-data/market/freshness.ts +2 -2
  53. package/src/market-data/market/globex-day.ts +14 -0
  54. package/src/market-data/published-us-sessions.ts +3 -2
  55. package/src/market-data/quotes/live-valuation.ts +4 -2
  56. package/src/market-data/quotes/metadata.ts +48 -5
  57. package/src/market-data/quotes/regular-session-valuation.ts +12 -1
  58. package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
  59. package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
  60. package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
  61. package/src/plugins/builtin/chat/channels.ts +5 -2
  62. package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
  63. package/src/plugins/builtin/chat/content/footer.tsx +17 -7
  64. package/src/plugins/builtin/chat/content/index.tsx +108 -36
  65. package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
  66. package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
  68. package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
  69. package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
  70. package/src/plugins/builtin/chat/content/types.ts +2 -0
  71. package/src/plugins/builtin/chat/controller/channels.ts +15 -15
  72. package/src/plugins/builtin/chat/controller/index.ts +140 -34
  73. package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
  74. package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
  75. package/src/plugins/builtin/chat/controller/send.ts +41 -17
  76. package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
  77. package/src/plugins/builtin/chat/controller/state.ts +17 -8
  78. package/src/plugins/builtin/chat/controller/storage.ts +41 -4
  79. package/src/plugins/builtin/chat/controller/view.ts +6 -3
  80. package/src/plugins/builtin/chat/index.tsx +1 -1
  81. package/src/plugins/builtin/chat/layout.ts +8 -1
  82. package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
  83. package/src/plugins/builtin/chat/message/header.tsx +112 -30
  84. package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
  85. package/src/plugins/builtin/chat/message/render-state.ts +4 -2
  86. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  87. package/src/plugins/builtin/chat/message/types.ts +5 -0
  88. package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
  89. package/src/plugins/builtin/company-kpis/model.ts +11 -3
  90. package/src/plugins/builtin/correlation/compute.ts +6 -1
  91. package/src/plugins/builtin/custom-view/loader.ts +95 -34
  92. package/src/plugins/builtin/custom-view/pane.tsx +31 -41
  93. package/src/plugins/builtin/custom-view/table.ts +201 -0
  94. package/src/plugins/builtin/dividend-yield/client.ts +14 -17
  95. package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
  96. package/src/plugins/builtin/dividend-yield/model.ts +45 -6
  97. package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
  98. package/src/plugins/builtin/dividend-yield/types.ts +2 -3
  99. package/src/plugins/builtin/dividend-yield/view.ts +22 -2
  100. package/src/plugins/builtin/econ/calendar-model.ts +135 -0
  101. package/src/plugins/builtin/econ/columns.ts +132 -0
  102. package/src/plugins/builtin/econ/index.tsx +25 -65
  103. package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
  104. package/src/plugins/builtin/holders/disclosures.ts +20 -6
  105. package/src/plugins/builtin/holders/headless.ts +2 -2
  106. package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
  107. package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
  108. package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
  109. package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
  110. package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
  111. package/src/plugins/builtin/market-halts/pane.tsx +14 -2
  112. package/src/plugins/builtin/news/wire/news/row.ts +5 -12
  113. package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
  114. package/src/plugins/builtin/pe-band/headless.ts +1 -1
  115. package/src/plugins/builtin/pe-band/model.ts +41 -18
  116. package/src/plugins/builtin/pe-band/pane.tsx +6 -5
  117. package/src/plugins/builtin/perps/equity-row.tsx +4 -6
  118. package/src/plugins/builtin/perps/markets-section.tsx +19 -15
  119. package/src/plugins/builtin/perps/model.ts +10 -2
  120. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
  121. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
  122. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
  123. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
  124. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
  125. package/src/plugins/builtin/research/event-data.ts +3 -1
  126. package/src/plugins/builtin/research/event-model.ts +17 -15
  127. package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
  128. package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
  129. package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
  130. package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
  131. package/src/plugins/builtin/sec/headless.ts +8 -8
  132. package/src/plugins/builtin/sec/index.tsx +69 -29
  133. package/src/plugins/builtin/shared/report-freshness.ts +4 -1
  134. package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
  135. package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
  136. package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
  137. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
  138. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
  139. package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
  140. package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
  141. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
  142. package/src/plugins/builtin/time-sales/model.ts +16 -9
  143. package/src/plugins/builtin/time-sales/pane.tsx +27 -24
  144. package/src/plugins/builtin/treasury-daily/client.ts +43 -9
  145. package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
  146. package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
  147. package/src/portfolio/positions-import/parse.ts +14 -6
  148. package/src/portfolio/positions-import/plan.ts +3 -2
  149. package/src/react/async-resource.ts +3 -1
  150. package/src/renderers/dom/data-table/index.tsx +40 -0
  151. package/src/renderers/dom/data-table/row.tsx +39 -3
  152. package/src/renderers/dom/desktop/icons.tsx +147 -3
  153. package/src/renderers/dom/desktop/popover.tsx +2 -2
  154. package/src/renderers/dom/host/media-surface.tsx +204 -45
  155. package/src/renderers/dom/host/tabs.tsx +1 -0
  156. package/src/renderers/dom/styles.css +14 -2
  157. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  158. package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
  159. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  160. package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
  161. package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
  162. package/src/sources/gloomberb-cloud/index.ts +8 -7
  163. package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
  164. package/src/sources/listing-symbols.ts +7 -1
  165. package/src/sources/provider-router/cache.ts +5 -4
  166. package/src/sources/provider-router/financials.ts +40 -18
  167. package/src/state/app/tab-cursor.ts +47 -6
  168. package/src/telemetry/stall-clocks.ts +3 -0
  169. package/src/telemetry/stall-reports.ts +12 -3
  170. package/src/telemetry/windows-process-activity.ts +41 -0
  171. package/src/telemetry/windows-time.ts +32 -0
  172. package/src/test-support/scoped-earnings.ts +24 -0
  173. package/src/tickers/terminal-codes.ts +1 -6
  174. package/src/time-series/daily-valuation.ts +13 -6
  175. package/src/time-series/filed-trailing-eps.ts +16 -3
  176. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  177. package/src/time-series/fundamentals/historical-valuation.ts +20 -0
  178. package/src/time-series/fundamentals/series.ts +13 -1
  179. package/src/time-series/valuation-currency.ts +2 -0
  180. package/src/types/financials.ts +46 -10
  181. package/src/ui/dialog-context.ts +8 -0
  182. package/src/utils/datetime-format.ts +23 -1
  183. package/src/utils/declared-dividends.ts +12 -2
  184. package/src/utils/exchange-announcements.ts +4 -1
  185. package/src/utils/exchange-notation.generated.ts +3 -1
  186. package/src/utils/exchanges.ts +2 -1
  187. package/src/utils/fundamentals.ts +1 -0
  188. package/src/utils/main-thread-stall.ts +9 -1
  189. package/src/utils/rpc-timeout-error.ts +36 -11
  190. package/src/utils/sec.ts +3 -1
  191. package/src/utils/share-multiples.ts +1 -1
  192. package/src/utils/stall-process-activity.ts +70 -0
  193. package/src/utils/statement-scope.ts +103 -0
  194. package/src/utils/trailing-eps.ts +1 -1
  195. package/src/utils/zoned-date-time.ts +1 -0
@@ -1,47 +1,93 @@
1
- import { useRef, type ReactNode } from "react";
1
+ import { useRef, useState, type ReactNode } from "react";
2
2
  import { Box, Text, useUiCapabilities, type BoxRenderable } from "../../../../ui";
3
3
  import { t } from "../../../../i18n";
4
4
  import { displayWidth } from "../../../../utils/format";
5
+ import { formatShortcutForHost } from "../../../../app/keybindings/labels";
5
6
  import { chatAuthorName, isDiscordGhost } from "../ghost-user";
6
- import { Badge, Button } from "../../../../components/ui";
7
- import { MESSAGE_ACTION_WIDTH } from "../layout";
7
+ import { Badge, Button, IconButton } from "../../../../components/ui";
8
+ import { ICON_GROUP_ATTRIBUTE } from "../../../../components/ui/icon";
9
+ import { TerminalHoverLabel, terminalHoverLabelSide } from "../../../../components/ui/terminal-hover-label";
10
+ import { MESSAGE_ICON_ACTION_WIDTH, MESSAGE_RETRY_ACTION_WIDTH } from "../layout";
8
11
  import { CHAT_PERSON_ICON_WIDTH, chatPersonIcons, fitChatPersonIcons } from "../people";
9
12
  import { ChatPersonIcons } from "./person-icons";
10
13
  import type { ChatMessageRenderState } from "./render-state";
11
14
  import type { ChatMessageBaseProps } from "./types";
12
15
 
13
- type ChatMessageActionProps = Pick<ChatMessageBaseProps, "index" | "beginReplyTo" | "beginEditMessage" | "retryMessage"> & {
16
+ /** What every icon action of a message takes: its name, its key where it has one, its colour on the row. */
17
+ export interface ChatMessageActionIconProps {
18
+ label: string;
19
+ shortcut?: string;
20
+ color?: string;
21
+ onHoverChange?: (hovered: boolean) => void;
22
+ focusLabel?: boolean;
23
+ }
24
+
25
+ type ChatMessageAction = "reply" | "react" | "edit";
26
+
27
+ /** The keys that press each action on the row the keyboard is on (the chat's Enter, and the footer's + and e). */
28
+ const ACTION_KEYS: Record<ChatMessageAction, string> = { reply: "Enter", react: "+", edit: "e" };
29
+ const ACTION_LABELS: Record<ChatMessageAction, string> = { reply: "Reply", react: "React", edit: "Edit" };
30
+
31
+ type ChatMessageActionProps = Pick<ChatMessageBaseProps, "index" | "beginReplyTo" | "beginEditMessage" | "retryMessage" | "actionKeysShown"> & {
14
32
  state: ChatMessageRenderState;
15
- /** The React action, one action wide, where the message takes reactions. */
16
- reactAction?: ReactNode;
33
+ /** The React action where the message takes reactions, drawn with the props every icon action takes. */
34
+ reactAction?: (icon: ChatMessageActionIconProps) => ReactNode;
17
35
  /** The reaction picker is open from this message: its actions stay shown. */
18
36
  reactionPickerOpen?: boolean;
19
37
  };
20
38
 
21
- /** Reply, React and Edit for one message, or Retry for a failed send: after the header, or floated over the first body line of a grouped message. */
39
+ /**
40
+ * Reply, React and Edit for one message as icons, or Retry for a failed send:
41
+ * after the header, or floated over the first body line of a grouped message.
42
+ * Only the row the keyboard is on names their keys, so a hint never offers a
43
+ * key that would act on another message or type into the composer. The
44
+ * desktop names each in its tooltip, and the one keyboard focus is on beside
45
+ * the group; the terminal, which has no tooltips, names the one under the
46
+ * pointer beside the actions, over the row (`row`).
47
+ */
22
48
  export function ChatMessageActions({
23
49
  state,
24
50
  index,
25
51
  floating = false,
52
+ floatRight = 0,
53
+ row,
26
54
  beginReplyTo,
27
55
  beginEditMessage,
28
56
  retryMessage,
29
57
  reactAction,
30
58
  reactionPickerOpen = false,
31
- }: ChatMessageActionProps & { floating?: boolean }) {
59
+ actionKeysShown = false,
60
+ }: ChatMessageActionProps & {
61
+ floating?: boolean;
62
+ /**
63
+ * Cells between a floating group and its row's right edge. The desktop
64
+ * gives its rows' right padding, so the icons end where the text does and
65
+ * stay clear of an overlay scrollbar: WebKit takes a press on the list's
66
+ * last pixels for its scrollbar, which would swallow the last icon.
67
+ */
68
+ floatRight?: number;
69
+ /**
70
+ * Terminal: the row's width in cells and where the actions start in it, so
71
+ * the name of the one under the pointer goes where it covers none of them.
72
+ * A floating group sits at the row's right edge.
73
+ */
74
+ row?: { width: number; start?: number };
75
+ }) {
76
+ const { nativePaneChrome } = useUiCapabilities();
77
+ const [hovered, setHovered] = useState<ChatMessageAction | null>(null);
32
78
  const variant = state.isSelected ? "primary" : "secondary";
33
79
  if (state.showRetryAction && retryMessage) {
34
80
  return (
35
81
  <Box
36
- {...(floating ? { position: "absolute", top: 0, right: 0 } : {})}
37
- width={MESSAGE_ACTION_WIDTH}
82
+ {...(floating ? { position: "absolute" as const, top: 0, right: floatRight } : {})}
83
+ width={MESSAGE_RETRY_ACTION_WIDTH}
38
84
  height={1}
39
85
  flexDirection="row"
40
86
  data-gloom-role="chat-message-retry-action"
41
87
  >
42
88
  <Button stopPropagation
43
89
  label={t("Retry")}
44
- width={MESSAGE_ACTION_WIDTH}
90
+ width={MESSAGE_RETRY_ACTION_WIDTH}
45
91
  variant={variant}
46
92
  onPress={() => retryMessage(index)}
47
93
  />
@@ -50,39 +96,62 @@ export function ChatMessageActions({
50
96
  }
51
97
  if (!state.showReplyAction) return null;
52
98
  const showReact = state.showReactAction && !!reactAction;
53
- const actionCount = 1 + (showReact ? 1 : 0) + (state.showEditAction ? 1 : 0);
99
+ const actions: ChatMessageAction[] = ["reply", ...(showReact ? ["react" as const] : []), ...(state.showEditAction ? ["edit" as const] : [])];
100
+ const width = MESSAGE_ICON_ACTION_WIDTH * actions.length;
101
+ const icon = (action: ChatMessageAction): ChatMessageActionIconProps => ({
102
+ label: ACTION_LABELS[action],
103
+ ...(actionKeysShown ? { shortcut: ACTION_KEYS[action] } : {}),
104
+ // On the selected row the icons take its text colour, as its words do.
105
+ ...(state.isSelected ? { color: state.selectedTextColor } : {}),
106
+ // The desktop names the one the keyboard is on beside the row's icons, as the terminal names the one under the pointer.
107
+ ...(nativePaneChrome ? { focusLabel: true } : {
108
+ onHoverChange: (on: boolean) => setHovered((current) => (on ? action : current === action ? null : current)),
109
+ }),
110
+ });
111
+ const shownHover = hovered && actions.includes(hovered) ? hovered : null;
112
+ let label: ReactNode = null;
113
+ if (!nativePaneChrome && shownHover && row) {
114
+ const start = row.start ?? row.width - width;
115
+ const name = `${t(ACTION_LABELS[shownHover])}${actionKeysShown ? ` (${formatShortcutForHost(ACTION_KEYS[shownHover], "terminal")})` : ""}`;
116
+ const placement = terminalHoverLabelSide(name, { before: Math.max(0, start), after: Math.max(0, row.width - start - width) });
117
+ if (placement) {
118
+ label = (
119
+ <TerminalHoverLabel
120
+ text={placement.text}
121
+ left={placement.side === "after" ? width : -displayWidth(placement.text)}
122
+ role="chat-message-action-label"
123
+ />
124
+ );
125
+ }
126
+ }
54
127
  return (
55
128
  <Box
56
- {...(floating ? { position: "absolute", top: 0, right: 0 } : {})}
57
- width={MESSAGE_ACTION_WIDTH * actionCount}
129
+ // Relative where it sits in its row, so the terminal's name of the action under the pointer goes beside it.
130
+ {...(floating ? { position: "absolute" as const, top: 0, right: floatRight } : { position: "relative" as const })}
131
+ // The terminal's icons are a glyph and a space either side; the desktop's size themselves.
132
+ width={nativePaneChrome ? undefined : width}
58
133
  height={1}
59
134
  flexDirection="row"
60
135
  data-gloom-role="chat-message-reply-action"
136
+ {...{ [ICON_GROUP_ATTRIBUTE]: "true" }}
61
137
  data-picker-open={reactionPickerOpen ? "true" : undefined}
138
+ // Floated over a grouped message's first line, the band under the icons hides the words they cover.
139
+ style={nativePaneChrome && floating ? { backgroundColor: "inherit" } : undefined}
62
140
  >
63
- <Button stopPropagation
64
- label={t("Reply")}
65
- width={MESSAGE_ACTION_WIDTH}
66
- variant={variant}
67
- onPress={() => beginReplyTo(index)}
68
- />
69
- {showReact && reactAction}
141
+ <IconButton icon="reply" {...icon("reply")} onPress={() => beginReplyTo(index)} />
142
+ {showReact && reactAction(icon("react"))}
70
143
  {state.showEditAction && (
71
- <Button stopPropagation
72
- label={t("Edit")}
73
- width={MESSAGE_ACTION_WIDTH}
74
- variant={variant}
75
- onPress={() => beginEditMessage(index)}
76
- />
144
+ <IconButton icon="edit" {...icon("edit")} onPress={() => beginEditMessage(index)} />
77
145
  )}
146
+ {label}
78
147
  </Box>
79
148
  );
80
149
  }
81
150
 
82
151
  /** The widest status a header shows ("just now edited", a date with " edited", "sending..."). */
83
152
  const WIDEST_HEADER_STATUS = Math.max(...["just now edited", "12/31/99 edited", "sending..."].map(displayWidth));
84
- /** Reply, React and Edit, after the cell before them. */
85
- const WIDEST_HEADER_ACTIONS = 1 + MESSAGE_ACTION_WIDTH * 3;
153
+ /** Reply, React and Edit, or Retry, after the cell before them. */
154
+ const WIDEST_HEADER_ACTIONS = 1 + Math.max(MESSAGE_ICON_ACTION_WIDTH * 3, MESSAGE_RETRY_ACTION_WIDTH);
86
155
 
87
156
  /**
88
157
  * Whether a header row `rowWidth` cells wide has room for every icon of its
@@ -163,6 +232,19 @@ export function ChatMessageHeader({
163
232
  // An open reaction picker keeps the row's actions, so it keeps what stands before them too.
164
233
  const showOnPoint = state.showPersonIcons || actionProps.reactionPickerOpen === true;
165
234
  const iconColor = state.isSelected ? state.selectedTextColor : undefined;
235
+ // Terminal: where the actions start in the row, after everything drawn before them.
236
+ const terminalRow = typeof rowProps.width === "number"
237
+ ? {
238
+ width: rowProps.width,
239
+ start: 1 + displayWidth(authorLabel)
240
+ + besideName.length * CHAT_PERSON_ICON_WIDTH
241
+ + (showAnnouncementMark ? announcementMarkWidth() : 0)
242
+ + (msg.origin === "discord" ? 8 : 0)
243
+ + 1 + displayWidth(state.headerStatus)
244
+ + (showOnPoint ? onPoint.length * CHAT_PERSON_ICON_WIDTH : 0)
245
+ + 1,
246
+ }
247
+ : undefined;
166
248
  const profileTarget: Record<string, unknown> = hasProfile
167
249
  ? {
168
250
  onMouseOver: () => onUserHover(msg.user, nameRef.current),
@@ -203,7 +285,7 @@ export function ChatMessageHeader({
203
285
  <Text fg={state.headerStatusColor}> {state.headerStatus}</Text>
204
286
  {showOnPoint && <ChatPersonIcons icons={onPoint} selectedColor={iconColor} terminalTarget={profileTarget} />}
205
287
  {(state.showReplyAction || (state.showRetryAction && actionProps.retryMessage)) && <Text fg={state.headerStatusColor}> </Text>}
206
- <ChatMessageActions state={state} {...actionProps} />
288
+ <ChatMessageActions state={state} row={terminalRow} {...actionProps} />
207
289
  </Box>
208
290
  );
209
291
  }
@@ -1,6 +1,7 @@
1
1
  import { useState } from "react";
2
2
  import type { ChatMessage, ChatReaction } from "../../../../api-client";
3
- import { Button, MenuPopover, type MenuItem } from "../../../../components/ui";
3
+ import { Button, IconButton, MenuPopover, type MenuItem } from "../../../../components/ui";
4
+ import type { ChatMessageActionIconProps } from "./header";
4
5
  import { colors } from "../../../../theme/colors";
5
6
  import { t } from "../../../../i18n";
6
7
  import { Box, Text } from "../../../../ui";
@@ -164,32 +165,30 @@ function reactionMenuItems(msg: ChatMessage, currentUserId: string | null): Menu
164
165
  }
165
166
 
166
167
  /**
167
- * The React action on the desktop: a button in the message's actions that
168
+ * The React action on the desktop: an icon in the message's actions that
168
169
  * opens the picker beside it (also from the keyboard, on the selected message).
169
170
  */
170
171
  export function DesktopReactionAction({
171
172
  msg,
172
173
  currentUserId,
173
174
  open,
174
- width,
175
- variant,
175
+ icon,
176
176
  onOpenChange,
177
177
  onToggle,
178
178
  }: {
179
179
  msg: ChatMessage;
180
180
  currentUserId: string | null;
181
181
  open: boolean;
182
- width: number;
183
- variant: "primary" | "secondary";
182
+ /** What every icon action of the message takes: its name, its key on the keyboard's row, its colour. */
183
+ icon: ChatMessageActionIconProps;
184
184
  onOpenChange: (open: boolean) => void;
185
185
  onToggle: (messageId: string, emoji: string) => void;
186
186
  }) {
187
187
  const trigger = (
188
- <Button
189
- stopPropagation
190
- label={t("React")}
191
- width={width}
192
- variant={variant}
188
+ <IconButton
189
+ icon="react"
190
+ {...icon}
191
+ hasPopup="menu"
193
192
  expanded={open}
194
193
  onPress={() => onOpenChange(!open)}
195
194
  />
@@ -3,7 +3,7 @@ import { blendHex, colors, hoverBg } from "../../../../theme/colors";
3
3
  import type { ChatMessage } from "../../../../api-client";
4
4
  import { formatTimeAgo } from "../../../../utils/datetime-format";
5
5
  import { accentTint, terminalAccentTint } from "../../../../components/ui/quote";
6
- import { isGroupedWithPrevious, MESSAGE_ACTION_WIDTH } from "../layout";
6
+ import { isGroupedWithPrevious, MESSAGE_ICON_ACTION_WIDTH, MESSAGE_RETRY_ACTION_WIDTH } from "../layout";
7
7
  import { chatAuthorNameColor } from "../people";
8
8
 
9
9
  /** The band on a message the reader was sent to: the accent at low strength, between the hover and the selection. */
@@ -118,7 +118,9 @@ export function getChatMessageRenderState({
118
118
  showReactAction: showReplyAction && canReact,
119
119
  showEditAction: showReplyAction && canEdit,
120
120
  showRetryAction: showActions && hasFailed,
121
- actionsWidth: !canSend ? 0 : 1 + MESSAGE_ACTION_WIDTH * (hasFailed ? 1 : 1 + (canReact ? 1 : 0) + (canEdit ? 1 : 0)),
121
+ actionsWidth: !canSend
122
+ ? 0
123
+ : 1 + (hasFailed ? MESSAGE_RETRY_ACTION_WIDTH : MESSAGE_ICON_ACTION_WIDTH * (1 + (canReact ? 1 : 0) + (canEdit ? 1 : 0))),
122
124
  showPersonIcons: isSelected || hoveredIdx === index,
123
125
  isSending,
124
126
  bgColor: isSelected
@@ -1,13 +1,13 @@
1
1
  import { Box, Text, TextAttributes, useRendererHost } from "../../../../ui";
2
2
  import { colors } from "../../../../theme/colors";
3
3
  import { t } from "../../../../i18n";
4
- import { formatInlinePreview, getMessageBodyTokenLines, MESSAGE_ACTION_WIDTH } from "../layout";
4
+ import { formatInlinePreview, getMessageBodyTokenLines } from "../layout";
5
5
  import { chatImageLabel, chatImageReviewNote, chatReplyQuoteText } from "../attachments/model";
6
6
  import { heldMessage, isQuotedAuthorManagedBot } from "../ghost-user";
7
7
  import { ChatBotIcon } from "./person-icons";
8
8
  import { CHAT_PERSON_ICON_WIDTH } from "../people";
9
- import { ChatMessageActions, ChatMessageHeader } from "./header";
10
- import { Button } from "../../../../components/ui";
9
+ import { ChatMessageActions, ChatMessageHeader, type ChatMessageActionIconProps } from "./header";
10
+ import { IconButton } from "../../../../components/ui";
11
11
  import { useSelectionFill } from "../../../../components/ui/selection-fill";
12
12
  import { canReactToMessage } from "../reactions";
13
13
  import { TerminalChatReactions } from "./reactions";
@@ -31,6 +31,7 @@ export function TerminalChatMessage({
31
31
  selectedIdx,
32
32
  hoveredIdx,
33
33
  highlighted,
34
+ actionKeysShown = false,
34
35
  canSend,
35
36
  contentWidth,
36
37
  messageBodyWidth,
@@ -70,15 +71,12 @@ export function TerminalChatMessage({
70
71
  slowSend,
71
72
  host: "terminal",
72
73
  });
73
- const reactAction = openReactionPicker ? (
74
- <Button stopPropagation
75
- label={t("React")}
76
- width={MESSAGE_ACTION_WIDTH}
77
- variant={state.isSelected ? "primary" : "secondary"}
78
- onPress={() => openReactionPicker(index)}
79
- />
80
- ) : null;
81
- const actionProps = { state, index, beginReplyTo, beginEditMessage, retryMessage, reactAction };
74
+ const reactAction = openReactionPicker ? (icon: ChatMessageActionIconProps) => (
75
+ <IconButton icon="react" {...icon} hasPopup="dialog" onPress={() => openReactionPicker(index)} />
76
+ ) : undefined;
77
+ const actionProps = { state, index, beginReplyTo, beginEditMessage, retryMessage, reactAction, actionKeysShown };
78
+ // A grouped message floats its actions at the right edge of its first row.
79
+ const floatingRow = { width: contentWidth };
82
80
  const attachments = msg.attachments ?? [];
83
81
  // A share link is its chip's row; a message that was only one has no text row.
84
82
  const { links: paneLinks, content } = chatMessagePaneLinks(msg);
@@ -166,7 +164,7 @@ export function TerminalChatMessage({
166
164
  onUserContextMenu={onUserContextMenu}
167
165
  />
168
166
  </Box>
169
- {lineIndex === 0 && state.grouped && <ChatMessageActions floating {...actionProps} />}
167
+ {lineIndex === 0 && state.grouped && <ChatMessageActions floating row={floatingRow} {...actionProps} />}
170
168
  </Box>
171
169
  ))}
172
170
  {paneLinks.map((link, linkIndex) => (
@@ -183,7 +181,7 @@ export function TerminalChatMessage({
183
181
  selectedTextColor={state.selectedTextColor}
184
182
  onOpen={openPaneLink}
185
183
  >
186
- {state.grouped && bodyLines.length === 0 && linkIndex === 0 && <ChatMessageActions floating {...actionProps} />}
184
+ {state.grouped && bodyLines.length === 0 && linkIndex === 0 && <ChatMessageActions floating row={floatingRow} {...actionProps} />}
187
185
  </TerminalChatPaneChipRow>
188
186
  ))}
189
187
  {attachments.map((attachment, imageIndex) => (
@@ -207,7 +205,7 @@ export function TerminalChatMessage({
207
205
  {formatInlinePreview(`[${chatImageLabel(attachment)}]`, messageBodyWidth)}
208
206
  </Text>
209
207
  </Box>
210
- {state.grouped && bodyLines.length === 0 && paneLinks.length === 0 && imageIndex === 0 && <ChatMessageActions floating {...actionProps} />}
208
+ {state.grouped && bodyLines.length === 0 && paneLinks.length === 0 && imageIndex === 0 && <ChatMessageActions floating row={floatingRow} {...actionProps} />}
211
209
  </Box>
212
210
  ))}
213
211
  {reviewNote && (
@@ -20,6 +20,11 @@ export interface ChatMessageBaseProps {
20
20
  hoveredIdx: number | null;
21
21
  /** A message the reader was sent to, marked for a moment. */
22
22
  highlighted?: boolean;
23
+ /**
24
+ * This is the row the keyboard is on and the chat, not the composer, has the
25
+ * keys: its actions name the keys that press them (Enter, + and e).
26
+ */
27
+ actionKeysShown?: boolean;
23
28
  canSend: boolean;
24
29
  catalog: Record<string, InlineTickerCatalogEntry>;
25
30
  userByUsername: Map<string, ChatUserSummary>;
@@ -23,6 +23,8 @@ import { useDialog, type PromptContext } from "../../../ui/dialog";
23
23
  import { usePluginAppActions, usePluginPaneState } from "../../runtime";
24
24
  import type { CloudTweetPayload, CloudTweetSearchResponse } from "../../../api-client";
25
25
  import { formatTimeAgo } from "../../../utils/datetime-format";
26
+ import { toTimestampMillis } from "../../../utils/timestamp";
27
+ import { usePinnedList } from "../../../components/use-pinned-moment";
26
28
  import { tokenizeInlineContent } from "../../../utils/inline-content-tokenizer";
27
29
  import { isPlainKey } from "../../../utils/keyboard";
28
30
  import { colors } from "../../../theme/colors";
@@ -52,6 +54,12 @@ import { useAutoRefresh } from "../../../react/auto-refresh";
52
54
  import { usePaneStatusLinkFooter } from "../../../components/layout/pane/status-footer";
53
55
  import { logFailure } from "../../../utils/log-failure";
54
56
 
57
+ const tweetId = (tweet: CloudTweetPayload) => tweet.id;
58
+ const tweetMoment = (tweet: CloudTweetPayload) => {
59
+ const at = toTimestampMillis(tweet.createdAt);
60
+ return Number.isFinite(at) ? at : null;
61
+ };
62
+
55
63
  function isAuthError(error: string | null): boolean {
56
64
  return !!error && /unauthorized|verification/i.test(error);
57
65
  }
@@ -404,6 +412,20 @@ export function TweetSearchTable({
404
412
  hints: linkHints,
405
413
  });
406
414
 
415
+ // A crosshair pinned in the tab picks the newest post out by then, whatever
416
+ // the sort, and mutes the later ones, ticker badges too; the selection
417
+ // follows the pin when it moves, not when a refresh merges posts in. An
418
+ // open post stays open on itself, links too, while the pin moves; back on
419
+ // the list, the selection goes to the post at the pin.
420
+ const { pinnedRow, isAfterPin } = usePinnedList<CloudTweetPayload>(`${footerId}:pin`, {
421
+ enabled: !detailOpen,
422
+ rows,
423
+ getId: tweetId,
424
+ moment: tweetMoment,
425
+ selectedId: selectedTweetId,
426
+ select: setSelectedTweetId,
427
+ });
428
+
407
429
  useEffect(() => {
408
430
  if (rows.length === 0) {
409
431
  if (selectedTweetId !== null) setSelectedTweetId(null);
@@ -411,9 +433,9 @@ export function TweetSearchTable({
411
433
  return;
412
434
  }
413
435
  if (!selectedTweetId || selectedIndex < 0) {
414
- setSelectedTweetId(rows[0]!.id);
436
+ setSelectedTweetId((pinnedRow ?? rows[0]!).id);
415
437
  }
416
- }, [rows, selectedIndex, selectedTweetId]);
438
+ }, [pinnedRow, rows, selectedIndex, selectedTweetId]);
417
439
 
418
440
  const handleHeaderClick = useCallback((columnId: string) => {
419
441
  if (!isTweetSortColumnId(columnId)) return;
@@ -545,6 +567,7 @@ export function TweetSearchTable({
545
567
  onHeaderClick={handleHeaderClick}
546
568
  getItemKey={(tweet) => tweet.id}
547
569
  renderCell={renderCell}
570
+ isRowMuted={isAfterPin}
548
571
  selectedTextOverridesCellColor
549
572
  emptyContent={emptyContent}
550
573
  emptyStateTitle={emptyStateTitle ?? "No tweets"}
@@ -326,8 +326,8 @@ export function companyColumns(guidance: boolean, evidence: boolean, history: bo
326
326
  return order ? shown.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id)) : shown;
327
327
  }
328
328
 
329
- /** Cells a column gives up on a narrow pane, before any column is dropped: a date needs 10, a range about 19. */
330
- const NARROW_WIDTHS: Record<string, number> = { period: 13, value: 19, change: 11, issued: 10, actual: 12, outcome: 9, basis: 12, scope: 18 };
329
+ /** Narrow column widths before any column is dropped. The issued date keeps all 11 characters. */
330
+ const NARROW_WIDTHS: Record<string, number> = { period: 13, value: 19, change: 11, actual: 12, outcome: 9, basis: 12, scope: 18 };
331
331
  /** The metric keeps at least this much: a name such as "Revenue growth", and its series detail only when there is room. */
332
332
  const METRIC_FLOOR = 14;
333
333
 
@@ -341,7 +341,15 @@ const METRIC_FLOOR = 14;
341
341
  export function fitCompanyColumns(columns: readonly DataTableColumn[], width: number, history = false): DataTableColumn[] {
342
342
  const room = width - 1;
343
343
  if (getTableWidth(columns) <= room) return [...columns];
344
- const narrow = (list: readonly DataTableColumn[]) => list.map((column) => column.id in NARROW_WIDTHS ? { ...column, width: Math.min(column.width, NARROW_WIDTHS[column.id]!) } : column);
344
+ const narrow = (list: readonly DataTableColumn[]) => list.map((column) => {
345
+ const width = NARROW_WIDTHS[column.id];
346
+ if (width === undefined) return column;
347
+ return {
348
+ ...column,
349
+ width: Math.min(column.width, width),
350
+ label: history && column.id === "period" ? "Period" : column.label,
351
+ };
352
+ });
345
353
  const attempt = (list: readonly DataTableColumn[]): DataTableColumn[] | null => {
346
354
  const tight = narrow(list);
347
355
  const metric = tight.find((column) => column.id === "metric");
@@ -7,6 +7,10 @@ export interface CorrelationResult {
7
7
  sampleSize: number;
8
8
  }
9
9
 
10
+ interface DatedCorrelationResult extends CorrelationResult {
11
+ lastSharedDate: string | null;
12
+ }
13
+
10
14
  export interface DailyClose {
11
15
  dateKey: string;
12
16
  /** A closing price, or a map series' value for the day (a transit count). */
@@ -101,11 +105,12 @@ export function correlateDailyCloses(
101
105
  minObservations = 5,
102
106
  leftBasis: ChangeBasis = "return",
103
107
  rightBasis: ChangeBasis = "return",
104
- ): CorrelationResult {
108
+ ): DatedCorrelationResult {
105
109
  const changes = pairedChanges(alignDailyCloses(left, right), leftBasis, rightBasis);
106
110
  return {
107
111
  correlation: pearsonCorrelation(changes.map((point) => point.left), changes.map((point) => point.right), minObservations),
108
112
  sampleSize: changes.length,
113
+ lastSharedDate: changes.at(-1)?.dateKey ?? null,
109
114
  };
110
115
  }
111
116