Skip to content

feat(prompts): paginate High frequency table 10/page with numbered controls (#349) - #355

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
Maqbool61:main
Jul 6, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
Maqbool61:main

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

Closes #349

What changed

All changes are contained in a single file: _fanout-tab.tsx.

1. Renamed heading

  • CardTitle text changed from "Query fan-out" → "High frequency" as specified in the issue.

2. Client-side pagination (10/page)

  • Added page state (useState(1)) and a PAGE_SIZE = 10 constant.
  • data.subQueries is sliced into pageRows using (page - 1) * PAGE_SIZE offset before being passed to the table — no server changes needed.

3. Numbered page controls

  • Rendered below the table when totalPages > 1.
  • Each page number is a Button from the existing shadcn/ui component.
  • Active page uses variant="default", others use variant="ghost" for clear visual distinction.

4. Page reset on brand change

  • Added a useEffect watching brandId that calls setPage(1) — ensures switching brands always starts at page 1.

5. Page reset after successful track

  • setPage(1) called inside handleTrack immediately after toast.success — ensures the user lands back on page 1 after tracking a query.

What was NOT changed

  • No server actions touched (fanout.ts unchanged).
  • No other files modified.
  • Zero new TypeScript errors introduced (verified via tsc --noEmit diff before/after).

Testing

  • Load the prompts page with a brand that has >10 fan-out sub-queries → numbered controls appear below the table.
  • Click a page number → table updates to show the correct slice.
  • Switch brand → page resets to 1.
  • Track a query → page resets to 1 after success toast.

…ols, reset on brand change + track)

Closes #349

- Rename CardTitle from 'Query fan-out' to 'High frequency'
- Add PAGE_SIZE=10 constant and page state (useState(1))
- Slice subQueries into pageRows for current page (client-side, no server changes)
- Render numbered page buttons below table using shadcn Button component
- Active page uses variant=default, others variant=ghost
- Reset page to 1 on brandId change via useEffect
- Reset page to 1 after successful track inside handleTrack
- Zero new TypeScript errors introduced (verified via tsc --noEmit diff)

Signed-off-by: Maqbool Ahmed <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Welcome to Ansvisor, and thank you for your first PR! A maintainer will be by soon to review.

In the meantime, two things that make review faster:

  • A short description of why the change matters, not just what it does — most of our PRs link a Fixes #... to the issue that explains the why.
  • A quick local test note if there's anything worth eyeballing in the browser.

If you'd like to keep an eye on where Ansvisor goes next, a ⭐ on the repo helps others discover it (and Watch sends you a ping when related issues land). Either way — looking forward to your next one.

@gkhngyk gkhngyk 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.

Nice work — the logic is spot on: pagination (10/page), the numbered controls, the brand-change + post-track resets, the "High frequency" heading, and the intent column all stay intact. 🙌

One thing before merge: the file isn't Prettier-formatted — the wrapped table block needs re-indenting, so CI's format:check will fail. Please run yarn format from web/ and commit the result.

Optional / non-blocking: computing totalPages and pageRows as consts just above the return ( would read a bit cleaner than the inline IIFE — totally your call.

Thanks for the contribution!

@Maqbool61
Maqbool61 requested a review from gkhngyk July 6, 2026 18:10

@gkhngyk gkhngyk 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.

Thanks for the quick fix — Prettier's happy now (format diff is clean) and the pagination logic is unchanged: 10/page, numbered controls, brand-change + post-track resets, the "High frequency" heading, and the intent column all intact. LGTM! 🎉

@gkhngyk
gkhngyk merged commit e99df15 into ansvisor:main Jul 6, 2026
3 checks passed
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.

feat(prompts): paginate the Query Fan-out "High frequency" table (10 per page)

2 participants