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

Aperta
#151 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dotnetdork ci sta già lavorando.

Dal 2/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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).
Lingua principale
PowerShell
Stelle
0
Fork
0
Merge medio
2h 7m
PR unite (30g)
53

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnetdork/Labyrinth

Tutte le issue di dotnetdork/Labyrinth

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.