Skip to content

fix(xref/ui): disambiguate overloaded method signatures in search results#495

Open
marcoscaceres wants to merge 12 commits into
mainfrom
fix/overloaded-functions
Open

fix(xref/ui): disambiguate overloaded method signatures in search results#495
marcoscaceres wants to merge 12 commits into
mainfrom
fix/overloaded-functions

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Detect overloaded IDL entries that produce identical citation text
  • Extract parameter names from URI fragments for disambiguation
  • Embed full parameter signature in cite text: {{Window/postMessage(message, options)}} instead of ambiguous {{Window/postMessage()}}
  • Preserve original casing from URI fragments in parameter hints
  • Group overloads per individual for context, not by entire for list

Closes #383

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ambiguous “How to Cite?” suggestions on the /xref UI when multiple WebIDL overloads share the same base citation (e.g., Window/postMessage()), by detecting duplicate IDL citations and surfacing overload-specific parameter hints derived from the URI fragment.

Changes:

  • Detects duplicated IDL citation groups and flags corresponding result rows as overloaded.
  • Adds overload hint extraction from WebIDL fragment IDs (e.g., #dom-window-postmessage-message-options).
  • Renders overload hints as <small>(...)</small> adjacent to ambiguous IDL citations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the xref frontend’s result rendering to better handle overloaded WebIDL definitions by detecting when multiple IDL results would generate the same citation text and adding a UI hint derived from the entry’s URI fragment to help users distinguish them.

Changes:

  • Add detection of “overloaded” IDL entries by grouping results that would produce identical citation text.
  • Extend IDL citation rendering to optionally append a <small> overload hint.
  • Add URI-fragment parsing to extract parameter-name hints for overloaded IDL entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the xref frontend rendering to better handle overloaded WebIDL members that currently show identical citation text in search results, aiming to reduce ambiguity for users linking via ReSpec.

Changes:

  • Adds detection of potentially overloaded/ambiguous IDL results by grouping entries that would render the same citation.
  • Extracts overload “parameter” hints from WebIDL fragment identifiers (e.g., #dom-...-param1-param2).
  • Appends overload hints as <small> text next to IDL citations when an ambiguity is detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the /xref frontend rendering logic to better distinguish overloaded WebIDL search results by detecting duplicate IDL citations and deriving parameter “hints” from the result URI fragments.

Changes:

  • Add detection of potentially overloaded IDL entries that would render identical citation strings.
  • Extract a parameter-list hint from WebIDL-style URI fragments (e.g., #dom-window-postmessage-...) for ambiguous results.
  • Render overload hints as <small>(...)</small> next to IDL citations in search results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
@marcoscaceres marcoscaceres force-pushed the fix/overloaded-functions branch from 47d5627 to c98311c Compare April 26, 2026 00:17
@marcoscaceres marcoscaceres requested a review from Copilot April 26, 2026 01:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves cross-reference search result citations for WebIDL by detecting overloaded definitions that would otherwise render with identical citation text and adding parameter hints to disambiguate them.

Changes:

  • Detect ambiguous/overloaded IDL entries in search results and mark them for disambiguation.
  • Parse URI fragments to extract overload parameter hints.
  • Render overload hints as <small> text next to citations when needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js
Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the /xref UI’s suggested citation text for overloaded WebIDL entries by detecting ambiguous “same citation text” cases and appending parameter-list hints derived from the entry’s URI fragment.

Changes:

  • Detect IDL result groups that would render identical citations and mark them as requiring disambiguation.
  • Extend IDL citation rendering to optionally append an overload hint in <small> text.
  • Add URI-fragment parsing logic to extract a readable overload hint for ambiguous IDL entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Xref search UI to detect when multiple WebIDL results would render the same citation (common with overloaded methods) and to surface URI-fragment-derived parameter hints to help users pick the right overload.

Changes:

  • Detect overloaded IDL results that would produce identical citations.
  • Extract overload “parameter list” hints from WebIDL-style #dom-... fragments.
  • Render overload hints as <small>(...)</small> alongside citations for ambiguous IDL entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the client-side xref search results UI to better disambiguate overloaded WebIDL methods whose suggested {{...}} citations would otherwise be identical, addressing ambiguity like Window/postMessage().

Changes:

  • Add detection of potentially overloaded IDL entries that would generate the same citation text.
  • Extract overload “parameter hints” from WebIDL fragment IDs and display them as <small> annotations next to ambiguous citations.
  • Extend howToCiteIDL() to optionally include overload hints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js
@marcoscaceres marcoscaceres requested a review from Copilot April 27, 2026 00:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the static Xref search UI to detect IDL results that would render the same citation text (e.g., overloaded methods) and adds disambiguation hints derived from WebIDL URI fragments.

Changes:

  • Detect “overloaded”/duplicate IDL citation groups and mark the affected entries.
  • Extend IDL citation rendering to append <small> parameter hints for ambiguous results.
  • Add logic to extract a parameter-list hint from #dom-... style URI fragments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
When multiple xref results share the same term and context (e.g.,
overloaded methods like Window/postMessage), extract parameter info
from the URI fragment to show distinct linking text suggestions.

Closes #383

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the xref search UI to detect potentially ambiguous WebIDL results caused by overloads and to surface extra disambiguation information derived from IDL fragment URIs.

Changes:

  • Detects duplicate/overloaded IDL search results and flags affected entries.
  • Extracts overload “parameter hint” text from the URI fragment for flagged results.
  • Escapes additional citation output for safer HTML rendering in some citation paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Instead of appending a <small> hint after the citation, embed the
parameter names directly inside the {{ }} brackets. This produces
copy-pasteable cite text that resolves without ambiguity, e.g.
{{Window/postMessage(message, options)}} instead of
{{Window/postMessage()}} <small>(message, options)</small>.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the xref search UI to better handle overloaded WebIDL results by detecting when multiple IDL entries would produce the same ReSpec citation and attempting to disambiguate them using parameter hints derived from the entry URI fragment.

Changes:

  • Add detection of “overloaded” IDL entries that would render identical citation text.
  • Extract overload parameter hints from WebIDL-style #dom-... fragments and apply them to the displayed IDL citation.
  • Improve HTML escaping in some citation renderers (IDL and term citations).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/xref/script.js Outdated
Comment thread static/xref/script.js Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Can you address any unresolved comments and any concerns you have?

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@copilot Can you address any unresolved comments and any concerns you have?

Addressed the remaining unresolved feedback in c9382ad:

  1. detectOverloadedEntries now groups per individual f value rather than the whole entry.for list joined. This correctly catches the overlapping-context case (e.g., one entry with for: ['Window','Worker'] and another with for: ['Window'] — the {{Window/...}} citation is now correctly flagged as ambiguous while {{Worker/...}} is not).

  2. extractOverloadHint now preserves original fragment casing for the returned hint. The function splits the hash twice — originalParts for display and lowerParts for case-insensitive prefix matching — so the parameter hint reflects the actual fragment text rather than a forced-lowercase version.

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Can you review this and fix any issues that come up?

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Can you confirm that all your comments have been addressed? Please resolve them if you’re happy. Can you fix anything outstanding from your feedback that hasn’t been addressed?

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@copilot Can you confirm that all your comments have been addressed? Please resolve them if you’re happy. Can you fix anything outstanding from your feedback that hasn’t been addressed?

All reviewer concerns are addressed. Summary of current state:

  1. HTML injection (howToCiteIDL, howToCiteTerm, howToCiteMarkup) — all now escape term and f via escapeHTML before output.innerHTML insertion (fc0a245 also fixes howToCiteMarkup which had the same pre-existing gap).

  2. Hint embedded in citation{{Window/postMessage(message, options)}} is produced directly; no <small> append.

  3. Fragment casing preservedextractOverloadHint splits into originalParts (for display) and lowerParts (for prefix matching), so hints reflect the fragment's original casing.

  4. No noisy fallback hint — returns "" when no parameter tail can be extracted after the prefix.

  5. Per-context overload detectiondetectOverloadedEntries groups per individual f value and returns a Set<"uri|forContext"> so entries only get disambiguation hints for their actually-ambiguous contexts (e.g., an entry with for: ['Window', 'Worker'] only gets a hint for Window if that's the ambiguous context).

@marcoscaceres marcoscaceres marked this pull request as ready for review April 29, 2026 03:14
An enum-value and a method with the same name/for/spec/status
would be falsely grouped as overloads. They render differently
("term" vs term()) so should not trigger disambiguation hints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@sidvishnoi sidvishnoi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract this into 3 PRs please, as it's doing 3 things?

  • Using safeTerm (security)
  • Copy to clipboard
  • Disambiguating hint for overloaded method signatures

Comment thread static/xref/script.js
<td>${entry.shortname}</td>
<td>${entry.type}</td>
<td>${cite}</td>
<td class="cite-cell" role="button" tabindex="0" title="Click to copy">${cite}</td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a <button>, so we don't lose the table-cell role either.

Comment thread static/xref/script.js Outdated
@sidvishnoi sidvishnoi changed the title fix(xref): disambiguate overloaded method signatures in search results fix(xref/ui): disambiguate overloaded method signatures in search results May 3, 2026
marcoscaceres and others added 2 commits May 4, 2026 23:21
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
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.

respec.org/xref suggests ambiguous linking text for overloaded functions

4 participants