Files
opencode-mobile/src/lib/status-labels.ts
engineer 6013d1d86d test(lib): cover agent-activity status labels (57→65 tests)
Extract TOOL_STATUS + statusFromPart from stores/events.ts into a pure
status-labels.ts (type-only Part import, erased at runtime; events.ts delegates).
8 tests pin the live 'what is the agent doing' labels: reasoning/text/known-tool
mappings, shared labels (search/edit groups), unknown-tool degrade to
'Running <tool>...', and the no-tool/unknown-type fallthroughs. typecheck clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 14:22:39 -07:00

28 lines
1.0 KiB
TypeScript

// Human-readable status labels shown while the agent works ("Searching codebase...").
// Extracted from stores/events.ts so the mapping is unit-testable in isolation.
// `import type` is erased at runtime, so this module pulls in no RN/SDK code.
import type { Part } from "./sdk"
// Tool status labels derived from part type.
export const TOOL_STATUS: Record<string, string> = {
read: "Gathering context...",
list: "Searching codebase...",
grep: "Searching codebase...",
glob: "Searching codebase...",
webfetch: "Searching web...",
edit: "Making edits...",
write: "Making edits...",
apply_patch: "Making edits...",
bash: "Running command...",
task: "Delegating...",
todowrite: "Planning...",
todoread: "Planning...",
}
export function statusFromPart(part: Part): string {
if (part.type === "reasoning") return "Thinking..."
if (part.type === "tool" && part.tool) return TOOL_STATUS[part.tool] || `Running ${part.tool}...`
if (part.type === "text") return "Writing..."
return "Working..."
}