Skip to content

Add Tool, ToolApproval, ToolGroup, Reasoning and Activity #97

Closed

Description

@pratikbuilds

Render an agent's work (thinking, tool calls, approvals) as parts that stand alone and fold together inside a message, with approvals rendered from their record. Also give the shared story axe sweep a reliable contrast check on translucent backgrounds such as the attention wash.

Part of #94.

Depends on #95, #96.

Why

An agent's steps need parts that work on their own and fold into one summary line inside a chat message. Approvals follow Interchange's record: approved or denied, once or always, or timed out or expired. The host passes the record and never computes the resolved state.

Axe tends to report text on a translucent background as "incomplete" rather than pass or fail, and the approval's text sits on --attention-wash. Without a fallback the sweep can't vouch for it.

What

  • src/ui/tool.tsx: Tool, ToolHeader, ToolInput, ToolOutput.
  • src/ui/tool-approval.tsx: ToolApproval (part, onDecide({ outcome, scope })). Pending shows Approve, Approve always and Deny; any other status shows the resolved line from part.approval (approved once, approved always, denied, timed out, expired).
  • src/ui/tool-group.tsx: ToolGroup for a PartToolBatch.
  • src/ui/reasoning.tsx: Reasoning, ReasoningTrigger, ReasoningContent.
  • src/ui/activity.tsx: Activity, ActivityTrigger, ActivityContent.
  • stories/chat/tool.stories.tsx and stories/chat/activity.stories.tsx, using the shared samples from Add sample conversations for the chat stories #96.
  • e2e/stories-a11y.spec.ts: when axe returns color-contrast as incomplete inside a story's iframe, measure the element's computed text and background colours (compositing translucent backgrounds) and fail below 4.5:1, keying failures the same way e2e/stories-a11y.known.json does. Every later story inherits the check.
  • e2e/fixtures.tsx: a tool-approval scenario that records decisions, with e2e/tool-approval.spec.ts.
  • src/ui/tool.test.tsx, src/ui/tool-approval.test.tsx, src/ui/activity.test.tsx; the five modules exported from src/index.ts.

Requirements

  • R13: Tool and its parts render every ToolTraceStatus, input and output through a caller render prop.
  • R14: ToolApproval with Approve, Approve always and Deny; resolved approvals rendered from the record.
  • R15: ToolGroup, Reasoning and Activity (summary line closed, latest 10 open, a control for the rest); open state controllable.
  • R11: the contrast fallback makes the "no serious or critical violation" check hold on the wash.
  • R5–R12: the shared component rules.

Constraints

  • "Pending" follows the contract rule: approval.status === "pending" wins over ToolTraceStatus; a part with no record falls back to ToolTraceStatus === "approval-requested".
  • Open state through useControllableState; no timers inside the components.
  • Labels are props with English defaults.
  • The old ToolBlock, ToolNarrative, ReasoningBlock and ApprovalCard stay until Remove the old chat components #110; these are new modules beside them.
  • The shared rules in Replace the chat components with a stateless Conversation family #94 apply: no new dependency or peer, no optional-peer import, token-only styling, no change to existing modules, additions only to src/index.ts and e2e/fixtures.tsx.

Done when

  • Unit tests cover:
    • Each ToolTraceStatus renders its label and icon, and the error state shows the output.
    • ToolApproval pending calls onDecide once with { outcome: "approved", scope: "once" }, { outcome: "approved", scope: "always" } or { outcome: "rejected", scope: "once" }; each resolved status renders its line and no buttons; a record marked pending shows the buttons whatever the ToolTraceStatus.
    • Activity closed shows the summary; opening shows the latest 10 and a control that reveals the rest; a controlled open is respected.
  • The approval spec passes in the browser.
  • The axe sweep gives the approval story a pass or fail contrast verdict, never only "incomplete".
  • No serious or critical axe violation in the new stories, in light or dark.
  • bun run check, bun run build, bun run test:e2e and bun run dep-guard pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions