feat: Sortable columns on library page (#111)#146
Conversation
Add clickable Author, Title, and Status column headers that toggle ascending/descending sort. Third click clears sort back to default. Backend validates sort columns against a whitelist to prevent injection.
🔍 Vibe Check ReviewContextPR #146 adds sortable columns (author, title, status) to the library page with proper whitelisting, three-state sorting (asc → desc → clear), and visual indicators. Codebase Patterns I Verified
✅ Good
🚨 Issues FoundNONE - This is clean, secure code.
📋 Scope Verification
Scope Status: SCOPE_OK 📝 Documentation Check
Recommendation: Add CHANGELOG entry before merge: ## [0.9.0-beta.XXX] - YYYY-MM-DD
### Added
- **Issue #111: Sortable columns** - Library table columns (Author, Title, Status) can now be sorted
- Click column headers to toggle sort order: ascending → descending → default
- Visual indicators show active sort column and direction
- Sort state preserved during pagination and filter changes
- Works across all filter contexts (pending, queue, fixed, verified, etc.)🎯 VerdictREQUEST_CHANGES Required before merge:
Why this is good code:
The ONLY issue is missing documentation - the implementation itself is excellent. Fix the CHANGELOG and this is ready to ship. |
🔍 Vibe Check ReviewContextPR #146 adds sortable columns (Author, Title, Status) to the library page table with visual indicators and persistent state across pagination/filters. Codebase Patterns I Verified
✅ Good
🚨 Issues Found
Explanation: When the page loads initially or after Code location for fix (library.html around line 402): .then(data => {
libraryData = data;
+ currentSort = data.sort || '';
+ currentSortDir = data.sort_dir || 'asc';
updateCounts(data.counts);📋 Scope Verification
Scope Status: SCOPE_OK 📝 Documentation Check
🎯 VerdictREQUEST_CHANGES Fix required:
This is a well-crafted feature with strong security practices (SQL injection protection via whitelist). The single issue is a minor state synchronization bug that could cause UI confusion when users navigate or refresh the page. Once fixed, this is ready to ship. |
🔍 Vibe Check ReviewContextPR #146 adds sortable columns (Author, Title, Status) to the library page by implementing URL parameters for sort column/direction, with whitelist validation against SQL injection. Codebase Patterns I VerifiedSQL Query Patterns:
Error Handling:
Type Hints:
Security Patterns:
✅ Good
🚨 Issues Found
Quote verification for CRITICAL issues: # app.py diff lines 52-56 (CRITICAL ISSUE #1):
def build_order_by(sort_cols, default_order):
"""Build ORDER BY clause from user sort or fall back to default."""
if sort_by and sort_by in sort_cols:
return f"ORDER BY {sort_cols[sort_by]} {sort_dir.upper()}" # <-- f-string SQL
return f"ORDER BY {default_order}"# app.py diff lines 78-86 (CRITICAL ISSUE #2 example):
order = build_order_by(HISTORY_SORT_COLS, 'h.fixed_at DESC')
c.execute(f'''SELECT h.id, h.book_id, h.old_author, h.old_title, h.new_author, h.new_title,
h.old_path, h.new_path, h.status, h.fixed_at, h.error_message,
b.path, b.current_author, b.current_title
FROM history h
JOIN books b ON h.book_id = b.id
WHERE h.status = 'pending_fix'
{order} # <-- Direct interpolation into query string
LIMIT ? OFFSET ?''', (per_page, offset))Why this is CRITICAL: The codebase has ZERO instances of
📋 Scope Verification
Scope Status: SCOPE_OK Feature fully implements the requested sortable columns functionality. 📝 Documentation CheckThis is a feat: PR
🎯 VerdictREQUEST_CHANGES BLOCKING ISSUE: SQL Injection Anti-Pattern This PR introduces f-string SQL query construction (
Required fixes before merge:
Non-blocking improvements:
The feature implementation is excellent, but the SQL construction pattern cannot be merged as-is. Fix the f-string issue and this will be ready to ship. |
🔍 Vibe Check ReviewContextPR #146 adds sortable columns (Author, Title, Status) to the library table. Users can click headers to toggle sort direction (asc → desc → clear). Backend implements whitelist-based SQL ORDER BY clause construction to prevent injection. Codebase Patterns I VerifiedI examined existing patterns in app.py to understand the project's conventions:
✅ Good
🚨 Issues Found
📋 Scope Verification
Scope Status: SCOPE_OK 📝 Documentation Check
🎯 VerdictAPPROVE This is solid work. The SQL injection protection is correctly implemented via whitelist, and the feature fully addresses Issue #111. The two LOW-severity issues I found are nitpicks that don't warrant blocking:
The code is safe to ship. The developer clearly thought about security (explicit mention in CHANGELOG, whitelist approach) and implemented comprehensive sorting across all filter contexts. Optional improvements for future consideration (not blocking):
|
Summary
Test plan