Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "0.2.12",
"@electron/remote": "^2.0.12",
"@grammyjs/runner": "^2.0.0",
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.1",
"@larksuiteoapi/node-sdk": "^1.58.0",
Expand All @@ -100,7 +99,6 @@
"electron-log": "^5.4.3",
"extract-zip": "^2.0.1",
"form-data": "^4.0.5",
"grammy": "^1.21.0",
"js-yaml": "^4.1.1",
"katex": "^0.16.21",
"mermaid": "^10.9.5",
Expand Down
7 changes: 2 additions & 5 deletions src/main/im/http.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { app, session } from 'electron';

// Fallback for cases where Electron session is not ready yet.
const nodeFetch = require('node-fetch');

function linkAbortSignal(source: AbortSignal, controller: AbortController): void {
if (source.aborted) {
controller.abort();
Expand All @@ -17,11 +14,11 @@ export async function fetchWithSystemProxy(url: string, options: RequestInit = {
return await session.defaultSession.fetch(url, options);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn(`[IM HTTP] session fetch failed, fallback to node-fetch: ${message}`);
console.warn(`[IM HTTP] session fetch failed, fallback to global fetch: ${message}`);
}
}

return nodeFetch(url, options);
return fetch(url, options);
}

export async function fetchJsonWithTimeout<T>(
Expand Down
3 changes: 1 addition & 2 deletions src/main/im/imGatewayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ export class IMGatewayManager extends EventEmitter {
feishu: this.feishuGateway.getStatus(),
telegram: telegramStatus,
qq: this.qqGateway.getStatus(),
telegram: this.telegramGateway.getStatus(),
discord: this.discordGateway.getStatus(),
nim: this.nimGateway.getStatus(),
xiaomifeng: this.xiaomifengGateway.getStatus(),
Expand Down Expand Up @@ -992,7 +991,7 @@ export class IMGatewayManager extends EventEmitter {
* Check if any gateway is connected
*/
isAnyConnected(): boolean {
return this.dingtalkGateway.isConnected() || this.feishuGateway.isConnected() || this.telegramGateway.isConnected() || this.discordGateway.isConnected() || this.nimGateway.isConnected() || this.xiaomifengGateway.isConnected() || this.qqGateway.isConnected() || this.wecomGateway.isConnected();
return this.dingtalkGateway.isConnected() || this.feishuGateway.isConnected() || this.discordGateway.isConnected() || this.nimGateway.isConnected() || this.xiaomifengGateway.isConnected() || this.qqGateway.isConnected() || this.wecomGateway.isConnected();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/im/imStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
FeishuConfig,
TelegramOpenClawConfig,
QQConfig,
TelegramConfig,
DiscordConfig,
NimConfig,
XiaomifengConfig,
Expand All @@ -22,7 +21,6 @@ import {
DEFAULT_FEISHU_CONFIG,
DEFAULT_TELEGRAM_OPENCLAW_CONFIG,
DEFAULT_QQ_CONFIG,
DEFAULT_TELEGRAM_CONFIG,
DEFAULT_DISCORD_CONFIG,
DEFAULT_NIM_CONFIG,
DEFAULT_XIAOMIFENG_CONFIG,
Expand Down Expand Up @@ -334,6 +332,8 @@ export class IMStore {
setTelegramOpenClawConfig(config: Partial<TelegramOpenClawConfig>): void {
const current = this.getTelegramOpenClawConfig();
this.setConfigValue('telegramOpenClaw', { ...current, ...config });
}

// ==================== QQ Config ====================

getQQConfig(): QQConfig {
Expand Down
8 changes: 4 additions & 4 deletions src/main/im/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ export interface IMGatewayConfig {
feishu: FeishuConfig;
telegram: TelegramOpenClawConfig;
qq: QQConfig;
telegram: TelegramConfig;
discord: DiscordConfig;
nim: NimConfig;
xiaomifeng: XiaomifengConfig;
Expand Down Expand Up @@ -344,7 +343,7 @@ export type IMConnectivityCheckCode =
| 'telegram_privacy_mode_hint'
| 'dingtalk_bot_membership_hint'
| 'nim_p2p_only_hint'
| 'openclaw_gateway_not_running';
| 'openclaw_gateway_not_running'
| 'qq_guild_mention_hint';

export interface IMConnectivityCheck {
Expand Down Expand Up @@ -428,6 +427,9 @@ export const DEFAULT_TELEGRAM_OPENCLAW_CONFIG: TelegramOpenClawConfig = {
proxy: '',
webhookUrl: '',
webhookSecret: '',
debug: false,
};

export const DEFAULT_QQ_CONFIG: QQConfig = {
enabled: false,
appId: '',
Expand All @@ -452,7 +454,6 @@ export const DEFAULT_IM_CONFIG: IMGatewayConfig = {
feishu: DEFAULT_FEISHU_CONFIG,
telegram: DEFAULT_TELEGRAM_OPENCLAW_CONFIG,
qq: DEFAULT_QQ_CONFIG,
telegram: DEFAULT_TELEGRAM_CONFIG,
discord: DEFAULT_DISCORD_CONFIG,
nim: DEFAULT_NIM_CONFIG,
xiaomifeng: DEFAULT_XIAOMIFENG_CONFIG,
Expand Down Expand Up @@ -534,7 +535,6 @@ export const DEFAULT_IM_STATUS: IMGatewayStatus = {
lastOutboundAt: null,
},
qq: DEFAULT_QQ_STATUS,
telegram: DEFAULT_TELEGRAM_STATUS,
discord: DEFAULT_DISCORD_STATUS,
nim: DEFAULT_NIM_STATUS,
xiaomifeng: DEFAULT_XIAOMIFENG_STATUS,
Expand Down
10 changes: 8 additions & 2 deletions src/main/libs/agentEngine/openclawRuntimeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
private channelSessionSync: OpenClawChannelSessionSync | null = null;
private readonly knownChannelSessionIds = new Set<string>();
private readonly fullySyncedSessions = new Set<string>();
/** Sessions re-created after user deletion — use latestOnly sync to avoid replaying old history. */
private readonly reCreatedChannelSessionIds = new Set<string>();
/** Channel sessionKeys explicitly deleted by the user. Polling will not re-create these. */
private readonly deletedChannelKeys = new Set<string>();
private channelPollingTimer: ReturnType<typeof setInterval> | null = null;
Expand Down Expand Up @@ -1225,6 +1227,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
if (this.deletedChannelKeys.has(sessionKey)) {
this.deletedChannelKeys.delete(sessionKey);
this.fullySyncedSessions.add(channelSessionId);
this.reCreatedChannelSessionIds.add(channelSessionId);
console.log('[Debug:handleAgentEvent] re-created after delete, skipping history sync for:', sessionKey);
}
this.sessionIdBySessionKey.set(sessionKey, channelSessionId);
Expand Down Expand Up @@ -1915,6 +1918,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
if (this.deletedChannelKeys.has(sessionKey)) {
this.deletedChannelKeys.delete(sessionKey);
this.fullySyncedSessions.add(channelSessionId);
this.reCreatedChannelSessionIds.add(channelSessionId);
console.log('[Debug:resolveSessionId] re-created after delete, skipping history sync for:', sessionKey);
}
this.sessionIdBySessionKey.set(sessionKey, channelSessionId);
Expand Down Expand Up @@ -1980,7 +1984,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
&& !turn.sessionKey.startsWith('lobsterai:')
&& this.channelSessionSync.isChannelSessionKey(turn.sessionKey);
if (isChannel) {
const latestOnly = this.fullySyncedSessions.has(sessionId);
const latestOnly = this.reCreatedChannelSessionIds.has(sessionId);
this.syncChannelUserMessages(sessionId, history.messages, latestOnly);
}

Expand Down Expand Up @@ -2247,6 +2251,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
}
this.activeTurns.delete(sessionId);
this.lastSystemPromptBySession.delete(sessionId);
this.reCreatedChannelSessionIds.delete(sessionId);
}

/**
Expand Down Expand Up @@ -2275,6 +2280,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim

// Allow full history re-sync when session is re-created
this.fullySyncedSessions.delete(sessionId);
this.reCreatedChannelSessionIds.delete(sessionId);

// Clean up active turn and related run-id mappings
this.cleanupSessionTurn(sessionId);
Expand Down Expand Up @@ -2358,7 +2364,7 @@ export class OpenClawRuntimeAdapter extends EventEmitter implements CoworkRuntim
console.log('[Debug:prefetch] chat.history returned', msgCount, 'messages (attempt', attempt, ')');

if (Array.isArray(history?.messages) && history.messages.length > 0) {
const latestOnly = this.fullySyncedSessions.has(sessionId);
const latestOnly = this.reCreatedChannelSessionIds.has(sessionId);
const beforeCount = this.getUserMessageCount(sessionId);
this.syncChannelUserMessages(sessionId, history.messages, latestOnly);
const afterCount = this.getUserMessageCount(sessionId);
Expand Down
4 changes: 4 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ const getOpenClawConfigSync = (): OpenClawConfigSync => {
getTelegramOpenClawConfig: () => {
try {
return getIMGatewayManager()?.getConfig()?.telegram ?? null;
} catch {
return null;
}
},
getDingTalkConfig: () => {
try {
return getIMGatewayManager().getConfig().dingtalk;
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/components/im/IMSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { SignalIcon, XMarkIcon, CheckCircleIcon, XCircleIcon, ExclamationTriangl
import { EyeIcon, EyeSlashIcon, XCircleIcon as XCircleIconSolid } from '@heroicons/react/20/solid';
import { RootState } from '../../store';
import { imService } from '../../services/im';
import { setDingTalkConfig, setFeishuConfig, setTelegramOpenClawConfig, setDiscordConfig, setNimConfig, setXiaomifengConfig, clearError } from '../../store/slices/imSlice';
import { setDingTalkConfig, setFeishuConfig, setQQConfig, setTelegramConfig, setDiscordConfig, setNimConfig, setXiaomifengConfig, setWecomConfig, clearError } from '../../store/slices/imSlice';
import { setDingTalkConfig, setFeishuConfig, setTelegramOpenClawConfig, setQQConfig, setDiscordConfig, setNimConfig, setXiaomifengConfig, setWecomConfig, clearError } from '../../store/slices/imSlice';
import { i18nService } from '../../services/i18n';
import type { IMPlatform, IMConnectivityCheck, IMConnectivityTestResult, IMGatewayConfig, TelegramOpenClawConfig } from '../../types/im';
import { getVisibleIMPlatforms } from '../../utils/regionFilter';
Expand Down Expand Up @@ -126,14 +125,16 @@ const IMSettings: React.FC = () => {
? { ...tgOpenClawConfig, ...override }
: tgOpenClawConfig;
await imService.updateConfig({ telegram: configToSave });
};

// Handle QQ config change
const handleQQChange = (field: 'appId' | 'appSecret', value: string) => {
dispatch(setQQConfig({ [field]: value }));
};

// Handle Telegram config change
const handleTelegramChange = (field: 'botToken' | 'allowedUserIds', value: string | string[]) => {
dispatch(setTelegramConfig({ [field]: value }));
// Handle Telegram OpenClaw config change (legacy wrapper)
const handleTelegramChange = (field: string, value: string | string[]) => {
dispatch(setTelegramOpenClawConfig({ [field]: value }));
};

// Handle Discord config change
Expand Down Expand Up @@ -443,7 +444,6 @@ const IMSettings: React.FC = () => {
feishu: setFeishuConfig,
telegram: setTelegramOpenClawConfig,
qq: setQQConfig,
telegram: setTelegramConfig,
discord: setDiscordConfig,
nim: setNimConfig,
xiaomifeng: setXiaomifengConfig,
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/store/slices/imSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {
FeishuConfig,
TelegramOpenClawConfig,
QQConfig,
TelegramConfig,
DiscordConfig,
NimConfig,
XiaomifengConfig,
Expand Down Expand Up @@ -55,12 +54,10 @@ const imSlice = createSlice({
...state.config.telegram,
...action.payload,
};
},
setQQConfig: (state, action: PayloadAction<Partial<QQConfig>>) => {
state.config.qq = { ...state.config.qq, ...action.payload };
},
setTelegramConfig: (state, action: PayloadAction<Partial<TelegramConfig>>) => {
state.config.telegram = { ...state.config.telegram, ...action.payload };
},
setDiscordConfig: (state, action: PayloadAction<Partial<DiscordConfig>>) => {
state.config.discord = { ...state.config.discord, ...action.payload };
},
Expand Down Expand Up @@ -97,7 +94,6 @@ export const {
setFeishuConfig,
setTelegramOpenClawConfig,
setQQConfig,
setTelegramConfig,
setDiscordConfig,
setNimConfig,
setXiaomifengConfig,
Expand Down
1 change: 0 additions & 1 deletion src/renderer/types/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ interface IMGatewayConfig {
feishu: FeishuConfig;
telegram: TelegramOpenClawConfig;
qq: QQConfig;
telegram: TelegramConfig;
discord: DiscordConfig;
nim: NimConfig;
xiaomifeng: XiaomifengConfig;
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/types/im.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export interface IMGatewayConfig {
feishu: FeishuConfig;
telegram: TelegramOpenClawConfig;
qq: QQConfig;
telegram: TelegramConfig;
discord: DiscordConfig;
nim: NimConfig;
xiaomifeng: XiaomifengConfig;
Expand Down Expand Up @@ -283,7 +282,7 @@ export type IMConnectivityCheckCode =
| 'telegram_privacy_mode_hint'
| 'dingtalk_bot_membership_hint'
| 'nim_p2p_only_hint'
| 'openclaw_gateway_not_running';
| 'openclaw_gateway_not_running'
| 'qq_guild_mention_hint';

export interface IMConnectivityCheck {
Expand Down Expand Up @@ -363,6 +362,9 @@ export const DEFAULT_TELEGRAM_OPENCLAW_CONFIG: TelegramOpenClawConfig = {
proxy: '',
webhookUrl: '',
webhookSecret: '',
debug: false,
};

export const DEFAULT_QQ_CONFIG: QQConfig = {
enabled: false,
appId: '',
Expand All @@ -387,7 +389,6 @@ export const DEFAULT_IM_CONFIG: IMGatewayConfig = {
feishu: DEFAULT_FEISHU_CONFIG,
telegram: DEFAULT_TELEGRAM_OPENCLAW_CONFIG,
qq: DEFAULT_QQ_CONFIG,
telegram: DEFAULT_TELEGRAM_CONFIG,
discord: DEFAULT_DISCORD_CONFIG,
nim: DEFAULT_NIM_CONFIG,
xiaomifeng: DEFAULT_XIAOMIFENG_CONFIG,
Expand Down