Skip to content

webchat: 'agent is working' spinner never clears after reply #28

Closed

Description

@melvincarvalho

What happens

After the agent replies in the webchat, the agent is working ●●● indicator stays on screen indefinitely, even though the answer has already been rendered.

Seen on a live gateway (v0.0.11) with the agent-micro runner; the same should apply to any runner that keeps the agent process alive between messages.

Why

In src/webchat.html, the agent.output handler clears the typing indicator, renders the result, then immediately turns the indicator back on, expecting the final res frame to clear it:

if (frame.type === 'event' && frame.event === 'agent.output') {
  setTyping(false);
  if (frame.payload.result) add('agent', frame.payload.result);
  setTyping(true);          // <-- stays on until the res frame
} else if (frame.type === 'res') {
  ...
  setTyping(false);
}

But the res frame for chat.send is only sent when runContainerAgent() resolves — and that promise resolves when the agent process exits. Agents deliberately stay alive after answering, polling for follow-up IPC messages until the _close sentinel or the 30-minute containerTimeout. So in normal operation the res arrives ~30 minutes after the reply, and the spinner spins the whole time.

Possible fixes

  • Treat a status: "success" / status: "error" agent.output event as end-of-turn in the webchat and clear the indicator there (smallest change, webchat-only).
  • Or send the chat.send res when the first terminal output arrives rather than on process exit (changes gateway semantics for all WS clients — raw clients currently have the same problem, they cannot await res per turn).

Repro

  1. npx jsclaw gateway, open the chat URL
  2. Send any message
  3. Reply renders; agent is working ●●● remains until the container exits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions