Count wrapped rows when clearing a shown password or seed on Linux

Abierto
#151 0 comentarios 0 reacciones 1 asignado Ver en GitHub

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

area: core platform: linux type: bug

Read first

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, then lab_tty_write $'\r\033['"$lines"$'A\033[J'.
  • core/seed/seed.sh, lab_seed_show: the same pattern.
  • The Windows version (Get-LabTerminalRowCount and Get-LabClearRow in core/secret/Secret.ps1, from PR #143) counts each line as floor(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

  1. Read the terminal width when showing the block (tput cols on the terminal, or stty size; fall back to 80 when neither works).
  2. Count the rows written: for each line written (including each prompt plus the typed answer), floor(length / width) + 1.
  3. Move up by that row count and clear to the end of the screen, as now.
  4. Share one helper between lab_secret_show and lab_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_show and lab_seed_show move 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.