Skip to content

Add invoke() bridge for source/remote/updater#3

Merged
seokju-na merged 2 commits into
mainfrom
bridges
Jun 20, 2026
Merged

Add invoke() bridge for source/remote/updater#3
seokju-na merged 2 commits into
mainfrom
bridges

Conversation

@seokju-na

@seokju-na seokju-na commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Native invoke() bridge for source / remote / updater, mirroring the Electron IPC surface, plus a common error shape and unified logging.

Key changes

  • Bridge commands — 20 <category><Name> commands (e.g. sourceListBundles), auto-registered by install. Typed Decodable args / Encodable responses (Codable both ways).
  • BridgeError { code?, message } — common JSON error shape delivered to the webview.
  • Unified os.Logger (subsystem: webview-bundle) — includes a seam (CoreLog) to fold in the Rust core's tracing once the FFI exposes a callback.

Tests

swift test — 16 passing (codec decode/encode, command dispatch, error shape, auto-registration, log-level mapping).

Also sweeps in minor TestApp fixture / e2e config updates.

🤖 Generated with Claude Code


Summary by cubic

Adds a native invoke() bridge for WKWebView with typed source, remote, and updater commands, unified { code?, message } errors, and unified logging. Invokes are now accepted only from the main frame; subframe messages are dropped for safety.

  • New Features

    • 20 invoke() commands for source/*, remote/*, updater/*; auto-registered under wvbIos with Codable args/results.
    • Common BridgeError { code?, message }; missing Remote/Updater reject with remote_not_initialized / updater_not_initialized.
    • Main-frame only: subframe invoke messages are ignored and logged.
    • Unified os.Logger (subsystem webview-bundle) with CoreLog.forward(...); log levels map to OSLogType.
    • New APIs: WebViewBundle.configure(), shared/safeShared, and install(on:bridge:), makeConfiguration(bridge:), makeWebView(frame:bridge:).
  • Migration

    • Initialize once with WebViewBundle.configure(config) and use WebViewBundle.shared; webViewBundle(_:) / wvb(_:) now alias configure(_:).
    • When creating a web view, call install(on:) or use makeConfiguration(bridge:) to auto-register commands; the message handler name is wvbIos.
    • If not using Remote or Updater, related web calls will reject with the codes above.

Written for commit 817bf66. Summary will update on new commits.

Review in cubic

@seokju-na

Copy link
Copy Markdown
Member Author

@cubic

@cubic-dev-ai

cubic-dev-ai Bot commented Jun 20, 2026

Copy link
Copy Markdown

@cubic

@seokju-na I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 19 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread Sources/WebViewBundle/Bridge.swift
@seokju-na seokju-na marked this pull request as ready for review June 20, 2026 09:43

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Sources/WebViewBundle/Bridge.swift">

<violation number="1" location="Sources/WebViewBundle/Bridge.swift:34">
P2: `install(on:)` is not idempotent and can crash when called more than once on the same configuration. Remove existing handler before re-adding `wvbIos`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


/// Registers this bridge on `configuration` as the `wvbIos` message handler.
func install(on configuration: WKWebViewConfiguration) {
configuration.userContentController.add(self, name: Self.messageHandlerName)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: install(on:) is not idempotent and can crash when called more than once on the same configuration. Remove existing handler before re-adding wvbIos.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sources/WebViewBundle/Bridge.swift, line 34:

<comment>`install(on:)` is not idempotent and can crash when called more than once on the same configuration. Remove existing handler before re-adding `wvbIos`.</comment>

<file context>
@@ -0,0 +1,190 @@
+
+    /// Registers this bridge on `configuration` as the `wvbIos` message handler.
+    func install(on configuration: WKWebViewConfiguration) {
+      configuration.userContentController.add(self, name: Self.messageHandlerName)
+    }
+
</file context>

@seokju-na seokju-na merged commit cdb3ba2 into main Jun 20, 2026
3 checks passed
@seokju-na seokju-na deleted the bridges branch June 20, 2026 15:43
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