MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / sendOutput

Function sendOutput

projects/electron/src/modules/code/process.ts:237–265  ·  view source on GitHub ↗

* Send output chunk to renderer

(processId: string, type: "stdout" | "stderr", data: string)

Source from the content-addressed store, hash-verified

235 * Send output chunk to renderer
236 */
237function sendOutput(processId: string, type: "stdout" | "stderr", data: string): void {
238 const proc = activeProcesses.get(processId)
239 if (!proc) return
240
241 const chunk: ProcessOutputChunk = {
242 type,
243 data,
244 timestamp: Date.now(),
245 }
246
247 // Buffer the output (with size limit)
248 const chunkSize = Buffer.byteLength(data, "utf8")
249 if (proc.bufferSizeBytes + chunkSize <= MAX_BUFFER_SIZE_BYTES) {
250 proc.outputBuffer.push(chunk)
251 proc.bufferSizeBytes += chunkSize
252 } else {
253 // Buffer full - shift old entries to make room
254 while (proc.outputBuffer.length > 0 && proc.bufferSizeBytes + chunkSize > MAX_BUFFER_SIZE_BYTES) {
255 const removed = proc.outputBuffer.shift()
256 if (removed) {
257 proc.bufferSizeBytes -= Buffer.byteLength(removed.data, "utf8")
258 }
259 }
260 proc.outputBuffer.push(chunk)
261 proc.bufferSizeBytes += chunkSize
262 }
263
264 emitLifecycle({ type: "output", processId, chunk })
265}
266
267/**
268 * Send exit event to renderer

Callers 1

setupProcessHandlersFunction · 0.70

Calls 3

pushMethod · 0.80
emitLifecycleFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected