# Delete pending turn starts, and follow the real state directory · pingdotgg/t3code

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

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

Visibility: public

Requested revision: c92ad95fe3e6ce86937ded61a2b63954c364a967

Requested commit: c92ad95fe3e6ce86937ded61a2b63954c364a967

Commit: c92ad95fe3e6ce86937ded61a2b63954c364a967

Tree: 8b15fbf6582581008624010780db25b1a7eb20af

Author: Theo Browne

Committer: Theo Browne

## Message

```
Delete pending turn starts, and follow the real state directory

Three findings from Macroscope review:

- Settling `pending` rows to `interrupted` was the wrong verb. The server
  deletes them (`clearPendingProjectionTurnsByThread`) once the turn
  starts or the thread stops, and never settles one in place. They also
  cannot be settled coherently: `turn_id` is NULL, so an "interrupted"
  pending row is a terminal turn with no id, a shape no real turn has.
  Now deleted, matching the server's predicate exactly so a checkpoint
  row is never caught by it.
- `COALESCE(completed_at, requested_at)` preserved a stale completion on
  a running turn. One can carry a completion from an earlier settle that
  a later checkpoint reverted to "running" — the `...existingTurn` spread
  in ProjectionPipeline keeps the old value — and dating the interruption
  to that checkpoint gives a wrong duration. Overwritten unconditionally.
- The CLI hard-coded `<base>/userdata/state.sqlite` while a dev server
  under an implicit dev home stores state in `<base>/dev`. A main-checkout
  `bun run dev` was therefore unseedable, and said so by claiming no
  database existed and suggesting the user start the server that was
  already running. Source and target now follow whichever directory holds
  a database, `userdata` breaking the tie; attachments follow the same
  directory. Verified both a dev-only target and the precedence order.

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

```

## Parents

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

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