Repository navigation
feat(remote): remote workspace preferences: SSH program and reconnect limit (Refs 1lck/Lithe-IDEA#2231) - #158
Merged
Conversation
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 16:04
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
1lck/Lithe-IDEA#2231(远程开发完整设计)§10 R0:设置 › 工具 › 远程工作区页需要的值,由 Core 校验、解析并告诉界面每个“自动”实际取什么值。本 PR 是 Core 部分,桌面端的设置页和接入另开 PR。
类型
remote.preferences和remote.editPreferences(远程工作区设置:SSH 程序、自动重连最长时间);remote.probe、remote.connect、remote.effectiveSettings、remote.sshConfigHosts新增可选preferences,用设置里的 SSH 程序启动 OpenSSH改动说明
设置文档规则(新文件
crates/remote/src/client/preferences.rs)remote/preferences.json,最大 16 KiB,版本 1,拒绝未知字段;只写用户改过的值,“自动”的值不写,所以全自动时文档是{"version": 1}。sshProgram:绝对路径,去掉首尾空白,不能有控制字符,最长 4096 字节。改设置时要求文件存在且可执行(Unix 看执行位),不满足就按字段拒绝(missing、notExecutable、relative、invalid、tooLong)。已保存的程序后来被删掉不算文档损坏,读取时报告status: "missing",让设置页显示出来。PATH中只看绝对路径的目录,取第一个可执行的ssh(Windows 上是ssh.exe);一个都没有时用ssh,交给系统去找,和以前一样。reconnectLimitSeconds:0 到 3600 秒,自动是 60 秒。重连间隔从 1 秒开始翻倍,最长 30 秒,最后一次缩短,让总和正好等于上限;默认的 60 秒是 1、2、4、8、16、29 秒,0 表示不自动重连。这套重连节奏原来写在桌面端(6 次、1 秒起翻倍、最长 30 秒),现在由 Core 给出,客户端只按delaysMilliseconds等待。命令(新文件
crates/workspace/src/preferences.rs,接线在command.rs、dispatcher/remote.rs)remote.preferences { document, homeDirectory? }返回:preferences:保存的值,null表示自动;ssh { source, path, status }:实际使用的 SSH 程序及来源(setting/automatic);reconnect { source, limitSeconds, delaysMilliseconds };storage:文档的位置和大小上限;sshConfig { path, exists }:给了homeDirectory才返回,供设置页显示和打开~/.ssh/config。相对路径的主目录按{ field: "homeDirectory", reason: "relative" }拒绝。remote.editPreferences { document }一次只改一个值:sshProgram: { path|null }或reconnectLimit: { seconds|null },null恢复自动。两个都给或都不给,按{ field: "operation", reason: "invalid" }拒绝。返回{ changed, document|null },没有变化时document为null,客户端不创建文件。parse_failed,编辑被拒是invalid_request;两者都带{ field, reason }的details,和已保存的连接一致。使用 SSH 程序的四个命令(
probe.rs、sessions.rs、ssh_configuration.rs)preferences,就是文档的文本。不传等于全自动,旧客户端不受影响。parse_failed,不会启动 OpenSSH。WSL 连接不使用这个字段。ssh_program(stand_in, document)),原来的测试不需要改。契约文档(
contracts/rust-core-api.md)remote.probe的连接说明后补充:四个命令都可以带preferences。验证
cargo fmt --allcargo clippy -p lithe-remote -p lithe-workspace -p lithe-core --all-targets --all-features -- -D warnings:无警告cargo test -p lithe-remote --all-features:全部通过(新增 6 个 preferences 测试:默认值、文档拒绝、程序消失只报告、PATH查找、编辑往返、重连节奏)cargo test -p lithe-workspace --lib:58 个通过(新增 5 个:读取、损坏文档、发布与无变化、按字段拒绝、替身优先)cargo test -p lithe-core:888 个通过;connection_window_helpers_answer_through_the_dispatcher补充了经过分发器的读取、编辑,以及文档损坏时remote.effectiveSettings在启动 OpenSSH 前返回parse_failed