fix: input timeout bugs — read-raw-byte, SS3, parse-csi-params all use sub-second timeouts now (get-internal-real-time replaces get-universal-time which truncated to integer seconds)

This commit is contained in:
Hermes Agent
2026-05-12 13:42:39 +00:00
parent 30fdb1def8
commit b21daa99b8
19 changed files with 1044 additions and 231 deletions

115
docs/BUG-REPORT.md Normal file
View File

@@ -0,0 +1,115 @@
# cl-tty Code Audit — Bug Report
## Bug 1 [CRITICAL]: dialog rendering undefined functions
**File:** src/components/dialog-package.lisp and src/components/dialog.lisp
**Problem:** `render-dialog` (lines 34, 36, 39) and `render-toast` (lines 114, 115) call `draw-rect`, `draw-border`, `draw-text` without those symbols being available.
**Root cause:** The dialog package definition uses `(:use :cl :cl-tty.input :cl-tty.select)` but `draw-rect`, `draw-border`, and `draw-text` are generic functions exported from `cl-tty.backend`. They need to be imported. The package does NOT use `cl-tty.backend`.
**Tests don't catch this** because dialog-tests.lisp tests push/pop/toast management but never calls `render-dialog` or `render-toast`.
**Fix:** Add `:cl-tty.backend` to the `:use` list in dialog-package.lisp, or add individual `:import-from` entries for the three functions.
---
## Bug 2 [HIGH]: SBCL "function T is undefined" warning in input.lisp
**File:** src/components/input.lisp
**Problem:** When SBCL compiles this file, it issues:
"WARNING: The function T is undefined, and its name is reserved by ANSI CL so that even if it were defined later, the code doing so would not be portable."
The warning fires during the `defmethod read-event` compilation unit but the exact source is not identified by line number. The file uses `(t ...)` in case/cond default clauses extensively and `:ctrl t`, `:alt t` etc. as keyword argument values. The root cause needs investigation — could be the `case` macro expansion or a `return-from` interaction.
**Note:** this warning does NOT fire when `(compile 'read-event)` or `(compile nil '(lambda ...))` is called in isolation on individual functions. It only fires during `compile-file` on the whole file. This suggests it's a cross-form interaction.
**Investigation needed.**
---
## Bug 3 [MEDIUM]: text-input.lisp ignores variable that IS read
**File:** src/components/text-input.lisp, lines 163, 169-170
```lisp
(w (if ln (layout-node-width ln) 80)) ; line 163 — defined
...
(truncated (subseq display 0 (min (length display) w))) ; line 169 — USED
(declare (ignore w cursor)) ; line 170 — declared ignored
```
**Problem:** `w` is declared as `(ignore w)` on line 170 but is actually read on line 169. Declare ignore + read is a compiler-level contradiction. The `cursor` variable is legitimately unused and should remain ignored.
**Fix:** Remove `w` from the ignore declaration. Only `(declare (ignore cursor))`.
---
## Bug 4 [MEDIUM]: markdown.lisp ignores variable that IS read
**File:** src/components/markdown.lisp, lines 142-144
```lisp
(defun parse-list (lines start)
(declare (ignore start)) ; line 143
(let ((items nil) (i start)) ; line 144 — USES start!
```
**Problem:** Same pattern as bug 3. `start` is declared ignored then immediately used. The declaration should be removed.
**Fix:** Remove the `(declare (ignore start))` declaration.
---
## Bug 5 [MEDIUM]: scrollbox.lisp unused vx variable
**File:** src/components/scrollbox.lisp, line 45
```lisp
(vx 0) (vy 0)
```
**Problem:** `vx` is bound but never read — `vy` is used for viewport height calculations but viewport-x/vx is never referenced. This is a style-warning that indicates either dead code or a real issue where viewport-x should be used.
**Fix:** Add `(declare (ignore vx))` or remove the `vx` binding entirely.
---
## Bug 6 [LOW]: %simple-border-char ignores edge-style
**File:** backend/simple.lisp, lines 33-40
```lisp
(defun %simple-border-char (edge-style pos)
"Return ASCII border character for EDGE-STYLE at POS."
(case pos
((:top-left :top-right :bottom-left :bottom-right) #\+)
(:horizontal #\-)
(:vertical #\|)))
```
**Problem:** The `edge-style` parameter is never consulted. Always returns `+ - |` regardless of style. Callers also pass `nil` for it:
```lisp
(%simple-border-char nil :horizontal)
```
**Fix:** Either remove the `edge-style` parameter (dead code) or implement border style selection using `case` on `edge-style`.
---
## Bug 7 [LOW]: framebuffer draw-border ignores title-align
**File:** src/rendering/framebuffer.lisp, lines 94, 114-116
```lisp
(defmethod draw-border ((fb framebuffer-backend) x y w h &key (style :single) title title-align fg bg)
...
(when title
(loop for i from 0 below (length title)
do (%set-cell fb (+ x 2 i) y (char title i) :fg fg :bg bg))))
```
**Problem:** `title-align` is accepted but never used. Title always renders at offset 2 from left edge (hard-coded). The simple backend centers the title, the framebuffer backend left-aligns — inconsistent API behavior.
**Fix:** Implement `title-align` support or add `(declare (ignore title-align))` and document the behavior.