Skip to content

fix(tui): fold compaction summaries and a stopped turn's process - #360

Merged
openjiuwenai merged 1 commit into
openJiuwen-ai:mainfrom
Miaoranmmm:fix/context-fold-collapse
Nov 27, 2026
Merged

openjiuwenai merged 1 commit into
openJiuwen-ai:mainfrom
Miaoranmmm:fix/context-fold-collapse

Conversation

@Miaoranmmm

@Miaoranmmm Miaoranmmm commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Paired: GitHub #360 ↔ GitCode !255

What type of PR is this?
/kind bug

What

  • Compaction summaries start folded in live chat and on replay. Click the marker or use /fold to read them. Empty markers have no toggle.
  • Interrupted, failed, and awaiting-sub-agent turns fold by section, leaving the partial reply and stop notice visible. Replay also folds recorded stops before a final reply. The last turn recovered from a crash stays open, and structured-output completions keep their steps visible.
  • Continue or Retry reuses the stopped title when available, including during history replay. The status-card button keeps the composer draft. To send a note and start a new section, use the composer button or press Enter with plain text. Pressing Enter on a prompt shortcut that runs commands or switches the agent or model starts a new turn.

The transcript changes affect presentation. Windows session checkpoint reads now retry temporary sharing conflicts, and search tests isolate inherited Git configuration.

Tests

  • Regression coverage includes summary folding and selection, stopped turns and continuation during replay, and Windows checkpoint reads.
  • All 21 PR checks passed on ccf0f284.

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

变更摘要

