Skip to content

Admin UI is inconsistent about which slug represents 'the link' #6

@DennisAlund

Description

@DennisAlund

Found while addressing Copilot's QR slug-pick feedback in PR #3 (which fixed the same bug in src/api/qr.ts and src/mcp/server.ts).

The admin UI (src/client.ts) uses two different patterns to answer "which slug represents this link":

  • src/client.ts:1508link.slugs.find(s => s.is_primary) || link.slugs[0] ✓ (matches the canonical-redirect-target intent)
  • src/client.ts:153, 250, 1130, 1166link.slugs.find(s => !s.is_custom) (picks the auto-generated slug specifically, ignoring is_primary)

After SlugRepository.setPrimary flips primary to a custom slug, or after a primary custom slug is disabled/removed (which auto-promotes the auto-slug back to primary), the two patterns return different rows. The four !s.is_custom call sites were likely written when "primary" and "auto-generated" were synonymous; they no longer are.

Question for the fix: should the four !s.is_custom sites switch to s.is_primary, or do those specific UI paths genuinely need "the original system slug" regardless of primary? The intent is unclear from the surrounding code — pinning down which is which needs a UX-level decision before the code change.

No regression in PR #3 — those four sites only affect admin UI rendering, not the QR API or redirect path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions