Skip to content

Commit 45efa8d

Browse files
shadowfax92claude
andcommitted
fix: remove duplicate hidden window creation from scheduled task frontend
The server's ChatService already creates a hidden window for scheduled tasks (chat-service.ts:99-126), but the frontend (scheduledJobRuns.ts) was also creating a minimized Chrome window that the server immediately overwrote. This caused two windows to be created per scheduled task run, with only one being used. Removed from scheduledJobRuns.ts: - chrome.windows.create() call - 1-second race condition delay hack (FIXME) - chrome.windows.remove() cleanup - windowId/activeTab params to getChatServerResponse() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 05b5a99 commit 45efa8d

1 file changed

Lines changed: 0 additions & 28 deletions

File tree

‎apps/agent/entrypoints/background/scheduledJobRuns.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,34 +109,13 @@ export const scheduledJobRuns = async () => {
109109
throw new Error(`Job not found: ${jobId}`)
110110
}
111111

112-
const backgroundWindow = await chrome.windows.create({
113-
url: 'chrome://newtab',
114-
focused: false,
115-
state: 'minimized',
116-
type: 'normal',
117-
})
118-
119-
// FIXME: Race condition - the controller-ext extension sends a window_created
120-
// WebSocket message to register window ownership, but our HTTP request may arrive
121-
// at the server before that registration completes. This delay is a temporary fix.
122-
// Proper solution: ControllerBridge should wait/poll for window ownership registration.
123-
await new Promise((resolve) => setTimeout(resolve, 1000))
124-
125-
const backgroundTab = backgroundWindow?.tabs?.[0]
126-
127-
if (!backgroundWindow || !backgroundTab) {
128-
throw new Error('Failed to create background window')
129-
}
130-
131112
const jobRun = await createJobRun(jobId, 'running')
132113
const abortController = new AbortController()
133114
runAbortControllers.set(jobRun.id, abortController)
134115

135116
try {
136117
const response = await getChatServerResponse({
137118
message: job.query,
138-
activeTab: backgroundTab,
139-
windowId: backgroundWindow.id,
140119
signal: abortController.signal,
141120
})
142121

@@ -163,13 +142,6 @@ export const scheduledJobRuns = async () => {
163142
})
164143
} finally {
165144
runAbortControllers.delete(jobRun.id)
166-
if (backgroundWindow.id) {
167-
try {
168-
await chrome.windows.remove(backgroundWindow.id)
169-
} catch {
170-
// Window may already be closed
171-
}
172-
}
173145
await updateJobLastRunAt(jobId)
174146
}
175147
}

0 commit comments

Comments
 (0)