MCPcopy Index your code
hub / github.com/anomalyco/opencode / syncPermission

Function syncPermission

packages/opencode/src/cli/cmd/run/session-data.ts:342–372  ·  view source on GitHub ↗
(data: SessionData, part: ToolPart)

Source from the content-addressed store, hash-verified

340// tool's evolving state. Only triggers a footer update if the currently
341// displayed permission was the one that changed.
342function syncPermission(data: SessionData, part: ToolPart): FooterOutput | undefined {
343 data.call.set(key(part.messageID, part.callID), part.state.input)
344 if (data.permissions.length === 0) {
345 return undefined
346 }
347
348 let changed = false
349 let active = false
350 data.permissions = data.permissions.map((request, index) => {
351 if (!request.tool || request.tool.messageID !== part.messageID || request.tool.callID !== part.callID) {
352 return request
353 }
354
355 const next = enrichPermission(data, request)
356 if (next === request) {
357 return request
358 }
359
360 changed = true
361 active ||= index === 0
362 return next
363 })
364
365 if (!changed || !active) {
366 return undefined
367 }
368
369 return {
370 view: pickSessionView(data),
371 }
372}
373
374// Question tool replies can complete without a matching question.replied event.
375// When that happens, drop the recovered pending request tied to this tool call so

Callers 1

reduceSessionDataFunction · 0.85

Calls 4

enrichPermissionFunction · 0.85
pickSessionViewFunction · 0.85
keyFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected