From 202a654dd8518fbb61265deac360426906969a48 Mon Sep 17 00:00:00 2001 From: Gurpreet Kait Date: Tue, 20 Oct 2026 01:24:33 +0530 Subject: [PATCH 1/2] feat: compact the profile hover card into a one-row header Widen the preview to 360px with the avatar, name, handle and follow controls on one row, move the chips to their own line, and fold the live stream into a single clickable LiveStreamRow. Follows from the preview are now async visits so following several people in a row doesn't cancel the earlier ones. Co-Authored-By: Claude Opus 5.5 (1M context) --- DESIGN.md | 2 +- resources/js/components/live-stream-card.tsx | 52 ++++++++++ resources/js/components/user-preview.tsx | 102 +++++++++++-------- tests/Unit/FollowState.test.tsx | 28 ++++- tests/Unit/LiveStreamRow.test.tsx | 50 +++++++++ 5 files changed, 184 insertions(+), 50 deletions(-) create mode 100644 tests/Unit/LiveStreamRow.test.tsx diff --git a/DESIGN.md b/DESIGN.md index 50e649f9cf..6ffd37f069 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -316,7 +316,7 @@ Under the graph, a mono 13px strip prints the streaks, `longest streak 12 days - **Activity tooltip:** one dark tooltip (Ink on Background inverted) follows the hovered cell, edge-aligned near the ends ("3 commits on Tue, Oct 14", "2 commits between 14:00 and 15:00 today"); hovering a day or hour tints that period's commits in the profile feed with Primary Soft. ### User Preview -Hovering an avatar, name, or handle (mouse only, 450ms delay, 200ms grace to move into it) opens a 304px Popover preview below the trigger, flipping above near the viewport bottom: a 56px avatar ringed in the user's lane, Follow / Following (Unfollow on hover) top right, name, mono handle with lane dot and a "Follows you" chip, a 3-line bio, and mono counts linking to following and followers. Follow toggles optimistically and rolls back on error. Closes on scroll, Escape, or leaving. +Hovering an avatar, name, or handle (mouse only, 450ms delay, 200ms grace to move into it) opens a 360px Popover preview below the trigger, flipping above near the viewport bottom. The header is one row: a 48px avatar ringed in the user's lane, the name (600, wrapping to two lines) over the mono handle with its lane dot (truncated), and the safety menu plus Follow / Following (Unfollow on hover) on the right. "Follows you" and "Muted" chips get their own line under it, a 3-line bio follows, then one mono line of counts linking to following and followers. While the user is live, their avatar ring turns red with the LIVE label on its bottom edge, as on the rail, and the stream sits under a hairline as one clickable row: a 112px thumbnail with the LIVE label, a red mono "streaming · youtube.com", "{name} is live", and "Watch now ↗" in Commit Blue, opening the stream in a new tab. Follow toggles optimistically and rolls back on error. Closes on scroll, Escape, or leaving. ### Notifications The inbox is a log too: every row hangs on a Rail Gray rail whose node is a 36px hollow circle holding the type icon (person-plus, reply, quote, star, at, check, cross). A sticky header carries the "Notifications" title over a row of page tabs (All, Replies, Quotes, Stars, Mentions, Follows, Moderation) with the sliding Commit Blue underline; on phones the row scrolls sideways with the current filter kept in view. Day markers ("Today", "Yesterday", "Wed, Oct 14") split the rows the way they split the log. A row opens with a line of stacked 32px avatars (up to three, then a mono `+N` disc) and a mono relative time pushed right, then the sentence: the actor's name (600), their mono handle when they act alone, otherwise "and N others", and the action in plain prose. Words someone else wrote (a reply, quote, or mention) follow at 15px like a commit body; your own commit (a star, an approval, a rejection) sits underneath as a hairline-bordered, muted block clamped to three lines. Moderation rows replace the avatars with a mono `approved` or `rejected` chip, and a rejection prints a mono `reason:` key before the moderator's words. Groups expand in place from a Commit Blue toggle ("5 stars" / "Hide stars"), listing one compact row per event behind a 1px Rail Gray guide line, each follower with their own Follow button. Rows the inbox marked read on this visit ring their node in Commit Blue and sit above a `HEAD@{last visit}` marker. While you read, polling adds new rows above without moving the ones on screen, and a Commit Blue pill ("↑ 1 new notification") takes you to them. Empty filters speak in git's voice (`$ cat /dev/notifications | grep stars`) with a link back to all notifications; the end of the list is a hollow root node: "That's the oldest notification. There's nothing before it." diff --git a/resources/js/components/live-stream-card.tsx b/resources/js/components/live-stream-card.tsx index d292f9855b..36e5554131 100644 --- a/resources/js/components/live-stream-card.tsx +++ b/resources/js/components/live-stream-card.tsx @@ -67,6 +67,58 @@ export function LiveStreamCard({ ); } +/** + * The stream folded into one row, for a card that is about the person rather than the stream: a small thumbnail + * beside where it plays, the whole row linking out to it. + */ +export function LiveStreamRow({ + user, + stream, +}: { + user: Pick; + stream: LiveStream; +}) { + return ( + + + + + + + + streaming · youtube.com + + {/* A long name gives way, never "is live". */} + + {user.name} + is live + + + Watch now + + + + + ); +} + /** * The avatar's ring turns red and a LIVE label sits on its edge, sized to the avatar it marks. */ diff --git a/resources/js/components/user-preview.tsx b/resources/js/components/user-preview.tsx index 0b2542c1d6..aa9ff729c6 100644 --- a/resources/js/components/user-preview.tsx +++ b/resources/js/components/user-preview.tsx @@ -11,10 +11,7 @@ import { useFollowHover, useIsFollowing, } from '@/components/follow-button'; -import { - LiveAvatarMarker, - LiveStreamCard, -} from '@/components/live-stream-card'; +import { LiveAvatarMarker, LiveStreamRow } from '@/components/live-stream-card'; import { Button } from '@/components/ui/button'; import { UserAvatar } from '@/components/user-avatar'; import { UserSafetyMenu } from '@/components/user-safety-menu'; @@ -41,11 +38,11 @@ type Position = const openDelay = 450; const closeDelay = 200; -const previewWidth = 304; +const previewWidth = 360; const previewHeight = 260; const viewportMargin = 8; -// Where the centre of the preview's avatar sits: border, padding and half of the size-14 avatar. -const avatarCentre = 45; +// Where the centre of the preview's avatar sits: border, padding and half of the size-12 avatar. +const avatarCentre = 41; const cache = new Map(); async function fetchPreview(url: string): Promise { @@ -282,7 +279,7 @@ export function UserPreview({ scheduleClose(); }} data-state={isOpen ? 'open' : 'closed'} - className="fixed z-50 w-76 rounded-xl border bg-popover p-4 text-popover-foreground shadow-[0_12px_32px_-12px_rgb(0_0_0/0.35)] ease-spring data-[state=closed]:scale-70 data-[state=closed]:opacity-0 data-[state=closed]:ease-in motion-safe:transition-[opacity,scale] motion-safe:duration-560 motion-safe:data-[state=closed]:duration-160 starting:scale-70 starting:opacity-0" + className="fixed z-50 w-90 rounded-xl border bg-popover p-4 text-popover-foreground shadow-[0_12px_32px_-12px_rgb(0_0_0/0.35)] ease-spring data-[state=closed]:scale-70 data-[state=closed]:opacity-0 data-[state=closed]:ease-in motion-safe:transition-[opacity,scale] motion-safe:duration-560 motion-safe:data-[state=closed]:duration-160 starting:scale-70 starting:opacity-0" style={{ ...position, transformOrigin: anchor @@ -340,6 +337,7 @@ function UserPreviewContent({ /** * The button flips right away, but like every other follow control the shared state only changes once the server confirms, so there is nothing to roll back. + * It is an async visit, as follow buttons are, so following someone else before this answers doesn't cancel it. */ const toggleFollow = () => { if (!data || data.isUnavailable || pendingFollows !== null) { @@ -354,6 +352,7 @@ function UserPreviewContent({ ? UserFollowController.store(user) : UserFollowController.destroy(user), { + async: true, preserveScroll: true, preserveState: true, onSuccess: () => { @@ -379,21 +378,45 @@ function UserPreviewContent({ return (
-
- + {/* The LIVE label hangs below the avatar, so the header keeps the usual gap under it. */} +
+ {user.live && } +
+ + {user.name} + +

