feat: refactor HomePage to integrate agents store and update related components
feat: add runtime event handling for providers in ProvidersSection feat: update routing to include Channels and Agents pages feat: extend route types and navigation items for Channels and Agents feat: implement agents store for managing agent data and interactions fix: update chat store to utilize agents store for agent-related functionality chore: export agents store from index fix: enhance runtime types for better event handling fix: update Vite config to handle dev server URL correctly
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
import { windowManager } from '@electron/service/window-service';
|
||||
import logManager from '@electron/service/logger';
|
||||
import type { GatewayEvent } from './types';
|
||||
import type { GatewayEvent, RuntimeRefreshTopic } from './types';
|
||||
import * as chatHandlers from './handlers/chat';
|
||||
import * as providerHandlers from './handlers/provider';
|
||||
|
||||
type RuntimeChangeBroadcast = {
|
||||
topics: RuntimeRefreshTopic[];
|
||||
reason?: string;
|
||||
warnings?: string[];
|
||||
channelType?: string;
|
||||
accountId?: string;
|
||||
};
|
||||
|
||||
class GatewayManager {
|
||||
private initialized = false;
|
||||
private status: 'connected' | 'disconnected' | 'reconnecting' = 'disconnected';
|
||||
@@ -31,10 +39,13 @@ class GatewayManager {
|
||||
this.setStatus('disconnected');
|
||||
}
|
||||
|
||||
async restart(): Promise<void> {
|
||||
async restart(options?: RuntimeChangeBroadcast): Promise<void> {
|
||||
this.initialized = false;
|
||||
this.setStatus('reconnecting');
|
||||
await this.init();
|
||||
if (options) {
|
||||
this.notifyRuntimeChanged(options);
|
||||
}
|
||||
}
|
||||
|
||||
getStatus(): {
|
||||
@@ -97,10 +108,34 @@ class GatewayManager {
|
||||
}
|
||||
}
|
||||
|
||||
reloadProviders(): void {
|
||||
notifyRuntimeChanged(options: RuntimeChangeBroadcast): void {
|
||||
const topics = Array.from(new Set(options.topics.filter(Boolean)));
|
||||
if (topics.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.broadcast({
|
||||
type: 'runtime:changed',
|
||||
topics,
|
||||
reason: options.reason,
|
||||
warnings: options.warnings && options.warnings.length > 0 ? options.warnings : undefined,
|
||||
channelType: options.channelType,
|
||||
accountId: options.accountId,
|
||||
syncedAt: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
|
||||
reloadProviders(options?: RuntimeChangeBroadcast): void {
|
||||
logManager.info('GatewayManager reloading providers');
|
||||
// For now, providers are resolved on each chat.send call,
|
||||
// so no in-memory cache to invalidate. Future: notify active sessions.
|
||||
this.notifyRuntimeChanged({
|
||||
topics: options?.topics ?? ['providers', 'models'],
|
||||
reason: options?.reason ?? 'providers:reload',
|
||||
warnings: options?.warnings,
|
||||
channelType: options?.channelType,
|
||||
accountId: options?.accountId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user