Skip to content

fix(tool): cut the list tree on either path separator - #763

Merged
Ishaan Gangwani (ishaan1124) merged 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/list-tree-path-separator
Sep 28, 2026
Merged

Ishaan Gangwani (ishaan1124) merged 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/list-tree-path-separator

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What does this PR do, and why?

list built its file tree by splitting each directory on /, while the parent
lookup in the renderer used the platform-aware path.dirname:

const dir = path.dirname(file)                    // platform-aware
const parts = dir === "." ? [] : dir.split("/")   // POSIX only

Ripgrep.files passes no --path-separator, so ripgrep prints the host
separator — \ on Windows. The intermediate directories of a deep path were
therefore never added to dirs, so the renderer could never reach them.

The files are not skipped, they are collected and counted and then dropped:
metadata.count reports every file ripgrep found while output shows only the
root-level ones, so the model is told about files it cannot see.

This tree is model-facing text, so the fix cuts it on either separator and always
renders with /. A listing then reads identically on every platform, and the
separator handling becomes testable on Linux CI (see below).

Depth is what makes this easy to miss, and I confirmed the boundary: on
3e94875c one and two levels deep still render correctly, and three levels is
where it breaks — because path.dirname on the single key a\b\c correctly
reports a\b as its parent, but a\b was never itself added to the set.

Linked issue

Fixes #762

How did you verify it?

Reproduced on Windows against unmodified 3e94875c with a workspace holding
root.txt, src/evidence.txt, src/lib/two.txt and a/b/c/deep.txt. list
returned:

<workspace>/
  src/
    lib/
      two.txt
    evidence.txt
  root.txt

a/b/c/deep.txt is absent. With this change the same workspace renders the full
tree, and the output for the one- and two-level files is byte-identical to
before, so the change is not a reformat.

test/tool/ls-tree.test.ts has three cases:

  • renders the same tree for "/" separated paths and … for "\\" separated paths
    pin the exact rendered tree — names, order and indentation — for both
    separator styles. This is the cross-platform lock: the backslash case fails
    against the old POSIX-only split on any platform, which matters because
    Fast CI is ubuntu-latest only and Deep CI is dispatch-only.
  • renders a file three directories deep from the real listing drives the real
    ListTool against a real session workspace, so the whole path is covered on
    the platform that has the bug.

Commands run:

  • bun test --timeout 30000 ./test/tool/ls-tree.test.ts → 3 pass
  • bun test --timeout 30000 ./test/tool/workspace-file-tools.test.ts → 2 pass
    (this is the suite that already exercises list, including its
    permission-denied path)
  • bun run --cwd backend/cli typecheck → exit 0

While verifying I also caught a bug in my own first attempt: deriving the
directory name as dir.slice(parent(dir).length + 1) renders / and rc/
instead of a/ and src/ for a top-level directory. That is why the test
asserts the whole tree rather than a toContain on one filename.

Pre-existing reds on this Windows checkout, not from this diff:

  • bun run format:check cannot pass here: git materializes the LF blobs as CRLF,
    so Prettier flags hundreds of untouched files, including tsconfig.json and
    turbo.json. I verified all three changed files are formatted per the repo
    config with line endings normalized.
  • bun run typecheck: backend is clean; @synsci/workspace fails because
    frontend/workspace/src/custom-elements.d.ts is a symlink (mode 120000) that
    Windows checked out as a text file containing ../../ui/src/custom-elements.d.ts,
    which TypeScript then parses as source → TS1128.

Checklist

  • bun run check is green (format, typecheck, backend + frontend/ui + SDK tests) — blocked on this Windows checkout by the CRLF and symlink artifacts described above; backend typecheck is clean and both affected test files are green
  • bun run --cwd frontend/workspace build succeeds if I touched frontend/workspace or frontend/ui — not touched
  • ./tooling/repo/generate.ts was run and the tooling/sdk output committed if I changed backend/cli/src/server — not touched
  • CHANGELOG.md has an Unreleased entry if the change is user-visible
  • The matching docs page under frontend/docs/src/content/openscience/ is updated if behavior changed — no doc change needed: list is documented as listing a directory, and this makes it do that on every platform
  • Screenshots or a short video are attached for UI changes — not a UI change
  • No version bumps (package.json versions and tags are written by the release workflow)
  • install and frontend/landing/public/install are still byte-identical if I touched either — not touched

@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

The tree was cut on `/` while ripgrep prints the host separator, so on Windows
the intermediate directories of a deep path were never added to the set the
renderer walks and the files under them were collected, counted, then dropped
from the output. Cut on either separator and render with `/`, so a listing reads
the same on every platform.
@ishaan1124
Ishaan Gangwani (ishaan1124) merged commit 9e5e353 into synthetic-sciences:main Sep 28, 2026
1 check failed
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.

list silently drops files three or more directories deep on Windows

2 participants