fix: render existing agents when layout is already loaded#338
Open
yshyuk wants to merge 1 commit into
Open
Conversation
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.
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.
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
layoutLoadedbeforeexistingAgents(server/src/clientMessageHandler.ts). TheexistingAgentshandler inwebview-ui/src/hooks/useExtensionMessages.tsunconditionally buffers incoming agents intopendingAgents, which is only flushed by a subsequentlayoutLoaded. Since that message has already passed, the buffer never flushes: React state (setAgents) is updated — hence the debug view shows the agents — butos.addAgent()is never called, so no characters are created.Fix
In the
existingAgentshandler, if the layout is already ready (layoutReadyRef.current), add the characters immediately viaos.addAgent()(deduped againstos.characters). The buffering path is kept for the case whereexistingAgentsarrives beforelayoutLoaded.How to reproduce / verify
npx pixel-agentswith previously persisted external agents (or adopt a couple of running Claude Code sessions with Watch All Sessions on).http://localhost:3100.