Skip to content

Fix duplicate DOM ids in chat_ui tool-call partials#802

Open
edudepetris wants to merge 2 commits into
crmne:mainfrom
edudepetris:duplicated-html-ids
Open

Fix duplicate DOM ids in chat_ui tool-call partials#802
edudepetris wants to merge 2 commits into
crmne:mainfrom
edudepetris:duplicated-html-ids

Conversation

@edudepetris

@edudepetris edudepetris commented Jun 10, 2026

Copy link
Copy Markdown

What this does

Fix #804

When an assistant message has multiple tool calls, the chat_ui tool-call partial renders each one with the same id because it uses the parent message's id instead of the individual call's id. That's invalid HTML (the id attribute must be unique in a document)

The bug only surfaces with parallel tool calls (multiple calls per message). Sequential calling produces one call per message, keeping ids naturally unique.

Use tool_call.id for the element id (it's unique and already available in the partial). Namespace ids with tool_call and tool_result prefixes to keep them distinct from message ids.

Before:

 <div id="message_78">  Called a_tool
 <div id="message_78">  Called b_tool   ← duplicate

After:

 <div id="message_tool_call_101">  Called a_tool
 <div id="message_tool_call_102">  Called b_tool   ← unique
before after
before after

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Required for new features

N/A — bug fix.

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
    • For provider changes: Re-recorded VCR cassettes (no provider changes)
    • All tests pass: bundle exec rspec
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

AI-generated code

  • I used AI tools to help write this code
  • I have reviewed and understand all generated code

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

The chat_ui tool-call partial was rendered once per tool call used
the parent message id, which caused duplicated ids when a single
assistant message contained multiple tool calls (when parellel tool
calling happens).

Use tool_call.id as the element id source so each rendered
tool-call row has a unique id. Also update id prefixes to keep
tool_call and tool_result ids distinct from message ids.
@edudepetris edudepetris marked this pull request as draft June 10, 2026 17:34
@edudepetris

edudepetris commented Jun 10, 2026

Copy link
Copy Markdown
Author

I moving this into draft until I verify that d0035b9 is working.

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.48%. Comparing base (978d5f2) to head (d0035b9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #802      +/-   ##
==========================================
+ Coverage   88.47%   88.48%   +0.01%     
==========================================
  Files         122      122              
  Lines        5898     5898              
  Branches     1405     1405              
==========================================
+ Hits         5218     5219       +1     
+ Misses        680      679       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edudepetris edudepetris marked this pull request as ready for review June 10, 2026 18:56
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] Duplicate DOM ids in chat_ui tool-call partials

1 participant