Skip to content

fix: stop re-applying input template on message retry - #6894

Open
Qznan wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
Qznan:fix/resend-template-nesting
Open

Qznan wants to merge 1 commit into
ChatGPTNextWeb:mainfrom
Qznan:fix/resend-template-nesting

Conversation

@Qznan

@Qznan Qznan commented Sep 10, 2026

Copy link
Copy Markdown

onResend fetched the already template-filled user message content and passed it back through onUserInput, which called fillTemplateWith again. The existing dedupe (input.startsWith(output)) only catches the first re-send, so subsequent retries nested the template repeatedly.

Add a skipTemplateFill option to onUserInput and pass it from onResend, since the saved user message already stores the template-applied content.

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

  • app/store/chat.ts: 为 onUserInput 新增 skipTemplateFill 选项,当其为 true 时跳过 fillTemplateWith,直接使用传入的 content。
  • app/components/chat.tsx: onResend 在调用 onUserInput 时传入 skipTemplateFill=true,因为已保存的用户消息内容已经经过模板填充处理,重复填充会导致嵌套。

📝 补充信息 | Additional Information

  • 复现:在设置中配置非默认的输入模板后,点击用户消息或模型回复的重试按钮,原内容会被模板反复嵌套包装,每次重试嵌套一层。
  • 根因:onUserInput 每次都调用 fillTemplateWith 并把填充结果保存进 userMessage;onResend 读取已保存内容后再次走 onUserInput,于是模板被再次套用。fillTemplateWith 内部 input.startsWith(output) 的去重仅能挡住第一次,后续重试时 input 已不以原始模板开头(被嵌套结构包裹),去重失效。
  • 验证:手动连续多次点击用户消息与模型回复的重试按钮,用户内容保持稳定不再嵌套;首次发送仍正常应用输入模板;MCP 响应路径不受影响(已通过 isMcpResponse 跳过模板)。

onResend fetched the already template-filled user message content and
passed it back through onUserInput, which called fillTemplateWith again.
The existing dedupe (input.startsWith(output)) only catches the first
re-send, so subsequent retries nested the template repeatedly.

Add a skipTemplateFill option to onUserInput and pass it from onResend,
since the saved user message already stores the template-applied content.
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