fix(tui): make edit-last-turn boundaries authoritative - #17
Merged
h3c-hexin merged 3 commits intoAug 25, 2026
Conversation
Op::EditLastTurn 用 role=="user" 从尾部定位截断点,但工具结果与内部 运行时信封同样以 user 角色持久化;上一轮只要调用过工具,截断就会落在 最后一条 tool_result 上,旧 prompt 与工具往返残留在历史中,表现为模型 保留编辑前记忆、前端新旧气泡并存。 - 新增 is_user_turn_prompt 谓词(首块为 Text、不含 ToolResult 变体、 非内部运行时信封与 runtime/subagent_handoff/shell_completion provenance),EditLastTurn 改用它定位截断点 - cut==None 时发送错误事件并终止,不再静默降级为追加发送 - 修正 prompt_zones truncate_to 与实现相反的注释 - 新增行为测试覆盖尾部带 tool_result 的截断与无用户消息时报错路径 Signed-off-by: luzeyang (INT) <lu.zeyang@h3c.com>
|
Thanks @qiuYliangM for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
…t-turn-cut Signed-off-by: hexin <he.xin@h3c.com>
Classify editable, unsupported, and runtime-owned user-role messages in one place. Reject edit preflight failures with typed errors and an authoritative failed terminal so embedded hosts can roll back optimistic state safely. Signed-off-by: hexin <he.xin@h3c.com>
h3c-hexin
added a commit
that referenced
this pull request
Aug 26, 2026
Locate the edit cut at the latest genuine user prompt instead of any provider-compatible user-role message. Reject missing and unsupported targets with a terminal failed outcome so embedded hosts cannot remain busy after an invalid edit. Ported and adapted from #17. Co-authored-by: 秋月凉梦 <1461574375@qq.com> Signed-off-by: hexin <13790929+h3c-hexin@users.noreply.github.com> Co-authored-by: 秋月凉梦 <185303122+qiuYliangM@users.noreply.github.com>
h3c-hexin
added a commit
that referenced
this pull request
Aug 26, 2026
Locate the edit cut at the latest genuine user prompt instead of any provider-compatible user-role message. Reject missing and unsupported targets with a terminal failed outcome so embedded hosts cannot remain busy after an invalid edit. Ported and adapted from #17. Co-authored-by: 秋月凉梦 <185303122+qiuYliangM@users.noreply.github.com> Signed-off-by: hexin <13790929+h3c-hexin@users.noreply.github.com>
10 tasks
Hmbown
pushed a commit
to Hmbown/Codewhale
that referenced
this pull request
Aug 26, 2026
Locate the edit cut at the latest genuine user prompt instead of any provider-compatible user-role message. Reject missing and unsupported targets with a terminal failed outcome so embedded hosts cannot remain busy after an invalid edit. Ported and adapted from Pinvou#17. Signed-off-by: hexin <13790929+h3c-hexin@users.noreply.github.com> Co-authored-by: hexin <13790929+h3c-hexin@users.noreply.github.com> Co-authored-by: 秋月凉梦 <185303122+qiuYliangM@users.noreply.github.com>
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.
Background
Op::EditLastTurnpreviously located the cut with a rawrole == "user"scan even though tool results and runtime-owned control messages use that role for provider compatibility. A tool-using turn could therefore retain the old prompt and tool round-trip. The original fix separated editable prompts but still skipped unsupported real-user content and emitted only an advisory error on preflight rejection, which could leave embedded hosts busy or persisting an optimistic edit.Changes
edit_last_turn_*errors followed by authoritativeTurnComplete(Failed)terminals for every edit preflight rejection.is_user_turn_promptexport and corrects theprompt_zones::truncate_tocomment.Verification
cargo test -p codewhale-tui --lib --locked runtime_handoff: 12 passed.cargo test -p codewhale-tui --lib --locked edit_last_turn: 3 passed.cargo test -p codewhale-tui --tests --locked -- --skip runtime_api::tests::skill_lifecycle_uninstall_removes_installed_skill: library 10,098 passed; Cucumber 14 passed; integration 263 passed; PTY 65 passed, 3 ignored.skill_lifecycle_uninstall_removes_installed_skill; its exact rerun fails on the unchanged target as well.cargo fmt --all -- --checkandgit diff --check: passed.cargo clippy --workspace --all-targets --locked -- -D warningswas run and is blocked by 27 pre-existing target-branch diagnostics, including private-interface and unused-mut warnings; none points to this pull request diff.Known risks
No-Issue: this fixes an existing edit replay boundary and lifecycle bug; the background, behavior, and verification are documented above.