+ + @{user.username} +

+
+ {!isCurrentUser && (data ? ( -
+
{auth.user && ( { markToggled(); toggleFollow(); @@ -431,43 +454,34 @@ function UserPreviewContent({ )}
) : ( - + ))}
- - {user.name} - -

- - @{user.username} - {data?.followsYou && ( - - Follows you - - )} - {data?.isMuting && ( - - Muted - - )} -

+ {(data?.followsYou || data?.isMuting) && ( +

+ {data.followsYou && ( + + Follows you + + )} + {data.isMuting && ( + + Muted + + )} +

+ )} {user.bio && !data?.isUnavailable && ( -

+

{user.bio}

)} -
+
{data?.isUnavailable ? ( -

+

{data.isBlocking ? `You blocked @${user.username}.` : 'This profile is unavailable.'} @@ -486,7 +500,7 @@ function UserPreviewContent({ {data.user.following_count} @@ -497,7 +511,7 @@ function UserPreviewContent({ {data.user.followers_count} @@ -515,8 +529,8 @@ function UserPreviewContent({

{user.live && !data?.isUnavailable && ( -
- +
+
)}
diff --git a/tests/Unit/FollowState.test.tsx b/tests/Unit/FollowState.test.tsx index f8be4a131a..e1c696e3ca 100644 --- a/tests/Unit/FollowState.test.tsx +++ b/tests/Unit/FollowState.test.tsx @@ -32,8 +32,7 @@ vi.doMock('react', () => ({ : initial, () => {}, ], - useSyncExternalStore: (_subscribe: unknown, read: () => unknown) => - read(), + useSyncExternalStore: (_subscribe: unknown, read: () => unknown) => read(), })); vi.doMock('react-dom', async () => ({ ...(await vi.importActual('react-dom')), @@ -307,8 +306,10 @@ test('unfollowing through a cached preview keeps its follower count', () => { followFromProfile(user); const changes: { user: Profile }[] = []; - (previewFollowButton(user, false, (data) => changes.push(data)).props - .onClick as () => void)(); + ( + previewFollowButton(user, false, (data) => changes.push(data)).props + .onClick as () => void + )(); visits.at(-1)?.onSuccess?.(); assert.equal(changes.at(-1)?.user.followers_count, 0); @@ -379,5 +380,22 @@ test('a second click on a follow still on its way sends nothing', () => { (pending.onFinish as () => void)(); - assert.equal((suggestionFollowLink(user).onBefore as () => boolean)(), true); + assert.equal( + (suggestionFollowLink(user).onBefore as () => boolean)(), + true, + ); +}); + +test('following several people from their previews sends every follow without cancelling the others', () => { + const first = suggestion('lucia'); + const second = suggestion('marco'); + + (previewFollowButton(first).props.onClick as () => void)(); + const firstFollow = visits.at(-1); + (previewFollowButton(second).props.onClick as () => void)(); + const secondFollow = visits.at(-1); + + assert.equal(firstFollow?.async, true); + assert.equal(secondFollow?.async, true); + assert.notEqual(firstFollow, secondFollow); }); diff --git a/tests/Unit/LiveStreamRow.test.tsx b/tests/Unit/LiveStreamRow.test.tsx new file mode 100644 index 0000000000..dc7d8a8cf0 --- /dev/null +++ b/tests/Unit/LiveStreamRow.test.tsx @@ -0,0 +1,50 @@ +/// +import assert from 'node:assert/strict'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { test } from 'vite-plus/test'; +import { LiveStreamRow } from '../../resources/js/components/live-stream-card'; + +const stream = { + url: 'https://www.youtube.com/watch?v=abc123', + thumbnail_url: 'https://i.ytimg.com/vi/abc123/hqdefault_live.jpg', +}; + +test('live stream row links out to the stream in a new tab', () => { + const html = renderToStaticMarkup( + , + ); + + assert.match( + html, + /^]*href="https:\/\/www\.youtube\.com\/watch\?v=abc123"/, + ); + assert.match(html, /target="_blank"/); + assert.match(html, /rel="noopener noreferrer"/); + assert.match(html, /data-test="live-stream-row"/); +}); + +test('live stream row shows the thumbnail, the LIVE label, where it streams and the call to watch', () => { + const html = renderToStaticMarkup( + , + ); + + assert.match( + html, + /src="https:\/\/i\.ytimg\.com\/vi\/abc123\/hqdefault_live\.jpg"/, + ); + assert.match(html, /data-test="live-badge"/); + assert.match(html, /streaming · youtube\.com/); + assert.match(html.replace(/<[^>]+>/g, ''), /Nuno is live/); + assert.match(html, /Watch now/); +}); + +test('live stream row shortens a long name but always says the person is live', () => { + const name = 'Prof. Berta McDermott-Vandervort of the Laravel Core Team'; + const html = renderToStaticMarkup( + , + ); + + assert.match(html, new RegExp(`${name}`)); + assert.match(html, / is live<\/span>/); + assert.match(html, new RegExp(`title="${name} is live"`)); +}); From cc60afee14e9faefa5fb565648bb894da3ee1079 Mon Sep 17 00:00:00 2001 From: Kait <100063447+gurpreetkaits@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:53:55 +0530 Subject: [PATCH 2/2] fix: move the name back under the avatar with "Follows you" beside it The avatar row keeps the menu and Follow on the right, the name and handle get their own row under it, and "Follows you" and "Muted" sit beside the name. The test's visit options now type the async flag the new preview follow test reads. Co-Authored-By: Claude Opus 5.5 --- DESIGN.md | 2 +- resources/js/components/user-preview.tsx | 45 +++++++++++------------- tests/Unit/FollowState.test.tsx | 1 + 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 0a895d28a0..8d5c2b2e05 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -316,7 +316,7 @@ Under the graph, a mono 13px strip prints the streaks, `longest streak 12 days - **Activity tooltip:** one dark tooltip (Ink on Background inverted) follows the hovered cell, edge-aligned near the ends ("3 commits on Tue, Oct 14", "2 commits between 14:00 and 15:00 today"); hovering a day or hour tints that period's commits in the profile feed with Primary Soft. ### User Preview -Hovering an avatar, name, or handle (mouse only, 450ms delay, 200ms grace to move into it) opens a 360px Popover preview below the trigger, flipping above near the viewport bottom. The header is one row: a 48px avatar ringed in the user's lane, the name (600, wrapping to two lines) over the mono handle with its lane dot (truncated), and the safety menu plus Follow / Following (Unfollow on hover) on the right. "Follows you" and "Muted" chips get their own line under it, a 3-line bio follows, then one mono line of counts linking to following and followers. While the user is live, their avatar ring turns red with the LIVE label on its bottom edge, as on the rail, and the stream sits under a hairline as one clickable row: a 112px thumbnail with the LIVE label, a red mono "streaming · youtube.com", "{name} is live", and "Watch now ↗" in Commit Blue, opening the stream in a new tab. Follow toggles optimistically and rolls back on error. Closes on scroll, Escape, or leaving. +Hovering an avatar, name, or handle (mouse only, 450ms delay, 200ms grace to move into it) opens a 360px Popover preview below the trigger, flipping above near the viewport bottom. The top row holds a 48px avatar ringed in the user's lane, with the safety menu and Follow / Following (Unfollow on hover) on the right. Under it sit the name (600, wrapping to two lines) with "Follows you" and "Muted" chips beside it, and the mono handle with its lane dot (truncated), a 3-line bio follows, then one mono line of counts linking to following and followers. While the user is live, their avatar ring turns red with the LIVE label on its bottom edge, as on the rail, and the stream sits under a hairline as one clickable row: a 112px thumbnail with the LIVE label, a red mono "streaming · youtube.com", "{name} is live", and "Watch now ↗" in Commit Blue, opening the stream in a new tab. Follow toggles optimistically and rolls back on error. Closes on scroll, Escape, or leaving. ### Notifications The inbox is a log too: every row hangs on a Rail Gray rail whose node is a 36px hollow circle holding the type icon (person-plus, reply, quote, star, at, check, cross). A sticky header carries the "Notifications" title over a row of page tabs (All, Replies, Quotes, Stars, Mentions, Follows, Moderation) with the sliding Commit Blue underline; on phones the row scrolls sideways with the current filter kept in view. Day markers ("Today", "Yesterday", "Wed, Oct 14") split the rows the way they split the log. A row opens with a line of stacked 32px avatars (up to three, then a mono `+N` disc) and a mono relative time pushed right, then the sentence: the actor's name (600), their mono handle when they act alone, otherwise "and N others", and the action in plain prose. Words someone else wrote (a reply, quote, or mention) follow at 15px like a commit body; your own commit (a star, an approval, a rejection) sits underneath as a hairline-bordered, muted block clamped to three lines. Moderation rows replace the avatars with a mono `approved` or `rejected` chip, and a rejection prints a mono `reason:` key before the moderator's words. Groups expand in place from a Commit Blue toggle ("5 stars" / "Hide stars"), listing one compact row per event behind a 1px Rail Gray guide line, each follower with their own Follow button. Rows the inbox marked read on this visit ring their node in Commit Blue and sit above a `HEAD@{last visit}` marker. While you read, polling adds new rows above without moving the ones on screen, and a Commit Blue pill ("↑ 1 new notification") takes you to them. Empty filters speak in git's voice (`$ cat /dev/notifications | grep stars`) with a link back to all notifications; the end of the list is a hollow root node: "That's the oldest notification. There's nothing before it." diff --git a/resources/js/components/user-preview.tsx b/resources/js/components/user-preview.tsx index 0b3bd31189..135c4079b5 100644 --- a/resources/js/components/user-preview.tsx +++ b/resources/js/components/user-preview.tsx @@ -388,7 +388,7 @@ function UserPreviewContent({
{/* The LIVE label hangs below the avatar, so the header keeps the usual gap under it. */}
@@ -406,22 +406,6 @@ function UserPreviewContent({ {user.live && } -
- - {user.name} - -

- - @{user.username} -

-
- {!isCurrentUser && (data ? (
@@ -466,20 +450,33 @@ function UserPreviewContent({ ))}
- {(data?.followsYou || data?.isMuting) && ( -

- {data.followsYou && ( - +

+
+ + {user.name} + + {data?.followsYou && ( + Follows you )} - {data.isMuting && ( - + {data?.isMuting && ( + Muted )} +
+

+ + @{user.username}

- )} +
{user.bio && !data?.isUnavailable && (

diff --git a/tests/Unit/FollowState.test.tsx b/tests/Unit/FollowState.test.tsx index f4371016c1..8e717e6d11 100644 --- a/tests/Unit/FollowState.test.tsx +++ b/tests/Unit/FollowState.test.tsx @@ -9,6 +9,7 @@ type Props = Record & { children?: ReactNode }; let showPreview = false; type VisitOptions = { + async?: boolean; onHttpException?: (response: { status: number }) => boolean | void; onSuccess?: () => void; onError?: () => void;