a new chat offered fable. not displayed it — SELECTED it, sent it, and the server honoured the choice it was given. the composer's fallback was providerModels[0], the first entry in the catalogue, which is not a default but an ordering accident. the file already carried a comment about the day fable was added above opus and every resumed session came back claiming fable; the same accident then quietly defeated the whole server-side default. so the fallback prefers the platform's default and uses catalogue order only when that model is not in the provider's list at all — which is every opencode model, where there is no officer-wide default to prefer. and a test, because a comment cannot hold a constant mirrored across two packages. it asserts the client's copy equals the server's, and that the value names a tier rather than the bare harness. both of the ways this default has been defeated are now failures a test catches: a drifted mirror, and a stored harness read as a choice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043
55 lines
2.4 KiB
TypeScript
55 lines
2.4 KiB
TypeScript
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);
|
|
});
|
|
});
|