Skip to content

fix: render existing agents when layout is already loaded#338

Open
yshyuk wants to merge 1 commit into
pixel-agents-hq:mainfrom
yshyuk:fix/existing-agents-after-layout
Open

fix: render existing agents when layout is already loaded#338
yshyuk wants to merge 1 commit into
pixel-agents-hq:mainfrom
yshyuk:fix/existing-agents-after-layout

Conversation

@yshyuk

@yshyuk yshyuk commented Jul 12, 2026

Copy link
Copy Markdown

Problem

In standalone mode, restored/external agents show up in the debug view but their characters never appear on the office canvas after a page load or refresh.

Cause

On webview connect, the standalone server sends layoutLoaded before existingAgents (server/src/clientMessageHandler.ts). The existingAgents handler in webview-ui/src/hooks/useExtensionMessages.ts unconditionally buffers incoming agents into pendingAgents, which is only flushed by a subsequent layoutLoaded. Since that message has already passed, the buffer never flushes: React state (setAgents) is updated — hence the debug view shows the agents — but os.addAgent() is never called, so no characters are created.

Fix

In the existingAgents handler, if the layout is already ready (layoutReadyRef.current), add the characters immediately via os.addAgent() (deduped against os.characters). The buffering path is kept for the case where existingAgents arrives before layoutLoaded.

How to reproduce / verify

  1. npx pixel-agents with previously persisted external agents (or adopt a couple of running Claude Code sessions with Watch All Sessions on).
  2. Open/refresh http://localhost:3100.
  3. Before: office renders with no characters; debug view lists the agents. After: characters render at their seats immediately.

In standalone mode the server sends layoutLoaded before existingAgents
on webview connect. The existingAgents handler unconditionally buffered
agents into pendingAgents, which is only flushed by a subsequent
layoutLoaded — so restored agents appeared in the debug view (React
state) but their characters were never added to the canvas.

Add characters immediately when the layout is already ready, and keep
the buffering path for the case where existingAgents arrives first.
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