Skip to content

Fix unselectable no-prefix option in tag-prefix selector - #11

Merged
riki137 merged 1 commit into
mainfrom
fix/tag-prefix-selector
Jul 16, 2026
Merged

Fix unselectable no-prefix option in tag-prefix selector#11
riki137 merged 1 commit into
mainfrom
fix/tag-prefix-selector

Conversation

@riki137

@riki137 riki137 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

In a repo with no existing tags (or mixed prefixed/bare tags), pubv prompts for a tag prefix:

? no existing tags. tag prefix?
  ● v        v1.2.3
  ○ (empty)  1.2.3 (no prefix)
› [v]

The (empty) / no-prefix row was unselectable. askSelect was a type-the-value prompt and that option's key is the empty string — but empty input (pressing Enter) was already claimed by "use the default" (v), and no other token mapped to ''. So the no-prefix option could never be chosen.

Fix

  • Interactive (TTY): arrow-key selector — ↑/↓ (wrap-around) + Enter, Ctrl-C/ESC to abort — with a trailing "custom prefix…" row that reads a free-text prefix (whitespace rejected, matching --tag-prefix).
  • Non-TTY / piped / CI: numbered fallback (1..n, Enter = default) so pipes don't hang; this alone also makes the empty option reachable.

Tests

New tests/unit/prompt.test.ts drives the real createPrompt().select over fake streams — interactive (down+enter → empty, enter → default, up-wrap → custom) and numbered (number, empty → default, custom) — the regression coverage the old design lacked. FakePrompt.select gains the optional custom param; existing tests unchanged.

Local: lint, typecheck, build, and full suite (220 tests) all pass.

The tag-prefix picker was a type-the-value prompt whose no-prefix
option had an empty-string key. Empty input was already claimed by
"use the default" (v), so the no-prefix row was unreachable.

Replace askSelect with an arrow-key TUI (up/down + enter, wrap-around,
Ctrl-C/ESC abort) plus a "custom prefix..." row for free-text entry.
Non-TTY/piped input falls back to a numbered list so pipes and CI keep
working; that fallback also makes the empty option reachable by number.

Add tests/unit/prompt.test.ts covering the real selector over fake
streams (interactive and numbered paths, including the empty and custom
rows) — the regression coverage the old design lacked.
@riki137
riki137 merged commit 6ff6d09 into main Jul 16, 2026
2 checks passed
@riki137
riki137 deleted the fix/tag-prefix-selector branch July 16, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant