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>
64dd8d16b9Wout Stiens committed on 9/1/2026, 5:43:05 AMparent1567113
3 files changedLine totals unavailable