fix(webcrt): replay login banner/prompt on attach

Drain and nudge the device prompt after Netmiko login, replay bootstrap stdout when the WebSocket attaches, and surface connect errors in the terminal pane.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-07-29 18:54:59 +08:00
parent 8e3bed562f
commit 30f2db9708
6 changed files with 87 additions and 9 deletions

View file

@ -145,8 +145,11 @@ class WebcrtServiceTests(unittest.TestCase):
self.assertEqual(out["ne_id"], "ne-hop")
sess = svc.get_session(out["session_id"])
assert sess is not None
# create_session may nudge Enter when no prompt was drained.
before = list(fake.written)
sess.write_stdin("\n")
self.assertEqual(fake.written, ["\n"])
self.assertEqual(fake.written[len(before) :], ["\n"])
self.assertTrue(isinstance(sess.bootstrap_output, (bytes, bytearray)))
svc.close_session(out["session_id"], reason="test")
@patch.object(svc, "_audit")