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

推荐订阅源

月光博客
月光博客
云风的 BLOG
云风的 BLOG
小众软件
小众软件
雷峰网
雷峰网
博客园 - 【当耐特】
V
V2EX
WordPress大学
WordPress大学
IT之家
IT之家
Last Week in AI
Last Week in AI
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
The Cloudflare Blog
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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 gateway send inflight handling · openclaw...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

@@ -89,6 +89,41 @@ function resolveGatewayInflightMap(params: { context: GatewayRequestContext; ded

8989

return { kind: "ready", inflightMap };

9090

}

919192+

function resolveGatewayInflightStart(params: {

93+

context: GatewayRequestContext;

94+

dedupeKey: string;

95+

respond: RespondFn;

96+

}):

97+

| {

98+

kind: "ready";

99+

inflightMap: Map<string, Promise<InflightResult>>;

100+

}

101+

| {

102+

kind: "handled";

103+

done: Promise<void>;

104+

} {

105+

const inflight = resolveGatewayInflightMap({

106+

context: params.context,

107+

dedupeKey: params.dedupeKey,

108+

});

109+

if (inflight.kind === "cached") {

110+

params.respond(inflight.cached.ok, inflight.cached.payload, inflight.cached.error, {

111+

cached: true,

112+

});

113+

return { kind: "handled", done: Promise.resolve() };

114+

}

115+

if (inflight.kind === "inflight") {

116+

return {

117+

kind: "handled",

118+

done: inflight.inflight.then((result) => {

119+

const meta = result.meta ? { ...result.meta, cached: true } : { cached: true };

120+

params.respond(result.ok, result.payload, result.error, meta);

121+

}),

122+

};

123+

}

124+

return { kind: "ready", inflightMap: inflight.inflightMap };

125+

}

126+92127

async function runGatewayInflightWork(params: {

93128

inflightMap: Map<string, Promise<InflightResult>>;

94129

dedupeKey: string;

@@ -349,23 +384,12 @@ export const sendHandlers: GatewayRequestHandlers = {

349384

};

350385

const idem = request.idempotencyKey;

351386

const dedupeKey = `message.action:${idem}`;

352-

const inflight = resolveGatewayInflightMap({ context, dedupeKey });

353-

if (inflight.kind === "cached") {

354-

respond(inflight.cached.ok, inflight.cached.payload, inflight.cached.error, {

355-

cached: true,

356-

});

357-

return;

358-

}

359-

if (inflight.kind === "inflight") {

360-

const result = await inflight.inflight;

361-

const meta = result.meta ? { ...result.meta, cached: true } : { cached: true };

362-

respond(result.ok, result.payload, result.error, meta);

363-

return;

364-

}

365-

if (inflight.kind !== "ready") {

387+

const inflightStart = resolveGatewayInflightStart({ context, dedupeKey, respond });

388+

if (inflightStart.kind === "handled") {

389+

await inflightStart.done;

366390

return;

367391

}

368-

const inflightMap = inflight.inflightMap;

392+

const inflightMap = inflightStart.inflightMap;

369393

const work = (async (): Promise<InflightResult> => {

370394

const resolvedChannel = await resolveRequestedChannel({

371395

requestChannel: request.channel,

@@ -480,20 +504,12 @@ export const sendHandlers: GatewayRequestHandlers = {

480504

};

481505

const idem = request.idempotencyKey;

482506

const dedupeKey = `send:${idem}`;

483-

const inflight = resolveGatewayInflightMap({ context, dedupeKey });

484-

if (inflight.kind === "cached") {

485-

respond(inflight.cached.ok, inflight.cached.payload, inflight.cached.error, {

486-

cached: true,

487-

});

488-

return;

489-

}

490-

if (inflight.kind === "inflight") {

491-

const result = await inflight.inflight;

492-

const meta = result.meta ? { ...result.meta, cached: true } : { cached: true };

493-

respond(result.ok, result.payload, result.error, meta);

507+

const inflightStart = resolveGatewayInflightStart({ context, dedupeKey, respond });

508+

if (inflightStart.kind === "handled") {

509+

await inflightStart.done;

494510

return;

495511

}

496-

const inflightMap = inflight.inflightMap;

512+

const inflightMap = inflightStart.inflightMap;

497513

const to = normalizeOptionalString(request.to) ?? "";

498514

const message = normalizeOptionalString(request.message) ?? "";

499515

const mediaUrl = normalizeOptionalString(request.mediaUrl);

@@ -700,23 +716,12 @@ export const sendHandlers: GatewayRequestHandlers = {

700716

};

701717

const idem = request.idempotencyKey;

702718

const dedupeKey = `poll:${idem}`;

703-

const inflight = resolveGatewayInflightMap({ context, dedupeKey });

704-

if (inflight.kind === "cached") {

705-

respond(inflight.cached.ok, inflight.cached.payload, inflight.cached.error, {

706-

cached: true,

707-

});

708-

return;

709-

}

710-

if (inflight.kind === "inflight") {

711-

const result = await inflight.inflight;

712-

const meta = result.meta ? { ...result.meta, cached: true } : { cached: true };

713-

respond(result.ok, result.payload, result.error, meta);

714-

return;

715-

}

716-

if (inflight.kind !== "ready") {

719+

const inflightStart = resolveGatewayInflightStart({ context, dedupeKey, respond });

720+

if (inflightStart.kind === "handled") {

721+

await inflightStart.done;

717722

return;

718723

}

719-

const inflightMap = inflight.inflightMap;

724+

const inflightMap = inflightStart.inflightMap;

720725

const work = (async (): Promise<InflightResult> => {

721726

const resolvedChannel = await resolveRequestedChannel({

722727

requestChannel: request.channel,