Repository navigation
feat(remote): 重连续传后停放旧连接的进程事件,remote.attachProcess 接回运行窗口 (Refs 1lck/Lithe-IDEA#2231) - #167
Merged
Merged
Conversation
…Lithe-IDEA#2231) - 客户端:连接可延后续传;park("process") 让上一个连接建立的进程(id 小于 hello 的 nextResourceId)的事件先停放,attach 时一次交出;每个进程最多 4 MiB、合计 16 MiB,超出时先丢最早的输出,退出事件不丢;连接关闭时还有 停放事件则记为已丢弃。attach 区分“已有请求在接收”和“没有可接回的事件”。 - workspace:连接常驻会话时延后续传、停放进程事件,从本进程记住的上一个 连接最后收到的事件 seq 续传(最多记 32 个会话,只存会话键和序号);记下 这次续传是否完整。 - 新命令 remote.attachProcess { sessionId, processId }:先发 process.attached { processId, truncated },再转发断线期间和之后的 process.output / process.exit,直到进程结束;请求拥有该进程,取消即结束。 新错误码 remote_process_gone、remote_process_attached。 - 顺手补齐 preferences.rs、programs.rs 缺的字段文档(注释检查原本不过)。
xiaoyumuxi
marked this pull request as ready for review
November 22, 2026 03:49
27 of 34 tasks
xiaoyumuxi
added a commit
to 1lck/Lithe-IDEA
that referenced
this pull request
Nov 22, 2026
- 运行中连接断开、主机保留会话时,Run 窗口等待重新连接;接上同一个主机会话后经 remote.attachProcess 从丢失处接着输出,丢了部分输出时说明,可多次断线 - 主机开了新会话、进程已不在、被另一个连接接收时结束运行并说明原因 - 等待期间停止的运行,在接上同一个主机会话后强制结束主机进程 - 关闭时保留的进程,下次连接可“在运行窗口中接回”,每个进程一个带“主机”徽标的标签页 - Core 客户端新增 remote.attachProcess、process.attached 和两个错误码 - 固定 Core main 18feb4a(含 Lithe-IDEA/Lithe-core-rust#167) - 截图、功能矩阵、Agent Note 同步更新
1 task done
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(远程开发完整设计)§9.2 / §9.3 / S35 #43c:远程工作区断线重连、或者下次连到还留着程序的常驻会话时,运行窗口能把还在主机上跑的进程接回来,从上一个连接最后收到的事件接着显示,丢了输出要能说出来。本 PR 是 Core 部分;桌面端(运行窗口重连后接上、关闭确认里保留的程序可接回)等本 PR 合入后另开 PR。
类型
remote.attachProcess命令和remote_process_gone、remote_process_attached两个错误码;远端服务协议不变;不新增日志事件改动说明
客户端停放事件(新文件
crates/remote/src/client/routes.rs,client/session.rs)session.rs里的route、订阅表)搬到routes.rs,原来的三个路由测试一起搬过去,行为不变。RemoteSession::park(family):上一个连接建立的资源(id 小于 hello 里的session.nextResourceId)如果属于这个 family、又没人订阅,它们的事件先停放在连接里,等attach取走。要在resume之前调用(连接时用已有的ResumeMode::Deferred),这样续传回放的事件也会停放。*.output,退出事件不丢;丢过的资源在attach里报lost: true。RemoteSession::attach(family, id) -> Result<Attachment { missed, lost, events }, AttachRefusal>:先交出停放的事件,再像subscribe一样收后面的事件,中间没有空隙(取走和注册在同一把路由锁里完成)。拒绝分两种,一码一义:Owned(已有别人在收这个资源)、Unavailable(不是停放的 family、是这个连接自己建立的、或已经接回过一次)。RemoteSession::event_position() -> EventPosition { seq(), discarded() }(last_event_seq()保留,改为读同一个位置),会话结束后还能读:seq是最后收到的事件序号,discarded表示连接关闭时还有没人取走的停放事件(这些事件已经确认给主机,下一个连接拿不到)。工作区续传位置(新文件
crates/workspace/src/resumption.rs,sessions.rs、test_support.rs)park("process"),再用本进程记住的上一个连接的seq续传。位置只在内存里,按会话键记,最多 32 个会话,最旧的先忘;不含主机地址、账号或路径。应用重启后没有位置,主机回放它还留着的全部事件,接回时报可能缺输出。History { resumed, complete }里。test_support::register_in_process_with(session, history):测试用,register_in_process改为调用它。命令(
crates/workspace/src/host.rs,接线在command.rs、dispatcher/remote.rs)remote.attachProcess { sessionId, processId }→ 结果和remote.runProcess一样是进程组长的退出(exitCode、signal)。过程中先转发process.attached { processId, truncated },再转发断线期间和之后的process.output、process.exit,直到进程结束。truncated为lost || !history.complete。remote.runProcess一样:取消请求或调用方断开会结束主机上的进程树。server.state确认主机上还有这个进程,再收后面的事件;server.state的回复排在之前的退出事件后面,所以确认后再取一次订阅,就不会漏掉刚好在这期间到的退出。connection_closed;这个连接没有续传任何会话、进程不在了或已经接回过remote_process_gone;已有请求在收这个进程remote_process_attached;server.state解不开parse_failed。request_trace测试的“不算热路径”命令表加上remote.attachProcess(每次接回都是用户操作,要记录)。错误码(
crates/protocol/src/error.rs,contracts/application-boundary.md)RemoteProcessGone(remote_process_gone)和RemoteProcessAttached(remote_process_attached),各自只表示一种情况。契约文档(
contracts/rust-core-api.md)remote.attachProcess。truncated什么时候为真(4 MiB / 16 MiB 上限、退出事件不丢、应用重启后没有位置),两个错误码,终端和监听不接回。顺手修复
remote/src/client/preferences.rs的source、status字段和workspace/src/programs.rs的ProgramKind变体、RunningProgram::kind缺文档,scripts/rust-core/verify-rust-core-comments.sh在 main 上原本不过,这次补上。存储与日志
验证
cargo fmt --all -- --check:通过cargo clippy -p lithe-remote --features "client server" --all-targets -- -D warnings,cargo clippy -p lithe-workspace -p lithe-core --all-targets -- -D warnings:无警告scripts/rust-core/verify-rust-core-comments.sh remote workspace core protocol:通过node scripts/rust-core/verify-platform-tests.mjs、node scripts/logging/generate-log-events.mjs --check:通过cargo test -p lithe-remote --features "client server":单元测试 193 个通过,其中routes.rs新增 6 个:停放后接回不漏事件、只停放早先连接建立的资源、一个资源只有一个接收者、停放超限先丢最早的输出但保留退出、合计上限、关闭时结束订阅并报告丢弃;集成测试persistence16 个通过,新增 2 个(真实lithe-remote服务进程):重连后接回正在跑的进程、输出不缺不重,第二次接回报Owned;断线期间退出的进程接回后收到它的最后输出和退出cargo test -p lithe-workspace:全部通过,新增resumption单元测试 2 个(同一会话以最近一次连接为准、只记最近 32 个会话)cargo test -p lithe-core:896 个通过;新增tests/remote_attach.rs2 个,经过分发器验证:断线期间退出的进程收到process.attached(truncated: false)、输出、退出,再接一次报remote_process_gone;续传后一直没输出的进程先经server.state确认,再收到之后的输出和退出码;结束在已收事件之前的进程、这个连接自己建立的 id 都报remote_process_gone;会话注销后报connection_closed;没有续传的连接报remote_process_goneprotocol::command,检查rust-core-api.md命令表和解析器一致):通过