Files
buzz/mobile/test/features/agents/agent_model_picker_test.dart
morgmart 0dd778f800 mobile: start new agents on Sonnet at medium effort (#9034)
## Summary

The mobile create-agent screen opened with model and thinking effort
blank, so the easiest path was picking from the full catalog, expensive
models included. A new agent now starts on the first Sonnet model the
catalog offers, at medium effort when that model supports it. People can
still change either one.

- An agent link that suggests a model still wins when Builderlab offers
that model.
- A setup resumed after a failure keeps the choice it saved.
- If the catalog has no Sonnet model, both start blank like today. If
the Sonnet model has no medium effort, only effort is left blank.

Builderlab doesn't send a default or pricing, so the app matches on
"sonnet" in the model id rather than pinning a version. That keeps
working when the catalog moves to a newer Sonnet.

## Screenshots

Captured from the widget test harness with a catalog listing Opus first,
then Sonnet. The avatar preview is blank because the test doesn't load
network images.

| Narrow, light | Narrow, dark | Wide, light |
| --- | --- | --- |
| ![Create agent, narrow
light](https://raw.githubusercontent.com/block/buzz/8cb0af35dfc38de81ee942b2c3475009549d6370/default-model--create-agent-narrow-light.png)
| ![Create agent, narrow
dark](https://raw.githubusercontent.com/block/buzz/8cb0af35dfc38de81ee942b2c3475009549d6370/default-model--create-agent-narrow-dark.png)
| ![Create agent, wide
light](https://raw.githubusercontent.com/block/buzz/8cb0af35dfc38de81ee942b2c3475009549d6370/default-model--create-agent-wide-light.png)
|

## Testing

- New unit tests cover the default, missing medium effort, no Sonnet,
draft model wins, and a draft model the catalog lacks.
- A new widget test checks the form opens on Sonnet at medium and only
needs a name before Create.
- Full mobile suite passes locally with the CI dart-defines
(`BUZZ_PUSH_GATEWAY_URL`, `BUZZ_AUTH_DOMAINS`) at 256063f95.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
Co-authored-by: Carl <c217fe6b9d958f41c3a5e030dccc7f626775a923089cb6491305eade75ea1f1b@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 22:14:12 -08:00

67 lines
1.6 KiB
Dart

import 'package:buzz/features/agents/agent_model_picker.dart';
import 'package:buzz/shared/agents/remote_agents.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
const opus = RemoteAgentModel(
id: 'kgoose-claude-opus-4-6',
name: 'Opus',
efforts: ['low', 'medium', 'high'],
);
const sonnet = RemoteAgentModel(
id: 'kgoose-claude-sonnet-4-6',
name: 'Sonnet',
efforts: ['low', 'medium', 'high'],
);
test('defaults to Sonnet at medium effort', () {
expect(startingAgentModel([opus, sonnet]), (
'kgoose-claude-sonnet-4-6',
'medium',
));
});
test('leaves effort for the user when medium is not offered', () {
const highOnly = RemoteAgentModel(
id: 'claude-sonnet-5',
name: 'Sonnet 5',
efforts: ['high'],
);
expect(startingAgentModel([opus, highOnly]), ('claude-sonnet-5', null));
});
test('chooses nothing when no Sonnet is offered', () {
expect(startingAgentModel([opus]), (null, null));
});
test('a draft model the catalog offers wins over the default', () {
expect(
startingAgentModel(
[opus, sonnet],
draftModel: opus.id,
draftEffort: 'high',
),
(opus.id, 'high'),
);
expect(
startingAgentModel(
[opus, sonnet],
draftModel: opus.id,
draftEffort: 'max',
),
(opus.id, null),
);
});
test('a draft model the catalog lacks falls back to the default', () {
expect(
startingAgentModel(
[opus, sonnet],
draftModel: 'gone',
draftEffort: 'high',
),
(sonnet.id, 'medium'),
);
});
}