From 183a3f0a8131607550d41a45139614590e3c1b30 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sat, 27 Jun 2026 11:37:42 -0400 Subject: [PATCH] fix(ext): ERROR_COPY entries for org context errors (read-UI surfacing) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A's org foundation returns org_not_configured (ok:false) plus thrown not_an_org_member / device_key_unavailable, none of which had user-facing copy — they would render as the raw code. Add friendly copy (org_not_configured ties into the add-org flow) and a focused test; fixes the ERROR_COPY-coverage test that the foundation merge left red. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01W3b8DA2mXmLWkd4zDbHXHg --- extension/src/shared/__tests__/error-copy.test.ts | 11 +++++++++++ extension/src/shared/error-copy.ts | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/extension/src/shared/__tests__/error-copy.test.ts b/extension/src/shared/__tests__/error-copy.test.ts index 5e44b0d..d16fdf2 100644 --- a/extension/src/shared/__tests__/error-copy.test.ts +++ b/extension/src/shared/__tests__/error-copy.test.ts @@ -41,4 +41,15 @@ describe('ERROR_COPY', () => { expect(copy.title).toBe('Something went wrong'); expect(copy.body).toContain('made_up_code_xyz'); }); + + // The discovery test above only catches codes returned via `ok: false, error: ''` + // (org_not_configured). The other user-facing org errors are thrown (-> e.message -> + // humanizeError), so assert they resolve to real copy rather than the generic fallback. + it('maps the user-facing org error codes to friendly copy', () => { + for (const code of ['org_not_configured', 'not_an_org_member', 'device_key_unavailable']) { + const copy = lookupErrorCopy(code); + expect(copy.title).not.toBe('Something went wrong'); + expect(copy.body).not.toBe(code); + } + }); }); diff --git a/extension/src/shared/error-copy.ts b/extension/src/shared/error-copy.ts index 256a794..bd5377b 100644 --- a/extension/src/shared/error-copy.ts +++ b/extension/src/shared/error-copy.ts @@ -100,6 +100,20 @@ export const ERROR_COPY: Record = { body: 'Run setup to save your reference image.', cta: { label: 'Open setup', action: 'open_setup' }, }, + // --- Org (enterprise) context errors (v0.9.0 Plan B) --- + org_not_configured: { + title: 'Org not set up here', + body: 'This organization is not configured on this device yet. Add it from the vault switcher before browsing its items.', + }, + not_an_org_member: { + title: 'Not a member', + body: "This device isn't a member of that organization — ask an org admin to add your device key.", + }, + device_key_unavailable: { + title: 'Device key unavailable', + body: 'Your device key could not be restored. Lock and unlock your vault to refresh it, then try again.', + cta: UNLOCK_CTA, + }, }; export function lookupErrorCopy(code: string): ErrorCopy {