Skip to content

fix(term): keep the records a program reports through OSC 7501 at a prompt - #17

Merged
Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
xihale:fix/prompt-marks-keep-7501-records
Oct 24, 2026
Merged

Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
xihale:fix/prompt-marks-keep-7501-records

Conversation

@xihale

@xihale xihale commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

跟随 #11(已合并)的同一根因:omp 逐消息的 OSC 133 标记。#10 评论区报告的现象——omp working 时会话的运行时动效时有时无、ready 同理。

根因

omp 每渲染一条消息输出一组 133;A B C D;0。ELYTerminal 对每个 A 视为新提示符,Records::prompt()(src/term/status.rs)执行 retain(Done | Error)——清掉 Working/Blocked/Idle 记录。

  • omp 整个回合只报一次 OSC 7501 state=working:app=omp,第一条消息渲染时该记录即被清掉,动效消失;直到下一次 7501 上报(回合/工具调用边界)才复活 → 时有时无。
  • ready(idle 记录)同理被消息渲染的 A 清掉。
  • 附带:herdr 代理的 blocked(等待授权)记录也会被同一面板里敲命令时的 A 误清。

pty 捕获的完整序列证据见 PR #11 与 issue #10 评论。

修复

用现成的 Records.reported 标志(自上次全复位以来有程序通过 OSC 7501 上报过)门控 prompt():说 7501 的程序自管生命周期(omp 以 state=done 结束回合),A 不再清它的记录;真实 shell 集成只发 133 从不发 7501,行为不变。herdr 的 waiting 记录也因此不再被误清。

取舍

程序上报 working 后异常退出(无终态、无 clear)会留下滞留记录。omp 每回合必报 done,herdr 自管 seen;prompt() 跳过时留有 debug 日志,OSC c 全复位与下一次 7501 上报均可清除。

验证

  • rebase 到 e477637 后 cargo test --lib:273 通过;3 个失败均为本机环境问题(fish 4.9.1 与上游 CI 版本差异、缺 Xvfb ×2),干净 main 上同样失败。
  • status 模块 16 项全过,含重写的 a_new_prompt_leaves_done_and_error_unless_a_program_reports_itself:7501 上报过的会话记录在提示符处保留;shell 会话(含 OSC 9;4 进度记录)照旧在提示符处清理。

…rompt

A program may wrap each message it renders in OSC 133 marks of its own,
as omp 18.12.5 does: every mark A read as a new prompt, which dropped
the working record the program itself had reported, so a row's running
mark came and went while an agent worked (ELY-Open-Source#10).

A prompt now ends the records of a session where no program reports
through OSC 7501; one that does ends its records itself, as omp does
with done, and herdr's waiting agents keep their places.
@xihale

xihale commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

这个处理的是 omp 工作时和完成时所对应的 ELYTerminal 的相关图标状态混乱了的问题。

@xihale

xihale commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

@Raiden-MeixElysia 可以审计了,我用了一天发现确实修复了问题。现在当 omp 的 working、finish 和 idle 都正常对应上了。
image

@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

OK

@Raiden-MeixElysia
Raiden-MeixElysia merged commit 4b4e1b0 into ELY-Open-Source:main Oct 24, 2026
2 of 3 checks passed
Raiden-MeixElysia added a commit that referenced this pull request Oct 24, 2026
…e records, as OSC 7501 asks: the records count running commands as OSC 133 C and D nest them, so omp's marks inside the shell's C keep its work, in place of PR #17's gate
@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

谢谢你的排查和这个 PR,已合并进 main(4b4e1b0)。

你找到的根因是对的:omp 给每条消息都打 OSC 133 A,每个 A 都把它自己的 working 记录清掉了。合并后我把门控换了一种做法,因为规范要求真正的 shell 提示符必须清掉 working 和 blocked:如果有程序上报过 7501 就一律不清,一个崩溃的程序会一直显示 working。

现在的做法(89b4873):

  • ELYTerminal 自己的 shell 集成在提示符的 A 上带 aid=elyterminal。这样的 A 是 shell 的,照规范清掉 working、blocked、idle。
  • 不带这个名字的 A(omp 的)按读到它时前台进程组判断:omp 还占着终端,就保留它自己上报的记录。fish 4.3 以后自己打的提示符、PowerShell 下运行的程序,也都单独处理了。

审查用真实的 zsh、fish、PowerShell 跑了 omp 式的消息流、Ctrl+C 打断、嵌套 shell、后台任务等场景,都对。这会进下一个版本。再次感谢!

@xihale
xihale deleted the fix/prompt-marks-keep-7501-records branch October 25, 2026 01:17
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.

2 participants