Skip to content

Conversation

@ItzNotABug
Copy link
Member

@ItzNotABug ItzNotABug commented Jan 16, 2026

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Refactor
    • Updated payment history data loading flow: invoice list now loads with consistent page sizing and offset behavior, and UI lifecycle triggers use the new loading flow for more stable pagination and invoice reloads.

✏️ Tip: You can customize this high-level summary in your review settings.

@ItzNotABug ItzNotABug self-assigned this Jan 16, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Warning

Rate limit exceeded

@ItzNotABug has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0bad3d5 and e8ff2a1.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte

Walkthrough

A single-file refactor in the payment history billing component replaces an internal request function with loadInvoices. The new function removes the optional patchQuery parameter and the conditional logic that previously adjusted limit and offset for the first page; it uses fixed limit and offset values. All invocation sites (the onMount hook, the pagination change handler, and the URL validate-invoice effect) were updated to call loadInvoices().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix: hacky pagination' directly corresponds to the main change: refactoring pagination logic by replacing a hacky request function with a cleaner loadInvoices function that uses fixed parameters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/routes/`(console)/organization-[organization]/billing/paymentHistory.svelte:
- Around line 45-51: In loadInvoices(), remove the extra "+ 1" so
Query.offset(offset) is used (the +1 causes the first invoice to be skipped and
misaligns pagination), and wrap the sdk.forConsole.billing.listInvoices(...)
call in a try/finally that sets isLoadingInvoices = false in the finally block
so isLoadingInvoices is always reset on error; update references to invoiceList
and Query.orderDesc/Query.limit as needed inside the same try block.
🧹 Nitpick comments (1)
src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte (1)

45-54: Ensure loading state clears on request failures.

If listInvoices throws, Line 53 won’t run and isLoadingInvoices stays true. Wrap the await in a try/finally to guarantee cleanup.

♻️ Proposed fix
 async function loadInvoices() {
     isLoadingInvoices = true;
-    invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
-        Query.orderDesc('$createdAt'),
-        Query.limit(limit),
-        Query.offset(offset + 1)
-    ]);
-
-    isLoadingInvoices = false;
+    try {
+        invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
+            Query.orderDesc('$createdAt'),
+            Query.limit(limit),
+            Query.offset(offset + 1)
+        ]);
+    } finally {
+        isLoadingInvoices = false;
+    }
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36f5ba4 and 884c185.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx,svelte}: Import reusable modules from the src/lib directory using the $lib alias
Use minimal comments in code; reserve comments for TODOs or complex logic explanations
Use $lib, $routes, and $themes aliases instead of relative paths for module imports

Files:

  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
src/routes/**/*.svelte

📄 CodeRabbit inference engine (AGENTS.md)

Use SvelteKit file conventions: +page.svelte for components, +page.ts for data loaders, +layout.svelte for wrappers, +error.svelte for error handling, and dynamic route params in square brackets like [param]

Files:

  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
**/*.{ts,tsx,js,jsx,svelte,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use 4 spaces for indentation, single quotes, 100 character line width, and no trailing commas per Prettier configuration

Files:

  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
**/*.svelte

📄 CodeRabbit inference engine (AGENTS.md)

Use Svelte 5 + SvelteKit 2 syntax with TypeScript for component development

Files:

  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
src/routes/**

📄 CodeRabbit inference engine (AGENTS.md)

Configure dynamic routes using SvelteKit convention with [param] syntax in route directory names

Files:

  • src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (1)
src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte (1)

43-43: Consistent wiring to loadInvoices looks clean.

Nice simplification of the load triggers across mount, URL validation, and pagination.

Also applies to: 64-65, 188-188

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte (1)

45-54: Wrap in try/finally to reset loading state on error.

If listInvoices throws, isLoadingInvoices remains true and the UI is stuck showing skeletons indefinitely.

Suggested fix
 async function loadInvoices() {
     isLoadingInvoices = true;
-    invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
-        Query.orderDesc('$createdAt'),
-        Query.limit(limit),
-        Query.offset(offset)
-    ]);
-
-    isLoadingInvoices = false;
+    try {
+        invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
+            Query.orderDesc('$createdAt'),
+            Query.limit(limit),
+            Query.offset(offset)
+        ]);
+    } finally {
+        isLoadingInvoices = false;
+    }
 }

@ItzNotABug
Copy link
Member Author

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)

src/routes/(console)/organization-[organization]/billing/paymentHistory.svelte (1)> 45-54: Wrap in try/finally to reset loading state on error.

If listInvoices throws, isLoadingInvoices remains true and the UI is stuck showing skeletons indefinitely.

Suggested fix

 async function loadInvoices() {
     isLoadingInvoices = true;
-    invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
-        Query.orderDesc('$createdAt'),
-        Query.limit(limit),
-        Query.offset(offset)
-    ]);
-
-    isLoadingInvoices = false;
+    try {
+        invoiceList = await sdk.forConsole.billing.listInvoices(page.params.organization, [
+            Query.orderDesc('$createdAt'),
+            Query.limit(limit),
+            Query.offset(offset)
+        ]);
+    } finally {
+        isLoadingInvoices = false;
+    }
 }

Addressed 👍

@ItzNotABug ItzNotABug merged commit 9c8b88e into main Jan 18, 2026
3 checks passed
@ItzNotABug ItzNotABug deleted the remove-hacky-pagination branch January 18, 2026 10:04
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