Skip to content

feat(session-ui): display tool input context on error - #43487

Open
12britz wants to merge 1 commit into
anomalyco:devfrom
12britz:feat/tool-error-context-info
Open

feat(session-ui): display tool input context on error#43487
12britz wants to merge 1 commit into
anomalyco:devfrom
12britz:feat/tool-error-context-info

Conversation

@12britz

@12britz 12britz commented Aug 19, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #43434

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 status directly on the error card. When a file read fails, you see File: 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 new input prop on ToolErrorCard is optional, so all existing usage continues to work unchanged.

How did you verify your code works?

  • Read through the existing ToolErrorCard and ToolPartDisplay components to understand the data flow
  • Verified that part.state.input is available in error state (confirmed via ToolStateError type in SDK)
  • All i18n keys are new additions — no existing strings modified
  • CSS uses existing design system tokens (--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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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>
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

[FEATURE][DESKTOP]: Display more information for failed (permission asked / original value before failed, for shell, edit, tool, mcp, webfetch, etc)

1 participant