Skip to content

feat: add daemon-backed TUI client - #482

Merged
delete-cloud merged 1 commit into
mainfrom
dogfood/local-daemon-tui-client
Jun 3, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
dogfood/local-daemon-tui-client

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add coding_agent daemon tui to create a local-path daemon session and render display-event SSEs through Rich TUI
  • allow prompt streaming helpers to emit display events to a wire consumer while preserving existing console rendering
  • update ADR-0058 daemon-backed client status and help/CLI regression coverage

Tests

  • uv run pytest tests/cli/test_remote_client.py -k "daemon_command_starts or local_daemon or daemon_run or daemon_repl or daemon_tui or emit_display_events or stream_prompt_requests_display_event" -v
  • uv run pytest tests/cli/test_entrypoint_contract.py -k "daemon or subcommand_help" -v
  • uv run ruff check src/coding_agent/cli/serve_command.py src/coding_agent/remote/client.py tests/cli/test_remote_client.py tests/cli/test_entrypoint_contract.py

Summary by CodeRabbit

  • New Features

    • Added a new daemon tui command to run a single prompt through a local daemon with a Rich terminal interface.
    • Added support for live, structured progress updates in the terminal, including interactive approval prompts and completion status reporting.
    • Added options to choose the model, limit maximum steps, and keep or automatically clean up the session afterward.
  • Documentation

    • Updated architecture notes to reflect that the terminal UI workflow is now completed and supported.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a new daemon tui CLI command that runs single prompts through an already-running local daemon while rendering progress via Rich TUI. The change adds a DisplayWireConsumer protocol to the remote client for pluggable, consumer-driven event handling, wires it through the prompt-like SSE streaming layer, and implements the CLI subcommand to use Rich TUI as a display consumer.

Changes

Daemon TUI Feature

Layer / File(s) Summary
Display Consumer Protocol and Remote Client Integration
src/coding_agent/remote/client.py, tests/cli/test_remote_client.py
Adds DisplayWireConsumer protocol with async emit and request_approval methods; threads it through stream_prompt_or_run_request → _stream_prompt_like_request → _handle_prompt_like_sse_event; implements _handle_prompt_like_sse_event_with_consumer to translate legacy SSE payloads into strongly typed WireMessage objects; coordinates approval round-trips with async callbacks; includes test validating consumer receives StreamDelta and TurnEnd events.
Daemon TUI CLI Command and Contract
src/coding_agent/cli/serve_command.py, tests/cli/test_entrypoint_contract.py, tests/cli/test_remote_client.py
Implements daemon tui subcommand with options for goal, repo, model, max-steps, and session cleanup; creates TUI context; builds daemon-backed local session; streams prompt with TUI consumer wired to display events; conditionally deletes remote session in finally block. Includes CLI help contract test and integration test verifying TUI consumer is passed to daemon HTTP control plane.
ADR Implementation Status
docs/adr/0058-local-daemon-control-plane-executor-architecture.md
Marks coding_agent daemon tui as completed, documenting that it creates a daemon-local session and renders display-event SSEs through Rich TUI consumer without owning an in-process runtime manager.

Sequence Diagrams

sequenceDiagram
  participant RemoteClient
  participant Consumer
  participant WireMessage
  RemoteClient->>RemoteClient: stream_prompt_or_run_request(display_consumer)
  RemoteClient->>RemoteClient: _stream_prompt_like_request(display_consumer)
  RemoteClient->>RemoteClient: _handle_prompt_like_sse_event(sse_event, display_consumer)
  alt display_consumer provided
    RemoteClient->>RemoteClient: _handle_prompt_like_sse_event_with_consumer
    RemoteClient->>WireMessage: translate SSE payload to WireMessage
    RemoteClient->>Consumer: asyncio.run(emit(WireMessage))
    alt is ApprovalRequest
      RemoteClient->>Consumer: asyncio.run(request_approval(ApprovalRequest))
      Consumer-->>RemoteClient: ApprovalResponse
      RemoteClient->>RemoteClient: _submit_approval(response)
    end
  else no consumer
    RemoteClient->>RemoteClient: default legacy stdout handling
  end
Loading
sequenceDiagram
  participant User
  participant CliCommand
  participant DaemonLocalSession
  participant StreamPrompt
  participant TUIConsumer
  User->>CliCommand: daemon tui --goal "..." --url ...
  CliCommand->>CliCommand: CodingAgentTUI().__enter__()
  CliCommand->>DaemonLocalSession: _create_daemon_local_session
  DaemonLocalSession-->>CliCommand: session_id
  CliCommand->>StreamPrompt: stream_prompt_or_run_request(display_consumer=tui.consumer)
  StreamPrompt->>TUIConsumer: emit(StreamDelta), emit(TurnEnd), etc
  TUIConsumer-->>StreamPrompt: ack
  StreamPrompt-->>CliCommand: status_code
  CliCommand->>DaemonLocalSession: optionally delete session (finally block)
  CliCommand->>User: SystemExit(status_code)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Poem

🐰 A TUI blooms where daemons run,
Display events skip and dance,
Rich colors flow for every turn,
Consumer protocol stands in stance,
Prompts now sing with styled ✨ glance!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: adding a new daemon-backed TUI client command with focused scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dogfood/local-daemon-tui-client

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@delete-cloud

Copy link
Copy Markdown
Owner Author

Manual P1/P2 fallback review because CodeRabbit remained pending and has not produced review findings.

Scope reviewed:

  • coding-agent/src/coding_agent/cli/serve_command.py
  • coding-agent/src/coding_agent/remote/client.py
  • coding-agent/tests/cli/test_remote_client.py
  • coding-agent/tests/cli/test_entrypoint_contract.py
  • coding-agent/docs/adr/0058-local-daemon-control-plane-executor-architecture.md

Focus:

  • daemon TUI session lifecycle and cleanup
  • display-event SSE to wire consumer conversion
  • approval request submission path
  • existing daemon run/repl compatibility

Result: no actionable P1/P2 correctness, security, data-loss, or agreed-scope findings found.

Verification:

  • uv run pytest tests/cli/test_remote_client.py -k "daemon_command_starts or local_daemon or daemon_run or daemon_repl or daemon_tui or emit_display_events or stream_prompt_requests_display_event" -v
  • uv run pytest tests/cli/test_entrypoint_contract.py -k "daemon or subcommand_help" -v
  • uv run ruff check src/coding_agent/cli/serve_command.py src/coding_agent/remote/client.py tests/cli/test_remote_client.py tests/cli/test_entrypoint_contract.py

@delete-cloud
delete-cloud merged commit 8df5982 into main Jun 3, 2026
1 check was pending
@delete-cloud
delete-cloud deleted the dogfood/local-daemon-tui-client branch June 3, 2026 03:37
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.

1 participant