MCPcopy Index your code
hub / github.com/coder/coder / snapshotBufferLocked

Function snapshotBufferLocked

coderd/x/chatd/chatd.go:4643–4655  ·  view source on GitHub ↗

snapshotBufferLocked returns the buffered message_part events that the caller should receive in their initial snapshot. Parts whose committedMessageID != 0 are dropped: those parts were claimed by a durable assistant message that the subscriber will receive through a different channel (REST snapsho

(buffer []bufferedStreamPart)

Source from the content-addressed store, hash-verified

4641//
4642// The caller must hold the per-chat stream state lock.
4643func snapshotBufferLocked(buffer []bufferedStreamPart) []codersdk.ChatStreamEvent {
4644 if len(buffer) == 0 {
4645 return nil
4646 }
4647 snapshot := make([]codersdk.ChatStreamEvent, 0, len(buffer))
4648 for _, part := range buffer {
4649 if part.committedMessageID != 0 {
4650 continue
4651 }
4652 snapshot = append(snapshot, part.event)
4653 }
4654 return snapshot
4655}
4656
4657// subscribeToStream registers a subscriber to the per-chat in-memory
4658// stream and returns a snapshot of currently in-progress message_part

Calls

no outgoing calls