From 0dce44e2c802ef7c2c8307c26e6968b3d1a20cb3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 13:07:11 +0000 Subject: [PATCH 1/7] Add Svelte tooltip wrapper and use it in related issues count Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/30cda529-0c48-4d53-9f76-c445b4b5dae8 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- source/helpers/related-issues-count.svelte | 16 +++++-- source/helpers/tooltipped.svelte | 52 ++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 source/helpers/tooltipped.svelte diff --git a/source/helpers/related-issues-count.svelte b/source/helpers/related-issues-count.svelte index d5dcbbae103b..c04ec8d4d6a5 100644 --- a/source/helpers/related-issues-count.svelte +++ b/source/helpers/related-issues-count.svelte @@ -3,6 +3,7 @@ import pluralize from './pluralize.js'; import getOpenRelatedIssuesCount from './related-issues-count.js'; import {getFeatureRelatedIssuesUrl} from './rgh-links.js'; + import Tooltipped from './tooltipped.svelte'; type Labels = { single: string; @@ -25,24 +26,31 @@ const countPromise = $derived.by(() => getOpenRelatedIssuesCount(featureId)); -{#snippet linked(text: string)} +{#snippet linked(text: string, id: string, labelledBy: string)} {#if linkify} {text} {:else} - {text} + {text} {/if} {/snippet} {#await countPromise} {#if labels.loading} - {@render linked(labels.loading)} + {labels.loading} {/if} {:then count} {#if count > 0 || labels.zero !== undefined} - {@render linked(pluralize(count, labels.single, labels.plural, labels.zero))} + {@const label = pluralize(count, labels.single, labels.plural, labels.zero)} + + {#snippet children(id: string, labelledBy: string)} + {@render linked(label, id, labelledBy)} + {/snippet} + {/if} {/await} diff --git a/source/helpers/tooltipped.svelte b/source/helpers/tooltipped.svelte new file mode 100644 index 000000000000..b22c5348856c --- /dev/null +++ b/source/helpers/tooltipped.svelte @@ -0,0 +1,52 @@ + + +{@render children(targetId, tooltipId)} + From 76c52342b268e33d770c6306bb75a37128907a7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 13:11:10 +0000 Subject: [PATCH 2/7] Fix Svelte lint issues in new tooltipped helper Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/30cda529-0c48-4d53-9f76-c445b4b5dae8 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- source/helpers/tooltipped.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/helpers/tooltipped.svelte b/source/helpers/tooltipped.svelte index b22c5348856c..8ff7af0c3879 100644 --- a/source/helpers/tooltipped.svelte +++ b/source/helpers/tooltipped.svelte @@ -1,4 +1,6 @@ -{#snippet linked(text: string, id: string, labelledBy: string)} +{#snippet linked(text: string, id: string, tooltipId: string)} {#if linkify} {text} {:else} - {text} + {text} {/if} {/snippet} @@ -60,8 +60,8 @@ {#if count > 0 || labels.zero !== undefined} {@const label = pluralize(count, labels.single, labels.plural, labels.zero)} - {#snippet children(id: string, labelledBy: string)} - {@render linked(label, id, labelledBy)} + {#snippet children(id: string, tooltipId: string)} + {@render linked(label, id, tooltipId)} {/snippet} {/if} From 6a8e9f7f1348d96ea09c0ff32a753b91a0ccb7ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 13:34:51 +0000 Subject: [PATCH 6/7] Use addToolTip effect and remove duplicated Svelte tooltip component Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/5e0217e7-1937-409c-b11f-4c6a8ad76bf0 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- source/helpers/related-issues-count.svelte | 36 ++++++--------- source/helpers/tooltipped.svelte | 54 ---------------------- 2 files changed, 13 insertions(+), 77 deletions(-) delete mode 100644 source/helpers/tooltipped.svelte diff --git a/source/helpers/related-issues-count.svelte b/source/helpers/related-issues-count.svelte index c32822267f95..f7623de9f55b 100644 --- a/source/helpers/related-issues-count.svelte +++ b/source/helpers/related-issues-count.svelte @@ -3,7 +3,7 @@ import pluralize from './pluralize.js'; import getOpenRelatedIssuesCount from './related-issues-count.js'; import {getFeatureRelatedIssuesUrl} from './rgh-links.js'; - import Tooltipped from './tooltipped.svelte'; + import addToolTip from './tooltip.js'; type Labels = { single: string; @@ -24,45 +24,35 @@ getFeatureRelatedIssuesUrl(featureId).href ); const countPromise = $derived.by(() => getOpenRelatedIssuesCount(featureId)); - -{#snippet linked(text: string, id: string, tooltipId: string)} - {#if linkify} - {text} - {:else} - {text} - {/if} -{/snippet} + function setTooltip(node: globalThis.HTMLElement, content?: string): void { + if (content) { + addToolTip(content, node); + } + } + -{#snippet linkedWithoutTooltip(text: string)} +{#snippet linked(text: string, openIssuesTooltip?: string)} {#if linkify} {text} {:else} - {text} + {text} {/if} {/snippet} {#await countPromise} {#if labels.loading} - {@render linkedWithoutTooltip(labels.loading)} + {@render linked(labels.loading)} {/if} {:then count} {#if count > 0 || labels.zero !== undefined} {@const label = pluralize(count, labels.single, labels.plural, labels.zero)} - - {#snippet children(id: string, tooltipId: string)} - {@render linked(label, id, tooltipId)} - {/snippet} - + {@const openIssuesTooltip = pluralize(count, '1 open issue', '$$ open issues', 'No open issues')} + {@render linked(label, openIssuesTooltip)} {/if} {/await} diff --git a/source/helpers/tooltipped.svelte b/source/helpers/tooltipped.svelte deleted file mode 100644 index 006e4e44317e..000000000000 --- a/source/helpers/tooltipped.svelte +++ /dev/null @@ -1,54 +0,0 @@ - - -{@render children(targetId, tooltipId)} - From 39ae1b35a15517c47fa0a798f31243d63b4da95a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 13:37:34 +0000 Subject: [PATCH 7/7] Harden tooltip action lifecycle in related issues count Agent-Logs-Url: https://github.com/refined-github/refined-github/sessions/5e0217e7-1937-409c-b11f-4c6a8ad76bf0 Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- source/helpers/related-issues-count.svelte | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/source/helpers/related-issues-count.svelte b/source/helpers/related-issues-count.svelte index f7623de9f55b..33f0d214a963 100644 --- a/source/helpers/related-issues-count.svelte +++ b/source/helpers/related-issues-count.svelte @@ -25,10 +25,32 @@ ); const countPromise = $derived.by(() => getOpenRelatedIssuesCount(featureId)); - function setTooltip(node: globalThis.HTMLElement, content?: string): void { - if (content) { - addToolTip(content, node); - } + function tooltipAction(node: globalThis.HTMLElement, content?: string) { + let tooltip: globalThis.HTMLElement | undefined; + + const apply = (value?: string): void => { + tooltip?.remove(); + tooltip = undefined; + if (!value) { + return; + } + + addToolTip(value, node); + const tooltipId = node.getAttribute('aria-labelledby'); + const potentialTooltip = tooltipId && globalThis.document.querySelector(`#${tooltipId}`); + if (potentialTooltip?.matches('tool-tip')) { + tooltip = potentialTooltip; + } + }; + + apply(content); + + return { + update: apply, + destroy() { + tooltip?.remove(); + }, + }; } @@ -38,10 +60,10 @@ href={relatedIssuesHref} data-turbo-frame="repo-content-turbo-frame" class={excludeFromDomTextExtraction} - use:setTooltip={openIssuesTooltip} + use:tooltipAction={openIssuesTooltip} >{text} {:else} - {text} + {text} {/if} {/snippet}