Skip to content

fix: restore plan usage and isolate self-hosted billing - #609

Merged
appflowy merged 3 commits into
mainfrom
codex/fix-hosted-plan-self-hosted-isolation
Oct 7, 2026
Merged

appflowy merged 3 commits into
mainfrom
codex/fix-hosted-plan-self-hosted-isolation

Conversation

@appflowy

@appflowy appflowy commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

When Vite starts before the local gateway, workspace usage can be routed to Cloud, which does not implement that endpoint. Keep local usage-and-limit requests on the gateway so Plan usage and both Pro upgrade toggles render correctly. Match the usage-track colors to desktop.

Require confirmed cloud hosting before any billing HTTP request. Pricing and workspace billing hooks, settings panels, and upgrade dialogs remain disabled for self-hosted or unresolved servers, including retries and direct deep links. Self-hosted access to Pro features is preserved.

Vault Workspace is no longer supported. Remove obsolete Vault pricing metadata, labels, and Storybook fixtures. The Web client has no Vault add-on UI or personal-subscription status/checkout APIs; generic tests still verify that unsupported account add-ons are excluded from workspace plans and checkout.

The proxy change applies only to local development. Hosting guards and UI changes apply to production builds when released.

Use a normal Playwright click for BDD slash-menu selection and wait for the menu to close. This prevents the click from racing the popover animation, which also caused flaky simple-table setup on main.

Validation

  • All eight simple-table header BDD scenarios passed locally without retries after fixing slash-menu selection.
  • 131 tests passed across 12 focused suites covering billing APIs, pricing, Plan/Billing settings, workspace billing, upgrade dialogs, hosting policy, and proxy routing.
  • pnpm type-check, ESLint on changed application/configuration files, and git diff --check passed.
  • Local Chrome cloud mode: pricing, workspace status, and usage returned HTTP 200. Both Pro toggles and the current-plan card are visible; no Vault UI or personal-subscription requests remain.
  • Local Chrome self-hosted simulation: the Plan/upgrade deep link falls back to Account & App, Plan/Billing are hidden, and the network log contains zero billing or plan-usage requests.
  • No console warnings or errors in either browser check. Checkout behavior is covered with mocks.

Checklist

General

  • I've included relevant documentation or comments for the changes introduced.
  • I've tested the changes in multiple browsers or operating systems. Browser validation used Chrome on macOS; self-hosting was simulated and server-info states were covered in tests.

Testing

  • I've added or updated tests to validate the changes introduced for AppFlowy Web.

Feature-Specific

  • I've attached a visual preview. These changes fix existing billing behavior and remove unsupported Vault references; no new feature is introduced.
  • I've verified integration with existing hosted billing and self-hosted feature access locally.

Summary by Sourcery

Restore workspace plan usage in local development and isolate hosted billing from self-hosted or unconfirmed servers while removing unsupported Vault Workspace support.

Bug Fixes:

  • Restore local workspace usage routing so Plan usage and Pro upgrade controls work reliably during development.
  • Prevent billing, pricing, usage, subscription, and checkout requests until official cloud hosting is confirmed, including self-hosted and unresolved server states.
  • Preserve self-hosted Pro access while hiding hosted-only Plan, Billing, and upgrade interfaces.

Enhancements:

  • Align Plan usage indicators with desktop colors and remove obsolete Vault Workspace pricing metadata, labels, fixtures, and add-on assumptions.

Build:

  • Limit the workspace usage proxy override to local development and keep production builds free of local proxy routes.

Tests:

  • Add coverage for billing API hosting isolation, pricing and workspace billing state transitions, self-hosted deep links, upgrade dialogs, unsupported add-ons, and local proxy routing.
  • Stabilize slash-command browser interaction tests.

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR restores local workspace usage routing and Plan rendering, removes unsupported Vault pricing artifacts, and establishes a defense-in-depth hosting policy that prevents all billing HTTP traffic and UI access until official cloud hosting is confirmed, while leaving self-hosted Pro features available.

Sequence diagram for hosting-guarded billing requests

sequenceDiagram
    participant UI as Web client
    participant Policy as getWorkspacePlanPolicy
    participant Billing as Billing API
    participant Server as Hosted billing server

    UI->>Billing: getPricingCatalog()
    Billing->>Policy: getWorkspacePlanPolicy()
    alt Official cloud hosting
        Policy-->>Billing: usesHostedBilling = true
        Billing->>Server: GET /billing/api/v1/pricing
        Server-->>UI: PricingCatalog
    else Self-hosted or unresolved server
        Policy-->>Billing: usesHostedBilling = false
        Billing-->>UI: Error: Hosted billing is not available
    end
