gloomberb 0.20.3 → 0.20.4

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 (154) hide show
  1. package/package.json +1 -1
  2. package/src/account/auth-dialog.tsx +17 -0
  3. package/src/api-client/data.ts +6 -0
  4. package/src/api-client/fx-interventions.ts +64 -0
  5. package/src/api-client/index.ts +1 -0
  6. package/src/api-client/release-summaries.ts +21 -0
  7. package/src/app/keybindings/actions.ts +2 -2
  8. package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
  9. package/src/cli/commands/market.ts +77 -1
  10. package/src/cli/commands/news-search.ts +1 -3
  11. package/src/cli/commands/plugins.ts +27 -5
  12. package/src/cli/commands/system.ts +19 -3
  13. package/src/cli/commands/ticker.ts +60 -19
  14. package/src/cli/index.ts +8 -8
  15. package/src/cli/pane-functions/function-help.ts +3 -3
  16. package/src/cli/report-tables.ts +18 -6
  17. package/src/cli/result.ts +15 -7
  18. package/src/cli/types.ts +2 -0
  19. package/src/components/chart/composite/axis-overlays.tsx +22 -0
  20. package/src/components/chart/composite/composite-chart.tsx +54 -13
  21. package/src/components/chart/composite/event-captions.ts +109 -0
  22. package/src/components/chart/composite/event-guides.ts +74 -0
  23. package/src/components/chart/composite/rasterizer.ts +2 -0
  24. package/src/components/chart/composite/text-renderer.ts +2 -0
  25. package/src/components/chart/composite/types.ts +31 -0
  26. package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
  27. package/src/components/command-bar/routes/root/provider-search.ts +5 -4
  28. package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
  29. package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
  30. package/src/components/layout/detached-pane-shell.tsx +1 -1
  31. package/src/components/layout/floating-pane.tsx +5 -1
  32. package/src/components/layout/pane/footer/index.tsx +21 -14
  33. package/src/components/layout/pane/footer/model.ts +6 -0
  34. package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
  35. package/src/components/layout/shell/active-drag.ts +149 -105
  36. package/src/components/layout/shell/drag/drop-zones.ts +162 -0
  37. package/src/components/layout/shell/drag/index.ts +47 -218
  38. package/src/components/layout/shell/drag/live.ts +10 -3
  39. package/src/components/layout/shell/drag/overlays.tsx +182 -5
  40. package/src/components/layout/shell/drag/runtime.ts +29 -6
  41. package/src/components/layout/shell/drag/shared-edges.ts +156 -0
  42. package/src/components/layout/shell/index.tsx +11 -6
  43. package/src/components/layout/shell/menu.ts +11 -2
  44. package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
  45. package/src/components/layout/shell/native/window-state.ts +2 -2
  46. package/src/components/layout/shell/pane/layers.tsx +71 -7
  47. package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
  48. package/src/components/layout/shell/window-mode/index.ts +8 -10
  49. package/src/components/layout/window-edit/mode.ts +39 -7
  50. package/src/components/layout/window-edit/presentation.ts +1 -1
  51. package/src/components/onboarding/onboarding-keyboard.ts +4 -0
  52. package/src/components/onboarding/onboarding-wizard.tsx +8 -3
  53. package/src/components/ui/button.tsx +2 -0
  54. package/src/components/ui/choice-dialog.tsx +1 -0
  55. package/src/components/ui/data-table/index.tsx +4 -3
  56. package/src/components/ui/list-view.tsx +7 -12
  57. package/src/components/ui/loading.tsx +10 -3
  58. package/src/components/ui/menu.tsx +6 -2
  59. package/src/components/ui/quote.ts +14 -1
  60. package/src/data/config/layout.ts +5 -2
  61. package/src/docs/snapshot.json +29 -5
  62. package/src/i18n/es.ts +9 -8
  63. package/src/i18n/ja.ts +9 -8
  64. package/src/i18n/ko.ts +9 -8
  65. package/src/i18n/zh-cn.ts +9 -8
  66. package/src/i18n/zh-tw.ts +9 -8
  67. package/src/layout/pane-manager/floating-actions.ts +17 -0
  68. package/src/layout/pane-manager/floating-stack.ts +187 -0
  69. package/src/layout/pane-manager/floating.ts +4 -2
  70. package/src/layout/pane-manager/gridlock.ts +5 -1
  71. package/src/layout/pane-manager/index.ts +11 -0
  72. package/src/layout/pane-manager/layout-state.ts +10 -3
  73. package/src/market-data/futures-board.ts +46 -1
  74. package/src/market-data/futures-contract.ts +12 -3
  75. package/src/market-data/fx-interventions.ts +270 -0
  76. package/src/news/news-model.ts +44 -2
  77. package/src/plugins/builtin/alerts/cli.ts +4 -4
  78. package/src/plugins/builtin/alerts/format.ts +1 -2
  79. package/src/plugins/builtin/alerts/headless.ts +1 -2
  80. package/src/plugins/builtin/alerts/move-checks.ts +12 -6
  81. package/src/plugins/builtin/alerts/move.ts +30 -9
  82. package/src/plugins/builtin/alerts/pane.tsx +0 -2
  83. package/src/plugins/builtin/alerts/storage.ts +4 -2
  84. package/src/plugins/builtin/alerts/types.ts +12 -0
  85. package/src/plugins/builtin/changelog/index.tsx +292 -101
  86. package/src/plugins/builtin/changelog/versions.ts +293 -0
  87. package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
  88. package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
  89. package/src/plugins/builtin/chat/message/render-state.ts +2 -5
  90. package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
  91. package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
  92. package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
  93. package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
  94. package/src/plugins/builtin/cloud/askg/model.ts +14 -4
  95. package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
  96. package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
  97. package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
  98. package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
  99. package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
  100. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
  101. package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
  102. package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
  103. package/src/plugins/builtin/cot/headless.ts +14 -2
  104. package/src/plugins/builtin/earnings/index.tsx +2 -2
  105. package/src/plugins/builtin/futures/index.tsx +25 -4
  106. package/src/plugins/builtin/futures/model.ts +28 -32
  107. package/src/plugins/builtin/futures/series.ts +4 -3
  108. package/src/plugins/builtin/futures/table.tsx +16 -9
  109. package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
  110. package/src/plugins/builtin/help/index.tsx +3 -3
  111. package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
  112. package/src/plugins/builtin/layout-manager/index.tsx +8 -8
  113. package/src/plugins/builtin/news/headless.ts +2 -2
  114. package/src/plugins/builtin/news/index.tsx +3 -3
  115. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  116. package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
  117. package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
  118. package/src/plugins/builtin/research/event-model.ts +9 -1
  119. package/src/plugins/builtin/research/event-sources.ts +22 -0
  120. package/src/plugins/builtin/research/headless.ts +3 -3
  121. package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
  122. package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
  123. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
  124. package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
  125. package/src/plugins/installer.ts +45 -0
  126. package/src/remote/resources.ts +12 -1
  127. package/src/remote/schema.ts +1 -0
  128. package/src/remote/semantic-helpers.ts +29 -1
  129. package/src/remote/semantic-tree.tsx +32 -15
  130. package/src/renderers/cloudflare/worker.ts +16 -1
  131. package/src/renderers/dom/styles.css +40 -6
  132. package/src/renderers/share/layout-view.tsx +1 -1
  133. package/src/sources/gloomberb-cloud/news.ts +35 -12
  134. package/src/state/opening-ticker-panes.ts +47 -0
  135. package/src/test-support/cli-context.ts +2 -0
  136. package/src/test-support/preload.ts +4 -1
  137. package/src/tickers/instrument-kind.ts +23 -3
  138. package/src/types/config.ts +5 -0
  139. package/src/types/context-menu.ts +2 -0
  140. package/src/types/plugin-commands.ts +140 -0
  141. package/src/types/plugin-context.ts +125 -0
  142. package/src/types/plugin-contributions.ts +55 -0
  143. package/src/types/plugin-definition.ts +234 -0
  144. package/src/types/plugin-notifications.ts +38 -0
  145. package/src/types/plugin-pane-settings.ts +114 -0
  146. package/src/types/plugin-pane-templates.ts +160 -0
  147. package/src/types/plugin-panes.ts +221 -0
  148. package/src/types/plugin-reports.ts +35 -0
  149. package/src/types/plugin-shared.ts +14 -0
  150. package/src/types/plugin-state.ts +71 -0
  151. package/src/types/plugin.ts +14 -1169
  152. package/src/ui/index.tsx +14 -3
  153. package/src/updater/github-releases.ts +23 -0
  154. package/src/utils/cli-output.ts +22 -9
