-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Show All button in DirectoryGroup now properly expands sessions #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"; | ||||||
|
|
@@ -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(() => { | ||||||
|
|
@@ -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); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| return ( | ||||||
|
|
@@ -145,7 +151,7 @@ export function DirectoryGroup({ group, expanded, onToggle, searchQuery }: Direc | |||||
| ))} | ||||||
|
|
||||||
| {/* Show more button */} | ||||||
| {(hasMoreLoaded || hasMoreOnServer) && ( | ||||||
| {!showAll && (hasMoreLoaded || hasMoreOnServer) && ( | ||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM · correctness — "Show all" cannot reveal all sessions when the group has more than one server page
So for a group where One fix is to keep the button visible while the server still has more, so repeated clicks keep paging (each click just fetches the next 50). Since
Suggested change
|
||||||
| <div className="px-4 py-2"> | ||||||
| <button | ||||||
| type="button" | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: edspencer/herdctl
Length of output: 168
🏁 Script executed:
Repository: edspencer/herdctl
Length of output: 2340
🏁 Script executed:
Repository: edspencer/herdctl
Length of output: 4362
🏁 Script executed:
Repository: edspencer/herdctl
Length of output: 4916
Confirm pagination handles groups with >50 additional sessions.
loadMoreGroupSessionsfetches withlimit: 50(all-chats-slice.ts:118), buthandleShowAll(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 untilhasMoreOnServeris false, or preserve a visible "Load more" button when additional server data exists.Also applies to: 154-154
🤖 Prompt for AI Agents