Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(daemon): credit the human owner as author, agent as committer

Claudetteab377768e123
diff --git a/src/web/src/components/community/channel-ref-pill.tsx b/src/web/src/components/community/channel-ref-pill.tsx
index 51600be0d..6b601ab08 100644
--- a/src/web/src/components/community/channel-ref-pill.tsx
+++ b/src/web/src/components/community/channel-ref-pill.tsx
@@ -2,7 +2,6 @@
import { useMemo } from "react"
import type React from "react"
-import { useRouter } from "next/navigation"
import { ChannelPill } from "./inline-marks"
import { resolveChannelRefBase, type ResolvedChannelRef } from "@/lib/community/channel-ref"
import { useChannelRefDirectory } from "@/hooks/community/use-channel-ref-directory"
@@ -33,7 +32,7 @@ export type ChannelRefPillView =
/**
* Pure — takes already-computed inputs, decides what to render. No hooks.
* This repo has no jsdom/testing-library, so a component that calls
- * `useChannelRefDirectory`/`useThreads`/`useCommunityStore`/`useRouter`
+ * `useChannelRefDirectory`/`useThreads`/`useCommunityStore`/`useUiHandlers`
* directly can't be unit-tested the way this function can — mirrors the
* precedent set by `use-server-members.ts`, which extracts its reducers so
* hookless logic stays testable and leaves the hook wiring itself untested.
@@ -120,7 +119,6 @@ export function describeChannelRefPillView(args: {
*/
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()
@@ -156,15 +154,18 @@ export function ChannelRefPill({ children }: { children?: React.ReactNode }) {
// 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).
+ // seq→id). Cross-channel refs navigate via the `navigate` UI-handler — NOT a
+ // local `useRouter()`: this pill renders inside the memoized Streamdown
+ // message tree where `router.push` is a silent no-op (the click did nothing);
+ // the shell registers `navigate` off its live router. 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}`)
+ : () => uiHandlers.navigate?.(view.href.serverId, view.href.channelId)
return (
<>
diff --git a/src/web/src/components/community/server-ref-pill.tsx b/src/web/src/components/community/server-ref-pill.tsx
index 1d7a873c9..7fb139966 100644
--- a/src/web/src/components/community/server-ref-pill.tsx
+++ b/src/web/src/components/community/server-ref-pill.tsx
@@ -2,10 +2,10 @@
import { useMemo } from "react"
import type React from "react"
-import { useRouter } from "next/navigation"
import { ServerPill } from "./inline-marks"
import { resolveServerRefBase } from "@/lib/community/channel-ref"
import { useChannelRefDirectory } from "@/hooks/community/use-channel-ref-directory"
+import { useUiHandlers } from "@/stores/community"
export type ServerRefPillView =
| { kind: "plain"; text: string }
@@ -35,7 +35,7 @@ export function describeServerRefPillView(args: {
*/
export function ServerRefPill({ children }: { children?: React.ReactNode }) {
const ref = String(children ?? "")
- const router = useRouter()
+ const uiHandlers = useUiHandlers()
const { directory } = useChannelRefDirectory()
const resolved = useMemo(() => resolveServerRefBase(directory, ref), [directory, ref])
@@ -44,8 +44,12 @@ export function ServerRefPill({ children }: { children?: React.ReactNode }) {
if (view.kind === "plain") return <>{view.text}</>
+ // Navigate via the `navigate` UI-handler, NOT a local `useRouter()`: this pill
+ // renders in the memoized Streamdown message tree where `router.push` is a
+ // silent no-op (same pre-existing bug as ChannelRefPill). The shell registers
+ // `navigate` off its live router.
return (
- <ServerPill onClick={() => router.push(`/c/channels/${view.serverId}`)}>
+ <ServerPill onClick={() => uiHandlers.navigate?.(view.serverId)}>
{view.label}
</ServerPill>
)
diff --git a/src/web/src/components/community/shell-frame.tsx b/src/web/src/components/community/shell-frame.tsx
index 6350e13b1..17a14363d 100644
--- a/src/web/src/components/community/shell-frame.tsx
+++ b/src/web/src/components/community/shell-frame.tsx
@@ -404,13 +404,25 @@ export function ShellFrame({
const previewImage = useCallback((url: string) => setPreview(url), [])
const goBackMobile = useCallback(() => setMobileZone("nav"), [setMobileZone])
+ // Navigate for channel/server-ref pills. They live deep in the memoized
+ // Streamdown message tree where a subtree `useRouter().push` is a no-op; the
+ // 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) => {
+ markSwitch(channelId ? "channel" : "server", channelId ?? serverId)
+ router.push(channelId ? `/c/channels/${serverId}/${channelId}` : `/c/channels/${serverId}`)
+ },
+ [router],
+ )
useEffect(() => {
useCommunityStore.getState().registerUiHandlers({
previewImage,
openProfile,
goBackMobile,
+ navigate,
})
- }, [previewImage, openProfile, goBackMobile])
+ }, [previewImage, openProfile, goBackMobile, navigate])
// Inline self-status save from the `ProfileCard` header (see status-editor.tsx).
// Mirrors `userSettingsDialog`'s onSave status branch exactly — both save
diff --git a/src/web/src/stores/community/index.ts b/src/web/src/stores/community/index.ts
index 8c65ba066..5d932ed21 100644
--- a/src/web/src/stores/community/index.ts
+++ b/src/web/src/stores/community/index.ts
@@ -80,9 +80,16 @@ type CommunityUiHandlers = {
// 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).
+ // before message-ref-upgrade.md removed it.
jumpToSeq?: (seq: number) => void
+ // Navigate to a server (channelId omitted) or a channel. 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
}
type Timer = ReturnType<typeof setTimeout>
@@ -243,6 +250,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),
}
export const useUiHandlers = () => stableUiHandlers