@@ -246,13 +246,55 @@ export function filterNewsArticlesForQuery(items: NewsArticle[], query: NewsQuer
246
246
  return filtered.slice(0, MAX_ARTICLES);
247
247
  }
248
248
 
249
+ /** Words that carry no news of their own: a summary made of them and the headline's words says nothing new. */
250
+ const FILLER_WORDS = new Set([
251
+ "a", "an", "the", "and", "or", "but", "of", "to", "in", "on", "at", "for", "from", "by", "with", "as", "into", "onto",
252
+ "over", "through", "about", "after", "amid", "than", "that", "this", "these", "those", "it", "its", "their", "his",
253
+ "her", "they", "is", "are", "was", "were", "be", "been", "being", "has", "have", "had", "will", "would", "could",
254
+ "may", "might", "can", "also", "which", "who", "while", "more", "some",
255
+ ]);
256
+
257
+ /** A word cut to its stem, near enough to match its other forms: seeking and seeks, restricts and restrictions. */
258
+ function wordStem(word: string): string {
259
+ const bare = word.replace(/['\u2019]s$/, "");
260
+ let stem = bare.length > 5 ? bare.replace(/(?:ing|ed)$/, "") : bare;
261
+ stem = stem.length > 3 ? stem.replace(/e?s$/, "") : stem;
262
+ return stem.length >= 3 ? stem : bare;
263
+ }
264
+
265
+ function newsWordStems(text: string): string[] {
266
+ return (text.toLowerCase().match(/[\p{L}\p{N}]+(?:['\u2019][\p{L}]+)?/gu) ?? [])
267
+ .filter((word) => !FILLER_WORDS.has(word))
268
+ .map(wordStem);
269
+ }
270
+
271
+ /** How much of a summary may be words its headline lacks and the summary still only restate it. */
272
+ const RESTATED_NEW_WORDS = 1 / 3;
273
+
274
+ /**
275
+ * Whether a story's summary only says its headline again, in other words or
276
+ * not: at most a third of its words (fillers aside) are words the headline
277
+ * lacks, in any of their forms. "Apple is seeking to raise about $7 billion
278
+ * through a bond sale, Bloomberg News reports." restates "Apple seeks about $7
279
+ * billion from bond sale, Bloomberg News reports"; a summary that adds the
280
+ * why or the numbers does not.
281
+ */
282
+ export function summaryRestatesHeadline(title: string, summary: string): boolean {
283
+ const headline = newsWordStems(title);
284
+ const words = newsWordStems(summary);
285
+ if (words.length === 0) return true;
286
+ const known = (word: string) => headline.some((stem) => stem === word
287
+ || (Math.min(stem.length, word.length) >= 4 && (stem.startsWith(word) || word.startsWith(stem))));
288
+ return words.filter((word) => !known(word)).length <= words.length * RESTATED_NEW_WORDS;
289
+ }
290
+
249
291
  /**
250
292
  * A story's summary as one line under its row in a text list (`news`,
251
293
  * `fn CN`): its whitespace and line breaks run together, null when it has
252
- * none or only repeats the headline.
294
+ * none or only restates the headline (summaryRestatesHeadline).
253
295
  */
254
296
  export function newsSummaryLine(article: Pick<NewsArticle, "title" | "summary">): string | null {
255
297
  const summary = article.summary?.replace(/\s+/g, " ").trim();
256
- if (!summary || summary.toLowerCase() === article.title.trim().toLowerCase()) return null;
298
+ if (!summary || summaryRestatesHeadline(article.title, summary)) return null;
257
299
  return summary;
258
300
  }
@@ -84,7 +84,7 @@ import {
84
84
  bulkMoveLogRule, MOVE_REARM, moveNowText, parseMoveAddArgs, planMoveAlerts, quoteSavedListings, quoteTypedSymbols, uniqueInputs, venueCounts,
85
85
  watchlistListings, MAX_BULK_ALERTS, type MoveAddRequest, type MoveListing, type MovePlan,
86
86
  } from "./cli-move";
87
- import { MOVE_APP_ONLY, moveRuleWords } from "./move";
87
+ import { MOVE_DELIVERY, moveRuleWords } from "./move";
88
88
  import { MOVE_CHECKS_KEY, moveChecksOf, readMoveChecks, withMoveChecks, type MoveCheck } from "./move-checks";
89
89
  import { listAddLookups } from "../portfolio-list/cli/bulk-symbols";
90
90
  import type { AlertCondition, AlertRule } from "./types";
@@ -1094,7 +1094,7 @@ export const alertsCliCommand: CliCommandDef = {
1094
1094
  ];
1095
1095
  const waiting = rows.filter((row) => row.status === NEEDS_SIGN_IN).length;
1096
1096
  const allWarnings = [...(alertsError ? [alertsError] : []), ...(events.error ? [events.error] : []), ...warnings, ...cloud.warning ? [cloud.warning] : [],
1097
- ...waiting ? [needsSignInNote(waiting)] : [], ...alerts.some((alert) => alert.move) ? [MOVE_APP_ONLY] : []];
1097
+ ...waiting ? [needsSignInNote(waiting)] : []];
1098
1098
  ctx.printResult({ data: rows, ...(allWarnings.length ? { warnings: allWarnings } : {}) }, {
1099
1099
  rows: (data) => data.map(textRow),
1100
1100
  textColumns: [
@@ -1193,7 +1193,7 @@ export const alertsCliCommand: CliCommandDef = {
1193
1193
  const alert = plan.added[0]!;
1194
1194
  const nowText = moveNowText(alert, now);
1195
1195
  ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert }, ...(notes.length ? { warnings: notes } : {}) }, {
1196
- text: (data) => `Added alert ${data.alert.id}: ${formatAlertDescription(data.alert)} (${MOVE_REARM}).${nowText ? ` ${capitalize(nowText)}.` : ""}${dryRunNote(data.dryRun)}\n${MOVE_APP_ONLY}`,
1196
+ text: (data) => `Added alert ${data.alert.id}: ${formatAlertDescription(data.alert)} (${MOVE_REARM}).${nowText ? ` ${capitalize(nowText)}.` : ""}${dryRunNote(data.dryRun)}\n${MOVE_DELIVERY}`,
1197
1197
  });
1198
1198
  return;
1199
1199
  }
@@ -1206,7 +1206,7 @@ export const alertsCliCommand: CliCommandDef = {
1206
1206
  }, {
1207
1207
  text: (data) => [
1208
1208
  `Added ${data.added.length} move ${data.added.length === 1 ? "alert" : "alerts"}${source ? ` ${source}` : ""}: ${rule} from the previous close (${MOVE_REARM}).${dryRunNote(data.dryRun)}`,
1209
- ...data.added.length ? [` ${MOVE_APP_ONLY}`] : [],
1209
+ ...data.added.length ? [` ${MOVE_DELIVERY}`] : [],
1210
1210
  ...data.added.length ? [` By venue: ${venueCounts(data.added)}.`] : [],
1211
1211
  ...moveSummaryLines(plan, moves),
1212
1212
  ].join("\n"),
@@ -155,8 +155,7 @@ export function triggerLabel(alert: Pick<AlertRule, "condition" | "move" | "metr
155
155
 
156
156
  /** The Measure cell: Price, Move, or the measure's name. */
157
157
  export function measureLabel(alert: Pick<AlertRule, "move" | "metric">): string {
158
- // A move says in its row that only the running app hears of it (MOVE_APP_ONLY).
159
- return alert.metric ? metricName(alert.metric) : alert.move ? "Move, app only" : "Price";
158
+ return alert.metric ? metricName(alert.metric) : alert.move ? "Move" : "Price";
160
159
  }
161
160
 
162
161
  export function conditionLabel(condition: AlertCondition): string {
@@ -1,5 +1,5 @@
1
1
  import { closeBasis, metricReadingText } from "./metric-model";
2
- import { MOVE_APP_ONLY, moveBasisText, movePercentText } from "./move";
2
+ import { moveBasisText, movePercentText } from "./move";
3
3
  /**
4
4
  * `gloom fn ALRT`: the Alerts pane's three tabs as reports. Prices lists
5
5
  * the price alerts as the pane's table does, Events the event alerts (earnings,
@@ -135,7 +135,6 @@ function pricesResult(alerts: readonly AlertRule[], error: string | null, events
135
135
  const active = alerts.filter((alert) => alert.status === "active");
136
136
  const triggered = alerts.filter((alert) => alert.status === "triggered").sort((a, b) => (b.triggeredAt ?? 0) - (a.triggeredAt ?? 0));
137
137
  const notes = [
138
- ...alerts.some((alert) => alert.move) ? [MOVE_APP_ONLY] : [],
139
138
  ...events > 0 ? [`${plural(events, "event alert")} not listed here: gloom fn ALRT --tab events`] : [],
140
139
  ];
141
140
  return {
@@ -1,7 +1,8 @@
1
1
  // What this device read of each move rule, kept apart from the rules. The
2
- // synced `moveAlerts` list holds the rules alone, so it changes only when a
3
- // rule does; every check, every session a rule went off in and every re-arm
4
- // for the next session stay in plugin resume state, as IV levels' readings do.
2
+ // synced `moveAlerts` list holds the rules and the latest session each went off
3
+ // in (`moveDay`, for Gloom Cloud), so it changes only when a rule does or goes
4
+ // off; every check and every re-arm for the next session stay in plugin resume
5
+ // state, as IV levels' readings do.
5
6
  import type { QuoteChangeBasis } from "../../../market-data/market/change-basis";
6
7
  import type { QuoteDataSource } from "../../../types/financials";
7
8
  import type { AlertRule } from "./types";
@@ -135,9 +136,12 @@ export function moveChecksOf(alerts: readonly AlertRule[]): Record<string, MoveC
135
136
  }
136
137
 
137
138
  /**
138
- * A move rule as the synced list keeps it: the rule alone, never a reading,
139
- * so no check writes the list another device pulls. Always active there:
140
- * whether it went off this session is this device's to say.
139
+ * A move rule as the synced list keeps it: the rule, never a reading, so no
140
+ * check writes the list another device pulls. Always active there: whether
141
+ * it went off this session is this device's to say. The latest session it
142
+ * went off in (`moveDay`) goes with it, so Gloom Cloud never alerts on that
143
+ * session again; it changes at most once a session. `syncsMoveDay` says this
144
+ * app keeps `moveDay`, so Gloom Cloud may judge the rule.
141
145
  */
142
146
  export function moveRuleOnly(alert: AlertRule): AlertRule {
143
147
  return {
@@ -150,6 +154,8 @@ export function moveRuleOnly(alert: AlertRule): AlertRule {
150
154
  ...alert.armedAt != null ? { armedAt: alert.armedAt } : {},
151
155
  status: "active",
152
156
  ...alert.message ? { message: alert.message } : {},
157
+ ...alert.moveDay ? { moveDay: alert.moveDay } : {},
153
158
  move: true,
159
+ syncsMoveDay: true,
154
160
  };
155
161
  }
@@ -4,13 +4,14 @@
4
4
  // once per session and arms itself again for the next one.
5
5
  import { changeBasisLabel, quoteChangeBasis, type QuoteChangeBasis } from "../../../market-data/market/change-basis";
6
6
  import { getActiveQuoteDisplay } from "../../../market-data/market/status";
7
+ import { quoteTradingDay } from "../../../market-data/quotes/day-range";
7
8
  import type { Quote } from "../../../types/financials";
8
9
  import type { AlertCondition, AlertRule } from "./types";
9
10
 
10
11
  /**
11
12
  * Move rules keep a synced list of their own: an app or a Gloom Cloud that
12
- * reads `alerts` would judge `up 3` as a price above 3. Only the running app
13
- * checks them.
13
+ * reads `alerts` would judge `up 3` as a price above 3. The running app checks
14
+ * them, and for a signed-in account with Cloud sync, Gloom Cloud does too.
14
15
  */
15
16
  export const MOVE_ALERTS_KEY = "moveAlerts";
16
17
 
@@ -25,11 +26,13 @@ export function moveCondition(word: string | undefined): AlertCondition | null {
25
26
  }
26
27
 
27
28
  /**
28
- * Who hears of a move: only the running app checks moves, so no email or
29
- * phone alert comes of one, signed in or not. Said where a move alert is
30
- * made and listed, so nobody waits for an email.
29
+ * Who hears of a move, as docs/usage.md states it: the running app checks its
30
+ * move rules. Signed in with Cloud sync, Gloom Cloud checks them too and, with
31
+ * the app closed, pushes one that goes off to a registered phone and lists it
32
+ * in the day's market email, unless the app already alerted on that session
33
+ * (`moveDay`). Said where a move alert is made, as a price alert's add says it.
31
34
  */
32
- export const MOVE_APP_ONLY = "Move alerts notify only while the app is running, even when signed in with Cloud sync: no email or phone alert.";
35
+ export const MOVE_DELIVERY = "The app alerts while it is running; sign in with Cloud sync for a phone alert and a line in the day's market email when it is closed.";
33
36
 
34
37
  /** The largest move a rule takes, in percent: a fall cannot pass 100%. */
35
38
  const MAX_MOVE_PERCENT = 100;
@@ -82,6 +85,12 @@ export interface MoveReading {
82
85
  * a reading can set off an armed rule, never arm one again.
83
86
  */
84
87
  session: string | null;
88
+ /**
89
+ * The move's own session, as the quote dates its change (changeSessionDate,
90
+ * the 2026-11-06 session), the way Gloom Cloud dates the moves it judges;
91
+ * null when nothing dates it.
92
+ */
93
+ day: string | null;
85
94
  }
86
95
 
87
96
  const utcDay = (time: number) => new Date(time).toISOString().slice(0, 10);
@@ -99,7 +108,15 @@ export function readMove(quote: Quote, now = Date.now()): MoveReading | null {
99
108
  const basis = quoteChangeBasis(quote, { session: "active" });
100
109
  if (!basis) return null;
101
110
  const session = "date" in basis ? basis.date : basis.kind === "utc day" || basis.kind === "24h" ? utcDay(now) : null;
102
- return { percent, basis, session };
111
+ return { percent, basis, session, day: moveDayOf(quote, basis, now) };
112
+ }
113
+
114
+ /** The session a quote dates its move to: its changeSessionDate, a coin's UTC day, else its trading day. */
115
+ function moveDayOf(quote: Quote, basis: QuoteChangeBasis, now: number): string | null {
116
+ if (quote.changeSessionDate && ISO_DAY.test(quote.changeSessionDate)) return quote.changeSessionDate;
117
+ if (basis.kind === "utc day" || basis.kind === "24h") return utcDay(now);
118
+ const day = quoteTradingDay(quote);
119
+ return day && ISO_DAY.test(day) ? day : null;
103
120
  }
104
121
 
105
122
  /** A reading this recent dates an undated one after it: the same session, read by a stream and a poll that disagree. */
@@ -138,7 +155,8 @@ export function moveReached(alert: Pick<AlertRule, "condition" | "targetPrice">,
138
155
  * dated session later than the one it went off in: a print after the close,
139
156
  * a weekend quote, or a stream and a poll that date the move a day apart
140
157
  * never arm it twice. Then it goes off when the move reaches it, once for the
141
- * session. Returns the rule with its reading, and whether it went off now.
158
+ * session, and the rule keeps the move's session (`moveDay`, the latest) for
159
+ * Gloom Cloud. Returns the rule with its reading, and whether it went off now.
142
160
  */
143
161
  export function judgeMove(alert: AlertRule, quote: Quote, now = Date.now()): { alert: AlertRule; fired: boolean; reading: MoveReading | null } {
144
162
  const reading = readMove(quote, now);
@@ -150,7 +168,10 @@ export function judgeMove(alert: AlertRule, quote: Quote, now = Date.now()): { a
150
168
  // A session it already went off in, as a dated reading says, never sets it off again.
151
169
  const wentOff = !!reading.session && !!last && reading.session <= last && next.moveSession != null;
152
170
  const fired = next.status === "active" && !wentOff && moveReached(next, reading.percent);
153
- if (fired) next = { ...next, status: "triggered", triggeredAt: now, moveSession: firedSession(alert, reading, now) };
171
+ if (fired) {
172
+ const day = reading.day && (!alert.moveDay || reading.day > alert.moveDay) ? { moveDay: reading.day } : {};
173
+ next = { ...next, status: "triggered", triggeredAt: now, moveSession: firedSession(alert, reading, now), ...day };
174
+ }
154
175
  return { alert: next, fired, reading };
155
176
  }
156
177
 
@@ -116,8 +116,6 @@ function AlertDetail({ alert, scrollRef }: { alert: AlertRule; scrollRef: RefObj
116
116
  {reason ? null : <KeyValueRow {...DETAIL_ROW} label={alert.move ? "Move" : "Current"} value={formatCurrentPrice(alert, 24)} />}
117
117
  {/* What a move is measured from, as the quote's change line names it. */}
118
118
  {!reason && alert.move ? <KeyValueRow {...DETAIL_ROW} label="From" value={moveBasisText(alert.lastMoveBasis).replace(/^vs /, "")} tone="muted" /> : null}
119
- {/* Only the running app checks a move: no email or phone alert comes of it, signed in or not. */}
120
- {alert.move ? <KeyValueRow {...DETAIL_ROW} label="Notifies" value="Only while the app is running; no email or phone alert, even with Cloud sync" /> : null}
121
119
  {/* The two readings that place the quadrant, as RRG states them. */}
122
120
  {!reason && alert.metric?.kind === "rrg" && alert.lastCheckedPrice != null && alert.lastCheckedTarget != null ? <>
123
121
  <KeyValueRow {...DETAIL_ROW} label="Strength" value={alert.lastCheckedPrice.toFixed(2)} />
@@ -34,7 +34,9 @@ export async function saveAlerts(
34
34
  // A list never written that stays empty (moves, on a profile without them) is left unwritten.
35
35
  if (current === value || (current == null && value === "[]")) continue;
36
36
  // Move rules that read as the ones to write are left as written, whatever the order of their fields: a check changes no rule.
37
- if (key === MOVE_ALERTS_KEY && !stores.errors[key] && serializeAlerts(deserializeAlerts(current).map(moveRuleOnly)) === value) continue;
37
+ // A list an older app wrote, without `syncsMoveDay`, is written once more, so Gloom Cloud may judge its rules.
38
+ if (key === MOVE_ALERTS_KEY && !stores.errors[key] && serializeAlerts(deserializeAlerts(current).map(moveRuleOnly)) === value
39
+ && deserializeAlerts(current).every((alert) => alert.syncsMoveDay === true)) continue;
38
40
  await ctx.configState.set(key, value);
39
41
  }
40
42
  }
@@ -69,7 +71,7 @@ export function readLevelAlertStores(get: (key: string) => unknown): { alerts: A
69
71
  return { alerts, errors, error: Object.values(errors).filter(Boolean).join(" ") || null };
70
72
  }
71
73
  export function writeLevelAlertStores(alerts: AlertRule[]): Record<string, string> {
72
- // A move rule is written as the rule alone: its readings are this device's (`MOVE_CHECKS_KEY`), so a check never changes the list.
74
+ // A move rule is written as the rule and the session it last went off in: its readings are this device's (`MOVE_CHECKS_KEY`), so a check never changes the list.
73
75
  return Object.fromEntries(LEVEL_ALERT_KEYS.map(key => [key, serializeAlerts(alerts.filter(a => levelAlertStoreKey(a) === key)
74
76
  .map((alert) => alert.move ? moveRuleOnly(alert) : alert))]));
75
77
  }
@@ -19,6 +19,18 @@ export interface AlertRule {
19
19
  move?: boolean;
20
20
  /** The session a move rule last went off in (the close it was measured from); it arms again in the next one. */
21
21
  moveSession?: string;
22
+ /**
23
+ * The latest session a move rule went off in on a device, as its quote dates
24
+ * the move (changeSessionDate). Kept in the synced rule, so Gloom Cloud never
25
+ * pushes or emails a session the app already alerted on.
26
+ */
27
+ moveDay?: string;
28
+ /**
29
+ * Written on every synced move rule by an app that syncs `moveDay`. Gloom
30
+ * Cloud judges only rules that carry it: an older app alerts on its own and
31
+ * syncs nothing of it, and drops the field when it rewrites the list.
32
+ */
33
+ syncsMoveDay?: true;
22
34
  /** What the last move read was measured from, as its quote's change line names it. */
23
35
  lastMoveBasis?: QuoteChangeBasis;
24
36
  lastDailyClose?: string;