Files
codewhale/crates/tui/tests
Hunter Bown 903e4537f4 refactor(strings): rebrand user-facing strings to codewhale
Rename brand-bearing string literals across the TUI source and the
system-prompt templates that ship inside the binary. The DeepSeek
provider integration is again left intact: the `ApiProvider::Deepseek`
enum variant, the `"deepseek"` provider name string returned by
`ApiProvider`-to-string mappings, model IDs, the `~/.deepseek/` config
directory and `DEEPSEEK_CONFIG_PATH` env var, the OS keyring key
`"deepseek"`, the Ollama `deepseek-coder*` model defaults, the China
preset alias `deepseek-china`, and the various provider list error
messages all keep the legacy spelling.

Touchpoints:

- `crates/tui/src/prompts/*.md` and `*.txt`: brand language flipped to
  `codewhale`; the internal `<deepseek:subagent.done>`,
  `<deepseek:subagent_context>`, `<deepseek:fork_state>`,
  `<deepseek:tool_call>` XML-ish event tags rename in lockstep to
  `<codewhale:…>` so the model-facing format stays consistent.
- `crates/tui/src/tools/subagent/mod.rs`: emits the new event tag.
- `crates/tui/src/core/tool_parser.rs`: parses the new event tag.
- `crates/tui/src/tools/subagent/tests.rs`,
  `crates/tui/tests/protocol_recovery.rs`,
  `crates/tui/src/prompts.rs`: test expectations updated to match the
  new tag and the new prompt text.
- Status / display strings flipped to `codewhale`: `acp_server.rs`'s
  agent name + title, `config_ui.rs`'s config schema title,
  `share.rs`'s export title, `welcome.rs`'s onboarding banner,
  `commands/status.rs`, `core/engine*`, `tui/notifications.rs`,
  `tui/sidebar.rs`, `tui/widgets/header.rs`, `tui/widgets/mod.rs`,
  `tui/ui.rs`'s resume-hint, `main.rs`'s clap header and `Doctor`
  prose, `tui/ui/tests.rs` and other test assertions.
- `crates/tui/src/logging.rs` test fixture: `deepseek_cli=debug` ->
  `codewhale_cli=debug` so the log-filter test references the renamed
  crate.
- Tracing targets that were namespaced under the brand
  (`target: "deepseek::config"`) move to `target: "codewhale::config"`.
- Test-fixture tempdir prefixes (`deepseek-tui-…` / `deepseek-…`) rename
  for consistency.

Local gates green: `cargo check --workspace --all-targets --locked`,
`cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets
--all-features --locked -- -D warnings`, `cargo test --workspace
--all-features --locked` (3226+ pass, 0 fail).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 11:48:43 -05:00
..

crates/tui/tests/

Integration tests for the TUI binary. Per CONTRIBUTING.md, each crate's integration tests live in its own tests/ directory; the repository-root tests/ directory is unused.

Mock LLM client (integration_mock_llm.rs)

crates/tui/src/llm_client/mock.rs provides a MockLlmClient that implements the LlmClient trait by replaying queue-driven canned responses and capturing every outgoing MessageRequest. Tests mock at the trait boundary — never at the reqwest HTTP layer — because the trait is the durable abstraction the runtime is meant to depend on.

Coverage today exercises the trait surface end-to-end:

  • streaming turn loop
  • reasoning-content replay across tool-call rounds (V4 §5.1.1, the bug that broke v0.4.9-v0.5.1)
  • tool-call round-trip with chunked input JSON
  • multi-tool-call ordering inside a single turn
  • compaction-style non-streaming create_message
  • sub-agent style independent parent/child mocks
  • capacity-gate observation of a captured request before stream drain

Four full-engine tests (engine_full_*) are #[ignore]-marked. They unblock when core::engine::Engine is refactored to take Arc<dyn LlmClient> instead of a concrete Option<DeepSeekClient>. See the comment block at the bottom of integration_mock_llm.rs for the exact refactor surface.

--record mode for deepseek eval

The offline deepseek eval harness now accepts --record <DIR>. When set, each tool step appends one JSON Lines record to <DIR>/<scenario>.jsonl (default scenario: offline-tool-loop.jsonl). Each line is a self-contained JSON object with the schema:

{ "request":  { "step": "list_dir", "kind": "List" },
  "response_events": [ { "type": "ok", "output": "…" } ] }

The mock LLM client (crate::llm_client::mock) replays these fixtures by mapping each response_events array onto a canned Vec<StreamEvent>. Drop generated fixtures into crates/tui/tests/fixtures/ so they ride the repo and feed the mock in CI.

Quick example:

cargo run --bin deepseek -- eval --record crates/tui/tests/fixtures
cat crates/tui/tests/fixtures/offline-tool-loop.jsonl | jq .

The scenario name is sanitized to [A-Za-z0-9_-] before forming the filename, so unusual scenario strings stay portable across platforms.