-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(cli): Fix empty tool output for list_files and search_files #5250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 700deb6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Previous Issue ResolvedThe previous review flagged an issue with incorrect content checking for tool messages. This has been fixed in the current version. The code now properly parses the JSON and checks the let hasContent = false
try {
const parsed = JSON.parse(msg.text || "{}")
hasContent = parsed.content && parsed.content.trim().length > 0
} catch {
// If parsing fails, fall back to checking text directly
hasContent = Boolean(msg.text && msg.text.trim().length > 0)
}Files Reviewed (3 files)
SummaryThis PR adds a CLI-only workaround for an extension bug where
The implementation is well-structured and the tests are thorough. |
The previous implementation checked if msg.text was non-empty, but for tool messages, msg.text is always a JSON string containing a content property. Even when content is empty, the text field itself is non-empty. This fix parses the JSON and checks if the content field is non-empty, with a fallback to checking text directly if parsing fails.
…-Org#5250) * fix(cli): Fix empty tool output for list_files and search_files * fix(cli): Parse JSON to check content field for tool messages The previous implementation checked if msg.text was non-empty, but for tool messages, msg.text is always a JSON string containing a content property. Even when content is empty, the text field itself is non-empty. This fix parses the JSON and checks if the content field is non-empty, with a fallback to checking text directly if parsing fails.
…-Org#5250) * fix(cli): Fix empty tool output for list_files and search_files * fix(cli): Parse JSON to check content field for tool messages The previous implementation checked if msg.text was non-empty, but for tool messages, msg.text is always a JSON string containing a content property. Even when content is empty, the text field itself is non-empty. This fix parses the JSON and checks if the content field is non-empty, with a fallback to checking text directly if parsing fails.
* fix(cli): Fix empty tool output for list_files and search_files * fix(cli): Parse JSON to check content field for tool messages The previous implementation checked if msg.text was non-empty, but for tool messages, msg.text is always a JSON string containing a content property. Even when content is empty, the text field itself is non-empty. This fix parses the JSON and checks if the content field is non-empty, with a fallback to checking text directly if parsing fails.
Summary
Fixes an intermittent issue where
list_files(recursive) andsearch_filestools show "Total: 0 items" and "Found: 0 matches" even when files exist.Problem
The issue is a race condition in message handling that occurs more frequently in long-running sessions. When the extension sends a partial message followed by a complete message, the complete message can sometimes be lost or rejected due to IPC timing issues. The
hidePartialMessagesfilter then removes the partial message, showing "0 items".Solution
Added
autoCompleteOrphanedPartialTools()function that marks partial tool messages as complete when:This acts as a safety net to ensure tool results are displayed even when the complete message is lost.
Technical Details
type: "ask"withask: "tool", NOTtype: "say"withsay: "tool"updateChatMessagesAtomTesting
Files Changed
cli/src/state/atoms/extension.ts- AddedautoCompleteOrphanedPartialTools()functioncli/src/state/atoms/__tests__/tool-message-completion.spec.ts- Added tests.changeset/fix-cli-partial-tool-messages.md- Changeset