MCPcopy Create free account
hub / github.com/block/buzz / ensureMutable

Function ensureMutable

desktop/src/features/agents/ui/agentSessionTranscript.ts:100–106  ·  view source on GitHub ↗

Lazily copy items + itemsById on first mutation so callers get new refs.

(d: TranscriptDraft)

Source from the content-addressed store, hash-verified

98
99/** Lazily copy items + itemsById on first mutation so callers get new refs. */
100function ensureMutable(d: TranscriptDraft) {
101 if (!d.changed) {
102 d.items = [...d.items];
103 d.itemsById = new Map(d.itemsById);
104 d.changed = true;
105 }
106}
107
108function replaceItem(d: TranscriptDraft, id: string, updated: TranscriptItem) {
109 ensureMutable(d);

Callers 2

replaceItemFunction · 0.85
pushItemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected