fix(elements): render empty-string tool output in ToolOutput - #481
Open
shoemoney wants to merge 1 commit into
Open
fix(elements): render empty-string tool output in ToolOutput#481shoemoney wants to merge 1 commit into
shoemoney wants to merge 1 commit into
Conversation
The ToolOutput guard !(output || errorText) treats every falsy output as absent, so a tool that legitimately returns an empty string (reading an empty file, a search with no matches) renders nothing at all. Hide only when output is nullish and there is no error text; empty string, 0, and false now render as results.
Contributor
|
@shoemoney is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
CI note: Vercel failure is pre-existing on main/trunk and unrelated to this PR's changed files. Vercel Authorization required to deploy reproduces identically on recent fork PRs 475, 476, 477, 478 and is unrelated to tool.tsx/tool.test.tsx; all code checks pass. No code fix required from this PR; rebase/label will clear it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #399.
ToolOutputhides any falsyoutputbecause its early return isif (!(output || errorText))(packages/elements/src/tool.tsx:141). A tool that legitimately returns an empty string, like reading an empty file or a search with no matches, renders nothing at all, not even the "Result" header.0andfalseoutputs are hidden the same way.The guard now hides only when
outputis nullish (undefinedornull) and there is noerrorText. Empty string,0, andfalsefall through to the normal rendering branches. Behavior fornull/undefinedoutput and for error text is unchanged.How tested
Four new tests in
packages/elements/__tests__/tool.test.tsx: empty-string,0, andfalseoutputs render the "Result" section, andnulloutput still renders nothing (pinning the existing hide behavior). With the source change reverted and the tests kept in place, the three falsy-output tests fail and the other 24 pass; with the fix, all 27 pass. Full@repo/elementssuite: 47 files, 962 tests, all passing.oxlintclean on both changed files.Deliberately not changed: the
errorTextside of the guard still uses a truthiness check, so an empty-stringerrorTextkeeps its current hide behavior. Empty error text carries no information worth rendering, and changing it would widen the diff past the reported issue.