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

推荐订阅源

Recent Announcements
Recent Announcements
J
Java Code Geeks
雷峰网
雷峰网
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
腾讯CDC
博客园 - 司徒正美
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
I
InfoQ
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
美团技术团队
The Cloudflare Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
H
Help Net Security
Martin Fowler
Martin Fowler
V
Visual Studio 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
test: simplify abort transcript lookups · openclaw/opencl...
steipete · 2026-05-09 · via Recent Commits to openclaw:main

@@ -50,16 +50,43 @@ async function writeTranscriptHeader(transcriptPath: string, sessionId: string)

50505151

async function readTranscriptLines(transcriptPath: string): Promise<TranscriptLine[]> {

5252

const raw = await fs.readFile(transcriptPath, "utf-8");

53-

return raw

54-

.split(/\r?\n/)

55-

.filter((line) => line.trim().length > 0)

56-

.map((line) => {

57-

try {

58-

return JSON.parse(line) as TranscriptLine;

59-

} catch {

60-

return {};

61-

}

62-

});

53+

const lines: TranscriptLine[] = [];

54+

for (const line of raw.split(/\r?\n/)) {

55+

if (line.trim().length === 0) {

56+

continue;

57+

}

58+

try {

59+

lines.push(JSON.parse(line) as TranscriptLine);

60+

} catch {

61+

lines.push({});

62+

}

63+

}

64+

return lines;

65+

}

66+67+

function collectMessagesWithIdempotencyKey(

68+

lines: TranscriptLine[],

69+

idempotencyKey: string,

70+

): Record<string, unknown>[] {

71+

const messages: Record<string, unknown>[] = [];

72+

for (const line of lines) {

73+

if (line.message?.idempotencyKey === idempotencyKey) {

74+

messages.push(line.message);

75+

}

76+

}

77+

return messages;

78+

}

79+80+

function findMessageWithIdempotencyKey(

81+

lines: TranscriptLine[],

82+

idempotencyKey: string,

83+

): Record<string, unknown> | undefined {

84+

for (const line of lines) {

85+

if (line.message?.idempotencyKey === idempotencyKey) {

86+

return line.message;

87+

}

88+

}

89+

return undefined;

6390

}

64916592

function setMockSessionEntry(transcriptPath: string, sessionId: string) {

@@ -124,12 +151,7 @@ describe("chat abort transcript persistence", () => {

124151

});

125152126153

const lines = await readTranscriptLines(transcriptPath);

127-

const persisted = lines

128-

.map((line) => line.message)

129-

.filter(

130-

(message): message is Record<string, unknown> =>

131-

Boolean(message) && message?.idempotencyKey === `${runId}:assistant`,

132-

);

154+

const persisted = collectMessagesWithIdempotencyKey(lines, `${runId}:assistant`);

133155134156

expect(persisted).toHaveLength(1);

135157

expect(persisted[0]).toMatchObject({

@@ -176,12 +198,8 @@ describe("chat abort transcript persistence", () => {

176198

expect(payload.runIds).toEqual(expect.arrayContaining(["run-a", "run-b"]));

177199178200

const lines = await readTranscriptLines(transcriptPath);

179-

const runAPersisted = lines

180-

.map((line) => line.message)

181-

.find((message) => message?.idempotencyKey === "run-a:assistant");

182-

const runBPersisted = lines

183-

.map((line) => line.message)

184-

.find((message) => message?.idempotencyKey === "run-b:assistant");

201+

const runAPersisted = findMessageWithIdempotencyKey(lines, "run-a:assistant");

202+

const runBPersisted = findMessageWithIdempotencyKey(lines, "run-b:assistant");

185203186204

expect(runAPersisted).toMatchObject({

187205

idempotencyKey: "run-a:assistant",

@@ -226,9 +244,7 @@ describe("chat abort transcript persistence", () => {

226244

expect(payload).toMatchObject({ aborted: true, runIds: ["run-stop-1"] });

227245228246

const lines = await readTranscriptLines(transcriptPath);

229-

const persisted = lines

230-

.map((line) => line.message)

231-

.find((message) => message?.idempotencyKey === "run-stop-1:assistant");

247+

const persisted = findMessageWithIdempotencyKey(lines, "run-stop-1:assistant");

232248233249

expect(persisted).toMatchObject({

234250

idempotencyKey: "run-stop-1:assistant",

@@ -264,9 +280,7 @@ describe("chat abort transcript persistence", () => {

264280

expect(payload).toMatchObject({ aborted: true, runIds: [runId] });

265281266282

const lines = await readTranscriptLines(transcriptPath);

267-

const persisted = lines

268-

.map((line) => line.message)

269-

.find((message) => message?.idempotencyKey === `${runId}:assistant`);

283+

const persisted = findMessageWithIdempotencyKey(lines, `${runId}:assistant`);

270284

expect(persisted).toBeUndefined();

271285

});

272286

});