# Break the state-dir tie on mtime, not a fixed preference · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/commit/da233f0a9674c91fce37d9263176fd302182830a)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

Requested revision: da233f0a9674c91fce37d9263176fd302182830a

Requested commit: da233f0a9674c91fce37d9263176fd302182830a

Commit: da233f0a9674c91fce37d9263176fd302182830a

Tree: bbf65f7fa50546342d8d444fe751785747fd54ba

Author: Theo Browne

Committer: Theo Browne

## Message

```
Break the state-dir tie on mtime, not a fixed preference

Preferring `userdata` whenever both directories exist was wrong for the
case that motivated resolving at all: an implicit `bun run dev` stores
state in `dev`, so a base directory that had also been used with an
explicit `--home-dir` would seed the database the running server does
not open — looking like the seed did nothing.

Neither directory is categorically right, so the tie now goes to
whichever was written most recently: the one the last server actually
used. `userdata` still wins an equal or unavailable mtime. The chosen
path is already printed, so a wrong guess is visible rather than silent.

Verified both directions against a target holding both databases.

Caught by Cursor Bugbot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

```

## Parents

- [8dee88913cb2ef9d2f092caed5e492a73edb78a9](https://git.cafe/pingdotgg/t3code/commit/8dee88913cb2ef9d2f092caed5e492a73edb78a9?format=markdown)

[Source at this commit](https://git.cafe/pingdotgg/t3code/tree/da233f0a9674c91fce37d9263176fd302182830a?format=markdown)
