Skip to content

fix(agent-status): keep stale Pi child rows on workspace refresh - #46903

Closed
renningg wants to merge 1 commit into
stablyai:mainfrom
renningg:fix/46585-pi-stale-child-rows
Closed

renningg wants to merge 1 commit into
stablyai:mainfrom
renningg:fix/46585-pi-stale-child-rows

Conversation

@renningg

Copy link
Copy Markdown
Contributor

ELI5

Opening or refreshing a paired worktree no longer makes Pi's background children disappear behind a green Done badge just because the lead has been quiet.

What Changed

Keep the last known Pi child roster when the same connected pane still has idle-title evidence and an older row says a child was working. Keep the original observation time so clients show No recent update, not a fresh working signal. Reset or newer completion evidence still supersedes it.

Why

Idle title and an expired observation cannot establish that a background child completed. Retaining the aged evidence avoids losing useful context without asserting that the child is still active.

Linked Issue

Fixes #46585

Visual Proof

Same Chromium fixture of the production worktree status component, using a synthetic 31-minute-old projection. No real agent or paired device was used.

Before: Done and no child row

After: stale status and child row

Testing

  • Two focused state-projection cases passed. The stale-child case failed before the change.
  • pnpm check:changed: 26 checks passed, including selected tests and typechecks.
  • Native paired-host session not tested locally.

Performance

No new timers, IO, or network requests. Only the current Pi evidence is examined while building or refreshing a status that Orca already projects.

Risk

Level: Low to medium. A stale roster can stay visible longer, but it is intentionally dated rather than counted as fresh. Reset and completion signals still retire it. Revert the commit to restore previous projection behavior.

AI Disclosure

Implemented and validated with OpenAI Codex.

Review

Uses existing Pi ownership and child-work evidence; does not change terminal lifecycle, provider authentication, IPC shape, or mobile storage. Host and renderer logic was exercised with synthetic inputs on macOS, not a real SSH or mobile pairing. No platform-specific path, hotkey or native feature changes.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material copied.

Notes

The visual evidence is separate from the PR diff.

Checklist

  • One focused issue; user-facing before/after and risk explained
  • Relevant tests and changed-code gate passed
  • Visual proof linked
  • Cross-platform, compatibility, performance and security reviewed
  • Full suite/build left to CI per repository guidance

@renningg
renningg marked this pull request as ready for review November 22, 2026 11:13
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The status evidence logic now detects stale Pi working statuses whose child work outlives an idle PTY title. PTY-title renewal preserves the existing status when this condition holds. The builder can use the latest eligible hook row as a live-row fallback. Tests cover preservation of child evidence and its retirement after a provider reset or newer confirmed completion.

Severity of issue fixed: Medium

Merge Risk: Low · up to 1060e

