@narumitw/pi-ticker 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ticker.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  import { join } from "node:path";
2
2
  import {
3
- type ExtensionAPI,
4
- type ExtensionCommandContext,
5
- type ExtensionContext,
6
- getAgentDir,
7
- type Theme,
3
+ type ExtensionAPI,
4
+ type ExtensionCommandContext,
5
+ type ExtensionContext,
6
+ getAgentDir,
7
+ type Theme,
8
8
  } from "@earendil-works/pi-coding-agent";
9
9
  import type { AutocompleteItem } from "@earendil-works/pi-tui";
10
10
  import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
11
11
  import { fetchQuotes, QuoteRequestTimeoutError } from "./quotes.js";
12
12
  import {
13
- formatTickerPlain,
14
- mergeQuoteResults,
15
- renderTickerWidget,
16
- type TickerItem,
17
- type TickerView,
13
+ formatTickerPlain,
14
+ mergeQuoteResults,
15
+ renderTickerWidget,
16
+ type TickerItem,
17
+ type TickerView,
18
18
  } from "./render.js";
19
19
  import { createSettingsWriter, loadSettings, normalizeSymbols, parseSymbols } from "./settings.js";
20
20
 
21
21
  export interface StockTickerDependencies {
22
- createSettingsWriter: typeof createSettingsWriter;
23
- loadSettings: typeof loadSettings;
22
+ createSettingsWriter: typeof createSettingsWriter;
23
+ loadSettings: typeof loadSettings;
24
24
  }
25
25
 
26
26
  export const WIDGET_KEY = "ticker";
@@ -30,312 +30,289 @@ export const REQUEST_TIMEOUT_MS = 10_000;
30
30
 
31
31
  const HELP = "Usage: /ticker [SYMBOL ...] | /ticker refresh | /ticker reset | /ticker help";
32
32
  const COMPLETIONS: AutocompleteItem[] = [
33
- { value: "refresh", label: "refresh", description: "Refresh quotes now" },
34
- { value: "reset", label: "reset", description: "Explain why no default reset is available" },
35
- { value: "help", label: "help", description: "Show command usage" },
33
+ { value: "refresh", label: "refresh", description: "Refresh quotes now" },
34
+ { value: "reset", label: "reset", description: "Explain why no default reset is available" },
35
+ { value: "help", label: "help", description: "Show command usage" },
36
36
  ];
37
37
 
