Skip to content

fix(term): post a command's end only after it ran 2 s - #11

Merged
Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
xihale:fix/spurious-command-finished
Oct 22, 2026
Merged

Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
xihale:fix/spurious-command-finished

Conversation

@xihale

@xihale xihale commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #10

根因

omp 18.12.5 会给每条渲染的消息包一层 shell 集成标记:ESC]133;A BEL(首行)、ESC]133;B BEL ESC]133;C BEL ESC]133;D;0 BEL(末行,含清空)。pty 捕获一个回合的完整序列:

OSC 7501: state=idle:app=omp
OSC 9;4;3
OSC 7501: state=working:app=omp
  10 × (133;A B C D;0)      ← 每条消息一组
OSC 7501: state=done:app=omp
OSC 9;4;0

ELYTerminal 的 tap 读取任何程序的 OSC 133(与 Ghostty 一致,见 T40)。于是 omp 的每条消息都被读成一次完整的命令生命周期:

  1. Mark::Output(C)置 ran = true;
  2. Mark::Done(D;0)→ finished():ran 为真且窗口非激活 → post "Command finished"。

omp 持续流式渲染消息,通知以 3s 限频(GAP)连发。标题转圈与它无关(改纯文字无效);其他终端同样解析 133 但不为 D 发通知,故不复现。

修复

ran: bool → ran: Option<Instant>,C 时记下时刻;finished() 仅在 C→D 间隔 ≥ RAN_FOR(2s)时 post。omp 的消息标记瞬时完成,永远过不了阈值;真实 shell 命令跑满 2s 才通知。

取舍:ls 等瞬时命令不再触发完成通知。参见 #10 下的讨论:瞬时命令本就无需通知,Ghostty/iTerm2 也只对长时间运行的命令提醒。

验证

  • cargo test --lib term::reports:9 通过(含新增边界测试 a_command_ran_short_of_ran_for_posts_nothing:0s、差 1ns、恰好 2s 三点)。
  • 本机实测:后台跑 omp 一整回合,无任何 "Command finished" 推送;sleep 3 切后台正常弹一条。

A program may write OSC 133 marks of its own: omp 18.12.5 wraps every
message it renders in A, B, C and D, so each message read as a command
that ended, and a session in the background posted "Command finished"
every 3 s while an agent worked (ELY-Open-Source#10).

Record the moment C came; only a command that ran RAN_FOR, 2 s, posts
its end. The marks of a message come and go in a breath, so they stay
quiet, as does a command that ends within the two seconds.
@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

感谢 PR!已合并,阈值按 Ghostty 的默认改为 5 秒,随 v0.1.8 发布。https://github.com/ELY-Open-Source/ELYTerminal/releases/tag/v0.1.8

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.

[BUG REPORT] 使用 omp 工作的时候,一直触发错误的系统推送

2 participants