Repository navigation
Conversation
There was a problem hiding this comment.
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
| type: item.type, | ||
| }) | ||
| }) | ||
| // fff intentionally excludes ignored files. Resolve only an exact path-like query on a miss; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
I replayed #67360 in macOS Chromium with the shared Markdown renderer and a real ripgrep-backed server. On this PR's 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.
|
Thanks for replaying that — good catch on the root-level case. The probe required a path separator, so a bare On the overlap: #68427 adds a client-side |
Issue for this PR
Closes #65546
Type of change
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.mdstay plain inline code even though/api/fs/readserves 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 existingresolveboundary, which rejects symlinks outside the workspace. Regular fuzzy search is unchanged and still never enumerates ignored files.How did you verify your code works?
packages/core/test/filesystem/search.test.tsagainst 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/inpackages/core: 67/67 pass. The search test file also passed 10 repeated runs (110/110).bun run checkfrom the repo root: 36/36 pass./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
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)