background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Improve Web App UI for get-task-status function call

Open ColeMurray opened this issue 5 months ago • 8 comments

When an agent makes a function call to view the task status of a child session, depending on the arguments, it can return the complete response.

It would be nice to have this better formatted and a more rich first-party presentation of this tool call within the UI

current

Image

ColeMurray avatar Jun 10 '26 06:06 ColeMurray

Hi! I'd like to work on this issue.

heat0206 avatar Jun 10 '26 06:06 heat0206

thanks @heat0206!

I'm happy to extend this further with a richer custom UI component if maintainers would prefer a more structured presentation of task metadata and final responses.

this was something I had more in mind, basically some kind of rich formatted UI that would better show the output

ColeMurray avatar Jun 11 '26 06:06 ColeMurray

@open-inspect[bot] the code currently doesn't look setup to render custom component UIs for tools. Review through the surrounding code and provide a high level overview of what would be required to do this?

ColeMurray avatar Jun 11 '26 06:06 ColeMurray

I reviewed the current event/rendering path. High-level: the web app can support this, but today it is only set up for generic tool rendering plus a one-off slack-notify special case, not a reusable custom component system.

Relevant current flow:

  • SandboxEvent defines tool_call as { tool, args, callId, status?, output?, ... } in packages/shared/src/types/index.ts. The output is just a string.
  • The control plane persists/broadcasts tool_call events opaquely in packages/control-plane/src/session/sandbox-events.ts; it does not interpret tool-specific payloads.
  • The session page groups consecutive tool_call events in packages/web/src/app/(app)/session/[id]/page.tsx and renders them through ToolCallGroup / ToolCallItem.
  • ToolCallItem currently renders generic JSON args + preformatted output. The only custom UI path is a direct if (event.tool === "slack-notify") return <SlackNotifyEvent ... /> branch in packages/web/src/components/tool-call-item.tsx.
  • get-task-status currently returns formatted plain text from packages/sandbox-runtime/src/sandbox_runtime/tools/get-task-status-format.js, even though the underlying control-plane child summary endpoint already returns structured JSON (ChildSessionDetail) with session metadata, artifacts, recent events, optional final response, and optional trajectory.

What I think would be required:

  1. Introduce a first-class custom tool renderer layer in the web app instead of adding more if (tool === ...) branches. For example, a registry keyed by normalized tool name that can provide collapsed summary metadata and an expanded React component, with a generic fallback using the current formatToolCall behavior.

  2. Decide on the data contract for rich tool output. There are two viable approaches:

    • Minimal/fast path: keep the existing tool output as text and have a get-task-status renderer parse the known formatted output. This is brittle and probably not worth building around.
    • Better path: have tools that need rich rendering emit a structured JSON envelope in tool_call.output, e.g. { ok: true, renderer: "get-task-status", version: 1, data: <ChildSessionDetail or list payload> }, while preserving readable fallback text if needed. This mirrors the slack-notify direction, but should be formalized rather than tool-specific.
  3. Extend shared types to document the optional structured output/envelope shape. The existing SandboxEvent.tool_call.output can remain a string for compatibility, but the renderer should parse JSON defensively and fall back to generic output on malformed/unknown versions. If we want stronger typing across packages, add shared types for get-task-status UI payloads rather than duplicating shape in web.

  4. Update get-task-status in packages/sandbox-runtime to return the structured payload for both modes:

    • list mode: child task count summary + child rows with id/title/status/createdAt
    • detail mode: the existing ChildSessionDetail JSON from the control-plane endpoint, including final response and trajectory when requested The current text formatter can still be used as a fallback field or by clients that do not render the envelope.
  5. Build a GetTaskStatusEvent component in packages/web and register it. The useful UI would likely include status badge, title/task id, repo/branch/model, created/updated timestamps, artifact links, final response rendered with existing markdown/safe text handling, tool summary, recent events, and a paginated trajectory hint when cursor is present.

  6. Keep grouping behavior in mind. ToolCallGroup groups consecutive calls by event.tool, so a custom renderer must work both as a single expanded item and inside a grouped list. The registry should be used by ToolCallItem, and optionally by formatToolGroup if grouped summaries should become richer.

  7. Add tests at the renderer and formatter boundaries:

    • registry falls back for unknown tools / invalid envelopes
    • get-task-status list and detail payloads render correctly
    • long final responses and trajectory/event data are bounded and safe to display
    • existing generic rendering and slack-notify behavior are unchanged

So the main implementation is not in the control-plane event pipeline; that path is already generic enough. The work is mostly: formalize a structured tool-output envelope, emit it from get-task-status, replace the one-off custom renderer branch with a small registry, and add the first get-task-status rich component on top of that.

open-inspect avatar Jun 11 '26 06:06 open-inspect

Thanks, this makes sense.

For the renderer registry approach, would you prefer introducing the registry first and migrating the existing slack-notify special case to it, then adding get-task-status on top? Or would you prefer keeping the existing slack-notify implementation as-is and only using the registry for new tool renderers?

heat0206 avatar Jun 11 '26 07:06 heat0206

introducing the registry first and migrating the existing slack-notify special case to it

this makes sense to me. let's introduce the registry with slack-notify as the first use-case, and then can create a follow-up change with the get-task-status specific one

ColeMurray avatar Jun 11 '26 17:06 ColeMurray

Sounds good, that approach makes sense to me.

I'll take a look at introducing the renderer registry first and moving the existing slack-notify implementation over to it. Once that's in place, we can build the get-task-status renderer on top of the new structure.

heat0206 avatar Jun 12 '26 07:06 heat0206

Resolved by #2424 (merged 2026-10-15), following the plan agreed above. Verified on current main.

  • Renderer registry: packages/web/src/components/tool-call-renderers.tsx replaces the one-off slack-notify branch, and ToolCallItem dispatches through getToolRenderer(). slack-notify was migrated to the registry first.
  • Rich child-status presentation: get-child-status, and the legacy get-task-status name, render through child-status-details.tsx. It shows child session metadata and links, status, and the final response as sanitized Markdown. Legacy plain-text output falls back to the generic view.
  • Structured payload: a versioned format (packages/shared/src/child-status-tool.ts) is produced by the sandbox-runtime tool, with tests on both sides.

Closing.

open-inspect avatar Oct 25 '26 21:10 open-inspect