Skip to content

fix: subscription entries not appearing after 3 additions in History tab#208

Merged
vakovalskii merged 1 commit intomainfrom
fix/subscription-history-limit
May 6, 2026
Merged

fix: subscription entries not appearing after 3 additions in History tab#208
vakovalskii merged 1 commit intomainfrom
fix/subscription-history-limit

Conversation

@NovakPAai
Copy link
Copy Markdown
Collaborator

Root cause

addSubEntry() and removeSubEntry() called render()renderAnalytics(), which has an HTML cache (_analyticsHtmlCache). The cache was never invalidated on subscription mutations — it was only cleared by loadSessions() (triggered by auto-refresh while cursor sessions were loading, roughly 2–3 times on startup). New entries were saved to localStorage correctly but the old cached HTML was shown instead. This gave the impression of a hard limit of ~3 entries (however many were added during the initial auto-refresh window).

Changes

Bug fix

  • Clear _analyticsHtmlCache / _analyticsCacheUrl in addSubEntry and removeSubEntry before calling render()

UX: any service, any plan

  • Replace <select> dropdowns (constrained to 5 predefined services) with <input> + <datalist> — users can type any service name (GitHub Copilot, Windsurf, JetBrains AI, etc.)
  • Auto-fill price on known service+plan combo via oninput with case-insensitive match
  • Reset price field when service changes (prevents stale price from prior selection)

Security

  • Fix stored XSS: e.from was interpolated into innerHTML without escHtml() — all other fields were escaped, this one was missed

UI polish

  • Add color-scheme: dark to :root so native datalist popup and date picker match the dark theme
  • Widen service input from 140px → 180px to fit longer names ("GitHub Copilot", "Amazon CodeWhisperer")
  • Add aria-label to all form inputs
  • Include service name in breakdown label (e.g. "Claude Pro $20" instead of just "Pro $20") for clarity with multiple subscriptions

Test plan

  • Add 5+ subscription entries — all appear immediately without page refresh
  • Remove an entry — list updates immediately
  • Type "Claude" in Service, "Pro" in Plan — price auto-fills to 20
  • Type "cursor" (lowercase) in Service, "ultra" in Plan — price auto-fills to 200
  • Change service after auto-fill — price field resets
  • Type a custom service name ("Windsurf") and plan ("Pro") with manual price — entry saves and displays correctly
  • Open browser DevTools, manually set localStorage['codedash-subscription'] with a crafted from field containing <img src=x onerror=alert(1)> — verify it renders as escaped text, not executed
  • Check datalist popup renders dark (not white) in Chrome/Edge/Firefox

- Clear _analyticsHtmlCache in addSubEntry/removeSubEntry so render()
  always rebuilds the HTML from current localStorage, not the stale cache
- Replace service/plan <select> dropdowns with <input>+<datalist> to
  allow adding any custom service (GitHub Copilot, Windsurf, etc.)
- Auto-fill price on known service+plan combo via oninput with
  case-insensitive match; reset price when service changes
- Fix stored XSS: e.from was rendered into innerHTML without escaping
- Add color-scheme: dark to :root so datalist popup matches dark theme
- Widen service input to 180px to fit longer service names
- Add aria-label to all form inputs
- Include service name in breakdown label for multi-subscription clarity
@NovakPAai NovakPAai self-assigned this May 5, 2026
@NovakPAai NovakPAai requested a review from vakovalskii May 5, 2026 19:16
Copy link
Copy Markdown
Owner

@vakovalskii vakovalskii left a comment

Choose a reason for hiding this comment

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

LGTM — clean fix with good explanation of root cause. CI green across Ubuntu/macOS × Node 18/20/22. Includes a nice XSS hardening as a bonus.

@vakovalskii vakovalskii merged commit 258d41f into main May 6, 2026
6 checks passed
@vakovalskii vakovalskii deleted the fix/subscription-history-limit branch May 6, 2026 07:26
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