mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(agents): pass workspace to cli flush probe
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
} from "./cli-runner.js";
|
||||
|
||||
describe("isCliBindingFlushed", () => {
|
||||
const workspaceDir = "/tmp/openclaw-workspace";
|
||||
|
||||
beforeEach(() => {
|
||||
restoreCliRunnerTestDeps();
|
||||
});
|
||||
@@ -26,16 +28,16 @@ describe("isCliBindingFlushed", () => {
|
||||
const probe = vi.fn(async () => true);
|
||||
setCliRunnerTestDeps({ claudeCliSessionTranscriptHasContent: probe });
|
||||
|
||||
expect(await isCliBindingFlushed("sid-fresh", "claude-cli")).toBe(true);
|
||||
expect(await isCliBindingFlushed("sid-fresh", "claude-cli", workspaceDir)).toBe(true);
|
||||
expect(probe).toHaveBeenCalledTimes(1);
|
||||
expect(probe).toHaveBeenCalledWith({ sessionId: "sid-fresh" });
|
||||
expect(probe).toHaveBeenCalledWith({ sessionId: "sid-fresh", workspaceDir });
|
||||
});
|
||||
|
||||
it("retries up to three times before giving up", async () => {
|
||||
const probe = vi.fn(async () => false);
|
||||
setCliRunnerTestDeps({ claudeCliSessionTranscriptHasContent: probe });
|
||||
|
||||
expect(await isCliBindingFlushed("sid-cold", "claude-cli")).toBe(false);
|
||||
expect(await isCliBindingFlushed("sid-cold", "claude-cli", workspaceDir)).toBe(false);
|
||||
expect(probe).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
@@ -47,7 +49,7 @@ describe("isCliBindingFlushed", () => {
|
||||
});
|
||||
setCliRunnerTestDeps({ claudeCliSessionTranscriptHasContent: probe });
|
||||
|
||||
expect(await isCliBindingFlushed("sid-late", "claude-cli")).toBe(true);
|
||||
expect(await isCliBindingFlushed("sid-late", "claude-cli", workspaceDir)).toBe(true);
|
||||
expect(probe).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
@@ -59,7 +61,7 @@ describe("isCliBindingFlushed", () => {
|
||||
|
||||
const settled = vi.fn();
|
||||
const errored = vi.fn();
|
||||
isCliBindingFlushed("sid-bounded", "claude-cli").then(settled, errored);
|
||||
isCliBindingFlushed("sid-bounded", "claude-cli", workspaceDir).then(settled, errored);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await vi.advanceTimersByTimeAsync(50);
|
||||
|
||||
@@ -49,6 +49,7 @@ export function restoreCliRunnerTestDeps(): void {
|
||||
export async function isCliBindingFlushed(
|
||||
sessionId: string | undefined,
|
||||
provider: string | undefined,
|
||||
workspaceDir?: string,
|
||||
): Promise<boolean> {
|
||||
if (!provider || !isClaudeCliProvider(provider)) {
|
||||
return true;
|
||||
@@ -60,7 +61,7 @@ export async function isCliBindingFlushed(
|
||||
if (delayMs > 0) {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
if (await cliRunnerDeps.claudeCliSessionTranscriptHasContent({ sessionId })) {
|
||||
if (await cliRunnerDeps.claudeCliSessionTranscriptHasContent({ sessionId, workspaceDir })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -719,7 +720,11 @@ export async function runPreparedCliAgent(
|
||||
assistantText,
|
||||
output,
|
||||
});
|
||||
const bindingFlushOk = await isCliBindingFlushed(effectiveCliSessionId, params.provider);
|
||||
const bindingFlushOk = await isCliBindingFlushed(
|
||||
effectiveCliSessionId,
|
||||
params.provider,
|
||||
context.cwd ?? context.workspaceDir,
|
||||
);
|
||||
await runCliAgentEndHook(params, {
|
||||
event: {
|
||||
messages: buildAgentEndMessages(lastAssistant),
|
||||
@@ -755,6 +760,7 @@ export async function runPreparedCliAgent(
|
||||
const bindingFlushOk = await isCliBindingFlushed(
|
||||
effectiveCliSessionId,
|
||||
params.provider,
|
||||
context.cwd ?? context.workspaceDir,
|
||||
);
|
||||
await runCliAgentEndHook(params, {
|
||||
event: {
|
||||
|
||||
Reference in New Issue
Block a user