Skip WebCRT audit for empty Enter on prompt-only lines.

Do not reuse the previous command when the operator presses Enter on a blank prompt; validate prompt-only rows on both frontend and backend.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-02 11:37:06 +08:00
parent b35e56afb0
commit 7ca57278fe
4 changed files with 109 additions and 21 deletions

View file

@ -539,6 +539,34 @@ def _is_prompt_command_line(line: str) -> bool:
)
def is_auditable_command_line(line: str) -> bool:
"""False for empty Enter (prompt only, no command text)."""
s = normalize_audit_line(line)
if not s.strip():
return False
if _is_prompt_only_line(s):
return False
return True
def _is_prompt_only_line(line: str) -> bool:
"""True when line is a device prompt with no command typed."""
s = normalize_audit_line(line)
if not s:
return True
return bool(
re.match(
r"^(?:"
r"[\w.-]+(?:\([^)]+\))*[#>]\s*"
r"|<[^>]+>\s*"
r"|\[[^\]]+\]\s*"
r")$",
s,
flags=re.I,
)
)
def extract_last_prompt_command(text: str) -> str | None:
"""Last prompt+command line in PTY transcript (tab-complete redraw aware).