import { describe, expect, test } from 'bun:test'; import { CHAT_DEFAULT_MODEL, DEFAULT_MODEL, isTierlessModel } from './websocket'; import { CHAT_DEFAULT_MODEL as CLIENT_CHAT_DEFAULT_MODEL } from 'officerdev'; /** * The default model, and the two ways it has already been defeated. * * Both failures were silent and both cost real money: every unconfigured surface ran Opus while the code * said Sonnet. Neither was visible in a diff — one was a constant in another package, the other was a * value stored in somebody's settings. */ describe('the client and server agree on the default', () => { /* A comment cannot hold this. `apps/Chat/types.ts` mirrors the server's constant because the picker has to SHOW what the server would choose — and if it shows something else it also sends it, at which point the server honours the client and the "default" never applies. That is not hypothetical: the client fell back to the catalogue's first entry, which was `fable`, and did exactly that. */ test('the mirrored constant matches', () => { expect(CLIENT_CHAT_DEFAULT_MODEL).toBe(CHAT_DEFAULT_MODEL); }); test('it names a tier rather than the bare harness', () => { expect(CHAT_DEFAULT_MODEL).toContain('/'); expect(isTierlessModel(CHAT_DEFAULT_MODEL)).toBe(false); }); }); describe('isTierlessModel', () => { /* `claude-code` is a harness, and it is a legitimate value — `decideResume` assumes it when neither side knows which sidecar a session belongs to. As an answer to "which model", it means "whatever the CLI picks", which is Opus. Accounts have it stored from before that distinction existed, which is why the default appeared to do nothing on a machine where it was set. */ test('the bare harness is not a model choice', () => { expect(isTierlessModel(DEFAULT_MODEL)).toBe(true); expect(isTierlessModel('claude-code')).toBe(true); }); test('nothing chosen is not a model choice either', () => { expect(isTierlessModel(null)).toBe(true); expect(isTierlessModel(undefined)).toBe(true); expect(isTierlessModel('')).toBe(true); }); test('a real tier is', () => { expect(isTierlessModel('claude-code/sonnet')).toBe(false); expect(isTierlessModel('claude-code/opus[1m]')).toBe(false); // OpenCode ids carry a provider prefix of their own, so they are tiered by the same test. expect(isTierlessModel('opencode/some-model')).toBe(false); }); });