Skip to content

fix(chat): 模型开始运行即清提示气泡,截断后丢弃失效摘要 - #14

Merged
tall-1997 merged 1 commit into
mainfrom
fix/bubble-delete-slice
Oct 14, 2026
Merged

tall-1997 merged 1 commit into
mainfrom
fix/bubble-delete-slice

Conversation

@tall-1997

Copy link
Copy Markdown
Owner

做了什么

两个上下文/提示修复:

  1. 重试/中断/错误气泡在模型开始运行后消失:旧代码里 clearInlineError() 清的是"最后一条 assistant 消息",而 runAgentLoop 启动时会先插入新的占位气泡成为最后一条——导致旧消息上的错误贴纸要等到第一个流式增量到达才被防御性清掉,中间有可见窗口。现在在插入新占位气泡之前先清旧贴纸,让气泡在模型开始运行的瞬间就消失。

  2. 长按"从此处删除"/重试后不再残留被删内容的记忆:deleteFromMessage/retryFromMessage 截断后重建了 agentHistory,但没清 llmDigestLines——那是被自动 trim 出窗口的消息摘要,effectiveAgentHistory() 每次发送都会注入它。删除后其中部分消息已不存在、窗口边界也变了,旧摘要就成了"删了还在上下文里"的失效记忆。现在两条路径都丢弃该摘要(用户主动压缩的 _compactSummary 是独立存储,保留)。

测试

本机无 JDK,编译与单测交由 CI。

关于 begin 0, end 376, length 375 切片错误

我用截图(消息正文残留上次崩溃的 StringIndexOutOfBoundsException, 1047 bytes),证明是"崩溃→持久化→再崩溃"的循环)穷举了流式 markdown 渲染、块拆分、inline 解析、文本选择、offload stub 等约 40 处 substring/take/subSequence,全部有越界防护,未找到能产生该异常的无防护切片点。该异常的确切位置需要一条完整堆栈跟踪才能定位——本 PR 不含此项修复,避免无依据乱改。

… on truncate

Two context/hint fixes:

- The retry/interrupt/error sticker on the last assistant row survived
  until the first stream delta's defensive clear, because clearInlineError()
  targets the last assistant row and the new placeholder becomes that row.
  runAgentLoop now clears the stale sticker BEFORE appending the new
  placeholder, so the hint bubble disappears the moment the model starts
  running rather than after the first token lands.

- deleteFromMessage / retryFromMessage rebuilt agentHistory from the
  truncated DB tail but left llmDigestLines intact. That digest summarizes
  rows trimAgentHistory evicted — after a truncation some of those rows are
  gone and the window moved, so their summaries were stale memory of
  deleted content that effectiveAgentHistory() kept injecting on every
  turn. Both paths now drop the digest (the user-initiated _compactSummary
  is a separate store and is preserved).
@tall-1997
tall-1997 merged commit a507a88 into main Oct 14, 2026
1 check passed
@tall-1997
tall-1997 deleted the fix/bubble-delete-slice branch October 14, 2026 03:52
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