Skip to content

fix(miners): Score sort matches displayed value and Repository is sortable#279

Merged
anderdc merged 1 commit intoentrius:testfrom
eureka0928:fix/miner-prs-table-sort
Apr 15, 2026
Merged

fix(miners): Score sort matches displayed value and Repository is sortable#279
anderdc merged 1 commit intoentrius:testfrom
eureka0928:fix/miner-prs-table-sort

Conversation

@eureka0928
Copy link
Copy Markdown
Contributor

@eureka0928 eureka0928 commented Apr 15, 2026

Summary

On the Miner Details page's PR table (/miners/details?githubId=<id>&tab=pull-requests):

  • Score column sort was broken for open PRs. The comparator read pr.score unconditionally while the cell's render fallback shows collateralScore for open PRs, score for merged PRs, and - for closed-unmerged. Every open PR collapsed to sort key 0 and clicking Score never reordered them. Verified against miner 42954461: 17 open PRs, all pr.score = "0.000000", collateralScore ranging from 0.001 to 0.370 → old comparator had 1 distinct sort key, new comparator has 17.
  • Repository column was not sortable. The header was a plain <TableCell>Repository</TableCell> with no click target, even though the other five columns are sortable.

Changes — src/components/miners/MinerPRsTable.tsx

  1. getEffectiveScore(pr) helper mirrors the Score cell's render fallback exactly (CLOSED && !mergedAt → 0, !mergedAt && collateralScore → parseFloat(collateralScore), else parseFloat(score)). Used in the 'score' sort case so the sort key matches the displayed value.
  2. 'repository' added to PrSortField with a.repository.localeCompare(b.repository) and a pullRequestNumber tiebreaker. Within a single repo, rows get a deterministic order that flips with the primary sort direction.
  3. DEFAULT_SORT_DIR: Record<PrSortField, SortDir> map centralizes each column's natural idle direction (string columns ascending, numeric/date descending). handleSort reads from it instead of branching on the field name, so adding Title/Author sort in the future is a one-line map entry.
  4. Repository header wrapped in <TableSortLabel> consistent with PR #, +/-, Score, Date. Idle-state direction pulled from DEFAULT_SORT_DIR.repository.

Diff stat: 1 file, +40 / −4.

Related Issues

Closes #276

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Screenshots

Before:

Screencast.from.2026-04-15.01-53-43.webm

Clicking Score on miner 42954461 leaves the open-PR rows (marked "Collateral") in API order. Repository header is static.

After:

Screencast.from.2026-04-15.01-51-27.webm

Same miner, same clicks. Score now reorders open-PR rows by their displayed collateral value (highest-first, then lowest-first on toggle). Repository is a sortable header that groups rows by owner/repo with a pullRequestNumber tiebreaker.

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

…table

The Score column's sort comparator unconditionally read `pr.score`, while
the cell's render fallback chain shows `collateralScore` for open PRs,
`score` for merged PRs, and `-` for closed-unmerged. Clicking Score on a
miner with many open PRs collapsed all of them to a single sort key (`0`),
so the visible collateral column never reordered.

Extract `getEffectiveScore(pr)` that mirrors the render fallback exactly
and use it in the `'score'` case. Also add `'repository'` to `PrSortField`
with a `localeCompare` comparator and a `pullRequestNumber` tiebreaker,
and wrap the Repository header in `<TableSortLabel>`.

Introduce a `DEFAULT_SORT_DIR` map so each column has a self-documenting
natural direction (string columns ascending, numeric/date descending),
and `handleSort` reads from it instead of branching on the field name.

Closes entrius#276
@eureka0928 eureka0928 force-pushed the fix/miner-prs-table-sort branch from ec93c7f to b710f45 Compare April 15, 2026 01:16
@anderdc anderdc merged commit ef05f27 into entrius:test Apr 15, 2026
2 checks passed
@anderdc anderdc added the bug Something isn't working label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Miner PRs table: Score sort broken for open PRs, Repository column unsortable

2 participants