feat: add terminal session management with HTTP/WebSocket routes and session history

This commit is contained in:
2026-09-25 20:31:20 +05:30
parent caaea12163
commit d870c98bfa
5 changed files with 240 additions and 17 deletions
+5 -5
View File
@@ -78,7 +78,7 @@ agent['child_main'](Path({str(self.scope.path)!r}), {username!r}, None)
self.assertFalse(self.thread.is_alive())
async def test_terminal_has_tty_persistent_shell_state_and_exit_code(self):
await self.terminal.write(b"test -t 0 && printf 'REAL-TTY\\n'\r")
await self.terminal.write(b"test -t 0 && printf '\\nREAL-TTY\\n'\r")
await self.until(b"\r\nREAL-TTY\r\n")
await self.terminal.write(b"export NEST_TEST=hello; cd /\r")
await self.terminal.write(b"printf 'STATE:%s:%s\\n' \"$NEST_TEST\" \"$PWD\"\r")
@@ -95,15 +95,15 @@ agent['child_main'](Path({str(self.scope.path)!r}), {username!r}, None)
await self.terminal.resize(40, 120)
await self.terminal.write(b"stty size\r")
await self.until(b"40 120\r\n")
await self.terminal.write(b"sleep 20\r")
await asyncio.sleep(0.1)
await self.terminal.write(b"sh -c 'printf \"\\nJOB-STARTED\\n\"; exec sleep 20'\r")
await self.until(b"\r\nJOB-STARTED\r\n")
await self.terminal.write(b"\x03")
await self.until(self.prompt)
await self.terminal.write(b"printf 'INTERRUPTED\\n'\r")
await self.terminal.write(b"printf '\\nINTERRUPTED\\n'\r")
await self.until(b"\r\nINTERRUPTED\r\n")
async def test_explicit_end_terminates_the_shell(self):
await self.terminal.write(b"printf 'READY\\n'\r")
await self.terminal.write(b"printf '\\nREADY\\n'\r")
await self.until(b"\r\nREADY\r\n")
await self.terminal.end()
async with asyncio.timeout(5):