feat(session-ui): display tool input context on error - #43487
Conversation
When a tool fails, show the relevant input context (command, file path, URL, query, etc.) above the error message so users can immediately see what the tool was trying to do before the failure occurred. This addresses the UX issue where failed tool operations only showed a generic error message without any indication of what was being attempted. Changes: - Add getToolContextLabel() helper to extract relevant input per tool type - Add optional `input` prop to ToolErrorCard - Render context label/value above error body when available - Add i18n keys for all context labels (command, file, url, etc.) - Style the context display with monospace font for the value 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
The following comment was made by an LLM, it may be inaccurate: Based on my search for related PRs, I found one potentially related PR: PR #42253: fix(opencode): propagate session errors and surface tool-load warnings in the UI This PR appears related because it also focuses on surfacing tool-related errors and warnings in the UI. While PR #43487 specifically adds input context display to tool errors, PR #42253 handles broader error and warning propagation for the UI, so they may have overlapping concerns around error messaging. However, they target different aspects: PR #43487 is specifically about displaying tool input context above error messages (what the tool was trying to do), while PR #42253 is about general error/warning propagation. They may complement each other or have minor overlap in error card rendering. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #43434
Type of change
What does this PR do?
When a tool fails (permission denied, error, etc.), the error card previously only showed the error message with no context about what the tool was trying to do. This made it hard to understand what went wrong without expanding the card and reading the raw error.
This PR adds a context line above the error message that displays the relevant input based on the tool type. For example, when a shell command fails, you now see
Command: git statusdirectly on the error card. When a file read fails, you seeFile: src/main.ts.The implementation adds a
getToolContextLabel()helper that maps each tool type to its most relevant input field (command for shell, filePath for read/edit/write, url for webfetch, etc.). The newinputprop onToolErrorCardis optional, so all existing usage continues to work unchanged.How did you verify your code works?
ToolErrorCardandToolPartDisplaycomponents to understand the data flowpart.state.inputis available in error state (confirmed viaToolStateErrortype in SDK)--v2-text-text-*,--v2-font-family-mono)Screenshots / recordings
No UI recording available yet — this is a small additive change to the error card component.
Checklist