refactor(saas): remove the legacy credits engine (FE + Java)#6687
Open
ConnorYoh wants to merge 3 commits into
Open
refactor(saas): remove the legacy credits engine (FE + Java)#6687ConnorYoh wants to merge 3 commits into
ConnorYoh wants to merge 3 commits into
Conversation
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.
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).
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theTeamCreditpool + its monthly reset.Frontend (saas)
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. KeptisPro/refreshProStatusand the Supabase auth subscription listener.services/apiClient.ts: removed the deadx-credits-remaininghandler + low-credit plumbing (token-refresh / PAYG / 401 logic untouched).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 theX-Credits-Remaining/X-Credit-Sourceresponse header (its only consumer, the desktop credit system, was already removed).SaasTeamService: dropped UserCredit/TeamCredit init on team-create + seat-update.SupabaseAuthenticationFilter/SupabaseSecurityConfig: droppedgetOrCreateUserCreditson signup + the credit field/CORS header.UserRoleService: droppedresetCycleAllocationForRoleChange;ROLE_PRO_USERgrant/revoke preserved.UserRepository: droppedfindUsersWithApiKeyButNoCredits().Kept / scope
isPro/is_proRPC /ROLE_PRO_USER(that's the separate Group-4 / EE effort) and all PAYG are untouched.user_credits/team_creditsstay until a later gated migration — which this PR unblocks (the JPA entities that pinned them are gone).Verify
:saas:compileJava+:saas:compileTestJavapass; FEtsc --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.