Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): remove manual community navigation prefetch (#857)

Gener9de0d405315c
diff --git a/src/web/src/app/c/channels/layout.tsx b/src/web/src/app/c/channels/layout.tsx
index 486930d16..1ea027c93 100644
--- a/src/web/src/app/c/channels/layout.tsx
+++ b/src/web/src/app/c/channels/layout.tsx
@@ -411,11 +411,6 @@ export default function ServerLayout({ children }: { children: ReactNode }) {
)
}, [cancelPendingNavigation, serverId])
- const prefetchChannel = useCallback(
- (id: string, _parentId?: string) => router.prefetch(channelHref(serverId, id)),
- [router, serverId],
- )
-
const onSidebarOpenSettings = useCallback((section?: SettingsSection) => {
if (section) setSettingsSection(section)
setServerSettingsOpen(true)
@@ -487,7 +482,6 @@ export default function ServerLayout({ children }: { children: ReactNode }) {
isAdmin,
currentUserId: currentUser.id,
setActiveChannel,
- prefetchChannel,
forumThreadsByParent,
activeThreadId: activeForumThreadId,
onSelectForumThread: setActiveForumThread,
@@ -510,7 +504,7 @@ export default function ServerLayout({ children }: { children: ReactNode }) {
}), [
currentServer, sidebarHintOnly,
currentChannelMeta?.parentChannelId,
- currentChannelId, isAdmin, currentUser.id, setActiveChannel, prefetchChannel,
+ currentChannelId, isAdmin, currentUser.id, setActiveChannel,
forumThreadsByParent, activeForumThreadId, setActiveForumThread,
onSidebarOpenSettings, onBlockedCreate, mutedChannels,
onCreateChannelInSidebar, onCreateCategoryInSidebar, onRenameChannel,
diff --git a/src/web/src/app/c/me/layout.tsx b/src/web/src/app/c/me/layout.tsx
index 3a37a6d3a..e24f3ba51 100644
--- a/src/web/src/app/c/me/layout.tsx
+++ b/src/web/src/app/c/me/layout.tsx
@@ -113,11 +113,6 @@ export default function MeLayout({ children }: { children: ReactNode }) {
useCommunityStore.getState().uiHandlers.navigatePath?.("/c/me/bots")
}, [])
- const prefetchDm = useCallback((id: string) => router.prefetch(`/c/me/${id}`), [router])
- const prefetchFriends = useCallback(() => router.prefetch("/c/me/friends"), [router])
- const prefetchMachines = useCallback(() => router.prefetch("/c/me/machines"), [router])
- const prefetchBots = useCallback(() => router.prefetch("/c/me/bots"), [router])
-
const blockedUserIds = useMemo(
() => new Set(blocked.map((b) => b.userId ?? b.id)),
[blocked],
@@ -130,19 +125,15 @@ export default function MeLayout({ children }: { children: ReactNode }) {
blockedUserIds={blockedUserIds}
loading={dmsLoading}
onPickDm={enterDm}
- onPrefetchDm={prefetchDm}
onShowFriends={onShowFriends}
friendRequestCount={friendRequestCount}
- onPrefetchFriends={prefetchFriends}
onShowMachines={onShowMachines}
- onPrefetchMachines={prefetchMachines}
onShowBots={onShowBots}
- onPrefetchBots={prefetchBots}
friendsActive={friendsActive}
machinesActive={machinesActive}
botsActive={botsActive}
/>
- ), [dms, currentChannelId, dmsLoading, blockedUserIds, enterDm, prefetchDm, onShowFriends, friendRequestCount, prefetchFriends, onShowMachines, prefetchMachines, onShowBots, prefetchBots, friendsActive, machinesActive, botsActive])
+ ), [dms, currentChannelId, dmsLoading, blockedUserIds, enterDm, onShowFriends, friendRequestCount, onShowMachines, onShowBots, friendsActive, machinesActive, botsActive])
return (
<ShellFrame
diff --git a/src/web/src/components/community/channels/adaptive-navigation-cutover.contract.test.ts b/src/web/src/components/community/channels/adaptive-navigation-cutover.contract.test.ts
index 953906ca1..c39f59998 100644
--- a/src/web/src/components/community/channels/adaptive-navigation-cutover.contract.test.ts
+++ b/src/web/src/components/community/channels/adaptive-navigation-cutover.contract.test.ts
@@ -18,7 +18,6 @@ describe("adaptive navigation cutover contracts", () => {
)
expect(layout).toContain("channelHref(serverId, id)")
expect(sidebar).toContain("onSelectForumThread?.(parentId, thread.id)")
- expect(sidebar).toContain("prefetchChannel?.(thread.id, parentId)")
})
it("keeps the layout as the one channel subtree owner and removes the nested leaf", () => {
diff --git a/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx b/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx
index e6cb54f96..d475ffec5 100644
--- a/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx
+++ b/src/web/src/components/community/channels/channel-sidebar-tree-owner.dom.test.tsx
@@ -1,6 +1,6 @@
import { createElement } from "react"
import { describe, expect, it, vi } from "vitest"
-import { fireEvent, render, screen } from "@/test/react-dom-harness"
+import { fireEvent, render, screen, setupUser } from "@/test/react-dom-harness"
import type { Category } from "@/lib/community/models/navigation"
import { tid } from "@/lib/community/testids"
import {
@@ -31,6 +31,40 @@ function scopeProps(categories: Category[] | null) {
}
describe("ChannelSidebarScope", () => {
+ it.each(["text", "forum"] as const)("activates %s rows and parent-aware child rows without navigating on hover/focus", async (type) => {
+ const setActiveChannel = vi.fn()
+ const onSelectForumThread = vi.fn()
+ render(createElement(ChannelSidebarScope, {
+ ...scopeProps([{ ...targetCategories[0], channels: [{ ...targetCategories[0].channels[0], type }] }]),
+ setActiveChannel,
+ onSelectForumThread,
+ forumThreadsByParent: {
+ "target-one": [{
+ id: "thread-one", parentChannelId: "target-one", parentMessageId: "message-one",
+ title: "Thread one", activityAt: "2026-09-25T00:00:00.000Z",
+ expiresAt: "2026-09-28T00:00:00.000Z", unread: false,
+ }],
+ },
+ }))
+ const row = screen.getByTestId(tid.channelRow("target-one"))
+ const child = screen.getByTestId(tid.forumSidebarThread("thread-one"))
+ for (const element of [row, child]) {
+ fireEvent.pointerEnter(element)
+ fireEvent.focus(element)
+ }
+ expect(setActiveChannel).not.toHaveBeenCalled()
+ expect(onSelectForumThread).not.toHaveBeenCalled()
+ fireEvent.click(row)
+ expect(setActiveChannel).toHaveBeenCalledExactlyOnceWith("target-one")
+ const user = setupUser()
+ await user.click(child)
+ child.focus()
+ await user.keyboard("{Enter}")
+ expect(onSelectForumThread.mock.calls).toEqual([
+ ["target-one", "thread-one"], ["target-one", "thread-one"],
+ ])
+ })
+
it("reveals restored rows immediately while forum projection is pending", () => {
render(createElement(ChannelSidebarRevealBoundary, {
...scopeProps(targetCategories),
diff --git a/src/web/src/components/community/channels/channel-sidebar.tsx b/src/web/src/components/community/channels/channel-sidebar.tsx
index fce3efb02..f13cee473 100644
--- a/src/web/src/components/community/channels/channel-sidebar.tsx
+++ b/src/web/src/components/community/channels/channel-sidebar.tsx
@@ -60,7 +60,6 @@ export type ChannelSidebarProps = {
serverIcon?: string | null
activeChannel: string
setActiveChannel: (id: string) => void
- prefetchChannel?: (id: string, parentId?: string) => void
noHeader?: boolean
onOpenSettings?: (section?: SettingsSection) => void
isAdmin?: boolean
@@ -86,7 +85,7 @@ export type ChannelSidebarProps = {
}
export const ChannelSidebar = memo(function ChannelSidebar({
- tree, serverName, official, activeChannel, setActiveChannel, prefetchChannel, noHeader, onOpenSettings,
+ tree, serverName, official, activeChannel, setActiveChannel, noHeader, onOpenSettings,
isAdmin = true, currentUserId, onBlockedCreate, mutedChannels,
onCreateChannel, onCreateCategory, onDeleteChannel, onDeleteCategory,
onUpdateCategory, onRenameChannel, onReorderCategories, onReorderChannels,
@@ -207,7 +206,6 @@ export const ChannelSidebar = memo(function ChannelSidebar({
active={thread.id === activeThreadId}
muted={!!mutedChannels?.[parentId]}
onClick={() => onSelectForumThread?.(parentId, thread.id)}
- onPrefetch={() => prefetchChannel?.(thread.id, parentId)}
/>
))}
</div>
@@ -248,7 +246,6 @@ export const ChannelSidebar = memo(function ChannelSidebar({
active={ch.id === activeChannel && !hasActiveSidebarThread}
canReorder={isAdmin}
onClick={() => setActiveChannel(ch.id)}
- onPrefetch={() => prefetchChannel?.(ch.id)}
onEdit={isAdmin ? () => setDialog({ kind: "edit-channel", id: ch.id, categoryId: noneCatId, name: ch.name, type: ch.type ?? "text" }) : undefined}
onDelete={isAdmin ? () => { removeChannel(ch.id); onDeleteChannel?.(ch.id) } : undefined}
/>
@@ -289,7 +286,6 @@ export const ChannelSidebar = memo(function ChannelSidebar({
active={ch.id === activeChannel && !hasActiveSidebarThread}
canReorder={isAdmin}
onClick={() => setActiveChannel(ch.id)}
- onPrefetch={() => prefetchChannel?.(ch.id)}
onEdit={canManageChannel ? () => setDialog({ kind: "edit-channel", id: ch.id, categoryId: id, name: ch.name, type: ch.type ?? "text" }) : undefined}
onDelete={canManageChannel ? () => { removeChannel(ch.id); onDeleteChannel?.(ch.id) } : undefined}
onManageMembers={(catPrivate[id] && canManageChannel) ? () => setDialog({ kind: "manage-members", channelId: ch.id, channelName: ch.name }) : undefined}
@@ -427,13 +423,11 @@ function ForumSidebarThreadRow({
active,
muted,
onClick,
- onPrefetch,
}: {
thread: ForumSidebarThread
active: boolean
muted: boolean
onClick: () => void
- onPrefetch?: () => void
}) {
const unread = selectUnreadPresentation({
accountUnread: thread.unread,
@@ -447,8 +441,6 @@ function ForumSidebarThreadRow({
data-testid={tid.forumSidebarThread(thread.id)}
aria-current={active ? "page" : undefined}
onClick={onClick}
- onPointerEnter={onPrefetch}
- onFocus={onPrefetch}
onContextMenu={(event) => {
event.preventDefault()
event.stopPropagation()
diff --git a/src/web/src/components/community/channels/dm-sidebar.prefetch.dom.test.ts b/src/web/src/components/community/channels/dm-sidebar.prefetch.dom.test.ts
index 6e2fe19fb..05885ba55 100644
--- a/src/web/src/components/community/channels/dm-sidebar.prefetch.dom.test.ts
+++ b/src/web/src/components/community/channels/dm-sidebar.prefetch.dom.test.ts
@@ -1,7 +1,7 @@
import { createElement } from "react"
import { describe, expect, it, vi } from "vitest"
import { tid } from "@/lib/community/testids"
-import { fireEvent, render } from "@/test/react-dom-harness"
+import { fireEvent, render, setupUser } from "@/test/react-dom-harness"
import { DmSidebar, DmSidebarSkeleton } from "./dm-sidebar"
describe("DmSidebar navigation intent", () => {
@@ -52,10 +52,7 @@ describe("DmSidebar navigation intent", () => {
expect(dmList).toHaveClass("min-h-0", "flex-1", "overflow-y-auto")
})
- it("prefetches the fixed destinations on pointer and keyboard intent", () => {
- const onPrefetchFriends = vi.fn()
- const onPrefetchMachines = vi.fn()
- const onPrefetchBots = vi.fn()
+ it("waits for click or Enter before activating fixed destinations", async () => {
const onShowFriends = vi.fn()
const onShowMachines = vi.fn()
const onShowBots = vi.fn()
@@ -64,11 +61,8 @@ describe("DmSidebar navigation intent", () => {
activeDm: null,
onPickDm: vi.fn(),
onShowFriends,
- onPrefetchFriends,
onShowMachines,
- onPrefetchMachines,
onShowBots,
- onPrefetchBots,
}))
const [friends, machines, bots] = renderer.container.querySelectorAll("button")
@@ -76,17 +70,23 @@ describe("DmSidebar navigation intent", () => {
fireEvent.focus(machines!)
fireEvent.pointerEnter(bots!)
- expect(onPrefetchFriends).toHaveBeenCalledTimes(1)
- expect(onPrefetchMachines).toHaveBeenCalledTimes(1)
- expect(onPrefetchBots).toHaveBeenCalledTimes(1)
expect(onShowFriends).not.toHaveBeenCalled()
expect(onShowMachines).not.toHaveBeenCalled()
expect(onShowBots).not.toHaveBeenCalled()
+ const user = setupUser()
+ for (const button of [friends!, machines!, bots!]) {
+ await user.click(button)
+ button.focus()
+ await user.keyboard("{Enter}")
+ }
+ expect(onShowFriends).toHaveBeenCalledTimes(2)
+ expect(onShowMachines).toHaveBeenCalledTimes(2)
+ expect(onShowBots).toHaveBeenCalledTimes(2)
+
})
- it("prefetches the intended DM without selecting it", () => {
- const onPrefetchDm = vi.fn()
+ it("selects the intended DM only on click or Enter", async () => {
const onPickDm = vi.fn()
const renderer = render(createElement(DmSidebar, {
dms: [{
@@ -99,15 +99,21 @@ describe("DmSidebar navigation intent", () => {
}],
activeDm: null,
onPickDm,
- onPrefetchDm,
onShowFriends: vi.fn(),
}))
fireEvent.focus(renderer.getByTestId(tid.dmRow("dm_1")))
- expect(onPrefetchDm).toHaveBeenCalledWith("dm_1")
+ fireEvent.pointerEnter(renderer.getByTestId(tid.dmRow("dm_1")))
expect(onPickDm).not.toHaveBeenCalled()
+ const user = setupUser()
+ const button = renderer.getByTestId(tid.dmRow("dm_1"))
+ await user.click(button)
+ button.focus()
+ await user.keyboard("{Enter}")
+ expect(onPickDm.mock.calls).toEqual([["dm_1"], ["dm_1"]])
+
})
it("uses the active row shape without a duplicate unread dot", () => {
diff --git a/src/web/src/components/community/channels/dm-sidebar.tsx b/src/web/src/components/community/channels/dm-sidebar.tsx
index 8c2ede348..3248817f4 100644
--- a/src/web/src/components/community/channels/dm-sidebar.tsx
+++ b/src/web/src/components/community/channels/dm-sidebar.tsx
@@ -11,7 +11,6 @@ import { compactRequestCount } from "@/lib/community/friend-requests"
export const DmSidebar = memo(function DmSidebar({
dms, activeDm, blockedUserIds, loading, onPickDm, onShowFriends, onShowMachines, onShowBots,
- onPrefetchDm, onPrefetchFriends, onPrefetchMachines, onPrefetchBots,
friendsActive, machinesActive, botsActive,
friendRequestCount = 0,
}: {
@@ -20,13 +19,9 @@ export const DmSidebar = memo(function DmSidebar({
blockedUserIds?: Set<string>
loading?: boolean
onPickDm: (id: string) => void
- onPrefetchDm?: (id: string) => void
onShowFriends: () => void
- onPrefetchFriends?: () => void
onShowMachines?: () => void
- onPrefetchMachines?: () => void
onShowBots?: () => void
- onPrefetchBots?: () => void
friendsActive?: boolean
friendRequestCount?: number
machinesActive?: boolean
@@ -40,8 +35,6 @@ export const DmSidebar = memo(function DmSidebar({
<button
aria-label={requestCount ? `Friends, ${friendRequestCount} new requests` : "Friends"}
onClick={onShowFriends}
- onPointerEnter={onPrefetchFriends}
- onFocus={onPrefetchFriends}
className={[
"mb-1 flex h-9 w-full items-center gap-2 rounded-md px-2 text-sm font-medium",
isFriendsActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
@@ -61,8 +54,6 @@ export const DmSidebar = memo(function DmSidebar({
<button
data-testid={tid.machineGuideIntroSource}
onClick={onShowMachines}
- onPointerEnter={onPrefetchMachines}
- onFocus={onPrefetchMachines}
className={[
"mb-1 flex h-9 w-full items-center gap-2 rounded-md px-2 text-sm font-medium",
machinesActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
@@ -74,8 +65,6 @@ export const DmSidebar = memo(function DmSidebar({
{onShowBots && (
<button
onClick={onShowBots}
- onPointerEnter={onPrefetchBots}
- onFocus={onPrefetchBots}
className={[
"mb-2 flex h-9 w-full items-center gap-2 rounded-md px-2 text-sm font-medium",
botsActive ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
@@ -108,8 +97,6 @@ export const DmSidebar = memo(function DmSidebar({
key={d.id}
data-testid={tid.dmRow(d.id)}
onClick={() => onPickDm(d.id)}
- onPointerEnter={() => onPrefetchDm?.(d.id)}
- onFocus={() => onPrefetchDm?.(d.id)}
className={[
"flex w-full items-center gap-3 rounded-md px-2 py-2",
active ? "bg-sidebar-accent text-foreground" : "text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
diff --git a/src/web/src/components/community/channels/sortable-channel.tsx b/src/web/src/components/community/channels/sortable-channel.tsx
index 09995114f..2e043dca8 100644
--- a/src/web/src/components/community/channels/sortable-channel.tsx
+++ b/src/web/src/components/community/channels/sortable-channel.tsx
@@ -38,11 +38,10 @@ export function PendingChannelRow({ ch }: { ch: Channel }) {
// A single drag-sortable channel row. The whole row is the drag surface (no handle);
// mouse movement or a touch long-press distinguishes navigation from reorder.
// Right-click opens an edit/mute/delete menu.
-export function SortableChannel({ ch, active, onClick, onPrefetch, onEdit, onDelete, onManageMembers, canReorder = true }: {
+export function SortableChannel({ ch, active, onClick, onEdit, onDelete, onManageMembers, canReorder = true }: {
ch: Channel
active: boolean
onClick: () => void
- onPrefetch?: () => void
onEdit?: () => void
onDelete?: () => void
onManageMembers?: () => void
@@ -63,8 +62,6 @@ export function SortableChannel({ ch, active, onClick, onPrefetch, onEdit, onDel
ref={setNodeRef}
style={style}
onClick={onClick}
- onPointerEnter={onPrefetch}
- onFocus={onPrefetch}
data-testid={tid.channelRow(ch.id)}
{...attributes}
{...listeners}
diff --git a/src/web/src/components/community/shell/server-rail.tsx b/src/web/src/components/community/shell/server-rail.tsx
index 704db2dc3..590978d2c 100644
--- a/src/web/src/components/community/shell/server-rail.tsx
+++ b/src/web/src/components/community/shell/server-rail.tsx
@@ -135,10 +135,8 @@ export const ServerRail = memo(function ServerRail({
view,
bottomInset,
onHome,
- onHomePrefetch,
onServer,
onServerNavigate,
- onServerPrefetch,
onCreateServer,
onLeaveServer,
onOpenSettings,
@@ -151,10 +149,8 @@ export const ServerRail = memo(function ServerRail({
view: View
bottomInset?: number
onHome: () => void
- onHomePrefetch?: () => void
onServer?: () => void
onServerNavigate?: (id: string) => void
- onServerPrefetch?: (id: string) => void
onCreateServer?: (name: string, icon?: File) => void
onLeaveServer?: (id: string) => void
onOpenSettings?: (serverId: string) => void
@@ -403,8 +399,6 @@ export const ServerRail = memo(function ServerRail({
<RailIndicator active={view === "dm"} />
<button
onClick={onHome}
- onPointerEnter={onHomePrefetch}
- onFocus={onHomePrefetch}
aria-label="Home"
data-testid={tid.homeButton}
className="group/alook grid size-10 shrink-0 place-items-center rounded-[20px] focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
@@ -429,7 +423,6 @@ export const ServerRail = memo(function ServerRail({
server={server}
active={view !== "dm" && activeId === serverId}
onClick={() => pickServer(serverId)}
- onPrefetch={() => onServerPrefetch?.(serverId)}
onLeave={() => onLeaveServer?.(serverId)}
onOpenSettings={() => onOpenSettings?.(serverId)}
onOpenInvitePopover={onOpenInvitePopover ? () => onOpenInvitePopover(serverId) : undefined}
@@ -481,7 +474,6 @@ export const ServerRail = memo(function ServerRail({
server={server}
active={view !== "dm" && activeId === server.id}
onClick={() => pickServer(server.id)}
- onPrefetch={() => onServerPrefetch?.(server.id)}
onOpenSettings={() => onOpenSettings?.(server.id)}
onOpenInvitePopover={onOpenInvitePopover ? () => onOpenInvitePopover(server.id) : undefined}
inFolder
diff --git a/src/web/src/components/community/shell/shell-frame-types.ts b/src/web/src/components/community/shell/shell-frame-types.ts
index b06136dc0..b93010541 100644
--- a/src/web/src/components/community/shell/shell-frame-types.ts
+++ b/src/web/src/components/community/shell/shell-frame-types.ts
@@ -21,5 +21,4 @@ export type ShellRouter = {
push: (href: string) => void
pushImmediate?: (href: string) => void
replace: (href: string) => void
- prefetch: (href: string) => void
}
diff --git a/src/web/src/components/community/shell/sortable-server.focus.dom.test.ts b/src/web/src/components/community/shell/sortable-server.focus.dom.test.ts
index ee5b3453a..56f992830 100644
--- a/src/web/src/components/community/shell/sortable-server.focus.dom.test.ts
+++ b/src/web/src/components/community/shell/sortable-server.focus.dom.test.ts
@@ -78,15 +78,15 @@ describe("SortableServer stable menu trigger", () => {
const focus = vi.spyOn(HTMLElement.prototype, "focus")
const dispose = vi.fn()
const registerItem = vi.fn(() => dispose)
- const onPrefetch = vi.fn()
- const result = renderServer(false, 0, false, { registerItem, onPrefetch })
+ const onClick = vi.fn()
+ const result = renderServer(false, 0, false, { registerItem, onClick })
const originalButton = result.button()
fireEvent.pointerEnter(result.activationRoot())
expect(result.button()).toBe(originalButton)
expect(registerItem).toHaveBeenCalledTimes(1)
- expect(onPrefetch).toHaveBeenCalledTimes(1)
+ expect(onClick).not.toHaveBeenCalled()
expect(result.container.querySelectorAll("context-menu-trigger")).toHaveLength(1)
expect(result.container.querySelectorAll("context-menu-content")).toHaveLength(1)
expect(focus).not.toHaveBeenCalled()
diff --git a/src/web/src/components/community/shell/sortable-server.tsx b/src/web/src/components/community/shell/sortable-server.tsx
index fc49ccece..f3d111037 100644
--- a/src/web/src/components/community/shell/sortable-server.tsx
+++ b/src/web/src/components/community/shell/sortable-server.tsx
@@ -27,7 +27,6 @@ type SortableServerProps = {
server: Server;
active?: boolean;
onClick: () => void;
- onPrefetch?: () => void;
onLeave?: () => void;
onOpenSettings?: () => void;
onOpenInvitePopover?: () => void;
@@ -46,7 +45,6 @@ function SortableServerImpl({
server,
active,
onClick,
- onPrefetch,
onLeave,
onOpenSettings,
onOpenInvitePopover,
@@ -69,19 +67,15 @@ function SortableServerImpl({
)
}, [registerItem, server.id])
const activate = activated ? undefined : () => setActivated(true);
- const activateAndPrefetch = () => {
- activate?.();
- onPrefetch?.();
- };
const icon = (
<div
ref={rootRef}
style={{ opacity: isDragActive ? 0.3 : 1 }}
className="group relative flex w-full justify-center"
- onPointerEnter={activateAndPrefetch}
+ onPointerEnter={activate}
onPointerDownCapture={activate}
- onFocusCapture={activateAndPrefetch}
+ onFocusCapture={activate}
onKeyDownCapture={activate}
onContextMenuCapture={activate}
>
@@ -244,8 +238,7 @@ export function serverPropsEqual(prev: SortableServerProps, next: SortableServer
!!prev.onLeave === !!next.onLeave &&
!!prev.onOpenSettings === !!next.onOpenSettings &&
!!prev.onOpenInvitePopover === !!next.onOpenInvitePopover &&
- prev.dragDescriptionId === next.dragDescriptionId &&
- !!prev.onPrefetch === !!next.onPrefetch
+ prev.dragDescriptionId === next.dragDescriptionId
);
}
diff --git a/src/web/src/components/community/shell/use-community-navigation-controller.ts b/src/web/src/components/community/shell/use-community-navigation-controller.ts
index 964cb301e..75721064c 100644
--- a/src/web/src/components/community/shell/use-community-navigation-controller.ts
+++ b/src/web/src/components/community/shell/use-community-navigation-controller.ts
@@ -25,7 +25,6 @@ export type CommunityNavigationController = {
push: (href: string) => void
pushImmediate: (href: string) => void
replace: (href: string) => void
- prefetch: (href: string) => void
resolveAndPush: (resolve: () => Promise<string>) => Promise<boolean>
cancelPendingNavigation: () => void
}
@@ -148,7 +147,6 @@ export function useCommunityNavigationController(
push,
pushImmediate,
replace,
- prefetch: router.prefetch,
resolveAndPush,
cancelPendingNavigation,
}
diff --git a/src/web/src/components/community/shell/use-shell-rail-controller.dom.test.ts b/src/web/src/components/community/shell/use-shell-rail-controller.dom.test.ts
index 01440cd70..19d3c8e86 100644
--- a/src/web/src/components/community/shell/use-shell-rail-controller.dom.test.ts
+++ b/src/web/src/components/community/shell/use-shell-rail-controller.dom.test.ts
@@ -270,21 +270,16 @@ describe("useShellRailController", () => {
const hook = await renderController()
await act(async () => hook.current.navigate("s1"))
- await act(async () => hook.current.railProps.onServerPrefetch("s1"))
await act(async () => hook.current.navigate("s2"))
- await act(async () => hook.current.railProps.onServerPrefetch("s2"))
expect(hook.pushed).toEqual([
"/c/channels/s1/canonical",
"/c/channels/s2",
])
- expect(hook.prefetched).toEqual([
- "/c/channels/s1",
- "/c/channels/s2",
- ])
+ expect(hook.prefetched).toEqual([])
})
- it("keeps rail navigation and prefetch on the semantic server root", async () => {
+ it("keeps rail navigation on the semantic server root without prefetch", async () => {
const hook = await renderController()
hook.cache.set("s1", {
categories: [{ channels: [{ id: "pending", pending: true }, { id: "cached", pending: false }] }],
@@ -292,38 +287,33 @@ describe("useShellRailController", () => {
mocks.lastChannel.current = "cached"
await act(async () => hook.current.railProps.onServerNavigate("s1"))
- await act(async () => hook.current.railProps.onServerPrefetch("s1"))
- await act(async () => hook.current.railProps.onHomePrefetch())
expect(hook.pushed).toEqual(["/c/channels/s1"])
- expect(hook.prefetched).toEqual(["/c/channels/s1", "/c/me/friends"])
+ expect(hook.prefetched).toEqual([])
expect(hook.queryClient.fetchQuery).not.toHaveBeenCalled()
await act(async () => hook.current.railProps.onServerNavigate("s2"))
expect(hook.pushed).toContain("/c/channels/s2")
- await act(async () => hook.current.railProps.onServerPrefetch("s2"))
- expect(hook.prefetched).toContain("/c/channels/s2")
- await act(async () => hook.current.railProps.onServerPrefetch("s3"))
- expect(hook.prefetched).toContain("/c/channels/s3")
+ expect(hook.prefetched).toEqual([])
+ expect(hook.current.railProps).not.toHaveProperty("onServerPrefetch")
+ expect(hook.current.railProps).not.toHaveProperty("onHomePrefetch")
expect(hook.queryClient.fetchQuery).not.toHaveBeenCalled()
})
- it("uses one breakpoint-canonical Home destination for click and prefetch", async () => {
+ it("uses the breakpoint-canonical Home destination only on activation", async () => {
mocks.lastMeLeaf.current = "dm-last"
const desktop = await renderController({ breakpoint: "desktop" })
await act(async () => {
- desktop.current.railProps.onHomePrefetch()
desktop.current.railProps.onHome()
})
- expect(desktop.prefetched).toEqual(["/c/me/dm-last"])
+ expect(desktop.prefetched).toEqual([])
expect(desktop.pushed).toEqual(["/c/me/dm-last"])
for (const breakpoint of ["mobile", "unknown"] as const) {
const safeRoot = await renderController({ breakpoint })
await act(async () => {
- safeRoot.current.railProps.onHomePrefetch()
safeRoot.current.railProps.onHome()
})
- expect(safeRoot.prefetched).toEqual(["/c/me"])
+ expect(safeRoot.prefetched).toEqual([])
expect(safeRoot.pushed).toEqual(["/c/me"])
}
})
diff --git a/src/web/src/components/community/shell/use-shell-rail-controller.ts b/src/web/src/components/community/shell/use-shell-rail-controller.ts
index 339d67ad3..45d81272a 100644
--- a/src/web/src/components/community/shell/use-shell-rail-controller.ts
+++ b/src/web/src/components/community/shell/use-shell-rail-controller.ts
@@ -95,13 +95,6 @@ export function useShellRailController({
const onHome = useCallback(() => {
navigation.push(homeDestination())
}, [homeDestination, navigation])
- const onServerPrefetch = useCallback((id: string) => {
- navigation.prefetch(`/c/channels/${id}`)
- }, [navigation])
- const onHomePrefetch = useCallback(
- () => navigation.prefetch(homeDestination()),
- [homeDestination, navigation],
- )
const onCreateServer = useCallback(async (name: string, icon?: File) => {
try {
const data = await createServerAsync({ name })
@@ -172,9 +165,7 @@ export function useShellRailController({
serversLoading: serversQuery.isPending && servers.length === 0,
view: projectedView,
onHome,
- onHomePrefetch,
onServerNavigate,
- onServerPrefetch,
onCreateServer,
onLeaveServer: hasLiveServers ? onLeaveServer : undefined,
onOpenSettings: hasLiveServers ? onOpenSettings : undefined,
diff --git a/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts b/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts
index 44c7ba3c4..32ca62cfa 100644
--- a/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts
+++ b/src/web/src/test/e2e-ui/38-community-navigation-checkpoint-matrix.spec.ts
@@ -156,11 +156,22 @@ test("community checkpoint shows target pending for detail and keeps list surfac
const leafGate = await holdRoute(page, `/c/channels/${serverId}/${channelB}`)
await page.getByTestId(tid.channelRow(channelB)).click({ noWaitAfter: true })
await expect.poll(leafGate.held).toBeGreaterThan(0)
- await expect(page.getByLabel("Resolving conversation")).toBeVisible()
+ const pendingMain = page.getByLabel("Resolving conversation")
+ const targetReady = page.locator(
+ `[data-slot="community-conversation-surface"][data-channel-id="${channelB}"]`,
+ ).filter({
+ has: page.getByRole("heading", { name: channelBName, exact: true }),
+ }).filter({ has: page.getByTestId(tid.composerInput) })
+ const oldMain = page.locator(
+ `[data-slot="community-conversation-surface"][data-channel-id="${channelA}"]`,
+ )
+ await expect(pendingMain.or(targetReady).first()).toBeVisible()
await expect(channelHeader(page, channelAName)).toHaveCount(0)
+ await expect(oldMain).toHaveCount(0)
await page.waitForTimeout(150)
- await expect(page.getByLabel("Resolving conversation")).toBeVisible()
+ await expect(pendingMain.or(targetReady).first()).toBeVisible()
await expect(channelHeader(page, channelAName)).toHaveCount(0)
+ await expect(oldMain).toHaveCount(0)
await leafGate.release()
await expect(channelHeader(page, channelBName)).toBeVisible({ timeout: 30_000 })
@@ -247,7 +258,16 @@ test("mobile route commits stay stationary while sidebar identity survives same-
const pendingGate = await holdRoute(page, pendingPath)
await page.getByTestId(tid.channelRow(pendingChannel)).click({ noWaitAfter: true })
await expect.poll(pendingGate.held).toBeGreaterThan(0)
- await expect(page.getByTestId(tid.pendingMain("server-conversation"))).toBeVisible()
+ const pendingMain = page.getByTestId(tid.pendingMain("server-conversation"))
+ const targetReady = page.locator(
+ `[data-slot="community-conversation-surface"][data-channel-id="${pendingChannel}"]`,
+ ).filter({
+ has: page.getByRole("heading", { name: pendingName, exact: true }),
+ }).filter({ has: page.getByTestId(tid.composerInput) })
+ await expect(pendingMain.or(targetReady).first()).toBeVisible()
+ await expect(page.locator(
+ `[data-slot="community-conversation-surface"][data-channel-id="${fastChannel}"]`,
+ )).toHaveCount(0)
await pendingGate.release()
await expect.poll(() => new URL(page.url()).pathname).toBe(pendingPath)