Skip to content

fix: Show All button in DirectoryGroup now properly expands sessions#161

Open
edspencer wants to merge 2 commits into
mainfrom
fix/150-show-all-button
Open

fix: Show All button in DirectoryGroup now properly expands sessions#161
edspencer wants to merge 2 commits into
mainfrom
fix/150-show-all-button

Conversation

@edspencer

@edspencer edspencer commented Feb 26, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #150

  • Added showAll state to track whether user clicked "Show all" button
  • When showAll is true, component renders all filteredSessions instead of slicing to INITIAL_SESSIONS_SHOWN
  • Button now shows all locally-loaded sessions first, then fetches more from server if hasMoreOnServer is true
  • Button is hidden after being clicked (when showAll is true)

Changes

  1. Import useState from React
  2. Add showAll state (defaults to false)
  3. Conditionally slice filteredSessions based on showAll state
  4. Update handleShowAll to set state and conditionally fetch from server
  5. Hide button when showAll is true

Test plan

  • Verify "Show All" button appears for directory groups with >10 sessions
  • Click "Show All" and verify all locally-loaded sessions are displayed
  • Verify button disappears after clicking
  • Verify additional sessions are fetched from server when needed
  • Verify no TypeScript errors

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed the "Show All" button in the directory to properly expand beyond the initial view and display all available sessions
    • Now correctly reveals all locally-loaded sessions and automatically fetches additional sessions from the server when needed
    • The button is hidden once all sessions have been displayed

edspencer and others added 2 commits February 26, 2026 02:54
Fixes #150

- Add showAll state to track whether user clicked "Show all"
- When showAll is true, render all filteredSessions instead of slicing to INITIAL_SESSIONS_SHOWN
- Button now shows all locally-loaded sessions first, then fetches more from server if needed
- Hide button after it's been clicked (when showAll is true)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a changeset file documenting a patch release and modifies DirectoryGroup component to fix the non-functional "Show All" button. Introduces local showAll state to track user action, conditionally rendering all filtered sessions instead of a hardcoded 10-session limit, and triggering server fetch for additional sessions when needed.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/fix-show-all-button.md
Adds changeset file documenting patch release for @herdctl/web with description of "Show All" button fix.
DirectoryGroup Component
packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx
Introduces showAll state via useState hook to track expansion state. Updates sessionsToShow logic to display all filtered sessions when showAll is true. Conditionally renders "Show All" button only when not expanded. Preserves server fetch logic on button click.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A button that couldn't quite show, kept ten sessions and wouldn't grow
Now showAll state does the trick, expanding sessions slick and quick
From local cache to server's store, your sessions appear—ten and more! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main fix: the Show All button now properly expands sessions in DirectoryGroup, which directly matches the changeset modifications.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #150: adds showAll state, renders full filteredSessions when showAll is true, implements conditional server fetching, and hides the button after expansion.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #150: the changeset file, useState import addition, showAll state logic, and rendering changes are all necessary for the fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/150-show-all-button

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying herdctl with  Cloudflare Pages  Cloudflare Pages

Latest commit: dfc37c8
Status: ✅  Deploy successful!
Preview URL: https://3bd151bf.herdctl.pages.dev
Branch Preview URL: https://fix-150-show-all-button.herdctl.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx (1)

65-65: Add an explicit boolean type for showAll state.

Line 65 currently relies on inference; prefer explicit typing for consistency with strict TS conventions.

Suggested diff
-  const [showAll, setShowAll] = useState(false);
+  const [showAll, setShowAll] = useState<boolean>(false);

As per coding guidelines, **/*.{ts,tsx}: Use strict TypeScript with explicit types.

🤖 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` at line
65, The state declaration for showAll uses type inference; update it to an
explicit boolean type to satisfy strict TS rules by changing the useState call
that defines showAll and setShowAll (the useState import or invocation in
DirectoryGroup.tsx) to declare useState<boolean>(...) so showAll is explicitly
typed as boolean while preserving the initial value and existing usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx`:
- Around line 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.

---

Nitpick comments:
In `@packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx`:
- Line 65: The state declaration for showAll uses type inference; update it to
an explicit boolean type to satisfy strict TS rules by changing the useState
call that defines showAll and setShowAll (the useState import or invocation in
DirectoryGroup.tsx) to declare useState<boolean>(...) so showAll is explicitly
typed as boolean while preserving the initial value and existing usage.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9649c2 and dfc37c8.

📒 Files selected for processing (2)
  • .changeset/fix-show-all-button.md
  • packages/web/src/client/src/components/all-chats/DirectoryGroup.tsx

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Show All" button in DirectoryGroup never expands beyond INITIAL_SESSIONS_SHOWN

1 participant