Skip to content

Fix note detail showing "/ 0 (-N remaining)" for unlimited views#65

Open
Osamaali313 wants to merge 1 commit into
Skyfay:mainfrom
Osamaali313:fix/tui-unlimited-views-display
Open

Fix note detail showing "/ 0 (-N remaining)" for unlimited views#65
Osamaali313 wants to merge 1 commit into
Skyfay:mainfrom
Osamaali313:fix/tui-unlimited-views-display

Conversation

@Osamaali313

Copy link
Copy Markdown

Problem

In the MyUploads TUI note-detail panel (apps/client/src/tui/views/MyUploads.tsx), the view counter renders unconditionally:

{liveNote.viewCount} / {liveNote.maxViews}
<Text dimColor> ({liveNote.maxViews - liveNote.viewCount} remaining)</Text>

But maxViews === 0 means unlimited, and it's the default (NOTE_DEFAULT_VIEWS = "0" in the server config; the server treats 0 as unlimited throughout). So a default note that's been viewed 3 times renders:

Views:     3 / 0 (-3 remaining)

— a nonsensical / 0 and a negative "remaining", implying the link is exhausted when it isn't.

Evidence (siblings prove intent)

Every other place that renders view counts special-cases 0:

  • CLI list: n.maxViews === 0 ? \${n.viewCount} / ∞` : …`
  • web NoteCard: info.maxViews === 0 ? …
  • client note command: Views: ${maxViews === 0 ? "unlimited" : maxViews}

Only this TUI panel doesn't. (The adjacent uploads panel uses the same max - count pattern correctly, because maxDownloads is schema-validated positive and can never be 0.)

Fix

Mirror the siblings — show for unlimited and only show the "remaining" hint for a finite limit:

{liveNote.viewCount} / {liveNote.maxViews === 0 ? "" : liveNote.maxViews}
{liveNote.maxViews > 0 && (
  <Text dimColor> ({liveNote.maxViews - liveNote.viewCount} remaining)</Text>
)}

Reproduction

Default (unlimited) note viewed 3×:

rendered
before Views: 3 / 0 (-3 remaining)
after Views: 3 / ∞

In the MyUploads TUI note-detail panel, the view counter renders:

    {liveNote.viewCount} / {liveNote.maxViews}
    <Text dimColor> ({liveNote.maxViews - liveNote.viewCount} remaining)</Text>

`maxViews === 0` means "unlimited" and is the default (server config
NOTE_DEFAULT_VIEWS = "0", and the server treats 0 as unlimited). So a
default note viewed 3 times shows `Views: 3 / 0 (-3 remaining)` — a
nonsensical `/ 0` and a negative "remaining", implying the link is
exhausted when it is not.

Every other place that renders view counts special-cases 0: the CLI
`list` (`maxViews === 0 ? \`${viewCount} / ∞\``), the web `NoteCard`, and
the client `note` command (`maxViews === 0 ? "unlimited"`). Mirror them:
show ∞ for unlimited and only show the "remaining" hint when there is a
finite limit. (The adjacent uploads panel uses the same `max - count`
pattern correctly because `maxDownloads` is schema-validated positive and
can never be 0.)
Copilot AI review requested due to automatic review settings July 19, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Skyfay

Skyfay commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Hey @Osamaali313

Thanks for your contribution.
I'll include that fix in the next version.

Thanks :)

@Osamaali313

Copy link
Copy Markdown
Author

Thanks @Skyfay, glad it helps — happy to adjust anything if needed when you pull it into the next release. Appreciate the quick response!

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.

3 participants