(size?: { cols?: number; rows?: number })
| 44 | } |
| 45 | |
| 46 | async function start(size?: { cols?: number; rows?: number }): Promise<void> { |
| 47 | const sid = sessionId.value; |
| 48 | if (!sid || loading.value) return; |
| 49 | loading.value = true; |
| 50 | error.value = null; |
| 51 | try { |
| 52 | const api = getKimiWebApi(); |
| 53 | const existing = (await api.listTerminals(sid)).find((item) => item.status === 'running'); |
| 54 | const next = existing ?? await api.createTerminal(sid, { |
| 55 | cols: size?.cols, |
| 56 | rows: size?.rows, |
| 57 | }); |
| 58 | terminal.value = next; |
| 59 | readOnly.value = next.status === 'exited'; |
| 60 | ensureConnection()?.terminalAttach(sid, next.id, lastSeq.value); |
| 61 | } catch (error_) { |
| 62 | error.value = error_ instanceof Error ? error_.message : String(error_); |
| 63 | } finally { |
| 64 | loading.value = false; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | function write(data: string): void { |
| 69 | const current = terminal.value; |
no test coverage detected