Skip to content

ux(recommendations): persist column filters across page reload (closes #163) - #819

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/163-wave7
Jun 3, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/163-wave7

Conversation

@cristim

@cristim cristim commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds loadColumnFilters / saveColumnFilters helpers to recommendations.ts following the same pattern as the existing loadColumnVisibility / saveColumnVisibility functions (issue feat(frontend/recs): per-column show/hide for the recommendations table #318).
  • localStorage key: cudly.recs.columnFilters.v1 (schema-versioned JSON blob).
  • Column filters are persisted to localStorage on every mutation (categorical commit, numeric commit, per-column clear, and the "Clear filters (N)" badge), and restored on the first render of renderRecommendationsList via a columnFiltersSeeded flag.

Validation strategy

  • Schema version field (schemaVersion: 1) enables forward-incompatible migrations to skip stale blobs cleanly.
  • On load, each key is checked against the closed VALID_COLUMN_IDS set; unknown column ids (e.g. from a stale session after a column rename) are silently dropped.
  • Filter values are structurally validated: kind:'set' requires a string array, kind:'expr' requires a non-empty string. Anything else is dropped without an error toast.
  • JSON parse errors or localStorage unavailability (private browsing, quota-exceeded) fall back to empty filters silently.

Test plan

  • loadColumnFilters returns {} when key is absent
  • loadColumnFilters returns {} on JSON parse error
  • loadColumnFilters returns {} when schemaVersion is wrong
  • loadColumnFilters returns {} when filters is not an object
  • Restores categorical (kind:'set') filter correctly
  • Restores numeric (kind:'expr') filter correctly
  • Silently drops unknown column keys (stale after deletion/rename)
  • Silently drops filters with malformed shape
  • Silently drops expr filter with empty-string expr
  • saveColumnFilters writes correct schemaVersion:1 JSON shape
  • saveColumnFilters writes empty filters:{} when no filters active
  • Round-trips numeric expr filter through save + load
  • Save then load restores full filter state
  • Stored key with unknown column is silently dropped, no error thrown
  • Corrupted JSON falls back to {}, no error thrown

334 tests passing, TypeScript clean.

Closes #163

🤖 Generated with claude-flow

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/many Affects most users effort/xs Trivial / one-liner type/feat New capability labels May 28, 2026
@cristim

cristim commented May 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 44 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3ff153b-4a20-473a-b577-155e3d3a4708

📥 Commits

Reviewing files that changed from the base of the PR and between eb85a50 and a76035a.

📒 Files selected for processing (2)
  • frontend/src/__tests__/recommendations.test.ts
  • frontend/src/recommendations.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/163-wave7

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

…163)

Add loadColumnFilters / saveColumnFilters to recommendations.ts following
the same schema-versioned pattern as loadColumnVisibility. Key:
cudly.recs.columnFilters.v1. Save on every mutation (categorical commit,
numeric commit, per-column Clear, Clear-filters badge). Restore on first
render via columnFiltersSeeded flag. Unknown column ids and malformed
filter shapes are silently dropped on load; JSON errors fall back to empty.
15 new tests added; 334 total pass.
@cristim

cristim commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

Rebased on feat/multicloud-web-frontend. Resolved additive conflicts in frontend/src/__tests__/recommendations.test.ts (kept both the base's renderUsageSparkline (#239) describe block and this PR's Column filters localStorage persistence (#163) describe block; merged the import line to keep both renderUsageSparkline and the new loadColumnFilters/saveColumnFilters/resetColumnFiltersState exports). frontend/src/recommendations.ts auto-merged cleanly.

Verification post-rebase: recommendations.test.ts passes (347 tests), npm run build succeeds. Note: pre-existing failures in recommendations-lookback.test.ts (#909) reproduce against the unmodified base recommendations.ts and are unrelated to this PR.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

@cristim Noted — the rebase context is clear. I'll kick off a fresh review of the updated branch, treating the renderUsageSparkline / loadColumnFilters import merge and the additive test-block consolidation as expected. Pre-existing failures in recommendations-lookback.test.ts tracked under #909 will be excluded from the review scope.


🧠 Learnings used
Learnt from: cristim
Repo: LeanerCloud/CUDly PR: 0
File: :0-0
Timestamp: 2026-05-05T15:44:54.463Z
Learning: In the LeanerCloud/CUDly repository, when a CodeRabbit review flags something as "outside-diff" that was already implemented in an earlier commit of the same PR, it is likely a stale-snapshot artifact where the review diff was generated against a pre-fix view. The inline comment convention `(CR pass on PR #<number> Finding N)` is used by the maintainer (cristim) to mark lines that were changed in direct response to a prior CodeRabbit review pass.

Learnt from: cristim
Repo: LeanerCloud/CUDly PR: 277
File: frontend/src/__tests__/recommendations.test.ts:2472-2476
Timestamp: 2026-05-05T07:46:01.902Z
Learning: In the CUDly frontend (`frontend/src/recommendations.ts`), `effectiveSavingsPct` intentionally has NO plausibility guard (no null return or warning for reconstructed percentages above per-term ceilings). The maintainer explicitly rejected that approach in PR `#277`. The fix for inflated percentages (issue `#274`) is purely a data-path fix: plumbing the provider's canonical `on_demand_cost` through to the frontend so the denominator is not reconstructed from potentially misleading `monthly_cost + savings + amortized`. Tests that pin the reconstructed >80% behavior are intentional documentation of the pre-fix path, not bugs.
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/many Affects most users priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant