Skip to content

Make Trends the default dashboard tab - #82

Open
alltheseas wants to merge 1 commit into
mainfrom
feat/trends-default-tab
Open

Make Trends the default dashboard tab#82
alltheseas wants to merge 1 commit into
mainfrom
feat/trends-default-tab

Conversation

@alltheseas

@alltheseas alltheseas commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Default landing tab changed from "By Kind" to "Trends" (app leaderboard)
  • Trends table now sorts by lowest error rate first (best compliance at top)
  • "Latest Error Rate" column header is clickable — toggles between ascending (▴) and descending (▾) sort

Test plan

  • Open dashboard — Trends tab should be active by default
  • Verify apps with 0% error rate appear at top
  • Click "Latest Error Rate" header — apps with highest error rate should move to top
  • Click again — returns to lowest-first order
  • Verify other tabs (By Kind, By App, Errors) still work when clicked

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Trends table now supports interactive sorting by latest error rate with visual ascending/descending indicators.
    • Click the "Latest Error Rate" column header to toggle sort order.
    • Default active tab changed from "By Kind" to "Trends."

The app leaderboard (Trends tab) is now the landing view, sorted by
lowest error rate first. The "Latest Error Rate" column header is
clickable to toggle between ascending and descending sort order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Updated the "Trends" table in the export panel to support interactive sorting by latest error rate. Changed the default active tab from "By Kind" to "Trends," added sortable header styling with direction indicators, and implemented client-side click-driven sorting logic with state management.

Changes

Cohort / File(s) Summary
Trends Table Interactive Sorting
src/commands/export.ts
Changed default active tab to "Trends"; added sortable header styling with asc/desc classes; removed fixed sort logic; implemented sortAsc state (default ascending by error rate), getLatestRate(app) helper, and renderTrends() function; made "Latest Error Rate" header clickable to toggle sort direction and re-render table.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The Trends now dance at my command,
Sorting errors across the land,
Click the header, watch them swirl,
Ascending, descending—a data whirl!
No more static, the table's alive,
Interactive magic makes users thrive! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making the Trends tab the default dashboard tab. It is concise, clear, and directly reflects the primary objective of the changeset.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/trends-default-tab

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

🧹 Nitpick comments (1)
src/commands/export.ts (1)

670-673: Consider using the delegated click handler for consistency.

The event listener is re-attached every time renderTrends() runs. While this works because the element is replaced via innerHTML, the codebase pattern (lines 680-697) uses event delegation with data-* attributes. This would be more consistent and slightly more efficient.

♻️ Suggested refactor using delegated handler

Update the header to use a data attribute:

-    var html = '<table><thead><tr><th>App</th><th>Direction</th><th>Sparkline (last 30d)</th><th class="sortable ' + sortClass + '" id="sort-error-rate">Latest Error Rate</th><th>Data Points</th></tr></thead><tbody>';
+    var html = '<table><thead><tr><th>App</th><th>Direction</th><th>Sparkline (last 30d)</th><th class="sortable ' + sortClass + '" data-action="toggle-trends-sort">Latest Error Rate</th><th>Data Points</th></tr></thead><tbody>';

Remove the inline listener and update the delegated handler at line 680:

 document.addEventListener('click', function(e) {
+  // Trends sort toggle
+  var sortHeader = e.target.closest('[data-action="toggle-trends-sort"]');
+  if (sortHeader && typeof window.toggleTrendsSort === 'function') {
+    window.toggleTrendsSort();
+    return;
+  }
   // Copy handler
   var copyEl = e.target.closest('.copy[data-copy]');

Then expose the toggle function:

-    document.getElementById('sort-error-rate').addEventListener('click', function() {
-      sortAsc = !sortAsc;
-      renderTrends();
-    });
   }
+
+  window.toggleTrendsSort = function() {
+    sortAsc = !sortAsc;
+    renderTrends();
+  };

   renderTrends();

Based on learnings: "In HTML dashboard generation, NEVER use inline onclick handlers. Use data-* attributes with the delegated click handler".

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

In `@src/commands/export.ts` around lines 670 - 673, The direct event listener on
the 'sort-error-rate' element should be replaced with a delegated click via the
existing delegated handler used around renderTrends(); remove the
document.getElementById('sort-error-rate').addEventListener(...) block, add a
data-sort-error (e.g. data-sort-error="toggle") attribute to the header element
that currently has id 'sort-error-rate', and update the delegated click handler
(the function that currently handles other data-* clicks near renderTrends()) to
check event.target.dataset.sortError and, when present, toggle the same sortAsc
flag and call renderTrends(); alternatively extract the toggle into a small
function toggleSortErrorRate() and call that from the delegated handler so the
behavior is identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/commands/export.ts`:
- Around line 670-673: The direct event listener on the 'sort-error-rate'
element should be replaced with a delegated click via the existing delegated
handler used around renderTrends(); remove the
document.getElementById('sort-error-rate').addEventListener(...) block, add a
data-sort-error (e.g. data-sort-error="toggle") attribute to the header element
that currently has id 'sort-error-rate', and update the delegated click handler
(the function that currently handles other data-* clicks near renderTrends()) to
check event.target.dataset.sortError and, when present, toggle the same sortAsc
flag and call renderTrends(); alternatively extract the toggle into a small
function toggleSortErrorRate() and call that from the delegated handler so the
behavior is identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5caeba09-6824-481f-98d8-599006526f8a

📥 Commits

Reviewing files that changed from the base of the PR and between fd94888 and 4946820.

📒 Files selected for processing (1)
  • src/commands/export.ts

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.

1 participant