diff --git a/apps/mobile/src/components/agents/cloud-prepare-error-display.test.ts b/apps/mobile/src/components/agents/cloud-prepare-error-display.test.ts index 767d1f9415b..515ad38faa8 100644 --- a/apps/mobile/src/components/agents/cloud-prepare-error-display.test.ts +++ b/apps/mobile/src/components/agents/cloud-prepare-error-display.test.ts @@ -59,6 +59,24 @@ describe('cloudPrepareFailureMessage', () => { ); }); + it('maps a missing profile record to the removed-or-unavailable copy', () => { + const missing = makeError('NOT_FOUND', "Profile 'profile-42' not found"); + const message = cloudPrepareFailureMessage(missing); + expect(message).toBe('This item may have been removed or is no longer available.'); + expect(message).not.toContain('profile-42'); + }); + + it('maps the shaped form of a missing record too', () => { + const missing = { + shape: { + data: { code: 'NOT_FOUND', message: "Profile 'profile-42' not found" }, + }, + }; + expect(cloudPrepareFailureMessage(missing)).toBe( + 'This item may have been removed or is no longer available.' + ); + }); + it('never shows the raw server detail for an unclassified rejection', () => { const raw = makeError('BAD_REQUEST', 'Runtime credential proxy configuration is unavailable'); const message = cloudPrepareFailureMessage(raw); diff --git a/apps/mobile/src/components/agents/cloud-prepare-error-display.ts b/apps/mobile/src/components/agents/cloud-prepare-error-display.ts index 66b5d8faee1..8d8bf68f553 100644 --- a/apps/mobile/src/components/agents/cloud-prepare-error-display.ts +++ b/apps/mobile/src/components/agents/cloud-prepare-error-display.ts @@ -17,9 +17,12 @@ const MODEL_UNAVAILABLE_MESSAGE = 'Selected model is not available for this clou /** * The localized failure copy for a rejected cloud prepare. Only failures the - * message names precisely get actionable copy; every other rejection — an - * unclassified server detail, an unknown transport failure — gets the generic - * service line, because the tRPC code alone does not identify the failure. + * message names precisely, plus the missing-selection code, get actionable + * copy; every other rejection — an unclassified server detail, an unknown + * transport failure — gets the generic service line, because the tRPC code + * alone does not identify the failure. Prepare resolves the requested profile + * before it registers the session, so its only `NOT_FOUND` is a profile that + * no longer exists: the reader refreshes the selection instead of retrying. */ export function cloudPrepareFailureMessage(error: unknown): string { const message = readTrpcErrorField(error, 'message'); @@ -29,6 +32,9 @@ export function cloudPrepareFailureMessage(error: unknown): string { if (message === MODEL_UNAVAILABLE_MESSAGE) { return i18n.t('agentChat.session.modelUnavailable'); } + if (readTrpcErrorField(error, 'code') === 'NOT_FOUND') { + return i18n.t('queryError.notFoundDescription'); + } if (readTrpcErrorField(error, 'code') === 'PAYMENT_REQUIRED') { return i18n.t('agentChat.session.notEnoughCredits'); }