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

推荐订阅源

Google DeepMind News
Google DeepMind News
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
罗磊的独立博客
Last Week in AI
Last Week in AI
B
Blog
IT之家
IT之家
S
SegmentFault 最新的问题
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
博客园 - 聂微东
U
Unit 42
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
MyScale Blog
MyScale Blog

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
refactor: share session history revocation helpers · open...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -113,6 +113,14 @@ vi.mock("./session-history-state.js", () => ({

113113114114

import { handleSessionHistoryHttpRequest } from "./sessions-history-http.js";

115115116+

const SESSION_HISTORY_URL = "/sessions/agent%3Amain/history";

117+

const SESSION_FILE = "/tmp/session-1.jsonl";

118+

const TRUSTED_PROXY_STARTUP_OPTIONS = {

119+

auth: { mode: "trusted-proxy" } as never,

120+

trustedProxies: ["10.0.0.1"],

121+

allowRealIpFallback: false,

122+

} satisfies Parameters<typeof handleSessionHistoryHttpRequest>[2];

123+116124

class MockReq extends EventEmitter {

117125

url: string;

118126

method: string;

@@ -161,6 +169,51 @@ class MockRes extends EventEmitter {

161169

flushHeaders() {}

162170

}

163171172+

async function openSessionHistoryStream(

173+

options: Parameters<typeof handleSessionHistoryHttpRequest>[2],

174+

) {

175+

const req = new MockReq(SESSION_HISTORY_URL);

176+

const res = new MockRes();

177+178+

const handled = await handleSessionHistoryHttpRequest(

179+

req as unknown as IncomingMessage,

180+

res as unknown as ServerResponse,

181+

options,

182+

);

183+184+

expect(handled).toBe(true);

185+

expect(transcriptUpdateHandler).toBeTypeOf("function");

186+187+

return res;

188+

}

189+190+

function emitTranscriptTextUpdate({

191+

sessionFile = SESSION_FILE,

192+

text,

193+

messageId,

194+

}: {

195+

sessionFile?: string;

196+

text: string;

197+

messageId: string;

198+

}) {

199+

transcriptUpdateHandler?.({

200+

sessionFile,

201+

message: { role: "assistant", content: [{ type: "text", text }] },

202+

messageId,

203+

});

204+

}

205+206+

async function expectStreamClosedWithoutMessage(res: MockRes, text: string) {

207+

await vi.waitFor(() => {

208+

expect(res.writableEnded).toBe(true);

209+

});

210+211+

const joined = res.writes.join("");

212+

expect(joined).not.toContain("event: message");

213+

expect(joined).not.toContain(text);

214+

expect(res.writableEnded).toBe(true);

215+

}

216+164217

afterEach(() => {

165218

transcriptUpdateHandler = undefined;

166219

authRevoked = false;

@@ -173,95 +226,42 @@ afterEach(() => {

173226174227

describe("session history SSE auth revocation", () => {

175228

it("closes the stream before delivering transcript updates after auth is revoked", async () => {

176-

const req = new MockReq("/sessions/agent%3Amain/history");

177-

const res = new MockRes();

229+

const res = await openSessionHistoryStream({ auth: { mode: "trusted-proxy" } as never });

178230179-

const handled = await handleSessionHistoryHttpRequest(

180-

req as unknown as IncomingMessage,

181-

res as unknown as ServerResponse,

182-

{ auth: { mode: "trusted-proxy" } as never },

183-

);

184-185-

expect(handled).toBe(true);

186-

expect(transcriptUpdateHandler).toBeTypeOf("function");

187231

expect(res.headers.get("content-type")).toContain("text/event-stream");

188232189233

authRevoked = true;

190234191-

transcriptUpdateHandler?.({

192-

sessionFile: "/tmp/session-1.jsonl",

193-

message: { role: "assistant", content: [{ type: "text", text: "post-revocation secret" }] },

235+

emitTranscriptTextUpdate({

236+

text: "post-revocation secret",

194237

messageId: "m-1",

195238

});

196239197-

await vi.waitFor(() => {

198-

expect(res.writableEnded).toBe(true);

199-

});

200-201-

const joined = res.writes.join("");

202-

expect(joined).not.toContain("event: message");

203-

expect(joined).not.toContain("post-revocation secret");

204-

expect(res.writableEnded).toBe(true);

240+

await expectStreamClosedWithoutMessage(res, "post-revocation secret");

205241

});

206242207243

it("rechecks SSE auth against live proxy config instead of startup fallbacks", async () => {

208-

const req = new MockReq("/sessions/agent%3Amain/history");

209-

const res = new MockRes();

210-211-

const handled = await handleSessionHistoryHttpRequest(

212-

req as unknown as IncomingMessage,

213-

res as unknown as ServerResponse,

214-

{

215-

auth: { mode: "trusted-proxy" } as never,

216-

trustedProxies: ["10.0.0.1"],

217-

allowRealIpFallback: false,

218-

},

219-

);

220-221-

expect(handled).toBe(true);

222-

expect(transcriptUpdateHandler).toBeTypeOf("function");

244+

const res = await openSessionHistoryStream(TRUSTED_PROXY_STARTUP_OPTIONS);

223245224246

gatewayConfig = {};

225247226-

transcriptUpdateHandler?.({

227-

sessionFile: "/tmp/session-1.jsonl",

228-

message: { role: "assistant", content: [{ type: "text", text: "stale-proxy event" }] },

248+

emitTranscriptTextUpdate({

249+

text: "stale-proxy event",

229250

messageId: "m-2",

230251

});

231252232-

await vi.waitFor(() => {

233-

expect(res.writableEnded).toBe(true);

234-

});

235-236-

const joined = res.writes.join("");

237-

expect(joined).not.toContain("event: message");

238-

expect(joined).not.toContain("stale-proxy event");

239-

expect(res.writableEnded).toBe(true);

253+

await expectStreamClosedWithoutMessage(res, "stale-proxy event");

240254

});

241255242256

it("skips SSE reauth for transcript updates outside this stream", async () => {

243-

const req = new MockReq("/sessions/agent%3Amain/history");

244-

const res = new MockRes();

245-246-

const handled = await handleSessionHistoryHttpRequest(

247-

req as unknown as IncomingMessage,

248-

res as unknown as ServerResponse,

249-

{

250-

auth: { mode: "trusted-proxy" } as never,

251-

trustedProxies: ["10.0.0.1"],

252-

allowRealIpFallback: false,

253-

},

254-

);

255-256-

expect(handled).toBe(true);

257-

expect(transcriptUpdateHandler).toBeTypeOf("function");

257+

const res = await openSessionHistoryStream(TRUSTED_PROXY_STARTUP_OPTIONS);

258258259259

authCheckCalls = 0;

260260

gatewayConfig = {};

261261262-

transcriptUpdateHandler?.({

262+

emitTranscriptTextUpdate({

263263

sessionFile: "/tmp/other-session.jsonl",

264-

message: { role: "assistant", content: [{ type: "text", text: "other session" }] },

264+

text: "other session",

265265

messageId: "m-3",

266266

});

267267