feat(ai-harness-cli)!: no UI library; runCli({ ui }) runs any TUI on a session view #1549
feat/harness-p11-session-view fromfeat/harness-p12-cli·opened View on GitHubTo show your own screen in a terminal, pass runCli(harness, { ui }). It works with any TUI library. @tanstack/ai-harness-cli has no UI library now: it does not depend on ink, react, or @types/react. Without ui, a terminal uses line mode, the same as piped input.
Stacked on #1546 (Phase 11) → #1540 → #1538 → #1524 → #1523 → #1522 → #1521 → #1520 → #1519 → #1518 → #1515 → #1513 → #1509. Merge those first.
🎯 Changes#
runCli(harness, { ui }), withui: (view: SessionView) => Promise<void> | void. In an interactive terminal,runClimakescreateSessionView(session)and waits forview.ready. Then it runsui(view), waits for it, and disposes the view. Piped input uses line mode, even withui.- No built-in Ink screen.
src/interactive.tsxis deleted. Withoutui, a terminal uses line mode. - Line mode prints from the session view. The new
src/printer.tsprints streamed text, and one bracketed line for each tool call, child agent, notice, question, and sign-in. In a terminal, line mode also opens sign-in links in the browser. The old event fold (applyEvent,applyChildEvent,ViewEntry) is deleted. It was internal. - An Ink screen in the example.
examples/harness-cli/src/tui.tsxis built on the view. It shows the transcript, tool calls, child agents, approvals (y/n), questions, sign-ins (links open in the browser), the goal line fromselectGoal, and the status. It has/help,/connect,/disconnect, and/exit. Esc cancels and Enter steers.src/cli.tsgives it torunCliasui. - Dependencies. The example lists
ink,react,@tanstack/react-store, and@types/reactitself.ts-react-chatmoves@tanstack/react-storefrom^0.8.0to^0.11.1, so sherif sees one version, andts-solid-chatmoves@tanstack/solid-storefrom^0.8.0to^0.11.1. Nothing in theirsrcimports them. Every direct TanStack Store dependency in the workspace is now on the latest release (0.11.1).
Also in this PR:
- Docs:
docs/harness/cli.md(line mode in a terminal, a new "Run your own screen" section, links to the example and to custom-ui), one line incustom-ui.md, the CLI package README, theUSAGEtext, and the message inprint.ts. - Changeset:
@tanstack/ai-harness-climinor. The!in the title marks the removed Ink screen. The stack is not released yet.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Testing#
Commands run (not the full pnpm test:pr, see below):
- ai-harness-cli:
vitest run(5 files, 22 tests pass),test:types,test:oxlint(0 errors, 0 warnings),build, andtest:build(publint: all good). - ai-harness, after the Phase 11 merge:
build, andvitest run(30 files, 259 tests pass). - Root:
install --frozen-lockfile --offline(up to date),test:sherif(0 errors),test:knip(pass, config hints only),test:docs(no broken links), andkiira check docs/harness/cli.md docs/harness/custom-ui.md(3 snippets pass, 6 ignored). The one sherif warning is old:examples/reacthas nopackage.json. - Examples:
tsc --noEmitinexamples/harness-cli, andtest:typesinexamples/ts-react-chatandexamples/ts-solid-chatpass. - I skipped the full
pnpm test:prbecause it is slow on this machine. CI runs it. No new E2E test: this is terminal behavior of the CLI, and no browser app uses it.
Manual test
No real terminal run was done. A scratch script drove runCli with ui: runTui by fake keystrokes, with the demo model. hi got the demo answer, /help listed the commands, /todos printed its result, and /exit quit with code 0. Piped input still used line mode. To do the real terminal run:
- Run
pnpm install, thenpnpm build:all. - In a real terminal, run
pnpm --filter harness-cli-example start. Without an API key, a demo model answers. Expect the Ink screen fromsrc/tui.tsx. - Type
hi, then/help, then/todos. Expect the demo answer, the command list, and the todo list. Type/exit. Expect the process to stop with code 0. - Run
echo /agents | pnpm --filter harness-cli-example start. Expect plain lines from line mode, not the Ink screen. - To see line mode in a terminal, remove
ui: runTuifromexamples/harness-cli/src/cli.ts, then do step 2 again. Expect plain lines.
How this PR makes testing easy
tests/cli.test.ts,custom ui(3 tests): a terminal gets a ready view andrunCliwaits forui. Piped input uses line mode, even withui. A terminal withoutuiuses line mode.tests/printer.test.ts(3 tests): streamed text, each item printed one time, and line breaks between turns. Long child answers are cut, failed children are reported, and each kind of sign-in prints.mark()hides the history.- The old line mode tests pass with no change.
cli.test.tsandchild-view.test.tspassed 10 runs in a row. - The example app:
pnpm --filter harness-cli-example startshows the new Ink screen.
Risk / rollback#
Low. The stack is not released yet, so no published CLI loses the Ink screen. Two things can change for code on this stack:
- A CLI that calls
runCli(harness)in a terminal now gets line mode, not the Ink screen. To keep a full screen, passui.examples/harness-cli/src/tui.tsxis a start. - Line mode now reads from the session view, not from
session.events(). If a line prints two times or not at all, the cause is insrc/printer.ts.
Revert the PR to undo.
Public API change#
Before
// In a terminal, this showed the built-in Ink screen.
process.exitCode = await runCli(harness)
After
// In a terminal, this uses line mode.
process.exitCode = await runCli(harness)
// Your own screen, with any TUI library.
process.exitCode = await runCli(harness, {
ui: async (view) => {
await render(<Screen view={view} />).waitUntilExit()
},
})
🤖 Generated with Claude Code
- 1
View your CI Pipeline Execution ↗ for commit 7790e06647e575412419dc7af5349f980e3a9e18
Command Status Duration Result nx run-many --targets=build --exclude=examples/...✅ Succeeded 2m 23s View ↗
☁️ Nx Cloud last updated this comment at
2026-09-28 15:10:09UTC@tanstack/ai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1549@tanstack/ai-acp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1549@tanstack/ai-angular
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1549@tanstack/ai-anthropic
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1549@tanstack/ai-bedrock
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1549@tanstack/ai-byteplus
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1549@tanstack/ai-claude-code
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1549@tanstack/ai-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1549@tanstack/ai-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1549@tanstack/ai-code-mode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1549@tanstack/ai-code-mode-snippets
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1549@tanstack/ai-codex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1549@tanstack/ai-cohere
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1549@tanstack/ai-compaction
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1549@tanstack/ai-dashboard
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-dashboard@1549@tanstack/ai-devtools-core
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1549@tanstack/ai-durable-stream
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1549@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1549@tanstack/ai-event-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1549@tanstack/ai-fal
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1549@tanstack/ai-gemini
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1549@tanstack/ai-grok
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1549@tanstack/ai-grok-build
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1549@tanstack/ai-groq
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1549@tanstack/ai-harness
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@1549@tanstack/ai-harness-cli
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@1549@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1549@tanstack/ai-isolate-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1549@tanstack/ai-isolate-node
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1549@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1549@tanstack/ai-isolate-quickjs-bun
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1549@tanstack/ai-llmgateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1549@tanstack/ai-lovable
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1549@tanstack/ai-mcp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1549@tanstack/ai-memory
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1549@tanstack/ai-mistral
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1549@tanstack/ai-octane
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1549@tanstack/ai-ollama
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1549@tanstack/ai-openai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1549@tanstack/ai-opencode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1549@tanstack/ai-openrouter
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1549@tanstack/ai-perplexity
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1549@tanstack/ai-persistence
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1549@tanstack/ai-preact
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1549@tanstack/ai-react
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1549@tanstack/ai-react-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1549@tanstack/ai-reactor
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1549@tanstack/ai-remix
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1549@tanstack/ai-sandbox
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1549@tanstack/ai-sandbox-blaxel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1549@tanstack/ai-sandbox-boxd
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1549@tanstack/ai-sandbox-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1549@tanstack/ai-sandbox-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1549@tanstack/ai-sandbox-docker
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1549@tanstack/ai-sandbox-e2b
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1549@tanstack/ai-sandbox-local-process
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1549@tanstack/ai-sandbox-sprites
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1549@tanstack/ai-sandbox-upstash-box
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1549@tanstack/ai-sandbox-vercel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1549@tanstack/ai-skills
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1549@tanstack/ai-solid
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1549@tanstack/ai-solid-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1549@tanstack/ai-svelte
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1549@tanstack/ai-typesafe
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1549@tanstack/ai-utils
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1549@tanstack/ai-vercel-gateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1549@tanstack/ai-vertex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1549@tanstack/ai-vue
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1549@tanstack/ai-vue-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1549@tanstack/ai-worldlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1549@tanstack/openai-base
npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1549@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1549@tanstack/react-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1549@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1549@tanstack/svelte-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1549commit:
7790e06Review the following changes in direct dependencies. Learn more about Socket for GitHub.
Diff Package Supply Chain
SecurityVulnerability Quality Maintenance License npm/@tanstack/solid-store@0.11.1 github-actions[bot](GitHub profile, opens in a new tab) assignedtombeckenham
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Closed in favor of the combined PR #1555, which holds this phase and every other phase of the harness (P0 to P14) on one branch against main. All further fixes go there. This PR stays as the review record of P12.
AlemTuzlak closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository: TanStack/ai/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
6811fe6d-28f4-4766-a2da-37fc8d89539aYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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