Skip to content

Commit 48231cf

Browse files
committed
fix(prompt): tell the user to log in when guest sessions are disabled
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk4f4h47qCJpk4KpQvZ
1 parent c925b7a commit 48231cf

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/prompt/auth.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ async function requestSession(endpoint: string, body: object): Promise<Anonymous
9595
});
9696

9797
if (!res.ok) {
98-
throw new Error(`Unable to start a Codify session (${res.status}): ${await res.text()}`);
98+
const text = await res.text();
99+
// Guest sessions are switched off on the server: the user has to log in
100+
if (text.includes('anonymous_provider_disabled')) {
101+
throw new Error('Guest sessions are not available right now. Run `codify login` to use the Codify agent.');
102+
}
103+
104+
throw new Error(`Unable to start a Codify session (${res.status}): ${text}`);
99105
}
100106

101107
const json = await res.json() as { access_token: string; refresh_token: string; expires_at?: number; expires_in?: number };

‎test/prompt/auth-and-store.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ describe('PromptAuth', () => {
9797
.mockResolvedValueOnce(sessionResponse('anon-2', now + 3600));
9898
expect((await PromptAuth.get()).userId).toBe('anon-2');
9999
});
100+
101+
it('tells the user to log in when anonymous sign-ins are disabled', async () => {
102+
fetchMock.mockResolvedValueOnce(new Response(
103+
'{"code":422,"error_code":"anonymous_provider_disabled","msg":"Anonymous sign-ins are disabled"}',
104+
{ status: 422 },
105+
));
106+
await expect(PromptAuth.get()).rejects.toThrow(/codify login/);
107+
});
100108
});
101109

102110
describe('SessionStore', () => {

0 commit comments

Comments
 (0)