Skip to content

refactor(browser): remove the unused screenshot-prep visibility helper - #22526

Merged
Jinwoo-H merged 1 commit into
mainfrom
browser-remove-unused-screenshot-prep
Sep 24, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
browser-remove-unused-screenshot-prep

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1 $\color{#cf222e}{\Huge{\mathbf{−}}}$​291 $\color{#cf222e}{\Huge{\mathbf{−}}}$​290
Prod 2 0 $\color{#cf222e}{\Huge{\mathbf{−}}}$​212 $\color{#cf222e}{\Huge{\mathbf{−}}}$​212

ELI5

The desktop app had a piece of code that could briefly flip the user's screen to a hidden browser page so a screenshot could be taken, then flip it back. Nothing uses it any more, so this removes it.

What Changed

  • Deleted ensureWebviewVisible from src/main/browser/browser-manager-visibility.ts. It ran a script inside the app window that switched the active worktree, tab, and browser page, then restored them afterwards.
  • Deleted the five tests that exercised only that method, and the matching mock in the agent-browser test harness.
  • The one added line only drops an unused name from a test's destructuring after those tests went away.

Before and after, the user sees nothing different: the method had no callers, so the app never ran it.

Why

Evidence it was unused: searching the whole repository (including src/, mobile/, tests/, config/, and docs/) for ensureWebviewVisible finds only the method itself, its tests, and the test-harness mock. It is not reached by name through any IPC channel or string lookup. Screenshots already go through holdPaintForCapture, which keeps a page drawn without changing what the user sees; other browser commands don't need the page drawn at all.

Dead code that mutates the user's visible selection is a trap: a future caller could reintroduce the tab-flipping behavior that the newer approach was built to avoid. Deleting it is simpler than keeping it tested.

holdPaintForCapture, the global screenshot serialization, and window.__store (used widely by end-to-end tests) are untouched.

Linked Issue

Part of the Linear STA-8024 browser cleanup: https://linear.app/stably/issue/STA-8024/bug-android-app-browser-issues

Visual Proof

N/A — deletes code that had no production caller, so there is no visual or interaction change.

Testing

  • pnpm tc:node passes.

  • pnpm vitest run --config config/vitest.config.ts src/main/browser: everything passes except browser-manager-viewport-ownership.test.ts (12 tests), which fails identically on unmodified main and is unrelated.

  • pnpm run check:code-quality:changed passes.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Tests for the deleted method were removed with it; the remaining automation-visibility tests still run.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security, cross-platform, SSH, mobile, backwards compatibility, performance: no impact — main-process-only deletion of an uncalled method.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ba0cc857-6dfd-4c1f-a837-d6715702415f

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4ddbb and 36205c0.

📒 Files selected for processing (3)
  • src/main/browser/agent-browser-bridge-test-harness.ts
  • src/main/browser/browser-manager-guest-visibility.test.ts
  • src/main/browser/browser-manager-visibility.ts
💤 Files with no reviewable changes (3)
  • src/main/browser/agent-browser-bridge-test-harness.ts
  • src/main/browser/browser-manager-guest-visibility.test.ts
  • src/main/browser/browser-manager-visibility.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The browser manager no longer defines ensureWebviewVisible. Tests for its activation and restoration behavior were removed, along with the method from the browser manager test mock.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 36205

No actionable behavior regression is established; the change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: removing the unused screenshot-preparation visibility helper.
Description check ✅ Passed The description is complete and relevant. It explains the change, rationale, user impact, linked issue, visual proof status, testing results, scope considerations, and checklist status. It also docume…
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Deleted dead ensureWebviewVisible helper — removed from src/main/browser/browser-manager-visibility.ts; repo-wide search finds no callers or string/IPC lookup, so it never ran in production.
  • Removed its five tests and the harness mock — the deleted cases in browser-manager-guest-visibility.test.ts only exercised the removed method, and browserWindowFromWebContentsMock is dropped from the top-level destructuring (still defined and used in the electron mock, so nothing is left unused).
  • Refreshed the screenshotTurn comment — agent-browser-bridge-state.ts now attributes shared paintability to the automation visibility lease, matching withSerializedScreenshotAccess in agent-browser-bridge-capture-commands.ts.

Verification: rg ensureWebviewVisible returns nothing across the repo; the remaining browser-manager-guest-visibility.test.ts and agent-browser-bridge-automation-visibility.test.ts suites pass (9 tests). The live screenshot path still uses acquireAutomationVisibility, which the PR leaves untouched.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H force-pushed the browser-remove-unused-screenshot-prep branch from 3c4ddbb to 36205c0 Compare September 24, 2026 01:22
@Jinwoo-H
Jinwoo-H merged commit 4064653 into main Sep 24, 2026
56 of 58 checks passed
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.

1 participant