Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(community): read profile-card status from WS overlay, drop from Profile
Gus4f96924797f8
diff --git a/src/daemon/src/drivers/systemPrompt.ts b/src/daemon/src/drivers/systemPrompt.tsindex 532a2c233..2780bb652 100644--- a/src/daemon/src/drivers/systemPrompt.ts+++ b/src/daemon/src/drivers/systemPrompt.ts@@ -155,7 +155,7 @@ function messagingSection(): string {"","- Send a reply β two options depending on length:",` - Short: \`${CLI} message send --target <ref> --text "brief reply"\``,- ` - Long&Complicated: write body to a tmp file, then \`${CLI} message send --target <ref> --file /path/to/msg.md\``,+ ` - Long&Complicated: write body to a tmp file, then \`${CLI} message send --target <ref> --file ./temp_msg.md\``,"- Address your reply to where the message came from.","","### Channel refs & addressing",diff --git a/src/web/src/app/community/preview/_mock.ts b/src/web/src/app/community/preview/_mock.tsindex dbd5d3495..6a0692dbe 100644--- a/src/web/src/app/community/preview/_mock.ts+++ b/src/web/src/app/community/preview/_mock.ts@@ -301,8 +301,8 @@ export const DM_MESSAGES: Record<string, Msg[]> = {}export const PROFILES: Record<string, Profile> = {- Gener: { name: "Gener", userId: "u_gener", discriminator: "0042", avatar: "G", role: "Owner", about: "Building Alook. Coffee, agents, and warm gray UIs.", mutual: 3, statusEmoji: "π§", statusText: "Vibing" },- Gus: { name: "Gus", userId: "u_gus", discriminator: "1337", avatar: "Gu", role: "Admin", about: "Tinkering with email-driven workflows.", mutual: 2, statusEmoji: "π¦₯", statusText: "Chillin'" },+ Gener: { name: "Gener", userId: "u_gener", discriminator: "0042", avatar: "G", role: "Owner", about: "Building Alook. Coffee, agents, and warm gray UIs.", mutual: 3 },+ Gus: { name: "Gus", userId: "u_gus", discriminator: "1337", avatar: "Gu", role: "Admin", about: "Tinkering with email-driven workflows.", mutual: 2 },Lindsay: { name: "Lindsay", userId: "u_lindsay", discriminator: "0007", avatar: "L", role: "Admin", about: "Research lead. Ask me about presets.", mutual: 2 },}diff --git a/src/web/src/app/community/preview/page.tsx b/src/web/src/app/community/preview/page.tsxindex 46ddd4731..659863cab 100644--- a/src/web/src/app/community/preview/page.tsx+++ b/src/web/src/app/community/preview/page.tsx@@ -64,7 +64,13 @@ export default function CommunityPreview() {// An open thread takes over the message area like a channel.const [openThreadId, setOpenThreadId] = useState<string | null>(null)const [mobileZone, setMobileZone] = useState<MobileZone>("messages")- const [profile, setProfile] = useState<{ data: Profile; x: number; y: number } | null>(null)+ const [profile, setProfile] = useState<{+ data: Profile+ x: number+ y: number+ initialStatusEmoji: string | null+ initialStatusText: string | null+ } | null>(null)// demo state β preview-local; the live app replaces these handlers with API mutations + WSconst [messages, setMessages] = useState<Msg[]>(MESSAGES)const [pinned, setPinned] = useState<Msg[]>(PINNED)@@ -138,14 +144,15 @@ export default function CommunityPreview() {about: member && "sub" in member && member.sub ? member.sub : "No bio yet.",mutual: 1,}- // Merge presence onto the FINAL data regardless of source (curated- // PROFILES lookup or the fallback literal above) β both mock arrays- // already carry real mixed online/offline values, so this is what- // makes the online/offline manual QA cases testable without two live- // logged-in sessions (see plans/profile-card.md).- data = { ...data, presence: member?.status, statusEmoji: member?.statusEmoji ?? data.statusEmoji, statusText: member?.statusText ?? data.statusText }- if (name === "Gener") data = { ...data, about: myAboutMe, statusEmoji: myStatus.emoji, statusText: myStatus.text }- setProfile({ data, x: e.clientX, y: e.clientY })+ data = { ...data, presence: member?.status }+ if (name === "Gener") data = { ...data, about: myAboutMe }+ // Seed the status pill from the member row (or the local self-status for+ // Gener). In the live app the card subscribes to `useCommunityWsStore`;+ // in this preview scaffold no WS store is running, so the seed is what+ // the card actually renders.+ const initialStatusEmoji = name === "Gener" ? myStatus.emoji : (member?.statusEmoji ?? null)+ const initialStatusText = name === "Gener" ? myStatus.text : (member?.statusText ?? null)+ setProfile({ data, x: e.clientX, y: e.clientY, initialStatusEmoji, initialStatusText })}const profileProps = { onOpenProfile: openProfile }let msgSeq = messages.length@@ -584,7 +591,7 @@ export default function CommunityPreview() {{...profileProps}/>)}- {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={profile.data.userId === "u_gener"} onUpdateStatus={(emoji, text) => { setMyStatus({ emoji, text }); setProfile((p) => p ? { ...p, data: { ...p.data, statusEmoji: emoji, statusText: text } } : p) }} />}+ {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={profile.data.userId === "u_gener"} onUpdateStatus={(emoji, text) => { setMyStatus({ emoji, text }); setProfile((p) => p ? { ...p, initialStatusEmoji: emoji, initialStatusText: text } : p) }} initialStatusEmoji={profile.initialStatusEmoji} initialStatusText={profile.initialStatusText} />}{preview && <ImageLightbox src={preview} onClose={() => setPreview(null)} />}{dialogs}</Shell>@@ -621,7 +628,7 @@ export default function CommunityPreview() {{...profileProps}/>)}- {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={profile.data.userId === "u_gener"} onUpdateStatus={(emoji, text) => { setMyStatus({ emoji, text }); setProfile((p) => p ? { ...p, data: { ...p.data, statusEmoji: emoji, statusText: text } } : p) }} />}+ {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={profile.data.userId === "u_gener"} onUpdateStatus={(emoji, text) => { setMyStatus({ emoji, text }); setProfile((p) => p ? { ...p, initialStatusEmoji: emoji, initialStatusText: text } : p) }} initialStatusEmoji={profile.initialStatusEmoji} initialStatusText={profile.initialStatusText} />}{preview && <ImageLightbox src={preview} onClose={() => setPreview(null)} />}{dialogs}</Shell>diff --git a/src/web/src/components/community/_types.ts b/src/web/src/components/community/_types.tsindex af4152ffb..2d46a1786 100644--- a/src/web/src/components/community/_types.ts+++ b/src/web/src/components/community/_types.ts@@ -232,11 +232,6 @@ export type Profile = {// member/friend match could be resolved (e.g. a stale mention). See// `resolveProfilePresence` in shell-frame.tsx.presence?: Presence- // Custom status (emoji + short term), e.g. "π§ Vibing". Both undefined/null- // means "no status set" β use `hasStatus()` from status-presets.ts, not a- // truthiness check on either field alone.- statusEmoji?: string | null- statusText?: string | null}// ββ Settings rows ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdiff --git a/src/web/src/components/community/member-list.tsx b/src/web/src/components/community/member-list.tsxindex c84bea288..a4782a39a 100644--- a/src/web/src/components/community/member-list.tsx+++ b/src/web/src/components/community/member-list.tsx@@ -259,7 +259,7 @@ function MemberRow({className="flex w-full items-center gap-3 rounded-md px-2 py-2 select-none hover:bg-accent"><Avatar label={mem.avatar} seed={mem.userId} size={32} presence={mem.status} dim={mem.status === "offline"} />- <div className="min-w-0 flex-1 text-left">+ <div className="min-w-0 flex-1 space-y-0.5 text-left"><div className={`truncate text-sm leading-tight ${mem.status === "offline" ? "text-muted-foreground" : ""}`}>{mem.name}{showDiscriminator && mem.discriminator && (diff --git a/src/web/src/components/community/profile-card.test.ts b/src/web/src/components/community/profile-card.test.tsindex fa9c4201b..be85b1fb3 100644--- a/src/web/src/components/community/profile-card.test.ts+++ b/src/web/src/components/community/profile-card.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from "vitest"-import { generateGradient } from "./profile-card"+import { generateGradient, resolveCardStatus } from "./profile-card"describe("generateGradient", () => {it("is deterministic for the same name", () => {@@ -42,3 +42,35 @@ describe("generateGradient", () => {expect(after).toBe(before)})})++describe("resolveCardStatus β WS overlay wins over row seed", () => {+ it("uses the overlay entry when one exists", () => {+ const out = resolveCardStatus({ emoji: "π§", text: "Vibing" }, "π", "Reading")+ expect(out).toEqual({ emoji: "π§", text: "Vibing" })+ })++ it("falls back to the seed when the overlay has no entry", () => {+ const out = resolveCardStatus(undefined, "π", "Reading")+ expect(out).toEqual({ emoji: "π", text: "Reading" })+ })++ it("returns nulls when neither overlay nor seed provide a status", () => {+ expect(resolveCardStatus(undefined, undefined, undefined)).toEqual({ emoji: null, text: null })+ expect(resolveCardStatus(undefined, null, null)).toEqual({ emoji: null, text: null })+ })++ it("lets the overlay clear a seed (emoji: null overrides seed emoji)", () => {+ // When someone clears their status, the WS store's setUserStatus writes+ // { emoji: null, text: null }. That must win over any lingering row seed.+ const out = resolveCardStatus({ emoji: null, text: null }, "π", "Reading")+ expect(out).toEqual({ emoji: null, text: null })+ })++ it("resolves emoji and text independently", () => {+ // Overlay carries a text-only status (no emoji). Seed offers an emoji.+ // The overlay's presence β not its individual field values β is what+ // decides the source, so the seed's emoji does NOT leak in.+ const out = resolveCardStatus({ emoji: null, text: "AFK" }, "π§", "Vibing")+ expect(out).toEqual({ emoji: null, text: "AFK" })+ })+})diff --git a/src/web/src/components/community/profile-card.tsx b/src/web/src/components/community/profile-card.tsxindex d3653cf08..06d7cd560 100644--- a/src/web/src/components/community/profile-card.tsx+++ b/src/web/src/components/community/profile-card.tsx@@ -8,6 +8,25 @@ import { Avatar } from "./avatar"import { StatusEditor, hasStatus } from "./status-editor"import type { Profile } from "./_types"import type { Breakpoint } from "@/hooks/use-mobile"+import { useCommunityWsStore } from "@/stores/community/ws"++// Merge rule for the card's status pill: overlay wins over seed. The overlay+// (`useCommunityWsStore.userStatuses`) is the same live source the member+// list and friend rows consume, so an entry there is always fresher than a+// row-fetched seed. When the overlay has no entry (either because that user+// hasn't emitted a `community:status.update` this session, or because the+// user is anonymous / userId is undefined), fall back to the initial-seed+// props passed by the opener. Both fields resolve independently; there is+// no "if the overlay defines emoji but not text, prefer the whole seed"+// case β the store writes both in one call.+export function resolveCardStatus(+ overlay: { emoji: string | null; text: string | null } | undefined,+ seedEmoji: string | null | undefined,+ seedText: string | null | undefined,+): { emoji: string | null; text: string | null } {+ if (overlay) return { emoji: overlay.emoji, text: overlay.text }+ return { emoji: seedEmoji ?? null, text: seedText ?? null }+}// Deterministic, on-brand banner gradient. The seed is the owner's stable// userId (falling back to name only when the id isn't yet resolved), so@@ -25,7 +44,12 @@ export function generateGradient(seed: string): string {}// Profile card β popover anchored at the click point on desktop, bottom sheet on mobile.-export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdateStatus }: {+// Status (emoji + text) is read live from `useCommunityWsStore.userStatuses` β+// the same overlay the member list, friends list, and UserBar consume. The+// `initialStatusEmoji` / `initialStatusText` props are a first-paint seed for+// users the overlay has never seen a WS event for; once the overlay has an+// entry, it wins. See plans/profile-card-status-overlay.md.+export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdateStatus, initialStatusEmoji, initialStatusText }: {data: Profilex: numbery: number@@ -36,10 +60,14 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda// Only used when `isSelf` β the inline status row opens `StatusEditor` and// calls this on a preset pick / free-text commit / emoji override / clear.onUpdateStatus?: (emoji: string | null, text: string | null) => void+ initialStatusEmoji?: string | null+ initialStatusText?: string | null}) {const [msg, setMsg] = useState("")const [open, setOpen] = useState(true)const mobile = bp === "mobile"+ const liveStatus = useCommunityWsStore((s) => (data.userId ? s.userStatuses.get(data.userId) : undefined))+ const { emoji: statusEmoji, text: statusText } = resolveCardStatus(liveStatus, initialStatusEmoji, initialStatusText)const close = () => setOpen(false)const send = () => {const text = msg.trim()@@ -80,8 +108,8 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda(and therefore the dot's) right edge. */}{isSelf ? (<StatusEditor- emoji={data.statusEmoji ?? null}- text={data.statusText ?? null}+ emoji={statusEmoji}+ text={statusText}onChange={(emoji, text) => onUpdateStatus?.(emoji, text)}side="bottom"align="start"@@ -110,11 +138,11 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpdarender={children}` (which clones this exact element) ornesting an interactive `Tooltip.Trigger` inside a`<button>` that's already a trigger for something else. */}- <button title={data.statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1) hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none">- {hasStatus(data.statusEmoji, data.statusText) ? (+ <button title={statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1) hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none">+ {hasStatus(statusEmoji, statusText) ? (<>- {data.statusEmoji && <span>{data.statusEmoji}</span>}- {data.statusText && <span className="min-w-0 truncate">{data.statusText}</span>}+ {statusEmoji && <span>{statusEmoji}</span>}+ {statusText && <span className="min-w-0 truncate">{statusText}</span>}</>) : (<span className="text-muted-foreground">Set a status</span>@@ -122,10 +150,10 @@ export function ProfileCard({ data, x, y, bp, onClose, onMessage, isSelf, onUpda</button></StatusEditor>) : (- hasStatus(data.statusEmoji, data.statusText) && (- <div title={data.statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1)">- {data.statusEmoji && <span>{data.statusEmoji}</span>}- {data.statusText && <span className="min-w-0 truncate">{data.statusText}</span>}+ hasStatus(statusEmoji, statusText) && (+ <div title={statusText || undefined} className="absolute left-full top-[68.5px] ml-2 flex max-w-32 -translate-y-1/2 items-center gap-2 rounded-full border border-border bg-secondary px-2 py-0.5 text-[13px] whitespace-nowrap text-secondary-foreground shadow-(--e1)">+ {statusEmoji && <span>{statusEmoji}</span>}+ {statusText && <span className="min-w-0 truncate">{statusText}</span>}</div>))}diff --git a/src/web/src/components/community/shell-frame.tsx b/src/web/src/components/community/shell-frame.tsxindex f7bff9fd8..b1e43a7de 100644--- a/src/web/src/components/community/shell-frame.tsx+++ b/src/web/src/components/community/shell-frame.tsx@@ -149,7 +149,16 @@ export function ShellFrame({const uploadUserAvatar = useUploadUserAvatar()const [editingProfile, setEditingProfile] = useState(false)- const [profile, setProfile] = useState<{ data: Profile; x: number; y: number } | null>(null)+ const [profile, setProfile] = useState<{+ data: Profile+ x: number+ y: number+ // First-paint seed for the status pill β used only until `userStatuses`+ // has an overlay entry for this user. See profile-card.tsx for the merge+ // rule (overlay wins, seed is fallback).+ initialStatusEmoji: string | null+ initialStatusText: string | null+ } | null>(null)const [preview, setPreview] = useState<string | null>(null)const [pendingAvatarCrop, setPendingAvatarCrop] = useState<{ src: string; fileName: string } | null>(null)@@ -329,10 +338,14 @@ export function ShellFrame({about: currentUser.aboutMe ?? "",mutual: 0,presence: resolveProfilePresence(true, undefined, onlineUserIds),- statusEmoji: currentUser.statusEmoji ?? null,- statusText: currentUser.statusText ?? "",}- setProfile({ data, x: e.clientX, y: e.clientY })+ setProfile({+ data,+ x: e.clientX,+ y: e.clientY,+ initialStatusEmoji: currentUser.statusEmoji ?? null,+ initialStatusText: currentUser.statusText ?? null,+ })return}const member = resolveProfileTarget(members, friends, { name, discriminator, userId: targetUserId })@@ -352,10 +365,14 @@ export function ShellFrame({about,mutual: 0,presence: resolveProfilePresence(false, userId, onlineUserIds),- statusEmoji: member?.statusEmoji ?? null,- statusText: member?.statusText ?? "",}- setProfile({ data, x: e.clientX, y: e.clientY })+ setProfile({+ data,+ x: e.clientX,+ y: e.clientY,+ initialStatusEmoji: member?.statusEmoji ?? null,+ initialStatusText: member?.statusText ?? null,+ })if (userId) {// Cached under `communityKeys.profile(userId)` β a re-click on the// same person within `PROFILE_STALE_TIME_MS` resolves from memory@@ -367,6 +384,19 @@ export function ShellFrame({staleTime: PROFILE_STALE_TIME_MS,}).then((p) => {+ // Refresh THIS card's seed only β never write to the WS overlay+ // from a REST snapshot. `communityKeys.profile(userId)` is cached+ // for 5 min, so a re-open can resolve from stale cache; the WS+ // overlay is meant to be the freshest source (community:status.update+ // events keep it live). Writing REST β overlay would let a stale+ // cache clobber a live WS value, and every other consumer+ // (member list, friends list, UserBar) that subscribes to the+ // overlay would visibly regress. Overlay stays write-only from+ // the WS handler + self-mutation paths.+ // Status fields are assigned directly (no `??` fallback) β the+ // REST route always populates both, and a freshly-cleared status+ // must overwrite a stale member-row seed instead of getting+ // masked by it.setProfile((prev) =>prev? {@@ -376,9 +406,9 @@ export function ShellFrame({about: p.aboutMe ?? prev.data.about,mutual: p.mutualServers ?? 0,discriminator: p.discriminator ?? prev.data.discriminator,- statusEmoji: p.statusEmoji ?? null,- statusText: p.statusText ?? "",},+ initialStatusEmoji: p.statusEmoji,+ initialStatusText: p.statusText,}: prev,)@@ -402,15 +432,14 @@ export function ShellFrame({// Inline self-status save from the `ProfileCard` header (see status-editor.tsx).// Mirrors `userSettingsDialog`'s onSave status branch exactly β both save// paths must independently apply the same local WS-store write, since self- // isn't in their own fan-out audience (see plans/profile-card.md).+ // isn't in their own fan-out audience (see plans/profile-card-status-overlay.md).+ // The card and every other consumer subscribe to `userStatuses`, so writing+ // to the store is enough β no need to mirror the value onto `Profile`.const updateOwnStatus = async (statusEmoji: string | null, statusText: string | null) => {try {await updateProfile.mutateAsync({ statusEmoji, statusText })setCurrentUser((u) => ({ ...u, statusEmoji, statusText }))useCommunityWsStore.getState().setUserStatus(currentUser.id, statusEmoji, statusText)- setProfile((prev) =>- prev ? { ...prev, data: { ...prev.data, statusEmoji, statusText } } : prev,- )} catch (e) {toastApiError(e, "Failed to update status")}@@ -637,7 +666,7 @@ export function ShellFrame({<UserBar user={{ id: currentUser.id, name: currentUser.name, avatar: currentUser.avatar }} onOpenProfile={openProfile} onEditProfile={() => setEditingProfile(true)} inbox={inboxElement} hasUnread={inboxHasUnread} /></div></div>- {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={!!profile.data.userId && profile.data.userId === currentUser.id} onUpdateStatus={updateOwnStatus} />}+ {profile && <ProfileCard key={`${profile.data.userId ?? profile.data.name}:${profile.x}:${profile.y}`} data={profile.data} x={profile.x} y={profile.y} bp={bp} onClose={() => setProfile(null)} onMessage={profileMessage} isSelf={!!profile.data.userId && profile.data.userId === currentUser.id} onUpdateStatus={updateOwnStatus} initialStatusEmoji={profile.initialStatusEmoji} initialStatusText={profile.initialStatusText} />}{preview && <ImageLightbox src={preview} onClose={() => setPreview(null)} />}{userSettingsDialog}{avatarCropDialog}