Repository navigation
Conversation
A child interrupted by a server restart keeps a persisted `running` status and no result entry. `get_subagent_result` already settled that to `interrupted`, but the session list served the raw file status, so the agent switcher and the subagent viewer spun forever while the top bar, which reads live wrappers, said the run had finished. - Settle a persisted `running` / `queued` status when a subagent row is read from disk, through `settleOrphanedSubagentStatus()`. - Let an alive wrapper's runtime row overlay that status in the merged list, so a genuinely queued child still reads as queued. - Derive the runtime row status from a running wrapper, the live run map, or the settled file, instead of trusting the file alone. - Cover the orphaned listing and the live overlay with tests, and record the rule in the subagents note.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
A subagent run that a server restart cut off keeps a persisted
running(orqueued) status and no result entry in its session file. The session listing served that raw file status, so the agent switcher and the subagent viewer spun forever on a run that is dead, while the top bar — which reads the live wrappers — said the run had finished.This PR makes the listing settle such an orphaned run the same way the tool already does:
lib/subagents.ts: newsettleOrphanedSubagentStatus()— a persistedrunning/queuedstatus with no result entry and no live run becomesinterrupted.lib/session-reader.ts:mapScannedSession()settles the status of the listed row;mergeSessionLists()lets an alive wrapper's runtime row overlay that settled status, so a genuinely queued child still reads asqueued.lib/rpc-manager.ts:getRpcSessionInfos()derives the runtime row's status from, in order, a running wrapper, the live run map (getLiveSubagentStatus()inlib/subagent-runtime.ts), or the settled file — never the raw file status alone.lib/subagent-runtime.ts:settleOrphanedRun()now uses the shared helper, andgetLiveSubagentStatus()exposes the status of a run this process still holds.Why it matters (the broken behaviour)
On
main, the session LIST disagrees with theget_subagent_resulttool:lib/subagents.ts(readSubagentRun()): the persisted status is"queued"or"running"whenever the file has a status entry and no result entry. It is only settled to"interrupted"when the status came from somewhere else.lib/session-reader.ts:258(mapScannedSession): the listed row takesstatus: subagent.status— the raw file status — with no check for a run that can no longer finish.lib/rpc-manager.ts:2345(getRpcSessionInfos): the runtime row'srelation.statusissession.isRunning() ? "running" : subagent.status— again the raw file status.lib/subagents.tsaround line 982 (get_subagent_result): a persistedrunning/queuedwith no result and no live wrapper is already reported asinterrupted.So the switcher and the viewer spin on a dead run, the top bar says it is done, and the two views contradict each other. With this PR the list agrees with the tool: the orphaned run reads as
interrupted.How to reproduce (on
main, before the fix)pi-web:subagent-statusentry withrunningand nopi-web:subagent-resultentry.running/queued, while the top bar's badge (which reads the live wrappers) says the run has finished. After the fix: the row readsinterrupted, likeget_subagent_resultreports.Testing
Node 26.7.0 (
nvm use 26.7.0).Failing on the base commit (
e533d9b3), with only the tests added:With the fix, all green:
The three new tests are the ones named above: the orphaned listing (
lib/session-reader.test.mjs), the live runtime row's overlay in the merged list (lib/session-reader.test.mjs), and the settled runtime row (lib/rpc-session-info.test.mjs).Provenance
Split out of the Bun-running fork https://github.com/brynne8/pi-web-bun, commit
4ddd96ec("fix(subagents): stop showing an interrupted run as still running"). It was ported by hand onto this repository's current code (the fork'slib/rpc-manager.tshas since diverged); upstream's own structures were kept, and no part of the fork's file was copied wholesale. No new setting, dependency, UI string or subsystem; nothing in pi or in what pi writes to session files changed.