refactor: remove unused controller extension#505
Conversation
|
@greptileai review |
Greptile SummaryThis PR removes the Key highlights:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as Go CLI (dev/test)
participant Chrome as Chrome/BrowserOS
participant CDP as CDP Backend
participant Server as HTTP Server
participant Client as SDK / Eval Client
Note over CLI,Client: Before this PR (controller-ext architecture)
CLI->>Server: Start server (with --extension-port)
CLI->>Chrome: Launch with --load-extension=controller-ext
Chrome-->>Server: WebSocket connect (ControllerBackend)
CLI->>Server: WaitForExtension (/status?extensionConnected)
Client->>Server: API calls → forwarded via WebSocket → Chrome ext
Note over CLI,Client: After this PR (CDP-only architecture)
CLI->>Chrome: Launch Chrome
Chrome-->>CDP: CDP available on --remote-debugging-port
CLI->>Server: Start server (after CDP ready)
Server->>CDP: Connect directly
Client->>Server: API calls → forwarded via CDP → Browser
Client->>Server: GET /health → { status: ok, cdpConnected: bool }
|
| } catch { | ||
| const fallbackPage = await this.getFallbackPage() | ||
| if (fallbackPage) { | ||
| await this.browser.goto(fallbackPage.pageId, url) | ||
| return { | ||
| tabId: fallbackPage.tabId, | ||
| windowId: fallbackPage.windowId ?? 0, | ||
| } | ||
| } | ||
| } | ||
| await this.browser.goto(page.pageId, url) | ||
| return { tabId: page.tabId, windowId } | ||
| } |
There was a problem hiding this comment.
Silent fall-through when
windowId navigation fails completely
When windowId !== undefined, the active tab in that window is missing, newPage(url, { windowId }) throws, and getFallbackPage() returns null (e.g. browser has zero open pages), execution silently falls out of the if (windowId !== undefined) block. The code then calls this.browser.newPage(url) at line 149 without the windowId, creating a page in an arbitrary window and returning it as if the requested window constraint was satisfied.
The previous behaviour threw SdkError('No active tab in specified window'), which was safer. Consider re-throwing (or at least logging) when both fallbacks are exhausted while a caller-specified window was targeted:
| } catch { | |
| const fallbackPage = await this.getFallbackPage() | |
| if (fallbackPage) { | |
| await this.browser.goto(fallbackPage.pageId, url) | |
| return { | |
| tabId: fallbackPage.tabId, | |
| windowId: fallbackPage.windowId ?? 0, | |
| } | |
| } | |
| } | |
| await this.browser.goto(page.pageId, url) | |
| return { tabId: page.tabId, windowId } | |
| } | |
| } catch { | |
| const fallbackPage = await this.getFallbackPage() | |
| if (fallbackPage) { | |
| await this.browser.goto(fallbackPage.pageId, url) | |
| return { | |
| tabId: fallbackPage.tabId, | |
| windowId: fallbackPage.windowId ?? 0, | |
| } | |
| } | |
| throw new SdkError(`Window ${windowId} not found and no fallback page available`) | |
| } | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/browseros-agent/apps/server/src/api/services/sdk/browser.ts
Line: 128-138
Comment:
**Silent fall-through when `windowId` navigation fails completely**
When `windowId !== undefined`, the active tab in that window is missing, `newPage(url, { windowId })` throws, *and* `getFallbackPage()` returns `null` (e.g. browser has zero open pages), execution silently falls out of the `if (windowId !== undefined)` block. The code then calls `this.browser.newPage(url)` at line 149 **without** the `windowId`, creating a page in an arbitrary window and returning it as if the requested window constraint was satisfied.
The previous behaviour threw `SdkError('No active tab in specified window')`, which was safer. Consider re-throwing (or at least logging) when both fallbacks are exhausted while a caller-specified window was targeted:
```suggestion
} catch {
const fallbackPage = await this.getFallbackPage()
if (fallbackPage) {
await this.browser.goto(fallbackPage.pageId, url)
return {
tabId: fallbackPage.tabId,
windowId: fallbackPage.windowId ?? 0,
}
}
throw new SdkError(`Window ${windowId} not found and no fallback page available`)
}
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Fixed in ecc8ede. The window-targeted navigation path now rethrows the original window-scoped failure when it cannot create a page and there is no fallback page available, so it no longer falls through to the generic new-page path and silently drops the requested windowId. I also added a focused unit test for that case and tightened the health route test coverage in the same follow-up.
ecc8ede to
1e33dd9
Compare
|
@greptileai review |
|
@claude review |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Rebase on main missed updating eval scripts that still referenced extension ports, --extension-port args, and /extension-status endpoint. Updated to use CDP-only architecture via /health endpoint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The .llm/ directory is in .gitignore but was accidentally committed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32b16b6 to
87506af
Compare
Summary
apps/controller-extChrome extension workspace and the server-sideControllerBackendWebSocket bridge end-to-endtest-lifecycle.ts,test-failure-scenarios.ts) to use CDP health checks instead of extension statusmkdircalls in page-actions for PDF/screenshot/download pathsRework
After rebasing on main (which added 9 new commits including credits tracking, Qwen OAuth, voice input, and build smoke tests), cleaned up remaining controller-ext references in eval scripts that the rebase missed. All extension port/status references are now fully removed.
Test plan
bun run typecheck— all packages passbun run lint— only pre-existing cognitive complexity warningscontroller-ext,extensionPort,extension-status, or--extension-portwindowIdfall-through now throws instead of dropping the constraint🤖 Generated with Claude Code