Skip to content

fix(desktop): read icon links from an HTML rel token list - #2474

Merged
arul28 merged 2 commits into
mainfrom
fix/favicon-rel-tokens
Nov 23, 2026
Merged

arul28 merged 2 commits into
mainfrom
fix/favicon-rel-tokens

Conversation

@arul28

@arul28 arul28 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Why

HTML's rel is an unordered, whitespace-separated token list, but ADE matched only the exact strings icon and shortcut icon. A project declaring <link rel="icon shortcut" href="/brand/logo.svg">, rel="Icon<TAB>shortcut", or the __root.tsx object form rel: "icon shortcut" got no icon when the file lived outside the direct candidate scan. The old regex also wrongly matched rel="icon's".

Same defect class as pingdotgg/t3code#41203, proven with an out-of-tree driver against ADE's real module.

What changed

  • Any icon token in the quoted rel value marks an icon link, in both the HTML-tag and object-literal forms.
  • The href capture, lookahead structure, fallback order, containment and caches are unchanged.
  • apple-touch-icon, mask-icon and fluid-icon still do not match, and rel="icon's" no longer does.

Evidence

  • Out-of-tree driver on unmodified code: 5/9 cases pass; rel="icon shortcut", rel="Icon<TAB>shortcut", object rel: "icon shortcut" return null, and rel="icon's" wrongly resolves. Against the patched module: 9/9 pass.
  • projectIconResolver.test.ts: 25 pass; 2 fail identically on unmodified HEAD in this Windows environment (file-mode assertion, symlink EPERM), not caused by this change.
  • Desktop and CLI typechecks pass.

Not checked

Not opened in a running app with a project whose only icon is a token-list declaration; the driver exercises the same resolver entry point. Full CI matrix not run locally.

🤖 Generated with Claude Code

ADE   Open in ADE  ·  fix/favicon-rel-tokens branch  ·  PR #2474


Devin Review

RetriggerView in GreptileConfidence Score: 4/5

Fix the eager object search before merging because icon lookup can stall ADE for seconds.

Fix All in Claude CodeFindings

  1. P1 Icon lookup freezes ADE ▶
  2. P2 Token-list cases lack coverage ▶
Fix with agent prompt
### Issue 1
apps/desktop/src/main/services/projects/projectIconResolver.ts:99-101
`extractIconHrefs` now runs `LINK_ICON_OBJ_RE` over the whole file before the caller can use a valid HTML link. When the file has no `}` or object-style `rel:` field, the regex scans the remaining text again at each position.

An 80 KB HTML input with a valid first icon link took about 2.24 seconds, versus under 1 ms for the previous extraction path. This runs synchronously in Electron's main process, so opening such a project stalls other app requests. Yield hrefs lazily so the caller can stop after a usable HTML link, or limit the object search to individual objects.

### Issue 2
apps/desktop/src/main/services/projects/projectIconResolver.test.ts:75-90
Both new success cases put lowercase `icon` first and use a space. They do not exercise the preceding-token branch in `ICON_REL_VALUE`, tabs, mixed case, or single-quoted values. Those paths could break while these tests still pass.

Add table-driven cases such as `rel="shortcut Icon"`, `rel="Icon\tshortcut"`, and single-quoted values, including the object form, so the committed tests cover the behavior described by this fix.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR reads rel as a token list and tries later icon links when earlier ones cannot be used.

  • Project icon lookup finds token-list icons and skips unusable links.

Reviews (2) · Last reviewed commit: "fix(desktop): try every icon link so one..." · Reviewed by Greptile

A project whose only icon was declared through a token-list rel value showed
the generic placeholder: the icon resolver compared rel as a literal string
(`icon` or `shortcut icon`), so <link rel="icon shortcut">, a tab-separated
variant, and the { rel: "icon shortcut", href } __root.tsx head-config form
never matched, and the declared icon was never resolved even when the file
existed. The same regex accepted a mismatched closing quote, so
rel="icon's" wrongly resolved an icon. Parse rel as the unordered,
whitespace-separated token list the HTML spec defines, in both the HTML and
object forms, keeping apple-touch-icon, mask-icon and fluid-icon unmatched.

Proof: pre-fix, an out-of-tree driver bundling the real module was 5/9
(rel="icon shortcut", rel="Icon<TAB>shortcut" and the object form returned
null while rel="icon's" wrongly resolved), and the focused test failed with
"expected null to be .../public/brand/logo.svg". Post-fix: driver 9/9, and
the extended case in projectIconResolver.test.ts passes (25 passed). The two
other failures in that file also fail on unmodified HEAD on this Windows
machine (file-mode bits and symlink EPERM) and are unrelated. Desktop and
ade-cli typechecks pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f263fed and ea7efb2.

Files selected for processing: 2

  • apps/desktop/src/main/services/projects/projectIconResolver.test.ts
  • apps/desktop/src/main/services/projects/projectIconResolver.ts
  • 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 on lines +75 to +90
// `rel` is an unordered, whitespace-separated token list; any `icon` token
// marks an icon link, wherever it sits in the list.
const tokenListRoot = makeProjectRoot();
writeFile(tokenListRoot, "index.html", '<link rel="icon shortcut" href="/brand/logo.svg">');
const tokenListIconPath = writeFile(tokenListRoot, "public/brand/logo.svg", "<svg>brand</svg>");
expect(resolveProjectIconPath(tokenListRoot)).toBe(tokenListIconPath);

