Skip to content

test(jetbrains): stop frontend tests opening a real browser - #13432

Merged
kirillk merged 1 commit into
mainfrom
nimble-reef
Aug 25, 2026
Merged

test(jetbrains): stop frontend tests opening a real browser#13432
kirillk merged 1 commit into
mainfrom
nimble-reef

Conversation

@kirillk

@kirillk kirillk commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Issue

No existing issue. Found while diagnosing a recurring "Your session has ended" ChatGPT page that kept appearing on a developer machine; the cause turned out to be our own test suite.

Context

Running the JetBrains frontend test suite opens a real browser tab on the developer's machine.

ProvidersSettingsUiTest seeds a fixture OAuth URL of https://auth.openai.com/device and then drives the real production UI. ProvidersSettingsUi.oauth() calls BrowserUtil.browse(ready.url), and BrowserUtil is only a static facade over the BrowserLauncher application service — nothing was stubbing it. So the test genuinely handed the URL to the default browser.

Confirmed from the macOS unified log: on every occurrence a short-lived java process calls LaunchServices.launchViaCSUA and Chrome receives a GURL Apple Event with target=GradleWorkerMain (the Gradle test worker), matching Chrome history visits to auth.openai.com/device with an AUTO_TOPLEVEL transition. Because the browser profile is not signed in to ChatGPT, OpenAI serves its logged-out "Your session has ended" page — which is what made this look like a broken Kilo auth flow rather than a test leak.

Beyond the interruption, this is a correctness gap: the test asserted the URL rendered in the panel field but never asserted that the browser was actually asked to open it.

Implementation

Fixed entirely on the test side — no production change.

BrowserUtil.browse resolves BrowserLauncher through ApplicationManager.getApplication().getService(...), so a test can replace that service. This is preferable to threading a new browse lambda through ProvidersSettingsUi: packages/kilo-jetbrains/AGENTS.md explicitly forbids adding production seams whose only purpose is test access, and replaceService + testRootDisposable is already the established pattern in this test tree.

  • Added FakeBrowserLauncher, a recording BrowserLauncher implementation, plus an installBrowser() extension on BasePlatformTestCase that installs it for the lifetime of the test.
  • ProvidersSettingsUiTest now installs the fake for the device-auth test and asserts the recorded URL, turning a silent real side effect into a real assertion.
  • Installed the same fake in AgentManagerPanelTest, GhBannerTest, and GhStatusCoordinatorTest, which reach other unguarded BrowserUtil call sites (PR URLs, git-scm / cli.github.com links), so future click assertions there cannot escape to a browser either.

Note that ~10 direct BrowserUtil call sites remain in the frontend (SessionUi, WorktreeStatsView, PrHeaderView, ModelDetailsPanel, and others). Their current tests do not trigger a browse, so they are left alone rather than churned; installBrowser() is the one-line guard to add if that changes.

Screenshots / Video

N/A — test-only change, no user-visible UI difference.

How to Test

Manual/local verification

Executed by the agent, from packages/kilo-jetbrains/:

  • ./gradlew :frontend:test --tests 'ai.kilocode.client.settings.providers.ProvidersSettingsUiTest' — passes, and the new assertion proves the browse call is intercepted.
  • ./gradlew :frontend:test for all four touched classes (ProvidersSettingsUiTest, AgentManagerPanelTest, GhBannerTest, GhStatusCoordinatorTest) — passes.
  • ./gradlew typecheck — passes.
  • Confirmed no browser handoff during those runs: /usr/bin/log show --last 2m --info --debug --style compact | grep -E 'target=GradleWorkerMain|launchViaCSUA' returned nothing, where it previously logged a GURL event to Chrome on every run.

Reviewer test steps

  1. From packages/kilo-jetbrains/, run ./gradlew :frontend:test --tests 'ai.kilocode.client.settings.providers.ProvidersSettingsUiTest'.
  2. Confirm no browser tab opens and the run passes.
  3. To see the old behaviour, stash this commit and rerun step 1 — a tab opens to auth.openai.com/device (showing OpenAI's logged-out page unless you are signed in).
  4. On macOS you can watch the handoff directly with /usr/bin/log show --last 2m --info --debug --style compact | grep target=GradleWorkerMain. Note log is shadowed by a zsh function in some shells, so use the absolute path.

Blocked checks and substitute verification

  • The full ./gradlew test suite was not run; verification was scoped to ./gradlew typecheck plus the four affected test classes, since the change only touches those test files and a new test-only helper.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes — not needed, test-only with no shipped behaviour change
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

@kirillk

ProvidersSettingsUiTest drove the real OAuth UI with a fixture URL of
https://auth.openai.com/device, and ProvidersSettingsUi calls
BrowserUtil.browse unstubbed. BrowserUtil is a static facade over the
BrowserLauncher application service, so every run of the frontend suite
launched an actual Chrome tab on the developer's machine.

Replace BrowserLauncher with a recording fake via replaceService instead
of adding a production seam, and assert the recorded URL so the browser
handoff is verified rather than performed. Install the same fake in the
GitHub/PR tests that reach other direct BrowserUtil call sites.
@kilo-code-bot

kilo-code-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/AgentManagerPanelTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/worktree/GhBannerTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/agentManager/worktree/GhStatusCoordinatorTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/settings/providers/ProvidersSettingsUiTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/testing/FakeBrowserLauncher.kt

Reviewed by grok-4.6 · Input: 225.4K · Output: 13.5K · Cached: 575.1K

Review guidance: REVIEW.md from base branch main

@kirillk
kirillk merged commit 24e3247 into main Aug 25, 2026
23 checks passed
@kirillk
kirillk deleted the nimble-reef branch August 25, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants