feat: NMH dual-path IPC — WebSocket primary + NMH fallback#4
Merged
easyvibecoding merged 1 commit intomainfrom Mar 18, 2026
Merged
feat: NMH dual-path IPC — WebSocket primary + NMH fallback#4easyvibecoding merged 1 commit intomainfrom
easyvibecoding merged 1 commit intomainfrom
Conversation
Upgrade Native Messaging Host from config-only to full WS relay, enabling Chrome Extension to submit keys and query state even when WebSocket is disconnected (e.g., Service Worker wake, Core restart). - NativeMessagingHost.swift: add WS relay for get_state, submit_captured_key, toggle_demo_mode via URLSessionWebSocketTask - IPCServer.swift: add .nmh clientType, skip in broadcast - service-worker.ts: sendRequest() dual-path dispatch with pending request tracking, NMH fallback, structured error logging - popup.ts/html: show connection path (WebSocket/NMH/Offline) with color-coded dots (green/blue/red) - NMHInstaller.swift: Core auto-installs NMH binary + manifest - ipc-protocol: add 'nmh' to clientType union - Security: plaintext keys are NOT queued to chrome.storage - Docs: update all architecture, protocol, and status docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WebSocket is disconnected (SW wake, Core restart)
sendRequest()unified dispatch in service-worker.ts: WS → NMH fallback with request-response correlation + 5s timeoutNMHInstallerauto-installs NMH binary + Chrome manifest on Core startupChanges
NativeMessagingHost.swift
get_state,submit_captured_key,toggle_demo_modeURLSessionWebSocketTaskconnections (~20-60ms)"nmh", 5s timeout, auto-skips event messageswriteJSONfallback on serialization failureIPCServer.swift
.nmhcase toClientTypeenumbroadcast()skips.nmhclients (short-lived connections don't receive events)service-worker.ts
sendRequest()unified entry: WS → NMH fallbackpendingRequestsMap for WS request-response tracking (with reject on close)ws.oncloseproperly rejects all pending promises so NMH fallback triggerssubmit_captured_keydoes NOT queue plaintext keys tochrome.storage.localon dual failureget_statedoes NOT setisConnected = true(NMH is one-shot relay, not persistent)console.warnloggingpopup.ts / popup.html
NMHInstaller.swift (new file)
install.shretained as manual fallbackDocumentation
nmhSecurity
127.0.0.1onlychrome.storage.local(security red line feat: implement Chrome Extension Native Messaging Host #1)allowed_originsrestricted to Extension IDTest plan
swiftc NativeMessagingHost.swiftcompiles successfully (93KB)get_configreturns correct port/tokenget_staterelay returns isDemoMode + activeContext (~23ms)toggle_demo_moderelay toggles correctly (~18ms)submit_captured_keyrelay stores successfully (~56ms)core_unreachable(<100ms)debugDisconnectWS()→ Offline → reopen popup → Connected (NMH) blue dotdebugReconnectWS()→ Connected (WebSocket) green dot🤖 Generated with Claude Code