fix(workspaces): see a session's work in a Windows folder #25

Merged
HumanBean merged 2 commits from dyst/Tooling:fix/workspaces-windows into main 2026-11-21 21:52:23 +00:00
Member

On Windows, workspaces.py never sees a session working in a workspace, so clean treats a workspace someone is in as unused once it hasn't been touched for 24 hours. On a Windows PC with 13 worktrees, sessions of the last day had worked in 12 of them; main saw none.

Why it missed them: recent_mentions looked for each folder exactly as given (E:\x), but a Claude Code transcript never writes it that way on Windows. A session's cwd and the files it edits are JSON ("cwd":"E:\\x"), and commands use forward slashes (E:/x) or Git Bash's /e/x, quoted whenever the path has a space (cd "E:/Dev Work/x").

What changed

  • recent_mentions looks for each folder in each of those forms (path_forms), with the drive letter in either case, after a quote or not. A listing of folders still counts as no work, and the rule that a session sweeping through more than 8 workspaces works in none of them is unchanged.
  • on_ram decides from a mount table it's given on any system, so its check runs on Windows too. Without a table it still answers no on Windows, as before.
  • The mentions tests set USERPROFILE as well as HOME. On Windows ~ is USERPROFILE, so they read the PC's own ~/.claude/projects rather than the made-up one, and failed there.

Tests

  • New check test_windows_paths: a Windows folder written each of those ways, plus one only named in a listing. It fails on main on any system (none of the forms is found) and passes here.
  • python -I -B tests/run_all.py on Windows 11: 6 of 6 pass (main: 4 of 6, with test_workspaces.py's two Windows failures counted as one file, plus the new check failing). test_workspaces.py's jj check is skipped: jj isn't installed on this PC.
  • Not run on Linux: the changed code is string matching, and the new check makes up its paths; nothing in it depends on the system.

Measured (Windows 11, 1.6 GB of transcripts from the last day, 13 worktrees, recent_mentions(roots, 24)):

Worktrees seen worked in Time, 4 interleaved runs
main 0 of 13 5.9, 5.9, 14.6, 18.6 s
this PR 12 of 13 6.3, 8.0, 9.5, 19.4 s

The time is reading the transcripts (other sessions were using the disk), the same for both; the extra forms cost nothing that shows. Reading every recent transcript whole is the cost to look at separately.

🤖 Generated with Claude Code

On Windows, `workspaces.py` never sees a session working in a workspace, so `clean` treats a workspace someone is in as unused once it hasn't been touched for 24 hours. On a Windows PC with 13 worktrees, sessions of the last day had worked in 12 of them; `main` saw none. **Why it missed them:** `recent_mentions` looked for each folder exactly as given (`E:\x`), but a Claude Code transcript never writes it that way on Windows. A session's cwd and the files it edits are JSON (`"cwd":"E:\\x"`), and commands use forward slashes (`E:/x`) or Git Bash's `/e/x`, quoted whenever the path has a space (`cd "E:/Dev Work/x"`). **What changed** - `recent_mentions` looks for each folder in each of those forms (`path_forms`), with the drive letter in either case, after a quote or not. A listing of folders still counts as no work, and the rule that a session sweeping through more than 8 workspaces works in none of them is unchanged. - `on_ram` decides from a mount table it's given on any system, so its check runs on Windows too. Without a table it still answers no on Windows, as before. - The mentions tests set `USERPROFILE` as well as `HOME`. On Windows `~` is `USERPROFILE`, so they read the PC's own `~/.claude/projects` rather than the made-up one, and failed there. **Tests** - New check `test_windows_paths`: a Windows folder written each of those ways, plus one only named in a listing. It fails on `main` on any system (none of the forms is found) and passes here. - `python -I -B tests/run_all.py` on Windows 11: 6 of 6 pass (`main`: 4 of 6, with `test_workspaces.py`'s two Windows failures counted as one file, plus the new check failing). `test_workspaces.py`'s jj check is skipped: jj isn't installed on this PC. - Not run on Linux: the changed code is string matching, and the new check makes up its paths; nothing in it depends on the system. **Measured** (Windows 11, 1.6 GB of transcripts from the last day, 13 worktrees, `recent_mentions(roots, 24)`): | | Worktrees seen worked in | Time, 4 interleaved runs | |---|---|---| | `main` | 0 of 13 | 5.9, 5.9, 14.6, 18.6 s | | this PR | 12 of 13 | 6.3, 8.0, 9.5, 19.4 s | The time is reading the transcripts (other sessions were using the disk), the same for both; the extra forms cost nothing that shows. Reading every recent transcript whole is the cost to look at separately. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
recent_mentions is checked with a Windows folder in each way a transcript writes it: JSON's escaped
backslashes (the session's cwd, a file it edited), forward slashes and Git Bash's /e/... in a command,
quoted when the path has a space, the drive letter in either case. It fails on main: none of them is
found.

The mentions tests set USERPROFILE as well as HOME: on Windows ~ is USERPROFILE, so they read the PC's
own ~/.claude/projects instead of the made-up one, and failed there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Windows, recent_mentions never found a session at work: a transcript writes a folder as JSON does
(E:\x, the session's cwd, a file it edited), with forward slashes or as Git Bash's /e/x in a command,
and quoted when the path has a space, while the search looked for the folder only as given. So clean
saw no session in any workspace there, and only "touched in the last 24 h" kept one a session worked in.
Now each folder is looked for in each of those forms (any case of the drive letter), after a quote or
not; a listing still counts as no work.

on_ram decides from a table of mounts given to it on any system, so its check runs on Windows too
(without a table it still says no there).

On this PC (Windows 11, 13 worktrees, 1.6 GB of transcripts of the last day): main finds 0 of them
worked in, this 12; both take 6 to 19 s, the time to read the transcripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch fix/workspaces-windows 2026-11-21 21:52:23 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Tooling!25
No description provided.