MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / writeTerminal

Function writeTerminal

desktop/terminal/manager.ts:175–210  ·  view source on GitHub ↗
(sessionId: string, data: string)

Source from the content-addressed store, hash-verified

173}
174
175export async function writeTerminal(sessionId: string, data: string) {
176 const record = getTerminalSession(sessionId)
177 const input = record ? applyTerminalInputToBuffer(record.inputBuffer, data) : null
178
179 if (record && input) {
180 record.inputBuffer = input.nextBuffer
181 if (input.submittedLines.some((line) => line.trim() && line.trim() !== 'clear')) {
182 record.suppressOutputVisibilityUntilInput = false
183 markTerminalVisible(record)
184 }
185 }
186
187 if (!(record?.process && data.length > 0)) {
188 if (record && data.length > 0 && isRestartableTerminalStatus(record.snapshot.status)) {
189 record.snapshot = {
190 ...record.snapshot,
191 status: 'starting',
192 exitCode: null,
193 exitSignal: null,
194 updatedAt: nowIso(),
195 }
196 await ensureProcessStarted(record, 'restarted')
197 record.process?.write(data)
198 if (input?.submittedLines.some((line) => line.trim() === 'clear')) {
199 clearTerminalHistory(record)
200 }
201 }
202 return
203 }
204
205 record.process.write(data)
206
207 if (input?.submittedLines.some((line) => line.trim() === 'clear')) {
208 clearTerminalHistory(record)
209 }
210}
211
212export async function resizeTerminal(sessionId: string, cols: number, rows: number) {
213 const record = getTerminalSession(sessionId)

Callers

nothing calls this directly

Calls 8

getTerminalSessionFunction · 0.90
nowIsoFunction · 0.90
markTerminalVisibleFunction · 0.85
ensureProcessStartedFunction · 0.85
clearTerminalHistoryFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected