[eric] windows: fix UA-spoof leak onto recreated main window + add diag logs across preload, createWindow, recreateMainWindow, resumeSession, launchAndSendFirstMessage, AgentChat, WebSocketManager so packaged-build stderr captures the chat-spawn crash trail

This commit is contained in:
Eric
2026-05-25 16:06:58 -07:00
parent e7a09c9568
commit d27f289cea
7 changed files with 50 additions and 5 deletions
+21 -3
View File
@@ -291,13 +291,19 @@ export const fetchSession = createAsyncThunk(
export const launchAndSendFirstMessage = createAsyncThunk(
'agents/launchAndSendFirstMessage',
async ({ draftId, config, prompt, mode, model, provider, images, contextPaths, forcedTools, attachedSkills, selectedBrowserIds }: LaunchAndSendPayload) => {
// eslint-disable-next-line no-console
console.log('[diag][thunk] launchAndSendFirstMessage START draft=', draftId, 'mode=', mode, 'model=', model, 'provider=', provider);
const launchRes = await fetch(`${AGENTS_API}/launch`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config),
});
// eslint-disable-next-line no-console
console.log('[diag][thunk] launch fetch ok=', launchRes.ok, 'status=', launchRes.status);
const launchData = await launchRes.json();
const session = launchData.session as AgentSession;
// eslint-disable-next-line no-console
console.log('[diag][thunk] launch parsed, sessionId=', session && session.id);
await fetch(`${AGENTS_API}/sessions/${session.id}/message`, {
method: 'POST',
@@ -470,9 +476,21 @@ export const searchHistory = createAsyncThunk(
export const resumeSession = createAsyncThunk(
'agents/resumeSession',
async ({ sessionId }: { sessionId: string }) => {
const res = await fetch(`${AGENTS_API}/sessions/${sessionId}/resume`, { method: 'POST' });
const data = await res.json();
return data.session as AgentSession;
// eslint-disable-next-line no-console
console.log('[diag][thunk] resumeSession START', sessionId);
try {
const res = await fetch(`${AGENTS_API}/sessions/${sessionId}/resume`, { method: 'POST' });
// eslint-disable-next-line no-console
console.log('[diag][thunk] resumeSession fetch ok=', res.ok, 'status=', res.status);
const data = await res.json();
// eslint-disable-next-line no-console
console.log('[diag][thunk] resumeSession parsed, keys=', Object.keys(data || {}).join(','));
return data.session as AgentSession;
} catch (e: any) {
// eslint-disable-next-line no-console
console.error('[diag][thunk] resumeSession THREW', e && e.message);
throw e;
}
}
);
@@ -192,6 +192,8 @@ class WebSocketManager {
const token = _getAuthTokenSafe();
const sep = this.url.includes('?') ? '&' : '?';
const urlWithToken = token ? `${this.url}${sep}token=${encodeURIComponent(token)}` : this.url;
// eslint-disable-next-line no-console
console.log('[diag][ws] connect', this.url, 'sessionId=', this.options.sessionId, 'hasToken=', !!token);
this.ws = new WebSocket(urlWithToken);
this.ws.onopen = () => {