Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions apps/mobile/src/components/agents/cloud-prepare-error-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
}
Expand Down
Loading