Skip to content

refactor(browser): split browser and browser-IPC modules under the max-lines budget - #14697

Merged
nwparker merged 1 commit into
mainfrom
nwparker/downsize-02-main-browser
Aug 16, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/downsize-02-main-browser

Conversation

@nwparker

@nwparker nwparker commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 +16 −11 +5
Prod 42 +3515 −2929 +586

What

Splits the five oversized src/main/browser modules and src/main/ipc/browser.ts into focused modules, removes their eslint-disable max-lines suppressions, and prunes the six corresponding entries from the max-lines ratchet baseline (341 → 335).

No behavior change.

Why

Each of these six files carried a file-level max-lines suppression and had grown to 377–654 counted lines against a 300-line budget. Per AGENTS.md → "Do Not Disable Max Lines", the fix is to split, not to suppress; config/max-lines-baseline.txt is a shrink-only ratchet.

How it was split

Target Was Now Extracted
ipc/browser.ts 654 181 browser-grab-ipc, browser-guest-view-ipc, browser-renderer-trust, browser-session-profile-ipc, browser-tab-registration-wait
browser/cdp-ws-proxy.ts 607 237 cdp-client-response-writer, cdp-debugger-channel, cdp-dom-focus-replay, cdp-page-capture-commands, cdp-page-navigation-commands, cdp-synthetic-session-registry, cdp-target-discovery
browser/browser-screencast-stream.ts 573 131 …-stream-types, …-debugger-command, …-frame-metadata, …-cdp-events, …-device-metrics, …-frame-pacer, …-snapshot-capture, …-viewport-fit
browser/browser-guest-ui.ts 529 157 browser-guest-renderer-target, browser-guest-context-menu, browser-guest-grab-shortcuts, browser-guest-wheel-zoom, browser-guest-shortcut-dispatch
browser/browser-session-registry.ts 489 295 browser-session-meta-store, browser-session-persisted-profile-validation, browser-session-cookie-staging, browser-session-partition-policies
browser/snapshot-engine.ts 377 143 snapshot-ax-tree-walk, snapshot-cursor-interactive-elements

cdp-ws-proxy.ts is decomposed into collaborating objects rather than free functions, because its state is genuinely per-connection. Every collaborator is a private readonly instance field built in the constructor with live closures over this (() => this.client, () => this.port, () => this.stop()), so per-connection state stays per-connection.

browser-guest-ui.ts was renamed to browser-guest-shortcut-forwarding.ts: after the split it exports exactly one function, setupGuestShortcutForwarding, so the old name no longer described its contents (AGENTS.md → "name files after what they actually contain").

No barrel exports; every new module owns real logic and importers point at the owner.

Verification

  • npx oxlint (whole repo) — clean
  • pnpm check:max-lines-ratchet — passes; baseline 341 → 335
  • pnpm typecheck (node + cli + web) — clean
  • pnpm test — full suite green; the only failures are pre-existing load-induced timeouts in files this branch does not touch, each verified passing when re-run serially
  • No new runtime import cycles (type-only edges excluded — they are erased at compile time)
  • Diff grepped to confirm no eslint/oxlint-disable directive was added anywhere
  • src/main/browser suite: 40 files / 637 tests green, zero skips

IPC surface proved intact. The channel registration set was extracted from the original and from the new modules and diffed: identical sets and identical per-channel counts. All 23 registered handlers remain trust-gated (22 → 22 isTrustedBrowserRenderer call sites), and trustedBrowserRendererWebContentsId remains a single module singleton — the split did not fork the trust state.

Independent adversarial review of every file, each instructed to refute the "pure move" claim. Beyond reading, reviewers ran a multiset diff of every string/numeric literal and every comparison/logical operator (??, ?., ===, !==, &&, ||, …) between the original and the union of the new modules — confirming no ?? silently became ||, no bound or error string changed.

