Skip to content

Find the home and the data directory on Windows too - #115

Merged
fylorn merged 1 commit into
mainfrom
feat/windows-dirs
Sep 23, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/windows-dirs

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Both of these resolved through HOME, and Windows does not set it.

They are also two different directories, which is easy to miss because on unix one sits inside the other:

what it is last resort before this on Windows now
tw_config::default_dir the data directory: configuration, request store, lock, socket, token a relative .thinkwatch %APPDATA%\ThinkWatch
tw_control::home_dir the user's home, only ever used to go looking for other clients' configuration an empty path %USERPROFILE%

The data directory's fallback is the sharper of the two: on Windows the whole thing would have landed in whatever the process's working directory happened to be, silently.

Why they resolve differently

The data directory follows the platform's own habit — %APPDATA%\ThinkWatch, not %USERPROFILE%\.thinkwatch. A leading dot is a unix convention, and someone looking for what a program stored on Windows looks in APPDATA.

The home keeps meaning the home. ~/.claude, ~/.codex and ~/.cursor really do live under %USERPROFILE% there, so adoption still finds them.

Testing a branch this machine cannot run

The choice between the two habits is a parameter (Convention::Unix / Convention::Windows) rather than an inline cfg!, so both branches are exercised on any host. CI only has macOS today, and the branch nobody runs is exactly the one that would be wrong. Six tests cover: the explicit override winning on either platform, each platform reading only its own variable (a machine with Git Bash has HOME set and is Windows — that must not change where data goes), an empty variable counting as unset, and the no-information case staying relative rather than falling to the root.

One duplicate collapsed

twcore had grown its own second copy of home(), reading HOME directly. It now asks tw-control — "what is the home" having two answers in two places is the same bug this PR is fixing.

Verified

cargo clippy --workspace --all-targets -- -D warnings clean, full workspace test suite green.

🤖 Generated with Claude Code

Both of these resolved through `HOME`, and Windows does not set it. They
are also two different directories, which is easy to miss because on unix
one sits inside the other:

  - the data directory holds the configuration, the request store, the
    lock, the socket and the token. Its last resort was a relative
    `.thinkwatch`, so on Windows the whole thing would have landed in
    whatever the process's working directory happened to be.
  - the user's home is only ever used to go looking for other clients'
    configuration -- `~/.claude`, `~/.codex`, `~/.cursor` -- and those
    dot-directories do live under `%USERPROFILE%` on Windows.

So the data directory follows the platform's own habit (`%APPDATA%\
ThinkWatch`, not `%USERPROFILE%\.thinkwatch`: a leading dot is a unix
convention, and someone looking for what a program stored on Windows
looks in APPDATA), while the home keeps meaning the home and reads
`USERPROFILE` there.

The choice between the two habits is a parameter rather than an inline
`cfg!`, so both branches are exercised on any machine. The CI only has
macOS today, and the branch nobody runs is exactly the one that would be
wrong.

`twcore` had grown its own second copy of `home()`. It now asks
tw-control, because "what is the home" having two answers in two places
is the same bug this commit is fixing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit e6f0994 into main Sep 23, 2026
1 check passed
@fylorn
fylorn deleted the feat/windows-dirs branch September 23, 2026 04:37
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.

1 participant