Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-show-all-button.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@herdctl/web": patch
---

Fix "Show All" button in DirectoryGroup to properly expand beyond initial 10 sessions. Button now reveals all locally-loaded sessions and fetches additional sessions from server when needed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ChevronRight, Info } from "lucide-react";
import { useMemo } from "react";
import { useMemo, useState } from "react";
import { Link } from "react-router";
import { agentPath } from "../../lib/paths";
import type { DirectoryGroup as DirectoryGroupType, DiscoveredSession } from "../../lib/types";
Expand Down Expand Up @@ -62,6 +62,7 @@ function sessionMatchesQuery(session: DiscoveredSession, query: string): boolean

export function DirectoryGroup({ group, expanded, onToggle, searchQuery }: DirectoryGroupProps) {
const { loadMoreGroupSessions } = useAllChatsActions();
const [showAll, setShowAll] = useState(false);

// Filter sessions client-side when searching
const filteredSessions = useMemo(() => {
Expand All @@ -70,13 +71,18 @@ export function DirectoryGroup({ group, expanded, onToggle, searchQuery }: Direc
}, [group.sessions, searchQuery]);

// Determine how many sessions to show
const sessionsToShow = filteredSessions.slice(0, INITIAL_SESSIONS_SHOWN);
const sessionsToShow = showAll ? filteredSessions : filteredSessions.slice(0, INITIAL_SESSIONS_SHOWN);
const hasMoreLoaded = filteredSessions.length > INITIAL_SESSIONS_SHOWN;
const hasMoreOnServer = group.sessionCount > group.sessions.length;

// Handle "Show all" click
const handleShowAll = () => {
loadMoreGroupSessions(group.encodedPath);
// First, show all locally-loaded sessions
setShowAll(true);
// Then fetch more from server if there are any
if (hasMoreOnServer) {
loadMoreGroupSessions(group.encodedPath);
}
Comment on lines +80 to +85

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Searching for loadMoreGroupSessions definition and usage =="
rg -nP --type=ts --type=tsx -C4 '\bloadMoreGroupSessions\b'

echo
echo "== Checking DirectoryGroup.tsx content around lines 80-85 and 154 =="
fd -e tsx -e ts "DirectoryGroup" | head -5

Repository: edspencer/herdctl

Length of output: 168


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Finding DirectoryGroup.tsx =="
fd "DirectoryGroup" -e tsx -e ts

echo
echo "== Searching for loadMoreGroupSessions without type restriction =="
rg -n 'loadMoreGroupSessions' --max-count=20

echo
echo "== Checking pagination-related patterns =="
rg -n 'hasMore|nextCursor|offset|limit|page' | head -30

Repository: edspencer/herdctl

Length of output: 2340


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Reading all-chats-slice.ts loadMoreGroupSessions implementation =="
cat -n packages/web/src/client/src/store/all-chats-slice.ts | sed -n '100,150p'

echo
echo "== Reading DirectoryGroup.tsx around lines 80-85 and 154 =="
cat -n packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx | sed -n '60,100p'

echo
echo "== Reading DirectoryGroup.tsx around line 154 =="
cat -n packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx | sed -n '145,165p'

Repository: edspencer/herdctl

Length of output: 4362


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Checking for any pagination continuation or hasMore tracking =="
grep -n "sessionCount\|sessions.length\|hasMore" packages/web/src/client/src/store/all-chats-slice.ts | head -20

echo
echo "== Check if there's re-fetching logic elsewhere =="
rg -n "loadMoreGroupSessions" packages/web/src/client/src/store/ -A5 -B5

echo
echo "== Check API response structure =="
rg -n "fetchDirectoryGroupSessions" packages/web/src/client/src/ -A10 | head -40

Repository: edspencer/herdctl

Length of output: 4916


Confirm pagination handles groups with >50 additional sessions.

loadMoreGroupSessions fetches with limit: 50 (all-chats-slice.ts:118), but handleShowAll (DirectoryGroup.tsx:79–85) calls it only once. If a group has more than 50 additional sessions beyond those already loaded, the button disappears after the first fetch (line 154), leaving remaining sessions inaccessible. Either loop until hasMoreOnServer is false, or preserve a visible "Load more" button when additional server data exists.

Also applies to: 154-154

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx` around
lines 80 - 85, handleShowAll currently calls loadMoreGroupSessions once (which
fetches limit:50 in all-chats-slice.ts) then hides the "Load more" button via
setShowAll(true), so groups with >50 remaining sessions become inaccessible;
update handleShowAll in DirectoryGroup.tsx to either (a) loop/await
loadMoreGroupSessions(group.encodedPath) until hasMoreOnServer is false so all
pages are fetched before hiding the button, or (b) keep the load-more control
visible (do not call setShowAll(true) or hide the button) and let the user
repeatedly invoke loadMoreGroupSessions while hasMoreOnServer remains true;
reference the symbols handleShowAll, loadMoreGroupSessions, and hasMoreOnServer
when making the change.

};

return (
Expand Down Expand Up @@ -145,7 +151,7 @@ export function DirectoryGroup({ group, expanded, onToggle, searchQuery }: Direc
))}

{/* Show more button */}
{(hasMoreLoaded || hasMoreOnServer) && (
{!showAll && (hasMoreLoaded || hasMoreOnServer) && (
<div className="px-4 py-2">
<button
type="button"
Expand Down
Loading