Specific invariants confirmed rather than assumed:

  • No per-stream, per-guest, or per-connection state became module-level. The only module-level containers in the guest split (CONTROL_MODIFIERS, MAC_COMMAND_MODIFIERS, WHEEL_ZOOM_BLOCKING_MODIFIERS, recentGuestWheelZoomByGuest) were already module-level in the original.
  • isSnapshotStale reads getSeq(), a live closure, not a captured number — had seq been passed by value across the new module boundary, the initial-snapshot fallback would have raced every live frame.
  • isClosed/isStopping are live thunks, so guards inside already-armed setTimeout callbacks still observe a stop() that happened after the timer was armed.
  • Listener pairing is identical in membership, handler identity, and order — including that the screencast message handler is built once per stream and stored in a const, so removeListener still receives the same reference.
  • Frame pacer timing preserved verbatim: the throttle disjunction, the non-sliding flush deadline, the retry re-entrancy guard, and the ackPending = false default (finish() must not ack, stop() must).
  • Ctrl+Tab state machine transitions, guards, relative ordering, and the load-bearing absence of preventDefault on the keydown branch are unchanged.
  • configuredPartitions moved from a private readonly instance field to a module-level const. The owning class is unexported with a single construction site, and two existing tests pin both halves of the semantics — one proves it still dedupes within a module instance, a later test reusing the same partition string proves state is still fresh between tests. Both pass.

Pre-existing issues found and deliberately NOT changed

  • browser-guest-wheel-zoom.ts: consumeRecentGuestWheelZoom returns false on a direction mismatch without deleting the stale WeakMap entry, so a zoom-in-then-zoom-out inside the 250 ms window leaves the old entry to expire on its own.
  • snapshot-cursor-interactive-elements.ts: in the injected page script, the trailing if (found.length >= 50) return is a no-op (last statement in the function); the cap is actually enforced by the two forEach guards at the call sites.
  • snapshot-ax-tree-walk.ts: ordinal() computes s[(v - 20) % 10], which indexes negatively for v < 20 and silently relies on the || s[v] || s[0] fallback chain.
  • browser-session-cookie-staging.ts: clearPendingBrowserCookieImport unlinks stagedPath + suffix after deleting the key, so a non-string persisted value would build a garbage path.
  • ipc/browser.ts: browser:acceptDownload is removeHandler'd but never registered (preserved verbatim in browser-guest-view-ipc.ts).

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f24fc469-4a4c-42d1-980e-1ee9838bfb7a

📥 Commits

Reviewing files that changed from the base of the PR and between 5b7f442 and 83e905b.

📒 Files selected for processing (48)
  • config/max-lines-baseline.txt
  • src/main/browser/browser-guest-context-menu.ts
  • src/main/browser/browser-guest-grab-shortcuts.ts
  • src/main/browser/browser-guest-renderer-target.ts
  • src/main/browser/browser-guest-shortcut-dispatch.ts
  • src/main/browser/browser-guest-shortcut-forwarding.test.ts
  • src/main/browser/browser-guest-shortcut-forwarding.ts
  • src/main/browser/browser-guest-ui.ts
  • src/main/browser/browser-guest-wheel-zoom.ts
  • src/main/browser/browser-manager.ts
  • src/main/browser/browser-screencast-cdp-events.ts
  • src/main/browser/browser-screencast-debugger-command.ts
  • src/main/browser/browser-screencast-device-metrics.ts
  • src/main/browser/browser-screencast-frame-metadata.ts
  • src/main/browser/browser-screencast-frame-pacer.ts
  • src/main/browser/browser-screencast-snapshot-capture.ts
  • src/main/browser/browser-screencast-stream-types.ts
  • src/main/browser/browser-screencast-stream.ts
  • src/main/browser/browser-screencast-viewport-fit.ts
  • src/main/browser/browser-session-cookie-staging.ts
  • src/main/browser/browser-session-meta-store.ts
  • src/main/browser/browser-session-partition-policies.ts
  • src/main/browser/browser-session-persisted-profile-validation.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/browser/cdp-client-response-writer.ts
  • src/main/browser/cdp-debugger-channel.ts
  • src/main/browser/cdp-dom-focus-replay.ts
  • src/main/browser/cdp-page-capture-commands.ts
  • src/main/browser/cdp-page-navigation-commands.ts
  • src/main/browser/cdp-synthetic-session-registry.ts
  • src/main/browser/cdp-target-discovery.ts
  • src/main/browser/cdp-ws-proxy.test.ts
  • src/main/browser/cdp-ws-proxy.ts
  • src/main/browser/snapshot-ax-tree-walk.ts
  • src/main/browser/snapshot-cursor-interactive-elements.ts
  • src/main/browser/snapshot-engine.ts
  • src/main/ipc/browser-grab-ipc.ts
  • src/main/ipc/browser-guest-view-ipc.ts
  • src/main/ipc/browser-renderer-trust.ts
  • src/main/ipc/browser-session-profile-ipc.test.ts
  • src/main/ipc/browser-session-profile-ipc.ts
  • src/main/ipc/browser-tab-registration-wait.ts
  • src/main/ipc/browser.test.ts
  • src/main/ipc/browser.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/runtime/orca-runtime-browser.test.ts
  • src/main/runtime/orca-runtime-browser.ts
