diff --git a/web/app/Services/Cloud/CloudJobService.php b/web/app/Services/Cloud/CloudJobService.php index b24adb04..0992f495 100644 --- a/web/app/Services/Cloud/CloudJobService.php +++ b/web/app/Services/Cloud/CloudJobService.php @@ -12,6 +12,9 @@ use App\Models\User; final class CloudJobService { + /** Local workflows observed by their owning page, never by the task drawer. */ + private const TASK_CENTER_HIDDEN_KINDS = ['payment_create']; + public const SHUTDOWN_CONVERGENCE_SECONDS = 60; private const RECEIPT_DEADLINE_SECONDS = 960; @@ -3898,22 +3901,7 @@ final class CloudJobService (int) ($actor['user_id'] ?? 0), null, 100 ); $limit = max(1, min(50, $limit)); - $owner = static function ($query) use ($actor): void { - $query->where('user_id', (int) ($actor['user_id'] ?? 0)); - }; - // Per-host child jobs are implementation details of one public batch. - // Only their parent appears in the task center. - $base = CloudJob::query()->whereNull('vpc_batch_id')->where( - static function ($public): void { - $public->whereNull('parent_job_id') - ->orWhere(static function ($currentCatalog): void { - self::whereCurrentAggregateCatalogBinding( - $currentCatalog - ); - }); - } - ); - $owner($base); + $base = self::taskCenterQuery($actor); $activeCount = (clone $base)->where('phase', '<>', 'terminal')->count(); $recovering = clone $base; self::applyRecoveringFilter($recovering); @@ -3957,9 +3945,20 @@ final class CloudJobService public static function unreadCount(array $actor): int { - $query = CloudJob::where('phase', 'terminal')->whereNull('read_at') - ->whereNull('vpc_batch_id') + return (int) self::taskCenterQuery($actor) + ->where('phase', 'terminal')->whereNull('read_at')->count(); + } + + /** + * Owner-visible drawer tasks only. Direct task receipts remain readable so + * the originating workflow can safely observe its own local operation. + */ + private static function taskCenterQuery(array $actor) + { + return CloudJob::query() ->where('user_id', (int) ($actor['user_id'] ?? 0)) + ->whereNotIn('kind', self::TASK_CENTER_HIDDEN_KINDS) + ->whereNull('vpc_batch_id') ->where(static function ($public): void { $public->whereNull('parent_job_id') ->orWhere(static function ($currentCatalog): void { @@ -3968,7 +3967,6 @@ final class CloudJobService ); }); }); - return (int) $query->count(); } private static function requestKey(array $actor): ?string diff --git a/web/public/cloud/invoice-detail-runtime.js b/web/public/cloud/invoice-detail-runtime.js index 4c5c828d..019679e9 100644 --- a/web/public/cloud/invoice-detail-runtime.js +++ b/web/public/cloud/invoice-detail-runtime.js @@ -902,7 +902,6 @@ async function createInvoicePayment(invoice, method, container, paymentResult) { error.code = 'INVALID_TASK_RECEIPT'; throw error; } - announceTaskAccepted(result, { title: t('billing.payment.task_title') }); paymentResult.replaceChildren(makeElement('p', 'invoice-payment-note', t('billing.payment.task_accepted'))); toast(t('billing.payment.task_accepted_short'), 'success'); diff --git a/web/resources/views/venix/layout_assets.tpl b/web/resources/views/venix/layout_assets.tpl index 2cb88b04..51212201 100644 --- a/web/resources/views/venix/layout_assets.tpl +++ b/web/resources/views/venix/layout_assets.tpl @@ -1,2 +1,2 @@ {* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *} -{assign var=venix_asset_version value='2026112202' scope='global'} +{assign var=venix_asset_version value='2026112301' scope='global'} diff --git a/web/tests/CloudTaskRecoveryPresentationTest.php b/web/tests/CloudTaskRecoveryPresentationTest.php index 31ac0dcc..3f417972 100644 --- a/web/tests/CloudTaskRecoveryPresentationTest.php +++ b/web/tests/CloudTaskRecoveryPresentationTest.php @@ -237,6 +237,43 @@ $insert(8000, [ 'finalization_error_code' => null, 'available_at' => 0, ]); +$insert(8001, [ + 'kind' => 'payment_create', + 'execution_mode' => 'local', + 'instance_id' => null, + 'host_id' => null, + 'phase' => 'accepted', + 'outcome' => null, + 'status' => 'queued', + 'attempts' => 0, + 'dispatch_attempts' => 0, + 'dispatch_deadline_at' => $now + 300, + 'dispatch_started_at' => null, + 'agent_accepted_at' => null, + 'dispatched_at' => null, + 'receipt_deadline_at' => null, + 'terminal_at' => null, + 'effect_may_have_applied' => null, + 'safe_to_resubmit' => null, + 'effect_resolution' => 'not_applicable', + 'finalization_incident' => 0, + 'finalization_error_code' => null, + 'available_at' => $now, +]); +$insert(8002, [ + 'kind' => 'payment_create', + 'execution_mode' => 'local', + 'instance_id' => null, + 'host_id' => null, + 'outcome' => 'succeeded', + 'status' => 'succeeded', + 'effect_may_have_applied' => 0, + 'safe_to_resubmit' => 0, + 'effect_resolution' => 'applied', + 'finalization_incident' => 0, + 'finalization_error_code' => null, + 'available_at' => 0, +]); $tasks = CloudJobService::tasks(['user_id' => 7, 'is_admin' => false], 'completed'); @@ -244,9 +281,18 @@ $assert(($tasks['active_count'] ?? null) === 1, 'Task center active count changed while adding recovery polling.'); $assert(($tasks['recovering_count'] ?? null) === 2, 'Task center did not count visible terminal tasks that still converge.'); +$assert(($tasks['unread_count'] ?? null) === 4, + 'A hidden payment task changed the task-center unread badge.'); $assert(array_map(static fn (array $item): string => $item['id'], $tasks['items']) === ['5', '3', '2', '1'], - 'Task center exposed hidden child work or changed terminal ordering.'); + 'Task center exposed hidden child or payment work, or changed terminal ordering.'); +$paymentReceipt = CloudJobService::display( + \App\Models\CloudJob::findOrFail(8002), + false +); +$assert(($paymentReceipt['id'] ?? null) === '8002' + && ($paymentReceipt['completed'] ?? null) === true, + 'Hiding payment work from the drawer also broke direct receipt polling.'); $assert(($tasks['items'][0]['recovery']['pending'] ?? null) === true && ($tasks['items'][3]['recovery']['pending'] ?? null) === true && !isset($tasks['items'][1]['recovery']) diff --git a/web/tests/PaymentProviderAttemptContractTest.php b/web/tests/PaymentProviderAttemptContractTest.php index c222331b..3c030267 100644 --- a/web/tests/PaymentProviderAttemptContractTest.php +++ b/web/tests/PaymentProviderAttemptContractTest.php @@ -52,5 +52,8 @@ $assert(!str_contains($invoiceRuntime, 'onlinePaymentFallbackExpiresAt') && str_contains($invoiceRuntime, 'const idempotencyKey = pendingInvoicePaymentKey(invoice.id, method.id);'), 'The browser no longer separates explicit payment attempts from transport retries.'); +$assert(!str_contains($invoiceRuntime, + "announceTaskAccepted(result, { title: t('billing.payment.task_title') });"), + 'Creating a provider payment still announces private payment work to the task center.'); echo "Provider attempt lifetime and retry contract passed.\n";