feat(version): upgrade openclaw version 4.11 (#845)

This commit is contained in:
Haze
2026-04-13 19:11:28 +08:00
committed by GitHub
Unverified
parent 5482acd43d
commit 03c40985e1
9 changed files with 595 additions and 759 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "clawx",
"version": "0.3.8",
"version": "0.3.9-beta.1",
"pnpm": {
"onlyBuiltDependencies": [
"@discordjs/opus",
@@ -94,7 +94,7 @@
"@radix-ui/react-tooltip": "^1.2.8",
"@playwright/test": "^1.56.1",
"@soimy/dingtalk": "^3.5.3",
"@tencent-weixin/openclaw-weixin": "^2.1.7",
"@tencent-weixin/openclaw-weixin": "^2.1.8",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/node": "^25.3.0",
@@ -119,7 +119,7 @@
"i18next": "^25.8.11",
"jsdom": "^28.1.0",
"lucide-react": "^0.563.0",
"openclaw": "2026.4.9",
"openclaw": "2026.4.11",
"png2icons": "^2.0.1",
"postcss": "^8.5.6",
"react": "^19.2.4",

1134
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -109,15 +109,26 @@ function buildChatEventDedupeKey(eventState: string, event: Record<string, unkno
return null;
}
function getFinalMessageIdDedupeKey(eventState: string, event: Record<string, unknown>): string | null {
if (eventState !== 'final') return null;
const msg = (event.message && typeof event.message === 'object')
? event.message as Record<string, unknown>
: null;
if (msg?.id != null) return `final-msgid|${String(msg.id)}`;
return null;
}
function isDuplicateChatEvent(eventState: string, event: Record<string, unknown>): boolean {
const key = buildChatEventDedupeKey(eventState, event);
if (!key) return false;
const msgKey = getFinalMessageIdDedupeKey(eventState, event);
if (!key && !msgKey) return false;
const now = Date.now();
pruneChatEventDedupe(now);
if (_chatEventDedupe.has(key)) {
if ((key && _chatEventDedupe.has(key)) || (msgKey && _chatEventDedupe.has(msgKey))) {
return true;
}
_chatEventDedupe.set(key, now);
if (key) _chatEventDedupe.set(key, now);
if (msgKey) _chatEventDedupe.set(msgKey, now);
return false;
}
@@ -1118,11 +1129,16 @@ export const useChatStore = create<ChatState>((set, get) => ({
}
// Background: fetch first user message for every non-main session to populate labels upfront.
// Uses a small limit so it's cheap; runs in parallel and doesn't block anything.
// Retries on "gateway startup" errors since the gateway may still be initializing.
const sessionsToLabel = sessionsWithCurrent.filter((s) => !s.key.endsWith(':main'));
if (sessionsToLabel.length > 0) {
void Promise.all(
sessionsToLabel.map(async (session) => {
const LABEL_RETRY_DELAYS = [2_000, 5_000, 10_000];
void (async () => {
let pending = sessionsToLabel;
for (let attempt = 0; attempt <= LABEL_RETRY_DELAYS.length; attempt += 1) {
const failed: typeof pending = [];
await Promise.all(
pending.map(async (session) => {
try {
const r = await useGatewayStore.getState().rpc<Record<string, unknown>>(
'chat.history',
@@ -1145,11 +1161,18 @@ export const useChatStore = create<ChatState>((set, get) => ({
}
return next;
});
} catch {
// ignore per-session errors
} catch (err) {
if (classifyHistoryStartupRetryError(err) === 'gateway_startup') {
failed.push(session);
}
}
}),
);
if (failed.length === 0 || attempt >= LABEL_RETRY_DELAYS.length) break;
await sleep(LABEL_RETRY_DELAYS[attempt]!);
pending = failed;
}
})();
}
}
} catch (err) {

View File

@@ -253,10 +253,12 @@ export function createHistoryActions(
return;
}
if (isCurrentSession() && isInitialForegroundLoad && classifyHistoryStartupRetryError(lastError)) {
const errorKind = classifyHistoryStartupRetryError(lastError);
if (isCurrentSession() && isInitialForegroundLoad && errorKind) {
console.warn('[chat.history] startup retry exhausted', {
sessionKey: currentSessionKey,
gatewayState: useGatewayStore.getState().status.state,
errorKind,
error: String(lastError),
});
}
@@ -267,6 +269,11 @@ export function createHistoryActions(
if (applied && isInitialForegroundLoad) {
foregroundHistoryLoadSeen.add(currentSessionKey);
}
} else if (errorKind === 'gateway_startup') {
// Suppress error UI for gateway startup -- the history will load
// once the gateway finishes initializing (via sidebar refresh or
// the next session switch).
set({ loading: false });
} else {
applyLoadFailure(
result?.error

View File

@@ -1,8 +1,8 @@
import type { GatewayStatus } from '@/types/gateway';
export const CHAT_HISTORY_RPC_TIMEOUT_MS = 35_000;
export const CHAT_HISTORY_STARTUP_RETRY_DELAYS_MS = [600] as const;
export const CHAT_HISTORY_STARTUP_CONNECTION_GRACE_MS = 15_000;
export const CHAT_HISTORY_STARTUP_RETRY_DELAYS_MS = [800, 2_000, 4_000, 8_000] as const;
export const CHAT_HISTORY_STARTUP_CONNECTION_GRACE_MS = 30_000;
export const CHAT_HISTORY_STARTUP_RUNNING_WINDOW_MS =
CHAT_HISTORY_RPC_TIMEOUT_MS + CHAT_HISTORY_STARTUP_CONNECTION_GRACE_MS;
export const CHAT_HISTORY_DEFAULT_LOADING_SAFETY_TIMEOUT_MS = 15_000;
@@ -11,11 +11,20 @@ export const CHAT_HISTORY_LOADING_SAFETY_TIMEOUT_MS =
+ CHAT_HISTORY_STARTUP_RETRY_DELAYS_MS.reduce((sum, delay) => sum + delay, 0)
+ 2_000;
export type HistoryRetryErrorKind = 'timeout' | 'gateway_unavailable';
export type HistoryRetryErrorKind = 'timeout' | 'gateway_unavailable' | 'gateway_startup';
export function classifyHistoryStartupRetryError(error: unknown): HistoryRetryErrorKind | null {
const message = String(error).toLowerCase();
if (
message.includes('unavailable during gateway startup')
|| message.includes('unavailable during startup')
|| message.includes('not yet ready')
|| message.includes('service not initialized')
) {
return 'gateway_startup';
}
if (
message.includes('rpc timeout: chat.history')
|| message.includes('gateway rpc timeout: chat.history')
@@ -47,6 +56,11 @@ export function shouldRetryStartupHistoryLoad(
): boolean {
if (!gatewayStatus || !errorKind) return false;
// The gateway explicitly told us it's still initializing -- always retry
if (errorKind === 'gateway_startup') {
return true;
}
if (gatewayStatus.state === 'starting') {
return true;
}

View File

@@ -1,5 +1,6 @@
import { invokeIpc } from '@/lib/api-client';
import { getCanonicalPrefixFromSessions, getMessageText, toMs } from './helpers';
import { classifyHistoryStartupRetryError, sleep } from './history-startup-retry';
import { DEFAULT_CANONICAL_PREFIX, DEFAULT_SESSION_KEY, type ChatSession, type RawMessage } from './types';
import type { ChatGet, ChatSet, SessionHistoryActions } from './store-api';
@@ -111,18 +112,29 @@ export function createSessionActions(
}
// Background: fetch first user message for every non-main session to populate labels upfront.
// Uses a small limit so it's cheap; runs in parallel and doesn't block anything.
// Retries on "gateway startup" errors since the gateway may still be initializing.
const sessionsToLabel = sessionsWithCurrent.filter((s) => !s.key.endsWith(':main'));
if (sessionsToLabel.length > 0) {
void Promise.all(
sessionsToLabel.map(async (session) => {
const LABEL_RETRY_DELAYS = [2_000, 5_000, 10_000];
void (async () => {
let pending = sessionsToLabel;
for (let attempt = 0; attempt <= LABEL_RETRY_DELAYS.length; attempt += 1) {
const failed: typeof pending = [];
await Promise.all(
pending.map(async (session) => {
try {
const r = await invokeIpc(
'gateway:rpc',
'chat.history',
{ sessionKey: session.key, limit: 1000 },
) as { success: boolean; result?: Record<string, unknown> };
if (!r.success || !r.result) return;
) as { success: boolean; result?: Record<string, unknown>; error?: string };
if (!r.success) {
if (classifyHistoryStartupRetryError(r.error) === 'gateway_startup') {
failed.push(session);
}
return;
}
if (!r.result) return;
const msgs = Array.isArray(r.result.messages) ? r.result.messages as RawMessage[] : [];
const firstUser = msgs.find((m) => m.role === 'user');
const lastMsg = msgs[msgs.length - 1];
@@ -143,6 +155,11 @@ export function createSessionActions(
} catch { /* ignore per-session errors */ }
}),
);
if (failed.length === 0 || attempt >= LABEL_RETRY_DELAYS.length) break;
await sleep(LABEL_RETRY_DELAYS[attempt]!);
pending = failed;
}
})();
}
}
} catch (err) {

View File

@@ -67,15 +67,28 @@ function buildGatewayEventDedupeKey(event: Record<string, unknown>): string | nu
return null;
}
function getMessageIdDedupeKey(event: Record<string, unknown>): string | null {
const state = event.state != null ? String(event.state) : '';
if (state !== 'final') return null;
const message = event.message;
if (message && typeof message === 'object') {
const msgId = (message as Record<string, unknown>).id;
if (msgId != null) return `final-msgid|${String(msgId)}`;
}
return null;
}
function shouldProcessGatewayEvent(event: Record<string, unknown>): boolean {
const key = buildGatewayEventDedupeKey(event);
if (!key) return true;
const msgKey = getMessageIdDedupeKey(event);
if (!key && !msgKey) return true;
const now = Date.now();
pruneGatewayEventDedupe(now);
if (gatewayEventDedupe.has(key)) {
if ((key && gatewayEventDedupe.has(key)) || (msgKey && gatewayEventDedupe.has(msgKey))) {
return false;
}
gatewayEventDedupe.set(key, now);
if (key) gatewayEventDedupe.set(key, now);
if (msgKey) gatewayEventDedupe.set(msgKey, now);
return true;
}

View File

@@ -272,7 +272,7 @@ describe('chat history actions', () => {
await vi.runAllTimersAsync();
await loadPromise;
expect(invokeIpcMock).toHaveBeenCalledTimes(2);
expect(invokeIpcMock).toHaveBeenCalledTimes(5);
expect(h.read().messages).toEqual([]);
expect(h.read().error).toBe('RPC timeout: chat.history');
expect(warnSpy).toHaveBeenCalledWith(

View File

@@ -90,7 +90,7 @@ describe('useChatStore startup history retry', () => {
{ sessionKey: 'agent:main:main', limit: 200 },
undefined,
);
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), 72_600);
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), 191_800);
setTimeoutSpy.mockRestore();
});