Skip to content

fix(ai-chat-turbo-engine): keep the peek on row menus, show the built version, and pass a soft break - #279

Merged
CYoJkoY merged 4 commits into
mainfrom
issue/278-peek-handoff-version-soft-enter
Dec 4, 2026
Merged

CYoJkoY merged 4 commits into
mainfrom
issue/278-peek-handoff-version-soft-enter

Conversation

@CYoJkoY

@CYoJkoY CYoJkoY commented Dec 4, 2026

Copy link
Copy Markdown
Owner

问题

ai-chat-turbo-engine 的三处缺陷,Closes #278。

  1. 悬停探出被历史行二级菜单打断 — 站点把历史行菜单挂在 body 或面板旁的定位包装里,多数没有 role,探出只认导轨子树与 popover 选择器,指针一进菜单就当作离开,隐藏延时随即收回面板;再往下一层的子菜单同样丢失。
  2. 设置面板版本号恒为 0.0.0 — 面板副标题通过 GM_info 取版本,而脚本以 @grant none 运行,页面上没有管理器 API,于是永远落到 0.0.0,与头部声明的 0.23.17 不符。
  3. 元宝 Shift + Enter 后输入标点会重复 — 软换行产生的 insertParagraph 不带修饰键信息,被「裸 Enter 兜底发送」当成发送接管并 preventDefault();站点 Quill 模型已按换行更新,DOM 与模型错位,随后第一个字符被插入两次。

修复

  • sidebar-peek.ts:探出认领从面板直接走进的浮动盒(peekLayers)。交接窗口 SIDEBAR_PEEK_HANDOFF_MS = 500,以「最后一次停在导轨或已认领层上」为基准计时,因此从已认领层离开的那一刻也能续上交接(子菜单常被 portal 到几像素外的兄弟包装里,命名事件来自两框之间的空隙)。视口级固定外壳(宽 ≥70% 且高 ≥60%)被拒绝,页面正文不会把面板钉住;层被站点拆除(isConnected 为假)即从集合中丢弃。指针进入、离开、按下、点击四条路径统一按「导轨子树 ∪ 已认领层」判定归属。
  • 版本号:tools/build-lib.ts 用 esbuild define 把 __SCRIPT_VERSION__ 注入成 meta.ts 的 version,与头部 @version 同源;lifecycle.ts 只读该常量,GM_info 读取与 0.0.0 回退一并移除。新增 src/build-constants.d.ts 声明,测试由 vitest.config.ts 提供占位值。
  • send.ts:keydown 阶段记住输入框内的 Shift + Enter,它引起的 insertParagraph 在 200ms 内直接放行;绕过 keydown 的裸 Enter 仍按原逻辑发送,窗口过期后也仍发送。

边界

  • 交接窗口有界:指针在悬停结束很久之后才走进去的浮层仍属于页面,不会把探出钉住(有测试)。
  • 裸 Enter 发送路径不变;仿真键盘事件与 IME 路径不变。
  • 版本注入只改构建期常量,头部渲染与 meta.ts 仍是唯一来源。

测试

  • pnpm check 全绿:typecheck + 969 项测试 + 构建。
  • 新增:二级菜单停驻超过交接窗口后进入、跨空隙进入子菜单、视口级固定壳不被认领、产物体内不出现 0.0.0 且无残留 GM_info、面板副标题显示构建版本、Shift + Enter 后段落放行与窗口过期后仍发送。

The peek only knew the rail subtree and the popover selector. History row
menus are portaled next to the panel with no role annotation, so walking
onto one counted as leaving and the hide delay collapsed the panel mid
gesture; the submenu that hangs off that menu lost it one level deeper.

The peek now adopts the out-of-flow wrapper the pointer reaches straight
from the panel, within a bounded 500ms hand-off measured from the last
contact with the rail or an adopted layer, so a flyout the user walks into
long afterwards still belongs to the page. Viewport-sized fixed shells are
rejected so page content never pins the peek, and an adopted layer is
dropped as soon as the site tears it down.
The panel subtitle read the version from GM_info through the userscript
globals helper. This script runs with @grant none, so no manager API exists
on the page and the 0.0.0 fallback rendered on every platform while the
header declared 0.23.17.

The build now passes the metadata version through esbuild define, the same
source the header is rendered from, and lifecycle reads that constant. A
build test pins the artifact to meta.ts and to the absence of both 0.0.0
and a leftover GM_info read; a HUD test pins the subtitle.
…uanbao

The paragraph net on beforeinput cannot see modifier keys. A soft line break
is inserted as insertParagraph, so the net took it for a bare Enter, sent,
and called preventDefault after Quill had already committed the newline to
its model. The DOM and the model then disagreed and the next typed character
was inserted twice, which reproduced as a doubled punctuation mark.

The keydown stage now remembers a Shift+Enter inside the composer and lets
the paragraph insertion it causes through for 200ms. A bare Enter that
bypasses keydown still sends, including once that window has passed.
Records the three repairs in the version log: the peek keeps a history row
menu and its submenu inside the panel, the settings panel shows the version
the header declares, and a Shift+Enter soft break no longer doubles the next
punctuation on Yuanbao.
@CYoJkoY
CYoJkoY merged commit e15fc4c into main Dec 4, 2026
1 check passed
@CYoJkoY
CYoJkoY deleted the issue/278-peek-handoff-version-soft-enter branch December 4, 2026 11:11
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.

Sidebar peek collapses on the way into a history row menu, and the settings panel shows version 0.0.0

1 participant