@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.
- package/package.json +1 -1
- package/src/account/heard-from-question.tsx +6 -4
- package/src/account/heard-from.ts +3 -4
- package/src/api-client/exchange-announcements.ts +2 -2
- package/src/api-client/heard-from.ts +5 -7
- package/src/api-client/ownership-disclosures.ts +38 -5
- package/src/api-client/types/ticker-data.ts +3 -1
- package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
- package/src/cli/commands/market.ts +5 -3
- package/src/cli/commands/overview.ts +7 -9
- package/src/cli/listing-arg.ts +45 -18
- package/src/cli/pane-functions/catalog-snapshot.json +2 -2
- package/src/cli/pane-functions/data.ts +3 -1
- package/src/cli/pane-functions/freshness.ts +6 -1
- package/src/cli/pane-functions/function-help.ts +0 -2
- package/src/cli/pane-functions/market-session.ts +12 -2
- package/src/cli/pane-functions/screenshot-payload.ts +3 -1
- package/src/cli/symbol-list.ts +52 -14
- package/src/cli/ticker-resolution.ts +133 -38
- package/src/components/chart/composite/composite-chart.tsx +12 -0
- package/src/components/chart/composite/types.ts +18 -0
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
- package/src/components/chart-table/header.tsx +11 -5
- package/src/components/chart-table/selection.ts +20 -1
- package/src/components/data-table/view.tsx +2 -0
- package/src/components/feed-data-table/stack-view.tsx +85 -5
- package/src/components/layout/pane/header.tsx +12 -30
- package/src/components/ticker/badge/index.tsx +9 -4
- package/src/components/ticker/badge/list.tsx +3 -1
- package/src/components/ui/data-table/index.tsx +7 -1
- package/src/components/ui/data-table/muted-row.tsx +47 -0
- package/src/components/ui/data-table/opentui/index.tsx +42 -11
- package/src/components/ui/data-table/spill.ts +36 -0
- package/src/components/ui/data-table/types.ts +17 -1
- package/src/components/ui/data-table/use-column-order.ts +11 -0
- package/src/components/ui/icon.tsx +50 -3
- package/src/components/ui/list-view.tsx +2 -2
- package/src/components/ui/table-layout.ts +32 -0
- package/src/components/ui/terminal-hover-label.tsx +49 -0
- package/src/components/use-pinned-moment.ts +222 -13
- package/src/core/state/app/state.ts +11 -2
- package/src/core/state/app/types.ts +2 -1
- package/src/data/sqlite/access.ts +14 -1
- package/src/data/sqlite/checkpointer.ts +2 -2
- package/src/data/sqlite/database.ts +4 -0
- package/src/docs/snapshot.json +180 -26
- package/src/i18n/es.ts +1 -0
- package/src/i18n/ja.ts +1 -0
- package/src/i18n/ko.ts +1 -0
- package/src/i18n/zh-cn.ts +1 -0
- package/src/i18n/zh-tw.ts +1 -0
- package/src/market-data/market/freshness.ts +2 -2
- package/src/market-data/market/globex-day.ts +14 -0
- package/src/market-data/published-us-sessions.ts +3 -2
- package/src/market-data/quotes/live-valuation.ts +4 -2
- package/src/market-data/quotes/metadata.ts +48 -5
- package/src/market-data/quotes/regular-session-valuation.ts +12 -1
- package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
- package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
- package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
- package/src/plugins/builtin/chat/channels.ts +5 -2
- package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
- package/src/plugins/builtin/chat/content/footer.tsx +17 -7
- package/src/plugins/builtin/chat/content/index.tsx +108 -36
- package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
- package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
- package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
- package/src/plugins/builtin/chat/content/types.ts +2 -0
- package/src/plugins/builtin/chat/controller/channels.ts +15 -15
- package/src/plugins/builtin/chat/controller/index.ts +140 -34
- package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
- package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
- package/src/plugins/builtin/chat/controller/send.ts +41 -17
- package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
- package/src/plugins/builtin/chat/controller/state.ts +17 -8
- package/src/plugins/builtin/chat/controller/storage.ts +41 -4
- package/src/plugins/builtin/chat/controller/view.ts +6 -3
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/chat/layout.ts +8 -1
- package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
- package/src/plugins/builtin/chat/message/header.tsx +112 -30
- package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
- package/src/plugins/builtin/chat/message/render-state.ts +4 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/message/types.ts +5 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
- package/src/plugins/builtin/company-kpis/model.ts +11 -3
- package/src/plugins/builtin/correlation/compute.ts +6 -1
- package/src/plugins/builtin/custom-view/loader.ts +95 -34
- package/src/plugins/builtin/custom-view/pane.tsx +31 -41
- package/src/plugins/builtin/custom-view/table.ts +201 -0
- package/src/plugins/builtin/dividend-yield/client.ts +14 -17
- package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
- package/src/plugins/builtin/dividend-yield/model.ts +45 -6
- package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
- package/src/plugins/builtin/dividend-yield/types.ts +2 -3
- package/src/plugins/builtin/dividend-yield/view.ts +22 -2
- package/src/plugins/builtin/econ/calendar-model.ts +135 -0
- package/src/plugins/builtin/econ/columns.ts +132 -0
- package/src/plugins/builtin/econ/index.tsx +25 -65
- package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
- package/src/plugins/builtin/holders/disclosures.ts +20 -6
- package/src/plugins/builtin/holders/headless.ts +2 -2
- package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
- package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
- package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
- package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
- package/src/plugins/builtin/market-halts/pane.tsx +14 -2
- package/src/plugins/builtin/news/wire/news/row.ts +5 -12
- package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
- package/src/plugins/builtin/pe-band/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/model.ts +41 -18
- package/src/plugins/builtin/pe-band/pane.tsx +6 -5
- package/src/plugins/builtin/perps/equity-row.tsx +4 -6
- package/src/plugins/builtin/perps/markets-section.tsx +19 -15
- package/src/plugins/builtin/perps/model.ts +10 -2
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
- package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
- package/src/plugins/builtin/research/event-data.ts +3 -1
- package/src/plugins/builtin/research/event-model.ts +17 -15
- package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
- package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
- package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
- package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
- package/src/plugins/builtin/sec/headless.ts +8 -8
- package/src/plugins/builtin/sec/index.tsx +69 -29
- package/src/plugins/builtin/shared/report-freshness.ts +4 -1
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
- package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
- package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
- package/src/plugins/builtin/time-sales/model.ts +16 -9
- package/src/plugins/builtin/time-sales/pane.tsx +27 -24
- package/src/plugins/builtin/treasury-daily/client.ts +43 -9
- package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
- package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
- package/src/portfolio/positions-import/parse.ts +14 -6
- package/src/portfolio/positions-import/plan.ts +3 -2
- package/src/react/async-resource.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +40 -0
- package/src/renderers/dom/data-table/row.tsx +39 -3
- package/src/renderers/dom/desktop/icons.tsx +147 -3
- package/src/renderers/dom/desktop/popover.tsx +2 -2
- package/src/renderers/dom/host/media-surface.tsx +204 -45
- package/src/renderers/dom/host/tabs.tsx +1 -0
- package/src/renderers/dom/styles.css +14 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
- package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
- package/src/sources/gloomberb-cloud/index.ts +8 -7
- package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
- package/src/sources/listing-symbols.ts +7 -1
- package/src/sources/provider-router/cache.ts +5 -4
- package/src/sources/provider-router/financials.ts +40 -18
- package/src/state/app/tab-cursor.ts +47 -6
- package/src/telemetry/stall-clocks.ts +3 -0
- package/src/telemetry/stall-reports.ts +12 -3
- package/src/telemetry/windows-process-activity.ts +41 -0
- package/src/telemetry/windows-time.ts +32 -0
- package/src/test-support/scoped-earnings.ts +24 -0
- package/src/tickers/terminal-codes.ts +1 -6
- package/src/time-series/daily-valuation.ts +13 -6
- package/src/time-series/filed-trailing-eps.ts +16 -3
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/historical-valuation.ts +20 -0
- package/src/time-series/fundamentals/series.ts +13 -1
- package/src/time-series/valuation-currency.ts +2 -0
- package/src/types/financials.ts +46 -10
- package/src/ui/dialog-context.ts +8 -0
- package/src/utils/datetime-format.ts +23 -1
- package/src/utils/declared-dividends.ts +12 -2
- package/src/utils/exchange-announcements.ts +4 -1
- package/src/utils/exchange-notation.generated.ts +3 -1
- package/src/utils/exchanges.ts +2 -1
- package/src/utils/fundamentals.ts +1 -0
- package/src/utils/main-thread-stall.ts +9 -1
- package/src/utils/rpc-timeout-error.ts +36 -11
- package/src/utils/sec.ts +3 -1
- package/src/utils/share-multiples.ts +1 -1
- package/src/utils/stall-process-activity.ts +70 -0
- package/src/utils/statement-scope.ts +103 -0
- package/src/utils/trailing-eps.ts +1 -1
- package/src/utils/zoned-date-time.ts +1 -0
|
@@ -33,10 +33,12 @@ export function useChatComposerRuntime({
|
|
|
33
33
|
inputFocused,
|
|
34
34
|
inputRef,
|
|
35
35
|
inputValueRef,
|
|
36
|
+
isComposerCurrent,
|
|
36
37
|
messages,
|
|
37
38
|
onComposerStateChange,
|
|
38
39
|
onChannelChange,
|
|
39
40
|
editingMessage,
|
|
41
|
+
editingMessageRef,
|
|
40
42
|
latestEditableMessageId,
|
|
41
43
|
replyTo,
|
|
42
44
|
setEditingMessage,
|
|
@@ -65,13 +67,15 @@ export function useChatComposerRuntime({
|
|
|
65
67
|
inputFocused: boolean;
|
|
66
68
|
inputRef: MutableRef<TextareaRenderable | null>;
|
|
67
69
|
inputValueRef: MutableRef<string>;
|
|
70
|
+
isComposerCurrent: () => boolean;
|
|
68
71
|
messages: ChatMessage[];
|
|
69
72
|
onComposerStateChange?: (draft: string, cursorOffset: number) => void;
|
|
70
73
|
onChannelChange?: (channelId: string) => void;
|
|
71
74
|
editingMessage: ChatMessage | null;
|
|
75
|
+
editingMessageRef: MutableRef<ChatMessage | null>;
|
|
72
76
|
latestEditableMessageId: string | null;
|
|
73
77
|
replyTo: ChatMessage | null;
|
|
74
|
-
setEditingMessage:
|
|
78
|
+
setEditingMessage: (message: ChatMessage | null) => void;
|
|
75
79
|
expandDirectSection: () => void;
|
|
76
80
|
setFollowMessages: Dispatch<SetStateAction<boolean>>;
|
|
77
81
|
setReplyTo: Dispatch<SetStateAction<ChatMessage | null>>;
|
|
@@ -95,9 +99,7 @@ export function useChatComposerRuntime({
|
|
|
95
99
|
const draftAttachmentCountRef = useRef(draftAttachmentCount);
|
|
96
100
|
draftAttachmentCountRef.current = draftAttachmentCount;
|
|
97
101
|
replyToRef.current = replyTo;
|
|
98
|
-
const
|
|
99
|
-
editingMessageRef.current = editingMessage;
|
|
100
|
-
const editSubmittingRef = useRef(false);
|
|
102
|
+
const editSubmittingRef = useRef<ChatMessage | null>(null);
|
|
101
103
|
|
|
102
104
|
const focusComposer = useCallback(() => {
|
|
103
105
|
setSelectedIdx(-1);
|
|
@@ -106,23 +108,25 @@ export function useChatComposerRuntime({
|
|
|
106
108
|
}, [focusInput, setFollowMessages, setSelectedIdx]);
|
|
107
109
|
|
|
108
110
|
const clearReplyTarget = useCallback(() => {
|
|
111
|
+
if (!isComposerCurrent()) return;
|
|
109
112
|
setReplyTo(null);
|
|
110
113
|
if (useDefaultControllerChannel) {
|
|
111
114
|
controller.setReplyToId(null);
|
|
112
115
|
} else {
|
|
113
116
|
controller.setChannelReplyToId(channelId, null);
|
|
114
117
|
}
|
|
115
|
-
}, [channelId, controller, setReplyTo, useDefaultControllerChannel]);
|
|
118
|
+
}, [channelId, controller, isComposerCurrent, setReplyTo, useDefaultControllerChannel]);
|
|
116
119
|
|
|
117
120
|
// The field's text is saved with the links of its chips, the way it will be sent.
|
|
118
121
|
const persistDraft = useCallback((text: string, links: readonly ComposerShareLink[] = draftLinksRef.current) => {
|
|
122
|
+
if (editingMessageRef.current) return;
|
|
119
123
|
const draft = joinComposerDraft(text, links);
|
|
120
124
|
if (useDefaultControllerChannel) {
|
|
121
125
|
controller.setDraft(draft);
|
|
122
126
|
} else {
|
|
123
127
|
controller.setChannelDraft(channelId, draft);
|
|
124
128
|
}
|
|
125
|
-
}, [channelId, controller, draftLinksRef, useDefaultControllerChannel]);
|
|
129
|
+
}, [channelId, controller, draftLinksRef, editingMessageRef, useDefaultControllerChannel]);
|
|
126
130
|
|
|
127
131
|
const replaceLocalComposer = useCallback((draft: string, cursorOffset = draft.length) => {
|
|
128
132
|
inputValueRef.current = draft;
|
|
@@ -143,26 +147,30 @@ export function useChatComposerRuntime({
|
|
|
143
147
|
}, [applyingExternalDraftRef, inputRef, inputValueRef, onComposerStateChange, updateComposerRows]);
|
|
144
148
|
|
|
145
149
|
const replaceComposerDraft = useCallback((draft: string, cursorOffset = draft.length) => {
|
|
150
|
+
if (!isComposerCurrent()) return;
|
|
146
151
|
replaceLocalComposer(draft, cursorOffset);
|
|
147
152
|
persistDraft(draft);
|
|
148
|
-
}, [persistDraft, replaceLocalComposer]);
|
|
153
|
+
}, [isComposerCurrent, persistDraft, replaceLocalComposer]);
|
|
149
154
|
|
|
150
155
|
/** New chips above the field, saved with the text as it is. */
|
|
151
156
|
const replaceDraftLinks = useCallback((links: ComposerShareLink[]) => {
|
|
157
|
+
if (!isComposerCurrent()) return;
|
|
152
158
|
setDraftLinks(links);
|
|
153
159
|
persistDraft(inputValueRef.current, links);
|
|
154
|
-
}, [inputValueRef, persistDraft, setDraftLinks]);
|
|
160
|
+
}, [inputValueRef, isComposerCurrent, persistDraft, setDraftLinks]);
|
|
161
|
+
|
|
162
|
+
const restoreNewMessageDraft = useCallback(() => {
|
|
163
|
+
setEditingMessage(null);
|
|
164
|
+
const view = splitComposerDraft(controller.getSnapshot(channelId).draft);
|
|
165
|
+
setDraftLinks(view.links);
|
|
166
|
+
replaceLocalComposer(view.text);
|
|
167
|
+
}, [channelId, controller, replaceLocalComposer, setDraftLinks, setEditingMessage]);
|
|
155
168
|
|
|
156
169
|
const beginReplyTo = useCallback((index: number, options?: { deferFocus?: boolean }) => {
|
|
157
|
-
if (!canSend || index < 0 || index >= messages.length) return;
|
|
170
|
+
if (!canSend || !isComposerCurrent() || index < 0 || index >= messages.length) return;
|
|
158
171
|
const nextReplyTo = messages[index] ?? null;
|
|
159
172
|
if (!nextReplyTo) return;
|
|
160
|
-
if (editingMessageRef.current)
|
|
161
|
-
setDraftLinks([]);
|
|
162
|
-
replaceLocalComposer("");
|
|
163
|
-
persistDraft("", []);
|
|
164
|
-
}
|
|
165
|
-
setEditingMessage(null);
|
|
173
|
+
if (editingMessageRef.current) restoreNewMessageDraft();
|
|
166
174
|
setSelectedIdx(index);
|
|
167
175
|
setFollowMessages(index === messages.length - 1);
|
|
168
176
|
setReplyTo(nextReplyTo);
|
|
@@ -180,31 +188,31 @@ export function useChatComposerRuntime({
|
|
|
180
188
|
canSend,
|
|
181
189
|
channelId,
|
|
182
190
|
controller,
|
|
191
|
+
editingMessageRef,
|
|
183
192
|
focusInput,
|
|
193
|
+
isComposerCurrent,
|
|
184
194
|
messages,
|
|
185
|
-
|
|
186
|
-
replaceLocalComposer,
|
|
187
|
-
setEditingMessage,
|
|
195
|
+
restoreNewMessageDraft,
|
|
188
196
|
setFollowMessages,
|
|
189
|
-
setDraftLinks,
|
|
190
197
|
setReplyTo,
|
|
191
198
|
setSelectedIdx,
|
|
192
199
|
useDefaultControllerChannel,
|
|
193
200
|
]);
|
|
194
201
|
|
|
195
202
|
const beginEditMessage = useCallback((index: number, options?: { deferFocus?: boolean }) => {
|
|
196
|
-
if (!canSend || index < 0 || index >= messages.length) return false;
|
|
203
|
+
if (!canSend || !isComposerCurrent() || index < 0 || index >= messages.length) return false;
|
|
197
204
|
const message = messages[index] ?? null;
|
|
198
205
|
if (!message || message.id !== latestEditableMessageId) return false;
|
|
206
|
+
const edit = { ...message };
|
|
207
|
+
setEditingMessage(edit);
|
|
199
208
|
clearReplyTarget();
|
|
200
|
-
|
|
209
|
+
if (editingMessageRef.current !== edit || !isComposerCurrent()) return false;
|
|
201
210
|
setSelectedIdx(index);
|
|
202
211
|
setFollowMessages(index === messages.length - 1);
|
|
203
212
|
// Links at the end of the message are chips again while it is edited.
|
|
204
213
|
const view = splitComposerDraft(message.content);
|
|
205
214
|
setDraftLinks(view.links);
|
|
206
215
|
replaceLocalComposer(view.text);
|
|
207
|
-
persistDraft(view.text, view.links);
|
|
208
216
|
if (options?.deferFocus) {
|
|
209
217
|
queueMicrotask(() => focusInput());
|
|
210
218
|
} else {
|
|
@@ -214,10 +222,11 @@ export function useChatComposerRuntime({
|
|
|
214
222
|
}, [
|
|
215
223
|
canSend,
|
|
216
224
|
clearReplyTarget,
|
|
225
|
+
editingMessageRef,
|
|
217
226
|
focusInput,
|
|
227
|
+
isComposerCurrent,
|
|
218
228
|
latestEditableMessageId,
|
|
219
229
|
messages,
|
|
220
|
-
persistDraft,
|
|
221
230
|
replaceLocalComposer,
|
|
222
231
|
setDraftLinks,
|
|
223
232
|
setEditingMessage,
|
|
@@ -232,13 +241,10 @@ export function useChatComposerRuntime({
|
|
|
232
241
|
}, [beginEditMessage, latestEditableMessageId, messages]);
|
|
233
242
|
|
|
234
243
|
const cancelEditMessage = useCallback(() => {
|
|
235
|
-
if (!editingMessageRef.current) return;
|
|
236
|
-
|
|
237
|
-
setDraftLinks([]);
|
|
238
|
-
replaceLocalComposer("");
|
|
239
|
-
persistDraft("", []);
|
|
244
|
+
if (!isComposerCurrent() || !editingMessageRef.current) return;
|
|
245
|
+
restoreNewMessageDraft();
|
|
240
246
|
focusInput();
|
|
241
|
-
}, [
|
|
247
|
+
}, [editingMessageRef, focusInput, isComposerCurrent, restoreNewMessageDraft]);
|
|
242
248
|
|
|
243
249
|
const returnToComposer = useCallback(() => {
|
|
244
250
|
setSelectedIdx(-1);
|
|
@@ -254,6 +260,7 @@ export function useChatComposerRuntime({
|
|
|
254
260
|
}, [replaceLocalComposer, setDraftLinks]);
|
|
255
261
|
|
|
256
262
|
const sendMessage = useCallback(() => {
|
|
263
|
+
if (!canSend || !isComposerCurrent()) return;
|
|
257
264
|
const content = composerMessage(inputValueRef.current, draftLinksRef.current);
|
|
258
265
|
const editing = editingMessageRef.current;
|
|
259
266
|
// Images let a message, or an edit of one that has them, go without text.
|
|
@@ -262,33 +269,43 @@ export function useChatComposerRuntime({
|
|
|
262
269
|
: draftAttachmentCountRef.current > 0;
|
|
263
270
|
if (!content && !imagesAllowEmpty) return;
|
|
264
271
|
if (editing) {
|
|
265
|
-
if (editSubmittingRef.current) return;
|
|
272
|
+
if (editSubmittingRef.current === editing) return;
|
|
266
273
|
const sendChannelId = useDefaultControllerChannel ? channelId : channelIdRef.current;
|
|
267
274
|
if (editing.channelId !== sendChannelId) return;
|
|
268
|
-
|
|
275
|
+
const isCurrent = controller.captureSessionScope();
|
|
276
|
+
if (!isCurrent()) return;
|
|
277
|
+
editSubmittingRef.current = editing;
|
|
269
278
|
void controller.editChannelMessage(sendChannelId, editing.id, content).then((accepted) => {
|
|
270
|
-
if (!accepted) return;
|
|
271
|
-
|
|
272
|
-
clearLocalComposer();
|
|
273
|
-
persistDraft("", []);
|
|
279
|
+
if (!accepted || !isCurrent() || editingMessageRef.current !== editing) return;
|
|
280
|
+
restoreNewMessageDraft();
|
|
274
281
|
setSelectedIdx(-1);
|
|
275
282
|
setFollowMessages(true);
|
|
276
283
|
}).finally(() => {
|
|
277
|
-
editSubmittingRef.current =
|
|
284
|
+
if (editSubmittingRef.current === editing) editSubmittingRef.current = null;
|
|
278
285
|
});
|
|
279
286
|
return;
|
|
280
287
|
}
|
|
281
288
|
const composerCommand = content ? parseChatComposerCommand(content) : null;
|
|
282
|
-
if (composerCommand?.kind === "direct") {
|
|
283
|
-
|
|
289
|
+
if (composerCommand?.kind === "direct" || composerCommand?.kind === "group") {
|
|
290
|
+
const isCurrent = controller.captureSessionScope();
|
|
291
|
+
if (!isCurrent()) return;
|
|
292
|
+
const usernames = composerCommand.kind === "direct" ? [composerCommand.username] : composerCommand.usernames;
|
|
293
|
+
const request = composerCommand.kind === "direct"
|
|
294
|
+
? controller.openDirectChannel({ username: composerCommand.username })
|
|
295
|
+
: controller.openGroupChannel({ usernames, name: composerCommand.name });
|
|
296
|
+
void request.then((channel) => {
|
|
297
|
+
if (!channel || !isCurrent()) return;
|
|
284
298
|
expandDirectSection();
|
|
285
299
|
channelIdRef.current = channel.id;
|
|
286
300
|
onChannelChange?.(channel.id);
|
|
301
|
+
if (!isCurrent()) return;
|
|
287
302
|
clearLocalComposer();
|
|
288
|
-
if (composerCommand.draft) {
|
|
303
|
+
if (composerCommand.kind === "direct" && composerCommand.draft) {
|
|
289
304
|
controller.setChannelDraft(channel.id, composerCommand.draft);
|
|
290
305
|
}
|
|
291
|
-
}).catch((error: unknown) =>
|
|
306
|
+
}).catch((error: unknown) => {
|
|
307
|
+
if (isCurrent()) onConversationStartError?.(error, usernames);
|
|
308
|
+
});
|
|
292
309
|
return;
|
|
293
310
|
}
|
|
294
311
|
if (composerCommand?.kind === "discord" && onDiscordCommand) {
|
|
@@ -297,18 +314,6 @@ export function useChatComposerRuntime({
|
|
|
297
314
|
onDiscordCommand(composerCommand);
|
|
298
315
|
return;
|
|
299
316
|
}
|
|
300
|
-
if (composerCommand?.kind === "group") {
|
|
301
|
-
void controller.openGroupChannel({
|
|
302
|
-
usernames: composerCommand.usernames,
|
|
303
|
-
name: composerCommand.name,
|
|
304
|
-
}).then((channel) => {
|
|
305
|
-
expandDirectSection();
|
|
306
|
-
channelIdRef.current = channel.id;
|
|
307
|
-
onChannelChange?.(channel.id);
|
|
308
|
-
clearLocalComposer();
|
|
309
|
-
}).catch((error: unknown) => onConversationStartError?.(error, composerCommand.usernames));
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
317
|
const sendChannelId = useDefaultControllerChannel ? channelId : channelIdRef.current;
|
|
313
318
|
const replyToId = replyToRef.current?.channelId === sendChannelId
|
|
314
319
|
? replyToRef.current.id
|
|
@@ -321,27 +326,29 @@ export function useChatComposerRuntime({
|
|
|
321
326
|
setSelectedIdx(-1);
|
|
322
327
|
setFollowMessages(true);
|
|
323
328
|
}, [
|
|
329
|
+
canSend,
|
|
324
330
|
channelId,
|
|
325
331
|
channelIdRef,
|
|
326
332
|
clearLocalComposer,
|
|
327
333
|
controller,
|
|
328
334
|
draftLinksRef,
|
|
335
|
+
editingMessageRef,
|
|
329
336
|
inputValueRef,
|
|
337
|
+
isComposerCurrent,
|
|
330
338
|
onChannelChange,
|
|
331
339
|
onConversationStartError,
|
|
332
340
|
onDiscordCommand,
|
|
333
341
|
expandDirectSection,
|
|
334
|
-
persistDraft,
|
|
335
342
|
replaceComposerDraft,
|
|
343
|
+
restoreNewMessageDraft,
|
|
336
344
|
setDraftLinks,
|
|
337
|
-
setEditingMessage,
|
|
338
345
|
setFollowMessages,
|
|
339
346
|
setSelectedIdx,
|
|
340
347
|
useDefaultControllerChannel,
|
|
341
348
|
]);
|
|
342
349
|
|
|
343
350
|
const commitLocalDraft = useCallback((draft: string) => {
|
|
344
|
-
if (applyingExternalDraftRef.current) return;
|
|
351
|
+
if (applyingExternalDraftRef.current || !isComposerCurrent()) return;
|
|
345
352
|
const previousDraft = inputValueRef.current;
|
|
346
353
|
// A share link pasted at the end of the draft leaves the field for a chip
|
|
347
354
|
// above it, the one the sent message shows; the cursor stays where it was.
|
|
@@ -369,8 +376,10 @@ export function useChatComposerRuntime({
|
|
|
369
376
|
}, [
|
|
370
377
|
applyingExternalDraftRef,
|
|
371
378
|
draftLinksRef,
|
|
379
|
+
editingMessageRef,
|
|
372
380
|
inputRef,
|
|
373
381
|
inputValueRef,
|
|
382
|
+
isComposerCurrent,
|
|
374
383
|
onComposerStateChange,
|
|
375
384
|
onPastedImagePaths,
|
|
376
385
|
persistDraft,
|
|
@@ -423,16 +432,6 @@ export function useChatComposerRuntime({
|
|
|
423
432
|
if (bound) bound.onContentChange = undefined;
|
|
424
433
|
}, []);
|
|
425
434
|
|
|
426
|
-
useEffect(() => {
|
|
427
|
-
if (canSend || !replyTo) return;
|
|
428
|
-
clearReplyTarget();
|
|
429
|
-
}, [canSend, clearReplyTarget, replyTo]);
|
|
430
|
-
|
|
431
|
-
useEffect(() => {
|
|
432
|
-
if (canSend || !editingMessage) return;
|
|
433
|
-
cancelEditMessage();
|
|
434
|
-
}, [canSend, cancelEditMessage, editingMessage]);
|
|
435
|
-
|
|
436
435
|
// The desktop and the web take the whole text and cut it in CSS where its row ends.
|
|
437
436
|
const replyPreview = !replyTo ? ""
|
|
438
437
|
: nativePaneChrome ? normalizeInlinePreview(chatTextWithImages(replyTo.content, replyTo.attachments?.length ?? 0))
|
|
@@ -10,7 +10,7 @@ import { chatAuthorName, isDiscordGhost } from "../ghost-user";
|
|
|
10
10
|
import { chatMessageOpenTargets, type ChatOpenTarget } from "./open-targets";
|
|
11
11
|
import { chatMessagePaneLinks, type ChatMessagePaneLink } from "../pane-links/model";
|
|
12
12
|
import { useChatFunctions } from "../pane-links/commands";
|
|
13
|
-
import { openChatImageViewer } from "../attachments/desktop";
|
|
13
|
+
import { openChatImageViewer, ScopedChatPreview, type ChatPreviewScope } from "../attachments/desktop";
|
|
14
14
|
import { canReactToMessage } from "../reactions";
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -25,6 +25,7 @@ export function useChatFooter({
|
|
|
25
25
|
canSend,
|
|
26
26
|
selectedIdx,
|
|
27
27
|
selectedMessage,
|
|
28
|
+
previewScope,
|
|
28
29
|
latestEditableMessageId,
|
|
29
30
|
beginEditMessage,
|
|
30
31
|
beginReplyTo,
|
|
@@ -63,6 +64,7 @@ export function useChatFooter({
|
|
|
63
64
|
canSend: boolean;
|
|
64
65
|
selectedIdx: number;
|
|
65
66
|
selectedMessage: ChatMessage | null;
|
|
67
|
+
previewScope: ChatPreviewScope;
|
|
66
68
|
latestEditableMessageId: string | null;
|
|
67
69
|
beginEditMessage: (index: number, options?: { deferFocus?: boolean }) => boolean;
|
|
68
70
|
beginReplyTo: (index: number, options?: { deferFocus?: boolean }) => void;
|
|
@@ -103,6 +105,7 @@ export function useChatFooter({
|
|
|
103
105
|
const rendererHost = useRendererHost();
|
|
104
106
|
const { links: paneLinks, content } = chatMessagePaneLinks(selectedMessage);
|
|
105
107
|
const attachments = selectedMessage?.attachments;
|
|
108
|
+
const localScope = selectedMessage?.clientStatus ? previewScope : undefined;
|
|
106
109
|
const { nativePaneChrome } = useUiCapabilities();
|
|
107
110
|
const functions = useChatFunctions();
|
|
108
111
|
// The desktop and the web draw functions written in a message as chips, so Open offers them too.
|
|
@@ -112,6 +115,7 @@ export function useChatFooter({
|
|
|
112
115
|
);
|
|
113
116
|
|
|
114
117
|
const openTarget = useCallback((target: ChatOpenTarget) => {
|
|
118
|
+
if (localScope && !localScope.isCurrent()) return;
|
|
115
119
|
if (target.kind === "pane") {
|
|
116
120
|
openPaneLink(target.link);
|
|
117
121
|
return;
|
|
@@ -127,14 +131,16 @@ export function useChatFooter({
|
|
|
127
131
|
index: target.index,
|
|
128
132
|
caption: selectedMessage.content,
|
|
129
133
|
author: chatAuthorName(selectedMessage.user),
|
|
134
|
+
scope: localScope,
|
|
130
135
|
});
|
|
131
136
|
return;
|
|
132
137
|
}
|
|
133
138
|
void rendererHost.openExternal(target.url);
|
|
134
|
-
}, [dialog, nativePaneChrome, openPaneLink, openTicker, rendererHost, selectedMessage]);
|
|
139
|
+
}, [dialog, localScope, nativePaneChrome, openPaneLink, openTicker, rendererHost, selectedMessage]);
|
|
135
140
|
|
|
136
141
|
// One target opens at once; several ask which, in the order the message reads.
|
|
137
142
|
const openSelectedTargets = useCallback(async () => {
|
|
143
|
+
if (localScope && !localScope.isCurrent()) return;
|
|
138
144
|
const [first] = openTargets;
|
|
139
145
|
if (!first) return;
|
|
140
146
|
if (openTargets.length === 1 || !dialog) {
|
|
@@ -148,13 +154,14 @@ export function useChatFooter({
|
|
|
148
154
|
}));
|
|
149
155
|
const choice = await dialog.prompt<string>({
|
|
150
156
|
closeOnClickOutside: true,
|
|
151
|
-
content: (context: PromptContext<string>) =>
|
|
152
|
-
<ChoiceDialog {...context} title="Open" choices={choices} selectedChoiceId="0"
|
|
153
|
-
|
|
157
|
+
content: (context: PromptContext<string>) => {
|
|
158
|
+
const chooser = <ChoiceDialog {...context} title="Open" choices={choices} selectedChoiceId="0" />;
|
|
159
|
+
return localScope ? <ScopedChatPreview scope={localScope} dismiss={context.dismiss}>{chooser}</ScopedChatPreview> : chooser;
|
|
160
|
+
},
|
|
154
161
|
}).catch(() => undefined);
|
|
155
162
|
const target = choice === undefined ? null : openTargets[Number(choice)];
|
|
156
163
|
if (target) openTarget(target);
|
|
157
|
-
}, [dialog, openTarget, openTargets]);
|
|
164
|
+
}, [dialog, localScope, openTarget, openTargets]);
|
|
158
165
|
|
|
159
166
|
// A Discord ghost has no card to show.
|
|
160
167
|
const author = selectedMessage && !isDiscordGhost(selectedMessage.user) ? selectedMessage.user : null;
|
|
@@ -287,7 +294,9 @@ export function useChatFooter({
|
|
|
287
294
|
// The message as its author wrote it, markdown and all; a selection copies what the row draws.
|
|
288
295
|
const messageText = composing ? "" : selectedMessage?.content ?? "";
|
|
289
296
|
if (messageText) {
|
|
290
|
-
menu.push({ id: "copy-message", label: "Copy Message Text", onSelect: () => {
|
|
297
|
+
menu.push({ id: "copy-message", label: "Copy Message Text", onSelect: () => {
|
|
298
|
+
if (!localScope || localScope.isCurrent()) void rendererHost.copyText(messageText);
|
|
299
|
+
} });
|
|
291
300
|
}
|
|
292
301
|
if (needsProfileSetup) {
|
|
293
302
|
menu.push({ id: "profile-setup", label: "Set Up Profile", onSelect: () => latest.current.openProfileSetup() });
|
|
@@ -307,6 +316,7 @@ export function useChatFooter({
|
|
|
307
316
|
canFocusSidebar,
|
|
308
317
|
canSend,
|
|
309
318
|
composing,
|
|
319
|
+
localScope,
|
|
310
320
|
newChannelTeamId,
|
|
311
321
|
needsProfileSetup,
|
|
312
322
|
notificationChannelId,
|