You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File status paths are relative to the server working directory, not the project #768
When OpenScience works in a subdirectory of a repository, the file status it
reports is unusable. Every path comes back as a chain of .. segments pointing
at wherever the server was started.
Two things combine:
// git prints repository-root-relative pathsconstdiffOutput=await$`git diff --numstat HEAD`.cwd(Instance.directory)…// git ls-files --others prints cwd-relative pathsconstuntrackedOutput=await$`git ls-files --others --exclude-standard`.cwd(Instance.directory)…// and then every one of them is re-relativizedreturnchangedFiles.map((x)=>({ ...x,path: path.relative(Instance.directory,x.path)}))
path.relative(from, to) resolves a relative to against process.cwd(), not
against from. Nothing in the codebase calls process.chdir, so the server's
working directory is fixed at launch while Instance.directory is whatever
project the client selected.
Reproduced on 3e94875c with a repository whose pkg/ is the project, and a
change to pkg/tracked.txt:
The same response also lists changes made outside the project
(outside.txt above), because both git diff calls were repo-wide.
The agent cannot open any of these paths, and the two branches disagree with each
other in the same response.
Steps to reproduce
git init a repository containing a subdirectory, and commit a file in it.
Start OpenScience in that subdirectory, or select it as the project.
Modify the committed file, add a new one and delete another.
Read the file status (GET /file/status, or the Files/Changes pane).
The focused regression in test/file/status-paths.test.ts fails on 3e94875c
and passes with the fix.
How did you install OpenScience?
From source (bun dev).
OpenScience version
Source commit 3e94875c.
Provider and model
Not applicable; this is the file status the server returns.
Operating system
Not OS-specific — it depends on the project directory differing from the server's
working directory, which is the normal case for both the server and the desktop
app.
Activity