mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-07-09 17:28:58 +00:00
35 lines
867 B
Go
35 lines
867 B
Go
package tool
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/open-code-review/open-code-review/internal/model"
|
|
)
|
|
|
|
// CommentCollector is a thread-safe, per-Agent comment store.
|
|
// Each Agent instance owns its own collector so reviews across different repos do not interfere.
|
|
type CommentCollector struct {
|
|
mu sync.Mutex
|
|
comments []model.LlmComment
|
|
}
|
|
|
|
// NewCommentCollector creates an empty collector.
|
|
func NewCommentCollector() *CommentCollector {
|
|
return &CommentCollector{}
|
|
}
|
|
|
|
// Add appends a comment to the collector.
|
|
func (c *CommentCollector) Add(cm model.LlmComment) {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
c.comments = append(c.comments, cm)
|
|
}
|
|
|
|
// Comments returns all collected comments.
|
|
func (c *CommentCollector) Comments() []model.LlmComment {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
out := make([]model.LlmComment, len(c.comments))
|
|
copy(out, c.comments)
|
|
return out
|
|
}
|