feat(power): add site patterns, clean links, Markdown links, and group names#36

open5
main
feat/power-logic-156
opened15h agobyKKainoa Newton
View on GitHubTwo-way sync enabledPR last imported 1h ago

Problem

Plan 07 (power features) needs four small pieces of pure logic before its hooks can land, about day 16, after Core's action table:

  • a shared site matcher, for link routing and site styles;
  • a clean-link strip table, for Shift+Cmd+C;
  • Copy as Markdown;
  • tab-group naming.

They can be written and unit-tested now, with no browser hooks.

Change

Three rac patches in patches/rac/power/. Nothing calls this code yet.

  • site-pattern.patch: rac::SitePattern (chrome/browser/rac/site_pattern/).
    • "Domain is": the host plus its subdomains, matched on label boundaries and case-insensitively. It refuses ICANN suffixes like com or co.uk through the registrable-domain helper, and allows private suffixes like github.io on purpose. It accepts *.host.
    • "URL contains": a case-insensitive substring of the canonical address.
    • Only http(s) pages match. ForSiteOf() gives the "Always open / Boost this site" pattern.
    • Values loaded from prefs are re-checked, so a hand-edited pref can't bypass the input checks.
  • clean-links.patch:
    • rac::CleanLink(), based on Stedding's L2 table (BSD-3). It drops utm_*, ad-click ids, and share ids on known hosts. Every other parameter keeps its order and its byte-exact encoding, the fragment is untouched, and only http(s) addresses change.
    • rac::MarkdownLink() writes [title](clean url), escaped so it always renders as exactly one link.
    • The one upstream hunk is the dep line in chrome/browser/BUILD.gn that loads these targets.
  • group-names.patch: rac::AutoGroupName(), Ardia's deterministic rule ported to C++ (Apache-2.0). The host's name comes from the public suffix list, and IDN hosts are shown in Unicode.

Borrowed code sits in chrome/browser/rac/power/third_party/{stedding,ardia}/ with README.chromium, LICENSE, and NOTICE, so about:credits lists it. tools/licenses/licenses.py parses both.

Net-diff hunks (D17): +1 (chrome/browser/BUILD.gn). Everything else is new rac-owned files.

Verification

  • rac_power_unittests: 106 of 106 pass in a real Chromium 156 build (base-156-2, through build-queue.sh). They include the plan's acceptance cases:
    • https://x.com/a?utm_source=y&id=3#c copies as https://x.com/a?id=3#c;
    • three GitHub PR tabs give the group name "GitHub";
    • Ardia's four test cases, ported one for one;
    • a must-not-change case for every strip-table name, including working look-alikes such as Google Calendar eid and Yandex clid.
  • he validate series is clean.
  • Reviews:
    • a hill-climb council (Sonnet and Devin SWE-2 Max), with no blocking findings; six confirmed findings were fixed;
    • a fresh Opus final review, whose two should-fix items and three nits were fixed;
    • /code-review, whose seven confirmed items were fixed. Two cost items were left for the hooks: PageOf splitting a title again, and Matches() copying the URL.
  • Nothing is user-visible, so there are no screenshots.

This PR is stacked on sync/helium-0.20.1.1. Retarget it to main once the sync merges (D62); it doesn't merge before then.

Model and tool: Claude Opus 5.5 (lead, judge, final review) in Claude Code, with Claude Sonnet 5.5 and Devin SWE-2 for tests and fixes.

🤖 Generated with Claude Code


Devin Review


Note

Low Risk New, untested-in-UI library code with no runtime hooks yet; URL/query handling is localized and heavily unit-tested, with no auth or network behavior changes.

Overview Introduces pure logic under chrome/browser/rac/power/ and chrome/browser/rac/site_pattern/ for upcoming power features (copy clean link, copy as Markdown, tab-group naming, per-site rules). The only upstream wiring change is adding //chrome/browser/rac/power to chrome/browser/BUILD.gn; nothing in the browser calls these APIs yet.

