feat: implement browser open functionality and related tests

This commit is contained in:
duanshuwen
2026-04-23 19:27:21 +08:00
parent c9617a3777
commit 979fb0a0f6
7 changed files with 567 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
import { randomUUID } from 'crypto';
import { randomUUID } from 'node:crypto';
import { createProvider } from '@electron/providers';
import type { BaseProvider } from '@electron/providers/BaseProvider';
import { providerApiService } from '@electron/service/provider-api-service';
@@ -8,6 +8,7 @@ import type { RawMessage } from '@runtime/shared/chat-model';
import { sessionStore } from '../session-store';
import type { GatewayEvent, GatewayRpcParams, GatewayRpcReturns } from '../types';
import { appendTranscriptLine } from '@electron/utils/token-usage-writer';
import { maybeHandleBrowserOpenMessage } from '../browser-shortcut';
export interface GatewayChatMessage {
role: 'system' | 'user' | 'assistant' | 'tool';
@@ -131,6 +132,10 @@ export function handleChatSend(
},
});
if (maybeHandleBrowserOpenMessage(sessionKey, runId, userMessage, broadcast)) {
return { runId };
}
// 2. Resolve provider account
const accountId = options?.providerAccountId || providerApiService.getDefault().accountId;
if (!accountId) {