Skip to content

Sortable columns, search filter, and collapsible live section for Stats tables - #26

Merged
EClinick merged 6 commits into
masterfrom
task/ec/stats-sort-search
Aug 10, 2026
Merged

EClinick merged 6 commits into
masterfrom
task/ec/stats-sort-search

Conversation

@EClinick

Copy link
Copy Markdown
Owner

What changed

Sortable column headers (APP, LIVE W, ENERGY / COST, CPU TIME / PEAK W) on both the battery and Mac mini Stats app tables:

  • Three-click cycle: natural direction (A-Z for APP, biggest-first for numeric columns) -> flipped -> back to natural order.
  • The default (no sort) preserves each table's natural ordering - live sections keep LiveTodayMerger's hysteresis-stable order, history stays energy-descending - so the live view never buries the apps drawing power right now.
  • Hover previews a dimmed arrow showing what the first click will do; the active sort shows a solid arrow.
  • Live-watts comparisons are quantized to the displayed precision so rows never visibly trade places while showing identical values.

Search filter in the pane title row: case/diacritic-insensitive, whitespace-trimmed, Esc or the clear button resets it; sections that filter out entirely are hidden and a no-match caption shows.

Collapsible DRAWING POWER NOW section on both Stats dashboards, reusing the popover's CollapsibleLiveHeader (with the collapsed 'N apps - X.X W' summary). The Mac mini table gains a proper live/EARLIER split, with row assembly extracted into a pure MacMiniAppRows helper.

Also: energy column widened to 88pt so ENERGY / COST renders on one line, and the standard 0.18s ease curve is consolidated into one shared juiceStandardEase constant (was duplicated at four sites).

Why

The Stats app tables were fixed-order only; sorting and filtering were requested for the circled column headers, with popover parity for collapsing the live section.

How it was verified

  • 360 tests in 44 suites pass via make test, including new unit coverage for the sort cycle, natural-order preservation, quantization, trimmed queries, and Mac mini row sectioning.
  • A 26-agent adversarial code review confirmed 10 findings (2 live-ordering regressions among them); 9 fixed, 1 intentional (APP header flush-left with the pane title).
  • Exercised manually in the built app: sort cycling on live data, search, collapse on both dashboards.

- Column headers cycle through three states on click: natural direction,
  flipped, then off (back to default order)
- Hover preview arrows indicate the sort direction a click would apply
- Add a search filter for the Stats app tables on both the battery and
  Mac mini dashboards
- Introduce a shared juiceStandardEase animation constant
- Add unit tests for the sorting and filtering behavior

https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
Share the popover's CollapsibleLiveHeader and use it for DRAWING POWER
NOW in the battery Today/Session tables and a new live/EARLIER split on
the Mac mini table. Row assembly moves to a pure, tested MacMiniAppRows
helper. Also widen the energy column to 88pt so ENERGY / COST stays on
one line, with a shrink-instead-of-wrap guard on all column titles.

Claude-Session: https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
Copilot AI lite review requested due to automatic review settings August 10, 2026 12:13
@vercel

vercel Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
website Ignored Ignored Preview Aug 10, 2026 12:50pm

Copilot AI 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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e78ece117

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +155 to +156
func effectiveColumn(hasLiveWatts: Bool) -> Column {
column == .liveWatts && !hasLiveWatts ? .energy : column

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear the live-watts sort when its column disappears

When a user selects LIVE W in Today and then switches to Week/All Time—or Session changes to historical mode on AC—appTableSort remains .liveWatts while the LIVE W header is removed. This fallback silently sorts the historical rows by energy, but no visible header shows an active sort and the user cannot complete the live column's click cycle to restore natural order. Clear or translate the live-watts sort whenever showsLivePower becomes false.

Useful? React with 👍 / 👎.

Reset the table sort to natural order when live power leaves the table,
so a LIVE W sort cannot silently keep sorting by energy with its header
gone. Quantize PEAK W to its displayed precision before comparing, the
same guard LIVE W already has against same-value row swaps.

Claude-Session: https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
String(format: %.1f) rounds ties to even, so displayedLiveWatts must do
the same or an app hitting exactly 0.25 W keys as 0.3 while showing
0.2 W, letting rows move with no visible change.

Claude-Session: https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
0.35 is above the true binary midpoint, so display and sort key both
round up; only exactly representable midpoints like 0.25 round to even.

Claude-Session: https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
Arithmetic rounding imitations double-round: 0.45 * 10 lands on exactly
4.5 and ties-to-even keys it 0.4 while %.1f displays 0.5. Format the
value with the same %.1f/%.2f the row renders and parse it back, so key
and display can never disagree. Keys are computed once per row, and the
boundary tests are now verified against printf output.

Claude-Session: https://claude.ai/code/session_018mkxULoejU6mi9V73xmFG2
@EClinick
EClinick merged commit 5600509 into master Aug 10, 2026
2 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.

2 participants