Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): separate user bar touch targets from visuals (#1147)

Gener377c9f963a47
diff --git a/DESIGN.md b/DESIGN.md
index 3d5ecbb1e..4ef28403b 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -129,6 +129,7 @@ Rules:
- **JS and CSS boundaries are the same 640px.** Use the hook for behavior (which zone to render, whether to show a back button); use Tailwind's `sm:` prefix for pure layout fit at the mobile ↔ desktop split. Both share the same 640px pivot so a mobile page never renders desktop CSS at the same width.
- **`md:` is banned. `lg:` is allowed only for desktop-internal fit** — e.g. an issue sheet that can float a timeline panel beside its body once the viewport clears ~1024px, or a stats grid that reflows from 1 col to 2 cols when there's room. This is not a third tier; it's a content-fit fallback that happens *within* desktop. If the switch changes navigation or a user-visible zone, it belongs in the JS hook, not in `lg:`.
- **Touch targets on mobile are non-negotiable.** Interactive elements ≥ 44×44px (`h-11`). On desktop the same control may collapse to `h-9`/`h-10`.
+- **UserBar keeps compact visuals inside its touch targets.** Below 640px, square buttons use fixed 44×44px targets and centered 28×28px visual surfaces; at 640px and above both are 28×28px. The name trigger is 44px high below the checkpoint and 28px high above it. Background, hover and expanded tint belong to the visual surface, while focus belongs to the native button. Preserve icon, avatar, unread and running-ring sizes. Keep the bar 48px high and reserve matching slots in both skeletons, including the homepage document with its 14px root font.
- **Don't introduce a third stage.** If a design "needs a tablet mode," either the mobile layout should stretch gracefully or the desktop layout should reflow inside — not a new tier.
### Dots & Indicators
diff --git a/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts b/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
index f14c0909f..c0b9a5e1f 100644
--- a/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
+++ b/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
@@ -60,6 +60,34 @@ describe("UserBar native mobile spacing", () => {
})
describe("UserBar Inbox switching", () => {
+ it.each([
+ ["collapsedBadge", "Open machine update"],
+ ["updating", "Machine update in progress"],
+ ["retry", "Retry machine update"],
+ ] as const)("opens the %s badge once without dispatching an update", async (phase, label) => {
+ const open = vi.fn()
+ const request = vi.fn()
+ const user = setupUser()
+ render(createElement(UserBar, {
+ breakpoint: "mobile",
+ user: { id: "u1", name: "User", avatar: "U", runningBotCount: 2 },
+ hasUnread: true,
+ unreadCount: 3,
+ extension: {
+ active: "none", inbox: null, profile: null, update: null,
+ updateBadgePhase: phase, eligibleMachines: [],
+ onOpenUpdate: open, onRequestUpdate: request, onDismiss: vi.fn(),
+ },
+ }))
+ const badge = screen.getByRole("button", { name: label })
+ badge.focus()
+ await user.keyboard("{Enter}")
+ expect(open).toHaveBeenCalledOnce()
+ expect(request).not.toHaveBeenCalled()
+ expect(screen.getByRole("button", { name: "Open profile. 2 running bots." })).toBeInTheDocument()
+ expect(screen.getByTestId(tid.userBarRunningBotsRing)).toBeInTheDocument()
+ })
+
it("dismisses the real mobile extension once through native Back", async () => {
const dismissed = vi.fn()
function Harness() {
diff --git a/src/web/src/components/community/shell/user-bar.module.css b/src/web/src/components/community/shell/user-bar.module.css
new file mode 100644
index 000000000..c31c7bc9d
--- /dev/null
+++ b/src/web/src/components/community/shell/user-bar.module.css
@@ -0,0 +1,38 @@
+.base { height: 48px; }
+
+.target {
+ position: relative;
+ display: grid;
+ flex-shrink: 0;
+ place-items: center;
+ width: 44px;
+ height: 44px;
+}
+
+.visual { width: 28px; height: 28px; }
+.name { height: 44px; }
+
+.squareButton { isolation: isolate; }
+
+.squareButton::before {
+ position: absolute;
+ z-index: -1;
+ inset: 0;
+ width: 28px;
+ height: 28px;
+ margin: auto;
+ border-radius: var(--radius);
+ pointer-events: none;
+ content: "";
+}
+
+.update::before { background: var(--secondary); }
+
+.update:hover::before,
+.hoverBackground:hover::before,
+.inbox[aria-expanded="true"]::before { background: var(--accent); }
+
+@media (min-width: 640px) {
+ .target { width: 28px; height: 28px; }
+ .name { height: 28px; }
+}
diff --git a/src/web/src/components/community/shell/user-bar.test.ts b/src/web/src/components/community/shell/user-bar.test.ts
index 5a5dd7c32..2908f369a 100644
--- a/src/web/src/components/community/shell/user-bar.test.ts
+++ b/src/web/src/components/community/shell/user-bar.test.ts
@@ -4,6 +4,7 @@ import { readFileSync } from "node:fs"
import { describe, expect, it } from "vitest"
import { UserBar, UserBarSkeleton } from "./user-bar"
import { tid } from "@/lib/community/testids"
+import styles from "./user-bar.module.css"
describe("UserBar", () => {
it("adds a geometry-neutral running-bot ring and accessible count only while bots are live", () => {
@@ -19,9 +20,10 @@ describe("UserBar", () => {
expect(running).toContain(`data-testid="${tid.userBarRunningBotsRing}"`)
expect(running).toContain(`data-testid="${tid.userBarRunningBotsGlow}"`)
expect(running).toContain('aria-label="Open profile. 2 running bots."')
- expect(running).toContain("relative grid size-7 place-items-center rounded-full")
+ expect(running).toContain(`${styles.visual} relative grid place-items-center rounded-full`)
expect(running).toContain("pointer-events-none absolute -inset-px")
- expect(running).toContain("focus-visible:ring-offset-4")
+ expect(running).toContain("focus-visible:ring-offset-0")
+ expect(running).toContain("sm:focus-visible:ring-offset-4")
expect(running).toContain("focus-visible:ring-offset-muted")
expect(running).toContain("var(--running-bots-primary)")
expect(readFileSync(new URL("../../../app/globals.css", import.meta.url), "utf8"))
@@ -60,7 +62,7 @@ describe("UserBar", () => {
expect(html).toContain("pr-[max(0.75rem,var(--app-safe-area-right))]")
expect(html).toContain("pb-[calc(0.75rem+var(--app-safe-area-bottom))]")
expect(html).toContain("sm:px-2 sm:pb-3")
- expect(html).toContain("flex h-12 items-center gap-3 border border-border/40 bg-muted px-2")
+ expect(html).toContain(`${styles.base} flex items-center gap-3 border border-border/40 bg-muted px-2`)
expect(html).not.toContain("ring-1 ring-border/40")
expect(html).toContain('class="flex min-w-0 flex-1 items-center justify-between gap-2 sm:@max-[224px]/user-bar:gap-1"')
expect(html).toContain('data-testid="community-user-bar-name"')
@@ -69,7 +71,8 @@ describe("UserBar", () => {
const desktopSettingsClass = html.match(
/class="([^"]*)" aria-label="User settings"/,
)?.[1]?.split(" ")
- expect(desktopSettingsClass).toContain("hover:bg-accent")
+ expect(desktopSettingsClass).toContain(styles.hoverBackground)
+ expect(desktopSettingsClass).not.toContain("hover:bg-accent")
})
it("keeps the mobile Settings action as a color-only icon button", () => {
@@ -83,6 +86,7 @@ describe("UserBar", () => {
expect(settingsClass).toContain("hover:text-foreground")
expect(settingsClass).toContain("active:text-foreground")
expect(settingsClass).not.toContain("hover:bg-accent")
+ expect(settingsClass).not.toContain(styles.hoverBackground)
expect(settingsClass).not.toContain("border")
expect(settingsClass).not.toContain("shadow")
expect(settingsClass).toContain("focus-visible:ring-2")
@@ -97,7 +101,7 @@ describe("UserBar", () => {
expect(html).toContain("pb-[calc(0.75rem+var(--app-safe-area-bottom))]")
expect(html).toContain("sm:px-2 sm:pb-3")
expect(html).toContain(
- "flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-2",
+ `${styles.base} flex items-center gap-3 rounded-xl border border-border/40 bg-muted px-2`,
)
expect(html).not.toContain("ring-1 ring-border/40")
expect(html).not.toContain("<button")
@@ -111,7 +115,7 @@ describe("UserBar", () => {
inboxOpen: true,
}))
expect(openHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-2 rounded-b-xl"',
+ `class="${styles.base} flex items-center gap-3 border border-border/40 bg-muted px-2 rounded-b-xl"`,
)
const closedHtml = renderToStaticMarkup(createElement(UserBar, {
@@ -120,7 +124,7 @@ describe("UserBar", () => {
inboxOpen: false,
}))
expect(closedHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-2 rounded-xl"',
+ `class="${styles.base} flex items-center gap-3 border border-border/40 bg-muted px-2 rounded-xl"`,
)
const profileHtml = renderToStaticMarkup(createElement(UserBar, {
@@ -139,7 +143,7 @@ describe("UserBar", () => {
},
}))
expect(profileHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-2 rounded-b-xl"',
+ `class="${styles.base} flex items-center gap-3 border border-border/40 bg-muted px-2 rounded-b-xl"`,
)
})
@@ -234,9 +238,9 @@ describe("UserBar", () => {
expect(closed).toContain('aria-expanded="false"')
expect(open).toContain('aria-expanded="true"')
- expect(closed).toContain("aria-expanded:bg-accent")
+ expect(closed).toContain(styles.inbox)
expect(closed).toContain("aria-expanded:text-foreground")
- expect(open).toContain("aria-expanded:bg-accent")
+ expect(open).toContain(styles.inbox)
expect(open).toContain("aria-expanded:text-foreground")
expect(closed).not.toContain("fill-current")
expect(open).not.toContain("fill-current")
diff --git a/src/web/src/components/community/shell/user-bar.tsx b/src/web/src/components/community/shell/user-bar.tsx
index 549f99b4d..1ee5c512f 100644
--- a/src/web/src/components/community/shell/user-bar.tsx
+++ b/src/web/src/components/community/shell/user-bar.tsx
@@ -22,6 +22,7 @@ import { UserBarExtensionDrawer } from "./user-bar-extension-drawer"
import { UserBarExtensionSlot } from "./user-bar-extension-slot"
import { UserBarPopover } from "./user-bar-popover"
import { useHydratedClient } from "./use-hydrated-client"
+import styles from "./user-bar.module.css"
import type {
UserBarExtensionKind,
UserBarUpdatePhase,
@@ -130,7 +131,8 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
ref={baseRef}
data-slot="community-user-bar-base"
className={cn(
- "flex h-12 items-center gap-3 border border-border/40 bg-muted px-2",
+ styles.base,
+ "flex items-center gap-3 border border-border/40 bg-muted px-2",
joinedMobileExtension
? "rounded-b-xl"
: "rounded-xl",
@@ -171,13 +173,15 @@ export function UserBarSkeleton() {
aria-hidden
className="@container/user-bar w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-2 sm:pb-3"
>
- <div className="flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-2">
+ <div className={cn(styles.base, "flex items-center gap-3 rounded-xl border border-border/40 bg-muted px-2")}>
<div className="flex min-w-0 flex-1 items-center justify-between gap-2 sm:@max-[224px]/user-bar:gap-1">
- <Skeleton className="size-7 shrink-0 rounded-full" />
- <Skeleton className="h-3.5 min-w-0 flex-1 rounded sm:@max-[224px]/user-bar:hidden" />
+ <div className={styles.target}><Skeleton className={cn(styles.visual, "rounded-full")} /></div>
+ <div className={cn(styles.name, "flex min-w-0 flex-1 items-center sm:@max-[224px]/user-bar:hidden")}>
+ <Skeleton className="h-3.5 w-full rounded" />
+ </div>
<div className="flex shrink-0 items-center gap-1">
- <Skeleton className="size-11 shrink-0 rounded-lg sm:size-7" />
- <Skeleton className="size-11 shrink-0 rounded-lg sm:size-7" />
+ <div className={styles.target}><Skeleton className={cn(styles.visual, "rounded-lg")} /></div>
+ <div className={styles.target}><Skeleton className={cn(styles.visual, "rounded-lg")} /></div>
</div>
</div>
</div>
@@ -229,10 +233,10 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
}
if (!extension) closeInboxForAction()
onOpenProfile?.(user.name, e, undefined, user.id)
- }} className="shrink-0 rounded-full focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-muted focus-visible:outline-none" aria-label={hasRunningBots
+ }} className={cn(styles.target, "rounded-full focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 focus-visible:ring-offset-muted focus-visible:outline-none sm:focus-visible:ring-offset-4")} aria-label={hasRunningBots
? `Open profile. ${runningBotCount} running ${runningBotCount === 1 ? "bot" : "bots"}.`
: "Open profile"} aria-expanded={extension ? extension.active === "profile" : undefined} aria-controls={extension?.active === "profile" ? "community-user-bar-extension" : undefined}>
- <span className="relative grid size-7 place-items-center rounded-full">
+ <span className={cn(styles.visual, "relative grid place-items-center rounded-full")}>
{hasRunningBots && (
<>
<span
@@ -259,7 +263,7 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
}
if (!extension) closeInboxForAction()
onOpenProfile?.(user.name, e, undefined, user.id)
- }} className="min-w-0 flex-1 text-left rounded sm:@max-[224px]/user-bar:hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none" aria-expanded={extension ? extension.active === "profile" : undefined} aria-controls={extension?.active === "profile" ? "community-user-bar-extension" : undefined}>
+ }} className={cn(styles.name, "min-w-0 flex-1 text-left rounded sm:@max-[224px]/user-bar:hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none")} aria-expanded={extension ? extension.active === "profile" : undefined} aria-controls={extension?.active === "profile" ? "community-user-bar-extension" : undefined}>
<div data-testid={tid.userBarName} className="truncate text-sm font-medium leading-tight">{user.name}</div>
</button>
<div className="flex shrink-0 items-center gap-1">
@@ -268,7 +272,7 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
ref={updateBadgeRef}
type="button"
data-testid={tid.daemonUpdateBadge}
- className="grid size-11 place-items-center rounded-lg bg-secondary text-secondary-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:size-7"
+ className={cn(styles.target, styles.squareButton, styles.update, "rounded-lg text-secondary-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none")}
aria-label={updateBadgeLabel}
onClick={() => {
onRequestExtensionFocus("update")
@@ -287,10 +291,13 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
type="button"
data-testid={tid.inboxTrigger}
className={cn(
- "relative grid size-11 place-items-center rounded-lg text-muted-foreground aria-expanded:bg-accent aria-expanded:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:size-7",
+ styles.target,
+ styles.squareButton,
+ styles.inbox,
+ "rounded-lg text-muted-foreground aria-expanded:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
mobile
? "hover:text-foreground active:text-foreground"
- : "hover:bg-accent hover:text-foreground",
+ : cn(styles.hoverBackground, "hover:text-foreground"),
)}
aria-label={mobile ? (inboxOpen || inboxOpening ? "Close Inbox" : "Open Inbox") : "Inbox"}
aria-busy={inboxOpening || undefined}
@@ -319,10 +326,12 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
onEditProfile?.()
}}
className={cn(
- "grid size-11 place-items-center rounded-lg text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:size-7",
+ styles.target,
+ styles.squareButton,
+ "rounded-lg text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
breakpoint === "mobile"
? "hover:text-foreground active:text-foreground"
- : "hover:bg-accent hover:text-foreground",
+ : cn(styles.hoverBackground, "hover:text-foreground"),
)}
aria-label="User settings"
data-testid={tid.userSettingsOpen}
diff --git a/src/web/src/components/home/landing-interactive-shell.module.css b/src/web/src/components/home/landing-interactive-shell.module.css
index 8267a82b6..ed21b553f 100644
--- a/src/web/src/components/home/landing-interactive-shell.module.css
+++ b/src/web/src/components/home/landing-interactive-shell.module.css
@@ -40,7 +40,9 @@
.skeletonChannel { display: flex; align-items: center; gap: 8px; height: 36px; }
.skeletonUser { position: absolute; bottom: 0; left: 0; width: 296px; padding: 0 8px 12px; }
.skeletonUserInner { display: flex; align-items: center; gap: 8px; height: 48px; padding-inline: 8px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--muted); }
-.skeletonUserAction { width: 28px; height: 28px; flex-shrink: 0; background: color-mix(in oklch, var(--background) 60%, transparent); }
+.skeletonUserActions { display: flex; flex-shrink: 0; align-items: center; gap: 4px; }
+.skeletonUserTarget { display: grid; flex-shrink: 0; place-items: center; width: 28px; height: 28px; }
+.skeletonUserVisual { width: 28px; height: 28px; }
.skeletonChat { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.skeletonMessages { display: flex; flex: 1; flex-direction: column; gap: 32px; overflow: hidden; padding: 32px 24px; }
.skeletonMessage { display: flex; gap: 16px; }
@@ -50,7 +52,7 @@
.skeletonSidebar { flex: 1; border-right: 0; }
.skeletonChat { display: none; }
.skeletonUser { width: 100%; padding-inline: 12px; }
- .skeletonUserAction { width: 44px; height: 44px; }
+ .skeletonUserTarget { width: 44px; height: 44px; }
}
:global(html):has(.previewRoot) :global(.chat-input-line-height),
diff --git a/src/web/src/components/home/landing-shell-motion.render.test.ts b/src/web/src/components/home/landing-shell-motion.render.test.ts
index 9d26ce40a..60cd65126 100644
--- a/src/web/src/components/home/landing-shell-motion.render.test.ts
+++ b/src/web/src/components/home/landing-shell-motion.render.test.ts
@@ -7,6 +7,7 @@ import {
landingChannelTreeScopeKey,
} from "./landing-shell-motion"
import { sceneSnapshot, SCENE_MAX_BEAT, type LandingScene } from "./landing-shell-motion-timeline"
+import { tid } from "@/lib/community/testids"
vi.mock("./landing-shell-motion.module.css", () => ({
default: new Proxy({}, { get: (_target, key) => String(key) }),
@@ -29,6 +30,16 @@ function channelHeader(markup: string) {
}
describe("landing community preview rendering", () => {
+ it.each(ALL_SCENES)("keeps the actual %s UserBar only in full-shell scenes", (scene) => {
+ const full = renderToStaticMarkup(createElement(LandingShellMotion, { scene, beat: SCENE_MAX_BEAT[scene] }))
+ const compact = renderToStaticMarkup(createElement(LandingShellMotion, { scene, compact: true, beat: SCENE_MAX_BEAT[scene] }))
+ expect(full.match(new RegExp(`data-testid="${tid.userBar}"`, "g"))).toHaveLength(1)
+ expect(full).toContain(`data-testid="${tid.userSettingsOpen}"`)
+ expect(full.includes(`data-testid="${tid.inboxTrigger}"`)).toBe(["server", "machine", "continuity"].includes(scene))
+ expect(full).not.toContain(`data-testid="${tid.daemonUpdateBadge}"`)
+ expect(compact).not.toContain(`data-testid="${tid.userBar}"`)
+ })
+
it("uses explicit identities for every Channel Tree fixture dataset", () => {
expect(landingChannelTreeScopeKey({ scene: "server", room: null, overviewDetails: false }))
.toBe("landing:root:default")
diff --git a/src/web/src/components/home/landing-workspace-skeleton.tsx b/src/web/src/components/home/landing-workspace-skeleton.tsx
index ce90db8ec..53df3bb07 100644
--- a/src/web/src/components/home/landing-workspace-skeleton.tsx
+++ b/src/web/src/components/home/landing-workspace-skeleton.tsx
@@ -15,9 +15,12 @@ export function LandingWorkspaceSkeleton() {
</div>
</div>
<div className={styles.skeletonUser}><div className={styles.skeletonUserInner}>
- <Skeleton className="size-7 shrink-0 rounded-full bg-background/60" />
+ <div className={styles.skeletonUserTarget}><Skeleton className={`${styles.skeletonUserVisual} rounded-full bg-background/60`} /></div>
<Skeleton className="h-3 min-w-0 flex-1 bg-background/60" />
- <Skeleton className={styles.skeletonUserAction} /><Skeleton className={styles.skeletonUserAction} />
+ <div className={styles.skeletonUserActions}>
+ <div className={styles.skeletonUserTarget}><Skeleton className={`${styles.skeletonUserVisual} rounded-lg bg-background/60`} /></div>
+ <div className={styles.skeletonUserTarget}><Skeleton className={`${styles.skeletonUserVisual} rounded-lg bg-background/60`} /></div>
+ </div>
</div></div>
<div className={styles.skeletonChat}>
<div className={styles.skeletonHeader}><Skeleton className="size-5" /><Skeleton className="h-4 w-24" /></div>
diff --git a/src/web/src/test/e2e-ui/50-daemon-update-notice.spec.ts b/src/web/src/test/e2e-ui/50-daemon-update-notice.spec.ts
index 8b4d2f94e..06d9a6eec 100644
--- a/src/web/src/test/e2e-ui/50-daemon-update-notice.spec.ts
+++ b/src/web/src/test/e2e-ui/50-daemon-update-notice.spec.ts
@@ -175,7 +175,7 @@ test("Update, Inbox, and viewer Profile share one desktop User Bar pop-up", asyn
const readInboxTriggerStyle = () => inboxTrigger.evaluate((element) => {
const style = getComputedStyle(element)
return {
- backgroundColor: style.backgroundColor,
+ backgroundColor: getComputedStyle(element, "::before").backgroundColor,
color: style.color,
}
})
diff --git a/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts b/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts
index a75b81647..8fb2ad4a3 100644
--- a/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts
+++ b/src/web/src/test/e2e-ui/53-mobile-inbox-surface.spec.ts
@@ -404,7 +404,7 @@ test.describe("mobile Inbox interactive user-bar base", () => {
const readTriggerSurfaceStyle = () => inboxTrigger.evaluate((element) => {
const style = getComputedStyle(element)
return {
- backgroundColor: style.backgroundColor,
+ backgroundColor: getComputedStyle(element, "::before").backgroundColor,
color: style.color,
borderWidth: style.borderWidth,
}
diff --git a/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts b/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts
index 9eecb8488..dab2862e1 100644
--- a/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts
+++ b/src/web/src/test/e2e-ui/60-desktop-default-user-bar-width.spec.ts
@@ -1,6 +1,6 @@
import { CURRENT_COMMUNITY_FIXTURE_HEADERS } from "./_fixtures/business-contract"
import { expectInertBackground } from "./_fixtures/inert-background"
-import type { Page, Request, Route, TestInfo } from "@playwright/test"
+import type { Locator, Page, Request, Route, TestInfo } from "@playwright/test"
import { expect, test } from "./_fixtures/case-fixture"
import { gotoAfterUserWsAuth, waitForElementMotion } from "./_fixtures/actions"
import { COMMUNITY_LAYOUT_STORAGE_KEY } from "@/components/community/shell/shell-frame-geometry"
@@ -392,6 +392,56 @@ async function attachJson(testInfo: TestInfo, name: string, value: unknown) {
})
}
+async function expectUserBarTargets(page: Page, size: 28 | 44) {
+ const bar = page.getByTestId(tid.userBar)
+ const profile = bar.getByRole("button", { name: /^Open profile/ })
+ const targets = [profile, page.getByTestId(tid.inboxTrigger), page.getByTestId(tid.userSettingsOpen)]
+ const update = page.getByTestId(tid.daemonUpdateBadge)
+ if (await update.count()) targets.push(update)
+ for (const target of targets) {
+ await expect(target).toHaveCSS("width", `${size}px`)
+ await expect(target).toHaveCSS("height", `${size}px`)
+ if (target === profile) {
+ const avatar = await target.locator(":scope > span").boundingBox()
+ expect(avatar?.width).toBe(28)
+ expect(avatar?.height).toBe(28)
+ } else {
+ expect(await target.evaluate((element) => {
+ const visual = getComputedStyle(element, "::before")
+ return {
+ width: visual.width, height: visual.height,
+ pointerEvents: visual.pointerEvents,
+ targetBackground: getComputedStyle(element).backgroundColor,
+ }
+ })).toEqual({ width: "28px", height: "28px", pointerEvents: "none", targetBackground: "rgba(0, 0, 0, 0)" })
+ }
+ }
+ await expect(page.getByTestId(tid.userBarName).locator("..")).toHaveCSS("height", `${size}px`)
+ const layout = await bar.evaluate((element) => {
+ const base = element.querySelector<HTMLElement>('[data-slot="community-user-bar-base"]')!.getBoundingClientRect()
+ const buttons = Array.from(element.querySelectorAll<HTMLButtonElement>('[data-slot="community-user-bar-base"] button'))
+ .map(button => button.getBoundingClientRect()).filter(box => box.width > 0 && box.height > 0)
+ return { height: base.height, inside: buttons.every(box => box.top >= base.top && box.bottom <= base.bottom && box.left >= base.left && box.right <= base.right), overlap: buttons.some((box, index) => index > 0 && buttons[index - 1].right > box.left) }
+ })
+ expect(layout).toEqual({ height: 48, inside: true, overlap: false })
+}
+
+async function clickTargetEdge(page: Page, target: Locator, edge: "top" | "right" | "bottom" | "left") {
+ const box = await target.boundingBox()
+ expect(box).not.toBeNull()
+ expect(box!.width).toBe(44)
+ expect(box!.height).toBe(44)
+ const point = {
+ x: box!.x + (edge === "left" ? 2 : edge === "right" ? 42 : 22),
+ y: box!.y + (edge === "top" ? 2 : edge === "bottom" ? 42 : 22),
+ }
+ expect(await target.evaluate((element, position) => (
+ document.elementFromPoint(position.x, position.y)?.closest("button") === element
+ ), point)).toBe(true)
+ await page.mouse.click(point.x, point.y)
+ return point
+}
+
test.describe("desktop default User Bar width", () => {
async function prepareCase1(actors: CaseActors) {
const { seedChannel, seedServer } = actors.seed
@@ -1116,4 +1166,68 @@ test.describe("desktop default User Bar width", () => {
}
await attachJson(testInfo, "user-bar-focus-records", focusRecords)
})
+
+ test("activates only the intended UserBar action outside each narrow visual surface", async ({ caseActors }, testInfo) => {
+ test.setTimeout(180_000)
+ const { asUser } = await caseActors(["alice"])
+ const { page } = await asUser("alice")
+ await page.setViewportSize({ width: 390, height: 844 })
+ await page.emulateMedia({ reducedMotion: "reduce" })
+ await serveOutdatedMachine(page)
+ await gotoAfterUserWsAuth(page, "/c/me")
+ const extension = page.getByTestId(tid.userBarExtension)
+ await expect(extension).toHaveAttribute("data-extension", "update")
+ await page.keyboard.press("Escape")
+ await expect(extension).toHaveCount(0)
+ const writes = captureWrites(page)
+ for (const width of [320, 390, 639, 640, 1280]) {
+ await page.setViewportSize({ width, height: 844 })
+ await expectUserBarTargets(page, width < 640 ? 44 : 28)
+ }
+ await page.setViewportSize({ width: 390, height: 844 })
+ await expect(page).toHaveURL(/\/c\/me\/friends$/)
+ const detailPath = new URL(page.url()).pathname
+ const back = page.locator('[data-mobile-page-active="true"]')
+ .getByRole("button", { name: "Back", exact: true })
+ await expect(back).toHaveCount(1)
+ await expect(back).toBeVisible()
+ await back.click()
+ await expect(page).toHaveURL(/\/c\/me$/)
+ await expect(page.locator('[data-community-mobile-surface="list"]')).toBeVisible()
+ await attachJson(testInfo, "user-bar-mobile-list-return", { from: detailPath, to: new URL(page.url()).pathname })
+ await expectUserBarTargets(page, 44)
+ const bar = page.getByTestId(tid.userBar)
+ const profile = bar.getByRole("button", { name: /^Open profile/ })
+ const inbox = page.getByTestId(tid.inboxTrigger)
+ const update = page.getByTestId(tid.daemonUpdateBadge)
+ const settings = page.getByTestId(tid.userSettingsOpen)
+ const records: Array<{ action: string; edge: string; point: { x: number; y: number } }> = []
+ for (const edge of ["top", "right", "bottom", "left"] as const) {
+ for (const [action, trigger] of [["profile", profile], ["inbox", inbox], ["update", update]] as const) {
+ const point = await clickTargetEdge(page, trigger, edge)
+ await expect(extension).toHaveAttribute("data-extension", action)
+ if (action === "profile") await expect(page.getByTestId(tid.profileCard)).toBeVisible()
+ await page.keyboard.press("Escape")
+ await expect(extension).toHaveCount(0)
+ await expect(trigger).toBeFocused()
+ records.push({ action, edge, point })
+ }
+ const point = await clickTargetEdge(page, settings, edge)
+ await expect(page.getByTestId(tid.settingsShell)).toBeVisible()
+ await expect(extension).toHaveCount(0)
+ await page.getByTestId(tid.settingsClose).click()
+ await expect(page.getByTestId(tid.settingsShell)).toHaveCount(0)
+ records.push({ action: "settings", edge, point })
+ }
+ const name = page.getByTestId(tid.userBarName).locator("..")
+ await name.click({ position: { x: 2, y: 2 } })
+ await expect(extension).toHaveAttribute("data-extension", "profile")
+ await page.keyboard.press("Escape")
+ await expect(extension).toHaveCount(0)
+ await expect(name).toBeFocused()
+ expect(writes.writes).toEqual([])
+ writes.stop()
+ await attachJson(testInfo, "user-bar-narrow-edge-clicks", records)
+ await attachScreenshot(page, testInfo, "user-bar-390-targets-closed")
+ })
})