Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(create): allow paid credit packs to unlock character training

purple985694c09c17
diff --git a/src/components/create/experimental/CreditsMeter.tsx b/src/components/create/experimental/CreditsMeter.tsx
index 8a6551a6..e16366cf 100644
--- a/src/components/create/experimental/CreditsMeter.tsx
+++ b/src/components/create/experimental/CreditsMeter.tsx
@@ -89,7 +89,7 @@ export function CreditsMeter() {
'credits',
)
}
- if (state.kind === 'no-trainings') return upsell('No trainings left this month, upgrade')
+ if (state.kind === 'no-trainings') return upsell('No included trainings left, top up', 'credits')
if (state.kind === 'no-video-budget') return upsell('Video budget used up, top up', 'credits')
const noun = op === 'lora-train' ? 'training' : kind === 'video' ? 'clip' : kind === 'audio' ? 'track' : 'image'
@@ -100,7 +100,7 @@ export function CreditsMeter() {
: ''
const trainingTail =
op === 'lora-train' && quota.trainings
- ? ` (${quota.trainings.remaining} of ${quota.trainings.limit} trainings left)`
+ ? ` (${quota.trainings.remaining} of ${quota.trainings.limit} included trainings left)`
: ''
return (
diff --git a/src/lib/render/__tests__/credits-meter.test.ts b/src/lib/render/__tests__/credits-meter.test.ts
index 5ad76f5c..d783db48 100644
--- a/src/lib/render/__tests__/credits-meter.test.ts
+++ b/src/lib/render/__tests__/credits-meter.test.ts
@@ -97,7 +97,25 @@ describe('the top-up wallet is exempt from the video sub-budget', () => {
})
})
-describe('character trainings are a count, not a budget', () => {
+describe('character trainings use included runs or paid credits', () => {
+ it('lets a credit-only buyer train without any included runs', () => {
+ const q = hosted({
+ remaining: { credits: 450_000 },
+ topup: { credits: 450_000 },
+ trainings: { limit: 0, used: 0, remaining: 0 },
+ })
+ expect(meterState(q, 100_000, 'image', 'lora-train')).toMatchObject({ kind: 'ok', runsLeft: 4 })
+ })
+
+ it('requires enough paid credits for the complete selected trainer', () => {
+ const q = hosted({
+ topup: { credits: 100_000 },
+ trainings: { limit: 2, used: 2, remaining: 0 },
+ })
+ expect(meterState(q, 100_000, 'image', 'lora-train')).toMatchObject({ kind: 'ok' })
+ expect(meterState(q, 125_000, 'image', 'lora-train')).toEqual({ kind: 'no-trainings' })
+ })
+
it('refuses the training when the monthly count is spent', () => {
const q = hosted({ trainings: { limit: 2, used: 2, remaining: 0 } })
expect(meterState(q, 100_000, 'image', 'lora-train')).toEqual({ kind: 'no-trainings' })
diff --git a/src/lib/render/credits-meter.ts b/src/lib/render/credits-meter.ts
index 64d5bf69..12acb33e 100644
--- a/src/lib/render/credits-meter.ts
+++ b/src/lib/render/credits-meter.ts
@@ -52,19 +52,20 @@ export function meterState(
// Absent fields mean a pre-0029 server: uncapped, never gate on data we do
// not have. Video's monthly room is extended by the wallet because top-up
- // credits are exempt from the sub-budget; the training count is a hard count
- // the wallet cannot buy past.
+ // credits are exempt from the sub-budget. Beyond included trainings, the
+ // paid wallet must cover the complete selected run (server migration 0047).
const videoRoom = quota.video ? quota.video.remaining + topup : Infinity
const trainingsLeft = quota.trainings ? quota.trainings.remaining : Infinity
+ const trainingPackRun = isTraining && cost > 0 && topup >= cost
if (remaining < cost) return { kind: 'insufficient', remaining, cost }
- if (isTraining && trainingsLeft <= 0) return { kind: 'no-trainings' }
+ if (isTraining && trainingsLeft <= 0 && !trainingPackRun) return { kind: 'no-trainings' }
if (isVideoBudget && videoRoom < cost) return { kind: 'no-video-budget' }
const runsPool = isVideoBudget ? Math.min(remaining, videoRoom) : remaining
const byCredits = cost > 0 ? Math.floor(runsPool / cost) : null
const runsLeft =
- byCredits === null ? null : isTraining ? Math.min(trainingsLeft, byCredits) : byCredits
+ byCredits === null ? null : isTraining && !trainingPackRun ? Math.min(trainingsLeft, byCredits) : byCredits
// No tier caps video below its pool since 2026-08-05, so on a plain plan
// videoRoom always covers `remaining` and this stays false. It turns itself