Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(community): keep sidebar labels and controls within bounds

Gener4ecf62bb0fde
diff --git a/src/web/src/components/community/channels/dm-sidebar.tsx b/src/web/src/components/community/channels/dm-sidebar.tsx
index d08f1416c..241cdf16e 100644
--- a/src/web/src/components/community/channels/dm-sidebar.tsx
+++ b/src/web/src/components/community/channels/dm-sidebar.tsx
@@ -45,11 +45,12 @@ export const DmSidebar = memo(function DmSidebar({
isFriendsActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
].join(" ")}
>
- <Users className="size-5" /> Friends
+ <Users className="size-5 shrink-0" />
+ <span className="min-w-0 flex-1 truncate">Friends</span>
{requestCount && (
<span
data-testid={tid.friendsShortcutBadge}
- className="ml-auto grid h-5 min-w-5 place-items-center rounded-full bg-primary px-1 text-xs font-semibold text-primary-foreground"
+ className="ml-auto grid h-5 min-w-5 shrink-0 place-items-center rounded-full bg-primary px-1 text-xs font-semibold text-primary-foreground"
>
{requestCount}
</span>
@@ -67,7 +68,8 @@ export const DmSidebar = memo(function DmSidebar({
machinesActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
].join(" ")}
>
- <Monitor className="size-5" /> Machines
+ <Monitor className="size-5 shrink-0" />
+ <span className="min-w-0 flex-1 truncate">Machines</span>
</CommunityNavigationLink>
)}
{onShowBots && (
@@ -81,13 +83,14 @@ export const DmSidebar = memo(function DmSidebar({
botsActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
].join(" ")}
>
- <Bot className="size-5" /> My Bots
+ <Bot className="size-5 shrink-0" />
+ <span className="min-w-0 flex-1 truncate">My Bots</span>
</CommunityNavigationLink>
)}
<div className="my-2 h-px bg-border" />
</div>
<div data-slot="dm-sidebar-list" className="min-h-0 flex-1 overflow-y-auto thin-scrollbar px-2 pb-4">
- <div className="mb-2 px-2 text-xs font-semibold text-muted-foreground">
+ <div className="mb-2 truncate px-2 text-xs font-semibold text-muted-foreground">
Direct Messages
</div>
{loading && dms.length === 0 ? (
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 953b1eec4..0db926ef2 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
@@ -63,7 +63,7 @@ describe("UserBar Inbox switching", () => {
}
})
- it("switches desktop pop-ups, restores focus on Escape, and dismisses outside", async () => {
+ it.each([false, true])("switches desktop pop-ups and restores focus with hidden name=%s", async (hideName) => {
function Harness() {
const [active, setActive] = useState<UserBarExtensionKind>("none")
const inbox = createElement("button", null, "Inbox item")
@@ -99,9 +99,12 @@ describe("UserBar Inbox switching", () => {
await user.click(screen.getByRole("button", { name: "User", exact: true }))
expect(screen.queryByRole("dialog", { name: "Inbox" })).not.toBeInTheDocument()
expect(screen.getByRole("dialog", { name: "Your profile" })).toHaveFocus()
+ const nameTrigger = screen.getByRole("button", { name: "User", exact: true })
+ if (hideName) nameTrigger.style.display = "none"
await user.keyboard("{Escape}")
expect(screen.queryByRole("dialog")).not.toBeInTheDocument()
- await vi.waitFor(() => expect(screen.getByRole("button", { name: "User", exact: true })).toHaveFocus())
+ const expectedFocus = hideName ? screen.getByRole("button", { name: "Open profile", exact: true }) : nameTrigger
+ await vi.waitFor(() => expect(expectedFocus).toHaveFocus())
await user.click(trigger)
await user.click(screen.getByRole("button", { name: "Outside" }))
expect(screen.queryByRole("dialog")).not.toBeInTheDocument()
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 02b6a4ad3..418c8b33e 100644
--- a/src/web/src/components/community/shell/user-bar.test.ts
+++ b/src/web/src/components/community/shell/user-bar.test.ts
@@ -62,7 +62,7 @@ describe("UserBar", () => {
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-4")
expect(html).not.toContain("ring-1 ring-border/40")
- expect(html).toContain('class="flex min-w-0 flex-1 items-center gap-2"')
+ 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"')
expect(html).toContain('class="truncate text-sm font-medium leading-tight"')
expect(html).toContain('class="flex shrink-0 items-center gap-1"')
@@ -97,7 +97,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-4",
+ "flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar:px-2",
)
expect(html).not.toContain("ring-1 ring-border/40")
expect(html).not.toContain("<button")
@@ -111,7 +111,7 @@ describe("UserBar", () => {
inboxOpen: true,
}))
expect(openHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 rounded-b-xl"',
+ 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar:px-2 rounded-b-xl"',
)
const closedHtml = renderToStaticMarkup(createElement(UserBar, {
@@ -120,7 +120,7 @@ describe("UserBar", () => {
inboxOpen: false,
}))
expect(closedHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 rounded-xl"',
+ 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar:px-2 rounded-xl"',
)
const profileHtml = renderToStaticMarkup(createElement(UserBar, {
@@ -139,7 +139,7 @@ describe("UserBar", () => {
},
}))
expect(profileHtml).toContain(
- 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 rounded-b-xl"',
+ 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar:px-2 rounded-b-xl"',
)
})
diff --git a/src/web/src/components/community/shell/user-bar.tsx b/src/web/src/components/community/shell/user-bar.tsx
index a5a6b4c03..1d7bbb86b 100644
--- a/src/web/src/components/community/shell/user-bar.tsx
+++ b/src/web/src/components/community/shell/user-bar.tsx
@@ -74,7 +74,11 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
globalThis.requestAnimationFrame(() => {
if (active === "inbox") inboxTriggerRef.current?.focus()
else if (active === "profile") {
- (lastProfileTriggerRef.current ?? profileTriggerRef.current)?.focus()
+ const trigger = lastProfileTriggerRef.current
+ const style = trigger ? getComputedStyle(trigger) : null
+ const visible = trigger?.isConnected && style?.display !== "none" && style?.visibility !== "hidden"
+ const focusTarget = visible ? trigger : profileTriggerRef.current
+ focusTarget?.focus()
}
else updateBadgeRef.current?.focus()
})
@@ -103,7 +107,7 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
return (
<div
data-testid={tid.userBar}
- className="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"
+ 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"
>
{mobile
? <UserBarExtensionDrawer>{extensionContent}</UserBarExtensionDrawer>
@@ -121,7 +125,7 @@ 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-4",
+ "flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar:px-2",
joinedMobileExtension
? "rounded-b-xl"
: "rounded-xl",
@@ -157,13 +161,17 @@ export function UserBarSkeleton() {
<div
data-testid={tid.initialUserBarPending}
aria-hidden
- className="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"
+ 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-4">
- <Skeleton className="size-7 shrink-0 rounded-full" />
- <Skeleton className="h-3.5 min-w-0 flex-1 rounded" />
- <Skeleton className="size-7 shrink-0 rounded-lg" />
- <Skeleton className="size-7 shrink-0 rounded-lg" />
+ <div className="flex h-12 items-center gap-3 rounded-xl border border-border/40 bg-muted px-4 sm:@max-[224px]/user-bar: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="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>
+ </div>
</div>
</div>
)
@@ -204,7 +212,7 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
? LoaderCircle
: Download
return (
- <div className="flex min-w-0 flex-1 items-center gap-2">
+ <div className="flex min-w-0 flex-1 items-center justify-between gap-2 sm:@max-[224px]/user-bar:gap-1">
<button ref={profileTriggerRef} onClick={(e) => {
lastProfileTriggerRef.current = e.currentTarget
if (extension && extension.active !== "profile") {
@@ -242,7 +250,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 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="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">