The opencode acp binary streams agent_message_chunk notifications with an EMPTY messageId. The backend was already correct (it groups when a messageId is present), but the UI rendered every chunk as its own bubble, so a single 'count 1 to 5' reply showed as 9 separate bubbles. Backend: - internal/acp/history.go: add MessageID to Message; new AppendOrCreate method that finds or creates an entry by messageId and appends text to it (preserving the original timestamp). - internal/acp/client.go: agent_message_chunk and user_message_chunk use AppendOrCreate. - internal/model/acp.go: expose MessageID in the wire response. - internal/service/acp_service.go: copy MessageID into the API DTO. - internal/acp/client_test.go: add TestHistoryAppendOrCreateGroupsByMessageID. Frontend: - web/src/components/acp/groupMessages.ts: new pure helper that coalesces consecutive same-role history entries into a single bubble (keeps the first chunk's time + messageId). - web/src/components/acp/AcpPanel.tsx: render coalesced messages; auto-scroll effect now depends on coalesced so it fires as the agent streams. Verified via e2e: 'count from 1 to 5' now returns a single agent entry with text '1\n2\n3\n4\n5' instead of 9 separate entries.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// AcpStatusResponse is the API response for ACP status.
|
|
type AcpStatusResponse struct {
|
|
WorkspaceID string `json:"workspaceId"`
|
|
Ready bool `json:"ready"`
|
|
SessionID string `json:"sessionId,omitempty"`
|
|
Running bool `json:"running"`
|
|
PID int `json:"pid,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// AcpMessage is a single role/text/time entry in the ACP history.
|
|
type AcpMessage struct {
|
|
Role string `json:"role"`
|
|
Text string `json:"text"`
|
|
Time time.Time `json:"time"`
|
|
MessageID string `json:"messageId,omitempty"`
|
|
}
|
|
|
|
// AcpHistoryResponse is the API response for ACP history.
|
|
type AcpHistoryResponse struct {
|
|
SessionID string `json:"sessionId"`
|
|
Messages []AcpMessage `json:"messages"`
|
|
}
|
|
|
|
// AcpPromptRequest is the body for POST /acp/prompt.
|
|
type AcpPromptRequest struct {
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
// AcpPromptResponse is the API response for a prompt turn.
|
|
type AcpPromptResponse struct {
|
|
SessionID string `json:"sessionId"`
|
|
StopReason string `json:"stopReason"`
|
|
Text string `json:"text"`
|
|
}
|