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>
This commit is contained in:
27
src/lib/status-labels.ts
Normal file
27
src/lib/status-labels.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// 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..."
|
||||
}
|
||||
Reference in New Issue
Block a user