autodetect label #12

Closed
opened 2026-05-17 07:58:24 +02:00 by heiko · 1 comment
Owner

If there as a label (--label) or label:, match it with existing ones. If
we find a non-ambigous match, autocorrect it. Otherwise fail with an
explanative message and list the possible values, emphasize (color) the
best matches.

Same for milestones.

If there as a label (--label) or label:, match it with existing ones. If we find a non-ambigous match, autocorrect it. Otherwise fail with an explanative message and list the possible values, emphasize (color) the best matches. Same for milestones.
Author
Owner

Plan

Matching strategy — unified matchCandidates(input, choices) helper, scoring:

  1. exact case-insensitive (silent use)
  2. case-insensitive prefix
  3. case-insensitive substring
  4. Levenshtein distance ≤ 2

Highest-scoring tier wins. Within a tier, ties = ambiguous.

Behaviour

  • unique match (any tier) → use it. If tier > exact, print a stderr note: label: using "Bug" for "bg".
  • ambiguous (multiple at the best tier) → error, list the candidates, color the best ones (ANSI bold).
  • no match → error, list all available, no emphasis.

Applies to:

  • resolveLabels in internal/cli/editor.go (replaces current closestLabel which silently picks the first substring hit even when ambiguous).
  • resolveMilestone in internal/cli/editor.go (currently has no fuzzy path at all).

Color — gated on useColor(). Use bold (\x1b[1m…\x1b[0m); label hex colors are unrelated and only used elsewhere for rendering label chips.

Tests — extend editor_test.go with: unique prefix autocorrect, unique substring autocorrect, ambiguous error, milestone fuzzy autocorrect, milestone ambiguous error.

Branch: issue-12-autodetect-label.


ius:ai:claude-opus-4-7

## Plan **Matching strategy** — unified `matchCandidates(input, choices)` helper, scoring: 1. exact case-insensitive (silent use) 2. case-insensitive prefix 3. case-insensitive substring 4. Levenshtein distance ≤ 2 Highest-scoring tier wins. Within a tier, ties = ambiguous. **Behaviour** - *unique match (any tier)* → use it. If tier > exact, print a stderr note: `label: using "Bug" for "bg"`. - *ambiguous* (multiple at the best tier) → error, list the candidates, color the best ones (ANSI bold). - *no match* → error, list all available, no emphasis. Applies to: - `resolveLabels` in `internal/cli/editor.go` (replaces current `closestLabel` which silently picks the first substring hit even when ambiguous). - `resolveMilestone` in `internal/cli/editor.go` (currently has no fuzzy path at all). **Color** — gated on `useColor()`. Use bold (`\x1b[1m…\x1b[0m`); label hex colors are unrelated and only used elsewhere for rendering label chips. **Tests** — extend `editor_test.go` with: unique prefix autocorrect, unique substring autocorrect, ambiguous error, milestone fuzzy autocorrect, milestone ambiguous error. Branch: `issue-12-autodetect-label`. --- ius:ai:claude-opus-4-7
heiko closed this issue 2026-05-17 08:21:15 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
heiko/fj#12
No description provided.