Skip to content

Make story filtering and ranking configurable - #22

Merged
brianlovin merged 5 commits into
mainfrom
claude/add-configurable-settings-Koml9
Jan 26, 2026
Merged

Make story filtering and ranking configurable#22
brianlovin merged 5 commits into
mainfrom
claude/add-configurable-settings-Koml9

Conversation

@brianlovin

Copy link
Copy Markdown
Owner

Summary

This PR makes the HN CLI's story filtering, ranking, and comment display behavior fully configurable through an interactive settings panel. Previously, these parameters were hardcoded constants. Users can now adjust 10 different settings to customize how stories are filtered, ranked, and displayed.

Key Changes

  • New settings module (src/settings.ts): Centralized configuration system with:

    • 10 configurable parameters covering filtering, ranking, comments, and caching
    • Validation ranges with min/max bounds and step increments
    • Settings organized into 4 categories for UI presentation
    • Load/save/reset/update functions for persistent configuration
  • Updated API layer (src/api.ts):

    • Removed hardcoded constants (MAX_ROOT_COMMENTS, MAX_CHILD_COMMENTS, etc.)
    • All filtering and ranking logic now uses settings from loadSettings()
    • Functions accept optional FilterSettings parameter for dependency injection
  • Enhanced settings UI (src/components/SettingsPanel.ts):

    • Added filter settings section with category headers
    • Left/right arrow keys adjust numeric values within valid ranges
    • Visual indicators show modified settings (asterisk) and current values
    • "Reset All to Defaults" button appears when settings are modified
    • Updated help text to show arrow key navigation
  • App integration (src/app.ts):

    • Added left/right arrow key handlers to adjust settings
    • New handleSettingsAction cases for adjust_setting and reset_filters
    • Settings changes immediately reflected in UI
  • Config persistence (src/config.ts):

    • Filter settings stored in config file alongside API keys
    • clearAllApiKeys() now preserves filter settings when clearing
  • Cache integration (src/cache.ts):

    • Stories TTL now configurable (previously hardcoded 5 minutes)
    • Dynamic TTL loaded from settings

Configurable Settings

Story Filtering: Max stories, time window, minimum points/comments
Ranking: Comment weight in scoring, recency bonus magnitude
Comments: Root comment limit, child comment limit, nesting depth
Advanced: API fetch limit, cache TTL

All settings have sensible defaults matching the original briOS implementation.

Create a settings module that allows users to configure story filtering,
ranking, comment display, and caching behavior through the settings panel.

Key changes:
- New src/settings.ts with FilterSettings interface, defaults, validation ranges,
  and load/save/reset functions
- Update api.ts to use settings instead of hardcoded constants for all filters
- Update cache.ts to use configurable TTL
- Update config.ts to persist filter settings
- Update SettingsPanel to display filter settings with left/right arrow adjustment
- Update app.ts to handle new settings actions (adjust_setting, reset_filters)

Settings are organized into categories:
- Story Filtering: maxPosts, hoursWindow, minPoints, minComments
- Ranking: commentWeight, recencyBonusMax
- Comments: maxRootComments, maxChildComments, maxCommentLevel
- Advanced: fetchLimit, storiesTtlMinutes

All settings have validation ranges to prevent invalid values.
@brianlovin
brianlovin force-pushed the claude/add-configurable-settings-Koml9 branch from cb75f2e to 49d3baf Compare January 26, 2026 15:50
brianlovin and others added 4 commits January 26, 2026 07:56
Restructure settings panel to match the story detail view pattern:
- Fixed "Settings" header at top with border
- Scrollable content area for all settings items
- Fixed shortcuts bar at bottom showing navigation hints

This allows the settings panel to handle tall content gracefully
when many filter settings are displayed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change "Settings" header to bold text-secondary
- Move Telemetry section to bottom before actions
- Add "(private and anonymous)" sublabel to telemetry toggle
- Remove "Done" button in favor of save-on-close with Esc

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Hide "Advanced" and "Ranking" sections (need more explanation)
- Add subtitle descriptions under each setting in text-secondary
- Arrow keys skip subtitle lines (non-selectable)
- Updated descriptions to be clearer and more helpful

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documentation:
- Add comprehensive Settings section to README with tables for all options
- Add Settings System section to CLAUDE.md with interface, functions, and behavior
- Update keyboard shortcuts and architecture sections in both files

Code fixes:
- Fix import placement in settings.test.ts (move to top of file)
- Remove stale "done" action test (button was removed from UI)
- Remove unused currentCategoryKey variable in SettingsPanel.ts
- Fix scroll reset on every render (preserve scroll when adjusting settings)
- Fix maxPosts description ("display" not "fetch")

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@brianlovin
brianlovin merged commit ff6c172 into main Jan 26, 2026
1 check passed
@brianlovin
brianlovin deleted the claude/add-configurable-settings-Koml9 branch January 26, 2026 16:22
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