Stale Pi child rows are retained for panes with a known Pi launch identity. Panes with no launch or foreground identity still show Done without children after a refresh. This is a narrow gap with low merge risk.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#46585] The issue requires that a Pi lead with live async children keeps its child rows after 30 minutes of silence. It must show working or 'No recent update', not Done. The reviewed head adds `stal… Provide readable diff or blob access for runtime-mobile-agent-status-builder.ts and runtime-mobile-agent-status-builder.test.ts at head. Confirm that the fallback row keeps the original observedAt, that the output has the child roster, and …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title follows conventional commit form and names the main change: stale Pi child rows are kept during workspace refresh. The summary and objectives describe the same retained roster behavior for p…
Description check Passed The description follows the template closely. It includes ELI5, What Changed, Why, a linked issue (Fixes #46585), Visual Proof with before and after images, Testing, Performance, Risk with a level, AI…
Out of Scope Changes check Passed The readable diff for runtime-mobile-agent-status-evidence.ts adds one Pi-specific predicate. The summary describes the other changes as the builder fallback, the projection renewal guard, and tests f…
Full details: Title check

Explanation

The title follows conventional commit form and names the main change: stale Pi child rows are kept during workspace refresh. The summary and objectives describe the same retained roster behavior for paired worktree refresh, so the title is related to the main change and specific enough for history scanning.

Full details: Description check

Explanation

The description follows the template closely. It includes ELI5, What Changed, Why, a linked issue (Fixes #46585), Visual Proof with before and after images, Testing, Performance, Risk with a level, AI Disclosure, Review, the upstream boundary checkbox, Notes, and the checklist. Testing lists the focused cases and the changed-code gate, and it states that native paired-host testing was not done. The Performance section gives a one-line reason. The Risk section names the riskiest part and gives a revert path, though it does not spell out the user-visible failure mode in detail.

Full details: Out of Scope Changes check

Explanation

The readable diff for runtime-mobile-agent-status-evidence.ts adds one Pi-specific predicate. The summary describes the other changes as the builder fallback, the projection renewal guard, and tests for those paths. All of them touch the Pi child-roster projection for the same stale-idle case in #46585. No terminal lifecycle, provider auth, IPC shape, or mobile storage change appears in the summary. The builder diff could not be read, so its content is taken from the AI-generated summary only.

Full details: Linked Issues check

Explanation

[#46585] The issue requires that a Pi lead with live async children keeps its child rows after 30 minutes of silence. It must show working or 'No recent update', not Done. The reviewed head adds stalePiChildWorkOutlivesIdleTitle in runtime-mobile-agent-status-evidence.ts. The function returns true for a connected Pi row that is working, has an idle PTY title, and has child work that holds the idle lead, with observedAt older than AGENT_STATUS_STALE_AFTER_MS. The projection change in runtime-mobile-agent-status-projection.ts preserves the existing status in this case. The builder change in runtime-mobile-agent-status-builder.ts, which uses the stale row as a live fallback, could not be read: the builder diff returned 'changed blobs are missing from the existing checkout'. The builder test file was also not read. The summary states the builder keeps the original observedAt and the tests cover the stale-child case, but this is not confirmed from source. The desktop decay path and the rowChildWorkHoldsIdleLead time check were not inspected. The PR author reports a native paired-host session was not tested.

Resolution

Provide readable diff or blob access for runtime-mobile-agent-status-builder.ts and runtime-mobile-agent-status-builder.test.ts at head. Confirm that the fallback row keeps the original observedAt, that the output has the child roster, and that the stale-child test fails before the change and passes after it. Confirm that rowChildWorkHoldsIdleLead does not reject the stale row on time alone.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fbd995bd-4ac7-40dd-9ded-b3385b5e2ad3
Commits

Reviewing files that changed from the base of the PR and between c2a5dee and 1060e6b.

Files selected for processing: 4

  • src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-builder.test.ts
  • src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-builder.ts
  • src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-evidence.ts
  • src/main/runtime/session-lifecycle/projection/runtime-mobile-agent-status-projection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

// Keep the last child roster as stale evidence, not a new claim that the pane is active.
const stalePiChildRow =
latestHook &&
ownerAgent === 'pi' &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Heavy lift

Preserve stale Pi children when pane ownership is unknown.

For an attached Pi pane without launch or foreground identity, the stale row is excluded from hookRow.agentType. The ownerAgent === 'pi' check then rejects the row, so refresh returns done without children.

Handle this case without treating every unknown owner as Pi: an OMP pane can also report Pi status. Keep the existing launched-Pi behavior and reject known conflicting owners.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @renningg. Keeping the last Pi child roster on refresh is the right goal, but review found one problem we need solved first.

Clients judge a mirrored row's age by when they received it (withMirroredEvidenceReceipt and agentStatusEvidenceObservedAt ignore host stamps). So a client seeing the pane for the first time (a fresh desktop launch, a new pairing, or the first load on mobile) stamps the held row as received now, and shows it as fresh Working with child rows for up to 30 more minutes before it decays. On main, that client got Done.

If the children have actually ended (a lost completion post, or Pi killed), the status is then wrong for up to 30 minutes, and different clients show different freshness for the same pane. To ship this, clients would need to age the held roster by the host's original timestamp, not by receipt time. Holding until then.

@Pr1p

Pr1p commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Traced both fixes against the reported symptom

I had already mapped #46585's mechanism chain before these PRs appeared, so I read both diffs and
checked where each one lands relative to the break. Sharing the result rather than opening a third
PR against the same issue.

The two PRs do not fix the same link

#46903 keeps the row on its working state: it re-publishes the latest hook row via
toHookLiveAgentRow(latestHook) as liveRow without stamping it fresh. The row therefore keeps
state: 'working' with a stale updatedAt, which is what the existing decay path expects — the
client derives unverifiable from it (resolveAgentRowState → resolveDecayedAgentRowState).
Its test asserts that derivation directly (expect(resolveAgentRowState(status, now, true)) .toBe('unverifiable')), and also asserts child retention.

#46968 builds a separate unverifiable entry and marks it restoredUnconfirmed: true. That
flag is documented for rows hydrated across a host restart, and it changes the client outcome:
resolveDecayedAgentRowState returns idle whenever restoredUnconfirmed === true, regardless of
a live PTY. The issue's complaint is that the row collapses to Done; ending on idle is a
different wrong state, and the row loses its "not reporting" rendering. Its test only asserts the
builder output (state: 'working', restoredUnconfirmed: true) — not what the sidebar renders from
it — so this does not show up.

Which is to say: #46903 targets the actual break (silence reaching the row as if it were
observer-confirmed completion) and lets the existing decay contract do the rest. #46968 adds a
parallel status-construction path and reuses a flag whose meaning is "hydrated from a restart" to
express "not fresh", which is where the two diverge on screen.

Where the two land, and what I initially got wrong

I first assumed runtime-mobile-agent-* meant these rows were phone-only, and that the reported row
came from a different (renderer-side) path. That is wrong and worth correcting in public:
projectSessionTabsForClient takes clientKind: 'mobile' | 'runtime', so a paired desktop consumes
the same projection, its status lands in the renderer's agentStatusByPaneKey store, and
buildExplicitWorktreeAgentRows → resolveAgentRowState renders it. Both PRs therefore sit on the
right path — the difference between them is only the flag and the resulting rendered state.

That makes the restoredUnconfirmed divergence material rather than cosmetic: it is on the exact
path the report describes.

Supporting detail for the idle vs unverifiable distinction: subagent rows survive either way
— buildRunningAgentChildRowModels filters on settled/ownsLiveWork, not display state, and
withFreshness only relabels a running child to unverifiable when the parent is not fresh. So the
child roster is not the differentiator here; the parent row's rendered state is.

Suggestion

If #46903 lands, #46968's AGENT_STATUS_HELD_ROW_MAX_AGE_MS bound (4 h) is the piece worth
carrying over — stored child states never age, and #46903 as written holds indefinitely. That
concern is real and orthogonal to the flag question; a rebase of just that bound onto #46903 would
close both gaps without the second status-construction path.

Happy to be corrected on any of this — I cannot run the paired-desktop repro here, so every claim
above comes from reading the two diffs and the shared decay contract, and I have flagged the one
place I had it wrong (the phone-only assumption).

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @renningg for working on #46585! We landed #48146, which fixes it at the source. While async children hold a turn, the Pi status extension now re-posts the held state every 10 minutes, capped at 24 h, so the host's 30-minute freshness window no longer expires on a live held turn. With that in place, the server-projection change here isn't needed for the issue, so I'm closing this one. Really appreciate the investigation.

@nwparker nwparker closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pi row with running subagents turns Done and loses its child rows after 30 minutes of lead silence on a paired server

3 participants