feat(im): align agent stream display with web thinking and tool progress
Mirror Web AgentStreamDisplay/RagPipelineProgress in IM text streams: retract live answers into 思考过程, show Web-aligned tool titles with query/summary from structured data, and collapse thinking on finalize instead of dropping it entirely.
This commit is contained in:
@@ -276,8 +276,8 @@ func (a *Adapter) StartStream(ctx context.Context, incoming *im.IncomingMessage)
|
||||
return streamID, nil
|
||||
}
|
||||
|
||||
func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMessage, streamID string, content string) error {
|
||||
if content == "" {
|
||||
func (a *Adapter) UpdateStreamContent(ctx context.Context, incoming *im.IncomingMessage, streamID string, fullContent string) error {
|
||||
if fullContent == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -289,17 +289,25 @@ func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMess
|
||||
}
|
||||
|
||||
state.mu.Lock()
|
||||
state.content.WriteString(content)
|
||||
full := state.content.String()
|
||||
state.content.Reset()
|
||||
state.content.WriteString(fullContent)
|
||||
postID := state.postID
|
||||
state.mu.Unlock()
|
||||
|
||||
if err := a.client.PatchPostMessage(ctx, postID, full); err != nil {
|
||||
if err := a.client.PatchPostMessage(ctx, postID, fullContent); err != nil {
|
||||
logger.Warnf(ctx, "[Mattermost] Patch post failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Adapter) FinalizeStream(ctx context.Context, incoming *im.IncomingMessage, streamID string, finalContent string) error {
|
||||
return a.UpdateStreamContent(ctx, incoming, streamID, finalContent)
|
||||
}
|
||||
|
||||
func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMessage, streamID string, content string) error {
|
||||
return a.UpdateStreamContent(ctx, incoming, streamID, content)
|
||||
}
|
||||
|
||||
func (a *Adapter) EndStream(ctx context.Context, incoming *im.IncomingMessage, streamID string) error {
|
||||
mmStreamsMu.Lock()
|
||||
state, ok := mmStreams[streamID]
|
||||
|
||||
Reference in New Issue
Block a user