chore(app): chat probes take platform/theme/tasks queries; note chat chrome fixes
This commit is contained in:
@@ -27,12 +27,24 @@ class _ProbeGateway implements ApiGateway {
|
||||
switch (type) {
|
||||
case 'chat_subscribe':
|
||||
return <String, dynamic>{};
|
||||
case 'chat_shells':
|
||||
// `?tasks=2` reports that many running background tasks.
|
||||
return {
|
||||
'chat_shells': [
|
||||
for (var i = 0; i < _probeTasks; i++)
|
||||
{
|
||||
'id': 'probe-shell-$i',
|
||||
'status': 'running',
|
||||
'command': 'go test ./... #$i',
|
||||
},
|
||||
],
|
||||
};
|
||||
case 'chat_messages':
|
||||
return {
|
||||
'chat_history': {
|
||||
'messages': [
|
||||
// A long history scrolls behind the floating header.
|
||||
if (_probeLong)
|
||||
if (_probeLong || _query['long'] == '1')
|
||||
for (var i = 0; i < 12; i++)
|
||||
{
|
||||
'id': 'probe-history-$i',
|
||||
@@ -133,26 +145,40 @@ const _probeStyle = String.fromEnvironment(
|
||||
defaultValue: 'material',
|
||||
);
|
||||
|
||||
/// Browser overrides: `?platform=cupertino|material`, `?theme=dark|light`,
|
||||
/// `?long=1`, `?tasks=<n>`, `?mode=0` (no permission mode recorded) and
|
||||
/// `?model=0` (a backend without models).
|
||||
Map<String, String> get _query => Uri.base.queryParameters;
|
||||
int get _probeTasks => int.tryParse(_query['tasks'] ?? '') ?? 0;
|
||||
|
||||
void main() {
|
||||
final gateway = _ProbeGateway();
|
||||
final cupertino = (_query['platform'] ?? _probeStyle) == 'cupertino';
|
||||
final dark = _query['theme'] == null ? cupertino : _query['theme'] == 'dark';
|
||||
final thread = ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 'probe-composer',
|
||||
title: 'Composer fixture',
|
||||
session: const {
|
||||
session: {
|
||||
'id': 'probe-composer',
|
||||
'backend': 'opencode',
|
||||
'backend': _query['model'] == '0' ? 'pi' : 'opencode',
|
||||
'model': _probeModel,
|
||||
'directory': '/Users/ada/repos/tank',
|
||||
if (_query['mode'] != '0') ...{
|
||||
'mode': 'default',
|
||||
'mode_name': 'Ask for permission',
|
||||
},
|
||||
},
|
||||
onBack: () {},
|
||||
drafts: MemoryChatDraftStore(),
|
||||
newOperationId: gateway.nextOperation,
|
||||
);
|
||||
if (_probeStyle == 'cupertino') {
|
||||
if (cupertino) {
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
theme: CupertinoThemeData(
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
home: CupertinoPageScaffold(child: _framed(SafeArea(child: thread))),
|
||||
),
|
||||
);
|
||||
@@ -162,7 +188,7 @@ void main() {
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
platform: TargetPlatform.android,
|
||||
brightness: Brightness.light,
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
home: Scaffold(body: _framed(SafeArea(child: thread))),
|
||||
),
|
||||
|
||||
@@ -132,11 +132,22 @@ const _probeStyle = String.fromEnvironment(
|
||||
void main() {
|
||||
final dark = Uri.base.queryParameters['dark'] == '1';
|
||||
final unseen = Uri.base.queryParameters['unseen'] == '1';
|
||||
final home = ChatSessionsScreen(
|
||||
gateway: _FixtureGateway(bumpAfterFirstRead: unseen),
|
||||
onOpen: (_) {},
|
||||
);
|
||||
if (_probeStyle == 'cupertino') {
|
||||
final gateway = _FixtureGateway(bumpAfterFirstRead: unseen);
|
||||
// `?many=1` adds enough chats to scroll the list behind the bar.
|
||||
if (Uri.base.queryParameters['many'] == '1') {
|
||||
gateway._sessions.addAll([
|
||||
for (var i = 0; i < 24; i++)
|
||||
{
|
||||
'id': 'probe-many-$i',
|
||||
'title': 'Fixture chat ${i + 1}',
|
||||
'directory': '/workspace/demo',
|
||||
},
|
||||
]);
|
||||
}
|
||||
final home = ChatSessionsScreen(gateway: gateway, onOpen: (_) {});
|
||||
// `?platform=cupertino` overrides the compile-time style.
|
||||
final style = Uri.base.queryParameters['platform'] ?? _probeStyle;
|
||||
if (style == 'cupertino') {
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
theme: CupertinoThemeData(
|
||||
|
||||
Reference in New Issue
Block a user