feat(extension): make the local daemon port configurable in the popup - #175
Open
shnpd wants to merge 4 commits into
Open
feat(extension): make the local daemon port configurable in the popup#175shnpd wants to merge 4 commits into
shnpd wants to merge 4 commits into
Conversation
The extension was hardwired to 52800; persist a custom loopback port and reconnect when it changes so users can match a non-default daemon. Co-authored-by: Cursor <cursoragent@cursor.com>
The field was too short to read; grow its height without widening the card. Co-authored-by: Cursor <cursoragent@cursor.com>
shnpd
requested review from
Ljy-0827 and
iuyo5678
and
a lite review from Copilot
September 2, 2026 11:27
There was a problem hiding this comment.
🟡 Changes recommended
Port parsing and URL construction need to be made stricter/more robust (e.g., avoid parseInt-accepting malformed input and avoid manual URL concatenation that can break IPv6 formatting).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR implements runtime configuration of the extension’s local daemon WebSocket port via the popup UI, persisting the setting in chrome.storage.local and updating the background connection behavior accordingly (addressing issue #114).
Changes:
- Added a popup “Connection port” input with validation + persistence (
bsk_daemon_port), plus friendlier disconnected-state messaging. - Updated background to read the stored port at startup and react to storage changes by updating the WebSocket URL and reconnecting.
- Extended transport to allow runtime URL changes and added/updated docs + i18n + tests.
File summaries
| File | Description |
|---|---|
| packages/i18n/src/locales/zh-CN/extension.json | Adds zh-CN strings for daemon port UI and unreachable messaging. |
| packages/i18n/src/locales/en-US/extension.json | Adds en-US strings for daemon port UI and unreachable messaging. |
| docs/architecture.md | Documents that the default daemon WS port is configurable via the popup. |
| apps/extension/src/transport/ws-transport.ts | Allows updating transport URL via setUrl() without auto-reconnect. |
| apps/extension/src/transport/daemon-endpoint.ts | New helpers for default port, URL resolution, and input/storage normalization. |
| apps/extension/src/transport/tests/ws-transport.test.ts | Adds coverage for setUrl() behavior. |
| apps/extension/src/transport/tests/daemon-endpoint.test.ts | Adds coverage for daemon endpoint URL/port parsing helpers. |
| apps/extension/src/lib/popup-bridge.ts | Removes unused set_port message variant; port now stored via storage. |
| apps/extension/src/lib/instance-id.ts | Adds get/set helpers and storage key for bsk_daemon_port. |
| apps/extension/src/lib/tests/instance-id.test.ts | Adds tests for daemon port persistence/normalization. |
| apps/extension/src/entrypoints/popup/use-daemon-port.ts | New hook to load/commit daemon port preference via chrome.storage.local. |
| apps/extension/src/entrypoints/popup/use-connection-state.ts | Updates comment to reflect current popup bridge semantics. |
| apps/extension/src/entrypoints/popup/App.tsx | Renders port input, adjusts disconnected messaging, and hides transport errors when disconnected. |
| apps/extension/src/entrypoints/popup/App.test.tsx | Adds tests for disconnected UX and daemon port input behavior. |
| apps/extension/src/entrypoints/background.ts | Reads stored port on startup and reconnects on storage updates. |
| apps/extension/PRIVACY.zh-CN.md | Updates privacy text to note configurable loopback port. |
| apps/extension/PRIVACY.md | Updates privacy text to note configurable loopback port. |
Review details
- Files reviewed: 17/17 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
如果有字符就报错,不直接转为数字 Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
修复注释不准确 Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
摘要
fix #114
扩展原先写死连接
ws://127.0.0.1:52800。本 PR 让用户在 popup 里配置本机 daemon 端口,写入chrome.storage.local后 background 自动改 WebSocket URL 并重连。默认端口仍为 52800。未连接时不再展示
[WSTransport] ...这类技术错误,改为提示确认 daemon 已启动且端口一致;连接开关在未连接时显示为关闭。改动说明
chrome.storage.local(bsk_daemon_port),不再使用未接线的set_port消息。setUrl+ disconnect/connect。WSTransport支持运行时更换 URL(不自动重连)。ui展示
测试
abc/0/65536)显示错误,且不写入 storage