Skip to content

[FEATURE] Improve Testability of View components #108

Closed

Description

@edenreich

Summary

Currently in order to see if a component looks as expected I have to go into chat mode, and see if it looks as I wanted - better would be if there was a way to just render it directly in the terminal so I can iterate over the improvements pixel by pixel faster.

Acceptance Criteria

  • View components are easier to test - styling adjustments etc
  • It's documented in the contributing guide

Activity

  1. added
    enhancement
    on Aug 23, 2025
  2. edenreich commented on Aug 23, 2025

    @edenreich
    ContributorAuthor

    @claude can you work on this?

    I'm in particular want to test a diff view component and the approval view.

  3. claude commented on Aug 23, 2025

    @claude
    Contributor

    Claude finished @edenreich's task —— View job • claude/issue-108-20250823-1519 • Create PR ➔


    I'll work on improving the testability of View components, focusing on the diff view and approval view components you mentioned. Let me start by analyzing the current codebase structure and creating a plan.

    Todo List

    • Analyze current View component architecture
    • Set up development environment
    • Create a testing mechanism to render components directly
    • Test the implementation with diff view and approval view
    • Document the new testing approach in contributing guide
    • Run quality checks
    • Commit changes and create PR

    Implementation Complete! 🎉

    I've successfully created a new infer test-view command that allows you to test and preview UI components directly in the terminal. Here's what I built:

    New Command: infer test-view

    • Approval View Testing: infer test-view approval - Renders the approval component with sample tool data
    • Diff Renderer Testing: infer test-view diff - Shows colored diff output for Edit and MultiEdit tools
    • Configurable: Width, height, and sample content can be customized via flags

    Key Features:

    • ✅ Direct Terminal Rendering - No need to enter chat mode to see component styling
    • ✅ Pixel-Perfect Iteration - Test different component states and sizes
    • ✅ Sample Data Support - Built-in realistic test cases for both components
    • ✅ Customizable Parameters - Control width, height, and sample content via CLI flags

    Example Usage:

    # Test approval view with default sample data
    infer test-view approval
    
    # Test diff renderer with custom content
    infer test-view diff --old "old code" --new "new code"
    
    # Test with custom dimensions
    infer test-view approval --width 120 --height 40

    What's Included:

    • New Command: cmd/test_view.go - Complete implementation with flag support
    • Documentation: Updated CONTRIBUTING.md with comprehensive testing guide
    • Quality Assured: All tests pass, code formatted, and meets project standards

    The implementation shows beautiful colored diffs with Tokyo Night theme styling, selection states for the approval component, and proper text wrapping. Perfect for rapid UI development iteration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions