Skip to content

refactor(saas): remove the legacy credits engine (FE + Java)#6687

Open
ConnorYoh wants to merge 3 commits into
feat/desktop-cloud-saas-reusefrom
feat/saas-credits-teardown
Open

refactor(saas): remove the legacy credits engine (FE + Java)#6687
ConnorYoh wants to merge 3 commits into
feat/desktop-cloud-saas-reusefrom
feat/saas-credits-teardown

Conversation

@ConnorYoh

@ConnorYoh ConnorYoh commented Jun 16, 2026

Copy link
Copy Markdown
Member

Complete legacy-credits teardown ("Group 3"). The per-user/per-team credit model is fully superseded by PAYG (wallet_ledger) — confirmed no PAYG code references it. Authorized to also remove the TeamCredit pool + its monthly reset.

Frontend (saas)

  • Deleted saas/hooks/useCredits.ts, apiKeys/hooks/useCredits.ts, types/credits.ts, apiKeys/UsageSection.tsx.
  • UseSession.tsx: removed credit members (creditBalance, creditSummary, hasSufficientCredits, updateCredits, refreshCredits, fetchCredits) + the credit types + global credit-update callback. Kept isPro/refreshProStatus and the Supabase auth subscription listener.
  • services/apiClient.ts: removed the dead x-credits-remaining handler + low-credit plumbing (token-refresh / PAYG / 401 logic untouched).
  • Credit refs removed from ApiKeys.tsx, AppConfigModal.tsx, auth/teamSession.ts.

Java (:saas)

Deleted (15): UserCredit(+repo), TeamCredit(+repo)+TeamCreditService, CreditService, CreditHeaderUtils, CreditResetScheduler, CreditController, CreditInterceptorConfig, UnifiedCreditInterceptor, CreditSuccessAdvice, CreditErrorAdvice, CreditConsumptionResult (+ the CreditController test).

Edited — stripped legacy credit side-effects, preserved auth/role/AI/PAYG logic:

  • AiCreate/AiProxyController: dropped the X-Credits-Remaining/X-Credit-Source response header (its only consumer, the desktop credit system, was already removed).
  • SaasTeamService: dropped UserCredit/TeamCredit init on team-create + seat-update.
  • SupabaseAuthenticationFilter / SupabaseSecurityConfig: dropped getOrCreateUserCredits on signup + the credit field/CORS header.
  • UserRoleService: dropped resetCycleAllocationForRoleChange; ROLE_PRO_USER grant/revoke preserved.
  • proprietary UserRepository: dropped findUsersWithApiKeyButNoCredits().
  • Tests updated to drop credit mocks/refs.

Kept / scope

  • isPro / is_pro RPC / ROLE_PRO_USER (that's the separate Group-4 / EE effort) and all PAYG are untouched.
  • No DB tables dropped. user_credits/team_credits stay until a later gated migration — which this PR unblocks (the JPA entities that pinned them are gone).

Verify

:saas:compileJava + :saas:compileTestJava pass; FE tsc --noEmit (saas) + eslint clean; 0 stray artifacts; no residual source refs to the deleted classes.

Follow-up (not in this PR)

ErrorTrackingService (+ UserErrorTracker/ProcessingErrorType/CreditsProperties) is now a dead island — its only callers were the deleted interceptors. Safe to delete, but it cascades beyond the credit scope, so it's a separate tidy-up.

Targets feat/desktop-cloud-saas-reuse.

The legacy per-user/per-tool credits model is dead under PAYG. Remove its
frontend surface:

- Delete saas/hooks/useCredits.ts, the apiKeys useCredits hook, types/credits.ts,
  and the apiKeys UsageSection UI.
- Strip the credit members from UseSession (creditBalance, creditSummary,
  hasSufficientCredits, updateCredits, refreshCredits, fetchCredits + the
  SubscriptionInfo/CreditSummary/CreditCheckResult types and the global
  credit-update callback). Kept isPro/refreshProStatus and the Supabase
  auth-state subscription listener.
- Remove the dead x-credits-remaining response handler + low-credit plumbing
  from saas services/apiClient.ts; the token-refresh / PAYG / 401 logic is
  untouched.
- Drop the credit refs from ApiKeys, AppConfigModal, and teamSession.

FE half of the credits teardown. The Java half (CreditService/UserCredit) is a
separate, larger change — it's entangled with the kept TeamCredit monthly reset
and live signup/role-change wiring (see PR description). Targets the cloud
refactor branch.
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines ignoring generated files. label Jun 16, 2026
The per-user/per-team credit model is fully superseded by PAYG (wallet_ledger);
no PAYG code references it. Authorized to also drop the TeamCredit pool + its
monthly reset.

Delete (15): UserCredit + UserCreditRepository, TeamCredit + TeamCreditRepository
+ TeamCreditService, CreditService, CreditHeaderUtils, CreditResetScheduler,
CreditController, CreditInterceptorConfig, UnifiedCreditInterceptor,
CreditSuccessAdvice, CreditErrorAdvice, CreditConsumptionResult (+ the
CreditController test).

Edit — strip legacy credit side-effects, keep all auth/role/AI/PAYG logic:
- AiCreate/AiProxyController: drop the X-Credits-Remaining/X-Credit-Source header
  (its only consumer, the desktop credit system, is gone).
- SaasTeamService: drop UserCredit/TeamCredit init on team create + seat update.
- SupabaseAuthenticationFilter / SupabaseSecurityConfig: drop getOrCreateUserCredits
  on signup + the credit field/CORS header.
- UserRoleService: drop resetCycleAllocationForRoleChange; ROLE_PRO_USER grant/
  revoke preserved.
- proprietary UserRepository: drop findUsersWithApiKeyButNoCredits().
- Tests updated to drop credit mocks/refs.

Kept: isPro / is_pro / ROLE_PRO_USER (Group 4), all PAYG. No DB tables dropped —
user_credits/team_credits drop is a later gated migration this unblocks.

Follow-up: ErrorTrackingService (+ UserErrorTracker/ProcessingErrorType/
CreditsProperties) is now a dead island (only the deleted interceptors used it).
@ConnorYoh ConnorYoh requested a review from Ludy87 as a code owner June 16, 2026 12:44
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines ignoring generated files. and removed size:XL This PR changes 500-999 lines ignoring generated files. labels Jun 16, 2026
@ConnorYoh ConnorYoh changed the title refactor(fe): remove the legacy credits surface from the saas app refactor(saas): remove the legacy credits engine (FE + Java) Jun 16, 2026
@stirlingbot

stirlingbot Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🚀 V2 Auto-Deployment Complete!

Your V2 PR with embedded architecture has been deployed!

🔗 Direct Test URL (non-SSL) http://54.175.155.236:6687

🔐 Secure HTTPS URL: https://6687.ssl.stirlingpdf.cloud

This deployment will be automatically cleaned up when the PR is closed.

🔄 Auto-deployed for approved V2 contributors.

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

Labels

size:XXL This PR changes 1000+ lines ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant