feat(version): upgrade openclaw version 4.11 (#845)
This commit is contained in:
@@ -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",
|
||||
@@ -143,4 +143,4 @@
|
||||
"zx": "^8.8.5"
|
||||
},
|
||||
"packageManager": "pnpm@10.31.0+sha512.e3927388bfaa8078ceb79b748ffc1e8274e84d75163e67bc22e06c0d3aed43dd153151cbf11d7f8301ff4acb98c68bdc5cadf6989532801ffafe3b3e4a63c268"
|
||||
}
|
||||
}
|
||||
|
||||
1134
pnpm-lock.yaml
generated
1134
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -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,38 +1129,50 @@ 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) => {
|
||||
try {
|
||||
const r = await useGatewayStore.getState().rpc<Record<string, unknown>>(
|
||||
'chat.history',
|
||||
{ sessionKey: session.key, limit: 1000 },
|
||||
);
|
||||
const msgs = Array.isArray(r.messages) ? r.messages as RawMessage[] : [];
|
||||
const firstUser = msgs.find((m) => m.role === 'user');
|
||||
const lastMsg = msgs[msgs.length - 1];
|
||||
set((s) => {
|
||||
const next: Partial<typeof s> = {};
|
||||
if (firstUser) {
|
||||
const labelText = getMessageText(firstUser.content).trim();
|
||||
if (labelText) {
|
||||
const truncated = labelText.length > 50 ? `${labelText.slice(0, 50)}…` : labelText;
|
||||
next.sessionLabels = { ...s.sessionLabels, [session.key]: truncated };
|
||||
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',
|
||||
{ sessionKey: session.key, limit: 1000 },
|
||||
);
|
||||
const msgs = Array.isArray(r.messages) ? r.messages as RawMessage[] : [];
|
||||
const firstUser = msgs.find((m) => m.role === 'user');
|
||||
const lastMsg = msgs[msgs.length - 1];
|
||||
set((s) => {
|
||||
const next: Partial<typeof s> = {};
|
||||
if (firstUser) {
|
||||
const labelText = getMessageText(firstUser.content).trim();
|
||||
if (labelText) {
|
||||
const truncated = labelText.length > 50 ? `${labelText.slice(0, 50)}…` : labelText;
|
||||
next.sessionLabels = { ...s.sessionLabels, [session.key]: truncated };
|
||||
}
|
||||
}
|
||||
if (lastMsg?.timestamp) {
|
||||
next.sessionLastActivity = { ...s.sessionLastActivity, [session.key]: toMs(lastMsg.timestamp) };
|
||||
}
|
||||
return next;
|
||||
});
|
||||
} catch (err) {
|
||||
if (classifyHistoryStartupRetryError(err) === 'gateway_startup') {
|
||||
failed.push(session);
|
||||
}
|
||||
}
|
||||
if (lastMsg?.timestamp) {
|
||||
next.sessionLastActivity = { ...s.sessionLastActivity, [session.key]: toMs(lastMsg.timestamp) };
|
||||
}
|
||||
return next;
|
||||
});
|
||||
} 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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,38 +112,54 @@ 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) => {
|
||||
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;
|
||||
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];
|
||||
set((s) => {
|
||||
const next: Partial<typeof s> = {};
|
||||
if (firstUser) {
|
||||
const labelText = getMessageText(firstUser.content).trim();
|
||||
if (labelText) {
|
||||
const truncated = labelText.length > 50 ? `${labelText.slice(0, 50)}…` : labelText;
|
||||
next.sessionLabels = { ...s.sessionLabels, [session.key]: truncated };
|
||||
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>; error?: string };
|
||||
if (!r.success) {
|
||||
if (classifyHistoryStartupRetryError(r.error) === 'gateway_startup') {
|
||||
failed.push(session);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (lastMsg?.timestamp) {
|
||||
next.sessionLastActivity = { ...s.sessionLastActivity, [session.key]: toMs(lastMsg.timestamp) };
|
||||
}
|
||||
return next;
|
||||
});
|
||||
} catch { /* ignore per-session errors */ }
|
||||
}),
|
||||
);
|
||||
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];
|
||||
set((s) => {
|
||||
const next: Partial<typeof s> = {};
|
||||
if (firstUser) {
|
||||
const labelText = getMessageText(firstUser.content).trim();
|
||||
if (labelText) {
|
||||
const truncated = labelText.length > 50 ? `${labelText.slice(0, 50)}…` : labelText;
|
||||
next.sessionLabels = { ...s.sessionLabels, [session.key]: truncated };
|
||||
}
|
||||
}
|
||||
if (lastMsg?.timestamp) {
|
||||
next.sessionLastActivity = { ...s.sessionLastActivity, [session.key]: toMs(lastMsg.timestamp) };
|
||||
}
|
||||
return next;
|
||||
});
|
||||
} 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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user