MCPcopy Index your code
hub / github.com/simstudioai/sim / applyWindow

Function applyWindow

apps/sim/lib/copilot/tools/handlers/vfs.ts:226–236  ·  view source on GitHub ↗
(result: T)

Source from the content-addressed store, hash-verified

224 const offset = parseOptionalNumber(params.offset)
225 const limit = parseOptionalNumber(params.limit)
226 const applyWindow = <T extends { content: string; totalLines: number }>(result: T): T => {
227 if (offset === undefined && limit === undefined) return result
228 const lines = result.content.split('\n')
229 const start = Math.max(0, Math.min(result.totalLines, offset ?? 0))
230 const endRaw = limit !== undefined ? start + Math.max(0, limit) : result.totalLines
231 const end = Math.max(start, Math.min(result.totalLines, endRaw))
232 return {
233 ...result,
234 content: lines.slice(start, end).join('\n'),
235 }
236 }
237
238 // Handle chat-scoped uploads via the uploads/ virtual prefix.
239 // Uploads are flat and have no metadata/content split like files/ — the upload

Callers 1

executeVfsReadFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected