Files
OpenHands/.pr/issue-132/demo.gif
T
Graham Neubigandopenhands e8ffdd2829 Render ACP sub-agent tool-call events in chat (port of OpenHands#13994 + #14246 + #14247) (#142)
* Render ACP sub-agent tool-call events in chat (#132)

Port of upstream OpenHands frontend PRs:
  - OpenHands#13994 — initial ACPToolCallEvent rendering
  - OpenHands#14246 — drop the 'ACP · ' prefix from titles
  - OpenHands#14247 — suppress in_progress events to avoid empty-args flash

Adds end-to-end support for the new V1 ACPToolCallEvent surfaced by ACP
sub-agents (Claude Code, Codex, Gemini CLI, …). Each tool call is rendered
through the same GenericEventMessage wrapper used for observation events,
so the resulting card shape, success indicator, and markdown formatting
match the rest of the OpenHands chat.

Highlights:
  - New ACPToolCallEvent type + isACPToolCallEvent type guard, wired into
    the OpenHandsEvent union.
  - getACPToolCallContent + getACPToolCallTitleKey helpers — execute calls
    render as Command:/Output: blocks just like getTerminalObservationContent;
    non-execute calls render their raw_input as a JSON Input: block. Errors
    use **Error:**, missing output falls back to OBSERVATION$COMMAND_NO_OUTPUT,
    and very long output is truncated to MAX_CONTENT_LENGTH.
  - getACPToolCallResult — maps status + is_error to success | error |
    undefined, mirroring getObservationResult so in_progress calls render
    without a check mark.
  - shouldRenderEvent — hides in_progress ACP events to avoid an empty-args
    card flashing before the first populated event arrives (matches #14247).
  - handleEventForUI — dedupes ACP events by tool_call_id so streaming
    in_progress → completed/failed transitions update the card in place
    instead of stacking duplicate cards.
  - EventMessage dispatch — routes ACP events to GenericEventMessageWrapper
    after hook execution events, before generic action handling.
  - Five new ACTION_MESSAGE$ACP_* i18n keys (RUN / EDIT / READ / FETCH /
    TOOL) localised across all bundled languages, with the title rendered
    inline via the existing <cmd> Trans component (no 'ACP · ' prefix per
    #14246).

Tests: 39 new/modified vitest cases across get-acp-tool-call-content,
should-render-event, handle-event-for-ui, and event-message-acp-tool-call.

Visual verification + demo GIF: .pr/issue-132/

This commit was created by an AI agent (OpenHands) on behalf of the user.

Co-authored-by: openhands <openhands@all-hands.dev>

* Capture real ACP card rendering for #142 demo

Addresses @neubig's review feedback on PR #142 ('I did not see any
examples of ACP events being rendered in the interface'):

  - Updates demo.gif to actually show three ACPToolCallEvent cards
    rendering in the live conversation UI (collapsed view + expanded
    view with Command/Output/Input blocks).
  - Adds 04-acp-cards-collapsed.png + 05-acp-cards-expanded.png as the
    individual frames, plus 04-acp-rendering-notes.md explaining what
    each frame shows and why a synthetic event injection was needed
    (no Claude Code / Codex / Gemini CLI binary in the sandbox).
  - Adds capture.mjs (the Playwright script used to record the demo) so
    future re-records are reproducible.
  - In src/stores/use-event-store.ts, exposes the existing Zustand
    store on window.__OH_EVENT_STORE__ when import.meta.env.DEV is
    true. Tree-shaken from production builds; no behaviour change for
    end users. Useful as a general dev affordance for fixture/preview
    tooling beyond this PR.

Functional verification (unchanged from the original PR):

    npx vitest run         __tests__/components/v1/chat/event-content-helpers/get-acp-tool-call-content.test.ts         __tests__/components/v1/chat/event-message-acp-tool-call.test.tsx
    Test Files  2 passed (2)
         Tests  20 passed (20)

This commit was created by an AI agent (OpenHands) on behalf of the user.

Co-authored-by: openhands <openhands@all-hands.dev>

---------

Co-authored-by: openhands <openhands@all-hands.dev>
2026-05-07 20:35:11 -04:00

113 KiB
1280x823px