feat: align TaskOutput UX with Bash output (#1029)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { isMemoryTool } from "../../cli/helpers/toolNameMapping";
|
||||
import {
|
||||
getDisplayToolName,
|
||||
isMemoryTool,
|
||||
isShellOutputTool,
|
||||
} from "../../cli/helpers/toolNameMapping";
|
||||
|
||||
describe("toolNameMapping.isMemoryTool", () => {
|
||||
test("recognizes all supported memory tool names", () => {
|
||||
@@ -15,3 +19,16 @@ describe("toolNameMapping.isMemoryTool", () => {
|
||||
expect(isMemoryTool("web_search")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toolNameMapping task output mappings", () => {
|
||||
test("uses distinct display labels for shell output and task output", () => {
|
||||
expect(getDisplayToolName("BashOutput")).toBe("Shell Output");
|
||||
expect(getDisplayToolName("TaskOutput")).toBe("Task Output");
|
||||
});
|
||||
|
||||
test("treats TaskOutput as shell-style output for streaming UI", () => {
|
||||
expect(isShellOutputTool("TaskOutput")).toBe(true);
|
||||
expect(isShellOutputTool("BashOutput")).toBe(true);
|
||||
expect(isShellOutputTool("Task")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,6 +31,7 @@ describe.skipIf(isWindows)("TaskOutput and TaskStop", () => {
|
||||
// Should return in less than 500ms (not waiting for 2s sleep)
|
||||
expect(elapsed).toBeLessThan(500);
|
||||
expect(result.status).toBe("running");
|
||||
expect(result.message).toContain("Task is still running");
|
||||
|
||||
// Cleanup
|
||||
await task_stop({ task_id: taskId });
|
||||
@@ -60,6 +61,31 @@ describe.skipIf(isWindows)("TaskOutput and TaskStop", () => {
|
||||
expect(result.status).toBe("completed");
|
||||
});
|
||||
|
||||
test("TaskOutput with block=true streams output chunks", async () => {
|
||||
const startResult = await bash({
|
||||
command: "sleep 0.2 && echo 'first' && sleep 0.2 && echo 'second'",
|
||||
description: "Streaming process",
|
||||
run_in_background: true,
|
||||
});
|
||||
|
||||
const match = startResult.content[0]?.text.match(/bash_(\d+)/);
|
||||
expect(match).toBeDefined();
|
||||
const taskId = `bash_${match?.[1]}`;
|
||||
|
||||
const outputChunks: string[] = [];
|
||||
const result = await task_output({
|
||||
task_id: taskId,
|
||||
block: true,
|
||||
timeout: 5000,
|
||||
onOutput: (chunk) => outputChunks.push(chunk),
|
||||
});
|
||||
|
||||
const streamed = outputChunks.join("");
|
||||
expect(streamed).toContain("first");
|
||||
expect(streamed).toContain("second");
|
||||
expect(result.status).toBe("completed");
|
||||
});
|
||||
|
||||
test("TaskOutput respects timeout when blocking", async () => {
|
||||
// Start a long-running process
|
||||
const startResult = await bash({
|
||||
|
||||
Reference in New Issue
Block a user