Skip to content

fix: fullscreen mouse ownership and trackpad scroll jitter - #16

Merged
kkkiio merged 5 commits into
mainfrom
fix/fullscreen-mouse-and-scroll-jitter
Aug 31, 2026
Merged

kkkiio merged 5 commits into
mainfrom
fix/fullscreen-mouse-and-scroll-jitter

Conversation

@kkkiio

@kkkiio kkkiio commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

两个 Advisor Overlay 输入 bug 的修复,以及配套的 pi 依赖升级。

1. Fullscreen 模式下 Overlay 破坏 pi 的鼠标支持

Overlay 直接写终端序列开关 mouse reporting(1000/1006)——这在 regular 模式是必要的(pi 不管鼠标),但在 fullscreen 模式下,Overlay 关闭时写的 1000l/1006l 会把 pi 自己启用的鼠标永久关掉(pi 只在 start/stop 管理),导致本会话 transcript 滚轮滚动、文本选择、滚动条拖拽全部失效。

修复:只在 tui.mode !== "fullscreen" 时由 Overlay 管理 mouse reporting;fullscreen 下 pi 会把滚轮事件透传给聚焦的 Overlay,滚动功能不受影响(已实测)。

2. 触控板滚动到底部时持续抖动

真实环境日志(PI_ADVISOR_DEBUG_SCROLL)定位:Ghostty 触控板斜向滑动会发出水平滚轮事件(SGR 按钮 66/67),而 getMouseScrollDelta 的 button & 1 判断把 66 误读为向上滚 3 行。每个水平微事件都把视图向上拽 3 行并打断 follow,后续向下事件再拉回底部,形成持续抖动。

修复:

  • 只有按钮 64/65(垂直滚轮)触发滚动;其余鼠标事件(水平滚轮、点击)被消费但不再泄漏进输入框
  • 输入阶段即用上次渲染的 maxScroll 钳制 offset,滚动爆发不会在帧间越过底部
  • 已在底部 follow 时向下滚动直接忽略;offset/follow 无变化时不再触发冗余重绘

3. 升级 @earendil-works/pi-* 到 0.84.4

tui.mode 需要 0.84+,且 0.84 有 API 破坏:createAgentSession 的 modelRegistry 选项换成 modelRuntime,ModelSelectorComponent 构造签名变更。ExtensionContext 只暴露 ModelRegistry 兼容门面,resolveModelRuntime() 复用其背后的共享 ModelRuntime,保持 Advisor 与 Primary 共享扩展注册 provider 和凭据。

BREAKING: peerDependencies 现在要求 pi >= 0.84.4。

Test plan

  • just fmt / just check / just test 通过
  • 新增 BDD 回归场景 "Trackpad drift does not bounce Advisor Overlay off the transcript bottom"——在旧代码上失败(视图卡在 ↓3),修复后通过
  • 既有滚轮 E2E 场景在 0.84.4 通过
  • tmux 实测 fullscreen:开+关 Overlay 后 mouse_any_flag/mouse_sgr_flag 保持 1 1(修复前归 0);Overlay 内滚轮上下滚动正常
  • CI 全量 E2E

kkkiio added 2 commits August 31, 2026 15:22
Pi 0.84 replaced CreateAgentSessionOptions.modelRegistry with the shared
ModelRuntime and changed the ModelSelectorComponent constructor. The
ExtensionContext still only exposes the synchronous ModelRegistry facade,
so resolveModelRuntime() reuses the runtime behind it; sharing the
Primary's runtime keeps extension-registered providers and runtime
credentials available to Advisor sessions.

BREAKING: peerDependencies now require pi >= 0.84.4.
Two overlay input bugs:

- The overlay toggled terminal mouse reporting (1000/1006) directly,
  which is required under the regular TUI but permanently disabled pi's
  own mouse support (transcript scroll, selection, scrollbar) after the
  overlay closed in fullscreen mode. The overlay now only manages mouse
  reporting when tui.mode is regular; fullscreen pi owns the mouse and
  forwards wheel input to the focused overlay.
- Horizontal trackpad wheel events (SGR buttons 66/67) were misread as
  vertical scroll, so diagonal swipes yanked the transcript up three
  lines and broke follow; subsequent wheel-down events snapped it back
  to the bottom, producing visible bounce at the bottom. Only buttons
  64/65 scroll now, other mouse events are consumed without leaking
  into the input, and scroll offsets are clamped at input time so
  no-op scrolls no longer trigger redundant repaints.

Also adds PI_ADVISOR_DEBUG_SCROLL to capture the raw input stream for
terminal-specific scroll diagnosis, plus a BDD regression scenario that
fails on the old misreading.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21da344d9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread e2e/features/tui-overlay.feature
kkkiio added 3 commits August 31, 2026 16:11
Pi 0.84 RPC message_update events carry assistantMessageEvent deltas
without the accumulated message, so the visibility step now reassembles
text_delta content instead of matching on event.message.
The variable holds a log file path (GIT_TRACE-style) and captures all
overlay input, not just scroll events; name it after the artifact so
future debug capture points share the same log.
Fullscreen pi enables button-motion mouse tracking, which tmux reports
via mouse_any_flag rather than mouse_standard_flag; add a matching
assertion helper. The new scenario opens and closes the overlay under
--tui-mode fullscreen and requires pi's mouse reporting to survive,
which fails when the overlay writes mouse-disable sequences itself.
@kkkiio

kkkiio commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 0b76c612fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kkkiio
kkkiio merged commit 2a5e481 into main Aug 31, 2026
1 check 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