Repository navigation
Conversation
Frontends detach for many transient reasons (SSH drops, terminal closes, app restarts), so the gateway must not tie its lifetime to client connections. Remove the last-client-disconnect auto shutdown and the startup deadline along with the GatewayClients lease machinery; the gateway now runs until the explicit shutdown control operation, Ctrl+C, or a host termination signal. Share the shutdown request as gateway_shutdown_request for non-CLI embedders and update the multi-identity validation doc to describe the new lifecycle. Signed-off-by: h4rm00n <harmoon@qq.com>
Plain /exit and /quit now leave the gateway running for whatever attaches next; /exit core (and /quit core) additionally sends the gateway shutdown request, whose stop intent pauses every attached TUI's auto-restart supervisor. A failed stop request keeps the TUI open so the user can retry or fall back to a plain quit. Signed-off-by: h4rm00n <harmoon@qq.com>
The tray exit action now performs an explicit full stop: it asks Dart to shut the gateway down through a new stopGateway runtime Host method (bridge FFI export plus Linux/Windows/macOS runner forwards) before quitting via a new keep-alive quit method, preserving the old button's stop-everything behavior now that exits no longer stop the core implicitly. A new tray item, 仅保留内核退出, quits the frontend natively and leaves the gateway serving other frontends. The desktop gateway process test expects the surviving gateway instead of the auto shutdown and also fixes its latent executable move-while- borrowed compile error in the ignored target. Signed-off-by: h4rm00n <harmoon@qq.com>
This branch has not been deployed
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.
变更说明
要解决的问题:此前网关(core)的生命周期绑定在客户端连接上——最后一个客户端断开 1 秒后自动关停,无前端的启动 60 秒后过期。但 TUI/前端可能因各种原因断开(SSH 掉线、终端关闭、应用重启),"谁拉起谁消灭"会误杀仍在使用的 core,也让"退出前端 = 丢失内核"成为隐式副作用。
采用的方案:改为显式生命周期——
apps/cli/src/gateway.rs)删除 last-client-disconnect 自动关停分支与GatewayClients租约全套机制(含 60 秒启动死线);网关现在运行到显式shutdown控制操作、前台 Ctrl+C 或宿主终止信号为止。断开连接不再保留或停止进程。gateway_shutdown_request(GatewayControlClient.rs),供非 CLI 嵌入方(flutter bridge)复用同一条显式停止路径。/exit、/quit只退出 TUI,内核保持运行;新增/exit core(/quit core等价)退出 TUI 并向网关发显式 shutdown——owner 先落 stop 意图标记,其他附着 TUI 的自动重启 supervisor 随即暂停,不会被立刻拉回。stop 请求失败时 TUI 保持打开以便重试。Ctrl+C / Ctrl+Q 行为不变(普通退出)。stopGateway运行时 Host 方法(bridge FFI 导出operit_flutter_bridge_gateway_stop+ 三平台 runner 转发)停掉网关后再通过 keep-alive 新增的quit方法原生退出——保持该按钮原有的"全停"用户语义(此前靠自动关停实现)。CoreApplicationService订阅 keep-alive 新增的exitActions事件流处理 stopCore 退出(尽力停止网关后必退出);浏览器运行时stopGateway为空实现。docs/pr603-multi-identity-validation.md生命周期描述)。影响范围:桌面网关进程生命周期、CLI/TUI 退出语义、桌面 App 托盘菜单、flutter bridge FFI 面(新增一个导出,未改动既有导出)。不改动控制协议既有操作(复用
shutdownop);移动端/嵌入式运行时不受影响(stopGateway在非桌面平台返回明确错误或空实现)。改动类型
影响范围
apps/cli(gateway 生命周期、TUI 命令与 i18n)、hosts/common/operit-host-native-common(控制协议助手)、apps/flutter/native/operit-flutter-bridge(FFI 导出与桌面网关)、三平台 runner(runtime channel 转发)、apps/flutter/thirdparty/operit_keep_alive(托盘插件协议)、apps/flutter/app(Dart Host 接口、CoreApplicationService、main)验证
内置包解析为必需检查,覆盖
buildin和external,包括默认关闭的插件。本次未改动任何插件包源码或清单,仍按要求实际运行并通过:截图或日志
复现步骤(TUI,端到端实测记录):
托盘菜单结构(Linux 实测占位符渲染):打开 / 仅保留内核退出 / 退出 。
提交者确认
Package parsing检查通过。CLA 签署评论链接:
#520 (comment)