') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix(bugs): clamp page on empty client-side filter results by ayush-that · Pull Request #335 · usedetail/cli · GitHub
Skip to content

fix(bugs): clamp page on empty client-side filter results - #335

Merged
sachiniyer merged 1 commit into
usedetail:mainfrom
ayush-that:fix/clamp-page-empty-filter-paths
Aug 25, 2026
Merged

fix(bugs): clamp page on empty client-side filter results#335
sachiniyer merged 1 commit into
usedetail:mainfrom
ayush-that:fix/clamp-page-empty-filter-paths

Conversation

@ayush-that

@ayush-thatayush-that commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

bugs list --vulns --page 5 on a repo with no vulns prints Page: 5 of 1.

The issue suggests clamping in both early-return branches. I dropped the returns instead: they only printed the empty-result hint, and the code just below already handles an empty set and clamps the page. Now reads Page: 1 of 1.

Closes#334.


Open in Devin Review

Summary by cubic

Clamps page number for empty client-side filter results in bugs list, fixing incorrect "Page: N of 1" output. Before: early returns printed the hint and returned "Page: 5 of 1"; now: print the hint (table only) and fall through to normal pagination, yielding "Page: 1 of 1".

  • Removes two early returns in empty-result branches; retains the empty-results hint for table output.
  • Delegates empty sets to output_list, which clamps the page.
  • No changes to non-table formats or non-empty results.

Written for commit 4b3aa46. Summary will update on new commits.

Review in cubic

CopilotAI lite review requested due to automatic review settings August 20, 2026 11:26
@aviator-app

aviator-appBot commented Aug 20, 2026

Copy link
Copy Markdown

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

CopilotAI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@devin-ai-integrationdevin-ai-integrationBot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@cubic-dev-aicubic-dev-aiBot 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.

No issues found across 1 file

Re-trigger cubic

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Tested this PR end-to-end by running the locally built binary against a locally running Detail backend (dev DB) with a minted API key. All scenarios pass; the page clamp now applies on empty client-side filter results.

Baseline (main) vs fix (this PR) — repo bkRoad (bugs but zero vulns):

$ detail bugs list bkRoad --vulns --page 5 # main (broken)
No security vulnerabilities found with the current filters.
Page: 5 of 1
$ detail bugs list bkRoad --vulns --page 5 # this PR (fixed)
No security vulnerabilities found with the current filters.
Page: 1 of 1
Other scenarios (all passed)

--introduced-by with a nonexistent author, --page 7:

No bugs matched --introduced-by. None of the current bugs have author information.
Page: 1 of 1

JSON format on empty results (no hint, valid JSON, clamped page):

$ detail bugs list bkRoad --vulns --page 5 --format json
{ "items": [], "total": 0, "page": 1, "total_pages": 1 }

Regression — non-empty results unchanged (detail repo, 205 pending bugs / 11 vulns):

  • bugs list detail --page 2 → 50 entries numbered 51–100, footer Page: 2 of 5
  • bugs list detail --vulns → 11 vuln bugs, footer Page: 1 of 1, no hint

Also verified locally: cargo build, cargo clippy -- -D warnings, cargo fmt --check, cargo test (all pass).

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown
Contributor

/aviator merge

@aviator-app

Copy link
Copy Markdown

Aviator has accepted the merge request. It will enter the queue when all of the required status checks have passed. Aviator will update the sticky status comment as the pull request moves through the queue.

@devin-ai-integrationdevin-ai-integrationBot 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.

Approving after end-to-end testing (see test results comment above). Approved on behalf of Sachin's merge request.

@sachiniyer

Copy link
Copy Markdown
Contributor

thanks for the contribution @ayush-that !

@aviator-app

Copy link
Copy Markdown

Skipping bot pull request creation because the queue is empty and this pull request is up to date with main.

@aviator-app

Copy link
Copy Markdown

This pull request failed to merge: blocked by Github, possibly missing approvals or merge cannot be cleanly created. After you have resolved the problem, you should remove the blocked pull request label from this PR and then try to re-queue the PR.

Failed checks: Security Audit, Vendored Artifacts, Tests, Check, Clippy, plan, Formatting

Additional debug info: Merge commits are not allowed on this repository.

@sachiniyer
sachiniyer merged commit 06b0762 into usedetail:mainAug 25, 2026
15 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] CLI: bugs list shows impossible page numbers on some client-side filtered empty results

3 participants

@ayush-that@sachiniyer