Repository navigation
Commit 7ef7b86
fix(server): retire live work when provider sessions detach (#1734)
## Problem
Deliberate provider teardown reports a provider failure, holds handoff continuations, and strands questions and native tools on dead sessions.
Stop also leaves questions from already failed runs interactive.
## Change
Publish owned interrupted terminals before closing subscribers, then retire the released session's live requests, tools, and nodes.
Shared detach cleans only its thread; cutoff and runtime identity checks preserve replacement work.
Stop also retires requests from ended runs and runless work.
Cleanup faults cannot skip teardown; attachment-locked retries retain the original cutoff and runtime ownership.
Inline and deferred detach share native teardown helpers.
## Scope and approval
The maintainer authorized fixing these lifecycle bugs, recording proof, opening PRs, and merging after review and green checks.
Closes #1731.
Closes #1610.
## Verification
### Automated
- [x] **Tests:** 146 detach/Stop cases, exit 0
- [x] **Isolation:** replacement work survives
- [x] **Failure:** runtime errors still fail
- [x] **Types/build:** server, exit 0
- [x] **Gate:** `vp run fork:ci`, exit 0
### Live
- [x] **Disconnect:** pending input clears
- [x] **Handoff:** continuation auto-starts
- [x] **Cleanup:** no waiting row remains
- [x] **Stop:** question clears; run interrupts
- [x] **Submit:** next prompt completes
Before, a dead session's question remains selectable.
https://github.com/user-attachments/assets/2c91dddd-bbd5-4107-bcd3-a45a0fa50b4e
After, disconnect clears its question and interrupts the run.
https://github.com/user-attachments/assets/9c6feaf7-075f-4aae-b125-9d0b2774745a
Before, handoff holds the continuation.
https://github.com/user-attachments/assets/463310c8-0ff9-4dda-99ac-7cee4c44be3d
After, handoff automatically produces `FINAL_HANDOFF_OK` and clears the sidebar waiting state.
https://github.com/user-attachments/assets/2c9be041-6456-4e79-a5d3-f4f5f5e266a2
After, actual client Stop clears pending input and interrupts the turn.
https://github.com/user-attachments/assets/1dd7c874-f8ad-4607-a6b4-5ef0cebd5b72
After Stop, a new submission completes.

Live build `529ebd95849` contains byte-identical detach source from final head `91beba566f5790b2d2db1028deb25e222fbefbdb`.
Fork run 8 interrupted; run 9 completed with `FINAL_SUBMIT_OK`.
Root disconnect run 15 interrupted; requests show zero pending.
Handoff run 17 interrupted intentionally; continuation run 18 started automatically and completed.
Historical prompts retain the Queued annotation; the current sidebar waiting state clears.
Fault tests cover typed lookup failures, repeated retry failures, persistence faults, shared runtime survival, replacement isolation, ended-run and runless requests.
All clips play normally: Stop 10s, disconnect 10s, handoff 11s; trailing idle is cut and the claim is captioned.
Handoff uses `startFromOrigin: false` because the isolated fixture has no reachable remote.
The service owns teardown for all providers and clients; shared and single-thread runtimes are covered by tests.
Mobile, Electron, and remote connections were not exercised live.
Codex, gpt-6.1-sol (high); independent review: Pi, zai/glm-5.3-flash.
## Fork trailers
Squashes:
- 624237b fix(server): retire live work when provider sessions detach (#1734) (#1734)
- 5389223 fixup! fix(server): retire live work when provider sessions detach (#1734) (#1734)
- 960b715 fix(server): retire live work when provider sessions detach (#1734) (#1734)
- 654d522 fixup! fix(server): retire live work when provider sessions detach (#1734) (#1734)
- 74d91fc fixup! fix(server): retire live work when provider sessions detach (#1734) (#1734)
Fork-Domain: upstream-fixes
Fork-Tier: bugfix
Fork-Upstreamable: yes1 parent a958a4e commit 7ef7b86
6 files changed
Lines changed: 2141 additions & 105 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| |||
10569 | 10573 | | |
10570 | 10574 | | |
10571 | 10575 | | |
| 10576 | + | |
| 10577 | + | |
10572 | 10578 | | |
10573 | 10579 | | |
10574 | 10580 | | |
| |||
10830 | 10836 | | |
10831 | 10837 | | |
10832 | 10838 | | |
| 10839 | + | |
| 10840 | + | |
10833 | 10841 | | |
10834 | 10842 | | |
10835 | 10843 | | |
| |||
10900 | 10908 | | |
10901 | 10909 | | |
10902 | 10910 | | |
| 10911 | + | |
| 10912 | + | |
| 10913 | + | |
| 10914 | + | |
| 10915 | + | |
| 10916 | + | |
| 10917 | + | |
| 10918 | + | |
| 10919 | + | |
| 10920 | + | |
| 10921 | + | |
| 10922 | + | |
10903 | 10923 | | |
10904 | 10924 | | |
10905 | 10925 | | |
| |||
11110 | 11130 | | |
11111 | 11131 | | |
11112 | 11132 | | |
| 11133 | + | |
| 11134 | + | |
| 11135 | + | |
| 11136 | + | |
| 11137 | + | |
| 11138 | + | |
| 11139 | + | |
| 11140 | + | |
11113 | 11141 | | |
11114 | 11142 | | |
11115 | 11143 | | |
| |||
11388 | 11416 | | |
11389 | 11417 | | |
11390 | 11418 | | |
11391 | | - | |
11392 | | - | |
11393 | | - | |
11394 | | - | |
| 11419 | + | |
| 11420 | + | |
| 11421 | + | |
| 11422 | + | |
| 11423 | + | |
| 11424 | + | |
| 11425 | + | |
| 11426 | + | |
| 11427 | + | |
| 11428 | + | |
| 11429 | + | |
| 11430 | + | |
| 11431 | + | |
| 11432 | + | |
| 11433 | + | |
11395 | 11434 | | |
11396 | 11435 | | |
11397 | 11436 | | |
| |||
11406 | 11445 | | |
11407 | 11446 | | |
11408 | 11447 | | |
| 11448 | + | |
| 11449 | + | |
| 11450 | + | |
| 11451 | + | |
| 11452 | + | |
| 11453 | + | |
| 11454 | + | |
| 11455 | + | |
| 11456 | + | |
11409 | 11457 | | |
11410 | 11458 | | |
11411 | 11459 | | |
| |||
0 commit comments