Count wrapped rows when clearing a shown password or seed on Linux
Los mantenedores suelen responder en 1 día
@dotnetdork ya está trabajando en esto.
Desde el 2/11/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Read first
- Design 04, section 2.3 (a new password is shown once, then cleared from the screen)
- Design 16, section 4.1 (a new decoy seed is shown the same way)
- Issue #140 and PR #143: the same fix on Windows.
Read these before starting. If this issue and the spec disagree, the spec wins; say so in the pull request.
Summary
On Linux, the screen that shows a new password or decoy seed once moves the cursor up a fixed number of lines and clears from there. On a narrow terminal, a long line (the prompt, or a long seed) wraps onto two or more rows, so the count is too small and the top of the block, including the secret, can stay on screen. Count rows, not lines, as the Windows version now does.
Depends on
Nothing.
Location & Context
core/secret/secret.sh,lab_secret_show:lines=6, plus one per repeated prompt, thenlab_tty_write $'\r\033['"$lines"$'A\033[J'.core/seed/seed.sh,lab_seed_show: the same pattern.- The Windows version (
Get-LabTerminalRowCountandGet-LabClearRowincore/secret/Secret.ps1, from PR #143) counts each line asfloor(length / width)wrapped rows plus one, which is the model to follow.
Current Behavior
The count assumes every line fits on one row. The seed prompt ("Type 'recorded' once it is in the offline record and the team chat: ") is about 70 characters plus the operator's answer, so on a terminal narrower than that, or after a long wrong answer, it takes two rows. Each extra row leaves one more row of the block uncleared at the top, and the secret sits three rows from the top.
Risk: the screen promises "shown once", but on a narrow window (a split pane or a small SSH console) the secret can stay visible.
Plan
- Read the terminal width when showing the block (
tput colson the terminal, orstty size; fall back to 80 when neither works). - Count the rows written: for each line written (including each prompt plus the typed answer),
floor(length / width) + 1. - Move up by that row count and clear to the end of the screen, as now.
- Share one helper between
lab_secret_showandlab_seed_show.
Acceptance tests
- A bats test of the row count: a line exactly the width, one longer than the width, and a long wrong answer, at widths 80 and 25.
-
lab_secret_showandlab_seed_showmove up by the counted rows (the test double for the terminal records the escape sequence). - Existing secret and seed tests still pass.
Done when
- The fix is merged with CI green.
Out of scope
- Clearing the terminal's own scrollback history.
- The Windows version (#140, done).
- Lenguaje dominante
- PowerShell
- Estrellas
- 0
- Forks
- 0
- Merge medio
- 2 h 7 min
- PR fusionados (30 d)
- 53
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.