Skip to content

fix: show fallback description for [read] and [apply_patch] tool lines#363

Open
thunter009 wants to merge 2 commits intosubsy:mainfrom
thunter009:fix/tool-call-display-fallback
Open

fix: show fallback description for [read] and [apply_patch] tool lines#363
thunter009 wants to merge 2 commits intosubsy:mainfrom
thunter009:fix/tool-call-display-fallback

Conversation

@thunter009
Copy link
Contributor

@thunter009 thunter009 commented Mar 17, 2026

Summary

  • Tool call lines like [read] and [apply_patch] displayed with no arguments when input field names didn't match the hardcoded formatter set (file_path, command, pattern, etc.)
  • Added extractFallbackDisplay() that kicks in when no known fields match — scans input values for the first useful short string, prioritizing path-like values
  • Also added fallback input extraction in OpenCode parser: event.part?.input when event.part?.state?.input is missing

Closes #362

Test plan

  • 6 new tests covering fallback behavior for both legacy string and TUI-native segment formatters
  • Existing 51 formatting tests + 97 OpenCode tests all pass
  • Typecheck and build clean
  • Manual verification: run ralph-tui with opencode agent and confirm [read] and [apply_patch] lines now show their arguments

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements

    • Tool call displays now include fallback details (e.g. file paths or other input) when standard fields are missing, and long values are truncated for readability.
    • Tool event input resolution now falls back to an alternative input source when the primary one is absent.
  • Tests

    • Expanded tests covering unknown fields, path-like values, long-value truncation and fallback behaviour across formatting pathways.

Tool call display showed bare [read] and [apply_patch] with no arguments
when input field names didn't match the hardcoded set. Add fallback that
extracts the first useful string value from input, prioritizing paths.
Also check event.part.input as fallback in OpenCode parser.

Closes subsy#362

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 17, 2026

@thunter009 is attempting to deploy a commit to the plgeek Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d591c902-c957-4d64-a486-df388425dcd9

📥 Commits

Reviewing files that changed from the base of the PR and between 71d50e7 and bc5a57f.

📒 Files selected for processing (1)
  • src/plugins/agents/output-formatting.ts
✅ Files skipped from review due to trivial changes (1)
  • src/plugins/agents/output-formatting.ts

Walkthrough

Update adds input-source fallback in the OpenCode JSONL parser and implements a display fallback that extracts a short, path‑preferential string from unknown tool input fields; tests and exports added to cover the new formatting fallback behaviour.

Changes

Cohort / File(s) Summary
OpenCode parser
src/plugins/agents/builtin/opencode.ts
Changed tool input lookup to use event.part.input when event.part.state.input is undefined, ensuring alternative input source is consulted.
Tool output formatting
src/plugins/agents/output-formatting.ts
Added extractFallbackDisplay(input) helper to pick a short, useful string (preferring path-like values, truncating to 120 chars) and appended fallback text in formatToolCall and formatToolCallSegments when known fields produce no extra content.
Tests & exports
src/plugins/agents/output-formatting.test.ts, src/plugins/agents/output-formatting.js
Exported formatToolCallSegments and segmentsToPlainText; extended tests to validate fallback behaviour for unknown fields, path-like prioritisation, long-value truncation, and that known-field cases do not trigger fallback.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding fallback display logic to show tool arguments for [read] and [apply_patch] tool calls.
Linked Issues check ✅ Passed The pull request directly addresses all objectives from issue #362: ensuring [read] shows file paths and [apply_patch] shows target files through fallback display logic.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing tool call display for [read] and [apply_patch]. Test additions for fallback behaviour and OpenCode parser fallback are both in scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 65.90909% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.38%. Comparing base (fcea670) to head (bc5a57f).

Files with missing lines Patch % Lines
src/plugins/agents/output-formatting.ts 68.29% 13 Missing ⚠️
src/plugins/agents/builtin/opencode.ts 33.33% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #363      +/-   ##
==========================================
+ Coverage   47.35%   47.38%   +0.03%     
==========================================
  Files         111      111              
  Lines       36446    36488      +42     
==========================================
+ Hits        17258    17289      +31     
- Misses      19188    19199      +11     
Files with missing lines Coverage Δ
src/plugins/agents/builtin/opencode.ts 72.88% <33.33%> (-0.17%) ⬇️
src/plugins/agents/output-formatting.ts 64.35% <68.29%> (+1.76%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/plugins/agents/output-formatting.ts`:
- Around line 154-172: The loop in src/plugins/agents/output-formatting.ts
currently drops any string value longer than 200 chars which causes long patch
bodies (e.g., apply_patch) to be discarded and no fallback shown; remove the
hard skip (the if (value.length > 200) continue;) and instead accept long values
into the selection logic (so bestPath / bestShort can be set from them) and rely
on the existing truncation step (result.length > 120 ? result.slice(0,120) +
'...' : result) to shorten the final output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 871392ca-c99e-4426-a0ae-b6483835ed40

📥 Commits

Reviewing files that changed from the base of the PR and between fcea670 and 71d50e7.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • src/plugins/agents/builtin/opencode.ts
  • src/plugins/agents/output-formatting.test.ts
  • src/plugins/agents/output-formatting.ts

The length guard prevented long string values (e.g. apply_patch bodies)
from being considered for fallback display, causing blank output.
The existing 120-char truncation already keeps output short.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Bug: [read] and [apply_patch] tool lines show no description in iteration log

1 participant