Skip to content

Name source workspaces after the repository, not the checkout - #515

Merged
milanb17 merged 2 commits into
mainfrom
claude/nice-chatelet-f46423
Sep 23, 2026
Merged

milanb17 merged 2 commits into
mainfrom
claude/nice-chatelet-f46423

Conversation

@milanb17

Copy link
Copy Markdown
Contributor

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-f92161 instead of review. The window title also still ended in "— Review" after #507.

  • Name: the GitHub slug's repo part, falling back to basename(dirname(commonDir)). This is the same rule as repositoryGroup() on Home. It's used for both the .code-workspace file name (the Explorer header) and folders[0].name.
  • Title: now ends in "— Whiteboard".
  • Existing workspaces: each open updates the root folder's name and path and 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-workspace file, 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 store for jj). Home's grouping has the same problem.

Testing

  • New behavioral test: registers a linked worktree named autocompact-500k-f92161 and opens its source. It checks that the workspace and root folder are named repository and 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 GitHub origin names the workspace whiteboard.
  • local-data.test.ts: 82/82 pass.
  • tsc: no errors in the changed files. The 8 existing errors are all in software-map-connectivity-validation.ts.
  • ESLint wasn't run: the package has no eslint.config.* file.
  • Not yet checked in the desktop app.

🤖 Generated with Claude Code

milanb17 and others added 2 commits September 23, 2026 18:22
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
@milanb17
milanb17 merged commit 4f39bf1 into main Sep 23, 2026
1 check passed
@milanb17
milanb17 deleted the claude/nice-chatelet-f46423 branch September 23, 2026 22:41
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>
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.

2 participants