Skip to content

feat(browser): add NativeKit-powered PiP overlay#2011

Open
zerob13 wants to merge 9 commits into
devfrom
codex/nativekit-pip-window
Open

feat(browser): add NativeKit-powered PiP overlay#2011
zerob13 wants to merge 9 commits into
devfrom
codex/nativekit-pip-window

Conversation

@zerob13

@zerob13 zerob13 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • pin @zerob13/nativekit to 0.6.0
  • configure the native PiP controls as Open in side panel and Close, then map their control IDs to the existing typed activate / dismiss flow
  • reduce the native preview from 400 x 250 DIP to 360 x 225 DIP for a sharper 480 x 300 source image
  • use NativeKit 0.6.0's display-work-area sizing and anchoring so root-level panels can remain outside the DeepChat window
  • retain the Canvas fallback and its compact-window guard for unsupported or host-constrained runtimes
  • update packaging assertions, adapter coverage, lockfile, and the NativeKit PiP architecture record

Why

NativeKit 0.6.0 replaces fixed product-semantic controls with up to two caller-configured controls and emits their IDs through control. It also decouples root-level overlay sizing and anchoring from host-window bounds. DeepChat can therefore own the button semantics while NativeKit owns native window movement and rendering.

UI / interaction

BEFORE — Native PiP 400×250
┌────────────────────────┐
│ Agent snapshot         │
│                 [↻][◉] │
└────────────────────────┘
fixed relocate / hide controls

AFTER — Native PiP 360×225
┌────────────────────────┐
│ Agent snapshot         │
│                 [▯][×] │
└────────────────────────┘
configured open-panel / close controls
root-level anchor uses display work area
  • [▯]: open the existing Browser side panel
  • [×]: dismiss PiP for the current Agent run
  • double-click: open the existing Browser side panel
  • drag: move the native panel without resetting its manual position during frame refresh

Validation

  • pnpm install
  • pnpm run format
  • pnpm run i18n
  • pnpm run lint
  • pnpm run typecheck
  • pnpm run build
  • focused NativeKit adapter, packaging, and Canvas fallback suite: 23 tests passed
  • full main suite: 405 files / 4,636 tests passed; 19 files / 233 tests skipped
  • PREBUILDS_ONLY=1 resolved the published macOS arm64 node.napi.armv8.node
  • published-addon smoke: start({ controls: [...] }) -> stop passed
  • git diff --check

Dependency review

  • reviewed NativeKit tag: v0.6.0, commit 02cdbcf
  • supported prebuilds: macOS arm64/x64, Linux arm64/x64, Windows x64
  • Windows arm64 and native Wayland continue to use the existing Canvas fallback

Dev sync

The branch contains current origin/dev at f4525e66c and was 0 commits behind when this update was pushed.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds NativeKit 0.6.0 as the preferred Agent Browser PiP surface on supported runtimes, preserves Canvas fallback behavior, introduces native overlay lifecycle and frame routing, updates typed contracts and renderer handling, validates packaged prebuilds, and documents the migration.

Changes

NativeKit Agent Browser PiP