// The same token list in the `__root.tsx` head-config object form.
const objectRoot = makeProjectRoot();
writeFile(
objectRoot,
"app/routes/__root.tsx",
'export const Route = { head: () => ({ links: [{ rel: "icon shortcut", href: "/brand/logo.svg" }] }) };',
);
const objectIconPath = writeFile(objectRoot, "public/brand/logo.svg", "<svg>brand</svg>");
expect(resolveProjectIconPath(objectRoot)).toBe(objectIconPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Token-list cases lack coverage

Both new success cases put lowercase icon first and use a space. They do not exercise the preceding-token branch in ICON_REL_VALUE, tabs, mixed case, or single-quoted values. Those paths could break while these tests still pass.

Add table-driven cases such as rel="shortcut Icon", rel="Icon\tshortcut", and single-quoted values, including the object form, so the committed tests cover the behavior described by this fix.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/services/projects/projectIconResolver.test.ts
Line: 75-90

Comment:
**Token-list cases lack coverage**

Both new success cases put lowercase `icon` first and use a space. They do not exercise the preceding-token branch in `ICON_REL_VALUE`, tabs, mixed case, or single-quoted values. Those paths could break while these tests still pass.

Add table-driven cases such as `rel="shortcut Icon"`, `rel="Icon\tshortcut"`, and single-quoted values, including the object form, so the committed tests cover the behavior described by this fix.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +80 to +87
const ICON_REL_VALUE = String.raw`(?:"(?:[^"]*[\t\n\f\r ])?icon(?=[\t\n\f\r "])|'(?:[^']*[\t\n\f\r ])?icon(?=[\t\n\f\r ']))`;
const LINK_ICON_HTML_RE = new RegExp(
String.raw`<link\b(?=[^>]*\brel=${ICON_REL_VALUE})(?=[^>]*\bhref=["']([^"'?]+))[^>]*>`,
"i",
);
const LINK_ICON_OBJ_RE = new RegExp(
String.raw`(?=[^}]*\brel\s*:\s*${ICON_REL_VALUE})(?=[^}]*\bhref\s*:\s*["']([^"'?]+))[^}]*`,
"i",

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.

🟡 Unusable icon link hides local fallback

LINK_ICON_HTML_RE and LINK_ICON_OBJ_RE now pick an earlier multi-token icon link even when its target is unusable. resolveProjectIconPath skips the rest of the file after rejecting that target. The later local icon no longer appears.

Learn more

ADE checks well-known icon paths first, then scans selected project source files for icon declarations. extractIconHref returns just one href per file. An earlier multi-token declaration that the old matcher passed over now becomes that one href. resolveProjectIconPath rejects non-local or unusable targets but does not try another declaration in the same file.

Example: A project with no well-known icon declares rel="icon shortcut" with an HTTPS CDN URL before rel="icon" with /brand/product.svg. The previous matcher returned the local SVG. The new matcher returns the CDN URL, which ADE rejects, and the tab falls back to its default icon if no other source provides one.

Recommended fix: Yield candidate hrefs from both supported source forms. In resolveProjectIconPath, continue to the next href after a locality, containment, extension, or size rejection; keep the first usable path and retain the current priority of well-known icons and source files.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

…e icon

Review finding on PR #2474: widening the rel match made a previously ignored
first icon link win extractIconHref, but only that one href was tried, so a
link pointing at a missing file, a CDN URL or a data: URL masked a later
usable icon that the old exact `icon`/`shortcut icon` pattern still resolved.

extractIconHrefs now collects every icon href in source order (HTML links,
then head-config objects), and resolveProjectIconPath tries each through the
existing isLocalIconHref / findExistingFile / supported / inlineable checks.
The proof test covers the fallback in both forms; it fails on the pre-fix
source (null instead of the later icon) and passes with the fix.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Comment on lines +99 to +101
for (const match of source.matchAll(LINK_ICON_OBJ_RE)) {
if (match[1]) hrefs.push(match[1]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Icon lookup freezes ADE

extractIconHrefs now runs LINK_ICON_OBJ_RE over the whole file before the caller can use a valid HTML link. When the file has no } or object-style rel: field, the regex scans the remaining text again at each position.

An 80 KB HTML input with a valid first icon link took about 2.24 seconds, versus under 1 ms for the previous extraction path. This runs synchronously in Electron's main process, so opening such a project stalls other app requests. Yield hrefs lazily so the caller can stop after a usable HTML link, or limit the object search to individual objects.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/services/projects/projectIconResolver.ts
Line: 99-101

Comment:
**Icon lookup freezes ADE**

`extractIconHrefs` now runs `LINK_ICON_OBJ_RE` over the whole file before the caller can use a valid HTML link. When the file has no `}` or object-style `rel:` field, the regex scans the remaining text again at each position.

An 80 KB HTML input with a valid first icon link took about 2.24 seconds, versus under 1 ms for the previous extraction path. This runs synchronously in Electron's main process, so opening such a project stalls other app requests. Yield hrefs lazily so the caller can stop after a usable HTML link, or limit the object search to individual objects.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

@arul28
arul28 merged commit d9a5359 into main Nov 23, 2026
28 checks passed
@arul28
arul28 deleted the fix/favicon-rel-tokens branch November 23, 2026 17:11
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.

1 participant