Skip to content

fix(desktop): let a provider-backed agent be restarted after shutdown - #1

Merged
renatobardi merged 1 commit into
mainfrom
fix/provider-agent-restart-after-shutdown
Aug 31, 2026
Merged

renatobardi merged 1 commit into
mainfrom
fix/provider-agent-restart-after-shutdown

Conversation

@renatobardi

Copy link
Copy Markdown
Owner

Summary

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-backed agent went offline it had no way back through the UI: the primary action stayed permanently wired to resend !shutdown, never reaching start again.

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

Related issue

None found.

Testing

  • Added unit tests pinning isManagedAgentActive as backend-agnostic (deployed provider agent / running local agent / never-deployed provider agent / stopped local agent).
  • pnpm exec tsc --noEmit clean.
  • pnpm exec biome check clean.
  • Full agents/profile/channels feature test suites: 2025/2025 passing.
  • Found while debugging a real deploy: a provider-backed agent (buzz-backend-lxc) shut down via !shutdown showed no way to restart it from the Buzz Desktop UI, even after quitting and reopening the app.

Co-Authored-By: Claude Sonnet 5 [email protected]

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 <[email protected]>
Signed-off-by: Renato Bardi <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 878b1a03-c11f-4bf2-b8bd-58c29c673681


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

Comment @coderabbitai help to get the list of available commands.

@renatobardi
renatobardi merged commit 62bbd78 into main Aug 31, 2026
1 check passed
renatobardi pushed a commit that referenced this pull request Sep 7, 2026
…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 <[email protected]>
Signed-off-by: Renato Bardi <[email protected]>
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