💤 Files with no reviewable changes (2)
  • config/max-lines-baseline.txt
  • src/main/browser/browser-guest-ui.ts
🚧 Files skipped from review as they are similar to previous changes (45)
  • src/main/runtime/orca-runtime-browser.test.ts
  • src/main/browser/cdp-ws-proxy.test.ts
  • src/main/ipc/browser-renderer-trust.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/browser/browser-screencast-device-metrics.ts
  • src/main/browser/browser-guest-shortcut-forwarding.test.ts
  • src/main/ipc/browser-session-profile-ipc.test.ts
  • src/main/browser/browser-screencast-stream-types.ts
  • src/main/browser/browser-guest-renderer-target.ts
  • src/main/browser/browser-screencast-stream.ts
  • src/main/browser/browser-manager.ts
  • src/main/browser/browser-session-persisted-profile-validation.ts
  • src/main/browser/browser-guest-context-menu.ts
  • src/main/browser/browser-screencast-debugger-command.ts
  • src/main/browser/browser-screencast-frame-metadata.ts
  • src/main/browser/cdp-dom-focus-replay.ts
  • src/main/browser/browser-screencast-viewport-fit.ts
  • src/main/ipc/browser.ts
  • src/main/ipc/browser.test.ts
  • src/main/browser/cdp-debugger-channel.ts
  • src/main/browser/snapshot-cursor-interactive-elements.ts
  • src/main/browser/cdp-target-discovery.ts
  • src/main/browser/browser-screencast-frame-pacer.ts
  • src/main/browser/browser-guest-shortcut-forwarding.ts
  • src/main/browser/browser-screencast-cdp-events.ts
  • src/main/runtime/orca-runtime-browser.ts
  • src/main/ipc/browser-session-profile-ipc.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/browser/snapshot-ax-tree-walk.ts
  • src/main/browser/browser-session-meta-store.ts
  • src/main/ipc/browser-guest-view-ipc.ts
  • src/main/browser/snapshot-engine.ts
  • src/main/ipc/browser-tab-registration-wait.ts
  • src/main/ipc/browser-grab-ipc.ts
  • src/main/browser/cdp-page-navigation-commands.ts
  • src/main/browser/cdp-client-response-writer.ts
  • src/main/browser/browser-session-cookie-staging.ts
  • src/main/browser/browser-guest-wheel-zoom.ts
  • src/main/browser/cdp-page-capture-commands.ts
  • src/main/browser/browser-guest-shortcut-dispatch.ts
  • src/main/browser/browser-screencast-snapshot-capture.ts
  • src/main/browser/cdp-ws-proxy.ts
  • src/main/browser/browser-session-partition-policies.ts
  • src/main/browser/browser-guest-grab-shortcuts.ts

📝 Walkthrough

Walkthrough

