diff --git a/.agents/notes/implemented/feature/2026-11-22-remote-workspace-git-worktrees.md b/.agents/notes/implemented/feature/2026-11-22-remote-workspace-git-worktrees.md new file mode 100644 index 000000000..0d5f73644 --- /dev/null +++ b/.agents/notes/implemented/feature/2026-11-22-remote-workspace-git-worktrees.md @@ -0,0 +1,61 @@ +# Agent 笔记:远程工作区里打开和新建 Git 工作树 + +状态:已实现 + +## 先说结论 + +受信任的远程工作区里,Git 工具窗口“工作树”页签的打开和新建不再被拒绝。打开工作树就是打开主机上的另一个文件夹:Lithe 用打开这个工作区所用的连接(或 WSL 发行版)再连一次,在本窗口的新标签页里经一个新会话打开它;已有标签页通过活着的会话打开着它时,直接切过去,不再连接。新建对话框显示和接收主机路径,Core 的“放在仓库旁边”的建议也以主机路径显示,创建由主机上的 Git 完成。“在新窗口打开”和“在文件浏览器中显示”仍然拒绝:新客户端只打开本机文件夹(#2231 S10),文件夹也不在本机。 + +## 问题 + +工作树列表、锁定、解锁、删除在 #2283 已经走主机,但打开和新建被拒绝,原因有三: + +- 工作树是主机上的另一个文件夹,打开它需要一个绑定到那个文件夹的会话;远程工作区的会话只绑定一个主机根目录(`RemoteWorkspace` 的 RemoteRoot),不能拿来打开别的文件夹。 +- 新建对话框的建议路径由 Core 的 `git.worktreePreview` 按仓库路径推算。远程工作区的仓库路径是本机占位路径,建议出来的也是本机占位目录旁的路径,Core 再把它映射回主机时会落到错误的位置,Windows 上还会被当成本机路径。 +- 用户在对话框里输入的是主机路径(POSIX),在 Windows 客户端上不是绝对路径,Core 会以“不是绝对路径”拒绝。 + +## 决策 + +### 打开工作树 = 用同一个连接打开另一个主机文件夹 + +- `openWorktree` 在远程工作区里改走 `openRemoteWorktree`:把列表里的占位路径换回主机路径(`remoteplaceholder.HostPath`),再交给 `openRemoteHostFolder`。换不回来说明列表过期,记为拒绝(`not_host_path`)并重新读取列表。 +- `openRemoteHostFolder` 先按占位根 `Root(anchor, connectionID, folder)` 查找已有标签页,会话还活着就切过去。否则打开“远程开发”窗口并记下 `remoteReopen`(连接 ID 或 WSL 发行版与用户、主机文件夹);窗口读完已保存的连接后,`connectRemoteReopen` 选中同一个连接,像用户点“连接”一样连接,并直接打开这个文件夹。连接步骤、OpenSSH 的提问、从未决定过的文件夹的信任询问都和手动打开一样出现在窗口里。 +- 连接已经在工作区打开之后被删除时,窗口说明原因(`desktop.remote.worktree.connectionRemoved`),记为拒绝(`connection_removed`),不连接。 +- 新建对话框的“创建后打开”沿用同一条路径。 + +### 对话框里的主机路径都用“占位目录旁”的路径发给 Core + +- `remoteplaceholder.HostNamedPath(root, host)` 把任何主机绝对路径映射为占位根旁 `.lithe-remote-host` 下的本机路径,Core 收到后按工作区绑定映射回主机。对话框发给 Core 的仓库路径、目标路径和上一次建议都用它(`worktreeHostNamed`),所以 Core 按“仓库路径”推出的建议也在 `.lithe-remote-host` 下,显示前再换回主机路径(`worktreeShown`)。Core 的建议规则和路径映射规则都不用改。 +- 这样 Windows 和 WSL 上的主机路径也是本机绝对路径,不会被 Core 当作相对路径拒绝。 +- 对话框在输入框下说明路径是主机上的文件夹(`desktop.remote.worktree.destination`)。 + +### 日志 + +只记 `git.worktree.open`、`remote.connect` 等动作和 `git_worktree_open` 的拒绝原因,不记主机、连接名、主机路径或用户输入的路径。 + +## 考虑过的备选方案 + +- **在当前会话里切换主机根目录**:一个窗口里同时会有两个文件夹的请求,绑定的 RemoteRoot 要随请求变化,监听、索引和信任都按根目录缓存,改动面大且容易串。没有采用;每个文件夹一个会话,和手动打开完全相同。 +- **不经过连接窗口,后台直接连接**:OpenSSH 的提问、连接步骤和信任询问都在连接窗口里,后台连接要么另做一套界面,要么吞掉提问。没有采用。 +- **让 Core 接收原始主机路径**:要给 `git.worktreePreview`、`git.createWorktree` 加一个“这是主机路径”的字段,且 Core 现有的路径映射只认本机路径。`HostNamedPath` 复用已有映射,不改协议。 +- **在新窗口打开远程工作树**:新客户端只接受本机文件夹(S10),要支持就得把连接和会话交给另一个进程。保持拒绝。 + +## 后果 + +- 收益:远程工作树和本机工作树的操作基本一致;不改 Core 协议;Windows 和 WSL 的路径问题一并解决。 +- 代价:每打开一个工作树多一个 SSH 会话(同一连接复用 OpenSSH 的设置,但不复用会话);打开时会出现连接窗口。 +- 未完成:远程 Git 的 AskPass 转交(推送、拉取时的凭据询问);“在新窗口打开”仍拒绝。 + +## 验证 + +- `desktop/internal/workbench/remote_worktree_test.go`:工作树在新标签页经自己的会话打开,再次打开时切到已有标签页;不是主机路径的条目和已删除的连接都被拒绝并说明;新建对话框建议并接收主机路径,创建请求在工作区会话上发送 `HostNamedPath` 路径并选中新工作树;日志不含主机和路径。 +- `desktop/internal/remoteplaceholder/remoteplaceholder_test.go` 的 `TestHostNamedPathNamesEveryHostPathBelowTheSibling`。 +- `desktop/internal/workbench/remote_worktree_visual_test.go` 生成 `docs/assets/remote-worktrees/` 下的截图。 + +```bash +cd desktop && ../scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/remoteplaceholder -run 'TestRemoteWorktree|TestHostNamed' -count=1 +``` + +## 适用范围 + +`desktop/internal/workbench/remote_worktree.go`、`gitworktree.go` 中远程分支、`remote.go` 的 `reopen`、`desktop/internal/remoteplaceholder/`。以后其他“打开主机上另一个文件夹”的入口(例如 Dev Container 里的文件夹)都走 `openRemoteHostFolder`,不要另起连接流程。 diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index d60bf62fe..acdaa4802 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -2049,6 +2049,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.workspace.localOnly": "This feature does not work in a remote workspace yet. You can browse, edit, save and search the host's files, run terminals and use Git on the host.", "desktop.remote.workspace.safeBanner": "This remote workspace is in safe mode: you can browse, edit, save and search its files on the host. Trust the folder to use Git.", "desktop.remote.workspace.title": "{folder} [{kind}: {connection}]", + "desktop.remote.worktree.connectionRemoved": "The connection this workspace was opened over was deleted, so its worktree cannot be opened. Add the connection again, then open the worktree.", + "desktop.remote.worktree.destination": "The path is a folder on the host, created by Git there.", "desktop.remote.wsl.about": "Opens through wsl.exe on this computer, as the Linux user below. Nothing about the distribution is saved: the folders opened in it are not remembered, and the list is read again each time this window opens.", "desktop.remote.wsl.distributionInvalid": "wsl.exe does not accept this distribution name.", "desktop.remote.wsl.heading": "WSL", @@ -5938,6 +5940,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.workspace.localOnly": "远程工作区暂不支持此功能,可以浏览、编辑、保存和搜索主机上的文件,也可以在主机上运行终端和使用 Git。", "desktop.remote.workspace.safeBanner": "此远程工作区处于安全模式:可以浏览、编辑、保存和搜索主机上的文件。信任此文件夹后即可使用 Git。", "desktop.remote.workspace.title": "{folder} [{kind}: {connection}]", + "desktop.remote.worktree.connectionRemoved": "打开此工作区所用的连接已被删除,无法打开它的工作树。请重新添加该连接后再打开工作树。", + "desktop.remote.worktree.destination": "路径是主机上的文件夹,由主机上的 Git 创建。", "desktop.remote.wsl.about": "通过本机的 wsl.exe 打开,以下方的 Linux 用户运行。不保存这个发行版的任何信息:不记住在其中打开过的文件夹,每次打开本窗口时重新读取列表。", "desktop.remote.wsl.distributionInvalid": "wsl.exe 不接受这个发行版名称。", "desktop.remote.wsl.heading": "WSL", diff --git a/desktop/internal/remoteplaceholder/remoteplaceholder.go b/desktop/internal/remoteplaceholder/remoteplaceholder.go index 7415e7f06..1256beacc 100644 --- a/desktop/internal/remoteplaceholder/remoteplaceholder.go +++ b/desktop/internal/remoteplaceholder/remoteplaceholder.go @@ -172,10 +172,27 @@ func LocalPath(root, remoteRoot, host string) (string, bool) { if host == remote { return root, true } - base, suffix := root+HostSuffix, strings.TrimPrefix(host, "/") if rest, ok := strings.CutPrefix(host, strings.TrimSuffix(remote, "/")+"/"); ok { - base, suffix = root, rest + return joinLocal(root, rest) } + return HostNamedPath(root, host) +} + +// HostNamedPath is the path below root's sibling (HostSuffix) that names host, an absolute host +// path, whether or not host lies in the workspace's folder. Core maps it to host as it maps every +// path of the sibling, and so maps the paths Core derives beside it, such as the folder it suggests +// for a new worktree next to the repository, to the host paths beside host. ok is false as for +// LocalPath. +func HostNamedPath(root, host string) (string, bool) { + if !path.IsAbs(host) { + return "", false + } + return joinLocal(root+HostSuffix, strings.TrimPrefix(path.Clean(host), "/")) +} + +// joinLocal is base with the slash-separated suffix below it as a local path; ok is false on +// Windows for a name of suffix holding "\", which would name another path there. +func joinLocal(base, suffix string) (string, bool) { if suffix == "" { return base, true } diff --git a/desktop/internal/remoteplaceholder/remoteplaceholder_test.go b/desktop/internal/remoteplaceholder/remoteplaceholder_test.go index a7bdf7c87..b1ed85b96 100644 --- a/desktop/internal/remoteplaceholder/remoteplaceholder_test.go +++ b/desktop/internal/remoteplaceholder/remoteplaceholder_test.go @@ -3,6 +3,7 @@ package remoteplaceholder import ( "errors" "os" + "path" "path/filepath" "runtime" "strings" @@ -146,3 +147,30 @@ func TestHostAndLocalPathsMapBothWays(t *testing.T) { } } } + +// HostNamedPath names every absolute host path below the root's sibling, the workspace's own +// folder too, so that a path beside it is a host path again, and HostPath undoes it. +func TestHostNamedPathNamesEveryHostPathBelowTheSibling(t *testing.T) { + anchor := filepath.Join(string(filepath.Separator)+"cache", AnchorName) + root := Root(anchor, "c1", "/srv/repo") + sibling := root + HostSuffix + for _, tc := range []struct{ host, local string }{ + {"/srv/repo", filepath.Join(sibling, "srv", "repo")}, + {"/srv/repo/sub/", filepath.Join(sibling, "srv", "repo", "sub")}, + {"/srv/repo-feature", filepath.Join(sibling, "srv", "repo-feature")}, + {"/", sibling}, + } { + local, ok := HostNamedPath(root, tc.host) + if !ok || local != tc.local { + t.Errorf("HostNamedPath(%q) = %q, %v; want %q", tc.host, local, ok, tc.local) + } + if host, ok := HostPath(root, "/srv/repo", local); !ok || host != path.Clean(tc.host) { + t.Errorf("HostPath(HostNamedPath(%q)) = %q, %v", tc.host, host, ok) + } + } + for _, host := range []string{"", "relative/path"} { + if local, ok := HostNamedPath(root, host); ok { + t.Errorf("HostNamedPath(%q) = %q; want no local path", host, local) + } + } +} diff --git a/desktop/internal/workbench/gitworktree.go b/desktop/internal/workbench/gitworktree.go index 5fe582999..8824ad62a 100644 --- a/desktop/internal/workbench/gitworktree.go +++ b/desktop/internal/workbench/gitworktree.go @@ -3,11 +3,13 @@ package workbench import ( "context" "errors" + "path" "path/filepath" "strings" "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteplaceholder" "github.com/vivaui/viva/app" "github.com/vivaui/viva/ui" ) @@ -820,25 +822,22 @@ func (a *App) showWorktrees() { } } -// openWorktree opens the checkout at path as the window's project. +// openWorktree opens the checkout at path as the window's project. A remote workspace's checkout +// is a host folder, which opens over a session of its own in a tab of this window +// (openRemoteWorktree). func (a *App) openWorktree(path string) { - // A remote workspace's checkout opens over a session of its own, which this window does not - // start yet; its placeholder would open as an empty local folder. - if a.refuseRemote(a.project, "git_worktree_open") { + a.performed("git.worktree.open", surfaceButton) + if p := a.project; p != nil && p.remote != nil { + a.openRemoteWorktree(p, path) return } - a.performed("git.worktree.open", surfaceButton) // The worktree menu offers This Window and New Window itself. a.openProjectThisWindow(path) } // beginCreateWorktree opens the dialog that creates a worktree and reads the references it -// can start from. +// can start from. In a remote workspace the dialog chooses a folder on the host. func (a *App) beginCreateWorktree(p *project) { - // The dialog chooses the new checkout's folder on this computer. - if a.refuseRemote(p, "git_worktree_create") { - return - } a.performed("git.worktree.create", surfaceButton) w := &p.worktrees cr := &w.create @@ -877,16 +876,19 @@ func (a *App) syncWorktreeCreation(p *project) { // previewWorktreeCreation has Core derive the dialog's values from its inputs and applies // them; require makes an empty branch name an error, as a submit does. It reports whether Core -// answered; without an answer the dialog cannot create the worktree. +// answered; without an answer the dialog cannot create the worktree. Core derives them from the +// paths alone, so a remote workspace sends its paths as host-named ones (worktreeHostNamed) and +// shows the answer's as host paths. func (a *App) previewWorktreeCreation(p *project, require bool) bool { w := &p.worktrees cr := &w.create ctx, cancel := context.WithTimeout(a.operationContext(context.Background()), kernelCallTimeout) defer cancel() + destination := p.worktreeHostNamed(cr.destination.Text()) result, err := a.kernel.GitWorktreeCreationPreview(ctx, core.GitWorktreeCreationInput{ - Root: p.git.repositoryRoot(p.root), Mode: cr.mode, Kind: cr.kind, Reference: cr.reference, + Root: p.worktreeHostNamed(p.remoteHostPath(p.git.repositoryRoot(p.root))), Mode: cr.mode, Kind: cr.kind, Reference: cr.reference, Name: cr.name.Text(), RequireName: require, Revision: cr.revision.Text(), - Destination: cr.destination.Text(), LastSuggestion: cr.suggested, + Destination: destination, LastSuggestion: p.worktreeHostNamed(cr.suggested), References: cr.refs.References, CheckedOutBranches: checkedOutBranches(w.list), }) if err != nil { @@ -905,10 +907,11 @@ func (a *App) previewWorktreeCreation(p *project, require bool) bool { if b := result.Branch; b != nil && b.TypingCleanedName != cr.name.Text() { cr.name.SetText(b.TypingCleanedName) } - if result.Destination != cr.destination.Text() { - cr.destination.SetText(result.Destination) + // A destination the user typed comes back as it was sent and stays as typed. + if result.Destination != destination { + cr.destination.SetText(p.worktreeShown(result.Destination)) } - cr.suggested = result.SuggestedDestination + cr.suggested = p.worktreeShown(result.SuggestedDestination) cr.key = cr.inputs(w.gen) return true } @@ -920,12 +923,20 @@ func (a *App) submitCreateWorktree(p *project) { if p.worktrees.busy || !cr.result.Ready || !a.previewWorktreeCreation(p, true) || !cr.result.Ready { return } + typed := strings.TrimSpace(cr.destination.Text()) creation := core.GitWorktreeCreation{ Mode: cr.mode, - Destination: filepath.Clean(strings.TrimSpace(cr.destination.Text())), + Destination: filepath.Clean(typed), NoCheckout: cr.noCheckout, } name := filepath.Base(creation.Destination) + // host is the new checkout's host folder in a remote workspace, which Core is sent as the + // path that names it. + var host string + if p.remote != nil { + host = path.Clean(typed) + creation.Destination, name = p.worktreeHostNamed(host), path.Base(host) + } if b := cr.result.Branch; cr.mode == core.GitWorktreeNewBranch && b != nil { creation.Name, name = b.CleanedName, b.CleanedName } @@ -944,6 +955,17 @@ func (a *App) submitCreateWorktree(p *project) { return kernel.GitCreateWorktree(ctx, root, creation) }, nil, func(a *App) { a.notifySuccess(a.text.Worktrees.Created(name)) + if p.remote != nil { + // The list names a host checkout by the path Core maps it to: below the root for one + // in the workspace's folder, below the root's sibling otherwise. + if local, ok := remoteplaceholder.LocalPath(p.root, p.remote.binding.RemoteRoot(), host); ok { + p.worktrees.selected = local + } + if openAfter { + a.openRemoteHostFolder(p, host) + } + return + } // Git lists the checkout by its canonical path, which differs from the typed one under // a symbolic link. selected := creation.Destination diff --git a/desktop/internal/workbench/gitworktree_view.go b/desktop/internal/workbench/gitworktree_view.go index 3524e7fe1..bc2d9ee07 100644 --- a/desktop/internal/workbench/gitworktree_view.go +++ b/desktop/internal/workbench/gitworktree_view.go @@ -55,7 +55,8 @@ func (a *App) worktreePageView(c ui.C) { }) } -// shownWorktrees are the worktrees whose path or branch holds the search's text. +// shownWorktrees are the worktrees whose path or branch holds the search's text: in a remote +// workspace, the host path. func (a *App) shownWorktrees(p *project) []core.GitWorktree { query := strings.ToLower(strings.TrimSpace(a.worktreeView.search.Text())) if query == "" { @@ -63,7 +64,7 @@ func (a *App) shownWorktrees(p *project) []core.GitWorktree { } var shown []core.GitWorktree for _, w := range p.worktrees.list { - if strings.Contains(strings.ToLower(w.Path), query) || strings.Contains(strings.ToLower(w.Branch), query) { + if strings.Contains(strings.ToLower(p.remoteHostPath(w.Path)), query) || strings.Contains(strings.ToLower(w.Branch), query) { shown = append(shown, w) } } @@ -78,7 +79,7 @@ func (a *App) drawWorktreeList(c ui.C, p *project) ui.Box { return ui.Column(c).FillHeight().Background(a.colors.Panel).Clip().Children(func() { ui.Row(c).Height(logToolbarHeight).Shrink(0).Items(ui.Center).Gap(4).PadX(6).Children(func() { ui.TextField(c, &v.search, t.Search, t.Search).Grow(1).MinWidth(0) - if a.gitIconButton(c, t.New, icons.Plus, false, w.busy || !w.loaded || p.remote != nil) { + if a.gitIconButton(c, t.New, icons.Plus, false, w.busy || !w.loaded) { c.After(func() { a.beginCreateWorktree(p) }) } if a.gitIconButton(c, t.Refresh, icons.RefreshCw, false, w.loading) { @@ -162,7 +163,7 @@ func (a *App) drawWorktreeRow(p *project, shown []core.GitWorktree, row ui.ListR return } w, c := shown[row.Index], row.C - item := row.Element.FillWidth().PadX(10).PadY(5).Gap(8).Items(ui.Center).Tooltip(w.Path) + item := row.Element.FillWidth().PadX(10).PadY(5).Gap(8).Items(ui.Center).Tooltip(p.remoteHostPath(w.Path)) if w.Path == p.worktrees.selected { item = item.Background(a.colors.Selection) } else { @@ -197,8 +198,8 @@ func (a *App) worktreeRowMenu(row ui.ListRow, p *project, w core.GitWorktree) { } ui.ContextMenu(c, row.Element, func(menu *ui.MenuItems) { ws, t := &p.worktrees, &a.text.Worktrees - // A remote workspace's worktrees are host folders: this window neither opens them nor shows - // them in the file browser yet. + // A remote workspace's worktrees are host folders: a new client opens local folders only, and + // the file browser shows this computer's. remote := p.remote != nil menu.WidthRange(180, 260) item := func(label string, disabled bool, action string, run func()) { @@ -209,7 +210,7 @@ func (a *App) worktreeRowMenu(row ui.ListRow, p *project, w core.GitWorktree) { }) } } - item(t.OpenCurrent, remote || w.IsCurrent || w.IsPrunable || w.IsBare, "git.worktree.open", func() { a.openWorktree(w.Path) }) + item(t.OpenCurrent, w.IsCurrent || w.IsPrunable || w.IsBare, "git.worktree.open", func() { a.openWorktree(w.Path) }) item(i18n.Shared(a.language(), "desktop.worktree.openNewWindow"), remote || w.IsPrunable || w.IsBare, "git.worktree.openNewWindow", func() { a.openWorktreeInNewWindow(w.Path) }) item(t.Reveal, remote || w.IsPrunable, "git.worktree.reveal", func() { a.revealWorktree(w.Path) }) item(t.CopyPath, false, "git.worktree.copyPath", func() { a.copyWorktreePath(w.Path) }) @@ -311,7 +312,7 @@ func (a *App) drawWorktreeOverview(c ui.C, p *project, w core.GitWorktree) { status := ws.statusOf(w) ui.Scroll(c).Scrollbars().Grow(1).FillWidth().Pad(shellContentPad).Gap(12).Children(func() { a.worktreeCard(c, t.BasicInformation, func() { - a.worktreeField(c, t.Path, w.Path) + a.worktreeField(c, t.Path, p.remoteHostPath(w.Path)) a.worktreeField(c, t.Branch, a.worktreeBranchText(w)) head := w.Head if len(head) > 12 { @@ -386,7 +387,7 @@ func (a *App) drawWorktreeActions(c ui.C, p *project, w core.GitWorktree) { c.After(run) } } - action(t.OpenCurrent, "", icons.FolderOpen, remote || w.IsCurrent || w.IsPrunable || w.IsBare, func() { a.openWorktree(w.Path) }) + action(t.OpenCurrent, "", icons.FolderOpen, w.IsCurrent || w.IsPrunable || w.IsBare, func() { a.openWorktree(w.Path) }) action(i18n.Shared(a.language(), "desktop.worktree.openNewWindow"), "", icons.FolderOpen, remote || w.IsPrunable || w.IsBare, func() { a.openWorktreeInNewWindow(w.Path) }) action(t.Reveal, "", icons.Folder, remote || w.IsPrunable, func() { a.revealWorktree(w.Path) }) action(t.CopyPath, "", icons.Copy, false, func() { a.copyWorktreePath(w.Path) }) @@ -810,6 +811,8 @@ func (a *App) drawWorktreeCreateDialog(c ui.C, p *project) { submitted = ui.TextField(c, &cr.destination, t.Destination, t.Destination).FillWidth().Submitted() || submitted if !cr.result.DestinationIsAbsolute { ui.Paragraph(c, t.DestinationAbsolute, 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger) + } else if p.remote != nil { + ui.Paragraph(c, i18n.Shared(a.language(), "desktop.remote.worktree.destination"), 3).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) } ui.Checkbox(c, &cr.noCheckout, t.NoCheckout).Disabled(w.busy) if cr.noCheckout { diff --git a/desktop/internal/workbench/remote.go b/desktop/internal/workbench/remote.go index 83b9f92cf..b9bb61e42 100644 --- a/desktop/internal/workbench/remote.go +++ b/desktop/internal/workbench/remote.go @@ -69,6 +69,9 @@ type remoteState struct { // shown as result. browser chooses the host folder to open over the session it opened. connect *remoteProbe browser *remoteBrowser + // reopen is the host folder the window connects to and opens once the saved list is read, nil + // when it opened for the user to choose (remote_worktree.go). + reopen *remoteReopen // probed is what the last test of each connection found, by the connection as Core stores // it, so that a saved connection's overview shows its host again after the form was saved // or the window reopened. It lives in memory while the app runs, outlives the window and @@ -208,7 +211,7 @@ func (a *App) closeRemote() { a.leaveRemoteTrust() a.leaveRemoteDevcontainer() r.generation++ - r.open, r.saving, r.loading = false, false, false + r.open, r.saving, r.loading, r.reopen = false, false, false, nil r.form = remoteForm{} } @@ -256,6 +259,11 @@ func (a *App) loadRemote(how remoteLoad, id string) { } r.selectFirst() default: + if reopen := r.reopen; reopen != nil { + r.reopen = nil + a.connectRemoteReopen(reopen) + return + } r.selectFirst() } } diff --git a/desktop/internal/workbench/remote_git_test.go b/desktop/internal/workbench/remote_git_test.go index 0dbaf9b71..e01a36f4a 100644 --- a/desktop/internal/workbench/remote_git_test.go +++ b/desktop/internal/workbench/remote_git_test.go @@ -31,6 +31,11 @@ type remoteHostGit struct { blamed []string // created are the host folders created. created []string + // references are the host repository's references; worktrees are its linked worktrees' host + // folders, and creations the worktrees Core was asked to create (remote_worktree_test.go). + references core.GitReferences + worktrees []string + creations []remoteWorktreeCreation } // remoteTrustStorage is the preference file the trust decisions are kept in. @@ -160,7 +165,20 @@ func (k *remoteHostKernel) GitOperationState(ctx context.Context, root string) ( func (k *remoteHostKernel) GitReferences(ctx context.Context, root string) (core.GitReferences, error) { return onHost(ctx, k, "git.references", func() (core.GitReferences, error) { return k.Client.GitReferences(ctx, root) }, - func(string) (core.GitReferences, error) { return core.GitReferences{}, nil }) + func(string) (core.GitReferences, error) { + k.mu.Lock() + defer k.mu.Unlock() + return k.git.references, nil + }) +} + +// GitReferenceTree groups the host's references as Core does: its handler computes from the +// names alone, so the tree is the one this computer's Core builds. +func (k *remoteHostKernel) GitReferenceTree(ctx context.Context, names []string, prioritized map[string]bool) ([]core.ReferenceTreeNode, error) { + return onHost(ctx, k, "git.referenceTree", func() ([]core.ReferenceTreeNode, error) { return k.Client.GitReferenceTree(ctx, names, prioritized) }, + func(string) ([]core.ReferenceTreeNode, error) { + return k.Client.GitReferenceTree(context.Background(), names, prioritized) + }) } func (k *remoteHostKernel) GitHistoryPage(ctx context.Context, root, reference, cursor string, limit, maxCommits int) (core.GitHistoryPage, error) { diff --git a/desktop/internal/workbench/remote_worktree.go b/desktop/internal/workbench/remote_worktree.go new file mode 100644 index 000000000..8e0ea4782 --- /dev/null +++ b/desktop/internal/workbench/remote_worktree.go @@ -0,0 +1,125 @@ +package workbench + +import ( + "path" + "path/filepath" + "strings" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteplaceholder" +) + +// A remote workspace's Git worktrees are host folders, which Core lists, creates and removes over +// the workspace's session as it does for its other Git work. Opening one is opening another host +// folder: the connection window opens, connects again over the connection the workspace was opened +// over, showing its steps and the questions OpenSSH asks, asks whether to trust the folder when +// that was never decided, and opens it in a tab of this window over a session of its own. A +// worktree already open in a tab with a live session is shown instead. Opening one in a new window +// and showing one in the system's file browser stay refused: a new client opens local folders only +// (#2231 S10), and the folder is not on this computer. +// +// The create dialog shows and takes host paths. Core derives its suggestion beside the repository +// from the repository's path alone, so the dialog sends every path as the path below the root's +// sibling that names it (remoteplaceholder.HostNamedPath): the suggestion then lies below the +// sibling too, which Core maps to the host for the creation. Nothing of a worktree's path or of the +// host is logged. + +// remoteReopen is a host folder the connection window connects to and opens once it has read its +// saved list: a worktree of a remote workspace, over the connection the workspace was opened over. +type remoteReopen struct { + // connectionID is the saved connection, or the WSL distribution's identity when wsl is set. + connectionID string + wsl *core.WSLConnection + // folder is the host folder, an absolute POSIX path. + folder string +} + +// openRemoteWorktree opens the worktree whose path in the workspace p is local, a path Core named +// in the list of worktrees. +func (a *App) openRemoteWorktree(p *project, local string) { + folder, ok := remoteplaceholder.HostPath(p.root, p.remote.binding.RemoteRoot(), local) + if !ok { + // Core names every worktree below the root or its sibling, so this list is stale. + a.operationRejected("git_worktree_open", "not_host_path") + a.loadWorktrees(p) + return + } + a.openRemoteHostFolder(p, folder) +} + +// openRemoteHostFolder opens the host folder over the connection the remote workspace p was opened +// over: the tab that has it open over a live session, or the connection window, which connects and +// opens it. +func (a *App) openRemoteHostFolder(p *project, folder string) { + r := p.remote + // The workspace's root is anchor// (remoteplaceholder.Root). + anchor := filepath.Dir(filepath.Dir(p.root)) + if open := a.sessions.showing(remoteplaceholder.Root(anchor, r.connectionID, folder)); open != nil { + if or := open.project.remote; or != nil && !or.closed && or.session != "" { + a.sessions.activate(open) + return + } + } + if a.remote.open { + // log-exempt: 连接窗口是模态窗口,打开时用户点不到工作树;这里只防重复打开。 + return + } + reopen := &remoteReopen{connectionID: r.connectionID, folder: folder} + if r.host.wsl != nil { + wsl := *r.host.wsl + reopen.wsl = &wsl + } + a.openRemote(surfaceButton) + a.remote.reopen = reopen +} + +// connectRemoteReopen connects the window to reopen's host, as Connect on its page does, and opens +// its folder. A saved connection deleted since the workspace opened is said so on the page the +// window shows instead. +func (a *App) connectRemoteReopen(reopen *remoteReopen) { + r := &a.remote + switch { + case reopen.wsl != nil: + r.selectRemoteWSL(reopen.wsl.Distribution) + r.wsl.user.SetText(reopen.wsl.User) + case r.entry(reopen.connectionID) != nil: + r.selectEntry(reopen.connectionID) + default: + r.selectFirst() + a.operationRejected("git_worktree_open", "connection_removed") + if r.readErr == "" { + r.err = i18n.Shared(a.language(), "desktop.remote.worktree.connectionRemoved") + } + return + } + a.connectRemote(reopen.folder) +} + +// worktreeHostNamed is text, a path the create dialog shows, as Core is sent it: in a remote +// workspace, a host path absolute once trimmed as the path that names it +// (remoteplaceholder.HostNamedPath); anything else as it is, which Core finds not absolute. A local +// project's paths are sent as they are. +func (p *project) worktreeHostNamed(text string) string { + if p.remote == nil { + return text + } + if host := strings.TrimSpace(text); path.IsAbs(host) { + if local, ok := remoteplaceholder.HostNamedPath(p.root, host); ok { + return local + } + } + return text +} + +// worktreeShown is local, a path Core answered to the create dialog, as the dialog shows it: its +// host path in a remote workspace, and local itself for any other. +func (p *project) worktreeShown(local string) string { + if p.remote == nil { + return local + } + if host, ok := remoteplaceholder.HostPath(p.root, p.remote.binding.RemoteRoot(), local); ok { + return host + } + return local +} diff --git a/desktop/internal/workbench/remote_worktree_test.go b/desktop/internal/workbench/remote_worktree_test.go new file mode 100644 index 000000000..0fcbe9253 --- /dev/null +++ b/desktop/internal/workbench/remote_worktree_test.go @@ -0,0 +1,231 @@ +package workbench + +import ( + "context" + "path/filepath" + "slices" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteplaceholder" +) + +// remoteTestFeature is the host folder of the host repository's linked worktree. +const remoteTestFeature = remoteTestHome + "/project-feature" + +// remoteWorktreeCreation is one worktree Core was asked to create on the host: the session the +// request carried, the repository's path and the creation. +type remoteWorktreeCreation struct { + session string + root string + creation core.GitWorktreeCreation +} + +// hostWorktrees lists the host repository's worktrees as Core names them in the workspace whose +// local root is root: the repository's folder (remoteTestFolder) first, then the linked ones. +func (k *remoteHostKernel) hostWorktrees(ctx context.Context, root string, counted bool) []core.GitWorktree { + remoteRoot := core.RemoteWorkspaceOf(ctx).RemoteRoot() + k.mu.Lock() + hosts := append([]string{remoteTestFolder}, k.git.worktrees...) + k.mu.Unlock() + list := make([]core.GitWorktree, 0, len(hosts)) + for i, host := range hosts { + local, ok := remoteplaceholder.LocalPath(root, remoteRoot, host) + if !ok { + continue + } + w := core.GitWorktree{Path: local, Head: "0123456789abcdef", Branch: "refs/heads/" + filepath.Base(host), IsPrimary: i == 0, IsCurrent: host == remoteRoot, Status: core.GitWorktreeAvailable} + if w.IsCurrent { + w.Status = core.GitWorktreeCurrent + } + if counted { + none := 0 + w.Changes = &none + } + w.Actions.Remove.Allowed = !w.IsPrimary && !w.IsCurrent + w.Actions.Lock.Allowed = !w.IsPrimary + list = append(list, w) + } + return list +} + +func (k *remoteHostKernel) GitWorktrees(ctx context.Context, root string) ([]core.GitWorktree, error) { + return onHost(ctx, k, "git.worktrees", func() ([]core.GitWorktree, error) { return k.Client.GitWorktrees(ctx, root) }, + func(string) ([]core.GitWorktree, error) { return k.hostWorktrees(ctx, root, false), nil }) +} + +func (k *remoteHostKernel) GitWorktreesWithChanges(ctx context.Context, root string) ([]core.GitWorktree, error) { + return onHost(ctx, k, "git.worktrees", func() ([]core.GitWorktree, error) { return k.Client.GitWorktreesWithChanges(ctx, root) }, + func(string) ([]core.GitWorktree, error) { return k.hostWorktrees(ctx, root, true), nil }) +} + +// GitCreateWorktree records the creation and lists the checkout from then on at the host path +// its destination names, as Core maps it. +func (k *remoteHostKernel) GitCreateWorktree(ctx context.Context, root string, creation core.GitWorktreeCreation) error { + _, err := onHost(ctx, k, "git.write", func() (struct{}, error) { return struct{}{}, k.Client.GitCreateWorktree(ctx, root, creation) }, + func(string) (struct{}, error) { + binding := core.RemoteWorkspaceOf(ctx) + k.mu.Lock() + defer k.mu.Unlock() + k.git.creations = append(k.git.creations, remoteWorktreeCreation{session: binding.SessionID(), root: root, creation: creation}) + if host, ok := remoteplaceholder.HostPath(root, binding.RemoteRoot(), creation.Destination); ok { + k.git.worktrees = append(k.git.worktrees, host) + } + return struct{}{}, nil + }) + return err +} + +// worktreeCreations is a copy of the creations Core was asked for. +func (k *remoteHostKernel) worktreeCreations() []remoteWorktreeCreation { + k.mu.Lock() + defer k.mu.Unlock() + return slices.Clone(k.git.creations) +} + +// openRemoteWorktrees opens the trusted remote test project with a linked worktree on the host +// and shows the Worktrees tab of the Git tool window until its worktrees were read. +func (h *harness) openRemoteWorktrees(t *testing.T, k *remoteHostKernel) (*project, *worktreeState) { + t.Helper() + k.trustAtHost(core.WorkspaceTrusted, ".") + k.set(func(k *remoteHostKernel) { + k.git.trust[remoteTestFeature] = core.WorkspaceDistrusted + k.git.worktrees = []string{remoteTestFeature} + k.git.references = core.GitReferences{References: []core.GitReference{{FullName: "refs/heads/main", ShortName: "main", Kind: "local", IsCurrent: true}}} + }) + p := h.openRemoteTestProject(t) + h.awaitRemoteGit(p) + h.app.layout.gitTab = gitTabWorktrees + h.app.invalidator.Invalidate() + h.settle() + w := &p.worktrees + if !w.started { + h.click(center(h.button(itemGit))) + h.settle() + } + h.await("the host's worktrees", func() bool { return w.loaded && w.countsKnown && len(w.list) == 2 }) + return p, w +} + +// A remote workspace lists the host repository's worktrees by their host paths, and opening the +// linked one connects again over the workspace's connection and opens its folder in a tab of its +// own over the new session. Opening it again shows that tab without connecting. Neither the host +// nor its paths are logged. +func TestRemoteWorktreeOpensOverASessionOfItsOwn(t *testing.T) { + h, k, _, logger := remoteWorkspaceHarness(t) + t.Cleanup(h.disposeTabs) + p, _ := h.openRemoteWorktrees(t, k) + linked, _ := remoteplaceholder.LocalPath(p.root, remoteTestFolder, remoteTestFeature) + h.selectWorktreeAt(t, linked) + if !h.shows(remoteTestFeature) { + t.Fatal("the worktree's details do not show its host folder") + } + + h.app.openWorktree(linked) + var second *App + h.await("the worktree's tab", func() bool { + second = h.app.sessions.active + q := second.project + return second != h.app && q != nil && q.remote != nil && !q.remote.beating && q.tree.root != nil && q.tree.root.listed + }) + h.settleTabs() + entry := savedRemoteConnections(t, h)[0] + anchor, _ := h.app.remoteAnchor() + q := second.project + if q.root != remoteplaceholder.Root(anchor, entry.ID, remoteTestFeature) || q.remote.session != "session-2" || p.remote.session != "session-1" { + t.Fatalf("the worktree opened over session %q, want its folder over a session of its own", q.remote.session) + } + if got := k.count(func(k *remoteHostKernel) int { return k.connects }); got != 2 || h.app.remote.open { + t.Fatalf("connected %d times, window open = %v; want one connection for the worktree", got, h.app.remote.open) + } + + h.app.sessions.activate(h.app) + h.app.openWorktree(linked) + h.settleTabs() + if h.app.sessions.active != second || h.app.remote.open || k.count(func(k *remoteHostKernel) int { return k.connects }) != 2 { + t.Fatal("opening the open worktree again did not show its tab") + } + if got := remoteActions(logger); len(got) == 0 || got[len(got)-1] != "remote.connect" || slices.Index(got, "remote.connect") == len(got)-1 { + t.Fatalf("performed %q, want the worktree's connection after the workspace's", got) + } + if event := loggedAny(t, logger, remoteTestHost, remoteTestHome); event != "" { + t.Fatalf("logged the host or its paths: %s", event) + } +} + +// A worktree whose connection was deleted since the workspace opened is not opened: the +// connection window says why. A path that names no host folder reads the list again. +func TestRemoteWorktreeOfADeletedConnectionSaysSo(t *testing.T) { + h, k, _, logger := remoteWorkspaceHarness(t) + lang := h.app.language() + p := h.openRemoteTestProject(t) + + h.app.openWorktree(filepath.Dir(p.root)) + h.settle() + if !rejected(logger, "git_worktree_open", "not_host_path") || h.app.remote.open { + t.Fatal("a path that names no host folder was not refused") + } + + linked, _ := remoteplaceholder.LocalPath(p.root, remoteTestFolder, remoteTestFeature) + p.remote.connectionID = "deleted" + h.app.openWorktree(linked) + removed := i18n.Shared(lang, "desktop.remote.worktree.connectionRemoved") + h.await("the connection window's list", func() bool { return h.app.remote.open && h.app.remote.loaded }) + h.settle() + if h.app.remote.err != removed || !h.showsWrapped(removed) { + t.Fatal("the connection window does not say the connection was deleted") + } + if !rejected(logger, "git_worktree_open", "connection_removed") || k.count(func(k *remoteHostKernel) int { return k.connects }) != 1 { + t.Fatal("the worktree of a deleted connection was connected to") + } + if event := loggedAny(t, logger, remoteTestHost, remoteTestHome); event != "" { + t.Fatalf("logged the host or its paths: %s", event) + } +} + +// The create dialog of a remote workspace shows Core's suggestion beside the repository as a host +// path and says the path is the host's. A host path typed elsewhere stays as typed, and Create +// sends the path that names it over the workspace's session, then selects the new worktree. +func TestRemoteWorktreeCreatesTheHostFolder(t *testing.T) { + h, k, _, logger := remoteWorkspaceHarness(t) + lang := h.app.language() + p, w := h.openRemoteWorktrees(t, k) + text := &h.app.text.Worktrees + + h.clickNamed(text.New) + h.await("the host's references", func() bool { return w.create.refsLoaded }) + w.create.name.SetText("topic") + h.app.invalidator.Invalidate() + h.settle() + if got, want := w.create.destination.Text(), remoteTestHome+"/project-topic"; got != want || w.create.suggested != want { + t.Fatalf("destination = %q, want the host folder beside the repository %q", got, want) + } + if !h.showsWrapped(i18n.Shared(lang, "desktop.remote.worktree.destination")) { + t.Fatal("the dialog does not say the path is the host's") + } + + typed := "/srv/checkouts/topic/" + w.create.destination.SetText(typed) + h.app.invalidator.Invalidate() + h.settle() + if got := w.create.destination.Text(); got != typed || !w.create.result.Ready { + t.Fatalf("destination = %q, ready = %v; want the typed host path kept", got, w.create.result.Ready) + } + h.clickNamed(text.Create) + h.awaitWorktreeWrite("the creation", w, func() bool { return len(w.list) == 3 }) + named, _ := remoteplaceholder.HostNamedPath(p.root, "/srv/checkouts/topic") + created := k.worktreeCreations() + if len(created) != 1 || created[0].session != "session-1" || created[0].root != p.root || created[0].creation.Destination != named || created[0].creation.Name != "topic" { + t.Fatalf("%d creations, want the named host folder over the workspace's session", len(created)) + } + if local, _ := remoteplaceholder.LocalPath(p.root, remoteTestFolder, "/srv/checkouts/topic"); w.selected != local { + t.Fatal("the new worktree is not selected") + } + if got := k.count(func(k *remoteHostKernel) int { return k.connects }); got != 1 { + t.Fatalf("connected %d times; staying in the workspace connects no more", got) + } + if event := loggedAny(t, logger, remoteTestHost, remoteTestHome, "/srv/checkouts"); event != "" { + t.Fatalf("logged the host or its paths: %s", event) + } +} diff --git a/desktop/internal/workbench/remote_worktree_visual_test.go b/desktop/internal/workbench/remote_worktree_visual_test.go new file mode 100644 index 000000000..68151d4d2 --- /dev/null +++ b/desktop/internal/workbench/remote_worktree_visual_test.go @@ -0,0 +1,99 @@ +//go:build vivahead && lithevisual + +package workbench + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteplaceholder" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteserver" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" + "github.com/vivaui/viva/app" + "github.com/vivaui/viva/headless" +) + +// TestVisualRemoteWorktrees captures the Worktrees tab of a trusted remote workspace: the host +// repository's worktrees by their host folders with the linked one selected, and the create dialog +// with Core's suggestion beside the repository as a host path and the hint that Git creates it on +// the host. +func TestVisualRemoteWorktrees(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0755); err != nil { + t.Fatal(err) + } + for _, look := range []struct{ theme, language, suffix string }{ + {"light", "en-US", "light-en-US"}, + {"dark", "zh-Hans", "dark-zh-CN"}, + } { + t.Run(look.suffix, func(t *testing.T) { + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, settings{Theme: themeChoice(look.theme), Language: look.language, DisableAutoSave: true}); err != nil { + t.Fatal(err) + } + var session *headless.Session + kernel := &remoteHostKernel{testKernel: &testKernel{Client: core.NewClient()}} + kernel.git.trust = map[string]string{} + h := newHarnessWithDriver(t, Options{Kernel: kernel, Store: prefs, Languages: []string{look.language}}, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1200, 760 + var err error + session, err = headless.Open(config, nil, headless.Options{}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + shot := func(scene string) { + t.Helper() + // The scenes set the window's state directly, which does not ask for a frame. + h.app.invalidator.Invalidate() + h.settleChain() + if err := session.Screenshot(filepath.Join(out, "remote-worktrees-"+scene+"-"+look.suffix+".png")); err != nil { + t.Fatal(err) + } + } + timers := &remoteTimers{} + anchor := filepath.Join(t.TempDir(), remoteplaceholder.AnchorName) + h.app.remoteBundle = func() (remoteserver.Bundle, error) { + return remoteserver.Bundle{Version: "0.0.0-visual", Builds: []remoteserver.Build{{ + Target: "x86_64-unknown-linux-musl", Path: "/bundle/lithe-server", SHA256: strings.Repeat("0", 64), + }}}, nil + } + h.app.remoteAnchor = func() (string, error) { return anchor, nil } + h.app.remoteAfter = timers.start + h.app.openRemote(surfaceMenu) + h.settleChain() + r := &h.app.remote + r.selectNew() + r.form.name.SetText("Build box") + r.form.host.SetText(remoteTestHost) + r.form.user.SetText("dev") + h.app.saveRemote() + h.settleChain() + if r.err != "" || r.fieldErr.field != "" { + t.Fatalf("saving the connection: %q %+v", r.err, r.fieldErr) + } + + p, w := h.openRemoteWorktrees(t, kernel) + linked, _ := remoteplaceholder.LocalPath(p.root, remoteTestFolder, remoteTestFeature) + h.selectWorktreeAt(t, linked) + shot("list") + + h.clickNamed(h.app.text.Worktrees.New) + h.await("the host's references", func() bool { return w.create.refsLoaded }) + w.create.name.SetText("topic") + h.app.invalidator.Invalidate() + h.settleChain() + if w.create.destination.Text() != remoteTestHome+"/project-topic" { + t.Fatal("the dialog does not suggest the host folder beside the repository") + } + shot("create") + }) + } +} diff --git a/docs/assets/remote-worktrees/README.md b/docs/assets/remote-worktrees/README.md new file mode 100644 index 000000000..12ee45f96 --- /dev/null +++ b/docs/assets/remote-worktrees/README.md @@ -0,0 +1,13 @@ +# 远程工作区的 Git 工作树(#2231)无头测试截图 + +来自生产 Viva Page 的无头渲染,由 `TestVisualRemoteWorktrees` 生成。主机由测试替换的内核模拟:受信任的远程工作区 `/home/dev/project` 是仓库的主工作树,主机上另有关联工作树 `/home/dev/project-feature`。测试不启动 OpenSSH。截图覆盖深色与浅色主题、中文与英文界面,用于确认: + +- Git 工具窗口的“工作树”页签按主机路径列出工作树,选中关联工作树时详情显示主机路径; +- 新建工作树对话框把 Core 的建议(仓库旁的 `/home/dev/project-topic`)显示为主机路径,输入框下说明路径是主机上的文件夹、由主机上的 Git 创建;“创建后”只有留在当前工作区和打开(在本窗口的新标签页经新会话打开)。 + +截图不代表 macOS/Windows 原生窗口验收,也不代表真实 SSH 主机上的整机验收。 + +| 场景 | 浅色英文 | 深色中文 | +| --- | --- | --- | +| 工作树列表 | [浅色英文](remote-worktrees-list-light-en-US.png) | [深色中文](remote-worktrees-list-dark-zh-CN.png) | +| 新建工作树 | [浅色英文](remote-worktrees-create-light-en-US.png) | [深色中文](remote-worktrees-create-dark-zh-CN.png) | diff --git a/docs/assets/remote-worktrees/remote-worktrees-create-dark-zh-CN.png b/docs/assets/remote-worktrees/remote-worktrees-create-dark-zh-CN.png new file mode 100644 index 000000000..1165643a2 Binary files /dev/null and b/docs/assets/remote-worktrees/remote-worktrees-create-dark-zh-CN.png differ diff --git a/docs/assets/remote-worktrees/remote-worktrees-create-light-en-US.png b/docs/assets/remote-worktrees/remote-worktrees-create-light-en-US.png new file mode 100644 index 000000000..da02a9371 Binary files /dev/null and b/docs/assets/remote-worktrees/remote-worktrees-create-light-en-US.png differ diff --git a/docs/assets/remote-worktrees/remote-worktrees-list-dark-zh-CN.png b/docs/assets/remote-worktrees/remote-worktrees-list-dark-zh-CN.png new file mode 100644 index 000000000..f30ee24c6 Binary files /dev/null and b/docs/assets/remote-worktrees/remote-worktrees-list-dark-zh-CN.png differ diff --git a/docs/assets/remote-worktrees/remote-worktrees-list-light-en-US.png b/docs/assets/remote-worktrees/remote-worktrees-list-light-en-US.png new file mode 100644 index 000000000..8a6a9cf98 Binary files /dev/null and b/docs/assets/remote-worktrees/remote-worktrees-list-light-en-US.png differ diff --git a/shared/i18n/features/remote-connections.json b/shared/i18n/features/remote-connections.json index 38b80319e..dbdba9579 100644 --- a/shared/i18n/features/remote-connections.json +++ b/shared/i18n/features/remote-connections.json @@ -1269,6 +1269,20 @@ "connection": "string" } }, + { + "id": "desktop.remote.worktree.connectionRemoved", + "description": "Remote Development window: error when a worktree of a remote workspace is opened but the saved connection the workspace was opened over was deleted", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.remote.worktree.destination", + "description": "Git worktree create dialog: hint under the path field in a remote workspace", + "platforms": [ + "desktop" + ] + }, { "id": "desktop.remote.document.disconnected", "description": "Reason a file of a remote workspace could not be opened or saved, after “Could not open/save {name}: ”: the workspace has no connection", @@ -3417,30 +3431,6 @@ "desktop.remote.workspace.safeBanner": "This remote workspace is in safe mode: you can browse, edit, save and search its files on the host. Trust the folder to use Git.", "desktop.remote.workspace.gitAbove": "This folder is inside a Git repository that starts in a folder above it on the host. Open the repository's top folder to use Git in a remote workspace.", "desktop.remote.workspace.localOnly": "This feature does not work in a remote workspace yet. You can browse, edit, save and search the host's files, run terminals and use Git on the host.", - "desktop.remote.close.title": "Close the remote workspace?", - "desktop.remote.close.running": "These programs are still running on {connection}:", - "desktop.remote.close.end": "End and Close", - "desktop.remote.close.keep": "Keep on Host and Close", - "desktop.remote.close.remember": "Remember my choice", - "desktop.remote.close.rememberHelp": "Don't ask again. You can change this in Settings › Tools › Remote Workspace.", - "desktop.remote.close.kept": "Programs left running on {connection}: {count}", - "desktop.remote.close.keepFailed": "Could not store the session of {connection}, so its programs ended with the workspace.", - "desktop.remote.close.keepRefused": "{connection} did not confirm it kept the session. If it did not, the host ends its programs.", - "desktop.remote.close.keepLost": "The connection to {connection} was lost, so its programs could not be kept. The host ends them after its idle timeout.", - "desktop.remote.close.rememberFailed": "Could not remember this choice. Closing a remote workspace will ask again.", - "desktop.remote.close.item": "• {kind} “{name}”: {command} ({duration})", - "desktop.remote.close.itemUnnamed": "• {kind}: {command} ({duration})", - "desktop.remote.close.kindTerminal": "Terminal", - "desktop.remote.close.kindProcess": "Process", - "desktop.remote.close.ranUnderMinute": "running for less than a minute", - "desktop.remote.close.ranMinutes": "running for {count} min", - "desktop.remote.close.ranHours": "running for {hours} h {minutes} min", - "desktop.remote.kept.title": "Programs Kept on the Host", - "desktop.remote.kept.text": "A closed window kept these programs running on {connection} ({count}):", - "desktop.remote.kept.end": "End Them", - "desktop.remote.kept.keep": "Keep Running", - "desktop.remote.kept.ended": "Ended programs on {connection}: {count}", - "desktop.remote.kept.endFailed": "Could not end the programs kept on {connection}.", "desktop.remote.document.disconnected": "the remote workspace is not connected; try again once it reconnects", "desktop.remote.document.timedOut": "the host did not answer in time", "desktop.remote.document.notFound": "the file no longer exists on the host", @@ -3487,6 +3477,32 @@ "desktop.remote.wsl.unreachable": "This WSL distribution is not installed, or it did not start.", "desktop.remote.wsl.missing": "wsl.exe was not found on this computer. Install the Windows Subsystem for Linux to open a distribution.", "desktop.remote.wsl.start": "Start the distribution", + "desktop.remote.worktree.connectionRemoved": "The connection this workspace was opened over was deleted, so its worktree cannot be opened. Add the connection again, then open the worktree.", + "desktop.remote.worktree.destination": "The path is a folder on the host, created by Git there.", + "desktop.remote.close.title": "Close the remote workspace?", + "desktop.remote.close.running": "These programs are still running on {connection}:", + "desktop.remote.close.end": "End and Close", + "desktop.remote.close.keep": "Keep on Host and Close", + "desktop.remote.close.remember": "Remember my choice", + "desktop.remote.close.rememberHelp": "Don't ask again. You can change this in Settings › Tools › Remote Workspace.", + "desktop.remote.close.kept": "Programs left running on {connection}: {count}", + "desktop.remote.close.keepFailed": "Could not store the session of {connection}, so its programs ended with the workspace.", + "desktop.remote.close.keepRefused": "{connection} did not confirm it kept the session. If it did not, the host ends its programs.", + "desktop.remote.close.keepLost": "The connection to {connection} was lost, so its programs could not be kept. The host ends them after its idle timeout.", + "desktop.remote.close.rememberFailed": "Could not remember this choice. Closing a remote workspace will ask again.", + "desktop.remote.close.item": "• {kind} “{name}”: {command} ({duration})", + "desktop.remote.close.itemUnnamed": "• {kind}: {command} ({duration})", + "desktop.remote.close.kindTerminal": "Terminal", + "desktop.remote.close.kindProcess": "Process", + "desktop.remote.close.ranUnderMinute": "running for less than a minute", + "desktop.remote.close.ranMinutes": "running for {count} min", + "desktop.remote.close.ranHours": "running for {hours} h {minutes} min", + "desktop.remote.kept.title": "Programs Kept on the Host", + "desktop.remote.kept.text": "A closed window kept these programs running on {connection} ({count}):", + "desktop.remote.kept.end": "End Them", + "desktop.remote.kept.keep": "Keep Running", + "desktop.remote.kept.ended": "Ended programs on {connection}: {count}", + "desktop.remote.kept.endFailed": "Could not end the programs kept on {connection}.", "desktop.remote.container.heading": "Containers", "desktop.remote.container.kind": "Container", "desktop.remote.container.docker": "Docker", @@ -3825,30 +3841,6 @@ "desktop.remote.workspace.safeBanner": "此远程工作区处于安全模式:可以浏览、编辑、保存和搜索主机上的文件。信任此文件夹后即可使用 Git。", "desktop.remote.workspace.gitAbove": "此文件夹位于主机上更上层文件夹开始的 Git 仓库中。请打开仓库的顶层文件夹,以便在远程工作区中使用 Git。", "desktop.remote.workspace.localOnly": "远程工作区暂不支持此功能,可以浏览、编辑、保存和搜索主机上的文件,也可以在主机上运行终端和使用 Git。", - "desktop.remote.close.title": "关闭远程工作区?", - "desktop.remote.close.running": "以下进程仍在 {connection} 上运行:", - "desktop.remote.close.end": "结束并关闭", - "desktop.remote.close.keep": "保留在远端并关闭", - "desktop.remote.close.remember": "记住我的选择", - "desktop.remote.close.rememberHelp": "之后不再询问,可在 设置 › 工具 › 远程工作区 中修改", - "desktop.remote.close.kept": "{count} 个进程保留在 {connection} 上", - "desktop.remote.close.keepFailed": "无法保存 {connection} 的会话,进程已随工作区结束。", - "desktop.remote.close.keepRefused": "{connection} 没有确认保留会话;如果没有保留,主机会结束这些进程。", - "desktop.remote.close.keepLost": "与 {connection} 的连接已断开,进程没能保留;主机会在空闲超时后结束它们。", - "desktop.remote.close.rememberFailed": "没能记住这个选择,下次关闭远程工作区时仍会询问。", - "desktop.remote.close.item": "• {kind}“{name}”:{command}({duration})", - "desktop.remote.close.itemUnnamed": "• {kind}:{command}({duration})", - "desktop.remote.close.kindTerminal": "终端", - "desktop.remote.close.kindProcess": "进程", - "desktop.remote.close.ranUnderMinute": "已运行不到 1 分钟", - "desktop.remote.close.ranMinutes": "已运行 {count} 分钟", - "desktop.remote.close.ranHours": "已运行 {hours} 小时 {minutes} 分钟", - "desktop.remote.kept.title": "上次保留的进程", - "desktop.remote.kept.text": "上次关闭时保留在 {connection} 上的 {count} 个进程仍在运行:", - "desktop.remote.kept.end": "结束这些进程", - "desktop.remote.kept.keep": "继续运行", - "desktop.remote.kept.ended": "已结束 {connection} 上的 {count} 个进程", - "desktop.remote.kept.endFailed": "无法结束 {connection} 上保留的进程。", "desktop.remote.document.disconnected": "远程工作区未连接,请在重新连接后再试", "desktop.remote.document.timedOut": "主机没有及时响应", "desktop.remote.document.notFound": "主机上已没有这个文件", @@ -3895,6 +3887,32 @@ "desktop.remote.wsl.unreachable": "这个 WSL 发行版没有安装,或者没能启动。", "desktop.remote.wsl.missing": "本机找不到 wsl.exe。安装适用于 Linux 的 Windows 子系统(WSL)后才能打开发行版。", "desktop.remote.wsl.start": "启动发行版", + "desktop.remote.worktree.connectionRemoved": "打开此工作区所用的连接已被删除,无法打开它的工作树。请重新添加该连接后再打开工作树。", + "desktop.remote.worktree.destination": "路径是主机上的文件夹,由主机上的 Git 创建。", + "desktop.remote.close.title": "关闭远程工作区?", + "desktop.remote.close.running": "以下进程仍在 {connection} 上运行:", + "desktop.remote.close.end": "结束并关闭", + "desktop.remote.close.keep": "保留在远端并关闭", + "desktop.remote.close.remember": "记住我的选择", + "desktop.remote.close.rememberHelp": "之后不再询问,可在 设置 › 工具 › 远程工作区 中修改", + "desktop.remote.close.kept": "{count} 个进程保留在 {connection} 上", + "desktop.remote.close.keepFailed": "无法保存 {connection} 的会话,进程已随工作区结束。", + "desktop.remote.close.keepRefused": "{connection} 没有确认保留会话;如果没有保留,主机会结束这些进程。", + "desktop.remote.close.keepLost": "与 {connection} 的连接已断开,进程没能保留;主机会在空闲超时后结束它们。", + "desktop.remote.close.rememberFailed": "没能记住这个选择,下次关闭远程工作区时仍会询问。", + "desktop.remote.close.item": "• {kind}“{name}”:{command}({duration})", + "desktop.remote.close.itemUnnamed": "• {kind}:{command}({duration})", + "desktop.remote.close.kindTerminal": "终端", + "desktop.remote.close.kindProcess": "进程", + "desktop.remote.close.ranUnderMinute": "已运行不到 1 分钟", + "desktop.remote.close.ranMinutes": "已运行 {count} 分钟", + "desktop.remote.close.ranHours": "已运行 {hours} 小时 {minutes} 分钟", + "desktop.remote.kept.title": "上次保留的进程", + "desktop.remote.kept.text": "上次关闭时保留在 {connection} 上的 {count} 个进程仍在运行:", + "desktop.remote.kept.end": "结束这些进程", + "desktop.remote.kept.keep": "继续运行", + "desktop.remote.kept.ended": "已结束 {connection} 上的 {count} 个进程", + "desktop.remote.kept.endFailed": "无法结束 {connection} 上保留的进程。", "desktop.remote.container.heading": "容器", "desktop.remote.container.kind": "容器", "desktop.remote.container.docker": "Docker", diff --git a/shared/platform-feature-matrix/features/remote-workspace.json b/shared/platform-feature-matrix/features/remote-workspace.json index 7d00e0f7d..4dbeda376 100644 --- a/shared/platform-feature-matrix/features/remote-workspace.json +++ b/shared/platform-feature-matrix/features/remote-workspace.json @@ -2,7 +2,7 @@ "id": "remote-workspace", "area": "工作区", "group": "远程开发", - "capability": "远程连接(SSH 主机、本机 WSL 发行版、本机及 SSH 主机与 WSL 发行版上的 Docker/Podman 容器,以及从本机文件夹的 devcontainer.json 构建并打开)、远程路径工作区、主机文件编辑与监听、按路径打开主机上的文件(工作区外只读)、主机终端、主机搜索与替换、远程信任与主机 Git、端口转发(含主机侧转发规则与反向转发)、远程工作区设置(SSH 程序、断线重连与关闭时的远端进程)、关闭确认与保留远端进程", + "capability": "远程连接(SSH 主机、本机 WSL 发行版、本机及 SSH 主机与 WSL 发行版上的 Docker/Podman 容器,以及从本机文件夹的 devcontainer.json 构建并打开)、远程路径工作区、主机文件编辑与监听、按路径打开主机上的文件(工作区外只读)、主机终端、主机搜索与替换、远程信任与主机 Git(含打开和新建工作树)、端口转发(含主机侧转发规则与反向转发)、远程工作区设置(SSH 程序、断线重连与关闭时的远端进程)、关闭确认与保留远端进程", "macos": { "implementationStatus": "partial", "verificationStatus": "pending", @@ -47,15 +47,7 @@ "desktop/internal/workbench/remote_ports_test.go", "desktop/internal/workbench/remote_ports_visual_test.go", "desktop/internal/workbench/remote_wsl.go", - "desktop/internal/workbench/remote_container.go", "desktop/internal/workbench/remote_wsl_test.go", - "desktop/internal/workbench/remote_container_test.go", - "desktop/internal/workbench/remote_host_containers.go", - "desktop/internal/workbench/remote_host_containers_test.go", - "desktop/internal/core/remote_devcontainer.go", - "desktop/internal/core/remote_devcontainer_test.go", - "desktop/internal/workbench/remote_devcontainer.go", - "desktop/internal/workbench/remote_devcontainer_test.go", "desktop/internal/core/remote_preferences.go", "desktop/internal/remoteconn/preferences.go", "desktop/internal/workbench/remote_preferences.go", @@ -64,17 +56,28 @@ "desktop/internal/remoteconn/preferences_test.go", "desktop/internal/settingswindow/remote_workspace_view_test.go", "desktop/internal/settingswindow/remote_workspace_visual_test.go", + "desktop/internal/workbench/remote_worktree.go", + "desktop/internal/workbench/remote_worktree_test.go", + "desktop/internal/workbench/remote_worktree_visual_test.go", "desktop/internal/workbench/remote_port_rules.go", "desktop/internal/workbench/remote_port_rules_view.go", "desktop/internal/workbench/remote_port_rules_test.go", - "desktop/internal/workbench/remote_host_files.go", - "desktop/internal/workbench/remote_host_files_view.go", - "desktop/internal/workbench/remote_host_files_test.go", "desktop/internal/workbench/remote_close.go", "desktop/internal/workbench/remote_close_test.go", "desktop/internal/workbench/remote_close_visual_test.go", "desktop/internal/remoteconn/kept.go", - "desktop/internal/remoteconn/kept_test.go" + "desktop/internal/remoteconn/kept_test.go", + "desktop/internal/workbench/remote_host_files.go", + "desktop/internal/workbench/remote_host_files_view.go", + "desktop/internal/workbench/remote_host_files_test.go", + "desktop/internal/workbench/remote_container.go", + "desktop/internal/workbench/remote_container_test.go", + "desktop/internal/workbench/remote_host_containers.go", + "desktop/internal/workbench/remote_host_containers_test.go", + "desktop/internal/core/remote_devcontainer.go", + "desktop/internal/core/remote_devcontainer_test.go", + "desktop/internal/workbench/remote_devcontainer.go", + "desktop/internal/workbench/remote_devcontainer_test.go" ] }, "windows": { @@ -108,25 +111,28 @@ "desktop/internal/workbench/remote_ports.go", "desktop/internal/workbench/remote_ports_view.go", "desktop/internal/workbench/remote_wsl.go", - "desktop/internal/workbench/remote_container.go", - "desktop/internal/workbench/remote_host_containers.go", - "desktop/internal/core/remote_devcontainer.go", - "desktop/internal/workbench/remote_devcontainer.go", "desktop/internal/core/remote_preferences.go", "desktop/internal/remoteconn/preferences.go", "desktop/internal/workbench/remote_preferences.go", "desktop/internal/settingswindow/remote_preferences_state.go", "desktop/internal/settingswindow/remote_workspace_view.go", + "desktop/internal/workbench/remote_worktree.go", + "desktop/internal/workbench/remote_worktree_test.go", + "desktop/internal/workbench/remote_worktree_visual_test.go", "desktop/internal/workbench/remote_port_rules.go", "desktop/internal/workbench/remote_port_rules_view.go", + "desktop/internal/workbench/remote_close.go", + "desktop/internal/remoteconn/kept.go", "desktop/internal/workbench/remote_host_files.go", "desktop/internal/workbench/remote_host_files_view.go", - "desktop/internal/workbench/remote_close.go", - "desktop/internal/remoteconn/kept.go" + "desktop/internal/workbench/remote_container.go", + "desktop/internal/workbench/remote_host_containers.go", + "desktop/internal/core/remote_devcontainer.go", + "desktop/internal/workbench/remote_devcontainer.go" ] }, "owner": "Remote", - "verification": "在“远程开发”窗口选中已保存的 Linux SSH 连接点“连接”:SSH 询问出现在窗口中,连接后窗口改为主机的文件夹选择,从主目录开始列出子文件夹(跳过名称不是 UTF-8 的条目并说明数量),可输入 ~ 或 / 开头的路径跳转,不存在的路径说明原因且不能打开;“返回”断开这次会话回到连接表单。选中文件夹点“打开”:新标签页打开远程工作区,窗口标题为“文件夹 [SSH: 连接名]”,项目树经 Core 列出主机目录(本机占位目录始终为空),右键只有复制主机路径和刷新;以安全模式打开的文件夹,编辑器上方说明可以浏览、编辑、保存和搜索主机文件,信任文件夹后才能用 Git;受信任的文件夹说明文件、终端和 Git 都在主机上,运行、调试和语言服务器暂不可用;空白编辑区提示 Search Everywhere 和 Find in Files。在项目树双击文件:编辑器经会话读取主机文件(不超过 16 MiB),保存时带上打开时的大小和修改时间写回主机,新建的文件只在主机上不存在时创建;主机上的文件期间被别人改过时保存被拒绝并显示外部修改冲突,“加载磁盘版本”载入主机内容,本机占位目录始终为空。超过 8 MiB 的保存说明主机单次保存上限,编辑内容保留;主机上缺失、无权限、不是普通文件、超时和连接断开分别说明原因,连接断开后自动重连并把打开的文档和主机重新比对。图片、PDF 等查看器、本地历史和插件终端都被拒绝并提示,不回退到本机;在文件浏览器中显示(标签页右键、Search Everywhere 结果、Git 变更)在远程工作区里不提供。状态栏连接菜单的“打开主机上的文件…”(未连接时不可用)从窗口顶部弹出路径框,默认 ~/,经 remote.readDir 列出路径最后一个“/”之前的文件夹,按其后的文字(不分大小写)筛选名称开头,文件夹在前,以“.”开头时才列出隐藏条目,无法读取的条目说明数量;上下键移动、Tab 补全名称、回车进入文件夹或打开文件,没有匹配时回车按输入的路径打开,Esc 或点外面关闭;不以 / 或 ~/ 开头的输入说明要输入什么,名称含“\\”的路径说明在 Windows 上无法打开。工作区文件夹里的文件与项目树打开的相同、可以编辑;文件夹以外的文件(对标 Zed)在占位目录旁的 .lithe-remote-host 下以只读方式打开(S25):不能切换为可编辑(提示原因并记为拒绝),保存和新建都被拒绝并说明原因、不写主机,状态栏导航路径显示 ~ 开头的主机路径,复制相对路径不提供;重连和关闭前与其他文档一样和主机比对,主机上的改动在没有编辑时重新载入(主机监听只覆盖工作区文件夹)。日志只记 remote_open_host_file、remote_read_dir、toggle_read_only 等操作名和原因,不含主机路径。打开“终端”工具窗口:经会话的 remote.runTerminal 在主机文件夹运行主机账户的登录 shell(不带参数,不读本机 Shell 设置,没有本机 Shell 菜单),标签名为连接名,之后的标签为“连接名 (2)”等;输入按顺序、每块不超过 32 KiB 写入,主机说忙时稍后重试,窗口尺寸随输入发送;输出超过 8 MiB 未显示时丢弃最旧的部分并记一次失败。程序退出显示退出码,被信号结束显示 128+信号,关闭标签不算失败。连接断开时终端显示会话已结束,工作区按退避重连;未连接时按回车说明工作区未连接,重连后按回车在新会话上运行。终端起不来时显示 Core 给出的原因(可能含主机路径),日志只记命令名和错误码。拖到终端的文件粘贴为主机路径并按 POSIX shell 加引号,本机工作区外的文件不粘贴并提示原因;粘贴图片不可用(图片会存到本机)。每个会话连接后,经 remote.runWatch 在主机上递归监听整个文件夹,跳过已启用插件隐藏的文件夹名(按原样比较大小写),插件改变隐藏名称时重新开始监听;在主机上新建、修改、删除文件后,项目树重新列出受影响的目录(Core 的 workspace.filterChanges 按可见性规则过滤,不需要会话),打开的文档与主机比对:没有编辑的重新载入,有编辑的显示外部修改冲突;文件夹外和被隐藏文件夹里的变化不触发列表。监听开始时、主机丢失变化(overflow)时、一次超过 4096 个变化时,重新列出树中展开的目录并比对所有文档,日志每次监听各记一次;主机监听数用尽时其余部分继续监听,提示一次“项目文件可能无法自动更新”。监听中文件夹被删除或移走时立即重新监听;主机找不到文件夹时项目树显示根目录不可用,监听等树重新列出文件夹后再开始,主机与树结论不一致时也只等待、不反复重试。其他监听失败只记命令名和错误码、提示一次,等下一个会话再开始;监听发现连接断开时与心跳一样结束会话并重连。Find in Files 的搜索、计数和替换预览带远程绑定发送,Core 从主机文件夹建立索引并读取主机上的当前内容,结果路径相对主机文件夹;点结果在远程编辑器打开主机文件并定位到匹配处,本机占位目录始终为空。主机监听报告的变化路径在下一次查询前增量更新索引,不重建;监听开始和主机丢失变化时重建一次。包含生成文件的查询每次都重建索引(主机监听跳过插件隐藏的文件夹);主机监听数用尽后、会话断开到下一个会话的监听开始之间,每次查询都重建,只由监听提示一次“项目文件可能无法自动更新”,搜索不再另外提示。查询显示期间主机上的变化让结果重新查询。Search Everywhere 所有页签都可用,文件名和文本来自主机,打开弹窗时重新读取生成文件的名称;远程工作区不启动语言服务器,符号只有 Core 在主机文件中找到的。Replace All 在编辑器中替换打开的文档;未打开的文件经会话读取主机内容,由 Core 替换后,只在主机文件仍是读取时的内容时写回,期间被改过的报告冲突,已被删除的说明主机上找不到文件,其余文件照常替换,都不写本机占位目录。在文件夹选择中打开从未决定过的文件夹:先询问是否信任(显示连接名和主机文件夹,Core 给出上级文件夹时可勾选信任其下的所有文件夹),“信任并打开”把决定按连接名记入 Core 的远程信任记录后以受信任方式打开,“以安全模式打开”只读打开,“返回”回到文件夹选择;之前决定过的文件夹直接按记录打开。安全模式下 Git、提交和日志窗口与本机项目一样说明需要信任,编辑器上方的提示里可以信任文件夹,信任后不重开窗口就在主机上启动 Git。受信任的工作区经会话在主机上运行 Git:状态、暂存、提交、差异(含编辑器行号旁的变更标记)、日志与分支、逐行追溯(读取主机上的文件内容)、搁置与储藏都读写主机仓库,本机占位目录始终没有 .git;“排除到本地”写入主机仓库的 info/exclude(缺少 info 文件夹时在主机上创建,读写期间文件被别人改过时这次排除失败、不覆盖)。同一会话经 remote.runWatch 递归监听主机仓库的 git 目录(公共目录在别处时一并监听),主机上 git checkout、commit 等改动元数据后按路径分类并重新读取状态;监听开始、丢失变化或主机监听数用尽时重新读取一次完整状态,新会话重新开始监听。主机文件夹位于上级目录开始的仓库内时,Git 和提交窗口说明要打开仓库顶层文件夹,不显示变更也不记为失败。工作树列表、锁定、解锁、删除在主机上执行,复制路径复制主机路径;打开、在新窗口打开、在文件浏览器中显示和新建工作树被拒绝并提示。受信任的远程工作区里运行、调试、当前文件运行、测试、构建任务和插件语言服务器都不在本机启动,都记为拒绝并提示,运行、测试和构建工具窗口说明暂不可用。状态栏前端显示连接名和心跳往返时间;连续两次心跳无响应显示“无响应”,第三次结束会话并按 Core 由“自动重连时长”给出的间隔重连(默认 1、2、4、8、16、29 秒,共 60 秒),每次失败后等下一个间隔,用完后显示“已断开”和原因,菜单里可“重新连接”;连接被关闭时同样按这些间隔重连;时长设为“不自动重连”时直接显示“已断开”。关闭窗口、退出 Lithe、菜单里“断开并关闭”和切换工作区时,先经 remote.runningPrograms 读取主机上 Lithe 为这个工作区启动的进程和终端;没有时直接结束会话,有时询问“关闭远程工作区?”,正文写明连接名并逐项列出类型(终端、进程)、名称、命令(原样显示,不脱敏)和已运行时长,按钮为“结束并关闭”(默认)、“保留在远端并关闭”和“取消”,“记住我的选择”旁的 ⓘ 说明之后不再询问、只能在 设置 › 工具 › 远程工作区 修改。“取消”保留窗口和会话;“结束并关闭”经 remote.disconnect 结束主机会话;“保留在远端并关闭”让主机保留会话,把恢复凭据按连接存入系统密钥存储后通知“N 个进程保留在 <连接名> 上”,凭据存不下时改为结束并说明原因,主机拒绝保留时同样结束并说明;读取进程列表失败时不询问、照常结束。勾选“记住我的选择”把结束或保留写入 Core 的远程工作区设置,之后直接按设置执行。下次经同一连接、同一 WSL 发行版或同一容器连接时带上最新的保留凭据接回会话,打开文件夹后列出上次保留、仍在运行的进程,可“结束这些进程”(经 remote.endPrograms 只结束它们,不动这次新开的)或“继续运行”;主机上已没有该会话时开新会话并忘掉凭据;接回后没打开工作区就停止的连接再次保留该会话,进程不会未经用户选择就结束。退出 Lithe 时每个远程工作区窗口同样询问,取消的窗口保持打开。最近项目不记录远程工作区。日志只有 remote.connect、remote.workspace.open/reconnect/disconnect、remote.close.cancel/keep/end、remote.kept.end/keep 等动作和失败的操作名,不含主机、用户名、主机路径、主目录、进程名称或命令。运行 remote_close_test.go 的 7 个测试、remoteconn 的 kept_test.go 3 个测试、TestVisualRemoteClose 无头截图(询问、保留后的通知、下次连接列出保留的进程)、remote_workspace_test.go 的 5 个测试、remote_git_test.go 的 6 个测试、remoteplaceholder 的 TestHostAndLocalPathsMapBothWays、remote_documents_test.go 的 2 个测试、remote_terminal_test.go 的 9 个测试、remote_watch_test.go 的 5 个测试、remote_search_test.go 的 4 个测试、remote_host_files_test.go 的 TestRemoteOpenFileOnHost、internal/core 的 TestRemoteTerminal*、TestRemoteWatch* 与 TestRemoteWorkspaceFiltersChangesWithoutTheHost、termview 的 TestOpenStartsTheProgramElsewhere,以及 TestVisualRemoteWorkspace 无头截图;在 Windows 运行 TestCoreRefusesUnadaptedCommandsAndAClosedSessionDetachesTheBinding,验证 Linux 主机路径能通过绑定校验。真实 SSH 主机上的整机验收(包括终端里 vim、top 等全屏程序与窗口缩放,主机上 git checkout 等大批量修改后的监听,以及大仓库上的搜索)仍待完成。远程工作区左侧多出“端口”工具窗口(本机工作区没有,关闭工作区后消失):窗口打开时每 3 秒经 ports.listening 读取主机上正在监听的端口和会话的转发,窗口关闭或未显示时停止读取;同一端口在 0.0.0.0 与 :: 上监听只显示一行;远端端口带上主机监听的 IP 地址,多个地址时显示第一个和其余数量,悬停提示列出全部,地址或网址过长被截断时悬停提示给出全文;列出远端端口、本机地址、进程(名称与 PID,读不到时为“未知”)、来源(监听发现、手动添加)和状态。默认不自动转发任何端口,打开窗口和发现新端口都不转发;行尾“转发”把端口转发到主机上对应族的回环地址,本机在 127.0.0.1 的同号端口监听,该端口被本机其他程序占用时改用空闲端口,本机地址用警告色显示并在提示里说明原端口。右键“转发到指定本机端口…”和已转发行的“更改本机端口…”打开对话框输入 1–65535 的本机端口,非法输入就地说明且不转发;改到另一个端口时先停止原转发再在新端口转发,选择在工作区打开期间保留,停止后再转发仍用该端口。顶部输入端口、主机:端口或网址(http、https、ws、wss,省略端口时按协议默认端口)可手动添加并转发,由 Core 的 remote.parseForwardAddress 解析;格式不对就地说明,网址里带用户名或密码时拒绝并说明,输入框保留原文、日志不记输入内容;同一目标再次添加不重复。网址行按输入的样子显示,转发到主机上提供该端口的回环地址;在浏览器打开和复制本机地址把主机部分换成本机地址并保留路径和查询,ws/wss 网址不提供在浏览器打开;浏览器打不开时提示网址,日志只记失败、不记网址。主机回环地址以外的目标先询问(S28),确认后才带 AllowNonLoopback 转发,取消记为拒绝。已转发行可在浏览器打开、复制本机地址、停止;手动添加且已停止、主机上也没有在监听的行可移除;窗口标题栏可全部停止,标题栏的 ⓘ 说明转发对本机其他程序可见(S30);会话转发数达到 Core 上限时说明上限;状态栏显示已转发数量,点击打开端口窗口;会话结束时转发随之结束,重连后不自动恢复。日志只记 remote.ports.forward/localPort/move/stop/status 等动作和失败操作名,不含主机、地址或进程名。运行 remote_ports_test.go 的 12 个测试、internal/core 的 TestRemoteSessionCommandsOfAnUnknownSession 与 TestRemoteParseForwardAddressReadsPortsAndURLs,以及 TestVisualRemotePorts 无头截图。手动添加的端口和本机端口选择只在工作区打开期间保留,关闭后不保存(需 Core 存储,后续阶段)。端口窗口标题栏的“+”打开“添加转发规则”:方向默认“主机端口 → 另一台服务器”,由主机自己连接目标,数据不经过本机;主机端口可留空由主机选择,目标接受端口、主机:端口或网址(由 Core 的 remote.parseForwardAddress 解析,网址里带用户名或密码时拒绝)。规则默认只在主机的回环地址 127.0.0.1 上监听;勾选“监听主机的全部网卡”时显示警告,每次添加都再次询问、不记住,列表里的监听地址用警告色显示并在悬停提示里说明;目标不是主机自身的回环地址时先询问(S28)。“主机端口 → 本机(反向转发)”只在 设置 › 工具 › 远程工作区 的“反向转发”允许时提供(默认自动,即不允许,对话框说明在哪里开启),每条都询问,主机只在回环地址监听,本机只连接回环地址上的端口。主机端口被占用、主机不允许监听(如 1024 以下)、远端服务不支持、达到会话转发上限(与本机转发合计)、反向转发未被允许分别说明原因,主机端口不是 1–65535 时就地说明,对话框保留输入。端口窗口的“转发规则”一节列出主机监听地址、转到的目标(反向转发为“本机 地址”)、连接数(有失败时注明失败数)和状态,每行可停止,标题栏的全部停止同样停止规则;规则随会话结束而停止,重连后不自动恢复,关闭工作区后也不保存。日志只记 remote.ports.addRule/ruleHost/ruleReverse/ruleConfirm/stopRule 等动作和失败的操作名,不含地址、网址或进程名。运行 remote_port_rules_test.go 的 5 个测试、settingswindow 的 TestRemoteWorkspaceReverseForwardingIsAppliedAndRestored,以及 TestVisualRemotePorts 的转发规则列表、添加对话框和全部网卡询问截图。远程 Git 的 AskPass 转交(推送、拉取时的凭据询问)、从上级目录开始的仓库、打开或新建远程工作树尚未支持。Windows 上“远程开发”窗口在已保存的连接之后以“WSL”标题列出本机安装的 WSL 发行版(Core 的 remote.listWslDistributions,每次打开窗口读取一次;搜索时不列出,标题可折叠;macOS 和没有 WSL 的 Windows 不显示这一组)。选中发行版后右侧说明经本机 wsl.exe 打开、不保存任何信息,可填写 Linux 用户(留空为发行版默认用户),地址显示为 wsl:[用户@]发行版。“连接”经 remote.connect 的 wsl 参数启动,不经 OpenSSH、没有询问,步骤从“启动发行版”开始,不显示读取配置和身份验证;发行版没有安装或没能启动、本机找不到 wsl.exe 时分别说明,不显示 SSH 的排查提示,也没有“编辑连接”;Core 拒绝的用户名或发行版名就地说明。连接后与 SSH 相同:选择文件夹、信任询问、工作区、心跳与重连;窗口标题为“文件夹 [WSL: 发行版]”,状态栏为“WSL: 发行版”(SSH 工作区的“SSH”也由同一参数给出),列表和概览显示已打开该发行版的窗口数。发行版不写入已保存的连接,打开过的文件夹不记入最近文件夹。日志只有 remote.wsl.select、remote.connect 等动作,不含发行版名、用户名或主机路径。运行 remote_wsl_test.go 的 3 个测试、internal/core 的 TestRemoteConnectSendsWSLAloneAndCoreRefusesItByField 与 TestRemoteListWSLDistributionsIsUnavailableOutsideWindows,以及 TestVisualRemoteConnections 的 WSL 截图;真实 Windows 上的 WSL 验收(wsl.exe 的错误输出、--exec 的二进制透传、结束 wsl.exe 后 Linux 进程是否退出、未知用户)仍待完成。打开“设置 › 工具 › 远程工作区”:页面只读取、不创建任何文件。“SSH 程序”默认“自动(Core 在 PATH 上找到的 ssh 路径)”,找不到时为“自动(未找到 ssh)”;“选择…”选一个文件作为草稿,下拉菜单可回到自动;保存的程序缺失或不可执行时在行下说明。“SSH 配置文件”只显示 Core 读取的 ~/.ssh/config 路径,不存在时注明。“自动重连时长”可选“自动(1 分钟)”、不自动重连、15 秒到 1 小时,保存过的其他值也列出。“反向转发”默认“自动(不允许)”,可选允许或不允许,ⓘ 说明主机上的所有用户都能连接反向转发的端口、每条规则仍会确认。“关闭工作区”卡片里“关闭时的远端进程”可选“每次询问”(默认)、“结束”和“保留在远端”,关闭对话框勾选“记住我的选择”后只能在这里改回;“常驻会话的空闲超时”只读显示 Core 报告的远端服务超时(10 分钟),ⓘ 说明断线且没人保留的会话多久后由主机结束。“保存位置”显示偏好目录下的 remote/preferences.json,还没有文件时注明修改后才创建。修改只是草稿:侧栏和底部显示未应用数量,“应用”或“好”经 Core 的 remote.editPreferences 写入(程序先于时长),写入后重新读取显示;Core 拒绝相对路径、不存在、不可执行的程序或超出 0–3600 秒的时长时在页面说明原因并保留草稿,不写文件;文件期间被改过时重新读取并请用户再次应用;文件损坏时说明路径、不提供编辑,此时连接、测试连接、读取有效设置和导入 SSH 主机都失败并说明原因,不用未经用户选择的程序启动 OpenSSH。选中的 SSH 程序用于连接、测试连接、有效设置和 SSH 配置导入(WSL 经 wsl.exe 启动,不使用它)。日志只记 remote_preferences_settings_load/save 等操作名和 Core 错误码,不记路径。运行 settingswindow 的 TestRemoteWorkspace* 6 个测试、remoteconn 的 preferences_test.go、internal/core 的 TestRemotePreferences*,以及 TestVisualRemoteWorkspace 无头截图(中英文、深浅色,自动值、草稿和关闭时保留远端进程三种状态)。真实 SSH 主机上关闭后保留、重连接回和结束保留进程的整机验收,以及保留进程的输出重新接回终端和运行窗口(后续阶段),仍待完成。“远程开发”窗口在 WSL 发行版之后以“容器”标题列出本机 Docker 和 Podman 正在运行的容器(Core 的 remote.listContainers,每次打开窗口读取一次,两个引擎在同一个后台任务里依次读取,一个超时或报错时跳过它并记一次 remote_containers_list 失败,另一个照常列出;搜索时不列出,标题可折叠;两个引擎都没有时不显示这一组)。每行显示容器名和“引擎 · 镜像”,已有窗口打开它时显示绿点。选中容器后右侧显示引擎标签、地址 引擎:[用户@]容器、镜像与引擎给出的状态,说明经本机引擎进入正在运行的容器、不启动不创建不改动容器、不挂载目录、不保存任何信息,可填写容器内用户(用户名、uid 或 用户:组,留空为镜像默认用户)。“连接”经 remote.connect 的 container 参数进入,不经 OpenSSH、没有询问、不发送 SSH 偏好,步骤从“进入容器”开始;容器已停止或暂停、引擎没有应答时说明这几种可能,找不到引擎命令行时说明需要安装哪个引擎,引擎输出只显示在步骤下方,不显示 SSH 的排查提示,也没有“编辑连接”;Core 拒绝的用户或容器名就地说明。连接后与 SSH 相同:选择文件夹、信任询问(信任记录包含容器)、工作区、心跳与重连;窗口标题为“文件夹 [容器: 容器名]”,状态栏为“容器: 容器名”,列表和概览按引擎和容器名显示已打开的窗口数。按容器名连接,所以同名重建的容器仍能接上;容器不写入已保存的连接,打开过的文件夹不记入最近文件夹。日志只有 remote.container.select、remote.connect 等动作,不含容器名、镜像、状态或用户名。测试替换的内核不运行本机的 docker 或 podman。运行 remote_container_test.go 的 4 个测试、internal/core 的 TestRemoteConnectSendsAContainerAloneAndCoreRefusesItByField 与 TestRemoteListContainersNamesTheSessionAndTheEngine,以及 TestVisualRemoteConnections 的容器截图;真实 Docker、Podman 与 Windows 上的整机验收仍待完成。“远程开发”窗口列表工具栏和空白页的“从 devcontainer.json 打开…”打开“在 Dev Container 中打开”页(窗口标题为“远程开发 › 在 Dev Container 中打开”):说明用官方 Dev Container CLI 按本机文件夹的 devcontainer.json 构建并启动容器、构建会运行文件夹的 Dockerfile、features 和命令所以文件夹必须受信任、Lithe 不额外挂载目录也不额外加参数。“选择文件夹…”打开系统文件夹选择,也可输入路径后按回车;相对路径、不存在的路径就地说明。读取文件夹时经 Core 的 remote.devcontainerConfigs 按规范顺序列出 .devcontainer/devcontainer.json、.devcontainer.json 和 .devcontainer 下一层文件夹里的配置,配置有 name 时显示“名称(路径)”,默认选第一个;没有配置时说明并且不能构建。容器引擎可选 Docker 或 Podman。同时读取文件夹的信任:未受信任时说明并把按钮换成“信任并构建”,先以与打开受信任项目相同的方式写入本机信任记录(记一次 workspace.trust.grant),再构建;读取信任失败时说明原因、不能构建。“构建并打开”经 remote.devcontainerUp 运行 CLI(带 projectCodeAllowed),CLI 的输出逐行显示在“构建日志”里(Core 已隐藏敏感信息,最多保留最近 5000 行,Core 截断时在下方说明),只显示、不写入 Lithe 的日志;构建期间左侧列表、配置、引擎和文件夹都不能改,底部显示“正在构建 dev container…”和“停止”。“停止”取消这次构建,日志保留并说明已经启动的容器会继续运行,不记失败;“取消”和关闭窗口也会先停止构建。找不到 devcontainer CLI 时说明用 npm 安装,CLI 报告失败时显示它的输出,超过一小时、结果里没有容器或工作区文件夹、文件夹不受信任分别说明,各记一次 remote_devcontainer_up 失败。成功后选中 CLI 返回的容器(重新读取容器列表,显示镜像),以 CLI 返回的 remoteUser 为容器内用户,按容器连接并直接打开 CLI 返回的工作区文件夹(与容器入口相同的信任询问、工作区、心跳与重连)。日志只有 remote.devcontainer.open/choose/build/stop、remote.connect 等动作,不含文件夹、配置名、容器名、用户名或 CLI 输出。测试替换的内核不运行本机的 devcontainer、docker 或 podman。运行 remote_devcontainer_test.go 的 5 个测试、internal/core 的 TestRemoteDevcontainer*,以及 TestVisualRemoteConnections 的 devcontainer 截图;装有 Dev Container CLI 的真实 Docker、Podman 上的整机验收仍待完成。在 SSH 主机或 WSL 发行版的文件夹选择里,标题栏的“主机上的容器”在文件夹的位置列出那台主机上 Docker 和 Podman 正在运行的容器(经浏览会话的 remote.listContainers 依次读取两个引擎,在远端服务的环境里运行,所以列出的容器就是能进入的;主机没有引擎命令行时说明没有找到 Docker 或 Podman,引擎报错时显示它的输出、不写日志),每行显示容器名、“引擎 · 镜像”和状态,可填写容器内用户(留空为镜像默认用户)。“进入容器”或双击一行结束浏览会话,重新连接主机并经主机上的引擎 exec 进入容器(OpenSSH 会再次询问它要问的内容;步骤与主机相同,地址显示为“主机 › 引擎:[用户@]容器”),随后在容器里选择文件夹;“返回文件夹”回到主机的文件夹。主机连不上或容器已停止、暂停、引擎没有应答时用同一段文字说明并点名引擎,具体原因在诊断输出里;没有“编辑连接”,“重试”进入同一台主机上的同一个容器。工作区身份为“已保存连接或发行版的身份/引擎:[用户@]容器”,窗口名为“容器名(主机名)”,不写入已保存的连接,打开过的文件夹不记入最近文件夹;信任记录包含主机与容器。Core 同样只进正在运行的容器,不提权、不改容器、不挂载(S32)。主机上不支持从 devcontainer.json 构建(devcontainer up 只在本机运行)。日志只有 remote.browse.containers/folders、remote.browse.container.enter、remote.connect 等动作和 remote_host_containers_list 失败名,不含主机、容器名、镜像、用户名或主机路径。运行 remote_host_containers_test.go 的 3 个测试和 TestVisualRemoteConnections 的主机容器截图;真实 SSH 主机与 Windows WSL 上的容器验收仍待完成。", + "verification": "在“远程开发”窗口选中已保存的 Linux SSH 连接点“连接”:SSH 询问出现在窗口中,连接后窗口改为主机的文件夹选择,从主目录开始列出子文件夹(跳过名称不是 UTF-8 的条目并说明数量),可输入 ~ 或 / 开头的路径跳转,不存在的路径说明原因且不能打开;“返回”断开这次会话回到连接表单。选中文件夹点“打开”:新标签页打开远程工作区,窗口标题为“文件夹 [SSH: 连接名]”,项目树经 Core 列出主机目录(本机占位目录始终为空),右键只有复制主机路径和刷新;以安全模式打开的文件夹,编辑器上方说明可以浏览、编辑、保存和搜索主机文件,信任文件夹后才能用 Git;受信任的文件夹说明文件、终端和 Git 都在主机上,运行、调试和语言服务器暂不可用;空白编辑区提示 Search Everywhere 和 Find in Files。在项目树双击文件:编辑器经会话读取主机文件(不超过 16 MiB),保存时带上打开时的大小和修改时间写回主机,新建的文件只在主机上不存在时创建;主机上的文件期间被别人改过时保存被拒绝并显示外部修改冲突,“加载磁盘版本”载入主机内容,本机占位目录始终为空。超过 8 MiB 的保存说明主机单次保存上限,编辑内容保留;主机上缺失、无权限、不是普通文件、超时和连接断开分别说明原因,连接断开后自动重连并把打开的文档和主机重新比对。图片、PDF 等查看器、本地历史和插件终端都被拒绝并提示,不回退到本机;在文件浏览器中显示(标签页右键、Search Everywhere 结果、Git 变更)在远程工作区里不提供。状态栏连接菜单的“打开主机上的文件…”(未连接时不可用)从窗口顶部弹出路径框,默认 ~/,经 remote.readDir 列出路径最后一个“/”之前的文件夹,按其后的文字(不分大小写)筛选名称开头,文件夹在前,以“.”开头时才列出隐藏条目,无法读取的条目说明数量;上下键移动、Tab 补全名称、回车进入文件夹或打开文件,没有匹配时回车按输入的路径打开,Esc 或点外面关闭;不以 / 或 ~/ 开头的输入说明要输入什么,名称含“\\”的路径说明在 Windows 上无法打开。工作区文件夹里的文件与项目树打开的相同、可以编辑;文件夹以外的文件(对标 Zed)在占位目录旁的 .lithe-remote-host 下以只读方式打开(S25):不能切换为可编辑(提示原因并记为拒绝),保存和新建都被拒绝并说明原因、不写主机,状态栏导航路径显示 ~ 开头的主机路径,复制相对路径不提供;重连和关闭前与其他文档一样和主机比对,主机上的改动在没有编辑时重新载入(主机监听只覆盖工作区文件夹)。日志只记 remote_open_host_file、remote_read_dir、toggle_read_only 等操作名和原因,不含主机路径。打开“终端”工具窗口:经会话的 remote.runTerminal 在主机文件夹运行主机账户的登录 shell(不带参数,不读本机 Shell 设置,没有本机 Shell 菜单),标签名为连接名,之后的标签为“连接名 (2)”等;输入按顺序、每块不超过 32 KiB 写入,主机说忙时稍后重试,窗口尺寸随输入发送;输出超过 8 MiB 未显示时丢弃最旧的部分并记一次失败。程序退出显示退出码,被信号结束显示 128+信号,关闭标签不算失败。连接断开时终端显示会话已结束,工作区按退避重连;未连接时按回车说明工作区未连接,重连后按回车在新会话上运行。终端起不来时显示 Core 给出的原因(可能含主机路径),日志只记命令名和错误码。拖到终端的文件粘贴为主机路径并按 POSIX shell 加引号,本机工作区外的文件不粘贴并提示原因;粘贴图片不可用(图片会存到本机)。每个会话连接后,经 remote.runWatch 在主机上递归监听整个文件夹,跳过已启用插件隐藏的文件夹名(按原样比较大小写),插件改变隐藏名称时重新开始监听;在主机上新建、修改、删除文件后,项目树重新列出受影响的目录(Core 的 workspace.filterChanges 按可见性规则过滤,不需要会话),打开的文档与主机比对:没有编辑的重新载入,有编辑的显示外部修改冲突;文件夹外和被隐藏文件夹里的变化不触发列表。监听开始时、主机丢失变化(overflow)时、一次超过 4096 个变化时,重新列出树中展开的目录并比对所有文档,日志每次监听各记一次;主机监听数用尽时其余部分继续监听,提示一次“项目文件可能无法自动更新”。监听中文件夹被删除或移走时立即重新监听;主机找不到文件夹时项目树显示根目录不可用,监听等树重新列出文件夹后再开始,主机与树结论不一致时也只等待、不反复重试。其他监听失败只记命令名和错误码、提示一次,等下一个会话再开始;监听发现连接断开时与心跳一样结束会话并重连。Find in Files 的搜索、计数和替换预览带远程绑定发送,Core 从主机文件夹建立索引并读取主机上的当前内容,结果路径相对主机文件夹;点结果在远程编辑器打开主机文件并定位到匹配处,本机占位目录始终为空。主机监听报告的变化路径在下一次查询前增量更新索引,不重建;监听开始和主机丢失变化时重建一次。包含生成文件的查询每次都重建索引(主机监听跳过插件隐藏的文件夹);主机监听数用尽后、会话断开到下一个会话的监听开始之间,每次查询都重建,只由监听提示一次“项目文件可能无法自动更新”,搜索不再另外提示。查询显示期间主机上的变化让结果重新查询。Search Everywhere 所有页签都可用,文件名和文本来自主机,打开弹窗时重新读取生成文件的名称;远程工作区不启动语言服务器,符号只有 Core 在主机文件中找到的。Replace All 在编辑器中替换打开的文档;未打开的文件经会话读取主机内容,由 Core 替换后,只在主机文件仍是读取时的内容时写回,期间被改过的报告冲突,已被删除的说明主机上找不到文件,其余文件照常替换,都不写本机占位目录。在文件夹选择中打开从未决定过的文件夹:先询问是否信任(显示连接名和主机文件夹,Core 给出上级文件夹时可勾选信任其下的所有文件夹),“信任并打开”把决定按连接名记入 Core 的远程信任记录后以受信任方式打开,“以安全模式打开”只读打开,“返回”回到文件夹选择;之前决定过的文件夹直接按记录打开。安全模式下 Git、提交和日志窗口与本机项目一样说明需要信任,编辑器上方的提示里可以信任文件夹,信任后不重开窗口就在主机上启动 Git。受信任的工作区经会话在主机上运行 Git:状态、暂存、提交、差异(含编辑器行号旁的变更标记)、日志与分支、逐行追溯(读取主机上的文件内容)、搁置与储藏都读写主机仓库,本机占位目录始终没有 .git;“排除到本地”写入主机仓库的 info/exclude(缺少 info 文件夹时在主机上创建,读写期间文件被别人改过时这次排除失败、不覆盖)。同一会话经 remote.runWatch 递归监听主机仓库的 git 目录(公共目录在别处时一并监听),主机上 git checkout、commit 等改动元数据后按路径分类并重新读取状态;监听开始、丢失变化或主机监听数用尽时重新读取一次完整状态,新会话重新开始监听。主机文件夹位于上级目录开始的仓库内时,Git 和提交窗口说明要打开仓库顶层文件夹,不显示变更也不记为失败。工作树列表、锁定、解锁、删除在主机上执行,列表和详情显示主机路径,复制路径复制主机路径。打开关联工作树时“远程开发”窗口打开,用打开工作区所用的连接(或 WSL 发行版)再连一次,显示连接步骤和 OpenSSH 的询问,从未决定过的文件夹先询问是否信任,然后在本窗口的新标签页经一个新会话打开该主机文件夹;再次打开时切到已打开的标签页,不再连接;连接在工作区打开后被删除时窗口说明原因、不连接。新建工作树对话框把 Core 在仓库旁的建议显示为主机路径(如 /home/dev/project-topic),输入框下说明路径是主机上的文件夹、由主机上的 Git 创建;输入的其他主机路径原样保留,“创建”在工作区会话上由主机上的 Git 创建并选中新工作树,“创建后打开”同样经新会话在新标签页打开。在新窗口打开和在文件浏览器中显示仍被拒绝并提示。受信任的远程工作区里运行、调试、当前文件运行、测试、构建任务和插件语言服务器都不在本机启动,都记为拒绝并提示,运行、测试和构建工具窗口说明暂不可用。状态栏前端显示连接名和心跳往返时间;连续两次心跳无响应显示“无响应”,第三次结束会话并按 Core 由“自动重连时长”给出的间隔重连(默认 1、2、4、8、16、29 秒,共 60 秒),每次失败后等下一个间隔,用完后显示“已断开”和原因,菜单里可“重新连接”;连接被关闭时同样按这些间隔重连;时长设为“不自动重连”时直接显示“已断开”。关闭窗口、退出 Lithe、菜单里“断开并关闭”和切换工作区时,先经 remote.runningPrograms 读取主机上 Lithe 为这个工作区启动的进程和终端;没有时直接结束会话,有时询问“关闭远程工作区?”,正文写明连接名并逐项列出类型(终端、进程)、名称、命令(原样显示,不脱敏)和已运行时长,按钮为“结束并关闭”(默认)、“保留在远端并关闭”和“取消”,“记住我的选择”旁的 ⓘ 说明之后不再询问、只能在 设置 › 工具 › 远程工作区 修改。“取消”保留窗口和会话;“结束并关闭”经 remote.disconnect 结束主机会话;“保留在远端并关闭”让主机保留会话,把恢复凭据按连接存入系统密钥存储后通知“N 个进程保留在 <连接名> 上”,凭据存不下时改为结束并说明原因,主机拒绝保留时同样结束并说明;读取进程列表失败时不询问、照常结束。勾选“记住我的选择”把结束或保留写入 Core 的远程工作区设置,之后直接按设置执行。下次经同一连接、同一 WSL 发行版或同一容器连接时带上最新的保留凭据接回会话,打开文件夹后列出上次保留、仍在运行的进程,可“结束这些进程”(经 remote.endPrograms 只结束它们,不动这次新开的)或“继续运行”;主机上已没有该会话时开新会话并忘掉凭据;接回后没打开工作区就停止的连接再次保留该会话,进程不会未经用户选择就结束。退出 Lithe 时每个远程工作区窗口同样询问,取消的窗口保持打开。最近项目不记录远程工作区。日志只有 remote.connect、remote.workspace.open/reconnect/disconnect、remote.close.cancel/keep/end、remote.kept.end/keep 等动作和失败的操作名,不含主机、用户名、主机路径、主目录、进程名称或命令。运行 remote_close_test.go 的 7 个测试、remoteconn 的 kept_test.go 3 个测试、TestVisualRemoteClose 无头截图(询问、保留后的通知、下次连接列出保留的进程)、remote_workspace_test.go 的 5 个测试、remote_git_test.go 的 6 个测试、remoteplaceholder 的 TestHostAndLocalPathsMapBothWays 与 TestHostNamedPathNamesEveryHostPathBelowTheSibling、remote_worktree_test.go 的 3 个测试、remote_documents_test.go 的 2 个测试、remote_terminal_test.go 的 9 个测试、remote_watch_test.go 的 5 个测试、remote_search_test.go 的 4 个测试、remote_host_files_test.go 的 TestRemoteOpenFileOnHost、internal/core 的 TestRemoteTerminal*、TestRemoteWatch* 与 TestRemoteWorkspaceFiltersChangesWithoutTheHost、termview 的 TestOpenStartsTheProgramElsewhere,以及 TestVisualRemoteWorkspace 与 TestVisualRemoteWorktrees 无头截图;在 Windows 运行 TestCoreRefusesUnadaptedCommandsAndAClosedSessionDetachesTheBinding,验证 Linux 主机路径能通过绑定校验。真实 SSH 主机上的整机验收(包括终端里 vim、top 等全屏程序与窗口缩放,主机上 git checkout 等大批量修改后的监听,以及大仓库上的搜索)仍待完成。远程工作区左侧多出“端口”工具窗口(本机工作区没有,关闭工作区后消失):窗口打开时每 3 秒经 ports.listening 读取主机上正在监听的端口和会话的转发,窗口关闭或未显示时停止读取;同一端口在 0.0.0.0 与 :: 上监听只显示一行;远端端口带上主机监听的 IP 地址,多个地址时显示第一个和其余数量,悬停提示列出全部,地址或网址过长被截断时悬停提示给出全文;列出远端端口、本机地址、进程(名称与 PID,读不到时为“未知”)、来源(监听发现、手动添加)和状态。默认不自动转发任何端口,打开窗口和发现新端口都不转发;行尾“转发”把端口转发到主机上对应族的回环地址,本机在 127.0.0.1 的同号端口监听,该端口被本机其他程序占用时改用空闲端口,本机地址用警告色显示并在提示里说明原端口。右键“转发到指定本机端口…”和已转发行的“更改本机端口…”打开对话框输入 1–65535 的本机端口,非法输入就地说明且不转发;改到另一个端口时先停止原转发再在新端口转发,选择在工作区打开期间保留,停止后再转发仍用该端口。顶部输入端口、主机:端口或网址(http、https、ws、wss,省略端口时按协议默认端口)可手动添加并转发,由 Core 的 remote.parseForwardAddress 解析;格式不对就地说明,网址里带用户名或密码时拒绝并说明,输入框保留原文、日志不记输入内容;同一目标再次添加不重复。网址行按输入的样子显示,转发到主机上提供该端口的回环地址;在浏览器打开和复制本机地址把主机部分换成本机地址并保留路径和查询,ws/wss 网址不提供在浏览器打开;浏览器打不开时提示网址,日志只记失败、不记网址。主机回环地址以外的目标先询问(S28),确认后才带 AllowNonLoopback 转发,取消记为拒绝。已转发行可在浏览器打开、复制本机地址、停止;手动添加且已停止、主机上也没有在监听的行可移除;窗口标题栏可全部停止,标题栏的 ⓘ 说明转发对本机其他程序可见(S30);会话转发数达到 Core 上限时说明上限;状态栏显示已转发数量,点击打开端口窗口;会话结束时转发随之结束,重连后不自动恢复。日志只记 remote.ports.forward/localPort/move/stop/status 等动作和失败操作名,不含主机、地址或进程名。运行 remote_ports_test.go 的 12 个测试、internal/core 的 TestRemoteSessionCommandsOfAnUnknownSession 与 TestRemoteParseForwardAddressReadsPortsAndURLs,以及 TestVisualRemotePorts 无头截图。手动添加的端口和本机端口选择只在工作区打开期间保留,关闭后不保存(需 Core 存储,后续阶段)。端口窗口标题栏的“+”打开“添加转发规则”:方向默认“主机端口 → 另一台服务器”,由主机自己连接目标,数据不经过本机;主机端口可留空由主机选择,目标接受端口、主机:端口或网址(由 Core 的 remote.parseForwardAddress 解析,网址里带用户名或密码时拒绝)。规则默认只在主机的回环地址 127.0.0.1 上监听;勾选“监听主机的全部网卡”时显示警告,每次添加都再次询问、不记住,列表里的监听地址用警告色显示并在悬停提示里说明;目标不是主机自身的回环地址时先询问(S28)。“主机端口 → 本机(反向转发)”只在 设置 › 工具 › 远程工作区 的“反向转发”允许时提供(默认自动,即不允许,对话框说明在哪里开启),每条都询问,主机只在回环地址监听,本机只连接回环地址上的端口。主机端口被占用、主机不允许监听(如 1024 以下)、远端服务不支持、达到会话转发上限(与本机转发合计)、反向转发未被允许分别说明原因,主机端口不是 1–65535 时就地说明,对话框保留输入。端口窗口的“转发规则”一节列出主机监听地址、转到的目标(反向转发为“本机 地址”)、连接数(有失败时注明失败数)和状态,每行可停止,标题栏的全部停止同样停止规则;规则随会话结束而停止,重连后不自动恢复,关闭工作区后也不保存。日志只记 remote.ports.addRule/ruleHost/ruleReverse/ruleConfirm/stopRule 等动作和失败的操作名,不含地址、网址或进程名。运行 remote_port_rules_test.go 的 5 个测试、settingswindow 的 TestRemoteWorkspaceReverseForwardingIsAppliedAndRestored,以及 TestVisualRemotePorts 的转发规则列表、添加对话框和全部网卡询问截图。远程 Git 的 AskPass 转交(推送、拉取时的凭据询问)、从上级目录开始的仓库尚未支持。Windows 上“远程开发”窗口在已保存的连接之后以“WSL”标题列出本机安装的 WSL 发行版(Core 的 remote.listWslDistributions,每次打开窗口读取一次;搜索时不列出,标题可折叠;macOS 和没有 WSL 的 Windows 不显示这一组)。选中发行版后右侧说明经本机 wsl.exe 打开、不保存任何信息,可填写 Linux 用户(留空为发行版默认用户),地址显示为 wsl:[用户@]发行版。“连接”经 remote.connect 的 wsl 参数启动,不经 OpenSSH、没有询问,步骤从“启动发行版”开始,不显示读取配置和身份验证;发行版没有安装或没能启动、本机找不到 wsl.exe 时分别说明,不显示 SSH 的排查提示,也没有“编辑连接”;Core 拒绝的用户名或发行版名就地说明。连接后与 SSH 相同:选择文件夹、信任询问、工作区、心跳与重连;窗口标题为“文件夹 [WSL: 发行版]”,状态栏为“WSL: 发行版”(SSH 工作区的“SSH”也由同一参数给出),列表和概览显示已打开该发行版的窗口数。发行版不写入已保存的连接,打开过的文件夹不记入最近文件夹。日志只有 remote.wsl.select、remote.connect 等动作,不含发行版名、用户名或主机路径。运行 remote_wsl_test.go 的 3 个测试、internal/core 的 TestRemoteConnectSendsWSLAloneAndCoreRefusesItByField 与 TestRemoteListWSLDistributionsIsUnavailableOutsideWindows,以及 TestVisualRemoteConnections 的 WSL 截图;真实 Windows 上的 WSL 验收(wsl.exe 的错误输出、--exec 的二进制透传、结束 wsl.exe 后 Linux 进程是否退出、未知用户)仍待完成。打开“设置 › 工具 › 远程工作区”:页面只读取、不创建任何文件。“SSH 程序”默认“自动(Core 在 PATH 上找到的 ssh 路径)”,找不到时为“自动(未找到 ssh)”;“选择…”选一个文件作为草稿,下拉菜单可回到自动;保存的程序缺失或不可执行时在行下说明。“SSH 配置文件”只显示 Core 读取的 ~/.ssh/config 路径,不存在时注明。“自动重连时长”可选“自动(1 分钟)”、不自动重连、15 秒到 1 小时,保存过的其他值也列出。“反向转发”默认“自动(不允许)”,可选允许或不允许,ⓘ 说明主机上的所有用户都能连接反向转发的端口、每条规则仍会确认。“关闭工作区”卡片里“关闭时的远端进程”可选“每次询问”(默认)、“结束”和“保留在远端”,关闭对话框勾选“记住我的选择”后只能在这里改回;“常驻会话的空闲超时”只读显示 Core 报告的远端服务超时(10 分钟),ⓘ 说明断线且没人保留的会话多久后由主机结束。“保存位置”显示偏好目录下的 remote/preferences.json,还没有文件时注明修改后才创建。修改只是草稿:侧栏和底部显示未应用数量,“应用”或“好”经 Core 的 remote.editPreferences 写入(程序先于时长),写入后重新读取显示;Core 拒绝相对路径、不存在、不可执行的程序或超出 0–3600 秒的时长时在页面说明原因并保留草稿,不写文件;文件期间被改过时重新读取并请用户再次应用;文件损坏时说明路径、不提供编辑,此时连接、测试连接、读取有效设置和导入 SSH 主机都失败并说明原因,不用未经用户选择的程序启动 OpenSSH。选中的 SSH 程序用于连接、测试连接、有效设置和 SSH 配置导入(WSL 经 wsl.exe 启动,不使用它)。日志只记 remote_preferences_settings_load/save 等操作名和 Core 错误码,不记路径。运行 settingswindow 的 TestRemoteWorkspace* 6 个测试、remoteconn 的 preferences_test.go、internal/core 的 TestRemotePreferences*,以及 TestVisualRemoteWorkspace 无头截图(中英文、深浅色,自动值、草稿和关闭时保留远端进程三种状态)。真实 SSH 主机上关闭后保留、重连接回和结束保留进程的整机验收,以及保留进程的输出重新接回终端和运行窗口(后续阶段),仍待完成。“远程开发”窗口在 WSL 发行版之后以“容器”标题列出本机 Docker 和 Podman 正在运行的容器(Core 的 remote.listContainers,每次打开窗口读取一次,两个引擎在同一个后台任务里依次读取,一个超时或报错时跳过它并记一次 remote_containers_list 失败,另一个照常列出;搜索时不列出,标题可折叠;两个引擎都没有时不显示这一组)。每行显示容器名和“引擎 · 镜像”,已有窗口打开它时显示绿点。选中容器后右侧显示引擎标签、地址 引擎:[用户@]容器、镜像与引擎给出的状态,说明经本机引擎进入正在运行的容器、不启动不创建不改动容器、不挂载目录、不保存任何信息,可填写容器内用户(用户名、uid 或 用户:组,留空为镜像默认用户)。“连接”经 remote.connect 的 container 参数进入,不经 OpenSSH、没有询问、不发送 SSH 偏好,步骤从“进入容器”开始;容器已停止或暂停、引擎没有应答时说明这几种可能,找不到引擎命令行时说明需要安装哪个引擎,引擎输出只显示在步骤下方,不显示 SSH 的排查提示,也没有“编辑连接”;Core 拒绝的用户或容器名就地说明。连接后与 SSH 相同:选择文件夹、信任询问(信任记录包含容器)、工作区、心跳与重连;窗口标题为“文件夹 [容器: 容器名]”,状态栏为“容器: 容器名”,列表和概览按引擎和容器名显示已打开的窗口数。按容器名连接,所以同名重建的容器仍能接上;容器不写入已保存的连接,打开过的文件夹不记入最近文件夹。日志只有 remote.container.select、remote.connect 等动作,不含容器名、镜像、状态或用户名。测试替换的内核不运行本机的 docker 或 podman。运行 remote_container_test.go 的 4 个测试、internal/core 的 TestRemoteConnectSendsAContainerAloneAndCoreRefusesItByField 与 TestRemoteListContainersNamesTheSessionAndTheEngine,以及 TestVisualRemoteConnections 的容器截图;真实 Docker、Podman 与 Windows 上的整机验收仍待完成。“远程开发”窗口列表工具栏和空白页的“从 devcontainer.json 打开…”打开“在 Dev Container 中打开”页(窗口标题为“远程开发 › 在 Dev Container 中打开”):说明用官方 Dev Container CLI 按本机文件夹的 devcontainer.json 构建并启动容器、构建会运行文件夹的 Dockerfile、features 和命令所以文件夹必须受信任、Lithe 不额外挂载目录也不额外加参数。“选择文件夹…”打开系统文件夹选择,也可输入路径后按回车;相对路径、不存在的路径就地说明。读取文件夹时经 Core 的 remote.devcontainerConfigs 按规范顺序列出 .devcontainer/devcontainer.json、.devcontainer.json 和 .devcontainer 下一层文件夹里的配置,配置有 name 时显示“名称(路径)”,默认选第一个;没有配置时说明并且不能构建。容器引擎可选 Docker 或 Podman。同时读取文件夹的信任:未受信任时说明并把按钮换成“信任并构建”,先以与打开受信任项目相同的方式写入本机信任记录(记一次 workspace.trust.grant),再构建;读取信任失败时说明原因、不能构建。“构建并打开”经 remote.devcontainerUp 运行 CLI(带 projectCodeAllowed),CLI 的输出逐行显示在“构建日志”里(Core 已隐藏敏感信息,最多保留最近 5000 行,Core 截断时在下方说明),只显示、不写入 Lithe 的日志;构建期间左侧列表、配置、引擎和文件夹都不能改,底部显示“正在构建 dev container…”和“停止”。“停止”取消这次构建,日志保留并说明已经启动的容器会继续运行,不记失败;“取消”和关闭窗口也会先停止构建。找不到 devcontainer CLI 时说明用 npm 安装,CLI 报告失败时显示它的输出,超过一小时、结果里没有容器或工作区文件夹、文件夹不受信任分别说明,各记一次 remote_devcontainer_up 失败。成功后选中 CLI 返回的容器(重新读取容器列表,显示镜像),以 CLI 返回的 remoteUser 为容器内用户,按容器连接并直接打开 CLI 返回的工作区文件夹(与容器入口相同的信任询问、工作区、心跳与重连)。日志只有 remote.devcontainer.open/choose/build/stop、remote.connect 等动作,不含文件夹、配置名、容器名、用户名或 CLI 输出。测试替换的内核不运行本机的 devcontainer、docker 或 podman。运行 remote_devcontainer_test.go 的 5 个测试、internal/core 的 TestRemoteDevcontainer*,以及 TestVisualRemoteConnections 的 devcontainer 截图;装有 Dev Container CLI 的真实 Docker、Podman 上的整机验收仍待完成。在 SSH 主机或 WSL 发行版的文件夹选择里,标题栏的“主机上的容器”在文件夹的位置列出那台主机上 Docker 和 Podman 正在运行的容器(经浏览会话的 remote.listContainers 依次读取两个引擎,在远端服务的环境里运行,所以列出的容器就是能进入的;主机没有引擎命令行时说明没有找到 Docker 或 Podman,引擎报错时显示它的输出、不写日志),每行显示容器名、“引擎 · 镜像”和状态,可填写容器内用户(留空为镜像默认用户)。“进入容器”或双击一行结束浏览会话,重新连接主机并经主机上的引擎 exec 进入容器(OpenSSH 会再次询问它要问的内容;步骤与主机相同,地址显示为“主机 › 引擎:[用户@]容器”),随后在容器里选择文件夹;“返回文件夹”回到主机的文件夹。主机连不上或容器已停止、暂停、引擎没有应答时用同一段文字说明并点名引擎,具体原因在诊断输出里;没有“编辑连接”,“重试”进入同一台主机上的同一个容器。工作区身份为“已保存连接或发行版的身份/引擎:[用户@]容器”,窗口名为“容器名(主机名)”,不写入已保存的连接,打开过的文件夹不记入最近文件夹;信任记录包含主机与容器。Core 同样只进正在运行的容器,不提权、不改容器、不挂载(S32)。主机上不支持从 devcontainer.json 构建(devcontainer up 只在本机运行)。日志只有 remote.browse.containers/folders、remote.browse.container.enter、remote.connect 等动作和 remote_host_containers_list 失败名,不含主机、容器名、镜像、用户名或主机路径。运行 remote_host_containers_test.go 的 3 个测试和 TestVisualRemoteConnections 的主机容器截图;真实 SSH 主机与 Windows WSL 上的容器验收仍待完成。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { @@ -163,5 +169,5 @@ "verificationStatus": "pending" } }, - "notes": "Viva:连接和会话由 Core 的 remote.connect/remote.disconnect/remote.closeAll 管理,远端服务按嵌入清单上传;文件夹选择用 remote.readDir。打开的工作区以用户缓存目录下的空占位目录作为本机根,每个请求带上远程绑定(会话、占位根、主机根),Core 只对有远程适配的命令放行,其余以 not_supported 拒绝,所以没有远程实现的功能在桌面端直接拒绝而不读本机占位目录。编辑器的读、写和比对改走 remote.stat、remote.readFile、remote.writeFile(带预期版本,主机按大小和修改时间拒绝过期写入);解码、恢复、语言识别等纯计算命令不带远程绑定发送。日志只记命令名和错误码,不记 Core 返回的消息(可能含主机路径)。macOS 由单元测试与无头截图覆盖;Core 按 POSIX 规则校验 Linux 主机路径,按客户端规则处理本机占位根(#2264)。终端经 remote.runTerminal 运行,输入与尺寸经 remote.hostRequest 的 terminal.write/terminal.resize 发送;关闭标签取消这次请求,Core 随即向主机发 terminal.close;一个连接断开的终端让工作区按同一会话丢失处理(与心跳一致),其他失败只结束该终端。文件夹监听经 remote.runWatch 在请求的 goroutine 上运行整个会话期间,不计入窗口的后台任务;事件在锁内合并后只投递一次到窗口线程,停止监听时作废已排队的变化。Find in Files、Search Everywhere 和 Replace All 的 workspace.search、searchIndex.update/invalidate、searchEverywhere、replacePreview 带远程绑定发送,searchPresentation、replaceText 等纯计算命令不带绑定;Core 以“会话身份 + 主机路径”为键缓存索引,主机监听的变化经 workspace.filterChanges 过滤后更新它。会话结束后 Core 不释放该会话的索引,每次重连或重新打开多留一份(#2277)。 远程信任:Core 的 remote.workspaceTrust 按“会话身份 + 主机文件夹”读出记录,remote.editWorkspaceTrust 写入决定(含连接名),桌面端只把 Core 给出的文档存到偏好目录;projectCodeAllowed 且状态为 trusted 才算受信任。受信任后 git.* 请求带远程绑定发送,Core 在主机上运行 Git,返回的路径是占位路径(remoteplaceholder.LocalPath 把主机路径换成占位路径,文件夹外的主机路径映射到占位目录旁的 .lithe-remote-host 下,不会落到本机真实路径)。git 目录的监听与文件夹监听同样跑在请求自己的 goroutine 上,会话丢失或失去信任时取消。 端口:remote.startForward/stopForward/forwards 与 ports.listening 都带会话发送;Core 只在本机 127.0.0.1 监听,请求的本机端口被占用时选空闲端口并返回 localPortChanged 与 requestedLocalPort;同一目标再次转发返回已有转发(created=false),所以更改本机端口是先停止再转发。顶部输入由 Core 的 remote.parseForwardAddress 解析为目标端口、主机、协议和路径,不连接主机;桌面端把网址的主机换成主机上提供该端口的回环地址再转发。非回环目标需 allowNonLoopback(S28),超过上限返回 forward_limit_reached 并带 maximum。读取在窗口的后台任务里进行,只在窗口打开且被绘制过时排下一次,不做空闲轮询。 转发规则:remote.startHostForward 让主机在回环地址(allInterfaces 时在全部网卡)监听并由主机连接目标,remote.startReverseForward 让主机只在回环地址监听、把每个连接带回本机回环地址上的端口;两者与 remote.startForward 共用会话转发上限,remote.forwards 用 kind 区分三种转发,端口窗口的端口列表只列本机转发。主机端口被占用、被拒绝、远端服务不支持和反向转发未允许分别是 forward_host_port_in_use、forward_host_port_denied、forward_host_unsupported、reverse_forward_disabled。remote.preferences 返回 reverseForwarding(来源与是否允许):打开对话框时据此决定是否提供反向方向,startReverseForward 也带上偏好文档由 Core 再校验一次。 WSL:remote.connect 的 connection 与 wsl 二选一,Core 经 wsl.exe --distribution … --exec 启动同一个远端服务,会话身份为 wsl:[用户@]发行版;桌面端的 remoteHost 在 SSH 连接与 WSL 发行版之间二选一,步骤、文件夹选择、信任、工作区和重连共用同一流程。remote.listWslDistributions 在 Windows 以外直接返回不可用,不运行任何程序。 远程工作区设置:Core 的 remote.preferences 读取偏好文档并解析 SSH 程序(found/missing/notExecutable)、~/.ssh/config 是否存在和重连间隔,remote.editPreferences 一次修改一个字段并返回新文档或 null(全部为自动时删除文件);桌面端只把文档按版本写到偏好目录的 remote/preferences.json(不超过 16 KiB),期间被改过时以冲突拒绝。每次连接、测试连接、读取有效设置和 SSH 配置导入都在后台重新读取文档并随请求发送;连接丢失时在后台读取重连间隔,读取失败时工作区保持断开并说明原因。页面的“自动(…)”另用不带文档的 remote.preferences 求出 Core 的默认值,所以保存了其他值时也能显示自动值。 关闭确认:连接都以常驻会话建立,Core 的 remote.connect 返回 sessionKey、sessionToken 和 resumed;关闭时 remote.runningPrograms 列出主机进程,remote.disconnect 带 programs=end/keep,keep 由 Core 发 server.keep,主机拒绝时返回错误、桌面端改为结束。保留的 sessionKey 与 sessionToken 按连接存入系统密钥存储(每个连接最多 8 条、整项不超过 2560 字节以适配 Windows 凭据管理器,最新的排最后),下次连接带上最新一条作为 resume;resumed=false 时忘掉这条。resumed 会话的 keptPrograms 在打开文件夹后列出,remote.endPrograms 按列出的 ID 只结束这些进程;空闲超时来自 Core 的 closing.idleTimeoutSeconds。记住的选择经 remote.editPreferences 的 closePrograms 写入同一份偏好文档。进程名称和命令只在对话框里显示,不写日志。 容器:remote.connect 的 container 单独出现时由 Core 在本机运行 exec -i [-u 用户] 容器 进入(S32:只进正在运行的容器,不提权、不改容器、不挂载),会话身份为 engine:[用户@]容器;container 跟在 connection 或 wsl 后面时 Core 在那台主机上、远端服务的非登录环境里运行同样的 exec,信任键包含主机与容器,remote.listContainers 带 sessionId 时也在那里列出。桌面端 remoteHost 由 SSH 连接或 WSL 发行版加可选的容器组成:overSSH() 决定是否发送 SSH 偏好、显示配置与认证步骤,saved() 决定是否提供编辑和记住文件夹,hosted() 区分主机上的容器(失败文字、重试目标)。列表键为 引擎:完整 ID,请求只发容器名。 devcontainer.json:Core 的 remote.devcontainerConfigs 只读文件夹并列出配置,remote.devcontainerUp 要求 projectCodeAllowed,在本机运行 devcontainer up(只传 --workspace-folder、选中的 --config,选 Podman 时加 --docker-path podman,不加挂载或其他参数),按流式事件返回已隐藏敏感信息的输出,结束时给出容器 ID、名称、remoteUser 和 remoteWorkspaceFolder;桌面端随后走与容器入口相同的 remote.connect 的 container 参数。未受信任的文件夹由桌面端先写本机信任记录再构建。" + "notes": "Viva:连接和会话由 Core 的 remote.connect/remote.disconnect/remote.closeAll 管理,远端服务按嵌入清单上传;文件夹选择用 remote.readDir。打开的工作区以用户缓存目录下的空占位目录作为本机根,每个请求带上远程绑定(会话、占位根、主机根),Core 只对有远程适配的命令放行,其余以 not_supported 拒绝,所以没有远程实现的功能在桌面端直接拒绝而不读本机占位目录。编辑器的读、写和比对改走 remote.stat、remote.readFile、remote.writeFile(带预期版本,主机按大小和修改时间拒绝过期写入);解码、恢复、语言识别等纯计算命令不带远程绑定发送。日志只记命令名和错误码,不记 Core 返回的消息(可能含主机路径)。macOS 由单元测试与无头截图覆盖;Core 按 POSIX 规则校验 Linux 主机路径,按客户端规则处理本机占位根(#2264)。终端经 remote.runTerminal 运行,输入与尺寸经 remote.hostRequest 的 terminal.write/terminal.resize 发送;关闭标签取消这次请求,Core 随即向主机发 terminal.close;一个连接断开的终端让工作区按同一会话丢失处理(与心跳一致),其他失败只结束该终端。文件夹监听经 remote.runWatch 在请求的 goroutine 上运行整个会话期间,不计入窗口的后台任务;事件在锁内合并后只投递一次到窗口线程,停止监听时作废已排队的变化。Find in Files、Search Everywhere 和 Replace All 的 workspace.search、searchIndex.update/invalidate、searchEverywhere、replacePreview 带远程绑定发送,searchPresentation、replaceText 等纯计算命令不带绑定;Core 以“会话身份 + 主机路径”为键缓存索引,主机监听的变化经 workspace.filterChanges 过滤后更新它。会话结束后 Core 不释放该会话的索引,每次重连或重新打开多留一份(#2277)。 远程信任:Core 的 remote.workspaceTrust 按“会话身份 + 主机文件夹”读出记录,remote.editWorkspaceTrust 写入决定(含连接名),桌面端只把 Core 给出的文档存到偏好目录;projectCodeAllowed 且状态为 trusted 才算受信任。受信任后 git.* 请求带远程绑定发送,Core 在主机上运行 Git,返回的路径是占位路径(remoteplaceholder.LocalPath 把主机路径换成占位路径,文件夹外的主机路径映射到占位目录旁的 .lithe-remote-host 下,不会落到本机真实路径)。git 目录的监听与文件夹监听同样跑在请求自己的 goroutine 上,会话丢失或失去信任时取消。 端口:remote.startForward/stopForward/forwards 与 ports.listening 都带会话发送;Core 只在本机 127.0.0.1 监听,请求的本机端口被占用时选空闲端口并返回 localPortChanged 与 requestedLocalPort;同一目标再次转发返回已有转发(created=false),所以更改本机端口是先停止再转发。顶部输入由 Core 的 remote.parseForwardAddress 解析为目标端口、主机、协议和路径,不连接主机;桌面端把网址的主机换成主机上提供该端口的回环地址再转发。非回环目标需 allowNonLoopback(S28),超过上限返回 forward_limit_reached 并带 maximum。读取在窗口的后台任务里进行,只在窗口打开且被绘制过时排下一次,不做空闲轮询。 转发规则:remote.startHostForward 让主机在回环地址(allInterfaces 时在全部网卡)监听并由主机连接目标,remote.startReverseForward 让主机只在回环地址监听、把每个连接带回本机回环地址上的端口;两者与 remote.startForward 共用会话转发上限,remote.forwards 用 kind 区分三种转发,端口窗口的端口列表只列本机转发。主机端口被占用、被拒绝、远端服务不支持和反向转发未允许分别是 forward_host_port_in_use、forward_host_port_denied、forward_host_unsupported、reverse_forward_disabled。remote.preferences 返回 reverseForwarding(来源与是否允许):打开对话框时据此决定是否提供反向方向,startReverseForward 也带上偏好文档由 Core 再校验一次。 WSL:remote.connect 的 connection 与 wsl 二选一,Core 经 wsl.exe --distribution … --exec 启动同一个远端服务,会话身份为 wsl:[用户@]发行版;桌面端的 remoteHost 在 SSH 连接与 WSL 发行版之间二选一,步骤、文件夹选择、信任、工作区和重连共用同一流程。remote.listWslDistributions 在 Windows 以外直接返回不可用,不运行任何程序。 远程工作区设置:Core 的 remote.preferences 读取偏好文档并解析 SSH 程序(found/missing/notExecutable)、~/.ssh/config 是否存在和重连间隔,remote.editPreferences 一次修改一个字段并返回新文档或 null(全部为自动时删除文件);桌面端只把文档按版本写到偏好目录的 remote/preferences.json(不超过 16 KiB),期间被改过时以冲突拒绝。每次连接、测试连接、读取有效设置和 SSH 配置导入都在后台重新读取文档并随请求发送;连接丢失时在后台读取重连间隔,读取失败时工作区保持断开并说明原因。页面的“自动(…)”另用不带文档的 remote.preferences 求出 Core 的默认值,所以保存了其他值时也能显示自动值。 关闭确认:连接都以常驻会话建立,Core 的 remote.connect 返回 sessionKey、sessionToken 和 resumed;关闭时 remote.runningPrograms 列出主机进程,remote.disconnect 带 programs=end/keep,keep 由 Core 发 server.keep,主机拒绝时返回错误、桌面端改为结束。保留的 sessionKey 与 sessionToken 按连接存入系统密钥存储(每个连接最多 8 条、整项不超过 2560 字节以适配 Windows 凭据管理器,最新的排最后),下次连接带上最新一条作为 resume;resumed=false 时忘掉这条。resumed 会话的 keptPrograms 在打开文件夹后列出,remote.endPrograms 按列出的 ID 只结束这些进程;空闲超时来自 Core 的 closing.idleTimeoutSeconds。记住的选择经 remote.editPreferences 的 closePrograms 写入同一份偏好文档。进程名称和命令只在对话框里显示,不写日志。 容器:remote.connect 的 container 单独出现时由 Core 在本机运行 exec -i [-u 用户] 容器 进入(S32:只进正在运行的容器,不提权、不改容器、不挂载),会话身份为 engine:[用户@]容器;container 跟在 connection 或 wsl 后面时 Core 在那台主机上、远端服务的非登录环境里运行同样的 exec,信任键包含主机与容器,remote.listContainers 带 sessionId 时也在那里列出。桌面端 remoteHost 由 SSH 连接或 WSL 发行版加可选的容器组成:overSSH() 决定是否发送 SSH 偏好、显示配置与认证步骤,saved() 决定是否提供编辑和记住文件夹,hosted() 区分主机上的容器(失败文字、重试目标)。列表键为 引擎:完整 ID,请求只发容器名。 devcontainer.json:Core 的 remote.devcontainerConfigs 只读文件夹并列出配置,remote.devcontainerUp 要求 projectCodeAllowed,在本机运行 devcontainer up(只传 --workspace-folder、选中的 --config,选 Podman 时加 --docker-path podman,不加挂载或其他参数),按流式事件返回已隐藏敏感信息的输出,结束时给出容器 ID、名称、remoteUser 和 remoteWorkspaceFolder;桌面端随后走与容器入口相同的 remote.connect 的 container 参数。未受信任的文件夹由桌面端先写本机信任记录再构建。 工作树:打开远程工作区的工作树等于用同一个连接打开另一个主机文件夹,每个文件夹一个会话、一个标签页,已有标签页的会话还活着时直接切换;新建对话框把仓库、目标和建议路径都用 remoteplaceholder.HostNamedPath 映射到占位根旁的 .lithe-remote-host 下发给 Core,Core 按仓库路径推出的建议也落在那里,显示前换回主机路径,所以不用改 Core 的建议和映射规则,Windows 与 WSL 上的主机路径也是本机绝对路径。" }