Name source workspaces after the repository, not the checkout - #515
Merged
Merged
Conversation
A Whiteboard registered from a linked worktree labeled its native source window with the worktree directory (e.g. autocompact-500k-f92161). Name the workspace file and root folder from the GitHub repo name, falling back to the git common dir's parent, matching Home's repository grouping. Update the window title suffix to "— Whiteboard". Existing workspaces keep their settings: an old checkout-named file seeds the new one and stays in place for any window still open on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: 8b958fd7-34fd-47a8-b6dd-c7d8c2f89db4
Satisfies the anti-slop lint rules: no unknown-valued dictionaries, typeof narrowing or conditional spreads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: 8b958fd7-34fd-47a8-b6dd-c7d8c2f89db4
thesiti92
approved these changes
Sep 23, 2026
milanb17
added a commit
that referenced
this pull request
Sep 23, 2026
#513 moved checkout reads to checkoutFs and dropped readFile from the node:fs/promises import. #515, written before that, added readWorkspace, which still calls readFile. Each passed CI alone; together every source window request fails with 'ReferenceError: readFile is not defined', so Source tree and Open file do nothing. The workspace file lives under .git/dev-fast, not in a checkout, so plain node:fs is correct here, matching the write in the same function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Agent-Session: 8b958fd7-34fd-47a8-b6dd-c7d8c2f89db4
milanb17
added a commit
that referenced
this pull request
Sep 23, 2026
## Summary
`main` currently fails typecheck, and in Desktop, **Source tree** and
full-file opens do nothing. Every request to open a source window fails
on the server:
```
POST /reviews-api/<id>/navigator failed: ReferenceError: readFile is not defined
at readWorkspace (…/review-api/local-data.ts:1732)
```
## Cause
Two PRs that each passed CI on their own conflicted in meaning once both
merged:
- #513 moved checkout reads to `checkoutFs` (Electron's `.asar` fix) and
dropped `readFile` from the `node:fs/promises` import, because it had no
other callers at that point.
- #515, branched before #513, added `readWorkspace()`, which calls plain
`readFile`.
## Fix
Re-add `readFile` to the `node:fs/promises` import. Plain `node:fs` is
correct here: the `.code-workspace` file lives under `.git/dev-fast/…`,
not inside a checkout, so the `.asar` handling doesn't apply. The same
function already writes that file with plain fs.
## Validation
- `tsc --noEmit -p packages/review` reports the missing `readFile`
without the fix and passes with it. This is the `TS2304` currently
failing `main`'s CI and open PRs such as #516.
- `vitest run src/review-api/local-data.test.ts`: all 82 pass, including
the `navigatorWorkspace` tests that read existing workspace files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The native source window added in #498 took its name from the registered checkout's directory. For a Whiteboard registered from a linked worktree, the Explorer header and root folder showed e.g.
autocompact-500k-f92161instead ofreview. The window title also still ended in "— Review" after #507.basename(dirname(commonDir)). This is the same rule asrepositoryGroup()on Home. It's used for both the.code-workspacefile name (the Explorer header) andfolders[0].name.window.title, and keeps every other setting, folder and key. The file is only rewritten when something changed. A file that isn't plain JSON (VS Code allows comments) is left untouched.Reviewer notes
VS Code identifies a workspace window by the path of its
.code-workspacefile, so renaming a file in place would break a window already open on it. Instead, an old checkout-named file seeds the new file and is left where it is. The cost is one-time: the first open after this change starts a new window instead of focusing a window still open on the old path, and that workspace's saved editor layout starts fresh. After that, reopening focuses the window as before. Old-name files only exist from #498, which merged the same day.For a bare repo, or a jj repo that isn't colocated with git, and has no GitHub remote, the fallback name comes out wrong (for example
storefor jj). Home's grouping has the same problem.Testing
autocompact-500k-f92161and opens its source. It checks that the workspace and root folder are namedrepositoryand the title ends "— Whiteboard". It checks that an old-name file's settings carry over and the old file is kept. It checks that adding a GitHuboriginnames the workspacewhiteboard.local-data.test.ts: 82/82 pass.tsc: no errors in the changed files. The 8 existing errors are all insoftware-map-connectivity-validation.ts.eslint.config.*file.🤖 Generated with Claude Code