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

Function stripEcho

packages/opencode/src/cli/cmd/run/session-data.ts:490–511  ·  view source on GitHub ↗
(data: SessionData, msg: string | undefined, chunk: string)

Source from the content-addressed store, hash-verified

488}
489
490function stripEcho(data: SessionData, msg: string | undefined, chunk: string): string {
491 if (!msg) {
492 return chunk
493 }
494
495 const set = data.echo.get(msg)
496 if (!set || set.size === 0) {
497 return chunk
498 }
499
500 data.echo.delete(msg)
501 const list = [...set].sort((a, b) => b.length - a.length)
502 for (const item of list) {
503 if (!item || !chunk.startsWith(item)) {
504 continue
505 }
506
507 return chunk.slice(item.length).replace(/^\n+/, "")
508 }
509
510 return chunk
511}
512
513function flushPart(data: SessionData, commits: SessionCommit[], partID: string, interrupted = false) {
514 const kind = data.part.get(partID)

Callers 1

flushPartFunction · 0.85

Calls 2

getMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected