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
feat(community): same-channel msg-ref jump + unify the ref pill
Shelly443a88c8e50d
diff --git a/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx b/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsxindex c28174e61..4abef939a 100644--- a/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx+++ b/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx@@ -598,6 +598,22 @@ function ChannelView() {// Message context sheet for unloaded message refsconst [contextSheetSeq, setContextSheetSeq] = useState<number | null>(null)+ // Jump to a message by seq within THIS channel — invoked by a same-channel+ // message-ref pill (`/server/channel#N` where the channel is open) via the+ // `jumpToSeq` UI-handler. Loaded in the window → reuse the mount-time scroll+ // path (`setScrollToMessageId` scrolls + highlights); not loaded → open the+ // context sheet, which resolves seq→id server-side. Reads `messages` lazily+ // off the actions ref so the callback stays reference-stable (no memo churn).+ const jumpToSeq = useCallback((seq: number) => {+ const msg = actionsCtxRef.current.messages.find((m) => m.seq === seq)+ if (msg) setScrollToMessageId(msg.id)+ else setContextSheetSeq(seq)+ }, [])+ useEffect(() => {+ useCommunityStore.getState().registerUiHandlers({ jumpToSeq })+ return () => useCommunityStore.getState().registerUiHandlers({ jumpToSeq: undefined })+ }, [jumpToSeq])+// Stable so it doesn't bust the memoized message rows; reads uiHandlers// lazily through the actions ref (assigned just below).const openProfile = useCallback<OpenProfile>((name, e, discriminator, userId) => {diff --git a/src/web/src/app/c/me/[dmId]/page.tsx b/src/web/src/app/c/me/[dmId]/page.tsxindex b535b039b..3c79eb677 100644--- a/src/web/src/app/c/me/[dmId]/page.tsx+++ b/src/web/src/app/c/me/[dmId]/page.tsx@@ -186,6 +186,16 @@ function DmView() {const goBack = useCallback(() => { uiHandlers.goBackMobile?.() }, [uiHandlers])+ // Jump to a message by seq within THIS DM — invoked by a same-DM message-ref+ // pill via the `jumpToSeq` UI-handler. The DM view has no in-place scroll+ // target prop (unlike the channel page), so always open the context sheet,+ // which resolves seq→id and shows the message with surrounding context.+ const jumpToSeq = useCallback((seq: number) => setContextSheetSeq(seq), [])+ useEffect(() => {+ useCommunityStore.getState().registerUiHandlers({ jumpToSeq })+ return () => useCommunityStore.getState().registerUiHandlers({ jumpToSeq: undefined })+ }, [jumpToSeq])+useEffect(() => {useCommunityStore.getState().setCurrentChannelId(dmId)communityWsSubscribe({ dmConversationId: dmId })diff --git a/src/web/src/components/community/channel-ref-pill.tsx b/src/web/src/components/community/channel-ref-pill.tsxindex c1cca8047..51600be0d 100644--- a/src/web/src/components/community/channel-ref-pill.tsx+++ b/src/web/src/components/community/channel-ref-pill.tsx@@ -7,7 +7,7 @@ import { ChannelPill } from "./inline-marks"import { resolveChannelRefBase, type ResolvedChannelRef } from "@/lib/community/channel-ref"import { useChannelRefDirectory } from "@/hooks/community/use-channel-ref-directory"import { useThreads } from "@/hooks/community/use-channel-panels"-import { useCommunityStore } from "@/stores/community"+import { useCommunityStore, useUiHandlers } from "@/stores/community"export type ChannelRefPillView =| { kind: "plain"; text: string }@@ -122,6 +122,8 @@ export function ChannelRefPill({ children }: { children?: React.ReactNode }) {const ref = String(children ?? "")const router = useRouter()const currentServerId = useCommunityStore((s) => s.currentServerId)+ const currentChannelId = useCommunityStore((s) => s.currentChannelId)+ const uiHandlers = useUiHandlers()const { directory, isLoading: directoryLoading } = useChannelRefDirectory()// The debt record's own verification (see finding #6) confirmed the@@ -149,16 +151,31 @@ export function ChannelRefPill({ children }: { children?: React.ReactNode }) {if (view.kind === "plain") return <>{view.text}</>if (view.kind === "muted") return <ChannelPill muted>{view.label}</ChannelPill>+ // A message ref (`#N` suffix) whose target is the ALREADY-OPEN channel should+ // SCROLL to the message, not navigate (navigating to the current channel is a+ // no-op that leaves the viewport put — the same-channel regression from+ // dropping the bare-`#N` pill). Route through the `jumpToSeq` UI-handler the+ // page registers (message loaded → scroll; else context sheet resolves+ // seq→id). Cross-channel refs still `router.push`; scroll-after-navigate is a+ // separate followup (see message-ref-upgrade.md).+ const sameChannelSeq =+ view.messageSuffix !== undefined && view.href.channelId === currentChannelId+ ? view.messageSuffix+ : undefined+ const onClick = sameChannelSeq !== undefined+ ? () => uiHandlers.jumpToSeq?.(sameChannelSeq)+ : () => router.push(`/c/channels/${view.href.serverId}/${view.href.channelId}`)+return (<>- <ChannelPill- serverPrefix={view.serverPrefix}- onClick={() => router.push(`/c/channels/${view.href.serverId}/${view.href.channelId}`)}- >+ <ChannelPill serverPrefix={view.serverPrefix} onClick={onClick} seqSuffix={view.messageSuffix}>{view.label}</ChannelPill>+ {/* The `/#N` thread-root suffix stays a detached plain span — it names the+ thread the pill degraded to (no matching thread found), not the pill's+ own target. The message `#N` (view.messageSuffix), by contrast, IS the+ target, so it's rendered INSIDE the pill via `seqSuffix` above. */}{view.threadSuffix !== undefined && <span className="text-muted-foreground">/#{view.threadSuffix}</span>}- {view.messageSuffix !== undefined && <span className="text-muted-foreground">#{view.messageSuffix}</span>}</>)}diff --git a/src/web/src/components/community/inline-marks.tsx b/src/web/src/components/community/inline-marks.tsxindex 7d2b9e1d2..ace523ab9 100644--- a/src/web/src/components/community/inline-marks.tsx+++ b/src/web/src/components/community/inline-marks.tsx@@ -2,6 +2,7 @@import { useState } from "react"import type React from "react"+import { Hash } from "lucide-react"import { ChannelIcon } from "./channel-icon"// Pill components the streamdown renderer maps custom tags to (see message-markdown.tsx).@@ -64,13 +65,22 @@ export function ChannelPill({onClick,serverPrefix,muted,+ seqSuffix,}: {children?: React.ReactNodeonClick?: (e: React.MouseEvent) => voidserverPrefix?: stringmuted?: boolean+ // A message ref (`/server/channel#N`): render the whole thing as ONE pill —+ // channel name + `#N` inside — with a leading `#` glyph (instead of the `/`+ // channel glyph) so it reads as "a message in general", one clickable unit.+ // A plain channel ref leaves this undefined and keeps the `/` glyph. (Alli+ // uiux#118: seq is the ref's real target, so it belongs inside the pill, not+ // floating after it as a detached muted span.)+ seqSuffix?: number}) {const title = typeof children === "string" ? children : undefined+ const isMsgRef = seqSuffix !== undefinedconst className = ["inline-flex max-w-[16rem] items-center gap-1 rounded-lg bg-accent px-1 align-bottom font-medium text-foreground",muted ? "opacity-60" : "",@@ -78,11 +88,14 @@ export function ChannelPill({].join(" ")const content = (<>- <ChannelIcon className="shrink-0 text-xs" />+ {isMsgRef+ ? <Hash className="h-[0.85em] w-auto shrink-0" aria-hidden />+ : <ChannelIcon className="shrink-0 text-xs" />}{serverPrefix && (<span className="shrink-0 text-muted-foreground transition-colors group-hover/pill:text-primary">{serverPrefix} /</span>)}<span className="min-w-0 truncate">{children}</span>+ {isMsgRef && <span className="shrink-0 font-semibold">#{seqSuffix}</span>}</>)if (onClick) {diff --git a/src/web/src/stores/community/index.ts b/src/web/src/stores/community/index.tsindex f7bab3062..8c65ba066 100644--- a/src/web/src/stores/community/index.ts+++ b/src/web/src/stores/community/index.ts@@ -75,6 +75,14 @@ type CommunityUiHandlers = {previewImage?: (url: string) => voidopenProfile?: (name: string, e: React.MouseEvent, discriminator?: string, userId?: string) => voidgoBackMobile?: () => void+ // Jump to message `seq` within the CURRENT channel/DM — the page registers+ // this (message already loaded → scroll to it; otherwise open the context+ // sheet, which resolves seq→id server-side). A same-channel message ref pill+ // (`/server/channel#N` where the channel is the open one) invokes it so+ // clicking still scrolls to the message — the behavior the bare-`#N` pill had+ // before message-ref-upgrade.md removed it. Cross-channel jumps route via the+ // pill's own `router.push` instead (a followup adds scroll-after-navigate).+ jumpToSeq?: (seq: number) => void}type Timer = ReturnType<typeof setTimeout>@@ -234,6 +242,7 @@ const stableUiHandlers: CommunityUiHandlers = {openProfile: (name, e, discriminator, userId) =>useCommunityStore.getState().uiHandlers.openProfile?.(name, e, discriminator, userId),goBackMobile: () => useCommunityStore.getState().uiHandlers.goBackMobile?.(),+ jumpToSeq: (seq) => useCommunityStore.getState().uiHandlers.jumpToSeq?.(seq),}export const useUiHandlers = () => stableUiHandlers