38
- export default function stockTicker(
39
- pi: ExtensionAPI,
40
- dependencies: Partial<StockTickerDependencies> = {},
41
- ): void {
42
- let activeSession: ExtensionContext["sessionManager"] | undefined;
43
- let generation = 0;
44
- let cycleVersion = 0;
45
- let pollTimer: ReturnType<typeof setTimeout> | undefined;
46
- let requestController: AbortController | undefined;
47
- let sessionController: AbortController | undefined;
48
- const activeMenus = new Set<Promise<void>>();
49
- let symbols: string[] = [];
50
- let widgetEnabled = true;
51
- let view: TickerView = createInitialView(symbols);
52
- const settingsWriter = (dependencies.createSettingsWriter ?? createSettingsWriter)();
53
- const readSettings = dependencies.loadSettings ?? loadSettings;
38
+ export default function stockTicker(pi: ExtensionAPI, dependencies: Partial<StockTickerDependencies> = {}): void {
39
+ let activeSession: ExtensionContext["sessionManager"] | undefined;
40
+ let generation = 0;
41
+ let cycleVersion = 0;
42
+ let pollTimer: ReturnType<typeof setTimeout> | undefined;
43
+ let requestController: AbortController | undefined;
44
+ let sessionController: AbortController | undefined;
45
+ const activeMenus = new Set<Promise<void>>();
46
+ let symbols: string[] = [];
47
+ let widgetEnabled = true;
48
+ let view: TickerView = createInitialView(symbols);
49
+ const settingsWriter = (dependencies.createSettingsWriter ?? createSettingsWriter)();
50
+ const readSettings = dependencies.loadSettings ?? loadSettings;
54
51
 
55
- const ownsSession = (ctx: ExtensionContext, expectedGeneration = generation): boolean =>
56
- ctx.sessionManager === activeSession && expectedGeneration === generation;
52
+ const ownsSession = (ctx: ExtensionContext, expectedGeneration = generation): boolean =>
53
+ ctx.sessionManager === activeSession && expectedGeneration === generation;
57
54
 
58
- const publish = (ctx: ExtensionContext): void => {
59
- if (!ctx.hasUI || !ownsSession(ctx)) return;
60
- if (!widgetEnabled || view.items.length === 0) {
61
- ctx.ui.setWidget(WIDGET_KEY, undefined);
62
- return;
63
- }
64
- const snapshot = cloneView(view);
65
- if (ctx.mode === "tui") {
66
- ctx.ui.setWidget(
67
- WIDGET_KEY,
68
- (_tui: unknown, theme: Theme) => ({
69
- render: (width: number) => renderTickerWidget(snapshot, theme, width),
70
- invalidate: () => {},
71
- }),
72
- { placement: "aboveEditor" },
73
- );
74
- return;
75
- }
76
- ctx.ui.setWidget(WIDGET_KEY, formatTickerPlain(snapshot), { placement: "aboveEditor" });
77
- };
55
+ const publish = (ctx: ExtensionContext): void => {
56
+ if (!ctx.hasUI || !ownsSession(ctx)) return;
57
+ if (!widgetEnabled || view.items.length === 0) {
58
+ ctx.ui.setWidget(WIDGET_KEY, undefined);
59
+ return;
60
+ }
61
+ const snapshot = cloneView(view);
62
+ if (ctx.mode === "tui") {
63
+ ctx.ui.setWidget(
64
+ WIDGET_KEY,
65
+ (_tui: unknown, theme: Theme) => ({
66
+ render: (width: number) => renderTickerWidget(snapshot, theme, width),
67
+ invalidate: () => {},
68
+ }),
69
+ { placement: "aboveEditor" },
70
+ );
71
+ return;
72
+ }
73
+ ctx.ui.setWidget(WIDGET_KEY, formatTickerPlain(snapshot), { placement: "aboveEditor" });
74
+ };
78
75
 
79
- const stopPolling = (): void => {
80
- cycleVersion += 1;
81
- if (pollTimer) clearTimeout(pollTimer);
82
- pollTimer = undefined;
83
- requestController?.abort();
84
- requestController = undefined;
85
- };
76
+ const stopPolling = (): void => {
77
+ cycleVersion += 1;
78
+ if (pollTimer) clearTimeout(pollTimer);
79
+ pollTimer = undefined;
80
+ requestController?.abort();
81
+ requestController = undefined;
82
+ };
86
83
 
87
- const clearWidget = (ctx: ExtensionContext): void => {
88
- if (ctx.hasUI) ctx.ui.setWidget(WIDGET_KEY, undefined);
89
- };
84
+ const clearWidget = (ctx: ExtensionContext): void => {
85
+ if (ctx.hasUI) ctx.ui.setWidget(WIDGET_KEY, undefined);
86
+ };
90
87
 
91
- const runCycle = async (
92
- ctx: ExtensionContext,
93
- expectedGeneration: number,
94
- expectedCycle: number,
95
- ): Promise<void> => {
96
- if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
97
- view = { ...view, loading: true };
98
- publish(ctx);
88
+ const runCycle = async (ctx: ExtensionContext, expectedGeneration: number, expectedCycle: number): Promise<void> => {
89
+ if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
90
+ view = { ...view, loading: true };
91
+ publish(ctx);
99
92
 
100
- const controller = new AbortController();
101
- requestController = controller;
102
- const timeout = setTimeout(() => {
103
- controller.abort(new QuoteRequestTimeoutError());
104
- }, REQUEST_TIMEOUT_MS);
105
- try {
106
- const results = await fetchQuotes(symbols, controller.signal);
107
- if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
108
- view = {
109
- items: mergeQuoteResults(view.items, results),
110
- loading: false,
111
- updatedAt: results.some((result) => result.quote) ? Date.now() : view.updatedAt,
112
- };
113
- publish(ctx);
114
- } catch {
115
- if (
116
- !controller.signal.aborted &&
117
- ownsSession(ctx, expectedGeneration) &&
118
- expectedCycle === cycleVersion
119
- ) {
120
- view = {
121
- items: view.items.map((item) => ({
122
- ...item,
123
- stale: Boolean(item.quote),
124
- error: "unavailable",
125
- })),
126
- loading: false,
127
- updatedAt: view.updatedAt,
128
- };
129
- publish(ctx);
130
- }
131
- } finally {
132
- clearTimeout(timeout);
133
- if (requestController === controller) requestController = undefined;
134
- }
135
- };
93
+ const controller = new AbortController();
94
+ requestController = controller;
95
+ const timeout = setTimeout(() => {
96
+ controller.abort(new QuoteRequestTimeoutError());
97
+ }, REQUEST_TIMEOUT_MS);
98
+ try {
99
+ const results = await fetchQuotes(symbols, controller.signal);
100
+ if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
101
+ view = {
102
+ items: mergeQuoteResults(view.items, results),
103
+ loading: false,
104
+ updatedAt: results.some((result) => result.quote) ? Date.now() : view.updatedAt,
105
+ };
106
+ publish(ctx);
107
+ } catch {
108
+ if (!controller.signal.aborted && ownsSession(ctx, expectedGeneration) && expectedCycle === cycleVersion) {
109
+ view = {
110
+ items: view.items.map((item) => ({
111
+ ...item,
112
+ stale: Boolean(item.quote),
113
+ error: "unavailable",
114
+ })),
115
+ loading: false,
116
+ updatedAt: view.updatedAt,
117
+ };
118
+ publish(ctx);
119
+ }
120
+ } finally {
121
+ clearTimeout(timeout);
122
+ if (requestController === controller) requestController = undefined;
123
+ }
124
+ };
136
125
 
137
- const startCycle = (ctx: ExtensionContext, expectedGeneration = generation): void => {
138
- if (!ownsSession(ctx, expectedGeneration)) return;
139
- if (!widgetEnabled || symbols.length === 0) {
140
- stopPolling();
141
- publish(ctx);
142
- return;
143
- }
144
- if (pollTimer) clearTimeout(pollTimer);
145
- requestController?.abort();
146
- const expectedCycle = ++cycleVersion;
147
- void runCycle(ctx, expectedGeneration, expectedCycle).finally(() => {
148
- if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
149
- pollTimer = setTimeout(() => startCycle(ctx, expectedGeneration), POLL_INTERVAL_MS);
150
- });
151
- };
126
+ const startCycle = (ctx: ExtensionContext, expectedGeneration = generation): void => {
127
+ if (!ownsSession(ctx, expectedGeneration)) return;
128
+ if (!widgetEnabled || symbols.length === 0) {
129
+ stopPolling();
130
+ publish(ctx);
131
+ return;
132
+ }
133
+ if (pollTimer) clearTimeout(pollTimer);
134
+ requestController?.abort();
135
+ const expectedCycle = ++cycleVersion;
136
+ void runCycle(ctx, expectedGeneration, expectedCycle).finally(() => {
137
+ if (!ownsSession(ctx, expectedGeneration) || expectedCycle !== cycleVersion) return;
138
+ pollTimer = setTimeout(() => startCycle(ctx, expectedGeneration), POLL_INTERVAL_MS);
139
+ });
140
+ };
152
141
 
153
- const openMenu = async (ctx: ExtensionCommandContext): Promise<void> => {
154
- const controller = sessionController;
155
- const expectedGeneration = generation;
156
- if (!controller || controller.signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
157
- const running = (async () => {
158
- const { showTickerMenu } = await import("./menu.js");
159
- if (controller.signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
160
- await showTickerMenu(ctx, {
161
- signal: controller.signal,
162
- isCurrent: () => !controller.signal.aborted && ownsSession(ctx, expectedGeneration),
163
- getSymbols: () => [...symbols],
164
- applySymbols: async (nextSymbols, signal) => {
165
- if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
166
- const normalized = normalizeSymbols(nextSymbols, true);
167
- await settingsWriter.save(settingsPath(), normalized);
168
- if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
169
- symbols = normalized;
170
- view = createInitialView(symbols);
171
- publish(ctx);
172
- startCycle(ctx, expectedGeneration);
173
- },
174
- getWidgetEnabled: () => widgetEnabled,
175
- applyWidgetEnabled: async (nextWidgetEnabled, signal) => {
176
- if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
177
- await settingsWriter.saveWidgetEnabled(settingsPath(), nextWidgetEnabled);
178
- if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
179
- widgetEnabled = nextWidgetEnabled;
180
- if (!widgetEnabled) stopPolling();
181
- publish(ctx);
182
- if (widgetEnabled) startCycle(ctx, expectedGeneration);
183
- },
184
- refresh: () => {
185
- if (!ownsSession(ctx, expectedGeneration)) return;
186
- if (!widgetEnabled) {
187
- notify(ctx, "Ticker widget is disabled. Enable it before refreshing.", "warning");
188
- return;
189
- }
190
- startCycle(ctx, expectedGeneration);
191
- },
192
- });
193
- })();
194
- activeMenus.add(running);
195
- try {
196
- await running;
197
- } finally {
198
- activeMenus.delete(running);
199
- }
200
- };
142
+ const openMenu = async (ctx: ExtensionCommandContext): Promise<void> => {
143
+ const controller = sessionController;
144
+ const expectedGeneration = generation;
145
+ if (!controller || controller.signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
146
+ const running = (async () => {
147
+ const { showTickerMenu } = await import("./menu.js");
148
+ if (controller.signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
149
+ await showTickerMenu(ctx, {
150
+ signal: controller.signal,
151
+ isCurrent: () => !controller.signal.aborted && ownsSession(ctx, expectedGeneration),
152
+ getSymbols: () => [...symbols],
153
+ applySymbols: async (nextSymbols, signal) => {
154
+ if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
155
+ const normalized = normalizeSymbols(nextSymbols, true);
156
+ await settingsWriter.save(settingsPath(), normalized);
157
+ if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
158
+ symbols = normalized;
159
+ view = createInitialView(symbols);
160
+ publish(ctx);
161
+ startCycle(ctx, expectedGeneration);
162
+ },
163
+ getWidgetEnabled: () => widgetEnabled,
164
+ applyWidgetEnabled: async (nextWidgetEnabled, signal) => {
165
+ if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
166
+ await settingsWriter.saveWidgetEnabled(settingsPath(), nextWidgetEnabled);
167
+ if (signal.aborted || !ownsSession(ctx, expectedGeneration)) return;
168
+ widgetEnabled = nextWidgetEnabled;
169
+ if (!widgetEnabled) stopPolling();
170
+ publish(ctx);
171
+ if (widgetEnabled) startCycle(ctx, expectedGeneration);
172
+ },
173
+ refresh: () => {
174
+ if (!ownsSession(ctx, expectedGeneration)) return;
175
+ if (!widgetEnabled) {
176
+ notify(ctx, "Ticker widget is disabled. Enable it before refreshing.", "warning");
177
+ return;
178
+ }
179
+ startCycle(ctx, expectedGeneration);
180
+ },
181
+ });
182
+ })();
183
+ activeMenus.add(running);
184
+ try {
185
+ await running;
186
+ } finally {
187
+ activeMenus.delete(running);
188
+ }
189
+ };
201
190
 
202
- pi.on("session_start", async (_event, ctx) => {
203
- sessionController?.abort();
204
- stopPolling();
205
- activeSession = ctx.sessionManager;
206
- sessionController = new AbortController();
207
- const expectedGeneration = ++generation;
208
- symbols = [];
209
- widgetEnabled = true;
210
- view = createInitialView(symbols);
211
- publish(ctx);
191
+ pi.on("session_start", async (_event, ctx) => {
192
+ sessionController?.abort();
193
+ stopPolling();
194
+ activeSession = ctx.sessionManager;
195
+ sessionController = new AbortController();
196
+ const expectedGeneration = ++generation;
197
+ symbols = [];
198
+ widgetEnabled = true;
199
+ view = createInitialView(symbols);
200
+ publish(ctx);
212
201
 
213
- await settingsWriter.flush();
214
- if (!ownsSession(ctx, expectedGeneration)) return;
215
- const loaded = await readSettings(settingsPath());
216
- if (!ownsSession(ctx, expectedGeneration)) return;
217
- symbols = loaded.settings.symbols;
218
- widgetEnabled = loaded.settings.widgetEnabled;
219
- view = createInitialView(symbols);
220
- publish(ctx);
221
- if (loaded.warning) notify(ctx, loaded.warning, "warning");
222
- if (ctx.hasUI && widgetEnabled && symbols.length > 0) startCycle(ctx, expectedGeneration);
223
- });
202
+ await settingsWriter.flush();
203
+ if (!ownsSession(ctx, expectedGeneration)) return;
204
+ const loaded = await readSettings(settingsPath());
205
+ if (!ownsSession(ctx, expectedGeneration)) return;
206
+ symbols = loaded.settings.symbols;
207
+ widgetEnabled = loaded.settings.widgetEnabled;
208
+ view = createInitialView(symbols);
209
+ publish(ctx);
210
+ if (loaded.warning) notify(ctx, loaded.warning, "warning");
211
+ if (ctx.hasUI && widgetEnabled && symbols.length > 0) startCycle(ctx, expectedGeneration);
212
+ });
224
213
 
225
- pi.on("session_shutdown", async (_event, ctx) => {
226
- if (!ownsSession(ctx)) return;
227
- sessionController?.abort();
228
- stopPolling();
229
- clearWidget(ctx);
230
- activeSession = undefined;
231
- sessionController = undefined;
232
- generation += 1;
233
- await Promise.allSettled([...activeMenus]);
234
- await settingsWriter.flush();
235
- });
214
+ pi.on("session_shutdown", async (_event, ctx) => {
215
+ if (!ownsSession(ctx)) return;
216
+ sessionController?.abort();
217
+ stopPolling();
218
+ clearWidget(ctx);
219
+ activeSession = undefined;
220
+ sessionController = undefined;
221
+ generation += 1;
222
+ await Promise.allSettled([...activeMenus]);
223
+ await settingsWriter.flush();
224
+ });
236
225
 
237
- pi.registerCommand("ticker", {
238
- description: "Show or change the stock ticker symbols",
239
- getArgumentCompletions: completeArguments,
240
- handler: async (argumentsText, ctx) => {
241
- if (!ctx.hasUI) {
242
- throw new Error("The /ticker command requires TUI or RPC mode.");
243
- }
244
- const input = argumentsText.trim();
245
- if (!input) {
246
- await openMenu(ctx);
247
- return;
248
- }
226
+ pi.registerCommand("ticker", {
227
+ description: "Show or change the stock ticker symbols",
228
+ getArgumentCompletions: completeArguments,
229
+ handler: async (argumentsText, ctx) => {
230
+ if (!ctx.hasUI) {
231
+ throw new Error("The /ticker command requires TUI or RPC mode.");
232
+ }
233
+ const input = argumentsText.trim();
234
+ if (!input) {
235
+ await openMenu(ctx);
236
+ return;
237
+ }
249
238
 
250
- const words = input.split(/\s+/);
251
- const route = words[0]?.toLowerCase();
252
- if (["help", "refresh", "reset"].includes(route ?? "") && words.length > 1) {
253
- notify(ctx, `${route} does not accept trailing arguments.`, "error");
254
- return;
255
- }
256
- if (route === "help") {
257
- notify(ctx, HELP);
258
- return;
259
- }
260
- if (route === "refresh") {
261
- if (!widgetEnabled) {
262
- notify(
263
- ctx,
264
- "Ticker widget is disabled. Enable it with /ticker before refreshing.",
265
- "warning",
266
- );
267
- return;
268
- }
269
- if (ownsSession(ctx)) startCycle(ctx);
270
- notify(ctx, "Refreshing stock quotes.");
271
- return;
272
- }
239
+ const words = input.split(/\s+/);
240
+ const route = words[0]?.toLowerCase();
241
+ if (["help", "refresh", "reset"].includes(route ?? "") && words.length > 1) {
242
+ notify(ctx, `${route} does not accept trailing arguments.`, "error");
243
+ return;
244
+ }
245
+ if (route === "help") {
246
+ notify(ctx, HELP);
247
+ return;
248
+ }
249
+ if (route === "refresh") {
250
+ if (!widgetEnabled) {
251
+ notify(ctx, "Ticker widget is disabled. Enable it with /ticker before refreshing.", "warning");
252
+ return;
253
+ }
254
+ if (ownsSession(ctx)) startCycle(ctx);
255
+ notify(ctx, "Refreshing stock quotes.");
256
+ return;
257
+ }
273
258
 
274
- if (route === "reset") {
275
- notify(
276
- ctx,
277
- "No default ticker list is configured. Use /ticker SYMBOL ... instead.",
278
- "error",
279
- );
280
- return;
281
- }
259
+ if (route === "reset") {
260
+ notify(ctx, "No default ticker list is configured. Use /ticker SYMBOL ... instead.", "error");
261
+ return;
262
+ }
282
263
 
283
- let nextSymbols: string[];
284
- try {
285
- nextSymbols = parseSymbols([input]);
286
- } catch (error) {
287
- notify(ctx, errorMessage(error), "error");
288
- return;
289
- }
290
- try {
291
- await settingsWriter.save(settingsPath(), nextSymbols);
292
- } catch (error) {
293
- notify(ctx, `Could not save stock ticker settings: ${errorMessage(error)}`, "error");
294
- return;
295
- }
296
- if (!ownsSession(ctx)) return;
297
- symbols = nextSymbols;
298
- view = createInitialView(symbols);
299
- publish(ctx);
300
- startCycle(ctx);
301
- notify(ctx, `Stock ticker symbols: ${symbols.join(" ")}`);
302
- },
303
- });
264
+ let nextSymbols: string[];
265
+ try {
266
+ nextSymbols = parseSymbols([input]);
267
+ } catch (error) {
268
+ notify(ctx, errorMessage(error), "error");
269
+ return;
270
+ }
271
+ try {
272
+ await settingsWriter.save(settingsPath(), nextSymbols);
273
+ } catch (error) {
274
+ notify(ctx, `Could not save stock ticker settings: ${errorMessage(error)}`, "error");
275
+ return;
276
+ }
277
+ if (!ownsSession(ctx)) return;
278
+ symbols = nextSymbols;
279
+ view = createInitialView(symbols);
280
+ publish(ctx);
281
+ startCycle(ctx);
282
+ notify(ctx, `Stock ticker symbols: ${symbols.join(" ")}`);
283
+ },
284
+ });
304
285
  }
305
286
 
306
287
  export function settingsPath(): string {
307
- return join(getAgentDir(), SETTINGS_FILE_NAME);
288
+ return join(getAgentDir(), SETTINGS_FILE_NAME);
308
289
  }
309
290
 
310
291
  export function completeArguments(prefix: string): AutocompleteItem[] | null {
311
- if (/\s/.test(prefix)) return null;
312
- const normalized = prefix.toLowerCase();
313
- const matches = COMPLETIONS.filter((item) => item.value.toLowerCase().startsWith(normalized));
314
- return matches.length > 0 ? matches : null;
292
+ if (/\s/.test(prefix)) return null;
293
+ const normalized = prefix.toLowerCase();
294
+ const matches = COMPLETIONS.filter((item) => item.value.toLowerCase().startsWith(normalized));
295
+ return matches.length > 0 ? matches : null;
315
296
  }
316
297
 
317
298
  function createInitialView(symbols: readonly string[]): TickerView {
318
- return {
319
- items: symbols.map((symbol): TickerItem => ({ symbol })),
320
- loading: true,
321
- };
299
+ return {
300
+ items: symbols.map((symbol): TickerItem => ({ symbol })),
301
+ loading: true,
302
+ };
322
303
  }
323
304
 
324
305
  function cloneView(view: TickerView): TickerView {
325
- return {
326
- ...view,
327
- items: view.items.map((item) => ({ ...item, quote: item.quote && { ...item.quote } })),
328
- };
306
+ return {
307
+ ...view,
308
+ items: view.items.map((item) => ({ ...item, quote: item.quote && { ...item.quote } })),
309
+ };
329
310
  }
330
311
 
331
- function notify(
332
- ctx: ExtensionContext,
333
- message: string,
334
- type: "info" | "warning" | "error" = "info",
335
- ): void {
336
- if (ctx.hasUI) ctx.ui.notify(sanitizeTerminalText(message), type);
312
+ function notify(ctx: ExtensionContext, message: string, type: "info" | "warning" | "error" = "info"): void {
313
+ if (ctx.hasUI) ctx.ui.notify(sanitizeTerminalText(message), type);
337
314
  }
338
315
 
339
316
  function errorMessage(error: unknown): string {
340
- return error instanceof Error ? error.message : String(error);
317
+ return error instanceof Error ? error.message : String(error);
341
318
  }