fix(daemon): avoid freezing Windows PATH in task scripts (#39139, thanks @Narcooo)

Co-authored-by: majx_mac <mjxnarco@pku.edu.cn>
This commit is contained in:
Peter Steinberger
2026-03-07 21:15:01 +00:00
parent f51cac277c
commit b9dd6e99b6
7 changed files with 74 additions and 9 deletions

View File

@@ -484,4 +484,20 @@ describe("tui-event-handlers: handleAgentEvent", () => {
expect(chatLog.dropAssistant).toHaveBeenCalledWith("run-silent");
expect(chatLog.finalizeAssistant).not.toHaveBeenCalled();
});
it("reloads history when a local run ends without a displayable final message", () => {
const { state, loadHistory, noteLocalRunId, handleChatEvent } = createHandlersHarness({
state: { activeChatRunId: "run-local-silent" },
});
noteLocalRunId("run-local-silent");
handleChatEvent({
runId: "run-local-silent",
sessionKey: state.currentSessionKey,
state: "final",
});
expect(loadHistory).toHaveBeenCalledTimes(1);
});
});

View File

@@ -136,10 +136,16 @@ export function createEventHandlers(context: EventHandlerContext) {
return sessionRuns.has(activeRunId);
};
const maybeRefreshHistoryForRun = (runId: string) => {
if (isLocalRunId?.(runId)) {
const maybeRefreshHistoryForRun = (
runId: string,
opts?: { allowLocalWithoutDisplayableFinal?: boolean },
) => {
const isLocalRun = isLocalRunId?.(runId) ?? false;
if (isLocalRun) {
forgetLocalRunId?.(runId);
return;
if (!opts?.allowLocalWithoutDisplayableFinal) {
return;
}
}
if (hasConcurrentActiveRun(runId)) {
return;
@@ -202,7 +208,9 @@ export function createEventHandlers(context: EventHandlerContext) {
if (evt.state === "final") {
const wasActiveRun = state.activeChatRunId === evt.runId;
if (!evt.message) {
maybeRefreshHistoryForRun(evt.runId);
maybeRefreshHistoryForRun(evt.runId, {
allowLocalWithoutDisplayableFinal: true,
});
chatLog.dropAssistant(evt.runId);
finalizeRun({ runId: evt.runId, wasActiveRun, status: "idle" });
tui.requestRender();