Skip to content

feat(tui): dedicated renderers for background-agent tools (#3103)#3117

Open
aheritier wants to merge 1 commit into
feat/tui-delegation-return-markerfrom
feat/tui-background-agent-renderers
Open

feat(tui): dedicated renderers for background-agent tools (#3103)#3117
aheritier wants to merge 1 commit into
feat/tui-delegation-return-markerfrom
feat/tui-background-agent-renderers

Conversation

@aheritier

@aheritier aheritier commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

The four background-agent tools (run / list / view / stop_background_agent) had no entry in the tool factory, so they fell through to defaulttool and rendered as raw JSON / text blobs. This gives them dedicated, presentation-only renderers so a dispatched fleet reads like delegations. Builds on #3102.

  • run_background_agent → a delegation-style card root dispatches worker (accent badges) + the task text, led by the same status-aware fixed-width icon as the transfer_task card (TUI: make a single delegation unambiguous (transfer_task) #3101).
  • view / stop_background_agentSimpleRendererWithResult showing the task id (argument) + the formatted result.
  • list_background_agents → shows the task listing. (The plan suggested NoArgsRenderer, but that drops the result — the only useful payload until a live surface lands — so the listing is preserved.)

No runtime change. The live "Background agents (N)" sidebar panel (Appendix C.2) is intentionally out of scope here and remains approval-gated.

Screenshots

run_background_agent fans out to several workers in parallel — each renders as a root dispatches worker card:

phase3-dispatch

list_background_agents shows the live fleet (three workers running concurrently):

phase3-list

Tests

  • pkg/tui/components/tool/backgroundagentrun per-ToolStatus glyph + fixed-width invariant; view/stop show task id + result; list shows its result; ANSI-stripped.

task build / task lint clean; touched-package tests pass (same unrelated teamloader DMR failure as #3101).

Stack

Top of the stack — stacked on #3102 (← #3101). Tracking #3104.

Refs #3103

@aheritier aheritier requested a review from a team as a code owner June 15, 2026 04:41

@docker-agent docker-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This PR adds dedicated TUI renderers for the four background-agent tools (run_background_agent, list_background_agents, view_background_agent, stop_background_agent). The implementation correctly mirrors the transfertask sibling pattern, and factory registration is complete and correct — all four tool-name constants map to the right constructors.

No high or medium severity bugs found. The drafter identified five low-severity observations:

  1. renderRun uses json.Unmarshal directly rather than the partial-JSON toolcommon.ExtractField path — streaming partial payloads produce an empty params.Task (card renders an orphaned icon). The transfertask sibling has the same limitation, so this is consistent with the codebase.
  2. iconWidth computed from lipgloss.Width of an ANSI-styled string is correct today but would silently misalign wrapped-line indents if margin conventions changed.
  3. renderList intentionally surfaces error-status content as a result, which is reasonable but asymmetric with NoArgsRenderer.
  4. TestRunCard_StatusIcon hard-codes spinner frame "⠋", creating a fragile coupling to spinner implementation details.
  5. TestRunCard_IconWidthIsStable does not assert len(parts)==3 before indexing parts[len(parts)-1], so a degenerate render could silently measure the wrong column.

None of these warrant blocking the PR. Test coverage for status-icon transitions, icon-width stability, view/stop task-ID extraction, and list result visibility is solid.

@aheritier aheritier marked this pull request as draft June 15, 2026 04:59
@aheritier aheritier added area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat: commit prefix) labels Jun 15, 2026
@aheritier aheritier self-assigned this Jun 15, 2026
@aheritier aheritier added the status/in-progress For stuff that's being worked on label Jun 15, 2026
@aheritier aheritier added area/agent For work that has to do with the general agent loop/agentic features of the app area/tools For features/issues/fixes related to the usage of built-in and MCP tools and removed status/in-progress For stuff that's being worked on labels Jun 15, 2026
@aheritier aheritier marked this pull request as ready for review June 15, 2026 11:33

@docker-agent docker-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

One medium-severity finding in the new backgroundagent renderer package. The PR correctly mirrors the transfertask pattern and the factory registration is complete. The finding is a known streaming limitation that toolcommon.ParseArgs was designed to address.

Comment thread pkg/tui/components/tool/backgroundagent/backgroundagent.go Outdated
@aheritier aheritier force-pushed the feat/tui-delegation-return-marker branch from d38caed to 3871fdb Compare June 15, 2026 12:12
@aheritier aheritier force-pushed the feat/tui-background-agent-renderers branch from cf40afa to d0f18c0 Compare June 15, 2026 12:12
@aheritier aheritier force-pushed the feat/tui-delegation-return-marker branch from 3871fdb to af97d1c Compare June 15, 2026 12:36
@aheritier aheritier force-pushed the feat/tui-background-agent-renderers branch from d0f18c0 to d432398 Compare June 15, 2026 12:36
The four background-agent tools (run/list/view/stop) had no entry in the
tool factory, so they fell through to defaulttool and rendered as raw
JSON/text blobs. Give them dedicated, pure-presentation renderers so a
dispatched fleet reads as delegations:

- run_background_agent: a delegation-style card "<sender> dispatches
  <agent>" with the task text, led by a status-aware icon (animated
  spinner while Running/Pending, checkmark on success, cross on error).
  Reuses the transfer_task card's fixed-width single-glyph icon so the
  wrapped task-text indent stays stable across statuses.
- view_background_agent / stop_background_agent: SimpleRendererWithResult
  showing the task id (argument) plus the already human-formatted result
  text once the call lands.
- list_background_agents: shows the tool result (the task listing). The
  plan suggested NoArgsRenderer, but that drops the result, which is the
  only useful payload for list until the C.2 live surface lands; showing
  it also avoids regressing below the prior defaulttool behavior.

No runtime change.

Refs #3103
@aheritier aheritier force-pushed the feat/tui-delegation-return-marker branch from af97d1c to e19f53b Compare June 15, 2026 13:18
@aheritier aheritier force-pushed the feat/tui-background-agent-renderers branch from d432398 to 0ed315d Compare June 15, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent For work that has to do with the general agent loop/agentic features of the app area/tools For features/issues/fixes related to the usage of built-in and MCP tools area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants