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): cross-channel message ref lands on the target message
Shellyc752d4c60c39
diff --git a/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx b/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsxindex 4abef939a..3c3c79ae4 100644--- a/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx+++ b/src/web/src/app/c/channels/[serverId]/[channelId]/page.tsx@@ -614,6 +614,24 @@ function ChannelView() {return () => useCommunityStore.getState().registerUiHandlers({ jumpToSeq: undefined })}, [jumpToSeq])+ // Cross-channel message ref: a pill in another channel navigated here with+ // `?msgseq=N` (see shell-frame's `navigate`). Land on that message once — a+ // freshly-opened channel rarely has an arbitrary seq in its initial window,+ // so this usually opens the context sheet (resolves seq→id server-side); if+ // the message happens to be loaded, jumpToSeq scrolls to it. Captured once at+ // mount and the param is stripped so a refresh/back doesn't re-trigger.+ const [jumpSeqTarget] = useState<number | null>(() => {+ const raw = searchParams.get("msgseq")+ const n = raw ? parseInt(raw, 10) : NaN+ return Number.isFinite(n) && n > 0 ? n : null+ })+ useEffect(() => {+ if (jumpSeqTarget === null) return+ jumpToSeq(jumpSeqTarget)+ router.replace(`/c/channels/${params.serverId}/${channelId}`, { scroll: false })+ // eslint-disable-next-line react-hooks/exhaustive-deps -- run once for this mount's cross-channel jump+ }, [])+// 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/components/community/channel-ref-pill.tsx b/src/web/src/components/community/channel-ref-pill.tsxindex 6b601ab08..69b9cce4a 100644--- a/src/web/src/components/community/channel-ref-pill.tsx+++ b/src/web/src/components/community/channel-ref-pill.tsx@@ -165,7 +165,7 @@ export function ChannelRefPill({ children }: { children?: React.ReactNode }) {: undefinedconst onClick = sameChannelSeq !== undefined? () => uiHandlers.jumpToSeq?.(sameChannelSeq)- : () => uiHandlers.navigate?.(view.href.serverId, view.href.channelId)+ : () => uiHandlers.navigate?.(view.href.serverId, view.href.channelId, view.messageSuffix)return (<>diff --git a/src/web/src/components/community/shell-frame.tsx b/src/web/src/components/community/shell-frame.tsxindex 17a14363d..0197fcfd6 100644--- a/src/web/src/components/community/shell-frame.tsx+++ b/src/web/src/components/community/shell-frame.tsx@@ -409,9 +409,17 @@ export function ShellFrame({// shell's router is the live one (rail clicks above navigate through it), so// the pills route through this bridge instead.const navigate = useCallback(- (serverId: string, channelId?: string) => {+ (serverId: string, channelId?: string, seq?: number) => {markSwitch(channelId ? "channel" : "server", channelId ?? serverId)- router.push(channelId ? `/c/channels/${serverId}/${channelId}` : `/c/channels/${serverId}`)+ if (channelId) {+ // `?msgseq=N` makes the destination channel jump to that message on+ // arrival (a cross-channel message ref) — the channel page reads it and+ // calls jumpToSeq. Without a channel (server ref) there's no message.+ const q = seq !== undefined ? `?msgseq=${seq}` : ""+ router.push(`/c/channels/${serverId}/${channelId}${q}`)+ } else {+ router.push(`/c/channels/${serverId}`)+ }},[router],)diff --git a/src/web/src/stores/community/index.ts b/src/web/src/stores/community/index.tsindex 5d932ed21..f0d0f138f 100644--- a/src/web/src/stores/community/index.ts+++ b/src/web/src/stores/community/index.ts@@ -82,14 +82,17 @@ type CommunityUiHandlers = {// clicking still scrolls to the message — the behavior the bare-`#N` pill had// before message-ref-upgrade.md removed it.jumpToSeq?: (seq: number) => void- // Navigate to a server (channelId omitted) or a channel. Registered by the+ // Navigate to a server (channelId omitted) or a channel, optionally landing on+ // a specific message `seq` (a cross-channel message ref). Registered by the// shell (shell-frame) where the router is the live App-Router instance.// Channel/server-ref pills call this INSTEAD of a subtree `useRouter()`:// those pills render deep inside the memoized Streamdown message tree, where// `useRouter().push` is a no-op (the ref pill's cross-channel click silently// did nothing — a pre-existing bug the full-path refs exposed). The shell// router works (rail clicks navigate through it), so route through the bridge.- navigate?: (serverId: string, channelId?: string) => void+ // With `seq`, the target channel opens with `?msgseq=N` and jumps to that+ // message on arrival (see the channel page's `?msgseq` handler).+ navigate?: (serverId: string, channelId?: string, seq?: number) => void}type Timer = ReturnType<typeof setTimeout>@@ -250,7 +253,7 @@ const stableUiHandlers: CommunityUiHandlers = {useCommunityStore.getState().uiHandlers.openProfile?.(name, e, discriminator, userId),goBackMobile: () => useCommunityStore.getState().uiHandlers.goBackMobile?.(),jumpToSeq: (seq) => useCommunityStore.getState().uiHandlers.jumpToSeq?.(seq),- navigate: (serverId, channelId) => useCommunityStore.getState().uiHandlers.navigate?.(serverId, channelId),+ navigate: (serverId, channelId, seq) => useCommunityStore.getState().uiHandlers.navigate?.(serverId, channelId, seq),}export const useUiHandlers = () => stableUiHandlers