Skip to content

Commit aca40b6

Browse files
authored
Polish thread reply hover states (#1329)
1 parent f00c86e commit aca40b6

11 files changed

Lines changed: 100 additions & 67 deletions

‎desktop/src/features/home/ui/InboxListPane.tsx‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,22 @@ export function InboxListPane({
169169
>
170170
<button
171171
className={cn(
172-
"relative block w-full border-l px-3 py-4 text-left transition-colors after:pointer-events-none after:absolute after:bottom-0 after:left-[3.625rem] after:right-0 after:h-px after:bg-border/45 after:content-['']",
173-
isSelected
174-
? "border-l-transparent bg-[var(--inbox-row-highlight-bg)]"
175-
: "border-l-transparent group-hover/inbox-item:bg-[var(--inbox-row-highlight-bg)] group-focus-within/inbox-item:bg-[var(--inbox-row-highlight-bg)] active:bg-muted/40",
172+
"relative block w-full border-l border-l-transparent px-3 py-4 text-left after:pointer-events-none after:absolute after:bottom-0 after:left-[3.625rem] after:right-3 after:h-px after:bg-border/45 after:content-['']",
176173
index === items.length - 1 && "after:hidden",
177174
)}
178175
onClick={() => onSelect(item.id)}
179176
type="button"
180177
>
181-
<div className="flex min-w-0 items-start gap-2.5">
178+
<span
179+
aria-hidden="true"
180+
className={cn(
181+
"pointer-events-none absolute inset-y-0 left-0 right-3 transition-colors",
182+
isSelected
183+
? "bg-[var(--inbox-row-highlight-bg)]"
184+
: "group-hover/inbox-item:bg-[var(--inbox-row-highlight-bg)] group-focus-within/inbox-item:bg-[var(--inbox-row-highlight-bg)] group-active/inbox-item:bg-muted/40",
185+
)}
186+
/>
187+
<div className="relative flex min-w-0 items-start gap-2.5">
182188
<div className="relative shrink-0">
183189
<UserAvatar
184190
avatarUrl={item.avatarUrl}
@@ -233,7 +239,7 @@ export function InboxListPane({
233239
</div>
234240
</button>
235241

236-
<div className="pointer-events-none absolute right-2 top-2 z-10 flex items-center gap-0.5 rounded-full bg-[var(--inbox-row-highlight-bg)] p-1 opacity-0 transition-opacity duration-150 ease-out group-hover/inbox-item:pointer-events-auto group-hover/inbox-item:opacity-100 group-focus-within/inbox-item:pointer-events-auto group-focus-within/inbox-item:opacity-100">
242+
<div className="pointer-events-none absolute right-3 top-2 z-10 flex items-center gap-0.5 rounded-full bg-[var(--inbox-row-highlight-bg)] p-1 opacity-0 transition-opacity duration-150 ease-out group-hover/inbox-item:pointer-events-auto group-hover/inbox-item:opacity-100 group-focus-within/inbox-item:pointer-events-auto group-focus-within/inbox-item:opacity-100">
237243
{isDone ? (
238244
<InboxRowActionButton
239245
label="Mark unread"
@@ -444,7 +450,7 @@ export function InboxListPane({
444450
</div>
445451
) : (
446452
<div
447-
className="min-h-0 flex-1 overflow-y-auto overscroll-contain"
453+
className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain"
448454
data-testid="home-inbox-list"
449455
ref={scrollRef}
450456
>

‎desktop/src/features/messages/lib/threadTreeLayout.test.mjs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,29 @@ import {
1212

1313
test("getThreadReplyIndentRem uses a visible Tailwind spacing step", () => {
1414
assert.equal(getThreadReplyIndentRem(0), 0);
15-
assert.equal(getThreadReplyIndentRem(1), 2.25);
16-
assert.equal(getThreadReplyIndentRem(2), 4.5);
17-
assert.equal(getThreadReplyIndentRem(3), 6.75);
15+
assert.equal(getThreadReplyIndentRem(1), 0);
16+
assert.equal(getThreadReplyIndentRem(2), 2.25);
17+
assert.equal(getThreadReplyIndentRem(3), 4.5);
1818
});
1919

2020
test("avatar center helpers expose the rail anchor points", () => {
2121
assert.equal(getThreadReplyAvatarCenterRem(0), 1.875);
22-
assert.equal(getThreadReplyAvatarCenterRem(1), 4.125);
22+
assert.equal(getThreadReplyAvatarCenterRem(1), 1.875);
23+
assert.equal(getThreadReplyAvatarCenterRem(2), 4.125);
2324
assert.equal(getThreadReplyAvatarCenterYRem(), 1.5);
2425
assert.equal(getThreadReplyDescendantRailStartYRem(), 2.875);
2526
});
2627

2728
test("getThreadReplyConnectorLayout stops before the child avatar edge", () => {
2829
assert.equal(getThreadReplyConnectorLayout(0), null);
29-
assert.deepEqual(getThreadReplyConnectorLayout(1), {
30+
assert.equal(getThreadReplyConnectorLayout(1), null);
31+
assert.deepEqual(getThreadReplyConnectorLayout(2), {
3032
childOffsetRem: 4.125,
3133
heightRem: 1.5,
3234
parentOffsetRem: 1.875,
3335
widthRem: 0.875,
3436
});
35-
assert.deepEqual(getThreadReplyConnectorLayout(2), {
37+
assert.deepEqual(getThreadReplyConnectorLayout(3), {
3638
childOffsetRem: 6.375,
3739
heightRem: 1.5,
3840
parentOffsetRem: 4.125,

‎desktop/src/features/messages/lib/threadTreeLayout.ts‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,34 @@ function clampVisibleDepth(depth: number) {
3434
return Math.min(Math.max(depth, 0), THREAD_REPLY_MAX_VISIBLE_DEPTH);
3535
}
3636

37-
export function getThreadReplyIndentRem(depth: number) {
38-
const visibleDepth = clampVisibleDepth(depth);
37+
function getThreadReplyVisualDepth(depth: number) {
38+
return clampVisibleDepth(Math.max(0, depth - 1));
39+
}
40+
41+
function getThreadReplyIndentForVisibleDepthRem(visibleDepth: number) {
3942
return visibleDepth > 0
4043
? THREAD_REPLY_ROOT_INDENT_REM +
4144
(visibleDepth - 1) * THREAD_REPLY_NESTED_INDENT_REM
4245
: 0;
4346
}
4447

48+
export function getThreadReplyIndentRem(depth: number) {
49+
return getThreadReplyIndentForVisibleDepthRem(
50+
getThreadReplyVisualDepth(depth),
51+
);
52+
}
53+
4554
export function getThreadReplyAvatarCenterRem(depth: number) {
4655
return getThreadReplyIndentRem(depth) + THREAD_REPLY_AVATAR_CENTER_OFFSET_REM;
4756
}
4857

58+
function getThreadReplyAvatarCenterForVisibleDepthRem(visibleDepth: number) {
59+
return (
60+
getThreadReplyIndentForVisibleDepthRem(visibleDepth) +
61+
THREAD_REPLY_AVATAR_CENTER_OFFSET_REM
62+
);
63+
}
64+
4965
export function getThreadReplyAvatarCenterYRem() {
5066
return THREAD_REPLY_AVATAR_CENTER_Y_REM;
5167
}
@@ -59,13 +75,16 @@ export function getThreadReplyDescendantRailStartYRem() {
5975
}
6076

6177
export function getThreadReplyConnectorLayout(depth: number) {
62-
const visibleDepth = clampVisibleDepth(depth);
78+
const visibleDepth = getThreadReplyVisualDepth(depth);
6379
if (visibleDepth === 0) {
6480
return null;
6581
}
6682

67-
const parentOffsetRem = getThreadReplyAvatarCenterRem(visibleDepth - 1);
68-
const childOffsetRem = getThreadReplyAvatarCenterRem(visibleDepth);
83+
const parentOffsetRem = getThreadReplyAvatarCenterForVisibleDepthRem(
84+
visibleDepth - 1,
85+
);
86+
const childOffsetRem =
87+
getThreadReplyAvatarCenterForVisibleDepthRem(visibleDepth);
6988
const childEdgeOffsetRem =
7089
childOffsetRem -
7190
THREAD_REPLY_AVATAR_RADIUS_REM -

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ export const MessageRow = React.memo(
197197
const depthGuideItems = React.useMemo(() => {
198198
const depths =
199199
depthGuideDepths ??
200-
Array.from({ length: message.depth }, (_, depth) => depth);
200+
Array.from(
201+
{ length: Math.max(0, message.depth - 1) },
202+
(_, index) => index + 1,
203+
);
201204

202205
return depths.map((depth) => ({
203206
depth,

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ function getActiveContinuationDepths({
149149
const depths: number[] = [];
150150

151151
for (const ancestor of ancestors) {
152+
if (ancestor.message.depth === 0) {
153+
continue;
154+
}
155+
152156
const childDepth = ancestor.message.depth + 1;
153157
const pathChild =
154158
message.depth === childDepth
@@ -626,27 +630,10 @@ export function MessageThreadPanel({
626630
actionBarPlacement="inside"
627631
agentPubkeys={agentPubkeys}
628632
channelId={channelId}
629-
collapseDescendantsLabel="Collapse thread"
630-
connectDescendants={
631-
shouldShowThreadBranchGuides &&
632-
!isThreadHeadRepliesCollapsed &&
633-
deferredThreadReplies.length > 0
634-
}
635-
highlightDescendantRail={
636-
shouldShowThreadBranchGuides &&
637-
!isThreadHeadRepliesCollapsed &&
638-
highlightedBranch?.id === threadHead.id
639-
}
640633
isFollowingThread={isFollowingThread}
641634
isUnread={isMessageUnreadById?.(threadHead.id)}
642635
layoutVariant="thread-reply"
643636
message={threadHead}
644-
onCollapseDescendants={
645-
isThreadHeadRepliesCollapsed
646-
? undefined
647-
: collapseThreadHeadReplies
648-
}
649-
onCollapseDescendantsHoverChange={handleCollapseBranchHoverChange}
650637
onDelete={
651638
onDelete && canManageMessage(threadHead, currentPubkey)
652639
? onDelete
@@ -730,7 +717,7 @@ export function MessageThreadPanel({
730717
return (
731718
<div
732719
className={cn(
733-
"content-visibility-auto flex flex-col gap-0",
720+
"content-visibility-auto-interactive flex flex-col gap-0",
734721
entry.summary &&
735722
"group/message rounded-2xl px-0 py-0.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",
736723
)}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function MessageThreadSummaryRow({
8888
: `View thread with ${summary.replyCount} ${replyLabel}`;
8989
const guideDepths = depthGuideDepths
9090
? [...depthGuideDepths]
91-
: Array.from({ length: depth }, (_, index) => index);
91+
: Array.from({ length: Math.max(0, depth - 1) }, (_, index) => index + 1);
9292
const depthGuideItems = guideDepths.map((guideDepth) => ({
9393
depth: guideDepth,
9494
offset: getThreadReplyAvatarCenterRem(guideDepth),
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { formatFullDateTime } from "@/features/messages/lib/dateFormatters";
2-
import { Tooltip, TooltipContent, TooltipTrigger } from "@/shared/ui/tooltip";
2+
import {
3+
Tooltip,
4+
TooltipContent,
5+
TooltipProvider,
6+
TooltipTrigger,
7+
} from "@/shared/ui/tooltip";
8+
9+
const TIMESTAMP_TOOLTIP_DELAY_MS = 500;
310

411
export function MessageTimestamp({
512
createdAt,
@@ -9,15 +16,20 @@ export function MessageTimestamp({
916
time: string;
1017
}) {
1118
return (
12-
<Tooltip>
13-
<TooltipTrigger asChild>
14-
<p className="shrink-0 cursor-default whitespace-nowrap text-xs font-normal leading-4 tabular-nums text-muted-foreground/55">
15-
{time}
16-
</p>
17-
</TooltipTrigger>
18-
<TooltipContent side="top">
19-
{formatFullDateTime(createdAt)}
20-
</TooltipContent>
21-
</Tooltip>
19+
<TooltipProvider
20+
delayDuration={TIMESTAMP_TOOLTIP_DELAY_MS}
21+
skipDelayDuration={0}
22+
>
23+
<Tooltip>
24+
<TooltipTrigger asChild>
25+
<p className="shrink-0 cursor-default whitespace-nowrap text-xs font-normal leading-4 tabular-nums text-muted-foreground/55">
26+
{time}
27+
</p>
28+
</TooltipTrigger>
29+
<TooltipContent side="top">
30+
{formatFullDateTime(createdAt)}
31+
</TooltipContent>
32+
</Tooltip>
33+
</TooltipProvider>
2234
);
2335
}

‎desktop/src/features/profile/ui/UserProfilePopover.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type UserProfilePopoverProps = {
3535
botIdenticonValue?: string;
3636
};
3737

38-
const HOVER_OPEN_DELAY_MS = 300;
38+
const HOVER_OPEN_DELAY_MS = 500;
3939
const HOVER_CLOSE_DELAY_MS = 200;
4040

4141
const RUNTIME_LABELS: Record<string, string> = {

‎desktop/src/shared/styles/globals.css‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,15 @@
18911891
contain-intrinsic-size: auto 200px;
18921892
}
18931893

1894+
.content-visibility-auto-interactive {
1895+
content-visibility: auto;
1896+
contain-intrinsic-size: auto 200px;
1897+
}
1898+
1899+
.content-visibility-auto-interactive:is(:hover, :focus-within) {
1900+
content-visibility: visible;
1901+
}
1902+
18941903
/* Compact variant for short single-line rows (sidebar channels, etc). */
18951904
.content-visibility-auto-row {
18961905
content-visibility: auto;

‎desktop/tests/e2e/thread-reply-anchor-roleplay.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ test.describe("thread reply anchor A/B roleplay screenshots", () => {
207207
await expect(
208208
page.getByTestId("message-thread-replies").getByTestId("message-row"),
209209
).toHaveCount(2);
210-
await expect(page.getByTestId("thread-collapse-rail")).toHaveCount(2);
210+
await expect(page.getByTestId("thread-collapse-rail")).toHaveCount(1);
211211

212212
await screenshotThreadPanel(page, `${SHOTS}/01-baseline-depth-2.png`);
213213
});
@@ -344,7 +344,7 @@ test.describe("thread reply anchor A/B roleplay screenshots", () => {
344344
await expect(
345345
page.getByTestId("message-thread-replies").getByTestId("message-row"),
346346
).toHaveCount(2);
347-
await expect(page.getByTestId("thread-collapse-rail")).toHaveCount(2);
347+
await expect(page.getByTestId("thread-collapse-rail")).toHaveCount(1);
348348

349349
await screenshotThreadPanel(page, `${SHOTS}/04-agent-only-nested.png`);
350350
});

0 commit comments

Comments
 (0)