Layer / File(s) Summary
Migration contracts and architecture
docs/architecture/nativekit-agent-browser-pip/*, docs/features/agent-browser-pip/spec.md, src/shared/contracts/*, src/shared/types/*
Documents NativeKit surface selection, lifecycle, fallback, packaging, and validation rules, and adds typed preview surfaces, mode results, and preview-action events.
NativeKit packaging and prebuild validation
package.json, pnpm-workspace.yaml, electron-builder.yml, scripts/afterPack.js, test/main/build/*, test/main/scripts/*
Pins NativeKit 0.6.0, disables install-time builds, unpacks prebuilds, and validates target-specific native binaries during packaging.
Native overlay adapter
src/main/desktop/browser/AgentBrowserNativeOverlay.ts, test/main/desktop/browser/AgentBrowserNativeOverlay.test.ts
Adds NativeKit startup, host attachment, JPEG presentation, visibility, action forwarding, display synchronization, fallback handling, and cleanup.
Presenter surface routing and lifecycle
src/main/desktop/browser/YoBrowserPresenter.ts, src/main/desktop/routes.ts, test/main/desktop/browser/YoBrowserPresenter.test.ts
Selects native or Canvas presentation, routes each frame to one surface, validates capture identity, manages native targets, and emits scoped native actions.
Renderer coordination and fallback behavior
src/renderer/api/BrowserClient.ts, src/renderer/src/components/browser/AgentBrowserPiP.vue, renderer and contract tests
Tracks the selected surface, suppresses Canvas rendering for native overlays, and handles window/session/run-scoped activation and dismissal.
ACP registry version updates
resources/acp-registry/registry.json
Updates the dimcode and fast-agent versions and their distribution references.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentBrowserPiP
  participant BrowserClient
  participant YoBrowserPresenter
  participant AgentBrowserNativeOverlay
  participant NativeKit
  AgentBrowserPiP->>BrowserClient: setPreviewMode
  BrowserClient->>YoBrowserPresenter: invoke preview mode route
  YoBrowserPresenter->>AgentBrowserNativeOverlay: prepare native target
  YoBrowserPresenter->>AgentBrowserNativeOverlay: present JPEG frame
  AgentBrowserNativeOverlay->>NativeKit: push image
  NativeKit-->>AgentBrowserNativeOverlay: activate or dismiss action
  AgentBrowserNativeOverlay-->>YoBrowserPresenter: forward scoped action
  YoBrowserPresenter-->>BrowserClient: emit browser.preview.action
  BrowserClient-->>AgentBrowserPiP: deliver preview action
Loading

Possibly related PRs

Suggested reviewers: yyhhyyyyyy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a NativeKit-powered browser PiP overlay.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/nativekit-pip-window

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.

zerob13 added 2 commits July 23, 2026 18:19
…ndow

# Conflicts:
#	src/renderer/src/lib/icons/icon-collections.generated.ts
@zerob13
zerob13 marked this pull request as ready for review July 23, 2026 10:56

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/nativekit-agent-browser-pip/spec.md`:
- Around line 19-22: Refresh the NativeKit implementation evidence in the spec
to use version 0.5.5 throughout: update the Electron/native addon smoke,
upstream demo prebuild regression, and packaged artifact references from 0.5.4
to the current tarball, and replace obsolete nativekit.napi.node evidence with
node.napi.node while preserving the existing runtime and capability conclusions.
- Around line 114-115: Resolve the contract mismatch for xwayland-satellite by
updating the PiP movement requirements and corresponding goals, performance, and
acceptance sections to explicitly document its host-bound clipping, or by making
that runtime satisfy unrestricted out-of-window dragging before marking the
capability matrix and contract complete. Keep the behavior consistent across all
referenced sections.

In `@docs/features/agent-browser-pip/spec.md`:
- Around line 56-60: Scope the architecture statements in the “V1 Critical
Architecture Correction” section, including the PiP-in-conversation goal and
renderer-owned Canvas surface constraints, explicitly to the renderer-canvas
fallback runtime. Preserve the one-page, read-only mirror invariant while
clarifying that these constraints do not apply to the shipped NativeKit path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 76ee1a9f-6cd4-408b-ad63-cd1ed03cb004

📥 Commits

Reviewing files that changed from the base of the PR and between 011407a and 41b7788.

📒 Files selected for processing (27)
  • docs/architecture/nativekit-agent-browser-pip/plan.md
  • docs/architecture/nativekit-agent-browser-pip/spec.md
  • docs/architecture/nativekit-agent-browser-pip/tasks.md
  • docs/features/agent-browser-pip/spec.md
  • electron-builder.yml
  • package.json
  • pnpm-workspace.yaml
  • resources/model-db/providers.json
  • scripts/afterPack.js
  • src/main/desktop/browser/AgentBrowserNativeOverlay.ts
  • src/main/desktop/browser/YoBrowserPresenter.ts
  • src/main/desktop/routes.ts
  • src/renderer/api/BrowserClient.ts
  • src/renderer/src/components/browser/AgentBrowserPiP.vue
  • src/shared/contracts/events.ts
  • src/shared/contracts/events/browser.events.ts
  • src/shared/contracts/routes/browser.routes.ts
  • src/shared/types/browser.ts
  • src/shared/types/desktop.ts
  • test/main/build/electronBuilderConfig.test.ts
  • test/main/desktop/browser/AgentBrowserNativeOverlay.test.ts
  • test/main/desktop/browser/YoBrowserPresenter.test.ts
  • test/main/routes/contracts.test.ts
  • test/main/scripts/afterPack.test.ts
  • test/renderer/api/clients.test.ts
  • test/renderer/components/AgentBrowserPiP.test.ts
  • test/setup.ts

Comment thread docs/architecture/nativekit-agent-browser-pip/spec.md Outdated
Comment thread docs/architecture/nativekit-agent-browser-pip/spec.md
Comment thread docs/features/agent-browser-pip/spec.md

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/features/agent-browser-pip/spec.md (1)

11-17: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align all out-of-window claims with the xwayland-satellite limitation.

The architecture explicitly supports xwayland-satellite but limits it to host bounds, so “supported runtimes” cannot universally promise work-area-only, out-of-window movement.

  • docs/features/agent-browser-pip/spec.md#L11-L17: qualify the status statement to exclude host-bounded xwayland-satellite.
  • docs/architecture/nativekit-agent-browser-pip/spec.md#L28-L31: propagate the exception through the goals, performance, and acceptance wording.
  • docs/features/agent-browser-pip/spec.md#L107-L108: preserve the same exception in the non-goal.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/features/agent-browser-pip/spec.md` around lines 11 - 17, Qualify the
out-of-window support claims to exclude host-bounded xwayland-satellite: update
docs/features/agent-browser-pip/spec.md lines 11-17 and 107-108, and
docs/architecture/nativekit-agent-browser-pip/spec.md lines 28-31, preserving
the stated native behavior for other supported runtimes while explicitly
limiting xwayland-satellite movement to host bounds.
🧹 Nitpick comments (1)
docs/architecture/nativekit-agent-browser-pip/tasks.md (1)

8-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Record explicit validation for the shipped NativeKit version.

The checklist only names v0.5.4/v0.5.5 reviews, while this migration changes the dependency to 0.6.0, including controls and prebuild filenames. Add explicit 0.6.0 source/demo/prebuild validation or label the older items as historical prerequisites.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/architecture/nativekit-agent-browser-pip/tasks.md` around lines 8 - 20,
Update the documentation checklist to explicitly record validation of the
shipped NativeKit v0.6.0 source, upstream demo control flow, controls, and
prebuild filenames; alternatively, clearly label the existing v0.5.4/v0.5.5
entries as historical prerequisites and add the corresponding v0.6.0 validation
evidence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/nativekit-agent-browser-pip/spec.md`:
- Around line 558-572: Update
docs/architecture/nativekit-agent-browser-pip/spec.md lines 558-572 to replace
the historical 0.5.4 evidence and obsolete nativekit.napi.node filename with the
completed NativeKit 0.6.0 smoke results and current arm64/x64 prebuild
filenames. Update docs/architecture/nativekit-agent-browser-pip/tasks.md lines
90-95 to mark macOS arm64 validation complete only based on those 0.6.0 checks.

---

Outside diff comments:
In `@docs/features/agent-browser-pip/spec.md`:
- Around line 11-17: Qualify the out-of-window support claims to exclude
host-bounded xwayland-satellite: update docs/features/agent-browser-pip/spec.md
lines 11-17 and 107-108, and
docs/architecture/nativekit-agent-browser-pip/spec.md lines 28-31, preserving
the stated native behavior for other supported runtimes while explicitly
limiting xwayland-satellite movement to host bounds.

---

Nitpick comments:
In `@docs/architecture/nativekit-agent-browser-pip/tasks.md`:
- Around line 8-20: Update the documentation checklist to explicitly record
validation of the shipped NativeKit v0.6.0 source, upstream demo control flow,
controls, and prebuild filenames; alternatively, clearly label the existing
v0.5.4/v0.5.5 entries as historical prerequisites and add the corresponding
v0.6.0 validation evidence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f043fe-0ba4-4b01-b2ef-3154077f5a87

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6d602 and 43ecbb0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • docs/architecture/nativekit-agent-browser-pip/plan.md
  • docs/architecture/nativekit-agent-browser-pip/spec.md
  • docs/architecture/nativekit-agent-browser-pip/tasks.md
  • docs/features/agent-browser-pip/spec.md
  • package.json
  • resources/acp-registry/registry.json
  • src/main/desktop/browser/AgentBrowserNativeOverlay.ts
  • test/main/build/electronBuilderConfig.test.ts
  • test/main/desktop/browser/AgentBrowserNativeOverlay.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • package.json
  • docs/architecture/nativekit-agent-browser-pip/plan.md
  • test/main/desktop/browser/AgentBrowserNativeOverlay.test.ts
  • src/main/desktop/browser/AgentBrowserNativeOverlay.ts

Comment on lines +558 to +572
- `@zerob13/nativekit` is pinned to `0.6.0`, remains external to the main bundle, and its prebuilds
are unpacked from ASAR.
- NativeKit 0.6.0 configures `open-panel` and `close` controls, emits their IDs through `control`,
sizes the native panel to 360 x 225 DIP, and keeps root-level sizing independent of host bounds.
- The published 0.5.5 tarball uses `node.napi.node` for all five prebuilds. This matches
`@electron/rebuild` on x64, but its arm64 lookup requires `node.napi.armv8.node`; the missing
match caused the Linux arm64 install to fall back to `node-gyp` and fail on unavailable X11
development packages.
- NativeKit 0.5.6 uses the architecture-specific filenames expected by `@electron/rebuild`:
`node.napi.armv8.node` for arm64 and `node.napi.node` for x64.
- Installing the published 0.6.0 package on macOS arm64 completes
`electron-builder install-app-deps`, resolves the arm64 prebuild with `PREBUILDS_ONLY=1`, and
creates no NativeKit `build/Release` fallback binary.
- Loading the published 0.6.0 arm64 prebuild and calling
`start({ controls: [open-panel, close] }) -> stop` succeeds.

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Base completed validation claims on NativeKit 0.6.0 artifacts.

The current evidence and checklist still rely on 0.5.4 smoke/package results and the obsolete nativekit.napi.node filename.

  • docs/architecture/nativekit-agent-browser-pip/spec.md#L558-L572: replace historical evidence with the 0.6.0 smoke and current arm64/x64 filenames.
  • docs/architecture/nativekit-agent-browser-pip/tasks.md#L90-L95: only mark macOS arm64 validation complete after those 0.6.0 checks pass.
📍 Affects 2 files
  • docs/architecture/nativekit-agent-browser-pip/spec.md#L558-L572 (this comment)
  • docs/architecture/nativekit-agent-browser-pip/tasks.md#L90-L95
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/architecture/nativekit-agent-browser-pip/spec.md` around lines 558 -
572, Update docs/architecture/nativekit-agent-browser-pip/spec.md lines 558-572
to replace the historical 0.5.4 evidence and obsolete nativekit.napi.node
filename with the completed NativeKit 0.6.0 smoke results and current arm64/x64
prebuild filenames. Update
docs/architecture/nativekit-agent-browser-pip/tasks.md lines 90-95 to mark macOS
arm64 validation complete only based on those 0.6.0 checks.

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