Improve WebCRT connect UX and terminal input handling.

Open shells asynchronously with clearer prompt settling, fix Telnet CRLF expansion, and add right-click paste with safer focus behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-10-11 22:55:31 +08:00
parent 1463652dbb
commit 3b45d6abe3
8 changed files with 108 additions and 71 deletions

View file

@ -89,10 +89,8 @@ def map_network_cli_enter(data: str, conn: ConnectHandler | None) -> str:
if not text:
return text
ret = channel_return(conn)
if ret == "\r":
return text
# Prefer replacing CRLF first so Telnet RETURN \\r\\n does not double-expand.
return text.replace("\r\n", ret).replace("\r", ret)
# Replace once: chained replacements expand the CR in Telnet CRLF again.
return re.sub(r"\r\n|\r|\n", lambda _match: ret, text)
def _drain_channel(conn: ConnectHandler, *, rounds: int = 6, wait: float = 0.06) -> str:

View file

@ -208,9 +208,8 @@ def api_quick_connect(
user_override = str(body.username or "").strip() or None
if str(body.password or "").strip():
pwd_override = str(body.password)
# SSH with password: wait for auth so wrong credentials can re-prompt (SecureCRT-like).
wait_for_auth = proto == "ssh" and bool(pwd_override)
async_connect = bool(body.async_connect) and not wait_for_auth
# Open the terminal immediately; WS reports auth progress and retryable failures.
async_connect = bool(body.async_connect)
try:
session = create_session(
db,

View file

@ -453,8 +453,12 @@ def _finish_connect(
text = _decode_bytes(chunk, sess.encoding)
except Exception:
text = ""
if _is_prompt_only_echo(text, prompt_hint):
# A slow VM may emit its FIRST prompt after the reader starts.
# Only drop duplicates when a prompt was already delivered during login.
if _looks_like_cli_prompt(final_view) and _is_prompt_only_echo(text, prompt_hint):
continue
if _looks_like_cli_prompt(text):
sess.needs_live_prompt = False
# Non-prompt data: put back and stop settling.
sess.out_queue.put(chunk)
break