(sessionId: string, data: string)
| 173 | } |
| 174 | |
| 175 | export 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 | |
| 212 | export async function resizeTerminal(sessionId: string, cols: number, rows: number) { |
| 213 | const record = getTerminalSession(sessionId) |
nothing calls this directly
no test coverage detected