惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
V
Visual Studio Blog
博客园 - 叶小钗
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Fortinet All Blogs
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
D
DataBreaches.Net
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(tui): clear stale streaming after orphaned finals (#7...
vincentkoc · 2026-04-28 · via Recent Commits to openclaw:main

@@ -532,6 +532,79 @@ describe("tui-event-handlers: handleAgentEvent", () => {

532532

expect(chatLog.updateAssistant).toHaveBeenLastCalledWith("continued", "run-active");

533533

});

534534535+

it("clears stale streaming when an orphan final arrives and no tracked run remains", () => {

536+

const { state, setActivityStatus, handleChatEvent } = createHandlersHarness({

537+

state: { activeChatRunId: "run-stale", activityStatus: "streaming" },

538+

});

539+540+

handleChatEvent({

541+

runId: "run-orphan",

542+

sessionKey: state.currentSessionKey,

543+

state: "final",

544+

message: { content: [{ type: "text", text: "done" }] },

545+

});

546+547+

expect(state.activeChatRunId).toBeNull();

548+

expect(setActivityStatus).toHaveBeenCalledWith("idle");

549+

});

550+551+

it("flushes deferred history reload after stale streaming clear makes the TUI idle", () => {

552+

const { state, loadHistory, noteLocalRunId, setActivityStatus, handleChatEvent } =

553+

createHandlersHarness({

554+

state: { activeChatRunId: "run-stale", activityStatus: "streaming" },

555+

});

556+557+

noteLocalRunId("run-local-empty");

558+

loadHistory.mockImplementation(() => {

559+

expect(state.activeChatRunId).toBeNull();

560+

expect(state.activityStatus).toBe("idle");

561+

});

562+563+

handleChatEvent({

564+

runId: "run-local-empty",

565+

sessionKey: state.currentSessionKey,

566+

state: "final",

567+

});

568+569+

expect(state.activeChatRunId).toBeNull();

570+

expect(state.activityStatus).toBe("idle");

571+

expect(setActivityStatus).toHaveBeenCalledWith("idle");

572+

expect(loadHistory).toHaveBeenCalledTimes(1);

573+

});

574+575+

it("does not surface inactive orphan final failures as the global status", () => {

576+

const { state, setActivityStatus, handleChatEvent } = createHandlersHarness({

577+

state: { activeChatRunId: "run-stale", activityStatus: "streaming" },

578+

});

579+580+

handleChatEvent({

581+

runId: "run-orphan-error",

582+

sessionKey: state.currentSessionKey,

583+

state: "final",

584+

message: { content: [{ type: "text", text: "failed" }], stopReason: "error" },

585+

});

586+587+

expect(state.activeChatRunId).toBeNull();

588+

expect(setActivityStatus).toHaveBeenCalledWith("idle");

589+

expect(setActivityStatus).not.toHaveBeenCalledWith("error");

590+

});

591+592+

it("does not force idle for an inactive final while another tracked run is active", () => {

593+

const { state, setActivityStatus, handleChatEvent } = createConcurrentRunHarness("partial");

594+

state.activityStatus = "streaming";

595+

setActivityStatus.mockClear();

596+597+

handleChatEvent({

598+

runId: "run-other",

599+

sessionKey: state.currentSessionKey,

600+

state: "final",

601+

message: { content: [{ type: "text", text: "other final" }] },

602+

});

603+604+

expect(state.activeChatRunId).toBe("run-active");

605+

expect(setActivityStatus).not.toHaveBeenCalledWith("idle");

606+

});

607+535608

it("suppresses non-local empty final placeholders during concurrent runs", () => {

536609

const { state, chatLog, loadHistory, handleChatEvent } =

537610

createConcurrentRunHarness("local stream");

@@ -715,15 +788,24 @@ describe("tui-event-handlers: streaming watchdog", () => {

715788

const btw = createMockBtwPresenter();

716789

const tui = { requestRender: vi.fn() } as unknown as MockTui & HandlerTui;

717790

const setActivityStatus = vi.fn();

791+

const loadHistory = vi.fn();

792+

const localRunIds = new Set<string>();

793+

const noteLocalRunId = (runId: string) => {

794+

localRunIds.add(runId);

795+

};

718796

const handlers = createEventHandlers({

719797

chatLog,

720798

btw,

721799

tui,

722800

state,

723801

setActivityStatus,

802+

loadHistory,

803+

noteLocalRunId,

804+

isLocalRunId: localRunIds.has.bind(localRunIds),

805+

forgetLocalRunId: localRunIds.delete.bind(localRunIds),

724806

streamingWatchdogMs: options?.streamingWatchdogMs,

725807

});

726-

return { state, chatLog, tui, setActivityStatus, handlers };

808+

return { state, chatLog, tui, setActivityStatus, loadHistory, noteLocalRunId, handlers };

727809

};

728810729811

it("resets activityStatus to idle when no stream delta arrives for the watchdog window", () => {

@@ -750,6 +832,37 @@ describe("tui-event-handlers: streaming watchdog", () => {

750832

handlers.dispose?.();

751833

});

752834835+

it("flushes a deferred history reload when the watchdog clears the active run", () => {

836+

const { state, loadHistory, noteLocalRunId, setActivityStatus, handlers } = createHarness({

837+

streamingWatchdogMs: 5_000,

838+

});

839+840+

handlers.handleChatEvent({

841+

runId: "run-stuck",

842+

sessionKey: state.currentSessionKey,

843+

state: "delta",

844+

message: { content: "hello" },

845+

} satisfies ChatEvent);

846+847+

noteLocalRunId("run-local-empty");

848+

handlers.handleChatEvent({

849+

runId: "run-local-empty",

850+

sessionKey: state.currentSessionKey,

851+

state: "final",

852+

} satisfies ChatEvent);

853+854+

expect(loadHistory).not.toHaveBeenCalled();

855+856+

vi.advanceTimersByTime(5_001);

857+858+

expect(state.activeChatRunId).toBeNull();

859+

expect(state.activityStatus).toBe("idle");

860+

expect(setActivityStatus).toHaveBeenLastCalledWith("idle");

861+

expect(loadHistory).toHaveBeenCalledTimes(1);

862+863+

handlers.dispose?.();

864+

});

865+753866

it("refreshes the watchdog window on each new stream delta", () => {

754867

const { state, setActivityStatus, handlers } = createHarness({

755868

streamingWatchdogMs: 5_000,