Skip to content

refactor(runtime): unify session model updates and TUI chat - #1601

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/runtime-model-chat-resize
Jul 17, 2026
Merged

refactor(runtime): unify session model updates and TUI chat#1601
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/runtime-model-chat-resize

Conversation

@limityan

@limityan limityan commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

变更概述

  • 新增窄口径 AgentSessionModelPort,由 Core 的 ConversationCoordinator 继续持有唯一会话状态;CLI/TUI、Peer Host、ACP、Desktop 与远程 Bot 的活动会话模型写入统一经过 Agent Runtime SDK。
  • 将约 5.9k 行的 modes/chat.rs 按职责拆为同一私有 Rust 模块下的子文件,不新增公共 TUI 框架、协议、DTO 或状态 owner。
  • Chat resize 使用 75ms 静默窗口:只记录事件时间,不保存或应用可能过期的事件尺寸;静默期暂停普通流式绘制与 MCP 兜底绘制,恢复后由 Ratatui 按当前 backend 尺寸统一重绘。
  • 修正 TUI 模型切换反馈:当前会话更新失败时明确提示;当前会话成功但未来默认值保存失败时保留已生效模型并提示重试。
  • 同步 Agent Runtime、产品架构、CLI 产品线与 Core 拆分文档;同时保留并明确披露两处最新 main 测试基线修复,不改变运行时行为。

范围边界

  • Core 仍是模型选择规范化、会话持久化和错误语义的唯一 owner;模型目录、模式和提供方配置不迁入 SDK。
  • SDK API version 保持 v1;缺少模型端口时复用既有 RuntimeError::Port(NotAvailable),不新增可穷举错误枚举成员。
  • Chat 拆分使用私有 include! 组织;resize 不新增 timer/task,不改变事件协议或绘制内容规格。
  • 不包含扩展能力或 HarmonyOS 工作,不改变 GUI/TUI 视觉规格、Remote wire schema 或模型选择策略。
  • 真实 PTY 中的活动 turn resize 仍是后续进程级验收,本 PR 不以启动页 PTY/ConPTY 冒烟替代该结论。

风险与控制

风险 控制
多产品入口出现不同模型写入语义 所有入口通过同一 typed port 回到 Core;覆盖真实 Runtime → Port → Coordinator → SessionManager 成功链路、NotFound 保真及持久化后恢复
窗口拖动触发过度绘制或使用过期尺寸 静默期状态单测覆盖合并;两个实际 draw 路径统一门控;TestBackend 验证窄屏流式内容增加换行
模型切换出现“后端已生效但界面仍显示旧值” 区分失败、完全成功和部分成功;分别验证标签与用户可见提示
大文件拆分引入行为漂移 同模块私有拆分,无公共边界变化;CLI 全套测试与 Windows 终端进程冒烟通过

验证

通过:

  • rustup run nightly cargo fmt --all -- --check
  • node scripts/check-core-boundaries.mjs
  • rustup run nightly cargo check --workspace
  • rustup run nightly cargo test -p bitfun-cli -- --nocapture(211 passed;其余 CLI 集成/进程测试也通过)
  • rustup run nightly cargo test -p bitfun-agent-runtime --test session_model_sdk -- --nocapture(2 passed)
  • rustup run nightly cargo test -p bitfun-core session_model -- --nocapture(4 passed)
  • git diff --check

此前还通过:

  • cargo test -p bitfun-runtime-ports
  • cargo test -p bitfun-agent-runtime -- --nocapture
  • cargo test -p bitfun-acp -- --nocapture(94 passed)
  • pnpm run prepare:mobile-web && cargo test -p bitfun-desktop --lib(107 passed)

cargo test --workspace 此前执行到 services-integrations,本 PR 相关测试均通过;最终有两个位于本 PR 未修改代码的环境测试失败:本地 HTTP 分页端口竞态,以及 Windows 临时目录 \\?\ 路径表示差异。本轮未在独立基线工作树重复执行这两项,也未为其扩大产品代码范围。

审核结论

修复后的最终差异已由相互独立的资深架构与产品视角复核;SDK 兼容、resize 绘制、模型切换反馈、持久化恢复和文档事实问题均已闭环,未发现剩余 P0–P3 阻塞。

Route session model mutations through the Agent Runtime SDK while keeping Core as the sole owner. Split chat mode by private responsibilities and debounce resize redraws without changing public TUI contracts.
@limityan
limityan force-pushed the yanzhn/runtime-model-chat-resize branch from 49edeb2 to 084ed9c Compare July 17, 2026 19:00
@limityan
limityan merged commit 5d7df22 into GCWing:main Jul 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant