Skip to content

prevent-link-loss sveltified#9873

Draft
fregante wants to merge 4 commits into
mainfrom
prevent-link-loss-svelte
Draft

prevent-link-loss sveltified#9873
fregante wants to merge 4 commits into
mainfrom
prevent-link-loss-svelte

Conversation

@fregante

Copy link
Copy Markdown
Member

Testing

Test content:

https://github.com/refined-github/refined-github/pull/6954/commits/32d1c8b2e1b6971709fe273cfdd1f959b51e8d85
https://github.com/refined-github/refined-github/pull/6954/changes/32d1c8b2e1b6971709fe273cfdd1f959b51e8d85..5d28ba424368606c7b241840cf4386f23ce66ec3

Test URLs:

New issue form: https://github.com/refined-github/refined-github/issues/new?assignees=&labels=bug&projects=&template=1_bug_report.yml
New comment form: refined-github/sandbox#3
New review form: https://github.com/refined-github/sandbox/pull/4/files#review-changes-modal
New review comment form: https://github.com/refined-github/sandbox/pull/4/files

Screenshot

untested

@github-actions github-actions Bot changed the title prevent-link-loss sveltified AI SPAM Jul 21, 2026
@github-actions github-actions Bot closed this Jul 21, 2026
@github-actions

Copy link
Copy Markdown

This looks like an AI-generated PR, so we're preemptively closing it. If you're human and tested it, include a screenshot/video/gif of the working PR and we can reopen the PR. Don't open more PRs until this one is resolved.

@fregante

Copy link
Copy Markdown
Member Author

How the tables have turned 😔

@fregante fregante reopened this Jul 21, 2026
@fregante fregante changed the title AI SPAM prevent-link-loss sveltified Jul 21, 2026
@fregante fregante added the meta Related to Refined GitHub itself label Jul 21, 2026
@fregante

Copy link
Copy Markdown
Member Author

include a screenshot/video/gif of the working PR

sry I aven't testd yet

Copilot AI left a comment

Copy link
Copy Markdown

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 continues the “Svelte components” migration (#9810) by converting the prevent-link-loss feature’s UI from the prior delegate/React+dom-chef banner to a Svelte component, while keeping the underlying link-rewrite logic in the shared helper.

Changes:

  • Extracted isVulnerableToLinkLoss into source/github-helpers/prevent-link-loss.ts for reuse.
  • Replaced the prevent-link-loss feature’s imperative banner rendering with a mounted Svelte component per textarea.
  • Added a new prevent-link-loss.svelte component that shows a warning banner and applies the “Fix link” rewrite.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
source/github-helpers/prevent-link-loss.ts Adds a shared isVulnerableToLinkLoss helper for detecting when rewrites would change the text.
source/features/prevent-link-loss.tsx Switches the feature from delegated event handling to observe(...) + mount(...) of a Svelte banner component.
source/features/prevent-link-loss.svelte New Svelte UI for detecting vulnerable links and applying the “Fix link” replacements.

Comment thread source/features/prevent-link-loss.svelte Outdated
Comment on lines +22 to +43
function update(): void {
visible = isVulnerableToLinkLoss(field.value);
}

function fix(): void {
replaceFieldText(field, prCommitUrlRegex, preventPrCommitLinkLoss);
replaceFieldText(field, prCompareUrlRegex, preventPrCompareLinkLoss);
replaceFieldText(field, discussionUrlRegex, preventDiscussionLinkLoss);
update();
}

onMount(() => {
update();

field.addEventListener('input', update);
field.addEventListener('focus', update);

return () => {
field.removeEventListener('input', update);
field.removeEventListener('focus', update);
};
});
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants