Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(web): add self-profile running bots (#847)

Gustavo Ye90c5ea4120f0
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index de6a41339..13021bef2 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -1539,6 +1539,32 @@ body.driver-active .community-ws-reconnect-overlay * {
pointer-events: none;
}
+@keyframes user-bar-running-bots-breathe {
+ 0%,
+ 100% {
+ opacity: 0.24;
+ transform: scale(0.96);
+ }
+
+ 50% {
+ opacity: 0.52;
+ transform: scale(1.06);
+ }
+}
+
+.user-bar-running-bots-glow {
+ animation: user-bar-running-bots-breathe 2.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
+ will-change: opacity, transform;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .user-bar-running-bots-glow {
+ animation: none;
+ opacity: 0.32;
+ transform: none;
+ }
+}
+
/* ── Utility: hide scrollbar ── */
.scrollbar-none {
-ms-overflow-style: none;
diff --git a/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts b/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
index 0a8a0e000..2513180d9 100644
--- a/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
+++ b/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
@@ -7,6 +7,14 @@ const mocks = vi.hoisted(() => ({
complete: vi.fn(),
navigate: vi.fn(),
initialize: vi.fn(),
+ recoverHarness: vi.fn(),
+ state: {
+ status: "active",
+ stage: "initializing",
+ machineId: "machine-1",
+ harness: "codex",
+ identity: "work",
+ } as Record<string, unknown>,
}))
vi.mock("next/navigation", () => ({
@@ -16,14 +24,10 @@ vi.mock("@/lib/community-onboarding", () => ({
advanceCommunityOnboarding: vi.fn(),
completeCommunityOnboarding: (...args: unknown[]) => mocks.complete(...args),
consumeQueuedCommunityOnboarding: () => false,
+ recoverCommunityOnboardingHarness: (...args: unknown[]) => mocks.recoverHarness(...args),
+ skipCommunityOnboarding: vi.fn(),
startCommunityOnboarding: vi.fn(),
- useCommunityOnboarding: () => ({
- status: "active",
- stage: "initializing",
- machineId: "machine-1",
- harness: "codex",
- identity: "work",
- }),
+ useCommunityOnboarding: () => mocks.state,
}))
vi.mock("@/stores/community", () => ({
useCommunityStore: {
@@ -36,8 +40,24 @@ vi.mock("@/contexts/community/current-user", () => ({
vi.mock("./initialize-community-onboarding", () => ({
initializeCommunityOnboarding: (...args: unknown[]) => mocks.initialize(...args),
}))
-vi.mock("./onboarding-machine-dialog", () => ({ OnboardingMachineDialog: () => null }))
-vi.mock("./onboarding-select-dialog", () => ({ OnboardingSelectDialog: () => null }))
+vi.mock("./onboarding-machine-dialog", () => ({
+ OnboardingMachineDialog: ({ onChooseAnotherHarness }: {
+ onChooseAnotherHarness: () => void
+ }) => createElement("button", {
+ "data-testid": "recover-harness",
+ onClick: onChooseAnotherHarness,
+ }),
+}))
+vi.mock("./onboarding-select-dialog", () => ({
+ OnboardingSelectDialog: ({ value, onValueChange }: {
+ value: string
+ onValueChange: (value: string) => void
+ }) => createElement("button", {
+ "data-testid": "select-harness",
+ "data-value": value,
+ onClick: () => onValueChange("codex"),
+ }),
+}))
vi.mock("./onboarding-status-dialog", () => ({
OnboardingStatusDialog: ({ status, onContinue }: {
status: string
@@ -54,8 +74,16 @@ import { CommunityOnboardingForm } from "./community-onboarding-form"
describe("CommunityOnboardingForm room navigation", () => {
beforeEach(() => {
mocks.pathname = "/c/me/machines"
+ mocks.state = {
+ status: "active",
+ stage: "initializing",
+ machineId: "machine-1",
+ harness: "codex",
+ identity: "work",
+ }
mocks.complete.mockClear()
mocks.navigate.mockClear()
+ mocks.recoverHarness.mockClear()
mocks.initialize.mockReset().mockResolvedValue({
serverId: "server-1",
publicChannelId: "channel-1",
@@ -86,4 +114,21 @@ describe("CommunityOnboardingForm room navigation", () => {
rendered.rerender(createElement(CommunityOnboardingForm))
expect(mocks.complete).toHaveBeenCalledTimes(1)
})
+
+ it("clears the local harness choice when recovering from the machine limit", () => {
+ mocks.state = { status: "active", stage: "harness" }
+ const rendered = render(createElement(CommunityOnboardingForm))
+
+ fireEvent.click(screen.getByTestId("select-harness"))
+ expect(screen.getByTestId("select-harness")).toHaveAttribute("data-value", "codex")
+
+ mocks.state = { status: "active", stage: "machine", harness: "codex" }
+ rendered.rerender(createElement(CommunityOnboardingForm))
+ fireEvent.click(screen.getByTestId("recover-harness"))
+ expect(mocks.recoverHarness).toHaveBeenCalledOnce()
+
+ mocks.state = { status: "active", stage: "harness" }
+ rendered.rerender(createElement(CommunityOnboardingForm))
+ expect(screen.getByTestId("select-harness")).toHaveAttribute("data-value", "")
+ })
})
diff --git a/src/web/src/components/community/onboarding/community-onboarding-form.tsx b/src/web/src/components/community/onboarding/community-onboarding-form.tsx
index f6a2fa896..ec046203f 100644
--- a/src/web/src/components/community/onboarding/community-onboarding-form.tsx
+++ b/src/web/src/components/community/onboarding/community-onboarding-form.tsx
@@ -7,6 +7,8 @@ import {
advanceCommunityOnboarding,
completeCommunityOnboarding,
consumeQueuedCommunityOnboarding,
+ recoverCommunityOnboardingHarness,
+ skipCommunityOnboarding,
startCommunityOnboarding,
useCommunityOnboarding,
} from "@/lib/community-onboarding"
@@ -143,6 +145,13 @@ export function CommunityOnboardingForm() {
onConnected={(machineId) => {
advanceCommunityOnboarding("machine", "identity", { machineId })
}}
+ onChooseAnotherHarness={() => {
+ setHarness("")
+ recoverCommunityOnboardingHarness()
+ }}
+ onManageMachines={() => {
+ skipCommunityOnboarding()
+ }}
/>
)
}
diff --git a/src/web/src/components/community/onboarding/onboarding-machine-dialog.dom.test.ts b/src/web/src/components/community/onboarding/onboarding-machine-dialog.dom.test.ts
index d460d73f4..289aacdf9 100644
--- a/src/web/src/components/community/onboarding/onboarding-machine-dialog.dom.test.ts
+++ b/src/web/src/components/community/onboarding/onboarding-machine-dialog.dom.test.ts
@@ -1,6 +1,6 @@
import React from "react"
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
-import { act, render } from "@/test/react-dom-harness"
+import { act, fireEvent, render } from "@/test/react-dom-harness"
const mocks = vi.hoisted(() => ({
apiFetch: vi.fn(),
@@ -54,6 +54,8 @@ describe("OnboardingMachineDialog", () => {
harness: "codex",
harnessLabel: "Codex",
onConnected: vi.fn(),
+ onChooseAnotherHarness: vi.fn(),
+ onManageMachines: vi.fn(),
}))
act(() => mockedSteps.mock.calls.at(-1)![0].onRetry())
@@ -72,6 +74,8 @@ describe("OnboardingMachineDialog", () => {
harness: "codex",
harnessLabel: "Codex",
onConnected: vi.fn(),
+ onChooseAnotherHarness: vi.fn(),
+ onManageMachines: vi.fn(),
previewCommand: "pair preview-token",
}))
@@ -82,4 +86,33 @@ describe("OnboardingMachineDialog", () => {
connectedHostname: null,
})
})
+
+ it("turns a machine limit rejection into explicit recovery actions", async () => {
+ const onChooseAnotherHarness = vi.fn()
+ const onManageMachines = vi.fn()
+ mocks.apiFetch.mockRejectedValue(new Error("MACHINE_LIMIT_REACHED"))
+
+ const view = render(React.createElement(OnboardingMachineDialog, {
+ open: true,
+ harness: "codex",
+ harnessLabel: "Codex",
+ onConnected: vi.fn(),
+ onChooseAnotherHarness,
+ onManageMachines,
+ }))
+
+ await act(async () => {
+ await Promise.resolve()
+ await Promise.resolve()
+ })
+
+ expect(view.getByRole("alert", { hidden: true })).toHaveTextContent("Machine limit reached")
+ expect(view.getByRole("alert", { hidden: true })).not.toHaveTextContent("Couldn’t prepare the command")
+ expect(mocks.refetch).toHaveBeenCalledOnce()
+
+ fireEvent.click(view.getByRole("button", { name: "Choose another harness", hidden: true }))
+ fireEvent.click(view.getByRole("button", { name: "Manage machines", hidden: true }))
+ expect(onChooseAnotherHarness).toHaveBeenCalledOnce()
+ expect(onManageMachines).toHaveBeenCalledOnce()
+ })
})
diff --git a/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx b/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
index 02f3f4bce..9a7ff5f4c 100644
--- a/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
+++ b/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
@@ -2,6 +2,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { isPresenceOnline } from "@alook/shared"
+import { CircleAlert } from "lucide-react"
import { toast } from "sonner"
import {
@@ -27,6 +28,8 @@ export function OnboardingMachineDialog({
harness,
harnessLabel,
onConnected,
+ onChooseAnotherHarness,
+ onManageMachines,
previewConnectedMachine,
previewCommand,
}: {
@@ -34,6 +37,8 @@ export function OnboardingMachineDialog({
harness: string
harnessLabel: string
onConnected: (machineId: string) => void
+ onChooseAnotherHarness: () => void
+ onManageMachines: () => void
previewConnectedMachine?: { id: string; hostname: string }
previewCommand?: string
}) {
@@ -52,6 +57,7 @@ export function OnboardingMachineDialog({
const [tokenId, setTokenId] = useState<string | null>(null)
const [generating, setGenerating] = useState(false)
const [generateError, setGenerateError] = useState<string | null>(null)
+ const [machineLimitReached, setMachineLimitReached] = useState(false)
const generationInFlight = useRef(false)
const generateCommand = useCallback(async () => {
@@ -59,19 +65,25 @@ export function OnboardingMachineDialog({
generationInFlight.current = true
setGenerating(true)
setGenerateError(null)
+ setMachineLimitReached(false)
try {
const result = await apiFetch<{ tokenId: string; expiresAt: string }>(
"/api/community/machines/pair",
{ method: "POST" },
)
setTokenId(result.tokenId)
- } catch {
+ } catch (error) {
+ if (error instanceof Error && error.message === "MACHINE_LIMIT_REACHED") {
+ setMachineLimitReached(true)
+ void refetch()
+ return
+ }
setGenerateError("Couldn’t prepare the command. Try again.")
} finally {
generationInFlight.current = false
setGenerating(false)
}
- }, [])
+ }, [refetch])
useEffect(() => {
if (
@@ -82,6 +94,7 @@ export function OnboardingMachineDialog({
previewCommand ||
tokenId ||
generating ||
+ machineLimitReached ||
generateError
) return
void generateCommand()
@@ -90,6 +103,7 @@ export function OnboardingMachineDialog({
generateError,
generating,
isSuccess,
+ machineLimitReached,
onlineMachine,
open,
previewConnectedMachine,
@@ -152,25 +166,50 @@ export function OnboardingMachineDialog({
</DialogHeader>
<div className="flex flex-col gap-4 px-4 pb-4 sm:px-6 sm:pb-6">
- <PairMachineSteps
- command={displayedCommand}
- generating={
- !previewConnectedMachine
- && !previewCommand
- && (!isSuccess || generating || (!command && !generateError))
- }
- generationError={generateError}
- onRetry={() => void generateCommand()}
- onCopy={() => void copyCommand()}
- connectedHostname={
- previewConnectedMachine?.hostname
- ?? (onlineMachine ? onlineMachine.hostname || "Your machine" : null)
- }
- headingAs="div"
- concise
- />
+ {machineLimitReached && !onlineMachine ? (
+ <section
+ role="alert"
+ className="flex flex-col gap-3 rounded-xl border border-warning/30 bg-warning/5 p-4"
+ >
+ <div className="flex items-start gap-3">
+ <CircleAlert aria-hidden className="mt-0.5 size-5 shrink-0 text-warning" />
+ <div className="flex min-w-0 flex-col gap-1">
+ <h3 className="text-sm font-medium text-foreground">Machine limit reached</h3>
+ <p className="text-sm leading-relaxed text-muted-foreground">
+ Your plan can’t connect another machine. Choose a harness already available on an online machine, or manage your machines and restart setup.
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-col gap-2 sm:flex-row sm:justify-end">
+ <Button type="button" variant="outline" onClick={onChooseAnotherHarness}>
+ Choose another harness
+ </Button>
+ <Button type="button" onClick={onManageMachines}>
+ Manage machines
+ </Button>
+ </div>
+ </section>
+ ) : (
+ <PairMachineSteps
+ command={displayedCommand}
+ generating={
+ !previewConnectedMachine
+ && !previewCommand
+ && (!isSuccess || generating || (!command && !generateError))
+ }
+ generationError={generateError}
+ onRetry={() => void generateCommand()}
+ onCopy={() => void copyCommand()}
+ connectedHostname={
+ previewConnectedMachine?.hostname
+ ?? (onlineMachine ? onlineMachine.hostname || "Your machine" : null)
+ }
+ headingAs="div"
+ concise
+ />
+ )}
- {!previewConnectedMachine && !onlineMachine && connectedMachine ? (
+ {!machineLimitReached && !previewConnectedMachine && !onlineMachine && connectedMachine ? (
<p role="status" className="text-sm text-muted-foreground">
{harnessLabel} isn’t available on {connectedMachine.hostname || "this machine"} yet.
</p>
diff --git a/src/web/src/components/community/onboarding/onboarding-select-dialog.preview.tsx b/src/web/src/components/community/onboarding/onboarding-select-dialog.preview.tsx
index 1f431b6a7..3eee00e59 100644
--- a/src/web/src/components/community/onboarding/onboarding-select-dialog.preview.tsx
+++ b/src/web/src/components/community/onboarding/onboarding-select-dialog.preview.tsx
@@ -110,6 +110,16 @@ export function OnboardingSelectDialogPreview({
setMode("identity")
setValue("")
}}
+ onChooseAnotherHarness={() => {
+ setHarness("")
+ setValue("")
+ setMode("harness")
+ }}
+ onManageMachines={() => {
+ setHarness("")
+ setValue("")
+ setMode("harness")
+ }}
/>
)
}
diff --git a/src/web/src/components/community/shell/shell-frame-view.dom.test.ts b/src/web/src/components/community/shell/shell-frame-view.dom.test.ts
index a384c7f11..b80dd4a12 100644
--- a/src/web/src/components/community/shell/shell-frame-view.dom.test.ts
+++ b/src/web/src/components/community/shell/shell-frame-view.dom.test.ts
@@ -36,6 +36,8 @@ const mocks = vi.hoisted(() => ({
overlayProps: vi.fn(),
pendingProps: vi.fn(),
channelSkeletonProps: vi.fn(),
+ userBarProps: vi.fn(),
+ runningBots: [] as Array<{ id: string }>,
}))
vi.mock("react-resizable-panels", () => ({
@@ -53,6 +55,13 @@ vi.mock("./use-hydrated-client", () => ({
vi.mock("@/hooks/use-mobile", () => ({
useBreakpoint: () => "desktop",
}))
+vi.mock("@/hooks/community/use-running-owned-bots", () => ({
+ useRunningOwnedBots: () => ({
+ runningBots: mocks.runningBots,
+ initialLoading: false,
+ unavailable: false,
+ }),
+}))
vi.mock("@/components/ui/resizable", () => ({
ResizablePanelGroup: ({ children, ...props }: Record<string, unknown>) => {
useLayoutEffect(() => {
@@ -113,7 +122,10 @@ vi.mock("./server-rail", () => ({
ServerRailPending: () => createElement("div", { "data-server-rail-pending": "" }),
}))
vi.mock("./user-bar", () => ({
- UserBar: () => createElement("div", { "data-user-bar": "" }),
+ UserBar: (props: Record<string, unknown>) => {
+ mocks.userBarProps(props)
+ return createElement("div", { "data-user-bar": "" })
+ },
UserBarSkeleton: () => createElement("div", { "data-user-bar-skeleton": "" }),
}))
vi.mock("./community-inbox-popover", () => ({
@@ -226,6 +238,8 @@ describe("ShellFrameView", () => {
mocks.overlayProps.mockClear()
mocks.pendingProps.mockClear()
mocks.channelSkeletonProps.mockClear()
+ mocks.userBarProps.mockClear()
+ mocks.runningBots = []
mocks.defaultLayout.current = undefined
mocks.hydratedClient.current = true
animateDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "animate")
@@ -285,6 +299,71 @@ describe("ShellFrameView", () => {
)?.className).toContain("max-sm:hidden")
})
+ it("projects the shared live running-bot count into the User Bar", () => {
+ mocks.runningBots = [{ id: "bot_1" }, { id: "bot_2" }]
+ const renderer = render(createElement(ShellFrameView, {
+ ...extensionProps,
+ breakpoint: "desktop",
+ checkpoint: committedCheckpoint("/c/me", "list"),
+ sidebar: () => createElement("sidebar-content"),
+ cancelPendingNavigation: vi.fn(),
+ rail,
+ profile,
+ inbox,
+ }, createElement("main-content")))
+
+ expect(latestProps(mocks.userBarProps).user).toMatchObject({
+ id: "u1",
+ runningBotCount: 2,
+ })
+ renderer.unmount()
+ })
+
+ it("gives the desktop User Bar popup a separate companion only while a bot is working", () => {
+ mocks.runningBots = [{ id: "bot_1" }]
+ const selfProfile = {
+ ...profile,
+ profile: {
+ data: { name: "User", userId: "u1", mutual: 0 },
+ x: 0,
+ y: 0,
+ },
+ } as never
+ const renderer = render(createElement(ShellFrameView, {
+ ...extensionProps,
+ userBarExtension: { active: "profile", update: null },
+ breakpoint: "desktop",
+ checkpoint: committedCheckpoint("/c/me", "list"),
+ sidebar: () => createElement("sidebar-content"),
+ cancelPendingNavigation: vi.fn(),
+ rail,
+ profile: selfProfile,
+ inbox,
+ }, createElement("main-content")))
+
+ const workingExtension = latestProps(mocks.userBarProps).extension as Record<string, unknown>
+ expect(workingExtension.profile).toBeTruthy()
+ expect(workingExtension.profileCompanion).toBeTruthy()
+
+ mocks.runningBots = []
+ renderer.rerender(createElement(ShellFrameView, {
+ ...extensionProps,
+ userBarExtension: { active: "profile", update: null },
+ breakpoint: "desktop",
+ checkpoint: committedCheckpoint("/c/me", "list"),
+ sidebar: () => createElement("sidebar-content"),
+ cancelPendingNavigation: vi.fn(),
+ rail,
+ profile: selfProfile,
+ inbox,
+ }, createElement("main-content")))
+
+ const idleExtension = latestProps(mocks.userBarProps).extension as Record<string, unknown>
+ expect(idleExtension.profile).toBeTruthy()
+ expect(idleExtension.profileCompanion).toBeNull()
+ renderer.unmount()
+ })
+
it("keeps rail, sidebar, and UserBar in the unknown list shell", async () => {
const renderer = render(createElement(ShellFrameView, {
...extensionProps,
diff --git a/src/web/src/components/community/shell/shell-frame-view.tsx b/src/web/src/components/community/shell/shell-frame-view.tsx
index d831c07a7..d1feb7f8f 100644
--- a/src/web/src/components/community/shell/shell-frame-view.tsx
+++ b/src/web/src/components/community/shell/shell-frame-view.tsx
@@ -19,6 +19,8 @@ import type { useShellDaemonUpdateController } from "./use-shell-daemon-update-c
import type { UserBarExtensionState } from "./user-bar-extension-state"
import { userBarUpdateBadgePhase } from "./user-bar-extension-state"
import type { OpenProfile } from "../social/profile-types"
+import { useRunningOwnedBots } from "@/hooks/community/use-running-owned-bots"
+import { ProfileRunningBotsCard } from "@/components/community/social/profile-running-bots-card"
type Props = Pick<ShellFrameProps, "sidebar" | "children" | "extraDialogs"> & {
breakpoint: Breakpoint
@@ -53,6 +55,7 @@ export function ShellFrameView({
dismissUserBarExtension,
}: Props) {
const { surface } = checkpoint
+ const { runningBots } = useRunningOwnedBots()
const inboxElement = (
<InboxPopover
{...inbox.popoverProps}
@@ -63,6 +66,7 @@ export function ShellFrameView({
id: profile.currentUser.id,
name: profile.currentUser.name,
avatar: profile.currentUser.avatar,
+ runningBotCount: runningBots.length,
}
const isInitial = breakpoint === "unknown"
const profileInExtension = userBarExtension.active === "profile"
@@ -82,6 +86,12 @@ export function ShellFrameView({
extension
/>
) : null
+ const profileCompanionElement = profileInExtension && runningBots.length > 0 ? (
+ <ProfileRunningBotsCard
+ onOpenBotAudit={profile.openBotAudit}
+ useBackdropEffect={breakpoint !== "mobile"}
+ />
+ ) : null
return (
<CommunityShellLayout
@@ -117,6 +127,7 @@ export function ShellFrameView({
active: userBarExtension.active,
inbox: inboxElement,
profile: profileElement,
+ profileCompanion: profileCompanionElement,
update: daemonUpdate.update,
updateBadgePhase: userBarUpdateBadgePhase(userBarExtension),
eligibleMachines: daemonUpdate.eligibleMachines,
diff --git a/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx b/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
index e20efef66..413b0d1df 100644
--- a/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
+++ b/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
@@ -34,6 +34,36 @@ const machines = [{
}]
describe("UserBarExtensionSlot", () => {
+ it("uses a real bounded mobile scroll container without shrinking either profile card", () => {
+ const renderer = render(createElement(UserBarExtensionSlot, {
+ active: "profile",
+ profile: createElement("div", { "data-testid": "profile-content" }, "Profile"),
+ profileCompanion: createElement("div", { "data-testid": "profile-companion" }, "Running bots"),
+ update: null,
+ eligibleMachines: [],
+ onDismiss: vi.fn(),
+ onRequestUpdate: vi.fn(),
+ presentation: "slot",
+ }))
+
+ const slot = renderer.getByTestId(tid.userBarExtension)
+ const scroller = renderer.getByTestId("profile-content").parentElement?.parentElement
+ expect(slot.style.maxHeight).toContain("100dvh")
+ expect(slot.className).toContain("bg-transparent")
+ expect(slot.className).toContain("shadow-none")
+ expect(slot.className).not.toContain("border-border/40")
+ expect(slot.className).not.toContain("border-x")
+ expect(slot.className).not.toContain("border-t")
+ expect(scroller?.className).toContain("min-h-0")
+ expect(scroller?.className).toContain("overflow-y-auto")
+ expect(scroller?.style.maxHeight).toContain("100dvh")
+ expect(renderer.getByTestId("profile-content").parentElement?.className).toContain("shrink-0")
+ const companionSurface = renderer.getByTestId("profile-companion").parentElement
+ expect(companionSurface?.className).toContain("shrink-0")
+ expect(companionSurface?.className).toContain("-mx-2")
+ expect(companionSurface?.className).toContain("mb-2")
+ })
+
it("disables dismissal and focus while retained for the closing animation", async () => {
const onDismiss = vi.fn()
const onInitialFocus = vi.fn()
diff --git a/src/web/src/components/community/shell/user-bar-extension-slot.tsx b/src/web/src/components/community/shell/user-bar-extension-slot.tsx
index 7afabefcf..bc536f0aa 100644
--- a/src/web/src/components/community/shell/user-bar-extension-slot.tsx
+++ b/src/web/src/components/community/shell/user-bar-extension-slot.tsx
@@ -28,6 +28,7 @@ type Props = {
active: Exclude<UserBarExtensionKind, "none">
inbox?: ReactNode
profile?: ReactNode
+ profileCompanion?: ReactNode
update: UserBarUpdateState | null
eligibleMachines: readonly MachineSummary[]
onDismiss: () => void
@@ -44,6 +45,7 @@ export function UserBarExtensionSlot({
active,
inbox,
profile,
+ profileCompanion,
update,
eligibleMachines,
onDismiss,
@@ -56,6 +58,8 @@ export function UserBarExtensionSlot({
presentation = "slot",
}: Props) {
const ref = useRef<HTMLDivElement>(null)
+ const boundedHeight = `min(28rem, max(0px, calc(100dvh - ${COMMUNITY_USER_BAR_HEIGHT_CSS} - var(--app-safe-area-top))))`
+ const unframedMobileProfile = presentation === "slot" && active === "profile"
useEffect(() => {
if (!interactive) return
@@ -103,21 +107,32 @@ export function UserBarExtensionSlot({
data-presentation={presentation}
tabIndex={-1}
className={cn(
- "relative min-h-0 origin-bottom overflow-hidden border-border/40 bg-popover text-popover-foreground shadow-(--e2)",
- presentation === "popup" ? "rounded-xl border" : "rounded-t-xl border-x border-t [clip-path:inset(-2rem_-2rem_0)]",
+ "relative min-h-0 origin-bottom overflow-hidden text-popover-foreground",
+ unframedMobileProfile
+ ? "bg-transparent shadow-none [clip-path:inset(-2rem_-2rem_0)]"
+ : "border-border/40 bg-popover shadow-(--e2)",
+ presentation === "popup"
+ ? "rounded-xl border"
+ : !unframedMobileProfile && "rounded-t-xl border-x border-t [clip-path:inset(-2rem_-2rem_0)]",
animate && "motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-safe:duration-150",
active === "inbox" && "flex flex-col",
)}
style={{
- maxHeight: `min(28rem, max(0px, calc(100dvh - ${COMMUNITY_USER_BAR_HEIGHT_CSS} - var(--app-safe-area-top))))`,
+ maxHeight: boundedHeight,
height: active === "inbox"
- ? `min(28rem, max(0px, calc(100dvh - ${COMMUNITY_USER_BAR_HEIGHT_CSS} - var(--app-safe-area-top))))`
+ ? boundedHeight
: undefined,
}}
>
{active === "inbox" && inbox}
{active === "profile" && (
- <div className="overflow-y-auto thin-scrollbar p-2">{profile}</div>
+ <div
+ className="flex min-h-0 flex-col gap-2 overflow-y-auto p-2 thin-scrollbar"
+ style={{ maxHeight: boundedHeight }}
+ >
+ {profileCompanion && <div className="-mx-2 mb-2 shrink-0">{profileCompanion}</div>}
+ <div className="shrink-0">{profile}</div>
+ </div>
)}
{active === "update" && update && (
<DaemonUpdateExtension
diff --git a/src/web/src/components/community/shell/user-bar-popover.dom.test.tsx b/src/web/src/components/community/shell/user-bar-popover.dom.test.tsx
new file mode 100644
index 000000000..f2c079f2d
--- /dev/null
+++ b/src/web/src/components/community/shell/user-bar-popover.dom.test.tsx
@@ -0,0 +1,51 @@
+import { createElement, forwardRef, type ReactNode } from "react"
+import { describe, expect, it, vi } from "vitest"
+import { render } from "@/test/react-dom-harness"
+import { tid } from "@/lib/community/testids"
+
+vi.mock("@/components/ui/popover", () => ({
+ Popover: ({ children }: { children: ReactNode }) => createElement("div", null, children),
+ PopoverPortal: ({ children }: { children: ReactNode }) => createElement("div", null, children),
+ PopoverPositioner: ({ children }: { children: ReactNode }) => createElement("div", null, children),
+ PopoverPopup: forwardRef<HTMLDivElement, { children: ReactNode; className?: string }>(
+ function MockPopoverPopup({ children, className }, ref) {
+ return createElement("div", { ref, className }, children)
+ },
+ ),
+}))
+
+vi.mock("@/components/community/social/profile-secondary-position", () => ({
+ useProfileSecondaryPosition: () => ({
+ popoverRef: { current: null },
+ cardRef: { current: null },
+ previewRef: { current: null },
+ position: { placement: "right", left: 328, top: 0, height: 260 },
+ ready: true,
+ }),
+}))
+
+import { UserBarPopover } from "./user-bar-popover"
+
+describe("UserBarPopover", () => {
+ it("keeps the complete profile as the anchor and docks its companion independently", () => {
+ const renderer = render(
+ <UserBarPopover
+ anchor={{ current: null }}
+ onDismiss={vi.fn()}
+ onEscape={vi.fn()}
+ companion={createElement("section", { "data-testid": "companion" }, "Running bots")}
+ >
+ <article data-testid="profile">Full profile</article>
+ </UserBarPopover>,
+ )
+
+ const profile = renderer.getByTestId("profile")
+ const dock = renderer.getByTestId(tid.userBarProfileSecondaryDock)
+ expect(profile.parentElement?.nextElementSibling).toBe(dock)
+ expect(dock).toHaveAttribute("data-placement", "right")
+ expect(dock).toHaveAttribute("data-measurement-ready", "true")
+ expect(dock.style.left).toBe("328px")
+ expect(dock.style.height).toBe("260px")
+ expect(renderer.getByTestId("companion")).toBeInTheDocument()
+ })
+})
diff --git a/src/web/src/components/community/shell/user-bar-popover.tsx b/src/web/src/components/community/shell/user-bar-popover.tsx
index c3628f158..8e0001d66 100644
--- a/src/web/src/components/community/shell/user-bar-popover.tsx
+++ b/src/web/src/components/community/shell/user-bar-popover.tsx
@@ -3,13 +3,23 @@
import type { ReactNode, RefObject } from "react"
import { Popover, PopoverPortal, PopoverPositioner, PopoverPopup } from "@/components/ui/popover"
import { tid } from "@/lib/community/testids"
+import { useProfileSecondaryPosition } from "@/components/community/social/profile-secondary-position"
-export function UserBarPopover({ anchor, children, onDismiss, onEscape }: {
+export function UserBarPopover({ anchor, children, companion, onDismiss, onEscape }: {
anchor: RefObject<HTMLElement | null>
children: ReactNode
+ companion?: ReactNode
onDismiss: () => void
onEscape: () => void
}) {
+ const {
+ popoverRef,
+ cardRef,
+ previewRef,
+ position,
+ ready,
+ } = useProfileSecondaryPosition(Boolean(companion), "user-bar-profile", 0, 0)
+
return (
<Popover open onOpenChange={(open, details) => {
if (open) return
@@ -26,12 +36,32 @@ export function UserBarPopover({ anchor, children, onDismiss, onEscape }: {
<PopoverPortal>
<PopoverPositioner anchor={anchor} side="top" align="start" sideOffset={8}>
<PopoverPopup
+ ref={popoverRef}
role="presentation"
- className="w-80 max-w-[calc(100vw-1rem)] border-0 bg-transparent p-0 shadow-none"
+ className={`relative w-80 max-w-[calc(100vw-1rem)] border-0 bg-transparent p-0 shadow-none ${companion && !ready ? "overflow-hidden" : "overflow-visible"}`}
initialFocus={() => document.getElementById("community-user-bar-extension")}
finalFocus={false}
>
- {children}
+ <div ref={cardRef}>{children}</div>
+ {companion && (
+ <div
+ ref={previewRef}
+ data-testid={tid.userBarProfileSecondaryDock}
+ data-placement={position?.placement}
+ data-measurement-ready={ready ? "true" : "false"}
+ aria-hidden={!ready}
+ className="absolute w-full"
+ style={{
+ left: position?.left ?? 0,
+ top: position?.top ?? 0,
+ height: position?.height,
+ visibility: ready ? "visible" : "hidden",
+ pointerEvents: ready ? undefined : "none",
+ }}
+ >
+ {companion}
+ </div>
+ )}
</PopoverPopup>
</PopoverPositioner>
</PopoverPortal>
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 ff9038e3e..f484c93ea 100644
--- a/src/web/src/components/community/shell/user-bar.test.ts
+++ b/src/web/src/components/community/shell/user-bar.test.ts
@@ -1,10 +1,46 @@
import { createElement } from "react"
import { renderToStaticMarkup } from "react-dom/server"
+import { readFileSync } from "node:fs"
import { describe, expect, it } from "vitest"
import { UserBar, UserBarSkeleton } from "./user-bar"
import { tid } from "@/lib/community/testids"
describe("UserBar", () => {
+ it("adds a geometry-neutral running-bot ring and accessible count only while bots are live", () => {
+ const running = renderToStaticMarkup(createElement(UserBar, {
+ breakpoint: "desktop",
+ user: { id: "u1", name: "User", avatar: "U", runningBotCount: 2 },
+ }))
+ const idle = renderToStaticMarkup(createElement(UserBar, {
+ breakpoint: "desktop",
+ user: { id: "u1", name: "User", avatar: "U", runningBotCount: 0 },
+ }))
+
+ 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("pointer-events-none absolute -inset-0.5")
+ expect(running).toContain("focus-visible:ring-offset-4")
+ expect(running).toContain("focus-visible:ring-offset-muted")
+ expect(running).toContain("var(--primary)")
+ expect(running).not.toContain("var(--status-online)")
+ expect(idle).toContain('aria-label="Open profile"')
+ expect(idle).not.toContain(tid.userBarRunningBotsRing)
+ expect(idle).not.toContain(tid.userBarRunningBotsGlow)
+ })
+
+ it("keeps the gradient ring static while reduced motion disables only its glow", () => {
+ const css = readFileSync(new URL("../../../app/globals.css", import.meta.url), "utf8")
+ const reducedMotion = css.slice(css.indexOf("@keyframes user-bar-running-bots-breathe"))
+
+ expect(reducedMotion).toContain(".user-bar-running-bots-glow")
+ expect(reducedMotion).toContain("animation: user-bar-running-bots-breathe 2.8s")
+ expect(reducedMotion).toContain("@media (prefers-reduced-motion: reduce)")
+ expect(reducedMotion).toContain("animation: none")
+ expect(reducedMotion).not.toContain("community-user-bar-running-bots-ring")
+ })
+
it("keeps the name shrinkable and truncated while the action group stays fixed", () => {
const html = renderToStaticMarkup(createElement(UserBar, {
breakpoint: "desktop",
@@ -82,6 +118,25 @@ describe("UserBar", () => {
expect(closedHtml).toContain(
'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 rounded-xl"',
)
+
+ const profileHtml = renderToStaticMarkup(createElement(UserBar, {
+ breakpoint: "mobile",
+ user: { id: "u1", name: "User", avatar: "U" },
+ extension: {
+ active: "profile",
+ inbox: null,
+ profile: createElement("div", null, "Profile"),
+ update: null,
+ updateBadgePhase: null,
+ eligibleMachines: [],
+ onOpenUpdate: () => {},
+ onRequestUpdate: () => {},
+ onDismiss: () => {},
+ },
+ }))
+ expect(profileHtml).toContain(
+ 'class="flex h-12 items-center gap-3 border border-border/40 bg-muted px-4 rounded-xl"',
+ )
})
it("preserves the desktop Inbox name while mobile exposes open state", () => {
diff --git a/src/web/src/components/community/shell/user-bar.tsx b/src/web/src/components/community/shell/user-bar.tsx
index 5209a02ff..729b26c6d 100644
--- a/src/web/src/components/community/shell/user-bar.tsx
+++ b/src/web/src/components/community/shell/user-bar.tsx
@@ -31,6 +31,7 @@ type UserBarExtension = {
active: UserBarExtensionKind
inbox: ReactNode
profile: ReactNode
+ profileCompanion?: ReactNode
update: UserBarUpdateState | null
updateBadgePhase: Exclude<UserBarUpdatePhase, "expanded"> | null
eligibleMachines: readonly MachineSummary[]
@@ -41,7 +42,7 @@ type UserBarExtension = {
export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnread, unreadCount, unreadCountPartial, inboxOpen, onInboxOpenChange, extension }: {
breakpoint: Breakpoint
- user: { id: string; name: string; avatar: string; presence?: Presence }
+ user: { id: string; name: string; avatar: string; presence?: Presence; runningBotCount?: number }
onOpenProfile?: OpenProfile
onEditProfile?: () => void
inbox?: ReactNode
@@ -60,6 +61,10 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
const baseRef = useRef<HTMLDivElement>(null)
const [pendingExtensionFocus, setPendingExtensionFocus] = useState<UserBarExtensionKind>("none")
const mobile = breakpoint === "mobile"
+ const joinedMobileExtension = mobile && (
+ inboxOpen
+ || Boolean(extension && extension.active !== "none" && extension.active !== "profile")
+ )
const closeInboxForAction = () => {
if (inboxOpen) onInboxOpenChange?.(false)
}
@@ -80,6 +85,7 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
active={extension.active}
inbox={extension.inbox}
profile={extension.profile}
+ profileCompanion={mobile ? extension.profileCompanion : undefined}
update={extension.update}
eligibleMachines={extension.eligibleMachines}
onDismiss={dismissExtensionWithFocus}
@@ -105,6 +111,7 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
: extensionContent && extension && (
<UserBarPopover
anchor={baseRef}
+ companion={extension.active === "profile" ? extension.profileCompanion : undefined}
onDismiss={extension.onDismiss}
onEscape={dismissExtensionWithFocus}
>
@@ -116,7 +123,7 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
data-slot="community-user-bar-base"
className={cn(
"flex h-12 items-center gap-3 border border-border/40 bg-muted px-4",
- mobile && ((extension && extension.active !== "none") || inboxOpen)
+ joinedMobileExtension
? "rounded-b-xl"
: "rounded-xl",
)}
@@ -165,7 +172,7 @@ export function UserBarSkeleton() {
function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnread, unreadCount, unreadCountPartial, inboxOpen, onInboxOpenChange, closeInboxForAction, profileTriggerRef, profileNameTriggerRef, lastProfileTriggerRef, inboxTriggerRef, updateBadgeRef, onRequestExtensionFocus, extension }: {
breakpoint: Breakpoint
- user: { id: string; name: string; avatar: string; presence?: Presence }
+ user: { id: string; name: string; avatar: string; presence?: Presence; runningBotCount?: number }
onOpenProfile?: OpenProfile
onEditProfile?: () => void
inbox?: ReactNode
@@ -185,6 +192,8 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
}) {
const inboxDescriptionId = useId()
const mobile = breakpoint === "mobile"
+ const runningBotCount = user.runningBotCount ?? 0
+ const hasRunningBots = runningBotCount > 0
const updateBadgeLabel = extension?.updateBadgePhase === "retry"
? "Retry machine update"
: extension?.updateBadgePhase === "updating"
@@ -204,8 +213,28 @@ 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:outline-none" aria-expanded={extension ? extension.active === "profile" : undefined} aria-controls={extension?.active === "profile" ? "community-user-bar-extension" : undefined}>
- <Avatar label={user.avatar} seed={user.id} size={28} presence={user.presence} ringColor="var(--muted)" />
+ }} 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
+ ? `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">
+ {hasRunningBots && (
+ <>
+ <span
+ data-testid={tid.userBarRunningBotsGlow}
+ aria-hidden
+ className="user-bar-running-bots-glow pointer-events-none absolute -inset-1 rounded-full opacity-40 blur-[5px] [background:conic-gradient(from_30deg,var(--link),var(--primary),var(--link))]"
+ />
+ <span
+ data-testid={tid.userBarRunningBotsRing}
+ aria-hidden
+ className="pointer-events-none absolute -inset-0.5 rounded-full [background:conic-gradient(from_30deg,var(--link),var(--primary),var(--link))]"
+ />
+ </>
+ )}
+ <span className="relative rounded-full">
+ <Avatar label={user.avatar} seed={user.id} size={28} presence={user.presence} ringColor="var(--muted)" />
+ </span>
+ </span>
</button>
<button ref={profileNameTriggerRef} onClick={(e) => {
lastProfileTriggerRef.current = e.currentTarget
diff --git a/src/web/src/components/community/social/bot-audit-preview.dom.test.ts b/src/web/src/components/community/social/bot-audit-preview.dom.test.ts
index 701dc3061..a29a857a7 100644
--- a/src/web/src/components/community/social/bot-audit-preview.dom.test.ts
+++ b/src/web/src/components/community/social/bot-audit-preview.dom.test.ts
@@ -22,11 +22,11 @@ vi.mock("lucide-react", () => ({
Lock: "lock-icon",
}))
+import { BotAuditPreview } from "./bot-audit-preview"
import {
- BotAuditPreview,
isBotActivityActive,
isBotActivityRunning,
-} from "./bot-audit-preview"
+} from "@/lib/community/bot-activity-status"
const globalCss = readFileSync(resolve(
process.cwd(),
diff --git a/src/web/src/components/community/social/bot-audit-preview.tsx b/src/web/src/components/community/social/bot-audit-preview.tsx
index baad7291a..fa223e07c 100644
--- a/src/web/src/components/community/social/bot-audit-preview.tsx
+++ b/src/web/src/components/community/social/bot-audit-preview.tsx
@@ -2,10 +2,6 @@
/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V4 */
-import {
- BOT_ACTIVITY_PRESETS,
- RUNNING_PRESETS,
-} from "@alook/shared"
import { Activity, ChevronRight, Lock } from "lucide-react"
import { useEffect, useState } from "react"
import { useBotAuditPreview } from "@/hooks/community/use-bot-audit-preview"
@@ -16,36 +12,11 @@ import {
} from "@/lib/community/audit-event-summary"
import { tid } from "@/lib/community/testids"
-type StatusPair = { emoji: string; text: string }
type BotAuditTone = "default" | "note"
const BOT_NOTE_ROW_CLASS = "grid min-h-5 shrink-0 grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2 px-[2px] text-xs leading-5"
const BOT_NOTE_TIME_CLASS = "whitespace-nowrap font-mono text-[10px] tabular-nums text-black"
-function matchesStatus(
- emoji: string | null | undefined,
- text: string | null | undefined,
- pair: StatusPair,
-): boolean {
- return emoji === pair.emoji && text === pair.text
-}
-
-export function isBotActivityActive(
- emoji: string | null | undefined,
- text: string | null | undefined,
-): boolean {
- return matchesStatus(emoji, text, BOT_ACTIVITY_PRESETS.starting)
- || matchesStatus(emoji, text, BOT_ACTIVITY_PRESETS.stopping)
- || isBotActivityRunning(emoji, text)
-}
-
-export function isBotActivityRunning(
- emoji: string | null | undefined,
- text: string | null | undefined,
-): boolean {
- return RUNNING_PRESETS.some((pair) => matchesStatus(emoji, text, pair))
-}
-
export function BotAuditPreview({
botId,
active,
diff --git a/src/web/src/components/community/social/profile-card-surface.dom.test.ts b/src/web/src/components/community/social/profile-card-surface.dom.test.ts
index ef6a8209b..5cf4051ea 100644
--- a/src/web/src/components/community/social/profile-card-surface.dom.test.ts
+++ b/src/web/src/components/community/social/profile-card-surface.dom.test.ts
@@ -48,6 +48,21 @@ vi.mock("./bot-mark-sticker", () => ({
BotMarkSticker: () => React.createElement("bot-mark-sticker"),
}))
+vi.mock("./profile-running-bots-card", () => ({
+ ProfileRunningBotsCard: () => React.createElement(
+ "section",
+ { "data-testid": "community-profile-running-bots-card" },
+ ),
+}))
+
+vi.mock("@/hooks/community/use-running-owned-bots", () => ({
+ useRunningOwnedBots: () => ({
+ runningBots: [{ id: "working-bot" }],
+ initialLoading: false,
+ unavailable: false,
+ }),
+}))
+
import { ProfileCard } from "./profile-card"
const ownedBotIdentity: Profile["identity"] = {
@@ -134,6 +149,29 @@ describe("ProfileCard surface contracts", () => {
expect(renderer.container.querySelectorAll("popover-root")).toHaveLength(0)
})
+ it("keeps the User Bar extension profile at its original single-card height", () => {
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ const renderer = render(React.createElement(
+ QueryClientProvider,
+ { client: queryClient },
+ React.createElement(ProfileCard, {
+ data: { name: "Ren", userId: "user_1", mutual: 0 },
+ x: 0,
+ y: 0,
+ bp: "desktop",
+ onClose: vi.fn(),
+ isSelf: true,
+ extension: true,
+ }),
+ ))
+
+ const profile = renderer.getByTestId("community-profile-card")
+ expect(profile.className).toBe("w-full")
+ expect(renderer.queryByTestId("community-profile-running-bots-card")).toBeNull()
+ expect(renderer.container.querySelectorAll("sheet-root")).toHaveLength(0)
+ renderer.unmount()
+ })
+
it("uses the shared modal bottom Sheet without a copied or foreground-derived overlay", () => {
const { renderer } = renderSurface("mobile")
const root = mockProps.get("sheet-root")!
diff --git a/src/web/src/components/community/social/profile-card.dom.test.ts b/src/web/src/components/community/social/profile-card.dom.test.ts
index fe4380221..cfdbed4f3 100644
--- a/src/web/src/components/community/social/profile-card.dom.test.ts
+++ b/src/web/src/components/community/social/profile-card.dom.test.ts
@@ -31,6 +31,14 @@ vi.mock("@/hooks/community/use-community-ws", () => ({
communityWsInterruptAgent: mocks.interruptAgent,
}))
+vi.mock("@/hooks/community/use-running-owned-bots", () => ({
+ useRunningOwnedBots: () => ({
+ runningBots: [{ id: "working-bot" }],
+ initialLoading: false,
+ unavailable: false,
+ }),
+}))
+
vi.mock("./bot-mark-sticker", () => ({
BotMarkSticker: ({
showStop,
@@ -56,6 +64,14 @@ vi.mock("./bot-mark-sticker", () => ({
),
}))
+vi.mock("./profile-running-bots-card", () => ({
+ ProfileRunningBotsCard: () => createElement(
+ "section",
+ { "data-testid": "community-profile-running-bots-card" },
+ "Running bots",
+ ),
+}))
+
afterEach(() => {
vi.useRealTimers()
mocks.interruptAgent.mockReset()
@@ -65,6 +81,7 @@ afterEach(() => {
function renderProfile(
overrides: Partial<Profile> = {},
activityStatus?: { emoji: string; text: string },
+ isSelf = false,
) {
mocks.profile = activityStatus
? { statusEmoji: activityStatus.emoji, statusText: activityStatus.text }
@@ -89,6 +106,7 @@ function renderProfile(
y: 0,
bp: "desktop",
onClose: () => undefined,
+ isSelf,
activityStatusEmoji: activityStatus?.emoji,
activityStatusText: activityStatus?.text,
}),
@@ -135,6 +153,14 @@ function findInterruptButton(container: HTMLElement) {
}
describe("ProfileCard contextual metadata", () => {
+ it("mounts the running-bots zone only for the signed-in user's profile", () => {
+ const self = renderProfile({}, undefined, true)
+ const peer = renderProfile()
+
+ expect(self).toContain('data-testid="community-profile-running-bots-card"')
+ expect(peer).not.toContain('data-testid="community-profile-running-bots-card"')
+ })
+
it("omits the badge when no context label exists", () => {
const html = renderProfile()
@@ -283,11 +309,13 @@ describe("ProfileCard contextual metadata", () => {
})
it("keeps the desktop main card at the anchor and independently docks the preview", () => {
- const source = readFileSync(resolve(
+ const root = resolve(
process.cwd(),
process.cwd().endsWith("/src/web") ? "" : "src/web",
- "src/components/community/social/profile-card.tsx",
- ), "utf8")
+ "src/components/community/social",
+ )
+ const source = readFileSync(resolve(root, "profile-card.tsx"), "utf8")
+ const positionSource = readFileSync(resolve(root, "profile-secondary-position.ts"), "utf8")
const desktop = source.slice(source.indexOf("// desktop:"))
const mainCard = desktop.indexOf(`data-testid={tid.profileCard}`)
const independentPreview = desktop.indexOf(`data-testid={tid.botAuditPreviewDock}`)
@@ -299,10 +327,10 @@ describe("ProfileCard contextual metadata", () => {
expect(independentPreview).toBeGreaterThan(0)
expect(independentPreview).toBeLessThan(mainCard)
expect(desktop).toContain("ref={popoverRef}")
- expect(source).toContain('addEventListener("animationend", update)')
- expect(source).toContain("cardElement.offsetWidth")
- expect(source).toContain("previewElement.offsetWidth")
- expect(source).toContain("measuredPosition?.measurementKey === measurementKey")
+ expect(positionSource).toContain('addEventListener("animationend", update)')
+ expect(positionSource).toContain("cardElement.offsetWidth")
+ expect(positionSource).toContain("previewElement.offsetWidth")
+ expect(positionSource).toContain("measuredPosition?.measurementKey === measurementKey")
expect(source).toContain("data-measurement-ready={previewReady ? \"true\" : \"false\"}")
expect(source).toContain("visibility: previewReady ? \"visible\" : \"hidden\"")
expect(source).toContain("pointerEvents: previewReady ? undefined : \"none\"")
diff --git a/src/web/src/components/community/social/profile-card.tsx b/src/web/src/components/community/social/profile-card.tsx
index 2faa61a35..1747878a9 100644
--- a/src/web/src/components/community/social/profile-card.tsx
+++ b/src/web/src/components/community/social/profile-card.tsx
@@ -1,6 +1,6 @@
"use client"
-import { useEffect, useLayoutEffect, useRef, useState } from "react"
+import { useEffect, useState } from "react"
import { Bot, MessagesSquare, Shield, UserRound } from "lucide-react"
import { BOT_ACTIVITY_PRESETS } from "@alook/shared"
import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover"
@@ -19,8 +19,19 @@ import { useCanonicalCommunityProfile } from "@/lib/community-db/projections"
import { avatarInitial } from "@/lib/community/avatar"
import { tid } from "@/lib/community/testids"
import { communityWsInterruptAgent } from "@/hooks/community/use-community-ws"
-import { isBotActivityActive, isBotActivityRunning } from "./bot-audit-preview"
+import {
+ isBotActivityActive,
+ isBotActivityRunning,
+} from "@/lib/community/bot-activity-status"
import { BotMarkSticker } from "./bot-mark-sticker"
+import { ProfileRunningBotsCard } from "./profile-running-bots-card"
+import { useRunningOwnedBots } from "@/hooks/community/use-running-owned-bots"
+import {
+ resolveAuditPreviewPlacement,
+ useProfileSecondaryPosition,
+} from "./profile-secondary-position"
+
+export { resolveAuditPreviewPlacement }
// Live cards resolve status from the global profile map. Seed props are used
// only by static, id-less showcase cards.
@@ -55,165 +66,7 @@ export function displayOwnerHandle(handle: string): string {
return handle.replace(/#\d+$/, "")
}
-export type AuditPreviewPlacement = "right" | "left" | "top" | "bottom"
-
-type RectLike = Pick<DOMRect, "top" | "right" | "bottom" | "left" | "width" | "height">
-
-export function resolveAuditPreviewPlacement({
- card,
- preview,
- viewportWidth,
- viewportHeight,
- gap = 8,
-}: {
- card: RectLike
- preview: Pick<RectLike, "width" | "height">
- viewportWidth: number
- viewportHeight: number
- gap?: number
-}): AuditPreviewPlacement {
- const room = {
- right: viewportWidth - card.right,
- left: card.left,
- top: card.top,
- bottom: viewportHeight - card.bottom,
- }
- const sideCrossAxisFits = preview.height <= viewportHeight - gap * 2
- const verticalCrossAxisFits = preview.width <= viewportWidth - gap * 2
-
- if (sideCrossAxisFits && room.right >= preview.width + gap) return "right"
- if (sideCrossAxisFits && room.left >= preview.width + gap) return "left"
- if (verticalCrossAxisFits && room.top >= preview.height + gap) return "top"
- if (verticalCrossAxisFits && room.bottom >= preview.height + gap) return "bottom"
-
- return (Object.entries(room) as Array<[AuditPreviewPlacement, number]>)
- .sort((a, b) => b[1] - a[1])[0]?.[0] ?? "right"
-}
-
-type AuditPreviewPosition = {
- placement: AuditPreviewPlacement
- left: number | string
- top: number
- height?: number
-}
-
-type MeasuredAuditPreviewPosition = AuditPreviewPosition & {
- measurementKey: string
-}
-
-function clamp(value: number, min: number, max: number): number {
- if (min > max) return value
- return Math.min(Math.max(value, min), max)
-}
-
-function useAuditPreviewPosition(
- enabled: boolean,
- previewId: string | undefined,
- x: number,
- y: number,
-) {
- const popoverRef = useRef<HTMLDivElement | null>(null)
- const cardRef = useRef<HTMLDivElement | null>(null)
- const previewRef = useRef<HTMLDivElement | null>(null)
- const [measuredPosition, setMeasuredPosition] = useState<MeasuredAuditPreviewPosition | null>(null)
- const measurementKey = enabled && previewId ? `${previewId}:${x}:${y}` : null
-
- useLayoutEffect(() => {
- if (!measurementKey) {
- setMeasuredPosition(null)
- return
- }
-
- let frame = 0
- const update = () => {
- const cardElement = cardRef.current
- const previewElement = previewRef.current
- if (!cardElement || !previewElement) return
- const transformedCard = cardElement.getBoundingClientRect()
- const card = {
- top: transformedCard.top,
- right: transformedCard.left + cardElement.offsetWidth,
- bottom: transformedCard.top + cardElement.offsetHeight,
- left: transformedCard.left,
- width: cardElement.offsetWidth,
- height: cardElement.offsetHeight,
- }
- const preview = {
- width: previewElement.offsetWidth,
- height: previewElement.offsetHeight,
- }
- const gap = 8
- const margin = 8
- const placement = resolveAuditPreviewPlacement({
- card,
- preview,
- viewportWidth: window.innerWidth,
- viewportHeight: window.innerHeight,
- gap,
- })
-
- const verticalOffset = clamp(
- 0,
- margin - card.top,
- window.innerHeight - margin - preview.height - card.top,
- )
- const horizontalOffset = clamp(
- card.width - preview.width,
- margin - card.left,
- window.innerWidth - margin - preview.width - card.left,
- )
- const next: MeasuredAuditPreviewPosition = placement === "right"
- ? { measurementKey, placement, left: card.width + gap, top: verticalOffset, height: card.height }
- : placement === "left"
- ? { measurementKey, placement, left: -preview.width - gap, top: verticalOffset, height: card.height }
- : placement === "top"
- ? { measurementKey, placement, left: horizontalOffset, top: -preview.height - gap, height: card.height }
- : { measurementKey, placement, left: horizontalOffset, top: card.height + gap, height: card.height }
-
- setMeasuredPosition((current) => current?.measurementKey === next.measurementKey
- && current.placement === next.placement
- && current.left === next.left
- && current.top === next.top
- && current.height === next.height
- ? current
- : next)
- }
-
- update()
- frame = requestAnimationFrame(update)
- window.addEventListener("resize", update)
- window.addEventListener("scroll", update, true)
- const popoverElement = popoverRef.current
- popoverElement?.addEventListener("animationend", update)
- popoverElement?.addEventListener("animationcancel", update)
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update)
- if (cardRef.current) observer?.observe(cardRef.current)
- if (previewRef.current) observer?.observe(previewRef.current)
- return () => {
- cancelAnimationFrame(frame)
- window.removeEventListener("resize", update)
- window.removeEventListener("scroll", update, true)
- popoverElement?.removeEventListener("animationend", update)
- popoverElement?.removeEventListener("animationcancel", update)
- observer?.disconnect()
- }
- }, [measurementKey])
-
- const ready = measurementKey !== null
- && measuredPosition?.measurementKey === measurementKey
- return {
- popoverRef,
- cardRef,
- previewRef,
- position: ready ? measuredPosition : null,
- ready,
- }
-}
-
-// Profile card — popover anchored at the click point on desktop, bottom sheet on mobile.
-// Identity, about, status, and presence are read from the global profile map
-// whenever a userId is present. Static cards use their supplied display data.
-export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdateStatus, onOpenOwnerProfile, onOpenBotAudit, initialStatusEmoji, initialStatusText, activityStatusEmoji, activityStatusText, embedded, extension }: {
+type ProfileCardProps = {
data: Profile
x: number
y: number
@@ -234,6 +87,23 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda
// profile interaction still uses the anchored popover / mobile sheet.
embedded?: boolean
extension?: boolean
+}
+
+export function ProfileCard(props: ProfileCardProps) {
+ if (props.isSelf && props.data.userId) return <SelfProfileCard {...props} />
+ return <ProfileCardContent {...props} hasSelfRunningBots={false} />
+}
+
+function SelfProfileCard(props: ProfileCardProps) {
+ const { runningBots } = useRunningOwnedBots()
+ return <ProfileCardContent {...props} hasSelfRunningBots={runningBots.length > 0} />
+}
+
+// Profile card — popover anchored at the click point on desktop, bottom sheet on mobile.
+// Identity, about, status, and presence are read from the global profile map
+// whenever a userId is present. Static cards use their supplied display data.
+function ProfileCardContent({ data, x, y, bp, onClose, onMessage, isSelf, onUpdateStatus, onOpenOwnerProfile, onOpenBotAudit, initialStatusEmoji, initialStatusText, activityStatusEmoji, activityStatusText, embedded, extension, hasSelfRunningBots }: ProfileCardProps & {
+ hasSelfRunningBots: boolean
}) {
const [msg, setMsg] = useState("")
const [open, setOpen] = useState(true)
@@ -271,14 +141,16 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda
const mutual = data.mutual ?? 0
const botIdentity = data.identity?.kind === "bot" ? data.identity : null
const showOwnedBotCard = Boolean(botIdentity?.ownedByViewer && data.userId)
+ const showSelfRunningBots = Boolean(isSelf && data.userId && hasSelfRunningBots)
+ const showSecondaryCards = showOwnedBotCard || showSelfRunningBots
const {
popoverRef,
cardRef,
previewRef,
position: previewPosition,
ready: previewReady,
- } = useAuditPreviewPosition(
- showOwnedBotCard && !mobile && !embedded && !extension,
+ } = useProfileSecondaryPosition(
+ showSecondaryCards && !mobile && !embedded && !extension,
data.userId,
x,
y,
@@ -460,7 +332,12 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda
</>
)
- const secondaryCards = showOwnedBotCard && data.userId ? (
+ const secondaryCards = showSelfRunningBots ? (
+ <ProfileRunningBotsCard
+ onOpenBotAudit={onOpenBotAudit}
+ useBackdropEffect={!mobile}
+ />
+ ) : showOwnedBotCard && data.userId ? (
<BotMarkSticker
botId={data.userId}
active={isBotActivityActive(activityStatus.emoji, activityStatus.text)}
diff --git a/src/web/src/components/community/social/profile-running-bots-card.dom.test.ts b/src/web/src/components/community/social/profile-running-bots-card.dom.test.ts
new file mode 100644
index 000000000..4263bf756
--- /dev/null
+++ b/src/web/src/components/community/social/profile-running-bots-card.dom.test.ts
@@ -0,0 +1,187 @@
+import { createElement } from "react"
+import { renderToStaticMarkup } from "react-dom/server"
+import { afterEach, describe, expect, it, vi } from "vitest"
+import { act, render } from "@/test/react-dom-harness"
+import type { BotSummary } from "@/hooks/community/use-bots"
+import type { CommunityProfile } from "@/lib/community/models/people"
+
+const mocks = vi.hoisted(() => ({
+ bots: [] as BotSummary[],
+ data: { bots: [] } as unknown,
+ isLoading: false,
+ isError: false,
+ profiles: new Map<string, CommunityProfile>(),
+}))
+
+vi.mock("@/hooks/community/use-bots", () => ({
+ useBots: () => ({
+ bots: mocks.bots,
+ data: mocks.data,
+ isLoading: mocks.isLoading,
+ isError: mocks.isError,
+ }),
+}))
+
+vi.mock("@/lib/community-db/projections", () => ({
+ useCanonicalProfilesByUserId: () => mocks.profiles,
+}))
+
+import {
+ ProfileRunningBotsCard,
+} from "./profile-running-bots-card"
+import { resolveRunningOwnedBots } from "@/hooks/community/use-running-owned-bots"
+
+function bot(id: string, overrides: Partial<BotSummary> = {}): BotSummary {
+ return {
+ id,
+ name: `Bot ${id}`,
+ description: "",
+ image: null,
+ avatarVersion: 0,
+ machineId: "machine_1",
+ runtime: "codex",
+ modelName: null,
+ reasoningEffort: null,
+ runtimeConfigRevision: 1,
+ isActive: true,
+ presence: "online",
+ lastRefreshContextAt: null,
+ dailyActivity: [],
+ ...overrides,
+ }
+}
+
+function renderCard(onOpenBotAudit?: (botId: string) => void) {
+ return render(createElement(ProfileRunningBotsCard, { onOpenBotAudit }))
+}
+
+afterEach(() => {
+ mocks.bots = []
+ mocks.data = { bots: [] }
+ mocks.isLoading = false
+ mocks.isError = false
+ mocks.profiles = new Map()
+})
+
+describe("resolveRunningOwnedBots", () => {
+ it("uses the exact working status instead of online presence", () => {
+ const result = resolveRunningOwnedBots([
+ bot("working-offline", { presence: "offline" }),
+ bot("idle-online"),
+ bot("inactive-working", { isActive: false }),
+ bot("online-without-status"),
+ ], new Map([
+ ["working-offline", { id: "working-offline", presence: "offline", statusEmoji: "⚡", statusText: "Working on it" }],
+ ["idle-online", { id: "idle-online", presence: "online", statusEmoji: "💤", statusText: "Idle" }],
+ ["inactive-working", { id: "inactive-working", presence: "online", statusEmoji: "🛠️", statusText: "Cooking" }],
+ ]))
+
+ expect(result.map((item) => item.id)).toEqual(["working-offline"])
+ })
+})
+
+describe("ProfileRunningBotsCard", () => {
+ it("shows live activity copy and opens the selected bot activity", async () => {
+ const onOpenBotAudit = vi.fn()
+ mocks.bots = [bot("writer", { name: "Writer" })]
+ mocks.profiles = new Map([[
+ "writer",
+ {
+ id: "writer",
+ presence: "online",
+ statusEmoji: "🛠️",
+ statusText: "Cooking",
+ },
+ ]])
+ const renderer = renderCard(onOpenBotAudit)
+
+ expect(renderer.getByLabelText("1 running bot")).toBeInTheDocument()
+ expect(renderer.getByText("Cooking")).toBeInTheDocument()
+ const row = renderer.getByRole("button", { name: "Open Writer activity" })
+ await act(async () => row.click())
+ expect(onOpenBotAudit).toHaveBeenCalledWith("writer")
+ })
+
+ it("reacts to a canonical working-state change without remounting", () => {
+ mocks.bots = [bot("runner")]
+ mocks.profiles = new Map([["runner", {
+ id: "runner",
+ presence: "online",
+ statusEmoji: "💤",
+ statusText: "Idle",
+ }]])
+ const renderer = renderCard()
+ expect(renderer.queryByTestId("community-profile-running-bots-card")).toBeNull()
+
+ mocks.profiles = new Map([["runner", {
+ id: "runner",
+ presence: "online",
+ statusEmoji: "⚡",
+ statusText: "Working on it",
+ }]])
+ renderer.rerender(createElement(ProfileRunningBotsCard))
+
+ expect(renderer.getByTestId("community-profile-running-bot-runner")).toBeInTheDocument()
+ })
+
+ it("defaults to nothing for loading, error, empty, and online-idle states", () => {
+ mocks.bots = [bot("idle")]
+ mocks.profiles = new Map([["idle", {
+ id: "idle",
+ presence: "online",
+ statusEmoji: "💤",
+ statusText: "Idle",
+ }]])
+
+ expect(renderToStaticMarkup(createElement(ProfileRunningBotsCard))).toBe("")
+ mocks.isLoading = true
+ mocks.data = undefined
+ expect(renderToStaticMarkup(createElement(ProfileRunningBotsCard))).toBe("")
+ mocks.isLoading = false
+ mocks.isError = true
+ expect(renderToStaticMarkup(createElement(ProfileRunningBotsCard))).toBe("")
+ })
+
+ it("keeps the liquid-glass and bounded-scroll surface contracts", () => {
+ mocks.bots = [bot("one"), bot("two")]
+ mocks.profiles = new Map([
+ ["one", { id: "one", statusEmoji: "⚡", statusText: "Working on it" }],
+ ["two", { id: "two", statusEmoji: "🛠️", statusText: "Cooking" }],
+ ])
+ const html = renderToStaticMarkup(createElement(ProfileRunningBotsCard))
+
+ expect(html).toContain("bg-popover/70")
+ expect(html).toContain("backdrop-blur-2xl")
+ expect(html).toContain("backdrop-saturate-150")
+ expect(html).toContain("border-foreground/10")
+ expect(html).toContain("after:bg-linear-to-br")
+ expect(html).toContain("before:via-white/60")
+ expect(html).not.toContain("status-online")
+ expect(html).not.toContain("Online ·")
+ expect(html).not.toContain('presence="online"')
+ expect(html).toContain("px-4 py-2")
+ expect(html).toContain("flex h-6 items-center gap-2")
+ expect(html).not.toContain("flex h-8 items-center")
+ expect(html).toContain("max-h-64")
+ expect(html).toContain("overflow-y-auto")
+ expect(html).toContain("thin-scrollbar")
+ expect(html).toContain("block truncate text-sm font-medium")
+ expect(html).toContain('<span class="truncate">')
+ })
+
+ it("uses a stable translucent surface when nested mobile backdrop composition is unavailable", () => {
+ mocks.bots = [bot("runner")]
+ mocks.profiles = new Map([["runner", {
+ id: "runner",
+ statusEmoji: "⚡",
+ statusText: "Working on it",
+ }]])
+ const html = renderToStaticMarkup(createElement(ProfileRunningBotsCard, {
+ useBackdropEffect: false,
+ }))
+
+ expect(html).toContain("bg-popover/95")
+ expect(html).not.toContain("backdrop-blur-2xl")
+ expect(html).not.toContain("backdrop-saturate-150")
+ })
+})
diff --git a/src/web/src/components/community/social/profile-running-bots-card.tsx b/src/web/src/components/community/social/profile-running-bots-card.tsx
new file mode 100644
index 000000000..1b744d0c0
--- /dev/null
+++ b/src/web/src/components/community/social/profile-running-bots-card.tsx
@@ -0,0 +1,103 @@
+"use client"
+
+import { useId } from "react"
+import { Bot, ChevronRight } from "lucide-react"
+import { Avatar } from "../avatar"
+import {
+ useRunningOwnedBots,
+ type RunningOwnedBot,
+} from "@/hooks/community/use-running-owned-bots"
+import { tid } from "@/lib/community/testids"
+
+function BotRow({ bot, onOpenBotAudit }: {
+ bot: RunningOwnedBot
+ onOpenBotAudit?: (botId: string) => void
+}) {
+ const content = (
+ <>
+ <Avatar
+ label={bot.name}
+ seed={bot.id}
+ src={bot.image}
+ size={32}
+ ringColor="var(--popover)"
+ />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-sm font-medium text-foreground">
+ {bot.name}
+ </span>
+ <span className="mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">
+ <span className="shrink-0" aria-hidden>{bot.activityEmoji}</span>
+ <span className="truncate">{bot.activityText}</span>
+ </span>
+ </span>
+ {onOpenBotAudit && (
+ <ChevronRight className="size-4 shrink-0 text-muted-foreground" aria-hidden />
+ )}
+ </>
+ )
+
+ if (!onOpenBotAudit) {
+ return (
+ <div
+ data-testid={tid.profileRunningBotRow(bot.id)}
+ className="flex min-h-11 items-center gap-3 px-1 py-2"
+ >
+ {content}
+ </div>
+ )
+ }
+
+ return (
+ <button
+ type="button"
+ data-testid={tid.profileRunningBotRow(bot.id)}
+ onClick={() => onOpenBotAudit(bot.id)}
+ aria-label={`Open ${bot.name} activity`}
+ className="flex min-h-11 w-full items-center gap-3 rounded-lg px-1 py-2 text-left transition-colors duration-150 hover:bg-accent/70 active:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
+ >
+ {content}
+ </button>
+ )
+}
+
+export function ProfileRunningBotsCard({ onOpenBotAudit, useBackdropEffect = true }: {
+ onOpenBotAudit?: (botId: string) => void
+ useBackdropEffect?: boolean
+}) {
+ const titleId = useId()
+ const { runningBots } = useRunningOwnedBots()
+
+ if (runningBots.length === 0) return null
+
+ return (
+ <section
+ data-testid={tid.profileRunningBotsCard}
+ aria-labelledby={titleId}
+ className={[
+ "relative isolate flex h-full min-h-0 w-full flex-col overflow-hidden rounded-2xl border border-foreground/10 px-4 py-2 text-popover-foreground shadow-2xl shadow-black/20 before:pointer-events-none before:absolute before:inset-x-5 before:top-0 before:z-20 before:h-px before:bg-linear-to-r before:from-transparent before:via-white/60 before:to-transparent before:content-[''] after:pointer-events-none after:absolute after:inset-0 after:z-0 after:bg-linear-to-br after:from-white/15 after:via-white/5 after:to-transparent after:content-['']",
+ useBackdropEffect
+ ? "bg-popover/70 backdrop-blur-2xl backdrop-saturate-150"
+ : "bg-popover/95",
+ ].join(" ")}
+ >
+ <div className="relative z-10 flex h-6 items-center gap-2">
+ <Bot className="size-4 shrink-0 text-foreground" aria-hidden />
+ <h2 id={titleId} className="text-sm font-semibold tracking-[-0.015em] text-foreground">
+ Running bots
+ </h2>
+ <span className="ml-auto flex items-center gap-1.5 text-xs tabular-nums text-muted-foreground" aria-label={`${runningBots.length} running ${runningBots.length === 1 ? "bot" : "bots"}`}>
+ {runningBots.length}
+ </span>
+ </div>
+
+ <div className="relative z-10 mt-2 min-h-0 flex-1 border-t border-foreground/10 pt-2">
+ <div className="h-full max-h-64 divide-y divide-border/40 overflow-y-auto pr-1 thin-scrollbar">
+ {runningBots.map((bot) => (
+ <BotRow key={bot.id} bot={bot} onOpenBotAudit={onOpenBotAudit} />
+ ))}
+ </div>
+ </div>
+ </section>
+ )
+}
diff --git a/src/web/src/components/community/social/profile-secondary-position.dom.test.ts b/src/web/src/components/community/social/profile-secondary-position.dom.test.ts
new file mode 100644
index 000000000..3c40059e5
--- /dev/null
+++ b/src/web/src/components/community/social/profile-secondary-position.dom.test.ts
@@ -0,0 +1,219 @@
+import { createElement } from "react"
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
+import {
+ act,
+ mockElementGeometry,
+ render,
+ renderHook,
+ screen,
+} from "@/test/react-dom-harness"
+import {
+ resolveAuditPreviewPlacement,
+ useProfileSecondaryPosition,
+} from "./profile-secondary-position"
+
+type PositionState = ReturnType<typeof useProfileSecondaryPosition>
+
+const animationFrames = new Map<number, FrameRequestCallback>()
+const resizeObservers: TestResizeObserver[] = []
+let nextAnimationFrame = 1
+
+class TestResizeObserver {
+ readonly observe = vi.fn()
+ readonly unobserve = vi.fn()
+ readonly disconnect = vi.fn()
+
+ constructor(readonly callback: ResizeObserverCallback) {
+ resizeObservers.push(this)
+ }
+}
+
+function setViewport(width: number, height: number) {
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: width })
+ Object.defineProperty(window, "innerHeight", { configurable: true, value: height })
+}
+
+function PositionHarness({
+ onRender,
+ enabled = true,
+ previewId = "preview",
+ x = 0,
+ y = 0,
+}: {
+ onRender: (state: PositionState) => void
+ enabled?: boolean
+ previewId?: string
+ x?: number
+ y?: number
+}) {
+ const state = useProfileSecondaryPosition(enabled, previewId, x, y)
+ onRender(state)
+ return createElement(
+ "div",
+ { ref: state.popoverRef, "data-testid": "popover" },
+ createElement("div", { ref: state.cardRef, "data-testid": "card" }),
+ createElement("div", { ref: state.previewRef, "data-testid": "preview" }),
+ )
+}
+
+beforeEach(() => {
+ animationFrames.clear()
+ resizeObservers.length = 0
+ nextAnimationFrame = 1
+ setViewport(1000, 800)
+ vi.stubGlobal("requestAnimationFrame", vi.fn((callback: FrameRequestCallback) => {
+ const frame = nextAnimationFrame++
+ animationFrames.set(frame, callback)
+ return frame
+ }))
+ vi.stubGlobal("cancelAnimationFrame", vi.fn((frame: number) => {
+ animationFrames.delete(frame)
+ }))
+ vi.stubGlobal("ResizeObserver", TestResizeObserver)
+})
+
+afterEach(() => {
+ vi.unstubAllGlobals()
+})
+
+describe("resolveAuditPreviewPlacement", () => {
+ it("uses the side with the most room when no placement fits", () => {
+ expect(resolveAuditPreviewPlacement({
+ card: {
+ top: 20,
+ right: 550,
+ bottom: 100,
+ left: 50,
+ width: 500,
+ height: 80,
+ },
+ preview: { width: 1000, height: 1000 },
+ viewportWidth: 600,
+ viewportHeight: 500,
+ })).toBe("bottom")
+ })
+
+ it("defaults to the right if no room ranking is available", () => {
+ const entries = vi.spyOn(Object, "entries").mockReturnValueOnce([])
+ const placement = resolveAuditPreviewPlacement({
+ card: { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 },
+ preview: { width: 1000, height: 1000 },
+ viewportWidth: 100,
+ viewportHeight: 100,
+ })
+ entries.mockRestore()
+
+ expect(placement).toBe("right")
+ })
+})
+
+describe("useProfileSecondaryPosition", () => {
+ it("stays unready when enabled before its refs exist", () => {
+ const rendered = renderHook(() => useProfileSecondaryPosition(true, "preview", 12, 24))
+
+ expect(rendered.result.current.ready).toBe(false)
+ expect(rendered.result.current.position).toBeNull()
+ expect(rendered.result.current.cardRef.current).toBeNull()
+ expect(rendered.result.current.previewRef.current).toBeNull()
+ expect(resizeObservers).toHaveLength(1)
+ expect(resizeObservers[0]?.observe).not.toHaveBeenCalled()
+
+ act(() => {
+ animationFrames.get(1)?.(0)
+ })
+ expect(rendered.result.current.position).toBeNull()
+
+ rendered.unmount()
+ expect(resizeObservers[0]?.disconnect).toHaveBeenCalledOnce()
+ expect(cancelAnimationFrame).toHaveBeenCalledWith(1)
+ })
+
+ it("clears a prior measurement when disabled and works without ResizeObserver", () => {
+ vi.stubGlobal("ResizeObserver", undefined)
+ const rendered = renderHook(
+ ({ enabled, previewId }) => useProfileSecondaryPosition(enabled, previewId, 0, 0),
+ { initialProps: { enabled: true, previewId: "preview" as string | undefined } },
+ )
+
+ expect(animationFrames).toHaveLength(1)
+ rendered.rerender({ enabled: false, previewId: "preview" })
+ expect(rendered.result.current.ready).toBe(false)
+ expect(rendered.result.current.position).toBeNull()
+
+ rendered.rerender({ enabled: true, previewId: undefined })
+ expect(rendered.result.current.ready).toBe(false)
+ expect(rendered.result.current.position).toBeNull()
+ })
+
+ it("measures every placement and reuses an identical observed position", () => {
+ let latest: PositionState | undefined
+ const rendered = render(createElement(PositionHarness, {
+ onRender: (state) => {
+ latest = state
+ },
+ }))
+ const popover = screen.getByTestId("popover")
+ const card = screen.getByTestId("card")
+ const preview = screen.getByTestId("preview")
+ const observer = resizeObservers[0]!
+
+ expect(observer.observe).toHaveBeenNthCalledWith(1, card)
+ expect(observer.observe).toHaveBeenNthCalledWith(2, preview)
+
+ mockElementGeometry(card, { left: 100, top: 100, offsetWidth: 200, offsetHeight: 300 })
+ mockElementGeometry(preview, { offsetWidth: 100, offsetHeight: 80 })
+ act(() => window.dispatchEvent(new Event("resize")))
+ expect(latest?.position).toEqual({
+ measurementKey: "preview:0:0",
+ placement: "right",
+ left: 208,
+ top: 0,
+ height: 300,
+ })
+
+ const stablePosition = latest?.position
+ act(() => observer.callback([], observer as unknown as ResizeObserver))
+ expect(latest?.position).toBe(stablePosition)
+
+ mockElementGeometry(card, { left: 700, top: 100, offsetWidth: 200, offsetHeight: 300 })
+ act(() => popover.dispatchEvent(new Event("animationend")))
+ expect(latest?.position).toMatchObject({ placement: "left", left: -108, top: 0 })
+
+ mockElementGeometry(card, { left: 100, top: 300, offsetWidth: 200, offsetHeight: 200 })
+ mockElementGeometry(preview, { offsetWidth: 800, offsetHeight: 100 })
+ act(() => popover.dispatchEvent(new Event("animationcancel")))
+ expect(latest?.position).toMatchObject({ placement: "top", left: -92, top: -108 })
+
+ mockElementGeometry(card, { left: 100, top: 50, offsetWidth: 200, offsetHeight: 200 })
+ act(() => window.dispatchEvent(new Event("scroll")))
+ expect(latest?.position).toMatchObject({ placement: "bottom", left: -92, top: 208 })
+
+ rendered.unmount()
+ expect(observer.disconnect).toHaveBeenCalledOnce()
+ })
+
+ it("keeps unclamped offsets when the preview is larger than its viewport", () => {
+ let latest: PositionState | undefined
+ render(createElement(PositionHarness, { onRender: (state) => { latest = state } }))
+ const card = screen.getByTestId("card")
+ const preview = screen.getByTestId("preview")
+
+ mockElementGeometry(card, { left: 400, top: 20, offsetWidth: 500, offsetHeight: 100 })
+ mockElementGeometry(preview, { offsetWidth: 1200, offsetHeight: 900 })
+ act(() => window.dispatchEvent(new Event("resize")))
+
+ expect(latest?.position).toMatchObject({
+ placement: "bottom",
+ left: -700,
+ top: 108,
+ })
+
+ mockElementGeometry(card, { left: 20, top: 20, offsetWidth: 100, offsetHeight: 100 })
+ act(() => window.dispatchEvent(new Event("resize")))
+ expect(latest?.position).toMatchObject({
+ placement: "right",
+ left: 108,
+ top: 0,
+ })
+ })
+})
diff --git a/src/web/src/components/community/social/profile-secondary-position.ts b/src/web/src/components/community/social/profile-secondary-position.ts
new file mode 100644
index 000000000..7aa563dd5
--- /dev/null
+++ b/src/web/src/components/community/social/profile-secondary-position.ts
@@ -0,0 +1,158 @@
+"use client"
+
+import { useLayoutEffect, useRef, useState } from "react"
+
+export type AuditPreviewPlacement = "right" | "left" | "top" | "bottom"
+
+type RectLike = Pick<DOMRect, "top" | "right" | "bottom" | "left" | "width" | "height">
+
+export function resolveAuditPreviewPlacement({
+ card,
+ preview,
+ viewportWidth,
+ viewportHeight,
+ gap = 8,
+}: {
+ card: RectLike
+ preview: Pick<RectLike, "width" | "height">
+ viewportWidth: number
+ viewportHeight: number
+ gap?: number
+}): AuditPreviewPlacement {
+ const room = {
+ right: viewportWidth - card.right,
+ left: card.left,
+ top: card.top,
+ bottom: viewportHeight - card.bottom,
+ }
+ const sideCrossAxisFits = preview.height <= viewportHeight - gap * 2
+ const verticalCrossAxisFits = preview.width <= viewportWidth - gap * 2
+
+ if (sideCrossAxisFits && room.right >= preview.width + gap) return "right"
+ if (sideCrossAxisFits && room.left >= preview.width + gap) return "left"
+ if (verticalCrossAxisFits && room.top >= preview.height + gap) return "top"
+ if (verticalCrossAxisFits && room.bottom >= preview.height + gap) return "bottom"
+
+ return (Object.entries(room) as Array<[AuditPreviewPlacement, number]>)
+ .sort((a, b) => b[1] - a[1])[0]?.[0] ?? "right"
+}
+
+type AuditPreviewPosition = {
+ placement: AuditPreviewPlacement
+ left: number | string
+ top: number
+ height?: number
+}
+
+type MeasuredAuditPreviewPosition = AuditPreviewPosition & {
+ measurementKey: string
+}
+
+function clamp(value: number, min: number, max: number): number {
+ if (min > max) return value
+ return Math.min(Math.max(value, min), max)
+}
+
+export function useProfileSecondaryPosition(
+ enabled: boolean,
+ previewId: string | undefined,
+ x: number,
+ y: number,
+) {
+ const popoverRef = useRef<HTMLDivElement | null>(null)
+ const cardRef = useRef<HTMLDivElement | null>(null)
+ const previewRef = useRef<HTMLDivElement | null>(null)
+ const [measuredPosition, setMeasuredPosition] = useState<MeasuredAuditPreviewPosition | null>(null)
+ const measurementKey = enabled && previewId ? `${previewId}:${x}:${y}` : null
+
+ useLayoutEffect(() => {
+ if (!measurementKey) {
+ setMeasuredPosition(null)
+ return
+ }
+
+ let frame = 0
+ const update = () => {
+ const cardElement = cardRef.current
+ const previewElement = previewRef.current
+ if (!cardElement || !previewElement) return
+ const transformedCard = cardElement.getBoundingClientRect()
+ const card = {
+ top: transformedCard.top,
+ right: transformedCard.left + cardElement.offsetWidth,
+ bottom: transformedCard.top + cardElement.offsetHeight,
+ left: transformedCard.left,
+ width: cardElement.offsetWidth,
+ height: cardElement.offsetHeight,
+ }
+ const preview = {
+ width: previewElement.offsetWidth,
+ height: previewElement.offsetHeight,
+ }
+ const gap = 8
+ const margin = 8
+ const placement = resolveAuditPreviewPlacement({
+ card,
+ preview,
+ viewportWidth: window.innerWidth,
+ viewportHeight: window.innerHeight,
+ gap,
+ })
+
+ const verticalOffset = clamp(
+ 0,
+ margin - card.top,
+ window.innerHeight - margin - preview.height - card.top,
+ )
+ const horizontalOffset = clamp(
+ card.width - preview.width,
+ margin - card.left,
+ window.innerWidth - margin - preview.width - card.left,
+ )
+ const next: MeasuredAuditPreviewPosition = placement === "right"
+ ? { measurementKey, placement, left: card.width + gap, top: verticalOffset, height: card.height }
+ : placement === "left"
+ ? { measurementKey, placement, left: -preview.width - gap, top: verticalOffset, height: card.height }
+ : placement === "top"
+ ? { measurementKey, placement, left: horizontalOffset, top: -preview.height - gap, height: card.height }
+ : { measurementKey, placement, left: horizontalOffset, top: card.height + gap, height: card.height }
+
+ setMeasuredPosition((current) => current?.measurementKey === next.measurementKey
+ && current.placement === next.placement
+ && current.left === next.left
+ && current.top === next.top
+ && current.height === next.height
+ ? current
+ : next)
+ }
+
+ update()
+ frame = requestAnimationFrame(update)
+ window.addEventListener("resize", update)
+ window.addEventListener("scroll", update, true)
+ const popoverElement = popoverRef.current
+ popoverElement?.addEventListener("animationend", update)
+ popoverElement?.addEventListener("animationcancel", update)
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update)
+ if (cardRef.current) observer?.observe(cardRef.current)
+ if (previewRef.current) observer?.observe(previewRef.current)
+ return () => {
+ cancelAnimationFrame(frame)
+ window.removeEventListener("resize", update)
+ window.removeEventListener("scroll", update, true)
+ popoverElement?.removeEventListener("animationend", update)
+ popoverElement?.removeEventListener("animationcancel", update)
+ observer?.disconnect()
+ }
+ }, [measurementKey])
+
+ const ready = measurementKey !== null
+ && measuredPosition?.measurementKey === measurementKey
+ return {
+ popoverRef,
+ cardRef,
+ previewRef,
+ position: ready ? measuredPosition : null,
+ ready,
+ }
+}
diff --git a/src/web/src/components/home/hero-section.tsx b/src/web/src/components/home/hero-section.tsx
index f7d3b07ac..ad972f64d 100644
--- a/src/web/src/components/home/hero-section.tsx
+++ b/src/web/src/components/home/hero-section.tsx
@@ -1,19 +1,13 @@
"use client";
-import { useRef, useState, type CSSProperties, type ReactNode } from "react";
+import { useState, type CSSProperties, type ReactNode } from "react";
import Link from "next/link";
-import gsap from "gsap";
-import { useGSAP } from "@gsap/react";
-import { ScrollTrigger } from "gsap/ScrollTrigger";
-import { SplitText } from "gsap/SplitText";
import { TypewriterVisual } from "@/components/typewriter-visual";
import { trackLandingCtaClicked } from "@/lib/analytics";
import { GithubOutboundLink } from "@/components/github-outbound-link";
import { HeroScrollCue } from "./hero-scroll-cue";
import { AnimatedAlookLogo } from "@/components/community/shell/animated-alook-logo";
-gsap.registerPlugin(ScrollTrigger, SplitText);
-
type HeroSecondaryCta =
| { href: string; label: string; kind?: "link" }
| { kind: "github"; label: string };
@@ -57,64 +51,13 @@ export function HeroSection({
desktopSplit?: boolean;
nextSectionId?: string;
}) {
- const sectionRef = useRef<HTMLDivElement>(null);
- const headingRef = useRef<HTMLHeadingElement>(null);
- const sublineRef = useRef<HTMLParagraphElement>(null);
- const ctaRef = useRef<HTMLDivElement>(null);
const [copied, setCopied] = useState(false);
const ctaSizingClassName = largeCtas
? "px-3 py-3 text-[clamp(0.6875rem,3vw,1rem)] whitespace-nowrap sm:px-8"
: "px-6 py-2 text-sm";
- useGSAP(
- () => {
- if (!headingRef.current || !ctaRef.current) return;
-
- const entranceTl = gsap.timeline({ delay: 0.3 });
-
- entranceTl
- .fromTo(".hero-brand",
- { y: -20, opacity: 0 },
- { y: 0, opacity: 1, duration: 0.5, ease: "power3.out" }
- )
- .to(headingRef.current, { opacity: 1, duration: 0.4, ease: "power2.out" }, 0.2);
-
- if (sublineRef.current) {
- entranceTl.to(sublineRef.current, { opacity: 1, duration: 0.3, ease: "power2.out" }, "-=0.1");
- }
-
- if (showClipboard) {
- entranceTl.fromTo(
- ".hero-clipboard",
- { y: 10, opacity: 0 },
- { y: 0, opacity: 1, duration: 0.3, ease: "power2.out" },
- "-=0.1"
- );
- }
-
- if (showCommunityLinks) {
- entranceTl.fromTo(
- ".hero-providers",
- { y: 10, opacity: 0 },
- { y: 0, opacity: 1, duration: 0.4, ease: "power2.out" },
- "-=0.2"
- );
- }
-
- entranceTl.fromTo(
- ctaRef.current,
- { y: 15, opacity: 0 },
- { y: 0, opacity: 1, duration: 0.4, ease: "power2.out" },
- "-=0.2"
- );
-
- },
- { scope: sectionRef }
- );
-
return (
<section
- ref={sectionRef}
data-testid={testId}
className={`hero-section relative flex h-screen items-center justify-center overflow-hidden${desktopSplit ? " hero-section-split" : ""}${nextSectionId ? " hero-section-scrollable" : ""}`}
style={{ backgroundColor: "var(--landing-bg)" }}
@@ -133,7 +76,7 @@ export function HeroSection({
<div className="hero-content relative z-10 mx-auto flex w-full max-w-4xl flex-col items-center px-4 sm:px-6 py-8 max-h-full">
{/* Brand */}
- <Link href="/" aria-label="Alook home" className="hero-brand mb-6 flex min-h-11 shrink-0 items-center gap-2 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-current" style={{ opacity: 0 }}>
+ <Link href="/" aria-label="Alook home" className="hero-brand mb-6 flex min-h-11 shrink-0 items-center gap-2 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-current">
<AnimatedAlookLogo className="size-8" />
<span
className="text-2xl tracking-tight"
@@ -164,14 +107,12 @@ export function HeroSection({
</p>
)}
<h1
- ref={headingRef}
className={`mb-1 px-2 text-center leading-[1.2] ${headlineClassName ?? ""}`}
style={{
fontFamily: "var(--font-crt)",
color: "var(--landing-text)",
fontSize: "clamp(26px, 4vw, 44px)",
letterSpacing: "-0.01em",
- opacity: 0,
...headlineStyle,
}}
>
@@ -179,13 +120,11 @@ export function HeroSection({
</h1>
{subline !== null && (
<p
- ref={sublineRef}
className="block max-w-lg px-2 text-center text-sm leading-relaxed sm:text-base"
style={{
fontFamily: "var(--font-crt)",
color: "var(--landing-text-muted)",
fontSize: "clamp(15px, 3.6vw, 20px)",
- opacity: 0,
}}
>
{subline === undefined ? (
@@ -210,7 +149,6 @@ export function HeroSection({
{/* Clipboard copy widget */}
{showClipboard && <div
className="hero-clipboard relative mt-8 shrink-0 w-full max-w-lg cursor-pointer"
- style={{ opacity: 0 }}
onClick={() => {
navigator.clipboard.writeText(
`Read ${window.location.origin}/onboard.md and follow the instructions to install and configure Alook`
@@ -271,28 +209,8 @@ export function HeroSection({
</div>
</div>}
- {/* Specs */}
- {/* <div className="hero-specs mt-6 flex flex-wrap items-center justify-center gap-x-6 gap-y-2" style={{ opacity: 0 }}>
- {[
- "Collaboration",
- "Always-On",
- "Self-Learning",
- ].map((spec) => (
- <span
- key={spec}
- className="text-xs sm:text-sm uppercase tracking-[0.15em] font-bold"
- style={{
- fontFamily: "var(--font-mono)",
- color: "var(--landing-text-muted)",
- }}
- >
- {spec}
- </span>
- ))}
- </div> */}
-
{/* Community links */}
- {showCommunityLinks && <div className="hero-providers mt-4 shrink-0 flex items-center justify-center gap-4" style={{ opacity: 0 }}>
+ {showCommunityLinks && <div className="hero-providers mt-4 shrink-0 flex items-center justify-center gap-4">
<GithubOutboundLink
surface="landing"
target="_blank"
@@ -332,7 +250,7 @@ export function HeroSection({
</div>}
{/* CTA */}
- <div ref={ctaRef} className="hero-ctas mt-8 shrink-0 flex flex-nowrap items-center justify-center gap-3" style={{ opacity: 0 }}>
+ <div className="hero-ctas mt-8 shrink-0 flex flex-nowrap items-center justify-center gap-3">
{/* <a
href="https://github.com/alookai/alook"
className="inline-flex items-center gap-2 px-6 py-2 text-sm transition-all duration-200 hover:opacity-80"
diff --git a/src/web/src/components/home/landing-content.test.ts b/src/web/src/components/home/landing-content.test.ts
index d14a67873..88e496970 100644
--- a/src/web/src/components/home/landing-content.test.ts
+++ b/src/web/src/components/home/landing-content.test.ts
@@ -70,6 +70,20 @@ describe("landing content contract", () => {
expect(heroSource).toContain('<svg className="size-5 shrink-0" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">')
})
+ it("renders hero copy and actions directly without an entrance timeline", () => {
+ const root = webRoot()
+ const heroSource = readFileSync(path.join(root, "src/components/home/hero-section.tsx"), "utf8")
+
+ expect(heroSource).not.toContain("useGSAP")
+ expect(heroSource).not.toContain("gsap.timeline")
+ expect(heroSource).not.toContain("ScrollTrigger")
+ expect(heroSource).not.toContain("SplitText")
+ expect(heroSource).not.toMatch(/className="hero-(?:brand|clipboard|providers|ctas)[^\n]*style=\{\{ opacity: 0 \}\}/)
+ expect(heroSource).not.toMatch(/opacity:\s*0/)
+ expect(heroSource).toContain("<TypewriterVisual")
+ expect(heroSource).toContain("entranceDelay={1.2}")
+ })
+
it("frames continuity as one agent remembering and acting across rooms", () => {
expect(LANDING_AGENT).toMatchObject({ name: "Alli", handle: "Alli#8145" })
expect(LANDING_CONTINUITY).toMatchObject({
diff --git a/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts b/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
index 181b44a05..15fad4559 100644
--- a/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
+++ b/src/web/src/hooks/community/use-forum-sidebar-threads.dom.test.ts
@@ -585,6 +585,7 @@ describe("forum sidebar canonical projection", () => {
it("folds an in-flight activity delta into an eligible retained row", async () => {
const { queryClient, wrapper } = await setup()
+ const activityAt = new Date(Date.now() - 60_000).toISOString()
let resolveRequest!: (value: SidebarThreadEnvelope) => void
apiFetchMock.mockReturnValue(new Promise((resolve) => { resolveRequest = resolve }))
const rendered = renderHook(
@@ -593,7 +594,7 @@ describe("forum sidebar canonical projection", () => {
)
await waitFor(() => expect(apiFetchMock).toHaveBeenCalledOnce())
patchForumSidebarActivityExact(
- queryClient, "server-1", "post-1", "forum-1", "2026-09-26T11:00:00.000Z",
+ queryClient, "server-1", "post-1", "forum-1", activityAt,
)
removeForumSidebarThreadExact(queryClient, "server-1", "post-1")
restoreForumSidebarThreadInflight("server-1", "post-1")
@@ -606,7 +607,7 @@ describe("forum sidebar canonical projection", () => {
included: retained.included,
}))
await waitFor(() => expect(rendered.result.current.threads[0]?.activityAt)
- .toBe("2026-09-26T11:00:00.000Z"))
+ .toBe(activityAt))
rendered.unmount()
})
diff --git a/src/web/src/hooks/community/use-running-owned-bots.ts b/src/web/src/hooks/community/use-running-owned-bots.ts
new file mode 100644
index 000000000..2effe1d8c
--- /dev/null
+++ b/src/web/src/hooks/community/use-running-owned-bots.ts
@@ -0,0 +1,41 @@
+"use client"
+
+import { useMemo } from "react"
+import { useBots, type BotSummary } from "@/hooks/community/use-bots"
+import { useCanonicalProfilesByUserId } from "@/lib/community-db/projections"
+import type { CommunityProfile } from "@/lib/community/models/people"
+import { isBotActivityRunning } from "@/lib/community/bot-activity-status"
+
+export type RunningOwnedBot = BotSummary & {
+ activityEmoji: string
+ activityText: string
+}
+
+export function resolveRunningOwnedBots(
+ bots: readonly BotSummary[],
+ profilesByUserId: ReadonlyMap<string, CommunityProfile>,
+): RunningOwnedBot[] {
+ return bots.flatMap((bot) => {
+ const profile = profilesByUserId.get(bot.id)
+ if (!bot.isActive || !isBotActivityRunning(profile?.statusEmoji, profile?.statusText)) return []
+ return [{
+ ...bot,
+ activityEmoji: profile!.statusEmoji!,
+ activityText: profile!.statusText!,
+ }]
+ })
+}
+
+export function useRunningOwnedBots() {
+ const botsQuery = useBots()
+ const profilesByUserId = useCanonicalProfilesByUserId()
+ const runningBots = useMemo(
+ () => resolveRunningOwnedBots(botsQuery.bots, profilesByUserId),
+ [botsQuery.bots, profilesByUserId],
+ )
+ return {
+ runningBots,
+ initialLoading: botsQuery.isLoading && botsQuery.data === undefined,
+ unavailable: botsQuery.isError && botsQuery.data === undefined,
+ }
+}
diff --git a/src/web/src/lib/community-onboarding.test.ts b/src/web/src/lib/community-onboarding.test.ts
index e568f8bc2..af58907a7 100644
--- a/src/web/src/lib/community-onboarding.test.ts
+++ b/src/web/src/lib/community-onboarding.test.ts
@@ -20,6 +20,7 @@ import {
consumeQueuedCommunityOnboarding,
queueCommunityOnboarding,
readCommunityOnboardingState,
+ recoverCommunityOnboardingHarness,
recoverCommunityOnboardingMachine,
skipCommunityOnboarding,
startCommunityOnboarding,
@@ -113,6 +114,25 @@ describe("community onboarding journey", () => {
expect(analytics.stageCompleted).toHaveBeenCalledTimes(2);
});
+ it("returns to harness selection without completing machine or retaining stale choices", () => {
+ startCommunityOnboarding({ guideAvatarSeed: "guide-face-7" });
+ advanceCommunityOnboarding("harness", "machine", { harness: "codex" });
+ updateCommunityOnboardingResources({ machineId: "stale-machine" });
+
+ recoverCommunityOnboardingHarness();
+
+ expect(readCommunityOnboardingState()).toEqual({
+ status: "active",
+ stage: "harness",
+ guideAvatarSeed: "guide-face-7",
+ });
+ expect(analytics.stageCompleted).toHaveBeenCalledOnce();
+ expect(analytics.stageCompleted).toHaveBeenCalledWith("harness");
+
+ recoverCommunityOnboardingHarness();
+ expect(analytics.stageCompleted).toHaveBeenCalledOnce();
+ });
+
it("clears an explicit skip and allows manual retry", () => {
startCommunityOnboarding();
skipCommunityOnboarding();
diff --git a/src/web/src/lib/community-onboarding.ts b/src/web/src/lib/community-onboarding.ts
index a6bfac4eb..a81770dc3 100644
--- a/src/web/src/lib/community-onboarding.ts
+++ b/src/web/src/lib/community-onboarding.ts
@@ -92,6 +92,18 @@ export function updateCommunityOnboardingResources(resources: JourneyResources)
return publish({ ...currentState, ...resources });
}
+export function recoverCommunityOnboardingHarness() {
+ if (currentState?.status !== "active" || currentState.stage !== "machine") {
+ return currentState;
+ }
+ const {
+ harness: _harness,
+ machineId: _machineId,
+ ...retainedState
+ } = currentState;
+ return publish({ ...retainedState, stage: "harness" });
+}
+
export function recoverCommunityOnboardingMachine() {
if (currentState?.status !== "active" || currentState.stage !== "bot") {
return currentState;
diff --git a/src/web/src/lib/community/bot-activity-status.ts b/src/web/src/lib/community/bot-activity-status.ts
new file mode 100644
index 000000000..cc473ff22
--- /dev/null
+++ b/src/web/src/lib/community/bot-activity-status.ts
@@ -0,0 +1,30 @@
+import {
+ BOT_ACTIVITY_PRESETS,
+ RUNNING_PRESETS,
+} from "@alook/shared"
+
+type StatusPair = { emoji: string; text: string }
+
+function matchesStatus(
+ emoji: string | null | undefined,
+ text: string | null | undefined,
+ pair: StatusPair,
+): boolean {
+ return emoji === pair.emoji && text === pair.text
+}
+
+export function isBotActivityActive(
+ emoji: string | null | undefined,
+ text: string | null | undefined,
+): boolean {
+ return matchesStatus(emoji, text, BOT_ACTIVITY_PRESETS.starting)
+ || matchesStatus(emoji, text, BOT_ACTIVITY_PRESETS.stopping)
+ || isBotActivityRunning(emoji, text)
+}
+
+export function isBotActivityRunning(
+ emoji: string | null | undefined,
+ text: string | null | undefined,
+): boolean {
+ return RUNNING_PRESETS.some((pair) => matchesStatus(emoji, text, pair))
+}
diff --git a/src/web/src/lib/community/testids.ts b/src/web/src/lib/community/testids.ts
index d0973c359..2994b55d4 100644
--- a/src/web/src/lib/community/testids.ts
+++ b/src/web/src/lib/community/testids.ts
@@ -51,6 +51,9 @@ export const tid = {
accountDeletionComplete: "community-account-deletion-complete",
settingsTab: (value: string) => `community-settings-tab-${value}`,
userSettingsOpen: "community-user-settings-open",
+ userBarRunningBotsRing: "community-user-bar-running-bots-ring",
+ userBarRunningBotsGlow: "community-user-bar-running-bots-glow",
+ userBarProfileSecondaryDock: "community-user-bar-profile-secondary-dock",
serverSettingsOpen: "community-server-settings-open",
serverSettingsName: "community-server-settings-name",
newDivider: "community-new-divider",
@@ -62,6 +65,8 @@ export const tid = {
profileContextBadge: "community-profile-context-badge",
profileBotBadge: "community-profile-bot-badge",
profileOwnerLink: "community-profile-owner-link",
+ profileRunningBotsCard: "community-profile-running-bots-card",
+ profileRunningBotRow: (id: string) => `community-profile-running-bot-${id}`,
botAuditPreview: "community-bot-audit-preview",
botAuditPreviewDock: "community-bot-audit-preview-dock",
botAuditPreviewActive: "community-bot-audit-preview-active",