Repository navigation
Commit 681bf67
fix(server): external MCP reads show background work and native subagent turns (#1648)
## Problem
External MCP reports run status only.
An owner whose run ended with 5 native subagents still running reads `completed`, and each child reads `idle` with `runCount: 0`.
The UI shows the same owner as **Waiting on 5 subagents**.
Refs #1647; it stays open for the gap below.
## Change
`t3_external_thread_read`, `_list`, and `_wait` gain an additive `work` field.
It reads the projection the UI reads:
| Source | Feeds |
| --- | --- |
| Shell `pendingBackgroundTasks` | `background`, the sidebar's roster |
| Last runless `root_turn` node | `nativeTurn` on provider-native subagents |
| Shell and native turn times | `updatedAt`: the latest |
`work.state` ranks like client-runtime `shellRuntime`:
1. `awaiting_response`: a request waits on a person
2. `running`: a live or queued run, or native turn
3. `waiting_on_background`: held background work
4. `running`: a run waiting on its checkpoint
5. `idle`
### Unchanged
| Field | Rule |
| --- | --- |
| `status`, `pendingRequestCount` | run view, as before |
| Pinned `runId` wait | run outcome stands; `work` reports what remains |
| Native child run ids | none fabricated; `runId` stays null |
| Grant, filters, pagination | `work` computed only for granted, paged rows |
### New wait mode
`until: "work"` polls every 500 ms until `work` is `idle` or `awaiting_response`.
With `runId` it refuses `invalid_request`.
A held command, such as a dev server, stays listed but does not hold the thread.
List reads nodes only for native subagent rows on the page, 4 at a time.
Deleted threads now read as missing at the shell, as the record read already did.
## Known gap: resumed native subagents
`work` reads the projection; it cannot be more current than it.
A native subagent resumed by a later run records nothing on its child thread (#1650, upstream `pingdotgg#16261`).
| Read | Result for a resumed child |
| --- | --- |
| Owner `work.background` | correct: lists it with `childThreadId` |
| Child `work.nativeTurn` | frozen pre-resume turn |
| Child `work.state` | may read `idle` while it works |
Reproduced live on 2026-10-06 with 5 resumed Claude subagents.
The routing fix is separate work under #1650; this PR does not change routing.
## Scope and approval
Owner-requested fix to the fork's external MCP (`device-auth`).
Internal `/mcp` parity is a follow-up.
## Verification
```text
vp test run apps/server/src/mcp/external/ → 47 passed
vp test run apps/server/src/mcp/ → 256 passed
roster and native turn ignored (mutation) → 12 of 23 work tests fail
apps/server vp run typecheck → exit 0
vp lint <touched files> → exit 0
independent review, 2 rounds → nothing blocking
aftercare on 6be86e5 (limited, not a full review) → 0 findings
apps/server vp run build → exit 0
vp run fork:ci → exit 0
```
Shells in the tests come from the real `threadShellFromProjection`, shaped like the live repro.
Not yet checked: the running instance; it needs a release and restart.
Claude Opus 5.5 (high, 1m) via Claude Code in T3 Code.
## Fork trailers
Squashes:
- 3c8f826 fix(server): external MCP reads show background work and native subagent turns (#1648) (#1648)
- eccf782 fixup! fix(server): external MCP reads show background work and native subagent turns (#1648) (#1648)
Fork-Domain: device-auth
Fork-Tier: core
Co-authored-by: donjor <[email protected]>1 parent 43dfaa3 commit 681bf67
6 files changed
Lines changed: 928 additions & 34 deletions
File tree
- apps/server/src/mcp
- external
- toolkits/external
- docs/fork/internals
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
74 | 87 | | |
75 | 88 | | |
76 | 89 | | |
| |||
96 | 109 | | |
97 | 110 | | |
98 | 111 | | |
99 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
100 | 115 | | |
101 | 116 | | |
102 | 117 | | |
103 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
104 | 130 | | |
105 | 131 | | |
106 | 132 | | |
| |||
112 | 138 | | |
113 | 139 | | |
114 | 140 | | |
115 | | - | |
| 141 | + | |
116 | 142 | | |
117 | 143 | | |
118 | 144 | | |
119 | 145 | | |
120 | 146 | | |
121 | 147 | | |
| 148 | + | |
122 | 149 | | |
123 | | - | |
| 150 | + | |
124 | 151 | | |
125 | 152 | | |
126 | 153 | | |
| |||
274 | 301 | | |
275 | 302 | | |
276 | 303 | | |
277 | | - | |
| 304 | + | |
278 | 305 | | |
279 | 306 | | |
280 | 307 | | |
281 | 308 | | |
282 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
283 | 314 | | |
284 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
285 | 322 | | |
286 | 323 | | |
287 | 324 | | |
| |||
293 | 330 | | |
294 | 331 | | |
295 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
296 | 376 | | |
297 | 377 | | |
298 | 378 | | |
| |||
455 | 535 | | |
456 | 536 | | |
457 | 537 | | |
458 | | - | |
459 | | - | |
460 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
461 | 541 | | |
462 | | - | |
| 542 | + | |
463 | 543 | | |
464 | 544 | | |
465 | 545 | | |
466 | 546 | | |
467 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
468 | 553 | | |
469 | 554 | | |
470 | | - | |
| 555 | + | |
471 | 556 | | |
472 | 557 | | |
473 | 558 | | |
| |||
476 | 561 | | |
477 | 562 | | |
478 | 563 | | |
| 564 | + | |
479 | 565 | | |
480 | 566 | | |
481 | 567 | | |
| |||
504 | 590 | | |
505 | 591 | | |
506 | 592 | | |
507 | | - | |
| 593 | + | |
508 | 594 | | |
509 | 595 | | |
510 | 596 | | |
| |||
519 | 605 | | |
520 | 606 | | |
521 | 607 | | |
522 | | - | |
| 608 | + | |
523 | 609 | | |
524 | 610 | | |
525 | 611 | | |
526 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
527 | 626 | | |
528 | 627 | | |
529 | 628 | | |
530 | 629 | | |
531 | 630 | | |
532 | 631 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 632 | + | |
537 | 633 | | |
538 | 634 | | |
| 635 | + | |
| 636 | + | |
539 | 637 | | |
540 | 638 | | |
541 | 639 | | |
542 | 640 | | |
543 | 641 | | |
544 | | - | |
| 642 | + | |
| 643 | + | |
545 | 644 | | |
546 | 645 | | |
547 | 646 | | |
| |||
0 commit comments