Skip to content

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

Merged
marcoscaceres merged 5 commits into
mainfrom
fix/overloaded-functions
Jun 30, 2026
Merged

fix(xref/ui): disambiguate overloaded method signatures in search results#495
marcoscaceres merged 5 commits into
mainfrom
fix/overloaded-functions

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Detect IDL entries that would render the same citation (overloaded methods) and embed their parameters from the URI fragment, e.g. {{Window/postMessage(message, options)}}. Reduced from #495 to just this and stacked on the escaping PR #528; also drops Map.prototype.getOrInsert (Baseline only since Feb 2026). 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

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 overloaded WebIDL entries that share the same suggested citation text and display additional parameter information to help users tell results apart (addressing ambiguity like Window/postMessage() overloads).

Changes:

  • Detect “overloaded” (duplicate-citation) IDL results within a search result set.
  • Extract a parameter-list hint from WebIDL-style fragment IDs (e.g., #dom-window-postmessage-...).
  • Render the hint alongside the citation as <small>(...)</small>.

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

Comment thread static/xref/script.js Outdated
@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

@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 Outdated
<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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The click-to-copy interaction this comment refers to is no longer part of this PR — it moved to #529. There, the citation is wrapped in a real <button type="button" class="cite-cell">, so the <td> keeps its native cell role. This PR now only renders the disambiguation hint and leaves the cell as plain <td>${cite}</td>, so there is no table-cell-role regression here. Safe to resolve.

Comment thread static/xref/script.js
@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
marcoscaceres force-pushed the fix/overloaded-functions branch from 6c16594 to 3a7a9b1 Compare June 24, 2026 13:50
@marcoscaceres
marcoscaceres requested a review from sidvishnoi June 24, 2026 13:51
@marcoscaceres
marcoscaceres changed the base branch from main to fix/xref-escape-cite June 24, 2026 13:51
Comment thread tests/static/xref/disambiguation.test.js Outdated
Comment thread tests/static/xref/disambiguation.test.js Outdated
Base automatically changed from fix/xref-escape-cite to main June 26, 2026 13:45
marcoscaceres and others added 5 commits June 30, 2026 11:31
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
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>.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@marcoscaceres
marcoscaceres force-pushed the fix/overloaded-functions branch from f2f9cfc to 805b4ac Compare June 30, 2026 01:32
@marcoscaceres
marcoscaceres merged commit 7bbcf4e into main Jun 30, 2026
3 checks passed
@marcoscaceres
marcoscaceres deleted the fix/overloaded-functions branch June 30, 2026 04:47
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