Skip to content

fix(core): resolve exact ignored paths in fs find - #65571

Open
holny wants to merge 4 commits into
anomalyco:devfrom
holny:fix-65546-ignored-links
Open

holny wants to merge 4 commits into
anomalyco:devfrom
holny:fix-65546-ignored-links

Conversation

@holny

@holny holny commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #65546

Type of change

  • Bug fix

What does this PR do?

Inline-code file paths in the Desktop app are only rendered clickable when the file is in the workspace file index. Files excluded by ignore rules never enter either search index, so paths like .slim/deepwork/restant.md stay plain inline code even though /api/fs/read serves them fine.

The gap is in FileSystem.find: both fff and ripgrep omit ignored files from their indexes. When the query is a full relative path and the index has no exact match, it now checks the path on disk using the existing resolve boundary, which rejects symlinks outside the workspace. Regular fuzzy search is unchanged and still never enumerates ignored files.

How did you verify your code works?

  • New cases in packages/core/test/filesystem/search.test.ts against real git repos with .gitignore: exact-path lookup through both fff and ripgrep now finds ignored files, fuzzy search still does not enumerate them, and a symlink pointing out of the workspace is not returned. The ripgrep case failed before this update.
  • bun test test/filesystem/ in packages/core: 67/67 pass. The search test file also passed 10 repeated runs (110/110).
  • bun run check from the repo root: 36/36 pass.
  • In a locally built app against a simulated API, a markdown link to an ignored file resolves through /api/fs/read/... with HTTP 200. I have not run the packaged desktop binary against a live server.

Screenshots / recordings

Not a visual change; the click decoration behavior is unchanged, it just starts matching ignored paths too.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #55863

Public API: /api/fs/find also returns ignored files/directories for an exact relative-path query (no schema change, backwards compatible)

@opencodejr opencodejr 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.

On Linux this fixes the reported problem. I ran the issue's script against the base and this branch, both from source. On the base, /api/fs/find returns nothing for .slim/deepwork/restant.md. With this change it returns the file, and fuzzy queries like restant still don't list ignored files. The packages/core filesystem tests pass and the package type-checks.

Public API: no schema change. /api/fs/find now also returns an ignored file or directory when the query is its exact relative path. This is backwards compatible.

The main concern is that the fallback only covers one of the two search backends. On Windows, the fff index is turned off by default and the ripgrep backend is used instead. Ripgrep also skips gitignored files, so the Desktop bug stays on Windows. Details are in the inline comment.

Related: #55863

Comment thread packages/core/src/filesystem/search.ts Outdated
type: item.type,
})
})
// fff intentionally excludes ignored files. Resolve only an exact path-like query on a miss;

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.

This fallback only runs in makeFffLayer. layer() below falls back to ripgrepLayer on win32 by default, when Fff.available() is false, for workspaceID locations, for the home directory and for folders without git. Ripgrep also respects .gitignore there, so #65546 stays unfixed on Windows desktops, a common setup. It is also skipped when fff fails to start (if (!finder) return [] above).

Could this move one level up, into find in packages/core/src/filesystem.ts? There, the existing resolve already handles the NUL check, the FSUtil.contains containment against the realpath'd root, and workspace locations. It also uses the FSUtil service, so you wouldn't need a raw node:fs/promises import inside Effect.tryPromise. That would cover both backends with one implementation. The client-side fallback in checkFileLinkExists (files.exists(files.resolve(path)), as absolute paths already do) would also work, if a fix scoped to link checks is preferred.

@opencodejr opencodejr 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.

Moving the check into FileSystem.find fixes my earlier point: it now covers both the fff and ripgrep backends and reuses resolve. I re-ran the issue's script against the base and this branch, both from source. With this change, /api/fs/find returns the gitignored file and its exact directory, and fuzzy queries still don't list ignored files. The packages/core filesystem tests pass and the package type-checks.

Public API: no schema change. /api/fs/find now also returns ignored entries when the query is their exact relative path. This is backwards compatible.

One new problem: a query whose path goes through an existing file now makes /api/fs/find fail with a server error. Details are in the inline comment.

if (!input.query.includes("/") || path.isAbsolute(input.query)) return entries
const exact = input.query.replace(/\/$/, "")
if (entries.some((entry) => entry.path === exact || entry.path === `${exact}${path.sep}`)) return entries
const found = yield* resolve(RelativePath.make(exact)).pipe(

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.

resolve turns any realPath failure other than NotFound into a defect ((_, error) => Effect.die(error)), and Effect.orElseSucceed only catches typed failures. So a path-like query that goes through a file now makes /api/fs/find fail. For example, with this branch, query=docs/business-model-risques.md/x returns {"_tag":"UnknownError",...} (ENOTDIR), while the base returns normal results. Permission errors would take the same route.

Since this is a best-effort probe, it should fall back to the normal results for any failure. You could use Effect.catchCause(() => Effect.succeed(undefined)) instead of orElseSucceed, or do the probe's realpath/stat without the dying branches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Concerning the best-effort probe: pushed c704caa — the probe now swallows every cause (typed failures and defects), so a path-like query that goes through a file falls back to the normal results instead of failing /api/fs/find with ENOTDIR. The comment-1 placement concern was already handled in ba5c90c, which moved the probe up to FileSystem.find so it runs for both backends.

realPath failures other than NotFound surface as defects, so a
path-like query passing through a file failed the whole find with
ENOTDIR. Swallow every cause instead; the probe stays best-effort.

Closes review feedback on anomalyco#65571
@archit15singh

Copy link
Copy Markdown

I replayed #67360 in macOS Chromium with the shared Markdown renderer and a real ripgrep-backed server. On this PR's c704caa6, a newly created docs/new-nested.md linked immediately. A new root-level new-root.md and ./new-root.md both stayed plain after the index refreshed, until the renderer remounted. Both spellings sent the slashless query new-root.md.

This confirms the overlap with #67360. If the two issues are handled together when this PR is rebased, a root-level file would be a useful additional regression case. AI-assisted verification.

The Desktop renderer sends root-level links as a bare name, which the
exact-path probe skipped because it required a separator. Resolve any
non-absolute query that names an existing root entry on a miss, strip a
leading ./, and keep fuzzy queries index-only.
@holny

holny commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for replaying that — good catch on the root-level case. The probe required a path separator, so a bare new-root.md never reached it. 623f8b4 now resolves any non-absolute query that names an existing root entry (stripping a leading ./), with a regression test for a root-level ignored file; fuzzy queries still stay index-only.

On the overlap: #68427 adds a client-side Files.exists fallback for the stale-index window, while this keeps the server-side find honest about ignored paths, so they look complementary rather than either one replacing the other.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: inline-code paths under gitignored files are never clickable (e.g. .slim/…)

2 participants