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

推荐订阅源

D
Docker
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
The GitHub Blog
The GitHub Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
博客园_首页
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
T
The Blog of Author Tim Ferriss
The Cloudflare 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
fix(ui): preserve startup chat sends during history load ...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -194,6 +194,36 @@ function messageDisplaySignature(message: unknown): string | null {

194194

}

195195

}

196196197+

function messageTimestampMs(message: unknown): number | null {

198+

if (!message || typeof message !== "object") {

199+

return null;

200+

}

201+

const timestamp = (message as { timestamp?: unknown; ts?: unknown }).timestamp;

202+

if (typeof timestamp === "number" && Number.isFinite(timestamp)) {

203+

return timestamp;

204+

}

205+

const ts = (message as { timestamp?: unknown; ts?: unknown }).ts;

206+

return typeof ts === "number" && Number.isFinite(ts) ? ts : null;

207+

}

208+209+

function historyHasSameOrNewerDisplayMessage(

210+

historyMessages: unknown[],

211+

signature: string,

212+

message: unknown,

213+

): boolean {

214+

const timestamp = messageTimestampMs(message);

215+

if (timestamp == null) {

216+

return false;

217+

}

218+

return historyMessages.some((historyMessage) => {

219+

if (messageDisplaySignature(historyMessage) !== signature) {

220+

return false;

221+

}

222+

const historyTimestamp = messageTimestampMs(historyMessage);

223+

return historyTimestamp != null && historyTimestamp >= timestamp;

224+

});

225+

}

226+197227

export function preserveOptimisticTailMessages(

198228

historyMessages: unknown[],

199229

previousMessages: unknown[],

@@ -247,6 +277,34 @@ export function preserveOptimisticTailMessages(

247277

return optimisticTail.length > 0 ? [...historyMessages, ...optimisticTail] : historyMessages;

248278

}

249279280+

function collectLateOptimisticTailMessages(

281+

previousMessages: unknown[],

282+

currentMessages: unknown[],

283+

historyMessages: unknown[],

284+

): unknown[] {

285+

if (currentMessages === previousMessages || currentMessages.length <= previousMessages.length) {

286+

return [];

287+

}

288+

if (previousMessages.some((message, index) => currentMessages[index] !== message)) {

289+

return [];

290+

}

291+

const lateTail: unknown[] = [];

292+

for (const message of currentMessages.slice(previousMessages.length)) {

293+

if (!isLocallyOptimisticHistoryMessage(message) || shouldHideHistoryMessage(message)) {

294+

return [];

295+

}

296+

const signature = messageDisplaySignature(message);

297+

if (!signature) {

298+

return [];

299+

}

300+

if (historyHasSameOrNewerDisplayMessage(historyMessages, signature, message)) {

301+

continue;

302+

}

303+

lateTail.push(message);

304+

}

305+

return lateTail;

306+

}

307+250308

function isRetryableStartupUnavailable(err: unknown, method: string): err is GatewayRequestError {

251309

if (!(err instanceof GatewayRequestError)) {

252310

return false;

@@ -489,6 +547,7 @@ async function loadChatHistoryUncached(

489547

const requestVersion = beginChatHistoryRequest(state);

490548

const startedAt = Date.now();

491549

const previousMessages = state.chatMessages;

550+

const previousRunId = state.chatRunId;

492551

// Any pending input-history snapshot becomes invalid once we start reloading transcript state.

493552

state.resetChatInputHistoryNavigation?.();

494553

state.chatLoading = true;

@@ -524,19 +583,29 @@ async function loadChatHistoryUncached(

524583

}

525584

const messages = Array.isArray(res.messages) ? res.messages : [];

526585

const visibleMessages = messages.filter((message) => !shouldHideHistoryMessage(message));

586+

const lateOptimisticTail = collectLateOptimisticTailMessages(

587+

previousMessages,

588+

state.chatMessages,

589+

visibleMessages,

590+

);

527591

state.chatMessages = preserveOptimisticTailMessages(visibleMessages, previousMessages);

592+

if (lateOptimisticTail.length > 0) {

593+

state.chatMessages = [...state.chatMessages, ...lateOptimisticTail];

594+

}

528595

state.currentSessionId =

529596

typeof res.sessionInfo?.sessionId === "string" && res.sessionInfo.sessionId.trim()

530597

? res.sessionInfo.sessionId

531598

: typeof res.sessionId === "string" && res.sessionId.trim()

532599

? res.sessionId

533600

: null;

534601

state.chatThinkingLevel = res.sessionInfo?.thinkingLevel ?? res.thinkingLevel ?? null;

535-

// Clear all streaming state — history includes tool results and text

536-

// inline, so keeping streaming artifacts would cause duplicates.

537-

maybeResetToolStream(state);

538-

state.chatStream = null;

539-

state.chatStreamStartedAt = null;

602+

if (!state.chatRunId || state.chatRunId === previousRunId) {

603+

// Clear all streaming state — history includes tool results and text

604+

// inline, so keeping streaming artifacts would cause duplicates.

605+

maybeResetToolStream(state);

606+

state.chatStream = null;

607+

state.chatStreamStartedAt = null;

608+

}

540609

return res;

541610

} catch (err) {

542611

if (!shouldApplyChatHistoryResult(state, requestVersion, sessionKey, requestAgentId)) {