# fix\(pi\): keep one provider thread row per app thread · stienswout/t3code

[View on GitCafe](https://git.cafe/stienswout/t3code/commit/64dd8d16b9ad2fafb6b51933a005d61a683bb015)

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

Visibility: public

Requested revision: 64dd8d16b9ad2fafb6b51933a005d61a683bb015

Requested commit: 64dd8d16b9ad2fafb6b51933a005d61a683bb015

Commit: 64dd8d16b9ad2fafb6b51933a005d61a683bb015

Tree: 73b8240f52361f6738fa899feb80ab70e363b6f2

Author: Wout Stiens

Committer: Wout Stiens

## Message

```
fix(pi): keep one provider thread row per app thread

A first run creates a placeholder provider thread with no native identity,
but ensureThread never handed that row to the adapter, so the Pi adapter
registered a second row keyed by the session file. Both rows then received
updates at turn end, and last-writer-wins on activeProviderThreadId decided
at random whether the row carrying contextUsage was active — hiding the
composer's context meter on most turns.

Pass the run's provider thread through existingProviderThread at both
ensureThread call sites so the adapter adopts the orchestration-owned row
id (Pi's adopt branch already handles a row without a native ref). The
replacement path after a failed resume drops the dead native ref so a
fresh session still binds to the same row. OpenCode now only takes its
resume path for rows that actually carry a native session, which keeps
its behavior unchanged for these new inputs.

Reported by @astarktc in #7211.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

```

## Parents

- [1567113fdea35eb7bebef6c94c49e773235d7335](https://git.cafe/stienswout/t3code/commit/1567113fdea35eb7bebef6c94c49e773235d7335?format=markdown)

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