SitePattern supports “domain is” (host + subdomains, with validation that blocks bare ICANN suffixes and re-checks prefs on load) and “URL contains” (case-insensitive substring of the canonical http(s) spec), plus ForSiteOf() to derive a site’s default domain pattern.

CleanLink() (Stedding-derived, BSD-3 in third_party/stedding/) strips tracking query params on http(s) URLs only, preserving non-tracker encoding/order and fragments. MarkdownLink() builds [label](destination) using the cleaned URL with CommonMark-safe escaping for labels and destinations.

AutoGroupName() / related helpers (Ardia-derived, Apache-2.0 in third_party/ardia/) deterministically name tab groups from titles and hosts, using the public suffix list for host labels and Unicode for IDNs.

All behavior is covered by rac_power_unittests (aggregating markdown, clean-link, group-name, and site-pattern tests). Third-party trees include README.chromium and license files for credits.

Reviewed by Cursor Bugbot for commit e970b2ceeb616de7c5506c0716398c3dff273629. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Adds the pure logic and unit tests for four upcoming power features — site pattern matching, clean-link copying, Copy as Markdown, and tab-group naming. Nothing calls this code yet, so there's no user-visible change.

New Features

  • rac::SitePattern matches "domain is" (host plus subdomains, rejecting ICANN suffixes like com, accepting *.host) or "URL contains" for http(s) pages only, and refuses typed sites with a broken scheme.
  • rac::CleanLink drops tracking, ad-click, and share parameters on known hosts, including _ga, _gl, and mibextid on facebook.com and si on youtube-nocookie.com, keeping every other parameter's order and byte-exact encoding, and leaving fragments untouched.
  • rac::MarkdownLink writes [title](clean url), percent-encoding < and > in destinations and escaping entity-like & and spaces kept by data: and javascript: addresses, so it renders as exactly one link.
  • rac::AutoGroupName names a tab group from the host's registrable domain, showing IDN hosts in Unicode and keeping non-Latin page titles.
  • Borrowed code from Stedding (BSD-3) and Ardia (Apache-2.0) sits in third_party/ with license files, so about:credits lists it.
  • All 106 rac_power_unittests pass, including must-not-change cases for every strip-table name and the plan's acceptance cases.

Written for commit e970b2ceeb616de7c5506c0716398c3dff273629. Summary will update on new commits.

View guided diff Turn on auto-fix

Checks

2 failing · 7 successful · 2 neutral · 1 skipped
Some checks failed

Failing2

  • pullfrogGitHub
    Failed
  • VercelGitHub
    Failed
e970b2c
Synced from GitHub

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

External image Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e2fad565-b325-4c0d-a40a-5417d59a769e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Synced from GitHub

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: a5ea60a3-586f-496c-bd03-8183ab839e93)

Synced from GitHub

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge once its base-branch requirement is satisfied.

Summary

Adds three patches with pure helpers for site patterns, clean links, Markdown links, and tab-group names.

  • Link helpers remove tracking details and format one Markdown link.
  • Tab groups can use their shared site and page titles as names.
  • Site rules check pages by host or address text.

Reviews (1) · Last reviewed commit: "refactor(power): split the logic patch i..." · Reviewed by Greptile

Synced from GitHub

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 816c23cc-ea2d-477c-8547-2d19d6e5ee12)

Added 4 commits

  • refactor(power): split the logic patch into clean links, group names, and site patterns41bfd6f
  • test(power): add edge-case tests for links, sites, and group namesa7e8bc9
  • fix(power): close review findings in Markdown links and site patternsa92ce48
  • feat(power): add site matching, clean links, Markdown links, and group namesd972654
Synced from GitHub

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 4436fe84-bf29-4b17-b192-585352c62c95)

Added 1 commit

  • fix(power): address review of PR #36e970b2c
Synced from GitHub

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: aa36c30e-55cc-4973-8e52-d511ec1d2dfe)