Repository navigation
feat(desktop): 远程工作区端口工具窗口:列出主机监听端口(带 IP),输入支持网址,默认不自动转发,可选本机端口 (#2231) - #2286
Merged
Merged
Conversation
1 task done
…,转发规则设计 (#2231) - 远端端口列显示主机监听的地址(IPv4 优先,多个地址显示“+N”),悬停提示给出全部地址;手动添加的网址行显示完整网址 - 顶部输入接受端口、主机:端口或网址,由 Core remote.parseForwardAddress 解析;网址带用户名或密码时拒绝;网址不写入日志 - 只有浏览器能打开的网址才显示“在浏览器中打开”,打开时把网址的路径接到本机地址上 - 固定 Core #156(46278d6),#156 合入后换成 main commit - Agent Note 与功能矩阵补充 T1–T4 转发规则模型(主机侧监听、反向转发已设计、未实现) - 重新生成端口页截图
# Conflicts: # desktop/internal/workbench/app.go
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 14:38
This was referenced Nov 21, 2026
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
Core 的远程模块已经有端口转发和监听端口读取(
remote.startForward、remote.stopForward、remote.forwards、ports.listening),但桌面端没有入口。远程工作区在主机上跑起来的服务,用户在本机既看不到也打不开。这次按用户的决定实现:
第一版评审后用户提出三点:
本 PR 实现了前两点。第三点已经设计好并写进 #2231(§8、D10、S20、S27–S30),实现另开 PR。
改动 / Changes
Core 调用封装(
desktop/internal/core/)remote_forward.go:RemoteForward、RemoteForwardTarget、RemoteListeningPort。RemoteStartForward、RemoteStopForward、RemoteForwards、RemoteListeningPorts,都按会话发送。RemoteForward带LocalPortChanged和RequestedLocalPort:请求的本机端口被占用时,Core 改用空闲端口,并告诉桌面端原来请求的是哪个。RemoteForwardAddress和方法RemoteParseForwardAddress,调用 Core 的remote.parseForwardAddress(feat(remote): read a port, host:port or URL typed into the ports page (#2231) Lithe-IDEA/Lithe-core-rust#156):主机:端口(IPv6 加方括号)或网址。网址没写端口时按协议取默认端口:http/ws 为 80,https/wss 为 443。RemoteConnectionFieldError给出原因:empty、tooLong、malformed、scheme、credentials、host、port。errors.go新增两个错误码:forward_target_not_confirmed:目标在主机回环地址以外,用户还没确认(S28)。forward_limit_reached:会话的转发数已到上限,详情带maximum。remote_session_test.go:对不存在的会话,四个转发命令都返回connection_closed。remote_helpers_test.go:新增TestRemoteParseForwardAddressReadsPortsAndURLs,直接调用真实 Core,覆盖端口、IPv6、网址默认端口、路径,以及拒绝带用户名的网址。“端口”工具窗口(
desktop/internal/workbench/remote_ports.go、remote_ports_view.go)itemPorts,放在左下区,带remote标记。chromeState.setRemote在打开远程工作区时显示它,在关闭工作区时隐藏它,排列位置保留。ports.listening和remote.forwards,之后每 3 秒读一次。0.0.0.0和::上监听只占一行。127.0.0.1:5432、10.0.0.5:9000。0.0.0.0:8080 +1),悬停提示列出全部地址。remote.parseForwardAddress解析。原来桌面端的parseRemotePort已删除。desktop.remote.ports.addCredentials)。Core 拒绝这种网址,不会保存它。http://127.0.0.1:5173/app。AllowNonLoopback重新转发;取消记为拒绝(target_declined)。remotePorts.reset()清掉转发,因为 Core 会随会话结束转发。remote.ports.forward、remote.ports.localPort、remote.ports.move、remote.ports.stop、remote.ports.status等。失败只记操作名和错误码,不记主机、地址、网址或进程名。credentials_in_address、invalid_port;Core 以后新增的原因统一记为invalid_address。errRemotePortOpen;网址只出现在给用户的通知里。接线
app.go:RemoteParseForwardAddress)。chrome.setRemote(false)。merge main 之后,这一行在 fix(desktop): open Viva settings and finish interrupted shutdowns #2287 抽出的disposeProject里。catalog.go:itemPorts、item.remote、chromeState.present和setRemote。apply跳过当前窗口里不存在的项。commands.go:“显示工具窗口”命令跳过当前窗口里不存在的项。shell_view.go:remoteToolWindow允许端口窗口。chrome_view.go:状态栏加入转发数量。remote_workspace.go:remoteProject.ports。setRemote(true)。i18n/messages.go、shell_messages.go:新增工具窗口名Tools.Ports。固定 Core 版本(
scripts/desktop/build-desktop-core.sh)PINNED_CORE_REVISION为 Core main 的ae593eb,即 fix(windows): expand compact folder chains in one click #156 合入后的 commit。它的 tree 与 PR 分支上的 46278d6 相同(都是5e20e66),已用新 pin 重新构建并跑了测试。文案(
shared/i18n/features/remote-ports.json)addCredentials)。remoteMore)及两种悬停提示(remoteListening、remoteUrlListening)。desktop/internal/i18n/shared.generated.go。功能矩阵(
shared/platform-feature-matrix/features/remote-workspace.json)desktop/internal/core/remote_helpers_test.go)。remote.parseForwardAddress,并写明 T3/T4(主机侧监听、反向转发)只设计、未实现。pending。Agent Note(
.agents/notes/proposed/architecture/2026-10-24-remote-development-workspace-host.md)remote.parseForwardAddress和 T1–T4 转发规则模型。转发规则设计(已写进 #2231 正文,代码在后续 PR)
规则 = 监听的一侧(地址和端口)+ 连接目标的一侧(端口、
主机:端口、网址,以后可加 Unix socket)。relay.open),数据不绕回本机;绑定所有网卡要单独确认,而且不记住计划中的 API(Core
crates/remote):remote.startHostForward和remote.startReverseForward。remote.forwards带kind字段(local、host、reverse)。截图(
docs/assets/remote-ports/)TestVisualRemotePorts生成 8 张截图:列表、菜单、S28 询问、本机端口对话框,各有浅色英文和深色中文两种。这次全部重新生成,加入了带 IP 的远端端口、+1和手动添加的网址行。README 已同步。不在本 PR 范围内 / Out of scope
类型专属:feat
多平台对齐
范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/remote-workspace.json,两端的验证状态如实保持pending。./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD。.artifacts/下生成的矩阵视图。插件归属 / Plugin ownership
item.remote是宿主内置工具窗口的标记,不对插件开放。UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… ../scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualRemotePorts$' -count=1,在本 PR 最新代码上生成,覆盖浅色英文和深色中文,窗口 1200×760。端口列表(浅色,英文):
http://localhost:5173/app按输入显示,已转发到127.0.0.1:5173。0.0.0.0:8080 +1是同时在0.0.0.0和::上监听的 node;本机 8080 被占用,改用 40001,并用警告色显示。127.0.0.1:5432、10.0.0.5:9000带出了主机监听的 IP。端口列表(深色,中文)
已转发行的右键菜单(浅色,英文)
转发回环地址以外的目标前询问(S28,深色,中文)
选择本机端口(深色,中文)
统一日志系统 / Structured logging
performed,失败用已有的operationFailed、operationRejected、backgroundFailed。没有新增事件 ID,也没有print或直接写 stderr。remoteLogError)。添加被拒绝时只记固定原因词,浏览器打开失败记固定错误。测试用loggedAny检查日志里没有这些内容,网址测试还检查了网址和其中的令牌。界面文案 / i18n
shared/i18n/features/remote-ports.json,中英文齐全,生成文件已重新生成并提交。代码用字面量键,通过i18n.Shared和i18n.SharedFormat读取。node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过,没有放宽脚本。逻辑归属 / Logic placement
parseRemotePort改由 Core 的remote.parseForwardAddress解析(feat(remote): read a port, host:port or URL typed into the ports page (#2231) Lithe-IDEA/Lithe-core-rust#156),旧函数和测试已删除。性能与内存 / Performance and memory
设置 / Settings
插件契约 / Plugin contract
N/A:没有改插件契约、能力版本或宿主方法。用到的是 Core 远程模块的命令,不属于插件 API。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过。无用代码与重构 / Dead code and refactoring
parseRemotePort、TestParseRemotePort、remotePorts.addInvalid和remotePortRow.manual(改为added)。验证 / Verification
gofmt -l internal/workbench internal/core../scripts/desktop/desktop-go.sh vet ./...(merge main 之后)../scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/core -count=1(merge main 之后)../scripts/desktop/desktop-go.sh test ./internal/core -run 'TestRemoteParseForwardAddressReadsPortsAndURLs|TestRemoteParseAddressSplitsTheFields'(换 pin 为 ae593eb 之后)test-stability-macos.sh --package ./internal/workbench -- --filter 'RemotePort'(换 pin 之后)TestVisualRemotePorts(vivahead,lithevisual)node scripts/i18n/generate-i18n.mjs --checknode scripts/i18n/verify-app-language-localization.mjsscripts/platform-feature-matrix/verify-platform-feature-matrix.shscripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADscripts/agent-notes/verify-agent-notes.shscripts/desktop/verify/verify-runtime-bundle-immutability.shrgdesktop/internal/workbench/remote_ports_test.go中的测试用一个假主机内核,按 Core 的语义模拟转发和地址解析:本机端口被占用时换成空闲端口,非回环目标要先确认,有转发上限,地址按 Core 的原因拒绝。真实 Core 的地址解析由internal/core的测试覆盖。TestRemotePortsWindowIsOnlyInARemoteWorkspaceTestRemotePortsListsAndForwardsTheHostsPortsTestRemotePortsAsksBeforeForwardingOutsideTheLoopbackTestRemotePortsAddsStopsAndRemovesAPortTestRemotePortsForwardOnAChosenLocalPortTestRemotePortsStopsAllAndReportsTheLimitTestRemotePortsForgetTheForwardsOfALostSessionTestRemotePortsReadOnlyWhileTheWindowIsOpenTestRemotePortsReportAFailedReadingOnceTestRemotePortsForwardAURL(新增)TestRemotePortRowText(新增)+N、http/https/ws 网址、过长的 IPv6 地址;哪些网址显示“在浏览器中打开”TestRemotePortHostTestRemoteParseForwardAddressReadsPortsAndURLs(internal/core,新增)未能执行的检查和原因:
提交前确认 / Final checks
main创建;已 merge 最新main(af37a1636,含 fix(desktop): open Viva settings and finish interrupted shutdowns #2287),解决了app.go冲突;目标分支为main