本 PR 主要修复 TUI 会话记录中两处展开过度的问题:压缩摘要总是完整展开,以及被中断或失败的回合在结束后丢失运行时的折叠状态。核心改动包括重写 ContextFoldWidget(改为标题行 + 默认折叠的摘要体,支持点击//fold 切换、空摘要不可点)、扩展 plan_process_segments 使已结束(含中断、失败、被后续回合接续)的回合按与完成回合一致的方式折叠、以及为回合续跑(Continue)增加在停止标题内就地恢复运行的控制器逻辑。同时新增 add_error_notice 接口区分“回合外错误”与“回合内错误”,并更新 /fold 的文案与手册说明。

主要改动

  • 压缩标记改为可折叠组件: ContextFoldWidget 由单一 Static.render 改为 SameCellClick + Vertical 组合,包含 NonSelectableStatic 标题行与默认 display = False 的 #summary 正文;新增 has_summary、collapsed 属性、toggle_summary、title_text 与 _reveal_summary_start,标题按 FOLDED_ARROW/OPEN_ARROW 显示 ▸/▾,无摘要时无箭头且点击穿透。
  • 拖拽不触发折叠: SameCellClick 新增 on_mouse_move,在 screen_offset != _pressed_cell 时清空按下单元,使拖出再拖回同一格不再被识别为点击,统一作用于所有折叠标题。
  • 停止回合按结束状态折叠: plan_process_segments 引入 _MEMBERS/_OUTPUT 与 completion 条目类型,process_entry 对 is_structured_completion 返回 "completion";ended 由末尾输出、failure、failure_after 或存在后续 user 边界共同决定,末条回复仍作为 segment 的 answer 留在折叠之外,结构化完成的回合保持逐步展开。
  • 续跑接管停止标题: ProcessController 新增 continue_stopped_turn、resume_stopped_title、_resume_stopped_segment、_join_row、forget_removed_members、complete_replayed_turn、_replan_turn,folded_live_rows 更名为 waiting_live_rows;complete_live 接受 fold_choice 回调以在重放期间保留最新 /fold 选择,LiveProcessRow 新增 resumed 标记使停止的标题在接管后先按原样显示。
  • 错误展示接口区分: 新增 add_error_notice(ports.py、view_adapter.py、main_screen_presenter.py、panel.py),remove_trailing_status 增加 replacing 参数,LiveRenderer 拆出 show_error;回合外错误不再清除或改写已结束回合的标题折叠状态。
  • /fold 覆盖压缩摘要与文案更新: ChatPanel.toggle_fold_all 将带摘要的 ContextFoldWidget 纳入折叠集合,ReplayMount.pending_folds_collapsed/_after_batch_mounted 对后续挂载的摘要套用同一选择;commands.py 与 locales 中 /fold 描述和手册页补充“压缩摘要”。

根据当前约束,我不会进行代码审查或报告发现,仅输出上述变更摘要。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

代码审查

审查结论

  • [建议] src/chrys/app/tui/widgets/chat/guide_fold.py:38 fix: SameCellClick.on_mouse_move 被 GuideHoverMixin 覆盖,拖拽守卫对现有折行无效
  • [阻塞] tests/app/tui/screens/main/test_error_surfaces.py:508 fix: 新增用例的假 screen 缺少 _debug,hook_blocked 分支会抛 AttributeError
  • [阻塞] tests/app/tui/screens/main/test_error_surfaces.py:572 fix: 参数化用例的假 screen 未提供 _debug,executor_error 分支会抛 AttributeError
  • [建议] tests/app/tui/screens/main/test_error_surfaces.py:456 fix: add_error 改名只做了一半,同文件仍有两处旧名假实现
类型 数量
🔴 阻塞 2
🟡 建议 2

⛔ 需要修改

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A


def on_mouse_move(self, event: MouseMove) -> None:
if event.screen_offset != self._pressed_cell:
self._pressed_cell = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

🟡 Medium Priority

新增的 SameCellClick.on_mouse_move(guide_fold.py:38-40)用于在指针移到别的单元格时清空 _pressed_cell,从而让"拖拽离开后又回到起始单元格"不触发展开/折叠。但 SameCellClick 的唯一宿主路径 GuideHoverMixin 在 guide_fold.py:218-219 也定义了 on_mouse_move,且没有调用 super();MRO 上(ProcessBlock、LiveProcessRow、ToolGroup、ThinkingMessage 等)解析到的是 GuideHoverMixin.on_mouse_move,于是新增的清空逻辑对这些"每一个折行标题"都不会执行。它们仍在用 guide_fold.py:210 / process_block.py:157 / live_process_row.py:154 的 clicked_same_cell,因此拖拽出单元格再拖回起始单元格后松开,仍会被判定为同格点击并触发折叠——正是本次 PR 声称修掉的交互缺陷,只在新增的 ContextFoldWidget(直接继承 SameCellClick)上生效,两条路径行为分叉。触发条件:在工具组/思考/流程标题行上按下左键,拖到行内其他单元格再拖回起点松开。

建议:在 GuideHoverMixin.on_mouse_move 里先调用 super().on_mouse_move(event)(或显式清空 self._pressed_cell)再执行 _update_guide_hover,使拖拽守卫对所有折行统一生效。


class _FakeChatPanel:
async def add_error(self, message: str, *, action_label: MessageRef | str | None = None) -> None:
async def add_error_notice(self, message: str, *, action_label: MessageRef | str | None = None) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

🟡 Medium Priority

本次 diff 把本文件 6 处 _FakeChatPanel 的协作方法从 add_error 改名为 add_error_notice(456、632、690、1019、1088、1179 行),说明该文件假定的 ChatPanel 契约已是 add_error_notice;但同文件仍未一起改的两处假实现保留了旧名:

  • 865-869 行 _FailingChatPanel.add_error(test_live_turn_error_render_failure_releases_input_without_absorb,期望抛出 "render failed")。
    触发条件:若 on_error 对 ChatPanel 实际调用的是 add_error_notice,这两处假对象没有该属性 → AttributeError(后者的 pytest.raises(RuntimeError, match="render failed") 也拿不到预期异常);反之若真实入口仍是 add_error,则本次改名的 6 处会全部失效。无论哪种,本次单边改名让同文件内的假实现出现两种契约并存,一旦真实 API 只保留一个就会有两种失败模式,属本次改动引入的不一致(此文件是本次 slice 内唯一可读证据,故置信度受限)。

建议:把 813 行与 866 行的 async def add_error( 一并改名为 add_error_notice(,使本文件所有 ChatPanel 错误入口假实现与改名后的 6 处保持同一契约。

_session_title=fake_session_title(),
query_one=lambda cls: widgets[cls.__name__],
_set_agent_running=lambda running: setattr(panel, "agent_running", running),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

🟠 High Priority

新增参数化用例 test_error_preserves_settled_history_and_ends_a_live_turn(521-598 行)在第 572-577 行构造假 screen,只给了 _state、_session_title、query_one、_set_agent_running,没有 _debug。
而 previous == "running" 这一组走 executor_error 分支(第 579 行),同文件 1008-1064 行的 test_executor_error_... 在同一分支上断言 debug_calls == [("Error", "[executor_error] Executor error")],证明该分支必然调用 screen 的 _debug;workspace_change_failed(非 recovered)分支同理也是所有既有用例都传了 _debug(647-653 行)。
触发条件:第 581 行 await handler.on_error(Error(...)) 执行到写调试日志的位置 → AttributeError: 'types.SimpleNamespace' object has no attribute '_debug',4 个参数组合都会挂,而不是断言失败。

建议:在该假 screen 的 SimpleNamespace 中补上 _debug=lambda *_args: None。

Suggested change
)
screen = SimpleNamespace(
_state=state,
_session_title=fake_session_title(),
query_one=lambda cls: widgets[cls.__name__],
_set_agent_running=lambda running: setattr(panel, "agent_running", running),
_debug=lambda *_args: None,
)


state = _blocked_prompt_state()
widgets = {"ChatPanel": panel, "StatusBar": _StatusBar()}
screen = SimpleNamespace(_state=state, query_one=lambda cls: widgets[cls.__name__])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: eedc0ad179b5099d608680b83c1b5e66d12777a6

🟠 High Priority

新增用例 test_a_hook_rejection_leaves_the_crash_recovered_turn_expanded(486-518 行)构造的假 screen 只有 _state 与 query_one:
第 508 行 screen = SimpleNamespace(_state=state, query_one=lambda cls: widgets[cls.__name__])。
但本文件所有投递 on_error 的用例都必须提供 _debug(例如形态几乎相同的 450-478 用例的 473 行 _debug=lambda *_args: None),而同文件 674-729 行的 test_pending_submit_error_display_localizes_chat_but_debug_keeps_protocol_english 在同样的 _blocked_prompt_state() + hook_blocked 路径下断言 debug_calls == [("Error", "[hook_blocked] Prompt blocked by hook.")],证明该分支确实会调用 screen 的 _debug。
触发条件:用例在第 510 行 state.submit.publish_from_current_task() 之后 await handler.on_error(...),渲染闸门被放行、错误立即处理,于是走到写 _debug 的位置 → AttributeError: 'types.SimpleNamespace' object has no attribute '_debug',新增用例必挂(在提供 _debug 的旧用例里不会出现,属本次新增引入)。文件里唯一没有 _debug 的 screen(770-773 行)之所以能过,是因为错误在 render gate 处被 defer 直接返回,没有走到该分支。

建议:在该假 screen 的 SimpleNamespace 中补上 _debug=lambda *_args: None,与同文件其他 on_error 用例保持一致。

Suggested change
screen = SimpleNamespace(_state=state, query_one=lambda cls: widgets[cls.__name__])
screen = SimpleNamespace(_state=state, query_one=lambda cls: widgets[cls.__name__], _debug=lambda *_args: None)

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: e86896756965435d2740c409fd8d403dfbd9b715

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: d135ad6a9aaeb970f72290a19b31dbc030db326e

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 008695f45f3b245662f230611d405de6fcfc34c6
Stale: GitHub PR head has moved on; preserving this CI result without changing ci-running.

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: e1a2a80c6beb873fc8110157ea20df0722c37c5b

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

Open compaction summaries from their title or /fold. Keep the activity
and replies of stopped and continued turns in order during live updates
and background replay. Preserve readable messages when reopening a
process and document how to send a continuation note.

Retry briefly held session checkpoint reads on Windows and isolate
the search tests from ambient Git configuration overrides.

Co-authored-by: Jiaqi (0x7c13) Liu <liujiaqi101@huawei.com>
@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: ccf0f284121ac670ccd0c473a64f84fa46bc5413

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwenai
openjiuwenai merged commit 4a3acd3 into openJiuwen-ai:main Nov 27, 2026
21 checks passed
@openjiuwen-release-bot

Copy link
Copy Markdown
Contributor

🤖 This pull request has been merged, and the target branch is up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants