Skip to content

Commit 7de5517

Browse files
tlongwell-blocknpub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dnpub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta
authored
fix(desktop): constrain message timeline width with min-w-0 (#1092)
Signed-off-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>
1 parent 22b47db commit 7de5517

6 files changed

Lines changed: 156 additions & 7 deletions

File tree

‎desktop/src/features/channels/ui/ChannelScreen.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export function ChannelScreen({
9595
setTopbarSearchHidden,
9696
} = useAppShell();
9797
const {
98+
clearMessageRouteTarget,
9899
openAgentSessionPubkey,
99100
openThreadHeadId,
100101
profilePanelPubkey,
@@ -495,6 +496,9 @@ export function ChannelScreen({
495496
const handleThreadScrollTargetResolved = React.useCallback(() => {
496497
setThreadScrollTargetId(null);
497498
}, []);
499+
const handleTargetReached = React.useCallback(() => {
500+
clearMessageRouteTarget({ replace: true });
501+
}, [clearMessageRouteTarget]);
498502
React.useEffect(() => {
499503
resetComposerTargets(activeChannelId);
500504
}, [activeChannelId, resetComposerTargets]);
@@ -695,6 +699,7 @@ export function ChannelScreen({
695699
handleThreadScrollTargetResolved
696700
}
697701
onThreadPanelResizeStart={handleThreadPanelResizeStart}
702+
onTargetReached={handleTargetReached}
698703
onToggleReaction={effectiveToggleReaction}
699704
openAgentSessionPubkey={openAgentSessionPubkey}
700705
openThreadHeadId={openThreadHeadId}

‎desktop/src/features/channels/ui/useChannelPanelHistoryState.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ export type PanelValueSetter = (
2323
options?: PanelSetterOptions,
2424
) => void;
2525

26-
const PANEL_SEARCH_KEYS = [
26+
const CHANNEL_SEARCH_KEYS = [
2727
"agentSession",
28+
"messageId",
2829
"profile",
2930
"profileView",
3031
"thread",
32+
"threadRootId",
3133
] as const;
3234

3335
function asProfilePanelView(value: string | null): ProfilePanelView {
3436
return value === "memories" || value === "channels" ? value : "summary";
3537
}
3638

3739
export function useChannelPanelHistoryState() {
38-
const { applyPatch, values } = useHistorySearchState(PANEL_SEARCH_KEYS);
40+
const { applyPatch, values } = useHistorySearchState(CHANNEL_SEARCH_KEYS);
3941

4042
const setOpenThreadHeadId = React.useCallback<PanelValueSetter>(
4143
(value, options) => applyPatch({ thread: value }, options),
@@ -61,7 +63,14 @@ export function useChannelPanelHistoryState() {
6163
[applyPatch],
6264
);
6365

66+
const clearMessageRouteTarget = React.useCallback(
67+
(options?: PanelSetterOptions) =>
68+
applyPatch({ messageId: null, threadRootId: null }, options),
69+
[applyPatch],
70+
);
71+
6472
return {
73+
clearMessageRouteTarget,
6574
openAgentSessionPubkey: values.agentSession,
6675
openThreadHeadId: values.thread,
6776
profilePanelPubkey: values.profile,

‎desktop/src/features/channels/ui/useChannelRouteTarget.ts‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,27 @@ export function useChannelRouteTarget({
110110
}
111111

112112
const targetMessage = timelineMessageById.get(targetMessageId) ?? null;
113-
if (
114-
!targetMessage?.parentId ||
115-
isBroadcastReply(targetMessage.tags ?? [])
116-
) {
113+
if (!targetMessage) {
114+
return;
115+
}
116+
117+
if (!targetMessage.parentId) {
118+
closeAgentSession();
119+
// Root message links should open the reply panel for that root. The
120+
// timeline scroll/highlight target alone is not enough: root links have
121+
// no parent/thread metadata, so the reply-only branch below cannot infer
122+
// a thread head.
123+
setProfilePanelPubkey(null, { replace: true });
124+
setEditTargetId(null);
125+
setOpenThreadHeadId(targetMessage.id, { replace: true });
126+
setThreadReplyTargetId(targetMessage.id);
127+
setThreadScrollTargetId(null);
128+
setExpandedThreadReplyIds(new Set());
129+
handledThreadRouteTargetRef.current = targetKey;
130+
return;
131+
}
132+
133+
if (isBroadcastReply(targetMessage.tags ?? [])) {
117134
return;
118135
}
119136

‎desktop/src/features/messages/ui/MessageTimeline.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export const MessageTimeline = React.memo(function MessageTimeline({
324324
showMessageList && !showIntro && "mt-auto",
325325
)}
326326
contentClassName={cn(
327-
"flex flex-col gap-2",
327+
"flex min-w-0 flex-col gap-2",
328328
(showIntro || showGenericEmpty) && "min-h-full",
329329
)}
330330
loading={isLoading}

‎desktop/tests/e2e/messaging.spec.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,3 +1046,50 @@ test("ArrowUp edits your last thread reply right after sending it", async ({
10461046
await expect(editBanner).toContainText(reply);
10471047
await expect(threadInput).toHaveText(reply);
10481048
});
1049+
1050+
test("action bar stays within the timeline when the thread panel is open", async ({
1051+
page,
1052+
}) => {
1053+
// Narrow viewport + open thread panel => the timeline shrinks to a column.
1054+
// A long unbreakable token must not widen message rows past that column,
1055+
// or the right-anchored action bar is pushed offscreen (regression: #1081
1056+
// fixed the wrap but rows still expanded to content min-width).
1057+
await page.setViewportSize({ width: 1024, height: 800 });
1058+
await page.goto("/");
1059+
await page.getByTestId("channel-general").click();
1060+
await expect(page.getByTestId("chat-title")).toHaveText("general");
1061+
1062+
const timeline = page.getByTestId("message-timeline");
1063+
const input = page.getByTestId("message-input").first();
1064+
const send = page.getByTestId("send-message").first();
1065+
1066+
const longUrl = `https://example.com/${"a".repeat(180)}/path`;
1067+
await input.fill(longUrl);
1068+
await send.click();
1069+
await expect(timeline).toContainText("example.com");
1070+
1071+
const rootMessage = timeline.getByTestId("message-row").first();
1072+
await rootMessage.hover();
1073+
await rootMessage.getByRole("button", { name: "Reply" }).click();
1074+
await expect(page.getByTestId("message-thread-panel")).toBeVisible();
1075+
1076+
const wideRow = timeline.getByTestId("message-row").last();
1077+
await wideRow.scrollIntoViewIfNeeded();
1078+
await wideRow.hover();
1079+
const bar = wideRow.locator('[data-testid^="message-action-bar-"]');
1080+
await expect(bar).toBeVisible();
1081+
1082+
const timelineBox = await timeline.boundingBox();
1083+
const rowBox = await wideRow.boundingBox();
1084+
const barBox = await bar.boundingBox();
1085+
if (!timelineBox || !rowBox || !barBox) {
1086+
throw new Error("Expected timeline, row, and action bar to have geometry.");
1087+
}
1088+
1089+
expect(rowBox.x + rowBox.width).toBeLessThanOrEqual(
1090+
timelineBox.x + timelineBox.width + 1,
1091+
);
1092+
expect(barBox.x + barBox.width).toBeLessThanOrEqual(
1093+
timelineBox.x + timelineBox.width + 1,
1094+
);
1095+
});

‎desktop/tests/e2e/navigation.spec.ts‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,77 @@ test("settings is a route: section survives reload, closing returns to the previ
266266
await expect(threadPanel).toBeVisible();
267267
});
268268

269+
test("message links to visible root messages open the thread panel", async ({
270+
page,
271+
}) => {
272+
await page.goto("/");
273+
await page.getByTestId("channel-general").click();
274+
await expect(page.getByTestId("chat-title")).toHaveText("general");
275+
await expect(page.getByTestId("message-timeline")).toContainText(
276+
"Welcome to #general",
277+
);
278+
279+
const link =
280+
"buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome";
281+
await page.getByTestId("message-input").fill(`Root link repro ${link}`);
282+
await page.getByTestId("send-message").click();
283+
284+
const linkMessage = page
285+
.getByTestId("message-row")
286+
.filter({ hasText: "Root link repro" })
287+
.last();
288+
await expect(linkMessage).toBeVisible();
289+
await linkMessage
290+
.getByRole("button", { name: "Open message in general" })
291+
.click();
292+
293+
const threadPanel = page.getByTestId("message-thread-panel");
294+
await expect(threadPanel).toBeVisible();
295+
await expect(page).toHaveURL(/thread=mock-general-welcome/);
296+
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
297+
"Welcome to #general",
298+
);
299+
});
300+
301+
test("message links reopen a closed thread when the same messageId is already in the URL", async ({
302+
page,
303+
}) => {
304+
await page.goto(
305+
"/#/channels/9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50?messageId=mock-general-welcome",
306+
);
307+
await expect(page.getByTestId("chat-title")).toHaveText("general");
308+
309+
const threadPanel = page.getByTestId("message-thread-panel");
310+
await expect(threadPanel).toBeVisible();
311+
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
312+
"Welcome to #general",
313+
);
314+
315+
await threadPanel.getByRole("button", { name: "Close thread" }).click();
316+
await expect(threadPanel).not.toBeVisible();
317+
318+
const link =
319+
"buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome";
320+
await page
321+
.getByTestId("message-input")
322+
.fill(`Reopen same root link repro ${link}`);
323+
await page.getByTestId("send-message").click();
324+
325+
const linkMessage = page
326+
.getByTestId("message-row")
327+
.filter({ hasText: "Reopen same root link repro" })
328+
.last();
329+
await expect(linkMessage).toBeVisible();
330+
await linkMessage
331+
.getByRole("button", { name: "Open message in general" })
332+
.click();
333+
334+
await expect(threadPanel).toBeVisible();
335+
await expect(threadPanel.getByTestId("message-thread-head")).toContainText(
336+
"Welcome to #general",
337+
);
338+
});
339+
269340
test("message deep links survive reload", async ({ page }) => {
270341
await page.goto(
271342
`/#/channels/${ENGINEERING_CHANNEL_ID}?messageId=mock-engineering-shipped`,

0 commit comments

Comments
 (0)