The change decomposes browser functionality into dedicated modules. Guest input, screencast processing, session persistence, CDP proxy handling, snapshot generation, and browser IPC now use focused services and handlers. Existing orchestration modules delegate to these components. Tests, imports, cleanup paths, and line-count baselines were updated for the new structure.

Merge Risk: 🟡 Moderate · up to 83e90

The refactor preserves the existing browser behavior but still carries two unresolved risks: some accessibility references may target ID 0, and deleting a profile may leave staged cookie database files on disk. These bounded correctness and cleanup issues should be fixed or explicitly accepted before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the refactor and verification, but it omits most required template sections, including ELI5, Linked Issue, Visual Proof, Checklist, and Author. Add the required template sections and complete the Linked Issue, Visual Proof, Testing checklist, AI Disclosure, Review, Checklist, and Author fields.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary refactor: splitting oversized browser and browser-IPC modules under the max-lines budget.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (7)
src/main/browser/snapshot-cursor-interactive-elements.ts (1)

4-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten or remove the implementation comments.

These comments restate visible behavior. Keep only a short comment for non-obvious policy or constraints.

As per coding guidelines, comments must be concise, non-obvious, and brief.

Also applies to: 16-17, 92-92

Source: Coding guidelines

src/main/browser/browser-session-meta-store.ts (1)

57-62: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Resolve the metadata path once per write.

persistBrowserSessionMeta calls resolveMetadataPath() four times in one write. The resolver reads metadataPathOverride and app.getPath('userData') at call time. If the resolved value changes between calls, the temporary file and the rename target can point to different directories, and the rename is no longer atomic. A single local value also removes the repeated lookups.

