feat(browser,ble): native-messaging stable connect, /browser command, BLE as desktop-only feature#111
Conversation
… as desktop-only feature Browser extension (native messaging): - Reuse one long-lived token (Bridge.StableToken) instead of minting a fresh one each launch, and reuse the desktop sidecar port across restarts, so the extension reconnects silently with no re-auth. TUI: - Add /browser command: shows browser-use status and toggles it on/off (/browser on|off), wired via a decoupled tui.BrowserController. BLE (Bluetooth status channel) is now desktop-only and cleanly gated: - Root cause of the macOS Bluetooth prompt at startup: tinygo's bluetooth DefaultAdapter instantiates a CBCentralManager at package-init, before any config is read — so a runtime flag can't prevent it. Fix: the main binary never links CoreBluetooth; BLE runs in a separate jcode-ble helper it spawns only when enabled. No prompt when off. - feature.BLE build flag (-tags desktop): plain `jcode web` compiles BLE off (endpoints 404 / hidden in settings); desktop compiles it on. Frontend hides the toggle based on the backend-reported capability. - Remove BLE from the terminal/ACP entrypoints; keep it on the desktop path. - Live toggle: ble.Proxy lets the settings switch start/stop the helper without an app restart. - Desktop bundles jcode-ble (externalBin) and adds a Bluetooth entitlement; release CI and Makefile build the helper per-platform (cgo=1 on macOS only). Verified: go build/vet/test ./... (both default and -tags "jcode_headless desktop"), web type-check/build, cargo check, and a real jcode-ble build across darwin/linux/windows targets. Generated with Jack AI bot
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (27)
📝 WalkthroughWalkthroughThis PR extracts BLE functionality into a separate ChangesBLE helper process and channel wiring
Desktop sidecar entitlements and port persistence
Browser bridge stable token and TUI/CLI browser status
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant WebChannelAPI
participant BLEProxy
participant BLENotifier
participant JcodeBleHelper
WebChannelAPI->>BLEProxy: Enable() / Disable()
BLEProxy->>BLENotifier: New() / Close()
BLENotifier->>JcodeBleHelper: spawn process, write wireEvent JSON to stdin
JcodeBleHelper-->>BLENotifier: write ReceivedCommand JSON to stdout
BLENotifier-->>BLEProxy: publish on inbound channel
BLEProxy-->>WebChannelAPI: forward via Notify/Receive
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
What & why
Follow-up polish on the browser-use + status-channel work, plus a proper fix for the macOS Bluetooth permission prompt.
Browser extension — silent reconnect
Bridge.StableToken) reused across restarts instead of minting a fresh token each launch (which accumulated tokens and rewrote the endpoint every time).(serverUrl, token)stays valid across restarts → it reconnects silently, no re-Auto-connect.TUI —
/browsercommand/browser on|off.tui.BrowserControllerso the TUI doesn't depend on the browser manager directly.BLE (Bluetooth status channel) — desktop-only, no startup prompt
Root cause of the prompt: tinygo's
bluetooth.DefaultAdapterinstantiates aCBCentralManager/CBPeripheralManagerat package-init — before any config is read — so a runtimeBLEEnabledflag can't prevent the macOS Bluetooth prompt/TCC-abort while the package is linked in.Fix — separate helper process:
jcode-blehelper the main process spawns only when BLE is enabled, relayingNotifyEvents over stdio. No prompt when off; the prompt (if any) appears exactly when the user turns BLE on.feature.BLEbuild flag (-tags desktop): plainjcode webcompiles BLE off (its endpoints 404, the settings toggle is hidden via a backend-reportedavailablecapability); the desktop sidecar compiles it on.ble.Proxy): the settings switch starts/stops the helper immediately — no app restart needed.jcode-ble(externalBin), adds a Bluetooth entitlement, and the Makefile / release CI build the helper per-platform (cgo=1 on macOS only; Linux D-Bus / Windows WinRT are pure Go).Reviewer notes
com.apple.security.device.bluetoothentitlement is a sandbox key (harmless/ignored there) included for a future sandboxed/App-Store path and explicitness.jcode-blewith-tags blebutCGO_ENABLED=0on macOS silently falls back to the spawner stub → the Makefile forces cgo on darwin only (BLE_CGO).Verification
go build/vet/test ./...— default and-tags "jcode_headless desktop".type-check+build; desktopcargo check.jcode-blebuilds for darwin (cgo) / linux / windows.Bridge.StableTokenstability across restart,ble.Proxystate machine.Generated with Jack AI bot
Summary by CodeRabbit
New Features
/browsercommand in the TUI to view browser status and turn browser integration on or off.Bug Fixes