mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:30:42 +00:00
Fix Telegram Pi tool progress timing
This commit is contained in:
committed by
Peter Steinberger
parent
e483115131
commit
14044edf28
@@ -1178,6 +1178,54 @@ describe("runAgentTurnWithFallback", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("fires tool-start progress before slow typing signals resolve for best-effort Pi events", async () => {
|
||||
const onToolStart = vi.fn(async () => {});
|
||||
let releaseTyping: (() => void) | undefined;
|
||||
const typingSignals = createMockTypingSignaler();
|
||||
vi.mocked(typingSignals.signalToolStart).mockImplementation(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
releaseTyping = resolve;
|
||||
}),
|
||||
);
|
||||
state.runEmbeddedPiAgentMock.mockImplementationOnce(async (params: EmbeddedAgentParams) => {
|
||||
void params.onAgentEvent?.({
|
||||
stream: "tool",
|
||||
data: {
|
||||
name: "exec",
|
||||
phase: "start",
|
||||
args: { command: "echo hi" },
|
||||
},
|
||||
});
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
return { payloads: [{ text: "final" }], meta: {} };
|
||||
});
|
||||
|
||||
const runAgentTurnWithFallback = await getRunAgentTurnWithFallback();
|
||||
const result = await runAgentTurnWithFallback({
|
||||
...createMinimalRunAgentTurnParams({
|
||||
opts: {
|
||||
onToolStart,
|
||||
} satisfies GetReplyOptions,
|
||||
}),
|
||||
typingSignals,
|
||||
});
|
||||
|
||||
try {
|
||||
expect(result.kind).toBe("success");
|
||||
expect(onToolStart).toHaveBeenCalledWith({
|
||||
name: "exec",
|
||||
phase: "start",
|
||||
args: { command: "echo hi" },
|
||||
detailMode: undefined,
|
||||
});
|
||||
} finally {
|
||||
releaseTyping?.();
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
|
||||
it("leaves Codex app-server telemetry publication to the harness", async () => {
|
||||
const agentEvents = await import("../../infra/agent-events.js");
|
||||
const emitAgentEvent = vi.mocked(agentEvents.emitAgentEvent);
|
||||
|
||||
@@ -1660,8 +1660,7 @@ export async function runAgentTurnWithFallback(params: {
|
||||
const phase = readStringValue(evt.data.phase) ?? "";
|
||||
const name = readStringValue(evt.data.name);
|
||||
if (phase === "start" || phase === "update") {
|
||||
await params.typingSignals.signalToolStart();
|
||||
await params.opts?.onToolStart?.({
|
||||
const toolStartProgressPromise = params.opts?.onToolStart?.({
|
||||
name,
|
||||
phase,
|
||||
args:
|
||||
@@ -1670,6 +1669,10 @@ export async function runAgentTurnWithFallback(params: {
|
||||
: undefined,
|
||||
detailMode: params.toolProgressDetail,
|
||||
});
|
||||
await Promise.all([
|
||||
params.typingSignals.signalToolStart(),
|
||||
toolStartProgressPromise,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (evt.stream === "item") {
|
||||
|
||||
Reference in New Issue
Block a user