Repository navigation
feat(desktop): 远程开发窗口进入本机及 SSH/WSL 主机上的 Docker/Podman 容器,并从 devcontainer.json 构建打开 Dev Container (#2231) - #2295
Merged
Merged
Conversation
- 打开窗口时经 Core remote.listContainers 依次列出本机 docker 与 podman 正在运行的容器,一个引擎失败不影响另一个;WSL 之后以“容器”分组显示, 可折叠,搜索时不列出。 - 容器页显示引擎、地址、镜像与状态,可选填写容器内用户;“连接”经 remote.connect 的 container 参数进入,按容器名连接,不保存、不记住文件夹。 - remoteHost 改为 SSH、WSL、容器三选一,新增 overSSH() 统一 SSH 专属行为; 容器失败说明区分停止/暂停与找不到引擎,不显示 SSH 提示和“编辑连接”。 - 标题与状态栏标出容器;日志只记动作,不含容器名、镜像或用户。 - Core 客户端新增 ContainerConnection 与 RemoteListContainers; PINNED_CORE_REVISION 固定 Core #162 的 2e496d2。 - 新增中英词条、容器截图、功能矩阵条目与 Agent Note。
- 列表工具栏和空白页新增“从 devcontainer.json 打开…”:选本机文件夹,经 Core remote.devcontainerConfigs 按规范顺序列出配置,可选 Docker/Podman。 - 构建经 Core remote.devcontainerUp 运行官方 Dev Container CLI,输出逐行显示在 “构建日志”里(最多 5000 行),不写 Lithe 日志;可停止,停止后保留日志。 - 文件夹未受信任时按钮为“信任并构建”,先写本机信任记录再构建;Lithe 不额外 挂载目录、不加参数。 - 成功后选中 CLI 返回的容器,以 remoteUser 走容器入口连接并直接打开工作区文件夹。 - 找不到 CLI、CLI 失败、超时、结果不可用、未受信任分别说明,失败只记命令名和错误码。 - Core 固定到 #162 的 05c4139;中英词条、功能矩阵、Agent Note 与无头截图同步更新。
Resolve the feature matrix and the Core pin; pin Core #162 at b92fcaf, merged with Core main ac80382.
…ainers # Conflicts: # desktop/internal/i18n/shared.generated.go # desktop/internal/workbench/remote_workspace.go # desktop/internal/workbench/remote_workspace_test.go # scripts/desktop/build-desktop-core.sh # shared/platform-feature-matrix/features/remote-workspace.json
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
devcontainer.json构建并打开 Dev Container,以及进入已连接的 SSH 主机和 WSL 发行版上正在运行的容器,都作为远程工作区打开)remote.connect容器参数、remote.listContainers、remote.devcontainerConfigs与remote.devcontainerUp,Draft,本 PR 固定在它的 b92fcaf,即 【bug】双击Shift唤醒时以及关闭都会有卡顿 #162 合入 Core mainac80382(含 【bug】mac上的一些页面优化建议 #160、【bug】mac上卡顿问题 #161)后的提交;【bug】双击Shift唤醒时以及关闭都会有卡顿 #162 合入后改为固定 Core main)PR 类型 / Type
改动说明 / What changes
背景 / Why
#2231 要求远程工作区兼容 Dev Container。不论容器由 Dev Container CLI、
docker compose还是手工运行,第一步都是“进入一个正在运行的容器、在里面打开文件夹”。原来的远程开发窗口只能连 SSH 主机和 WSL 发行版,用户只能在容器里另装 sshd 再按 SSH 连。Core #162 已经能经docker exec -i/podman exec -i启动同一个远端服务,并能列出正在运行的容器。第一个提交(5df633064)在桌面端接上它:窗口直接列出本机的容器,选中后就能打开里面的文件夹,后面的流程和 SSH、WSL 一样(选文件夹、信任、工作区、心跳与重连)。只有一个文件夹和它的
devcontainer.json、还没有容器时,用户原来要先在终端里跑devcontainer up。第二个提交(ad5ad9a58)把这一步接进窗口:Core #162 的 05c4139 用官方 Dev Container CLI 构建并启动容器,返回容器、容器内用户和工作区文件夹;桌面端随后走同一个容器入口,直接打开那个文件夹。容器也常常跑在远程主机上。Core #162 的
remote.connect已支持container跟在connection或wsl后面(在那台主机上运行同样的exec),remote.listContainers带sessionId时在会话的主机上列出。第三个提交(b78cdf0d7)在已连接主机的文件夹选择页加了“主机上的容器”:列出那台主机上的容器,进入后在容器里选文件夹。改动 / Changes
列表与容器页(新增
remote_container.go;remote.go、remote_list.go、remote_view.go、remote_shell_view.go、remote_detail_view.go)remote.listContainers(本机,docker和podman各一次),整体超时 40 秒;Core 自己给每次ps留了 15 秒。remote_containers_list失败(只有命令名和错误码),另一个引擎的容器照常列出;两个引擎都没有时不显示这一组。窗口关闭或重新打开后,旧的结果不再应用。引擎:完整 ID,所以两个引擎里的同名容器是两行。引擎:[用户@]容器地址、镜像和引擎给出的状态;从 devcontainer.json 打开(新增
remote_devcontainer.go;remote.go、remote_browse.go、remote_shell_view.go、remote_detail_view.go、remote_container.go)remote.devcontainerConfigs和读取本机信任记录;新一次读取会作废旧的结果。devcontainer.json(有name时显示“名称(路径)”),默认选第一个,ⓘ 说明查找顺序;没有配置时说明原因,不能构建。“容器引擎”可选 Docker 或 Podman,ⓘ 说明 Podman 会作为 CLI 的 docker 路径。workspace.trust.grant),再构建。读取信任失败时说明原因,不能构建。remote.devcontainerUp(带projectCodeAllowed)。CLI 的输出(Core 已隐藏敏感信息)经a.post逐行送回界面线程,显示在“构建日志”里,最多保留最近 5000 行;Core 截断输出时在下方说明。ⓘ 说明日志不写入 Lithe 的日志。runtime_missing)时,说明用npm install -g @devcontainers/cli安装;remoteUser作为容器内用户按容器连接,直接打开remoteWorkspaceFolder,不再弹文件夹选择。主机上的容器(新增
remote_host_containers.go;remote_browse.go、remote_browse_view.go、remote_steps.go、remote_view.go、remote_workspace.go、remote.go)remote.listContainers(带sessionId,docker和podman各一次),在远端服务的环境里运行,所以列出来的就是能进入的容器。主机上没有任何引擎命令行时说明没找到 Docker 或 Podman;引擎报错时显示它的原始输出,不写日志;其他失败记remote_host_containers_list(只有命令名和错误码)。remote.connect发送原来的connection(或wsl)加container。步骤与主机相同,OpenSSH 会再问一次它要问的内容;地址显示为“主机 › 引擎:[用户@]容器”。连接(
remote_wsl.go、remote_steps.go、remote_browse.go、remote_workspace.go)remoteHost由 SSH 连接或 WSL 发行版加可选的容器组成,request()带上主机和container(engine、container为容器名、可选user)。overSSH():经 OpenSSH 登录(SSH 连接或 SSH 主机上的容器),决定是否发送 SSH 偏好、显示“读取配置”和“身份验证”;saved():就是一个已保存的 SSH 连接,决定是否提供“编辑连接”、记住打开过的文件夹;hosted():主机上的容器,决定失败说明和“重试”的目标。connectRemoteTo(entry, host, folder),本机容器、主机上的容器和“重试”共用。runtime_missing)时,说明需要安装哪个引擎;标题与状态栏
Core 客户端(
internal/core/remote_session.go、internal/core/remote_devcontainer.go、errors.go、app.go的Kernel接口)RemoteConnectRequest新增Container *ContainerConnection;新增ContainerConnection{Engine, Container, User}与Identity()(与 Core 的会话身份引擎:[用户@]容器一致)、ContainerEngineDocker/ContainerEnginePodman。RemoteListContainers(ctx, engine, sessionID)与RemoteContainers{Available, Containers, Diagnostics}、RemoteContainer{ID, Name, Image, Status}。RemoteDevcontainerConfigs(ctx, folder),返回[]DevcontainerConfig{Path, Name};新增RemoteDevcontainerUp(ctx, request, output),经ExecuteWithEvents运行,把流式输出交给output,返回DevcontainerUp{Container, Diagnostics};Devcontainer{Engine, Container, ContainerID, User, WorkspaceFolder}的Connection()给出remote.connect要的容器参数。errors.go新增错误码常量CodeDevcontainerUntrustedFolder。固定 Core 修订(
scripts/desktop/build-desktop-core.sh)PINNED_CORE_REVISION升到 b92fcaf(Core 【bug】双击Shift唤醒时以及关闭都会有卡顿 #162 分支,已合入 Core mainac80382);【bug】双击Shift唤醒时以及关闭都会有卡顿 #162 合入后改为 Core main。日志
remote.container.select动作;devcontainer 页记remote.devcontainer.open、.choose、.build、.stop,都复用现有的performed。remote.browse.containers、remote.browse.folders、remote.browse.container.enter,失败记remote_host_containers_list。remote_containers_list、remote_devcontainer_choose、remote_devcontainer_configs、remote_devcontainer_up,复用现有的backgroundFailed/operationFailed,错误只带命令和错误码;用户停止构建不记失败。文案、截图、矩阵与 Note
shared/i18n/features/remote-connections.json新增 15 条desktop.remote.container.*中英词条(分组标题、种类、两个引擎名、行副标题、状态、说明、用户栏与 ⓘ、两种字段拒绝、两种失败、“进入容器”),32 条desktop.remote.devcontainer.*(入口、标题、说明、文件夹栏与选择器、配置和引擎及其 ⓘ、未受信任提示、日志、按钮、状态和各种失败),以及主机上的容器的 10 条(desktop.remote.container.hostUnreachable和desktop.remote.hostContainers.*:按钮、标题、说明、列表失败、没有容器、没有引擎、返回、进入、窗口名),并已重新生成。docs/assets/remote-connections/新增四个场景的截图:容器页、进入已停止的容器失败、devcontainer 页(文件夹未受信任)、构建中的 CLI 日志,各有浅色英文和深色中文两版;README 补了说明和表格行。列表工具栏多了“从 devcontainer.json 打开…”按钮,所以已有的远程开发窗口截图也一起重新生成了。第三个提交新增host-containers场景(主机上的容器,选中一个并填写用户),并重新生成了folder(标题栏多了“主机上的容器”)。remote-workspace.json补了容器、devcontainer 和主机上的容器的能力描述、证据、验证动作和说明,删掉了“SSH 主机和 WSL 中的容器入口仍待完成”。.agents/notes/implemented/feature/2026-11-22-remote-local-containers.md:按名字连接、不保存、一个引擎失败不影响另一个、overSSH()的边界、为什么不在桌面端直接运行 docker;devcontainer 一节写了为什么用官方 CLI 而不自己实现规范、为什么构建前必须信任、Lithe 不加挂载、停止不删除容器;第三个提交补了“SSH 主机和 WSL 上的容器”一节:入口为什么放在文件夹选择页、为什么重新连接而不在浏览会话里切换、为什么不保存、为什么失败说明合在一起、主机上为什么不支持 devcontainer up,以及overSSH/saved/hosted的分工和三个被否方案。测试
remote_container_test.go里的 4 个测试:remote_devcontainer_test.go里的 5 个测试:workspace.trust.grant;internal/core新增五个测试:TestRemoteConnectSendsAContainerAloneAndCoreRefusesItByField、TestRemoteListContainersNamesTheSessionAndTheEngine、TestRemoteDevcontainerConfigsListTheFolder、TestRemoteDevcontainerUpRefusesBeforeTheCLIRuns和TestDevcontainerOutputObserverPassesTheCLIsLog。remote_host_containers_test.go里的 3 个测试:remoteHost五种组合(SSH、WSL、本机容器、SSH 上的容器、WSL 上的容器)的hosted/overSSH/saved、请求字段和地址。remote_container_test.go的替身按会话区分本机和主机上的容器,并记录每次连接经过的主机;本机容器的测试断言只在本机连接。testKernel、remoteProbeKernel)默认返回“没有引擎”和“没有 CLI”,打开远程开发窗口的测试不会在开发机上运行真实的docker ps、podman ps或devcontainer up。不在本 PR 范围内 / Out of scope
devcontainer.json构建:devcontainer up只在本机运行,主机上构建需要主机装 CLI 并把文件夹信任扩展到主机,需要单独设计。类型专属:feat
多平台对齐
platform-specific),理由:代码是两端共用的 Viva 桌面代码,进入容器、列出容器、读取配置和运行
devcontainer up都由 Core 执行;macOS 和 Windows 上只要装了 Docker 或 Podman 就会列出容器,装了 Dev Container CLI 就能构建;主机上的容器只依赖主机上的引擎,与本机系统无关。Windows 真机验收待做,矩阵里的验证状态没有提前改成通过。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/remote-workspace.json:补了容器、devcontainer 和主机上的容器的能力描述、证据(两端都有remote_container.go、remote_host_containers.go、remote_devcontainer.go和core/remote_devcontainer.go,macOS 还有对应测试)、验证动作和说明;真实引擎、CLI 与 Windows 验收写明待完成./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(validated 221 platform capabilities)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(matrix change gate passed).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空remoteHostKernel、remoteHostContainers和 devcontainer 测试里的内核替身),不涉及任何插件shared/i18n/;没有写插件的构建步骤或资源路径UI 验证 / UI evidence
已运行受影响场景的 Viva 无头测试,并检查了生成的截图。命令是
LITHE_VISUAL_OUTPUT_DIR=… scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualRemoteConnections$' -count=1,第三个提交 b78cdf0 上重新运行。新增五个场景:host-containers:已连接的 Build box 上的三个容器(两个 Docker、一个 Podman),选中 api-server,用户 app;container:Docker 的 web-frontend,用户 node;container-failed:Podman 的 pg-main 已停止,日志面板展开;devcontainer:文件夹未受信任,按钮为“信任并构建”;devcontainer-building:构建中,显示 CLI 日志和“停止”。每个场景都有浅色英文和深色中文两版,尺寸与已有截图相同。工具栏多了一个按钮,所以已有的远程开发窗口截图也一起重新生成,除了这个按钮没有其他变化。英文说明第一版超过三行被截断,缩短文案后重新截了图。第三个提交的
folder截图标题栏多了“主机上的容器”,其他已有截图逐字节不变。第一次截host-containers时行没有选中、标题仍是“选择文件夹”:列表只能在画过的行里选中,场景改为先画一帧再选;行加了选中高亮;标题改为“选择 某主机 上的容器”。已在本 PR 嵌入截图(见下方)
截图覆盖了明暗主题和中英文,以及正常、失败和构建中三种状态。这些是新加的页面,没有改动前的版本可以对照。目标平台原生窗口验收待做。
主机上的容器(选中一个、填写容器内用户)
选择远程文件夹(标题栏多了“主机上的容器”)
容器页(填写容器内用户)
进入已停止的容器失败(步骤从“进入容器”开始,没有 SSH 提示和“编辑连接”)
从 devcontainer.json 打开:文件夹未受信任(按钮为“信任并构建”)
从 devcontainer.json 打开:构建中的 CLI 日志(列表、配置和引擎锁定,底部为“停止”)
统一日志系统 / Structured logging
performed(remote.container.select、remote.devcontainer.open/choose/build/stop、remote.browse.containers/folders、remote.browse.container.enter),失败走现有的backgroundFailed/operationFailed(remote_containers_list、remote_host_containers_list、remote_devcontainer_choose/configs/up);窗口关闭或构建取消后不再应用结果的提前返回带log-exempt说明;没有print或直接写 stderrTestRemoteHostContainersOpenAFolderInAContainerOnTheHostTestRemoteContainerOpensAFolderInAContainerTestRemoteContainersKeepTheOtherEngineWhenOneFailsTestRemoteDevcontainerBuildsAndOpensTheWorkspaceFolderTestRemoteDevcontainerFailuresAreExplainedTestRemoteDevcontainerStopKeepsTheLog界面文案 / i18n
shared/i18n/features/remote-connections.json补了 57 条中英词条(15 条容器、32 条 devcontainer、10 条主机上的容器,带占位符的都声明了parameters),运行了node scripts/i18n/generate-i18n.mjsnode scripts/i18n/verify-app-language-localization.mjs(passed)和node scripts/i18n/generate-i18n.mjs --check(en-US、zh-CN 都是 12422/12422)逻辑归属 / Logic placement
以下逻辑都在 Core 【bug】双击Shift唤醒时以及关闭都会有卡顿 #162(
crates/remote、crates/workspace):exec的参数与转义、字段校验、权限边界(S32)和会话身份,包括在 SSH 主机和 WSL 上列出和进入容器、信任键包含主机与容器;devcontainer.json的查找顺序、CLI 参数、输出脱敏与截断、超时和信任检查。桌面端只负责调用、呈现,以及把 Core 拒绝的字段和错误码对应到文案。
[N/A] 没有修改平台层已有的可共享逻辑
没有按工具名加分支;Docker、Podman 和 Dev Container CLI 是 Core 远程连接的方式,不是插件提供的工具
性能与内存 / Performance and memory
docker ps、docker exec、devcontainer up由 Core 在后台调用;主机上的ps经已有的浏览会话运行,不另开连接设置 / Settings
N/A:没有新增或修改设置项。容器内用户栏(本机和主机上的容器)只对这一次连接生效,不保存;devcontainer 页的文件夹、配置和引擎也只对这一次构建生效。
插件契约 / Plugin contract
N/A:只依赖 Core 的远程 API(
remote.connect、remote.listContainers、remote.devcontainerConfigs、remote.devcontainerUp),不涉及插件契约、能力版本或宿主方法。PINNED_CORE_REVISION已升到 b92fcaf。发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh(passed)无用代码与重构 / Dead code and refactoring
host.wsl == nil判断都改用overSSH();第三个提交把overSSH()原来兼管的“已保存连接”拆成saved(),connectRemote改为共用的connectRemoteTo验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/workbench/ ./internal/core/ ./internal/remoteplaceholder/ -count=1scripts/desktop/desktop-go.sh test ./internal/workbench/ -run 'TestRemoteHost|TestRemoteContainer|TestRemoteDevcontainer' -count=1scripts/desktop/desktop-go.sh vet ./internal/core/ ./internal/workbench/、scripts/desktop/desktop-go.sh build ./...gofmt -l desktop/internal/{core,workbench}TestVisualRemoteConnections(vivahead,lithevisual)node scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/agent-notes/verify-agent-notes.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.shrg未能执行的检查和原因: 还没有用真实的 Docker、Podman 和 Dev Container CLI 做整机验收,也没在 Windows 上运行。本机测试用的是 Core 替身,不运行真实引擎和 CLI,所以下面这些都没有验证:
docker ps列表和exec进入;sh);devcontainer up的输出、features 构建和 compose 配置;docker ps/podman ps与exec(含 OpenSSH 再次询问),以及 Windows WSL 发行版里的容器。提交前确认 / Final checks
main(994b67331)创建,目标分支main