Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Organizations with custom billing plans were showing as "Free" (or generic "Custom") because tierToPlan() defaulted to tierFree for any tier ID not in the static enum.

Changes

  • tierToPlan() function - Changed default return value from tierFree to tierCustom for unknown tier IDs
  • Account organizations page - Added getPlanName() async function that fetches actual custom plan names via billing.getPlan() API
  • Plan name display - Updated badges to use async plan name fetching for custom plans
// Before: always returned tierFree for unknown tiers
export function tierToPlan(tier: Tier) {
    switch (tier) {
        // ... static cases
        default:
            return tierFree;  // Custom plans fell through here
    }
}

// After: returns tierCustom for unknown tiers
export function tierToPlan(tier: Tier) {
    switch (tier) {
        // ... static cases
        default:
            return tierCustom;  // Now returns Custom instead of Free
    }
}

For displaying actual custom plan names, the account organizations page now:

  1. Calls tierToPlan() to check if it's a known plan type
  2. If the plan is custom, fetches the real plan name using billing.getPlan() API
  3. Uses Svelte's {#await} to handle async plan name loading

This approach ensures custom plans show their actual names (e.g., "Enterprise Custom") instead of the generic "Custom" or incorrect "Free" label.

Testing

  • ✅ TypeScript compilation passes
  • ✅ Linting passes
  • ✅ All tests pass (227 tests)
  • ✅ Build completes successfully
Original prompt

The account organizations page (src/routes/(console)/account/organizations/+page.svelte) shows orgs on a custom plan as Free because the custom plan does not exist in the tierToPlan map. Instead of defauting to Free, we should lookup the plan info and use the correct name.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@appwrite
Copy link

appwrite bot commented Nov 3, 2025

Console

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Cursor pagination performs better than offset pagination when loading further pages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Note

Free review on us!

CodeRabbit is offering free reviews until Thu Nov 06 2025 to showcase some of the refinements we've made.

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

Copilot AI and others added 2 commits November 3, 2025 22:42
Modified tierToPlan function to lookup custom plans from plansInfo map instead of defaulting to Free. Updated account organizations page to pass plansInfo to tierToPlan calls.

Co-authored-by: stnguyen90 <[email protected]>
Removed redundant conditional and simplified the default case to use a single variable for the map lookup.

Co-authored-by: stnguyen90 <[email protected]>
Copilot AI changed the title [WIP] Fix display of custom plan names on organizations page Fix custom plan names displaying as "Free" on account organizations page Nov 3, 2025
Copilot AI requested a review from stnguyen90 November 3, 2025 22:55
Copilot finished work on behalf of stnguyen90 November 3, 2025 22:55
…s from API

- Changed default return value from tierFree to tierCustom for unknown tiers
- Removed optional plansMap parameter and lookup logic from tierToPlan
- Added getPlanName function to fetch custom plan names via billing.getPlan() API
- Updated account organizations page to use async plan name fetching for custom plans

Co-authored-by: stnguyen90 <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 5, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • o1.ingest.sentry.io
    • Triggering command: node (vitest) (dns block)
    • Triggering command: node build.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Fix custom plan names displaying as "Free" on account organizations page Fix custom plan names displaying as "Custom" on account organizations page Nov 5, 2025
Copilot AI requested a review from stnguyen90 November 5, 2025 22:55
Copilot finished work on behalf of stnguyen90 November 5, 2025 22:55
Comment on lines +160 to +166
{#await getPlanName(payingOrg.billingPlan) then name}
<Badge
size="xs"
type="success"
variant="secondary"
content={name} />
{/await}
Copy link
Contributor

Choose a reason for hiding this comment

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

@ItzNotABug do we want some sort of skeleton loader here?

Copy link
Member

Choose a reason for hiding this comment

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

yeah as I mentioned above for shifts, we could use a skeleton. Please run by design once 👍

@stnguyen90 stnguyen90 requested a review from ItzNotABug November 5, 2025 23:36
@stnguyen90 stnguyen90 marked this pull request as ready for review November 5, 2025 23:37
// For custom plans, fetch from API
try {
const plan = await sdk.forConsole.billing.getPlan(billingPlan);
Copy link
Member

Choose a reason for hiding this comment

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

we can do a quick cached data lookup first to avoid a network call, there should be a plansInfo available.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ItzNotABug tierToPlan essentially has the same data as plansInfo, right?

</span>
</Tooltip>
{#if planName}
{#await planName then name}
Copy link
Member

Choose a reason for hiding this comment

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

won't there be a slight content/layout shift until this loads and if the api call was made?

Comment on lines +160 to +166
{#await getPlanName(payingOrg.billingPlan) then name}
<Badge
size="xs"
type="success"
variant="secondary"
content={name} />
{/await}
Copy link
Member

Choose a reason for hiding this comment

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

yeah as I mentioned above for shifts, we could use a skeleton. Please run by design once 👍

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