♻️ Proposed refactor
   try {
     const existing = loadBrowserSessionMeta(resolveMetadataPath, defaultPartition)
-    const tmpPath = `${resolveMetadataPath()}.tmp`
-    mkdirSync(dirname(resolveMetadataPath()), { recursive: true })
+    const metadataPath = resolveMetadataPath()
+    const tmpPath = `${metadataPath}.tmp`
+    mkdirSync(dirname(metadataPath), { recursive: true })
     writeFileSync(tmpPath, JSON.stringify({ ...existing, ...updates }))
-    renameSync(tmpPath, resolveMetadataPath())
+    renameSync(tmpPath, metadataPath)
   } catch {
src/main/browser/browser-session-partition-policies.ts (1)

25-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider one shared helper for clean user-agent application.

Lines 28 and 34-38 duplicate the logic in applyBrowserSessionUserAgentModes at lines 112-121: set the user-agent mode, clean the Electron user agent, then install the client-hints override. The two copies can drift, and only the copy in installBrowserSessionPartitionPolicies guards typeof sess.getUserAgent === 'function'. Extract a single applyUserAgentModeToSession(sess, profile) helper and call it from both places.

Also applies to: 106-126

src/main/browser/browser-session-persisted-profile-validation.ts (1)

4-5: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Tighten the profile-ID pattern.

Each group in BROWSER_SESSION_PROFILE_ID_RE allows - as a member character, so strings such as ------------------------------------ pass. The deterministic partition comparison in isProfileOwnedSessionPartition still confines the derived partition, so this is a strictness gap and not an exploitable path. Use [\da-f] in each group to make the check a real UUID match.

♻️ Proposed refactor
-const BROWSER_SESSION_PROFILE_ID_RE =
-  /^[\da-f-]{8}-[\da-f-]{4}-[\da-f-]{4}-[\da-f-]{4}-[\da-f-]{12}$/
+const BROWSER_SESSION_PROFILE_ID_RE =
+  /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/
src/main/browser/browser-session-registry.ts (1)

236-242: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Reuse clearPendingCookieImport in deleteProfile.

deleteProfile removes the pending entry from the metadata map only. clearPendingBrowserCookieImport in src/main/browser/browser-session-cookie-staging.ts also unlinks the staged database and its -wal/-shm sidecars. As written, the staged cookie database for a deleted profile stays on disk, so user cookie data survives profile deletion. This behavior predates the refactor, but the extracted helper now makes the fix a one-line delegation.

♻️ Proposed change
     this.profiles.delete(profileId)
     this.persistProfiles()
-    const meta = this.loadPersistedMeta()
-    const pendingCookieImports = { ...meta.pendingCookieImports }
-    delete pendingCookieImports[profile.partition]
-    this.persistMeta({
-      pendingCookieImports,
-      pendingCookieDbPath: pendingCookieImports[this.defaultPartition] ?? null
-    })
+    this.clearPendingCookieImport(profile.partition)
src/main/browser/cdp-synthetic-session-registry.ts (1)

49-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: simplify the synthetic-session guard.

The expression repeats the msgSessionId truthiness check three times. A single early return states the same rule.

♻️ Proposed simplification
   resolveDebuggerSessionId(msgSessionId?: string): string | undefined {
-    const syntheticSession =
-      (msgSessionId && this.clientSessionIds.has(msgSessionId)) ||
-      (msgSessionId && this.clientBrowserSessionIds.has(msgSessionId))
-    return msgSessionId && !syntheticSession ? msgSessionId : undefined
+    if (!msgSessionId) {
+      return undefined
+    }
+    const synthetic =
+      this.clientSessionIds.has(msgSessionId) || this.clientBrowserSessionIds.has(msgSessionId)
+    return synthetic ? undefined : msgSessionId
   }
src/main/browser/cdp-target-discovery.ts (1)

26-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: hoist the Chrome version fallback to one place.

Lines 28 and 90 duplicate process.versions.chrome ?? '134.0.0.0'. A module constant keeps the two identity responses in sync.

♻️ Proposed extraction
+const CHROME_VERSION = process.versions.chrome ?? '134.0.0.0'
+
 export class CdpTargetDiscovery {

Then use CHROME_VERSION in both handleHttpRequest and the Browser.getVersion branch.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1487f71b-1b32-4c96-9251-808967c98c3c

📥 Commits

Reviewing files that changed from the base of the PR and between 3908978 and bd298cb.

📒 Files selected for processing (48)
  • config/max-lines-baseline.txt
  • src/main/browser/browser-guest-context-menu.ts
  • src/main/browser/browser-guest-grab-shortcuts.ts
  • src/main/browser/browser-guest-renderer-target.ts
  • src/main/browser/browser-guest-shortcut-dispatch.ts
  • src/main/browser/browser-guest-shortcut-forwarding.test.ts
  • src/main/browser/browser-guest-shortcut-forwarding.ts
  • src/main/browser/browser-guest-ui.ts
  • src/main/browser/browser-guest-wheel-zoom.ts
  • src/main/browser/browser-manager.ts
  • src/main/browser/browser-screencast-cdp-events.ts
  • src/main/browser/browser-screencast-debugger-command.ts
  • src/main/browser/browser-screencast-device-metrics.ts
  • src/main/browser/browser-screencast-frame-metadata.ts
  • src/main/browser/browser-screencast-frame-pacer.ts
  • src/main/browser/browser-screencast-snapshot-capture.ts
  • src/main/browser/browser-screencast-stream-types.ts
  • src/main/browser/browser-screencast-stream.ts
  • src/main/browser/browser-screencast-viewport-fit.ts
  • src/main/browser/browser-session-cookie-staging.ts
  • src/main/browser/browser-session-meta-store.ts
  • src/main/browser/browser-session-partition-policies.ts
  • src/main/browser/browser-session-persisted-profile-validation.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/browser/cdp-client-response-writer.ts
  • src/main/browser/cdp-debugger-channel.ts
  • src/main/browser/cdp-dom-focus-replay.ts
  • src/main/browser/cdp-page-capture-commands.ts
  • src/main/browser/cdp-page-navigation-commands.ts
  • src/main/browser/cdp-synthetic-session-registry.ts
  • src/main/browser/cdp-target-discovery.ts
  • src/main/browser/cdp-ws-proxy.test.ts
  • src/main/browser/cdp-ws-proxy.ts
  • src/main/browser/snapshot-ax-tree-walk.ts
  • src/main/browser/snapshot-cursor-interactive-elements.ts
  • src/main/browser/snapshot-engine.ts
  • src/main/ipc/browser-grab-ipc.ts
  • src/main/ipc/browser-guest-view-ipc.ts
  • src/main/ipc/browser-renderer-trust.ts
  • src/main/ipc/browser-session-profile-ipc.test.ts
  • src/main/ipc/browser-session-profile-ipc.ts
  • src/main/ipc/browser-tab-registration-wait.ts
  • src/main/ipc/browser.test.ts
  • src/main/ipc/browser.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/runtime/orca-runtime-browser.test.ts
  • src/main/runtime/orca-runtime-browser.ts
💤 Files with no reviewable changes (2)
  • src/main/browser/browser-guest-ui.ts
  • config/max-lines-baseline.txt

Comment on lines +124 to +130
if (isInteractive && (hasFocusable || node.backendDOMNodeId)) {
const ref = `@e${nextRef()}`
entries.push({
ref,
role: formatInteractiveRole(role),
name: name || '(unlabeled)',
backendDOMNodeId: node.backendDOMNodeId ?? 0,

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Require a backend DOM ID before creating an @e reference.

Line 124 accepts a focusable node without backendDOMNodeId. Line 130 then stores 0. This creates a reference with no usable DOM target.

Proposed fix
-  if (isInteractive && (hasFocusable || node.backendDOMNodeId)) {
+  if (isInteractive && hasFocusable && node.backendDOMNodeId !== undefined) {
     const ref = `@e${nextRef()}`
     entries.push({
       ref,
       role: formatInteractiveRole(role),
       name: name || '(unlabeled)',
-      backendDOMNodeId: node.backendDOMNodeId ?? 0,
+      backendDOMNodeId: node.backendDOMNodeId,
       depth
     })

@nwparker
nwparker force-pushed the nwparker/downsize-02-main-browser branch from bd298cb to 83e905b Compare August 15, 2026 09:50
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…x-lines budget

The five oversized src/main/browser modules and src/main/ipc/browser.ts each
carried a file-level `eslint-disable max-lines` and ran 377-654 counted lines
against a 300-line budget. AGENTS.md calls for splitting rather than
suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so
this removes all six suppressions and prunes their entries (341 -> 335).

Pure move, no behavior change. cdp-ws-proxy is decomposed into collaborating
objects rather than free functions because its state is genuinely
per-connection: every collaborator is a private readonly instance field built
in the constructor with live closures over `this`, so per-connection state
stays per-connection. Likewise the screencast pacer's isClosed/isStopping and
snapshot capture's getSeq are live thunks, not values captured at wiring time,
so guards inside already-armed timers still observe a later stop().

browser-guest-ui.ts is renamed to browser-guest-shortcut-forwarding.ts: after
the split it exports exactly one function, setupGuestShortcutForwarding, so the
old name no longer described its contents.

Also restores a single `webContents.debugger` read in the screencast path. The
extraction had left three reads where the original had one; the accessor is
stable today, so this is not a behavior fix but it removes a latent divergence.

Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green
(remaining failures are pre-existing load flakes in untouched files, each green
when re-run serially), no new runtime import cycles, and the IPC channel set
diffed identical before/after with all 23 handlers still trust-gated.
@nwparker
nwparker force-pushed the nwparker/downsize-02-main-browser branch from 83e905b to c577e13 Compare August 15, 2026 10:31
@nwparker
nwparker merged commit c8fe5fc into main Aug 16, 2026
45 checks passed
@nwparker
nwparker deleted the nwparker/downsize-02-main-browser branch August 16, 2026 00:59
brennanb2025 added a commit that referenced this pull request Aug 17, 2026
Resolves conflicts with #14697, which split the browser and browser-IPC modules
under the max-lines budget. This branch's additions are relocated rather than
re-applied in place:

- browser-session-registry.ts: took main's restructured file and re-added only
  hasProfileNonTransplantableCookies / clearProfileNonTransplantableCookies plus
  the two imports they need. The import block this branch had touched was
  removed upstream because its consumers moved out.
- ipc/browser.ts: the session-profile handlers now live in
  browser-session-profile-ipc.ts, so the hasGoogleCookies / clearGoogleCookies
  handlers moved there beside their siblings instead of staying behind.
- browser.test.ts: main extracted the api mock into createBrowserMockApi, so the
  two new session mocks were added to the shared harness rather than inlined in
  one test file.
brennanb2025 added a commit that referenced this pull request Aug 17, 2026
Resolves a conflict with #14697, which split the browser IPC modules under the
max-lines budget and slimmed ipc/browser.ts's import block.

Took main's reorganized imports and re-added only the two this branch still
needs: cancelBrowserWebAuthnAccountRequests / respondToBrowserWebAuthnAccountRequest
and the BrowserWebAuthnAccountResponse type. The call sites stay put — the
browser:unregisterGuest handler that cancels pending pickers on tab close
remained in ipc/browser.ts rather than moving to one of the new modules.
AmethystLiang pushed a commit that referenced this pull request Aug 17, 2026
…x-lines budget (#14697)

The five oversized src/main/browser modules and src/main/ipc/browser.ts each
carried a file-level `eslint-disable max-lines` and ran 377-654 counted lines
against a 300-line budget. AGENTS.md calls for splitting rather than
suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so
this removes all six suppressions and prunes their entries (341 -> 335).

Pure move, no behavior change. cdp-ws-proxy is decomposed into collaborating
objects rather than free functions because its state is genuinely
per-connection: every collaborator is a private readonly instance field built
in the constructor with live closures over `this`, so per-connection state
stays per-connection. Likewise the screencast pacer's isClosed/isStopping and
snapshot capture's getSeq are live thunks, not values captured at wiring time,
so guards inside already-armed timers still observe a later stop().

browser-guest-ui.ts is renamed to browser-guest-shortcut-forwarding.ts: after
the split it exports exactly one function, setupGuestShortcutForwarding, so the
old name no longer described its contents.

Also restores a single `webContents.debugger` read in the screencast path. The
extraction had left three reads where the original had one; the accessor is
stable today, so this is not a behavior fix but it removes a latent divergence.

Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green
(remaining failures are pre-existing load flakes in untouched files, each green
when re-run serially), no new runtime import cycles, and the IPC channel set
diffed identical before/after with all 23 handlers still trust-gated.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…x-lines budget (stablyai#14697)

The five oversized src/main/browser modules and src/main/ipc/browser.ts each
carried a file-level `eslint-disable max-lines` and ran 377-654 counted lines
against a 300-line budget. AGENTS.md calls for splitting rather than
suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so
this removes all six suppressions and prunes their entries (341 -> 335).

Pure move, no behavior change. cdp-ws-proxy is decomposed into collaborating
objects rather than free functions because its state is genuinely
per-connection: every collaborator is a private readonly instance field built
in the constructor with live closures over `this`, so per-connection state
stays per-connection. Likewise the screencast pacer's isClosed/isStopping and
snapshot capture's getSeq are live thunks, not values captured at wiring time,
so guards inside already-armed timers still observe a later stop().

browser-guest-ui.ts is renamed to browser-guest-shortcut-forwarding.ts: after
the split it exports exactly one function, setupGuestShortcutForwarding, so the
old name no longer described its contents.

Also restores a single `webContents.debugger` read in the screencast path. The
extraction had left three reads where the original had one; the accessor is
stable today, so this is not a behavior fix but it removes a latent divergence.

Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green
(remaining failures are pre-existing load flakes in untouched files, each green
when re-run serially), no new runtime import cycles, and the IPC channel set
diffed identical before/after with all 23 handlers still trust-gated.
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