fix: improve project favicon detection for monorepos#1024
fix: improve project favicon detection for monorepos#1024ponbac wants to merge 2 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
30cac2c to
b936f17
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4a8d330eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c396c88 to
551d9f2
Compare
|
My 2c
I would add unit tests for this file rather than relying on integration tests. Since this is a new file, I would also add some solid docblocks to provide good human and AI context for the decisions being made. Hopefully the reviewers will pick that up and think it's a good idea for their code standards. |
Not sure about separating them right now, but I also feel like I agree with the unit tests, added now. Also added an explanatory comment to the |
a079d93 to
470ab3d
Compare
470ab3d to
9f02bfb
Compare
9f02bfb to
8cc9e19
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| parts.pop(); | ||
| } | ||
| return parts.filter((value) => value.length > 0); | ||
| } |
There was a problem hiding this comment.
Duplicated splitNullSeparatedPaths helper across two files
Low Severity
splitNullSeparatedPaths is duplicated between gitIgnore.ts and workspaceEntries.ts with near-identical implementations. The PR explicitly set out to extract shared logic (like filterGitIgnoredPaths and isInsideGitWorkTree) into gitIgnore.ts, but this helper was copied rather than shared. The two copies have a trivial difference (an unreachable parts.length === 0 guard in workspaceEntries.ts), and any future bug fix to one copy risks not being applied to the other.


The
XXLtag seems a little weird for this PR? It is a net +288 LoC, excluding test files.What Changed
Improve project favicon detection without introducing a broad recursive search.
Closes #1020.
Rules, in order:
Example:
/repo/favicon.svgor/repo/public/favicon.ico.<link rel="icon" ... href="...">tags or object-style{ href, rel: "icon" }declarations in a small set of common source files, then resolve that target.Example:
/repo/index.htmlpoints to/brand/logo.svg, so the route first tries/repo/public/brand/logo.svgand then/repo/brand/logo.svg.apps/andpackages/, plus other top-level directories in the requested root, using the same non-git directory ignore rules asworkspaceEntries.Example:
/repo/apps/web/public/favicon.pngor/repo/frontend/public/favicon.pngis found when the cwd is/repo.Example:
/repo/favicon.svgwins over/repo/apps/web/public/favicon.ico.I also extracted the shared gitignore probing into
apps/server/src/gitIgnore.tsso bothworkspaceEntriesandprojectFaviconRouteuse the same chunkedgit check-ignore --no-index -z --stdinfiltering. I also extracted the shared workspace directory ignore policy intoapps/server/src/workspaceIgnore.ts, soprojectFaviconRoutenow uses the same non-git skip rules asworkspaceEntrieswhen scanning nested roots instead of keeping a separate ignore list.Why
The current behavior misses common monorepo layouts where the favicon lives under an app directory instead of the repo root.
There was already an earlier PR for this in the upstream repo: #690. That version was larger and messier. This keeps the rules simple on purpose, leaving more extensive changes to project icons for trusted maintainers.
UI Changes
Not applicable.
Checklist
Note
[!NOTE]
Improve project favicon detection to support monorepos and respect .gitignore
tryHandleProjectFaviconRequestin projectFaviconRoute.ts as an Effect-based handler usingFileSystem; now prefers a root favicon, then searches nestedapps/andpackages/directories, and falls back to a built-in SVG./public/<href>and app-relative paths.filterGitIgnoredPaths(usinggit check-ignore) andisInsideGitWorkTree; ignored directories and files are skipped during favicon search and workspace indexing.FileSystem; wsServer.ts is updated to provide this, but any other callers would need the same.Macroscope summarized 8cc9e19.
Note
Medium Risk
Refactors the
/api/project-faviconroute to new Effect/FileSystem-based logic and expands its search behavior across nested directories, which could change which icon is served or impact latency in large repos. Also introduces shared git-ignore filtering used by both favicon lookup and workspace indexing, so regressions could affect file discovery when git commands behave unexpectedly.Overview
Project favicon resolution is rewritten and expanded for monorepos.
tryHandleProjectFaviconRequestis converted to an Effect-based handler usingFileSystem, now checking well-known favicon files and icon metadata in common source files, then (if needed) scanning first-level children underapps/,packages/, and other top-level directories—while still preferring a root match and falling back to the built-in SVG.Gitignore + workspace ignore rules are centralized and enforced. Adds
gitIgnore.ts(with chunkedgit check-ignore+ fail-open behavior) andworkspaceIgnore.ts, updatesworkspaceEntries.tsto use these shared helpers, and updates the HTTP server integration (wsServer.ts) plus tests to run the new Effect-based favicon route and validate gitignored/unreadable/ignored-directory behaviors.Written by Cursor Bugbot for commit 8cc9e19. This will update automatically on new commits. Configure here.