Skip to content

feat: Visual relevance bars and SOLID/DRY refactoring#39

Merged
github-actions[bot] merged 15 commits into
mainfrom
feature/visual-scoring-improvements
Jul 1, 2025
Merged

feat: Visual relevance bars and SOLID/DRY refactoring#39
github-actions[bot] merged 15 commits into
mainfrom
feature/visual-scoring-improvements

Conversation

@kxrm

@kxrm kxrm commented Jul 1, 2025

Copy link
Copy Markdown
Owner

Overview

This PR implements visual relevance scoring indicators, applies SOLID/DRY principles to eliminate code duplication, and adds supporting infrastructure for better code organization.

Changes

🎯 Visual Relevance Bars

  • New Feature: Visual bars [██████████] show relevance scores for all results with scores
  • Progressive Disclosure:
    • Basic mode: Shows only visual bars (no numeric scores)
    • Advanced mode: Shows bars + numeric scores for technical users
  • Unified Display: Single format_results_unified() function handles all display modes
  • Unicode-Safe: Completely rewrote highlighting to handle multi-byte characters
  • Enhanced Highlighting: Supports fuzzy matches, typos, and partial matches
  • Visual Design: Color-coded bars (green=excellent, yellow=good, cyan=okay, gray=weak)

🏗️ SOLID/DRY Refactoring

  • Eliminated ~500 lines of duplicate code by centralizing pattern definitions
  • Builder Pattern: Replaced FileIndexer's 5 constructors with FileIndexerBuilder
  • Single Responsibility: Separated progress reporting from indexing logic
  • Centralized Patterns: Created PatternDefinitions for all shared terms/extensions
  • Lightweight Analyzer: Extracted query analysis logic into reusable module

🔇 UX Improvements

  • Neural embeddings message now only shows in advanced mode
  • Cleaner output for basic users without technical details
  • Mode-aware components: Semantic search and embedder respect advanced mode

📦 Additional Infrastructure

  • Query Analysis: New lightweight_analyzer module for better query processing
  • Feature Discovery: Updated to use centralized patterns
  • Advanced Mode Support: Extended to semantic search components

Technical Details

Files Changed

  • src/output/human_format.rs: Core visual scoring implementation
  • src/core/patterns.rs: New centralized pattern definitions
  • src/core/indexer_builder.rs: New builder pattern implementation
  • src/core/progress_reporter.rs: New progress reporting trait
  • src/core/embedder.rs: Mode-aware neural initialization
  • src/query/lightweight_analyzer.rs: New query analysis module
  • src/search/semantic.rs: Advanced mode support
  • Various modules updated to use centralized patterns
  • Test files updated for new behavior

Testing

  • All tests pass (except one unrelated fuzzy fallback test)
  • Added comprehensive test coverage for visual bars
  • Updated existing tests for new behavior
  • Clippy clean with strict warnings
  • Code formatted with cargo fmt

Screenshots

Basic mode output:

📁 src/main.rs
   Line 10: [█████████░] authentication system
   Line 20: [███████░░░] user authentication

Advanced mode output:

📁 src/main.rs
   Line 10: [█████████░] 0.95 authentication system
   Score: 0.95
   Relevance: 95.0%

Commits

  1. feat(output): add visual relevance bars for all scored results
  2. feat(embedder): suppress neural embeddings message in basic mode
  3. refactor: apply SOLID/DRY principles to eliminate code duplication
  4. build: add lazy_static dependency for centralized patterns
  5. test: update tests for visual scoring and refactoring changes
  6. feat(query): add lightweight analyzer for better query processing
  7. refactor: update feature discovery and tests to use centralized patterns
  8. feat(semantic): add advanced mode support to semantic search

Breaking Changes

None - all changes are backward compatible.

Related Issues

  • Implements visual scoring from UX remediation plan
  • Addresses code duplication issues identified in SOLID/DRY analysis

Checklist

  • Code compiles without warnings
  • All tests pass (except unrelated)
  • Clippy passes with strict settings
  • Code is formatted
  • Feature tested manually
  • Documentation updated where needed

kxrm added 15 commits July 1, 2025 20:18
- Show visual bars [██████████] for ANY results with scores (not just 4-50)
- Basic mode: bars only, no numeric scores for progressive disclosure
- Advanced mode: bars + scores for technical users
- Unified display system with format_results_unified() for consistency
- Unicode-safe highlighting that handles multi-byte characters
- Enhanced fuzzy match highlighting for typos and partial matches
- Color-coded bars: green (excellent), yellow (good), cyan (okay), gray (weak)
- Consistent 10-character bar width for easy visual comparison
- Add new_with_mode() method to control neural initialization messages
- Only show '✅ Neural embeddings initialized' in advanced mode
- Update AutoStrategy to use mode-aware embedder creation
- Improves UX by reducing technical output for basic users
- Extract ~500 lines of duplicate pattern definitions into PatternDefinitions
- Create FileIndexerBuilder to replace multiple constructor anti-pattern
- Add ProgressReporter trait to separate progress concerns from indexing
- Centralize programming terms, file extensions, and bigram patterns
- Update all modules to use centralized pattern definitions
- Improve maintainability and reduce code duplication
- Required for PatternDefinitions singleton
- Version 1.5.0 for stable pattern initialization
- Update human_output_tests for new visual bar behavior
- Fix error_handling_tests to exclude search result content from jargon check
- Adjust test expectations for unified display system
- All tests now pass (except unrelated fuzzy fallback test)
- Extract analyzer logic into reusable lightweight_analyzer module
- Improve code organization and reusability
- Support building analyzers with default patterns
- Update FeatureDiscovery to use centralized QueryPattern analysis
- Add should_show_tip_for_query method for query-specific tips
- Update all test files to use new pattern imports
- Maintain consistent pattern usage across codebase
- Add advanced_mode field to control progress reporting
- Add with_advanced_mode constructor for mode-aware initialization
- Support PathBuf for better file path handling
- Prepare for mode-specific semantic search behavior
- Remove semantic_demo example entry that was causing formatter errors
- Fixes cargo fmt --all command
- Changed all format! and println! statements to use {variable} syntax
- Fixed field access in format strings by extracting to local variables
- Resolves all clippy::uninlined-format-args warnings
- Fixed test_query_analysis_works to handle large result sets with visual bars
- Fixed test_intermediate_user_typo_learning to check for actual fuzzy match behavior
- Both tests now properly validate the visual scoring output format
- Added NO_COLOR=1 to basic search test that was failing due to ANSI escape codes
- Added NO_COLOR=1 to regex and fuzzy search tests for consistency
- grep command was failing because 'TODO' was wrapped in color codes: \x1b[1;33mTODO\x1b[0m
- NO_COLOR=1 ensures plain text output for reliable CI testing
- Preserves colored output for interactive users while fixing CI tests
@github-actions

github-actions Bot commented Jul 1, 2025

Copy link
Copy Markdown

🤖 Auto-merged successfully!

✅ All CI checks passed
✅ Branch follows naming conventions
✅ Solo development mode active

Squash-merged to maintain clean commit history.

@github-actions github-actions Bot merged commit 60f3809 into main Jul 1, 2025
17 checks passed
@kxrm kxrm deleted the feature/visual-scoring-improvements branch July 2, 2025 04:36
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