Loading

Flow diagram for hosted-only Plan and Billing UI

flowchart TD
    Start[Load Plan, Billing, or upgrade UI] --> Hosted{"useIsOfficialHosted()"}
    Hosted -->|Yes| Load[Load pricing, subscription, and usage data]
    Load --> Render[Render Plan/Billing UI and upgrade actions]
    Hosted -->|No| Hide[Hide billing UI and skip requests]
    Hide --> Pro[Self-hosted Pro features remain available]
    DeepLink[Direct upgrade or Plan deep link] --> Hosted
Loading

Flow diagram for local workspace usage proxy routing

flowchart TD
    Request["/api/workspace/{workspaceId}/usage-and-limit"] --> Mode{Vite command}
    Mode -->|serve| Target{Explicit API target?}
    Target -->|Yes| Explicit[Configured API target]
    Target -->|No| Gateway[Local gateway: http://localhost:8100]
    Mode -->|build| None[No local development proxy]
    Explicit --> Usage[Workspace usage response]
    Gateway --> Usage
Loading

File-Level Changes

Change Details Files
Routes workspace usage to the local gateway during development while preserving configurable API routing and excluding proxy rules from production builds.
  • Adds a higher-priority usage-and-limit proxy route targeting the gateway, including when Vite starts before the gateway.
  • Preserves explicit API target overrides for usage and general API traffic.
  • Adds tests for route precedence, query strings, overrides, and production behavior.
vite.config.ts
src/config/vite-local-proxy.test.ts
Centralizes billing request protection behind confirmed official cloud hosting.
  • Guards all billing, subscription, pricing, portal, and workspace usage HTTP calls before creating requests.
  • Blocks requests for self-hosted, loading, unavailable, and unsupported server states.
  • Adds coverage for every endpoint and prevents billing traffic during unresolved hosting states.
src/application/services/js-services/http/billing-api.ts
src/application/services/js-services/http/__tests__/billing-api.test.ts
Disables billing-related data loading and UI when hosting is self-hosted or unresolved while preserving self-hosted Pro access.
  • Prevents pricing fetches, retries, cached catalog display, workspace billing loads, mutations, checkout, and portal actions until cloud hosting is confirmed.
  • Hides Plan, Billing, and upgrade dialog surfaces and rejects billing deep links without network requests.
  • Invalidates pending billing responses when switching from cloud to self-hosted.
  • Adds hosting-mode tests for hooks, settings, dialogs, retries, and direct links.
src/components/app/hooks/usePricingCatalog.ts
src/components/app/hooks/__tests__/usePricingCatalog.test.tsx
src/components/app/settings/PlanPanel.tsx
src/components/app/settings/BillingPanel.tsx
src/components/app/settings/billing/useWorkspaceBilling.ts
src/components/app/settings/__tests__/useWorkspaceBilling.hosting.test.tsx
src/components/app/settings/__tests__/BillingPanel.test.tsx
src/components/app/settings/__tests__/ChangePeriodDialog.test.tsx
src/components/app/settings/__tests__/Settings.billing.test.tsx
src/components/app/settings/__tests__/billing-test-utils.tsx
src/components/billing/UpgradePlan.tsx
src/components/billing/__tests__/UpgradePlan.test.tsx
src/components/billing/UpgradePlan.stories.tsx
Removes unsupported Vault Workspace pricing and client metadata while retaining generic filtering of unsupported account add-ons.
  • Removes Vault from Storybook pricing fixtures, pricing-plan identifiers, and translated labels.
  • Updates pricing utility tests to verify unknown account add-ons are excluded from checkout mapping.
.storybook/mocks.ts
src/@types/translations/en.json
src/application/types.ts
src/utils/__tests__/pricing.test.ts
Aligns the Plan usage progress track styling with the desktop appearance.
  • Updates light and dark mode track colors.
src/components/app/settings/PlanPanel.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@appflowy appflowy changed the title fix: align hosted plan settings and isolate self-hosted billing fix: restore plan usage and isolate self-hosted billing Oct 7, 2026
@appflowy
appflowy marked this pull request as ready for review October 7, 2026 03:31

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@appflowy
appflowy merged commit f18b1fb into main Oct 7, 2026
21 checks passed
@appflowy
appflowy deleted the codex/fix-hosted-plan-self-hosted-isolation branch October 7, 2026 06:55
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.

1 participant