Skip to content

fix(composer-prediction): make the next-message ghost actually appear - #109

Closed
HuHong-Tao wants to merge 3 commits into
MichengAI:mainfrom
HuHong-Tao:fix/composer-prediction-ghost
Closed

HuHong-Tao wants to merge 3 commits into
MichengAI:mainfrom
HuHong-Tao:fix/composer-prediction-ghost

Conversation

@HuHong-Tao

Copy link
Copy Markdown

问题

Fixes #108(同 #65 的「预测永远不出现」家族)。在 DSH 0.2.2-rc.5 + 插件 2.4.0 + deepseek-v4.1-flash 上实测,空框 next 预测有三个独立故障叠加,任意一个都会让 ghost 消失:

  1. 预算被推理吃满 —— 默认 maxOutputTokens: 220,推理模型先把预算用在思考上,finish.kind === 'max-tokens'、正文为空,predict() 返回 reason: 'empty',客户端静默。
  2. 单行答案被截成空串 —— if (finish.kind === 'max-tokens') text = text.slice(0, text.lastIndexOf('\n') + 1):单行输出没有换行,lastIndexOf 返回 -1,slice(0, 0) 把整段清空。
  3. ghost 被 composer 自己的层盖住 —— NEXT_GHOST_STYLE.zIndex = 2 与 composer 卡内层同级,元素被插入、被测量、颜色也对,但画面上看不见;续写用 zIndex: 3 所以一直正常。

改动

提交 内容
57d0352 只有流里真的出现换行时才回退到最后一个完整行;单行答案原样保留
74bd2c6 next ghost zIndex 2 → 8,continue 3 → 9(保持相对顺序)
80a6505 默认预算 220 → 1024(与 session-title-provider.ts:5 的 4096 同因)

lib/client.js、lib/composer-plugin.mjs 已按仓库习惯用 pnpm run build 重新生成,产物与源码改动一致(git diff --stat 4 文件 / +22 −8)。

实测证据

直连网关复刻预测请求(同一 prompt、effort 与预算对照):

预算 / 档位 结果
220 / low finish=length,content=null
220 / off finish=stop,有内容(1.7 s)
400 / low finish=stop,正常
1024 / low finish=stop,正常(≈5 s)

ghost 层级的判据(修复前同一次会话内):

  • document.querySelector('[data-composer-prediction]') 存在,文字就是候选原文;
  • 几何正常 x=39 y=750 w=588 h=24,display:flex、opacity:1、颜色 rgb(119,111,113);
  • 同一时刻截图里输入框是空的;输入框真实 value 一直是 ''。

修完后再实测:输入框空白,但出现候选原文 + 1/3 计数 + Tab 键帽,按 Tab 可采纳。

验证

  • pnpm run typecheck 通过;
  • pnpm run build 通过(lib 产物已更新);
  • vitest run 在本机因可选依赖 @rolldown/binding-wasm32-wasi 缺失无法启动(环境问题,与本次改动无关),麻烦 CI 跑一遍。

如果担心 1024 对慢模型增加延迟,也可以只保留前两个修复——它们各自独立成立,预算那条只是让 low 档不再必然空结果。

…uncated

A max-tokens finish with a single-line answer has no newline to slice at, so lastIndexOf returns -1 and slice(0, 0) blanks the whole candidate even though the model produced usable text. Only trim back to the last complete line when one exists.
The next-message ghost used z-index 2, the same level as the composer's own in-card layers, so it was inserted and measured but painted underneath them; the continuation ghost at z-index 3 stayed visible. Lift both so the ghost is actually shown.
With deepseek-v4.1-flash the 220-token default is consumed entirely by reasoning, so the stream ends with max-tokens and no text at all and the client silently renders nothing. 1024 leaves room for a short answer plus reasoning, matching the session-title provider that asks for 4096.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:30

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@MichengAI

Copy link
Copy Markdown
Owner

非常感谢 @HuHong-Tao 的排查分析与 PR 贡献!

PR 中提出的核心方向(默认预算调至 1024、单行输出截断回收)已在主分支通过提交 5d95b0f 和 85dfeb5 落地(同时补充了 NONE 终止判定、流式提示词回声过滤以及完整的自动化回归测试用例),并已正式打包发布于 v2.4.2。

因此关闭本 PR,再次感谢对 DSH Codex UI 的支持与贡献!

@MichengAI MichengAI closed this Nov 20, 2026
@HuHong-Tao

Copy link
Copy Markdown
Author

感谢处理,v2.4.2 已装并复测。确认 5d95b0f 的预算 1024 与截断回收、85dfeb5 的回声过滤/NONE 都生效了。

不过 PR 里第三个问题(ghost 被 composer 卡内层盖住)看起来没有包含进来:2.4.2 的 src/client/composer/ComposerPredictionOverlay.tsx 里 NEXT_GHOST_STYLE 仍是 zIndex: 2、CONTINUE_GHOST_STYLE 仍是 zIndex: 3。

刚在装好的 2.4.2 上复测(空闲会话、空输入框、等 7 秒):

  • 网关日志有请求:out=322 / reasoning=275 / effort=low / 6397 ms,即正文有约 47 tokens,服务端不是空结果;
  • 同一时刻截图里输入框是空的,没有灰字;
  • 紧接着按 Tab,候选被写进了输入框(你看看 GitHub ),说明候选数据已经到了客户端、Tab 逻辑也正常工作,只是没画出来。

这跟之前 2.4.0 上抓到的一致:幽灵元素被插入、被测量、颜色也对,但压在 composer 自己 z-index 2 的层下面。把 next 抬到 8、continue 抬到 9 后画面立刻可见(输入框真实 value 仍为空,纯绘制问题)。

要不要我单开一个只改这两行的 PR?我可以在你们的环境上再验证一遍,也能补一个「验证 ghost 已绘制」的断言。

MichengAI added a commit that referenced this pull request Nov 21, 2026
…d occlusion

The next prediction ghost was styled with zIndex: 2, which matched the
composer card's internal layer stack in some environments (e.g. macOS
desktop), causing the ghost text to be hidden behind the inner background
layer despite being present in the DOM. Elevate next to zIndex: 8 and
continue to zIndex: 9.

Refs #108, #109
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] 输入预测在推理模型路由下恒为空:maxOutputTokens=220 被思考 token 吃光,强制最低档 reasoning effort 反而打开思考

3 participants