From 4120e1286144dbe1e8ec898082720239c7bdfa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Wed, 1 Jul 2026 09:47:55 +0200 Subject: [PATCH] refactor(ai): remove AiConsentSettings feature flag (#619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What Removes the `AiConsentSettings` Laravel Pennant feature flag. The AI consent management UI — the toggle in **Billing settings** and the banner in **Transactions** — is now available to all users automatically, no longer gated behind the flag. The underlying AI consent functionality (model, controller, routes, `User` consent methods) is unchanged; only the gate that hid its UI was removed. ## Changes - Delete `app/Features/AiConsentSettings.php`. - `HandleInertiaRequests`: drop the `aiConsentSettings` shared prop and its resolution. - Frontend: render `AiConsentSection` and the transactions consent banner unconditionally; drop the now-unused `aiConsentSettings` type and `features` destructuring. - Tests: remove the two flag-specific assertions in `AiConsentSettingsTest` (consent-state coverage kept), update `InertiaSharedDataTest`, and switch `FeatureEnableCommandTest` to `CalculateBalancesOnImport` as its example feature. ## Testing - `php artisan test` on the affected suites — 13 passed. - `vendor/bin/pint`, `bun run format`, `bun run lint` — clean. --- app/Features/AiConsentSettings.php | 24 ------------------- app/Http/Middleware/HandleInertiaRequests.php | 4 ---- resources/js/pages/settings/billing.tsx | 12 ++++------ resources/js/pages/transactions/index.tsx | 3 +-- resources/js/types/index.d.ts | 1 - tests/Feature/AiConsentSettingsTest.php | 21 ---------------- .../Console/FeatureEnableCommandTest.php | 8 +++---- tests/Feature/InertiaSharedDataTest.php | 1 - 8 files changed, 10 insertions(+), 64 deletions(-) delete mode 100644 app/Features/AiConsentSettings.php diff --git a/app/Features/AiConsentSettings.php b/app/Features/AiConsentSettings.php deleted file mode 100644 index 92049d47..00000000 --- a/app/Features/AiConsentSettings.php +++ /dev/null @@ -1,24 +0,0 @@ - true, 'calculateBalancesOnImport' => false, - 'aiConsentSettings' => false, ]; } $features = Feature::for($user)->values([ CalculateBalancesOnImport::class, - AiConsentSettings::class, ]); return [ 'cashflow' => true, 'calculateBalancesOnImport' => $features[CalculateBalancesOnImport::class] !== false, - 'aiConsentSettings' => $features[AiConsentSettings::class] !== false, ]; } diff --git a/resources/js/pages/settings/billing.tsx b/resources/js/pages/settings/billing.tsx index 0a1ff167..5ca05e8c 100644 --- a/resources/js/pages/settings/billing.tsx +++ b/resources/js/pages/settings/billing.tsx @@ -476,7 +476,7 @@ function AiConsentSection({ } export default function Billing() { - const { auth, pricing, locale, features, hasAiConsent, refund } = usePage< + const { auth, pricing, locale, hasAiConsent, refund } = usePage< SharedData & { hasAiConsent: boolean; refund?: RefundInfo } >().props; const isDemoAccount = auth?.isDemoAccount ?? false; @@ -507,12 +507,10 @@ export default function Billing() { /> )} - {features.aiConsentSettings && ( - - )} + diff --git a/resources/js/pages/transactions/index.tsx b/resources/js/pages/transactions/index.tsx index c951b057..9fa09fdd 100644 --- a/resources/js/pages/transactions/index.tsx +++ b/resources/js/pages/transactions/index.tsx @@ -437,12 +437,11 @@ export default function Transactions({ lastVisitAt, }: Props) { const locale = useLocale(); - const { auth, features } = usePage().props; + const { auth } = usePage().props; const [aiConsentResolved, setAiConsentResolved] = useState(false); const [aiConsentSaving, setAiConsentSaving] = useState(false); const showAiConsentBanner = auth.hasProPlan && - features.aiConsentSettings && !hasAiConsent && !aiConsentPromptDismissed && !aiConsentResolved; diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index dd8cda89..525a0033 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -42,7 +42,6 @@ export interface NavDivider { export interface Features { cashflow: boolean; calculateBalancesOnImport: boolean; - aiConsentSettings: boolean; } export interface ExpiredBankingConnectionNotification { diff --git a/tests/Feature/AiConsentSettingsTest.php b/tests/Feature/AiConsentSettingsTest.php index e7af5450..e7edacf5 100644 --- a/tests/Feature/AiConsentSettingsTest.php +++ b/tests/Feature/AiConsentSettingsTest.php @@ -1,31 +1,10 @@ onboarded()->create(); - - actingAs($user)->withoutVite()->get(route('dashboard')) - ->assertInertia(fn (Assert $page) => $page - ->where('features.aiConsentSettings', false) - ); -}); - -test('ai consent settings flag is exposed when activated for the user', function () { - $user = User::factory()->onboarded()->create(); - Feature::for($user)->activate(AiConsentSettings::class); - - actingAs($user)->withoutVite()->get(route('dashboard')) - ->assertInertia(fn (Assert $page) => $page - ->where('features.aiConsentSettings', true) - ); -}); - test('billing page reports current ai consent state', function () { config(['subscriptions.enabled' => true]); $user = User::factory()->onboarded()->create(); diff --git a/tests/Feature/Console/FeatureEnableCommandTest.php b/tests/Feature/Console/FeatureEnableCommandTest.php index 7b1f6264..2ea50280 100644 --- a/tests/Feature/Console/FeatureEnableCommandTest.php +++ b/tests/Feature/Console/FeatureEnableCommandTest.php @@ -1,17 +1,17 @@ count(10)->create(); - $this->artisan('feature:enable', ['feature' => 'AiConsentSettings', 'target' => '40%']) + $this->artisan('feature:enable', ['feature' => 'CalculateBalancesOnImport', 'target' => '40%']) ->expectsOutputToContain('enabled for 4 users') ->assertSuccessful(); - $enabled = $users->filter(fn (User $user) => Feature::for($user)->active(AiConsentSettings::class)); + $enabled = $users->filter(fn (User $user) => Feature::for($user)->active(CalculateBalancesOnImport::class)); expect($enabled)->toHaveCount(4); }); @@ -19,6 +19,6 @@ test('enables a feature for a percentage of users', function () { test('rejects an out-of-range percentage', function () { User::factory()->create(); - $this->artisan('feature:enable', ['feature' => 'AiConsentSettings', 'target' => '0%']) + $this->artisan('feature:enable', ['feature' => 'CalculateBalancesOnImport', 'target' => '0%']) ->assertFailed(); }); diff --git a/tests/Feature/InertiaSharedDataTest.php b/tests/Feature/InertiaSharedDataTest.php index b9097964..a2d2c691 100644 --- a/tests/Feature/InertiaSharedDataTest.php +++ b/tests/Feature/InertiaSharedDataTest.php @@ -43,7 +43,6 @@ test('shared feature flags do not include coinbase flag', function () { expect($props['features'])->toBe([ 'cashflow' => true, 'calculateBalancesOnImport' => false, - 'aiConsentSettings' => false, ]); });