Skip to content

fix(desktop): use live presence, not control-plane status, for a provider agent's status/action - #7078

Open
renatobardi wants to merge 3 commits into
block:mainfrom
renatobardi:fix/provider-agent-live-status-2
Open

fix(desktop): use live presence, not control-plane status, for a provider agent's status/action#7078
renatobardi wants to merge 3 commits into
block:mainfrom
renatobardi:fix/provider-agent-live-status-2

Conversation

@renatobardi

Copy link
Copy Markdown

Summary

runtime.rs documents a two-axis model for remote agents: control-plane status ("deployed" = the provider was invoked) stays permanent once set — there is no v1 undeploy — while live presence (online/away/offline) is "the real-time signal for whether the harness is connected." The primary Shutdown/Deploy label, its click handler, the profile avatar dot, and the members-sidebar status badge/icon all read only the control-plane status, so a provider agent that goes offline via !shutdown looks and behaves as if still running forever: the dot stays green, the label stays "Shutdown", and clicking it just resends !shutdown to an already-dead agent instead of ever reaching start.

Adds isManagedAgentLive(agent, presenceStatus), which defers to presence for provider backends (falling back to control-plane status only while presence hasn't resolved yet, avoiding a flash of "offline"), and wires it into every place that decides what a provider agent's live state looks like: the profile panel's avatar dot, primary action label/click decision, and their members-sidebar counterparts (badge, icon, label, click decision).

isManagedAgentActive itself is untouched — it stays the correct, presence-independent check for the Restart affordance (#7072) and other control-plane-only callers (e.g. picking which instance to show, sorting).

Out of scope, left as-is: the Agents grid (UnifiedAgentsSection.tsx) has no presence data plumbed in at all today — wiring that in is a separate, larger change (new query + multi-level prop threading). Likewise the real-time observer-attachment call sites (ManagedAgentSessionPanel, profileActivityFeedScope, AgentSessionThreadPanel) share the same root cause but are a distinct, riskier surface (live event streaming) left for a follow-up.

Related issue

Builds on #7072 (Restart affordance). None found for this specific issue.

Testing

  • Added unit tests for isManagedAgentLive: online/away → live, offline → not live, unresolved presence falls back to control-plane status, local agents ignore presence entirely.
  • pnpm exec tsc --noEmit clean.
  • pnpm exec biome check clean.
  • Full agents/profile/channels feature test suites: 2030/2030 passing.
  • Validated live in production: built and installed a local release build, ran a real Stop→Start cycle on a provider-backed agent through the primary action button (not the separate Restart button) — server logs confirm graceful shutdown (presence set to offline) followed by a real redeploy (new process, connected to relay, presence set to online), where before this fix the same click just resent an ineffective !shutdown.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

Renato Bardi and others added 3 commits August 30, 2026 21:33
The profile panel's Restart affordance was gated to
`backend.type === "local"`, but a provider agent's `status` is a
control-plane fact (runtime.rs's two-axis model: "the provider was
invoked") that stays "deployed" forever once set — there is no v1
undeploy. It never reverts after `!shutdown` takes the harness offline,
so once a provider agent went offline it had no way back: the primary
action stayed permanently wired to resend `!shutdown`, never `start`.

respawnManagedAgentWithRules already handles provider backends
correctly (skips the stop step, calls start directly), so the local-only
gate was just an unnecessary restriction — isManagedAgentActive is
already backend-agnostic. Drop the extra check and use it directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Renato Bardi <renato.bardi@outlook.com>
…er-shutdown

fix(desktop): let a provider-backed agent be restarted after shutdown
…ider agent's status/action

runtime.rs documents a two-axis model for remote agents: control-plane
status ("deployed" = the provider was invoked) stays permanent once set
— there is no v1 undeploy — while live presence (online/away/offline)
is "the real-time signal for whether the harness is connected". The
primary Shutdown/Deploy label, its click handler, the profile avatar
dot, and the members-sidebar status badge/icon all read only the
control-plane status, so a provider agent that goes offline via
`!shutdown` looks and behaves as if still running forever: the dot
stays green, the label stays "Shutdown", and clicking it just resends
`!shutdown` to an already-dead agent instead of ever reaching `start`.

Add isManagedAgentLive(agent, presenceStatus), which defers to presence
for provider backends (falling back to control-plane status only while
presence hasn't resolved yet, avoiding a flash of "offline"), and wire
it into every place that decides what a provider agent's live state
looks like: the profile panel's avatar dot, primary action label/click
decision, and their members-sidebar counterparts (badge, icon, label,
click decision).

isManagedAgentActive itself is untouched — it stays the correct,
presence-independent check for the Restart affordance (already fixed
in #1) and other control-plane-only callers (e.g. picking which
instance to show, sorting).

Out of scope, left as-is: the Agents grid (UnifiedAgentsSection.tsx)
has no presence data plumbed in at all today — wiring that in is a
separate, larger change (new query + multi-level prop threading), not
folded into this fix. Likewise the real-time observer-attachment call
sites (ManagedAgentSessionPanel, profileActivityFeedScope, AgentSessionThreadPanel)
share the same root cause but are a distinct, riskier surface (live
event streaming) left for a follow-up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Renato Bardi <renato.bardi@outlook.com>
@renatobardi
renatobardi requested a review from a team as a code owner August 31, 2026 01:55
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is eed74bde2f4797714335ac10c56c0b0244c1def4...e5eee5054d06d39421277e3e02977ee677699083.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review e5eee5054d06d39421277e3e02977ee677699083 to authorize a new review.
Any previous review applies only to its recorded range.

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.

1 participant