@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Box, Text, useContextMenu, useRendererHost, useUiCapabilities } from "../../../../ui";
|
|
2
|
-
import { useState, useEffect, useRef, useCallback, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { useState, useEffect, useLayoutEffect, useRef, useCallback, useMemo, useSyncExternalStore } from "react";
|
|
3
3
|
import { PageStackView } from "../../../../components/ui";
|
|
4
4
|
import { ChoiceDialog } from "../../../../components/ui/choice-dialog";
|
|
5
5
|
import { useOptionalDialog, type PromptContext } from "../../../../ui/dialog";
|
|
6
|
+
import { useAnyDialogOpen } from "../../../../ui/dialog-context";
|
|
6
7
|
import { canReactToMessage, terminalReactionChoices } from "../reactions";
|
|
7
8
|
import { type InputRenderable, type ScrollBoxRenderable, type TextareaRenderable } from "../../../../ui";
|
|
8
9
|
import { useAppDispatch, useAppSelector } from "../../../../state/app/context";
|
|
@@ -92,6 +93,11 @@ interface ChatContentProps {
|
|
|
92
93
|
onTargetMessageHandled?: () => void;
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
interface NewDmDialogSession {
|
|
97
|
+
id: number;
|
|
98
|
+
scope: object;
|
|
99
|
+
}
|
|
100
|
+
|
|
95
101
|
/** No account and no saved login to finish: the chat shows nothing. */
|
|
96
102
|
function isSignedOut(snapshot: { user: unknown; hasSavedSession: boolean }): boolean {
|
|
97
103
|
return !snapshot.user && !snapshot.hasSavedSession;
|
|
@@ -135,6 +141,7 @@ function ChatConversation({
|
|
|
135
141
|
const dispatch = useAppDispatch();
|
|
136
142
|
const { showPane, createPaneFromTemplate, notify } = usePluginAppActions();
|
|
137
143
|
const commandBarOpen = useAppSelector((state) => state.commandBarOpen);
|
|
144
|
+
const dialogOpen = useAnyDialogOpen();
|
|
138
145
|
const channelId = normalizeChannelId(rawChannelId);
|
|
139
146
|
const channelIdRef = useRef(channelId);
|
|
140
147
|
channelIdRef.current = channelId;
|
|
@@ -143,9 +150,28 @@ function ChatConversation({
|
|
|
143
150
|
const rendererHost = useRendererHost();
|
|
144
151
|
const [inputFocused, setInputFocused] = useState(false);
|
|
145
152
|
const [selectedIdx, setSelectedIdx] = useState(-1);
|
|
146
|
-
const
|
|
153
|
+
const editingMessageRef = useRef<ChatMessage | null>(null);
|
|
154
|
+
const [editingMessage, setEditingMessageState] = useState<ChatMessage | null>(null);
|
|
155
|
+
const setEditingMessage = useCallback((message: ChatMessage | null) => {
|
|
156
|
+
editingMessageRef.current = message;
|
|
157
|
+
setEditingMessageState(message);
|
|
158
|
+
}, []);
|
|
147
159
|
const [followMessages, setFollowMessages] = useState(true);
|
|
148
|
-
const [
|
|
160
|
+
const [newDmDialogSession, setNewDmDialogSession] = useState<NewDmDialogSession | null>(null);
|
|
161
|
+
const newDmDialogRef = useRef<NewDmDialogSession | null>(null);
|
|
162
|
+
const nextNewDmDialogIdRef = useRef(0);
|
|
163
|
+
const releaseNewDmDialog = useCallback((dialog: NewDmDialogSession | null) => {
|
|
164
|
+
if (!dialog || newDmDialogRef.current !== dialog) return false;
|
|
165
|
+
newDmDialogRef.current = null;
|
|
166
|
+
dispatch({ type: "SET_INPUT_CAPTURED", captured: false, owner: dialog });
|
|
167
|
+
return true;
|
|
168
|
+
}, [dispatch]);
|
|
169
|
+
const closeNewDmDialog = useCallback((dialog = newDmDialogRef.current) => {
|
|
170
|
+
if (releaseNewDmDialog(dialog)) setNewDmDialogSession((current) => current === dialog ? null : current);
|
|
171
|
+
}, [releaseNewDmDialog]);
|
|
172
|
+
useLayoutEffect(() => () => {
|
|
173
|
+
releaseNewDmDialog(newDmDialogRef.current);
|
|
174
|
+
}, [releaseNewDmDialog]);
|
|
149
175
|
// The first-chat handle field above the composer has the keyboard.
|
|
150
176
|
const [handleFieldFocused, setHandleFieldFocusedState] = useState(false);
|
|
151
177
|
// Read by the field's blur, which can come before the render that moved focus on.
|
|
@@ -212,6 +238,10 @@ function ChatConversation({
|
|
|
212
238
|
() => controller.attachmentsSupported(),
|
|
213
239
|
);
|
|
214
240
|
const [dropActive, setDropActive] = useState(false);
|
|
241
|
+
const resetComposerSession = useCallback(() => {
|
|
242
|
+
closeNewDmDialog();
|
|
243
|
+
setDropActive(false);
|
|
244
|
+
}, [closeNewDmDialog]);
|
|
215
245
|
const attachPickerRef = useRef<(() => void) | null>(null);
|
|
216
246
|
const replaceComposerDraftRef = useRef<((draft: string, cursorOffset?: number) => void) | null>(null);
|
|
217
247
|
const {
|
|
@@ -219,6 +249,7 @@ function ChatConversation({
|
|
|
219
249
|
channelsLoading,
|
|
220
250
|
channelStates,
|
|
221
251
|
conversationActivity,
|
|
252
|
+
composerScope,
|
|
222
253
|
draftAttachments,
|
|
223
254
|
hasOlderMessages,
|
|
224
255
|
loading,
|
|
@@ -235,10 +266,13 @@ function ChatConversation({
|
|
|
235
266
|
controller,
|
|
236
267
|
// A channel hidden behind the list is not being read.
|
|
237
268
|
focused: focused && !channelListOpen,
|
|
269
|
+
editingMessageRef,
|
|
238
270
|
initialSnapshot,
|
|
239
271
|
inputRef,
|
|
240
272
|
inputValueRef,
|
|
241
273
|
onComposerStateChange: syncComposerState,
|
|
274
|
+
onComposerScopeChange: resetComposerSession,
|
|
275
|
+
setEditingMessage,
|
|
242
276
|
draftLinksRef,
|
|
243
277
|
onDraftLinksChange: setDraftLinks,
|
|
244
278
|
prependAnchorRef,
|
|
@@ -271,7 +305,21 @@ function ChatConversation({
|
|
|
271
305
|
if (!stackedNav) setChannelListOpen(false);
|
|
272
306
|
}, [stackedNav]);
|
|
273
307
|
composerTextWidthRef.current = composerTextWidth;
|
|
274
|
-
const canSend = !!user?.emailVerified;
|
|
308
|
+
const canSend = !!user?.emailVerified && composerScope !== null;
|
|
309
|
+
const isComposerCurrent = useCallback(() => composerScope !== null && controller.getComposerScope() === composerScope, [composerScope, controller]);
|
|
310
|
+
const activeNewDmDialog = focused && canSend && newDmDialogSession?.scope === composerScope ? newDmDialogSession : null;
|
|
311
|
+
const newDmOpen = activeNewDmDialog !== null;
|
|
312
|
+
useLayoutEffect(() => {
|
|
313
|
+
if (!activeNewDmDialog) closeNewDmDialog(newDmDialogSession);
|
|
314
|
+
}, [activeNewDmDialog, closeNewDmDialog, newDmDialogSession]);
|
|
315
|
+
const isActiveNewDmDialogCurrent = useCallback(() => (
|
|
316
|
+
activeNewDmDialog !== null && newDmDialogRef.current === activeNewDmDialog
|
|
317
|
+
&& controller.getComposerScope() === activeNewDmDialog.scope
|
|
318
|
+
), [activeNewDmDialog, controller]);
|
|
319
|
+
const previewScope = useMemo(() => ({
|
|
320
|
+
isCurrent: isComposerCurrent,
|
|
321
|
+
subscribe: (onChange: () => void) => controller.subscribe(channelId, onChange),
|
|
322
|
+
}), [channelId, controller, isComposerCurrent]);
|
|
275
323
|
// Images go only to a server that said it takes them, and never into an edit.
|
|
276
324
|
const imagesAvailable = canSend && attachmentsSupported;
|
|
277
325
|
const canAttach = imagesAvailable && !editingMessage;
|
|
@@ -495,7 +543,6 @@ function ChatConversation({
|
|
|
495
543
|
useEffect(() => {
|
|
496
544
|
if (previousEditingChannelIdRef.current === channelId) return;
|
|
497
545
|
previousEditingChannelIdRef.current = channelId;
|
|
498
|
-
setEditingMessage(null);
|
|
499
546
|
setReactionPickerMessageId(null);
|
|
500
547
|
// A card pinned in one channel does not follow into the next.
|
|
501
548
|
closeProfilePopover();
|
|
@@ -559,26 +606,27 @@ function ChatConversation({
|
|
|
559
606
|
});
|
|
560
607
|
|
|
561
608
|
const focusInput = useCallback(() => {
|
|
562
|
-
|
|
609
|
+
closeNewDmDialog();
|
|
563
610
|
setSidebarFocused(false);
|
|
564
611
|
setHandleFieldFocused(false);
|
|
565
612
|
setInputFocused(true);
|
|
566
613
|
dispatch({ type: "SET_INPUT_CAPTURED", captured: true });
|
|
567
614
|
inputRef.current?.focus?.();
|
|
568
|
-
}, [dispatch, setHandleFieldFocused, setSidebarFocused]);
|
|
569
|
-
|
|
570
|
-
const closeNewDmDialog = useCallback(() => {
|
|
571
|
-
setNewDmOpen(false);
|
|
572
|
-
dispatch({ type: "SET_INPUT_CAPTURED", captured: false });
|
|
573
|
-
}, [dispatch]);
|
|
615
|
+
}, [closeNewDmDialog, dispatch, setHandleFieldFocused, setSidebarFocused]);
|
|
574
616
|
|
|
575
617
|
const openNewDmDialog = useCallback(() => {
|
|
576
|
-
|
|
618
|
+
if (!canSend || !composerScope || !isComposerCurrent() || newDmDialogRef.current) return;
|
|
619
|
+
if (inputFocused || handleFieldFocusedRef.current) {
|
|
620
|
+
setHandleFieldFocused(false);
|
|
621
|
+
blurInput();
|
|
622
|
+
}
|
|
577
623
|
closeProfilePopover();
|
|
578
624
|
setSidebarFocused(false);
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
625
|
+
const dialog = { id: ++nextNewDmDialogIdRef.current, scope: composerScope };
|
|
626
|
+
newDmDialogRef.current = dialog;
|
|
627
|
+
dispatch({ type: "SET_INPUT_CAPTURED", captured: true, owner: dialog });
|
|
628
|
+
if (newDmDialogRef.current === dialog) setNewDmDialogSession(dialog);
|
|
629
|
+
}, [blurInput, canSend, closeProfilePopover, composerScope, dispatch, inputFocused, isComposerCurrent, setHandleFieldFocused, setSidebarFocused]);
|
|
582
630
|
|
|
583
631
|
const openChannelList = useCallback(() => {
|
|
584
632
|
blurInput();
|
|
@@ -614,19 +662,14 @@ function ChatConversation({
|
|
|
614
662
|
return true;
|
|
615
663
|
}, [channelListOpen, focusChannelSidebar, openChannelList, stackedNav]);
|
|
616
664
|
|
|
617
|
-
useEffect(() => {
|
|
618
|
-
if (!focused && newDmOpen) {
|
|
619
|
-
closeNewDmDialog();
|
|
620
|
-
}
|
|
621
|
-
}, [closeNewDmDialog, focused, newDmOpen]);
|
|
622
|
-
|
|
623
665
|
const attachFiles = useCallback((files: TransferFile[]) => {
|
|
666
|
+
if (!isComposerCurrent()) return;
|
|
624
667
|
if (!canAttach) {
|
|
625
668
|
if (imagesAvailable) notify({ body: "Images can't be added to an edit.", type: "info" });
|
|
626
669
|
return;
|
|
627
670
|
}
|
|
628
671
|
if (controller.attachToChannel(channelIdRef.current, files.map(uploadFromTransferFile)) > 0) focusInput();
|
|
629
|
-
}, [canAttach, controller, focusInput, imagesAvailable, notify]);
|
|
672
|
+
}, [canAttach, controller, focusInput, imagesAvailable, isComposerCurrent, notify]);
|
|
630
673
|
|
|
631
674
|
// A chip: the shared pane, the story or calendar a Wire post names, or a function written in a message.
|
|
632
675
|
const openPaneLink = useCallback((link: ChatMessagePaneLink) => {
|
|
@@ -645,15 +688,16 @@ function ChatConversation({
|
|
|
645
688
|
// The terminal: a pasted or dropped path to an image file attaches the file
|
|
646
689
|
// and leaves the composer. A path that is no file stays as typed.
|
|
647
690
|
const handlePastedImagePaths = useCallback((paths: string[], pasted: string) => {
|
|
691
|
+
if (!isComposerCurrent()) return;
|
|
648
692
|
const targetChannelId = channelIdRef.current;
|
|
649
693
|
void readChatImageFiles(paths).then((uploads) => {
|
|
650
|
-
if (uploads.length === 0 || channelIdRef.current !== targetChannelId) return;
|
|
694
|
+
if (!isComposerCurrent() || uploads.length === 0 || channelIdRef.current !== targetChannelId) return;
|
|
651
695
|
const draft = inputValueRef.current;
|
|
652
696
|
const at = draft.indexOf(pasted);
|
|
653
697
|
if (at >= 0) replaceComposerDraftRef.current?.(`${draft.slice(0, at)}${draft.slice(at + pasted.length)}`, at);
|
|
654
698
|
controller.attachToChannel(targetChannelId, uploads);
|
|
655
699
|
}).catch(() => {});
|
|
656
|
-
}, [controller]);
|
|
700
|
+
}, [controller, isComposerCurrent]);
|
|
657
701
|
|
|
658
702
|
const reportConversationStartError = useCallback((error: unknown, usernames: string[]) => {
|
|
659
703
|
notify({ body: describeConversationStartError(error, usernames, userByUsername), type: "error" });
|
|
@@ -709,10 +753,12 @@ function ChatConversation({
|
|
|
709
753
|
inputFocused,
|
|
710
754
|
inputRef,
|
|
711
755
|
inputValueRef,
|
|
756
|
+
isComposerCurrent,
|
|
712
757
|
messages,
|
|
713
758
|
onComposerStateChange: syncComposerState,
|
|
714
759
|
onChannelChange,
|
|
715
760
|
editingMessage,
|
|
761
|
+
editingMessageRef,
|
|
716
762
|
latestEditableMessageId,
|
|
717
763
|
replyTo,
|
|
718
764
|
setEditingMessage,
|
|
@@ -808,11 +854,17 @@ function ChatConversation({
|
|
|
808
854
|
else showConversation(channelId);
|
|
809
855
|
}, [canSend, channelId, commandBarOpen, focused, openNewDmDialog, pendingPaneRequest, showConversation]);
|
|
810
856
|
|
|
811
|
-
const
|
|
857
|
+
const captureConversationScope = useCallback(() => {
|
|
858
|
+
const isSessionCurrent = controller.captureSessionScope();
|
|
859
|
+
return () => isComposerCurrent() && isSessionCurrent();
|
|
860
|
+
}, [controller, isComposerCurrent]);
|
|
861
|
+
|
|
862
|
+
const openConversationFromDialog = useCallback(async (usernames: string[], isCurrent: () => boolean) => {
|
|
863
|
+
if (!isCurrent()) return;
|
|
812
864
|
const channel = usernames.length === 1
|
|
813
|
-
? await controller.openDirectChannel({ username: usernames[0] })
|
|
814
|
-
: await controller.openGroupChannel({ usernames });
|
|
815
|
-
showConversation(channel.id);
|
|
865
|
+
? await controller.openDirectChannel({ username: usernames[0] }, isCurrent)
|
|
866
|
+
: await controller.openGroupChannel({ usernames }, isCurrent);
|
|
867
|
+
if (channel && isCurrent()) showConversation(channel.id);
|
|
816
868
|
}, [controller, showConversation]);
|
|
817
869
|
|
|
818
870
|
const directMessageContext = useMemo(
|
|
@@ -822,6 +874,8 @@ function ChatConversation({
|
|
|
822
874
|
|
|
823
875
|
/** "Message @name": opens the DM you share, or starts one and opens it. */
|
|
824
876
|
const messageUser = useCallback(async (target: ChatUserSummary) => {
|
|
877
|
+
const isCurrent = captureConversationScope();
|
|
878
|
+
if (!isCurrent()) return;
|
|
825
879
|
const action = directMessageAction(target, directMessageContext);
|
|
826
880
|
if (!action || action.kind === "refused") return;
|
|
827
881
|
const existing = action.kind === "open" ? findDirectChannelWith(channels, target) : null;
|
|
@@ -831,11 +885,12 @@ function ChatConversation({
|
|
|
831
885
|
}
|
|
832
886
|
try {
|
|
833
887
|
const channel = await controller.openDirectChannel({ username: action.username });
|
|
834
|
-
showConversation(channel.id);
|
|
888
|
+
if (channel && isCurrent()) showConversation(channel.id);
|
|
835
889
|
} catch (error) {
|
|
890
|
+
if (!isCurrent()) return;
|
|
836
891
|
notify({ body: describeConversationStartError(error, [action.username], userByUsername), type: "error" });
|
|
837
892
|
}
|
|
838
|
-
}, [channels, controller, directMessageContext, notify, showConversation, userByUsername]);
|
|
893
|
+
}, [captureConversationScope, channels, controller, directMessageContext, notify, showConversation, userByUsername]);
|
|
839
894
|
|
|
840
895
|
const pinUserProfile = useCallback((target: ChatUserSummary, anchor?: ChatUserAnchor) => {
|
|
841
896
|
showProfilePopover(target, { ownProfile: target.id === user?.id, pin: true, anchor });
|
|
@@ -1053,8 +1108,14 @@ function ChatConversation({
|
|
|
1053
1108
|
? sidebarCursorRow.teamId
|
|
1054
1109
|
: null
|
|
1055
1110
|
: null;
|
|
1111
|
+
const composing = inputFocused || newDmOpen || handleFieldFocused;
|
|
1112
|
+
// Enter, + and e act on the selected message only while the chat has the
|
|
1113
|
+
// keys: its pane is focused, and neither the command bar, a dialog, the
|
|
1114
|
+
// reaction picker, a field nor the channel list has taken them.
|
|
1115
|
+
const actionKeysOwned = focused && !composing && !sidebarFocused && !commandBarOpen && !dialogOpen && reactionPickerMessageId === null;
|
|
1056
1116
|
useChatFooter({
|
|
1057
|
-
|
|
1117
|
+
previewScope,
|
|
1118
|
+
composing,
|
|
1058
1119
|
canSend,
|
|
1059
1120
|
selectedIdx,
|
|
1060
1121
|
// While the sidebar has the keys, a message's reply and edit are not on offer.
|
|
@@ -1126,15 +1187,23 @@ function ChatConversation({
|
|
|
1126
1187
|
/>
|
|
1127
1188
|
);
|
|
1128
1189
|
|
|
1129
|
-
const newDmDialog =
|
|
1190
|
+
const newDmDialog = activeNewDmDialog ? (
|
|
1130
1191
|
<NewDmDialog
|
|
1192
|
+
key={activeNewDmDialog.id}
|
|
1131
1193
|
width={stackedNav ? width : chatWidth}
|
|
1132
1194
|
height={height}
|
|
1133
1195
|
userByUsername={userByUsername}
|
|
1134
1196
|
currentUserId={user?.id}
|
|
1135
1197
|
channels={channels}
|
|
1136
|
-
|
|
1137
|
-
|
|
1198
|
+
isDialogCurrent={isActiveNewDmDialogCurrent}
|
|
1199
|
+
captureSessionScope={() => {
|
|
1200
|
+
const isSessionCurrent = captureConversationScope();
|
|
1201
|
+
return () => isActiveNewDmDialogCurrent() && isSessionCurrent();
|
|
1202
|
+
}}
|
|
1203
|
+
onCancel={() => closeNewDmDialog(activeNewDmDialog)}
|
|
1204
|
+
onOpenChannel={(nextChannelId) => {
|
|
1205
|
+
if (isActiveNewDmDialogCurrent()) showConversation(nextChannelId);
|
|
1206
|
+
}}
|
|
1138
1207
|
onSubmit={openConversationFromDialog}
|
|
1139
1208
|
/>
|
|
1140
1209
|
) : null;
|
|
@@ -1181,6 +1250,7 @@ function ChatConversation({
|
|
|
1181
1250
|
onRetryMessages={retryMessages}
|
|
1182
1251
|
retryMessage={retryMessage}
|
|
1183
1252
|
onImageLoadError={refreshImageLinks}
|
|
1253
|
+
previewScope={previewScope}
|
|
1184
1254
|
messageAreaHeight={messageAreaHeight}
|
|
1185
1255
|
messageBodyWidth={messageBodyWidth}
|
|
1186
1256
|
messages={messages}
|
|
@@ -1196,6 +1266,8 @@ function ChatConversation({
|
|
|
1196
1266
|
scheduleProfilePopoverClose={scheduleProfilePopoverClose}
|
|
1197
1267
|
scrollRef={scrollRef}
|
|
1198
1268
|
selectedIdx={selectedIdx}
|
|
1269
|
+
// The keys that press a message's actions act on the selected one, and only while the chat has them.
|
|
1270
|
+
actionKeysIdx={actionKeysOwned ? selectedIdx : -1}
|
|
1199
1271
|
setHoveredIdx={setHoveredIdx}
|
|
1200
1272
|
showProfilePopover={hoverUserProfile}
|
|
1201
1273
|
toggleProfilePopover={toggleUserProfile}
|
|
@@ -1271,7 +1343,7 @@ function ChatConversation({
|
|
|
1271
1343
|
onRemoveAttachment={removeDraftAttachment}
|
|
1272
1344
|
onRetryAttachment={retryDraftAttachment}
|
|
1273
1345
|
draftLinks={draftLinks}
|
|
1274
|
-
onOpenDraftLink={openPaneLink}
|
|
1346
|
+
onOpenDraftLink={(link) => { if (isComposerCurrent()) openPaneLink(link); }}
|
|
1275
1347
|
onRemoveDraftLink={removeDraftLink}
|
|
1276
1348
|
attachPickerRef={attachPickerRef}
|
|
1277
1349
|
/>
|
|
@@ -116,6 +116,8 @@ export function NewDmDialog({
|
|
|
116
116
|
onCancel,
|
|
117
117
|
onOpenChannel,
|
|
118
118
|
onSubmit,
|
|
119
|
+
isDialogCurrent,
|
|
120
|
+
captureSessionScope,
|
|
119
121
|
}: {
|
|
120
122
|
width: number;
|
|
121
123
|
height: number;
|
|
@@ -125,7 +127,9 @@ export function NewDmDialog({
|
|
|
125
127
|
channels: readonly ChatChannel[];
|
|
126
128
|
onCancel: () => void;
|
|
127
129
|
onOpenChannel: (channelId: string) => void;
|
|
128
|
-
onSubmit: (usernames: string[]) => Promise<void>;
|
|
130
|
+
onSubmit: (usernames: string[], isCurrent: () => boolean) => Promise<void>;
|
|
131
|
+
isDialogCurrent: () => boolean;
|
|
132
|
+
captureSessionScope: () => () => boolean;
|
|
129
133
|
}) {
|
|
130
134
|
const { nativePaneChrome } = useUiCapabilities();
|
|
131
135
|
const inputRef = useRef<InputRenderable | null>(null);
|
|
@@ -170,8 +174,8 @@ export function NewDmDialog({
|
|
|
170
174
|
const canSubmit = hasOnlyDmUsernameArgs(value) && selectedUsernames.length > 0 && !submitting && !knownRefusal;
|
|
171
175
|
|
|
172
176
|
useEffect(() => {
|
|
173
|
-
inputRef.current?.focus?.();
|
|
174
|
-
}, []);
|
|
177
|
+
if (isDialogCurrent()) inputRef.current?.focus?.();
|
|
178
|
+
}, [isDialogCurrent]);
|
|
175
179
|
|
|
176
180
|
// The cursor never rests on a user who cannot be picked.
|
|
177
181
|
useEffect(() => {
|
|
@@ -190,13 +194,18 @@ export function NewDmDialog({
|
|
|
190
194
|
};
|
|
191
195
|
|
|
192
196
|
const toggleCandidate = (username: string) => {
|
|
197
|
+
if (!isDialogCurrent()) return;
|
|
193
198
|
updateValue(setUsernameSelected(valueRef.current, username, !parseDmUsernames(valueRef.current).includes(username)));
|
|
194
199
|
setError(null);
|
|
195
|
-
queueMicrotask(() =>
|
|
200
|
+
queueMicrotask(() => {
|
|
201
|
+
if (isDialogCurrent()) inputRef.current?.focus?.();
|
|
202
|
+
});
|
|
196
203
|
};
|
|
197
204
|
|
|
198
205
|
const submit = async () => {
|
|
199
206
|
if (submittingRef.current) return;
|
|
207
|
+
const isCurrent = captureSessionScope();
|
|
208
|
+
if (!isCurrent()) return;
|
|
200
209
|
let submittedValue = valueRef.current;
|
|
201
210
|
// Nothing typed yet: Enter starts with the highlighted user, as Tab would
|
|
202
211
|
// have picked them.
|
|
@@ -226,17 +235,20 @@ export function NewDmDialog({
|
|
|
226
235
|
setSubmitting(true);
|
|
227
236
|
setError(null);
|
|
228
237
|
try {
|
|
229
|
-
await onSubmit(submittedUsernames);
|
|
238
|
+
await onSubmit(submittedUsernames, isCurrent);
|
|
230
239
|
} catch (submitError) {
|
|
231
|
-
setError(describeConversationStartError(submitError, submittedUsernames, userByUsername));
|
|
232
|
-
setSubmitting(false);
|
|
240
|
+
if (isCurrent()) setError(describeConversationStartError(submitError, submittedUsernames, userByUsername));
|
|
233
241
|
} finally {
|
|
234
|
-
|
|
242
|
+
if (isDialogCurrent()) {
|
|
243
|
+
submittingRef.current = false;
|
|
244
|
+
setSubmitting(false);
|
|
245
|
+
}
|
|
235
246
|
}
|
|
236
247
|
};
|
|
237
248
|
|
|
238
249
|
const bindings = useKeybindings();
|
|
239
250
|
useShortcut((event) => {
|
|
251
|
+
if (!isDialogCurrent()) return;
|
|
240
252
|
if (event.name === "escape") {
|
|
241
253
|
event.preventDefault?.();
|
|
242
254
|
event.stopPropagation?.();
|
|
@@ -289,6 +301,7 @@ export function NewDmDialog({
|
|
|
289
301
|
width={nativePaneChrome ? undefined : contentWidth}
|
|
290
302
|
backgroundColor={colors.panel}
|
|
291
303
|
onChange={(nextValue) => {
|
|
304
|
+
if (!isDialogCurrent()) return;
|
|
292
305
|
updateValue(nextValue);
|
|
293
306
|
setError(null);
|
|
294
307
|
}}
|
|
@@ -5,6 +5,21 @@ interface MutableRef<T> {
|
|
|
5
5
|
current: T;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Desktop: a control in the message list that has the page's focus gives it
|
|
10
|
+
* up. Shift-Tab from the composer puts the focus on a message's icon, where
|
|
11
|
+
* Enter presses that icon. Once a row key moves the list's cursor, Enter is
|
|
12
|
+
* the Reply of the row the cursor is on, as that row's icons say, and must not
|
|
13
|
+
* press a control left focused on another row. The terminal has no page, and
|
|
14
|
+
* nothing to let go of.
|
|
15
|
+
*/
|
|
16
|
+
export function releaseTranscriptFocus(): void {
|
|
17
|
+
const active = (globalThis as {
|
|
18
|
+
document?: { activeElement?: { closest?: (selector: string) => unknown; blur?: () => void } | null };
|
|
19
|
+
}).document?.activeElement;
|
|
20
|
+
if (active?.closest?.('[data-gloom-role="chat-transcript"]')) active.blur?.();
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
export function useChatMessageSelection({
|
|
9
24
|
inputRef,
|
|
10
25
|
messageCount,
|
|
@@ -38,6 +53,7 @@ export function useChatMessageSelection({
|
|
|
38
53
|
|
|
39
54
|
setSelectedIdx(next);
|
|
40
55
|
setFollowMessages(next === messageCount - 1);
|
|
56
|
+
releaseTranscriptFocus();
|
|
41
57
|
return true;
|
|
42
58
|
}, [messageCount, selectedIdx, setFollowMessages, setSelectedIdx]);
|
|
43
59
|
|
|
@@ -6,6 +6,7 @@ import { countEscapeTowardClose, keepEscapeFromClosing } from "../../../../utils
|
|
|
6
6
|
import { isPlainKey } from "../../../../utils/keyboard";
|
|
7
7
|
import { createOneShot } from "../../../../utils/one-shot";
|
|
8
8
|
import { scrollToBottom } from "../layout";
|
|
9
|
+
import { releaseTranscriptFocus } from "./selection-runtime";
|
|
9
10
|
import type { ChatSidebarRow } from "../sidebar-rows";
|
|
10
11
|
import type { ComposerShareLink } from "../pane-links/composer";
|
|
11
12
|
|
|
@@ -331,6 +332,7 @@ export function useChatContentShortcuts({
|
|
|
331
332
|
event.stopPropagation?.();
|
|
332
333
|
setSelectedIdx(0);
|
|
333
334
|
setFollowMessages(false);
|
|
335
|
+
releaseTranscriptFocus();
|
|
334
336
|
scrollRef.current?.scrollTo(0);
|
|
335
337
|
queueMicrotask(() => requestOlderMessagesIfNeeded({ firstIsSelected: true }));
|
|
336
338
|
return;
|
|
@@ -340,6 +342,7 @@ export function useChatContentShortcuts({
|
|
|
340
342
|
event.stopPropagation?.();
|
|
341
343
|
setSelectedIdx(messages.length - 1);
|
|
342
344
|
setFollowMessages(true);
|
|
345
|
+
releaseTranscriptFocus();
|
|
343
346
|
queueMicrotask(() => scrollToBottom(scrollRef.current, nativePaneChrome));
|
|
344
347
|
}
|
|
345
348
|
}, { allowEditable: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
|
|
1
|
+
import { useEffect, useRef, useState, type Dispatch, type SetStateAction } from "react";
|
|
2
2
|
import type { TextareaRenderable } from "../../../../ui";
|
|
3
3
|
import type { ChatMessage } from "../../../../api-client";
|
|
4
4
|
import type { ChatContentController } from "./types";
|
|
@@ -15,11 +15,14 @@ interface ChatSnapshotStateArgs {
|
|
|
15
15
|
applyingExternalDraftRef: MutableRef<boolean>;
|
|
16
16
|
channelId: string;
|
|
17
17
|
controller: ChatContentController;
|
|
18
|
+
editingMessageRef: MutableRef<ChatMessage | null>;
|
|
18
19
|
focused: boolean;
|
|
19
20
|
initialSnapshot: ChatSnapshot;
|
|
20
21
|
inputRef: MutableRef<TextareaRenderable | null>;
|
|
21
22
|
inputValueRef: MutableRef<string>;
|
|
22
23
|
onComposerStateChange?: (draft: string, cursorOffset: number) => void;
|
|
24
|
+
onComposerScopeChange: () => void;
|
|
25
|
+
setEditingMessage: (message: ChatMessage | null) => void;
|
|
23
26
|
/** The share links at the end of the saved draft, drawn as chips above the field. */
|
|
24
27
|
draftLinksRef: MutableRef<ComposerShareLink[]>;
|
|
25
28
|
/** Sets the chips; also updates `draftLinksRef`. */
|
|
@@ -81,11 +84,14 @@ export function useChatSnapshotState({
|
|
|
81
84
|
applyingExternalDraftRef,
|
|
82
85
|
channelId,
|
|
83
86
|
controller,
|
|
87
|
+
editingMessageRef,
|
|
84
88
|
focused,
|
|
85
89
|
initialSnapshot,
|
|
86
90
|
inputRef,
|
|
87
91
|
inputValueRef,
|
|
88
92
|
onComposerStateChange,
|
|
93
|
+
onComposerScopeChange,
|
|
94
|
+
setEditingMessage,
|
|
89
95
|
draftLinksRef,
|
|
90
96
|
onDraftLinksChange,
|
|
91
97
|
prependAnchorRef,
|
|
@@ -110,6 +116,8 @@ export function useChatSnapshotState({
|
|
|
110
116
|
const [hasOlderMessages, setHasOlderMessages] = useState(initialSnapshot.hasOlderMessages);
|
|
111
117
|
const [replyTo, setReplyTo] = useState<ChatMessage | null>(() => resolveReplyTo(initialSnapshot));
|
|
112
118
|
const [draftAttachments, setDraftAttachments] = useState(initialSnapshot.draftAttachments);
|
|
119
|
+
const [composerScope, setComposerScope] = useState(initialSnapshot.composerScope);
|
|
120
|
+
const composerScopeRef = useRef(initialSnapshot.composerScope);
|
|
113
121
|
|
|
114
122
|
useEffect(() => {
|
|
115
123
|
return useDefaultControllerChannel
|
|
@@ -129,6 +137,15 @@ export function useChatSnapshotState({
|
|
|
129
137
|
prependAnchorRef.current = null;
|
|
130
138
|
|
|
131
139
|
const applySnapshot = (snapshot: ChatSnapshot) => {
|
|
140
|
+
const scopeChanged = composerScopeRef.current !== snapshot.composerScope;
|
|
141
|
+
if (scopeChanged) {
|
|
142
|
+
composerScopeRef.current = snapshot.composerScope;
|
|
143
|
+
onComposerScopeChange();
|
|
144
|
+
}
|
|
145
|
+
if (editingMessageRef.current && (scopeChanged || !snapshot.user?.emailVerified
|
|
146
|
+
|| editingMessageRef.current.channelId !== snapshot.channelId)) {
|
|
147
|
+
setEditingMessage(null);
|
|
148
|
+
}
|
|
132
149
|
setMessages(snapshot.messages);
|
|
133
150
|
setMentionState((current) => current.channelId === snapshot.channelId && current.candidates === snapshot.mentionCandidates
|
|
134
151
|
? current
|
|
@@ -137,23 +154,26 @@ export function useChatSnapshotState({
|
|
|
137
154
|
setChannelStates(snapshot.channelStates);
|
|
138
155
|
setConversationActivity(snapshot.conversationActivity);
|
|
139
156
|
setChannelsLoading(snapshot.channelsLoading);
|
|
140
|
-
setUser(snapshot.user);
|
|
141
157
|
setLoading(snapshot.loading);
|
|
142
158
|
setMessagesError(snapshot.messagesError);
|
|
143
159
|
setLoadingOlderMessages(snapshot.loadingOlderMessages);
|
|
144
160
|
setHasOlderMessages(snapshot.hasOlderMessages);
|
|
145
161
|
setDraftAttachments(snapshot.draftAttachments);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
if (!editingMessageRef.current) {
|
|
163
|
+
syncDraftFromSnapshot({
|
|
164
|
+
applyingExternalDraftRef,
|
|
165
|
+
draftLinksRef,
|
|
166
|
+
inputRef,
|
|
167
|
+
inputValueRef,
|
|
168
|
+
onComposerStateChange,
|
|
169
|
+
onDraftLinksChange,
|
|
170
|
+
snapshot,
|
|
171
|
+
updateComposerRows,
|
|
172
|
+
});
|
|
173
|
+
setReplyTo(resolveReplyTo(snapshot));
|
|
174
|
+
}
|
|
175
|
+
setComposerScope(snapshot.composerScope);
|
|
176
|
+
setUser(snapshot.user);
|
|
157
177
|
};
|
|
158
178
|
|
|
159
179
|
applySnapshot(controller.getSnapshot(channelId));
|
|
@@ -168,10 +188,13 @@ export function useChatSnapshotState({
|
|
|
168
188
|
applyingExternalDraftRef,
|
|
169
189
|
channelId,
|
|
170
190
|
controller,
|
|
191
|
+
editingMessageRef,
|
|
171
192
|
draftLinksRef,
|
|
172
193
|
inputRef,
|
|
173
194
|
inputValueRef,
|
|
174
195
|
onComposerStateChange,
|
|
196
|
+
onComposerScopeChange,
|
|
197
|
+
setEditingMessage,
|
|
175
198
|
onDraftLinksChange,
|
|
176
199
|
prependAnchorRef,
|
|
177
200
|
setFollowMessages,
|
|
@@ -185,6 +208,7 @@ export function useChatSnapshotState({
|
|
|
185
208
|
channelsLoading,
|
|
186
209
|
channelStates,
|
|
187
210
|
conversationActivity,
|
|
211
|
+
composerScope,
|
|
188
212
|
draftAttachments,
|
|
189
213
|
hasOlderMessages,
|
|
190
214
|
loading,
|
|
@@ -12,6 +12,7 @@ import { UserProfilePopover } from "../message/profile-popover";
|
|
|
12
12
|
import { TerminalChatMessage } from "../message/terminal";
|
|
13
13
|
import { NewMessagesJump } from "./new-messages";
|
|
14
14
|
import { useWholeMessageCopy } from "./whole-message-copy";
|
|
15
|
+
import type { ChatPreviewScope } from "../attachments/desktop";
|
|
15
16
|
|
|
16
17
|
interface MutableRef<T> {
|
|
17
18
|
current: T;
|
|
@@ -37,6 +38,7 @@ interface ChatTranscriptProps {
|
|
|
37
38
|
onRetryMessages: () => void;
|
|
38
39
|
retryMessage: (index: number) => void;
|
|
39
40
|
onImageLoadError: (attachment: ChatAttachment) => void;
|
|
41
|
+
previewScope: ChatPreviewScope;
|
|
40
42
|
messageAreaHeight: number;
|
|
41
43
|
messageBodyWidth: number;
|
|
42
44
|
messages: ChatMessage[];
|
|
@@ -56,6 +58,11 @@ interface ChatTranscriptProps {
|
|
|
56
58
|
scheduleProfilePopoverClose: () => void;
|
|
57
59
|
scrollRef: MutableRef<ScrollBoxRenderable | null>;
|
|
58
60
|
selectedIdx: number;
|
|
61
|
+
/**
|
|
62
|
+
* The selected message while the chat, not the composer or a dialog, has the
|
|
63
|
+
* keys: its actions name the keys that press them. -1 for none.
|
|
64
|
+
*/
|
|
65
|
+
actionKeysIdx: number;
|
|
59
66
|
setHoveredIdx: Dispatch<SetStateAction<number | null>>;
|
|
60
67
|
showProfilePopover: (user: ChatUserSummary, anchor?: ChatUserAnchor) => void;
|
|
61
68
|
/** A click on a name: pins its card, or closes the one it pinned. */
|
|
@@ -104,6 +111,7 @@ export function ChatTranscript({
|
|
|
104
111
|
onRetryMessages,
|
|
105
112
|
retryMessage,
|
|
106
113
|
onImageLoadError,
|
|
114
|
+
previewScope,
|
|
107
115
|
messageAreaHeight,
|
|
108
116
|
messageBodyWidth,
|
|
109
117
|
messages,
|
|
@@ -119,6 +127,7 @@ export function ChatTranscript({
|
|
|
119
127
|
scheduleProfilePopoverClose,
|
|
120
128
|
scrollRef,
|
|
121
129
|
selectedIdx,
|
|
130
|
+
actionKeysIdx,
|
|
122
131
|
setHoveredIdx,
|
|
123
132
|
showProfilePopover,
|
|
124
133
|
toggleProfilePopover,
|
|
@@ -160,6 +169,7 @@ export function ChatTranscript({
|
|
|
160
169
|
selectedIdx={selectedIdx}
|
|
161
170
|
hoveredIdx={hoveredIdx === index ? index : null}
|
|
162
171
|
highlighted={msg.id === highlightedMessageId}
|
|
172
|
+
actionKeysShown={index === actionKeysIdx}
|
|
163
173
|
canSend={canSend}
|
|
164
174
|
contentWidth={desktopChatMessageWidth(msg, contentWidth)}
|
|
165
175
|
catalog={catalog}
|
|
@@ -176,6 +186,7 @@ export function ChatTranscript({
|
|
|
176
186
|
latestEditableMessageId={latestEditableMessageId}
|
|
177
187
|
retryMessage={retryMessage}
|
|
178
188
|
onImageLoadError={onImageLoadError}
|
|
189
|
+
previewScope={msg.clientStatus ? previewScope : undefined}
|
|
179
190
|
registerMessageElement={registerMessageElement}
|
|
180
191
|
{...reactionProps}
|
|
181
192
|
reactionPickerMessageId={reactionPickerMessageId}
|
|
@@ -245,6 +256,7 @@ export function ChatTranscript({
|
|
|
245
256
|
selectedIdx={selectedIdx}
|
|
246
257
|
hoveredIdx={hoveredIdx === index ? index : null}
|
|
247
258
|
highlighted={msg.id === highlightedMessageId}
|
|
259
|
+
actionKeysShown={index === actionKeysIdx}
|
|
248
260
|
canSend={canSend}
|
|
249
261
|
contentWidth={contentWidth}
|
|
250
262
|
messageBodyWidth={messageBodyWidth}
|