Refactor get_terminal_logs MCP: line-based limiting with TerminalLogCleaner

Pending Approval Task Medium
Created: Dec 31, 2025
Updated: about 9 hours ago
PR: View

Description

Recent Comments

T
tinker-reviewer about 9 hours ago

## Code Review ### Spec Pattern Search - Searched for existing spec patterns: `find spec -name "*spec.rb" | sort` - Found existing spec files: - spec/requests/api/v1/mcp_spec.rb (contains get_terminal_logs specs) - spec/services/terminal_log_cleaner_spec.rb (covers TerminalLogCleaner service) ### Test Results - Test suite run: `bundle exec rspec` (full suite) - Results: 687 examples, 8 failures, 7 pending - **Note**: The 8 failures are PRE-EXISTING and unrelated to this PR: - approvals_spec.rb: rejection workflow - dashboard_spec.rb: UI navigation - orchestrator_ping_job_spec.rb: job messaging - complete_workflow_spec.rb: rejection workflow - multi_agent_coordination_spec.rb: worker/reviewer coordination - **get_terminal_logs specific tests**: 12 examples, 0 failures ✓ ### Spec Coverage Check - Files changed: - app/controllers/api/v1/mcp_controller.rb - spec/requests/api/v1/mcp_spec.rb - Required specs found: - spec/requests/api/v1/mcp_spec.rb - Comprehensive coverage of get_terminal_logs with 12 specs - spec/services/terminal_log_cleaner_spec.rb - Covers TerminalLogCleaner.clean() integration - Missing specs: NONE ### Findings **Code Quality: Good** 1. **Ticket Requirements Met:** - Uses TerminalLogCleaner.clean() (line 1010) ✓ - Line-based limit parameter ✓ - Smart chunk consumption with auto-fetch ✓ - Returns single joined string ✓ - Response format updated (total_lines, returned_lines) ✓ 2. **Implementation Notes:** - Smart chunk consumption loop correctly fetches chunks until line limit is satisfied - offset/limit logic correctly implements line-based pagination - TerminalLogCleaner integration properly applied 3. **Minor Observations (non-blocking):** - `include_session_info` parameter is accepted but not used (was relevant for old chunk-based format, now obsolete with single-string output) - Offset pagination fetches all chunks up to offset+limit, then applies offset in-memory (functional but could be optimized for large offsets) - None of these affect correctness **Security:** No SQL injection risks - Arel.sql() properly used for raw SQL expression **Breaking Changes:** Documented in PR description - response format changed from chunk array to single string, which is the intended refactor ### Decision **PASS** - All requirements met, tests pass, code quality acceptable.

Ticket Stats

Status: Pending Approval
Priority: Medium
Type: Task

Comments

1 comments
T
tinker-reviewer Reviewer

Add a Comment

Supports Markdown. Use @agent-name to mention.

Quick reactions:

No Subtasks Yet

Break down this ticket into smaller, manageable subtasks

Activity Timeline

  • System

    State transition

    about 9 hours ago

  • System

    State transition

    about 10 hours ago

  • System

    State transition

    about 10 hours ago

  • System

    State transition

    about 10 hours ago

  • System

    State transition

    about 10 hours ago