Repository navigation
Description
What happens
On Settings → Connected apps, the disconnect server action in src/app/app/(chrome)/settings/connected-apps/page.tsx catches a ServiceException from revokeConnectedApp and puts err.serviceError.message straight into the ?error= redirect. The page then shows that text in a FormError box.
revokeConnectedApp (src/oauth/grants.ts) throws not_found with the message "no such connected app" when the grant is gone. Disconnecting an app from a tab opened before it was already disconnected (in another tab, say) shows the organizer a red box reading "no such connected app": lowercase, written for developers.
Everywhere else, organizer refusals map the error code to plain words before showing them. SAVE_ERROR_MESSAGE in src/components/ui/save-notice.tsx does this for the Settings tab and Delete, and so do status-refusal.ts and responses/remove-refusal.ts. SAVE_ERROR_MESSAGE's comment says why: the service's own message "is written for developers". Connected apps is the one place that skips this step.
Its fallback for any other error, "Could not disconnect. Try again.", also breaks the house style. Nearby refusals say "Couldn’t …" with a curly apostrophe, e.g. "Couldn’t publish. Try again." and "Couldn’t remove them. Try again.".
Fix, in outline
- Add a small
disconnectRefusal(code)beside the page, shaped likestatus-refusal.ts:not_found→ "That app is already disconnected."- anything else → "Couldn’t disconnect. Try again."
- Use it for both the
ServiceExceptionpath and the unexpected-error path. Keep logging unexpected errors as today. - Call
revalidatePath(PATH)before the error redirect too, so a stale row disappears from the list when the app was already gone.
Watch for
unauthorized("sign in required") is effectively unreachable, because the action callsrequireOrganizerSession()first. The mapping's fallback covers it anyway.- Help. If
src/help/articles/connect-an-ai-assistant.tsxdescribes disconnecting, check it still reads true. It doesn't quote this error today. - Existing tests.
src/oauth/flow.db.test.tschecks only the service's error codes. Leave them as they are.
Done when
- A unit test for
disconnectRefusalpins the wording fornot_foundand for another code. - The page never puts
serviceError.messageinto the URL. pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm testpass.
Found by the pipeline's refactor scout in the organizer settings pages (src/app/app/(chrome)/settings/connected-apps), at 001a284. Checked by an independent verify agent: a scratch DB test ran the page's catch logic against the real revokeConnectedApp with an unknown grant id, and the redirect decoded to "no such connected app". https://claude.ai/code/session_016YZ9STKE7qmnEctzqxYG4q
Activity
Say an app is already disconnected, from the message catalogs