545291e04a
- Run rows show a failed run's reason (else its diagnostic's first line, full text in a tooltip) or a short result preview; the Summary leads with "Why it failed". - Run again for succeeded/canceled/interrupted runs opens the New run form pre-filled (prompt, workspace, report format) at the latest version with the original offered. - Run detail and stage tabs show their names; touch shows captions on the Runs header and artifact viewer actions (desktop keeps tooltips). - ErrorNotice maps not connected / server too old / permission / timeout to what to do, raw detail behind Details (Schedules, create chat, Runs, Pipelines banners). - Settings has no Back arrow; Schedules keeps the rail on wide windows; phone Settings leads with Connection and Notifications and has a Jump to topic menu. - Walkthrough: Open Connection (skipped when connected), labelled Copy. - Pluralised counts; no duplicate status/rail names for screen readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
185 lines
5.7 KiB
Dart
185 lines
5.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/error_advice.dart';
|
|
import '../../../../ui/status/error_notice.dart';
|
|
|
|
/// The web's directory prompt, also the directory picker's label.
|
|
const String chatCreatePrompt = 'Where should this chat live?';
|
|
|
|
/// Opens the folder picker from the create dialog.
|
|
const String chatChooseFolderLabel = 'Choose folder…';
|
|
|
|
/// The home choice: shown as `Home (~)` and sent as the `~` the server
|
|
/// documents.
|
|
const String chatHomeDirectory = '~';
|
|
const String chatHomeLabel = 'Home ($chatHomeDirectory)';
|
|
|
|
/// The web's directory choices: home first (the server's first directory is
|
|
/// its path), then the remaining server directories as sent.
|
|
List<String> chatDirectoryChoices(List<String> directories) => [
|
|
chatHomeDirectory,
|
|
...directories.skip(1),
|
|
];
|
|
|
|
/// The visible label of a directory choice; home names its resolved path.
|
|
String chatDirectoryLabel(String choice, List<String> directories) {
|
|
if (choice != chatHomeDirectory) return choice;
|
|
final home = directories.isEmpty ? chatHomeDirectory : directories.first;
|
|
return '$chatHomeLabel — $home';
|
|
}
|
|
|
|
/// The web's names for the chat harnesses; an unknown one shows as sent.
|
|
String chatBackendLabel(String backend) => switch (backend) {
|
|
'codex' => 'Codex',
|
|
'claude' => 'Claude',
|
|
'pi' => 'Pi',
|
|
'opencode' => 'OpenCode',
|
|
_ => backend,
|
|
};
|
|
|
|
/// The create dialog's server catalog area: loading, error with retry, the
|
|
/// directory choices and, only when the server offers more than one, the
|
|
/// harness choice.
|
|
class ChatCatalogFields extends StatelessWidget {
|
|
const ChatCatalogFields({
|
|
super.key,
|
|
required this.loading,
|
|
required this.error,
|
|
required this.directories,
|
|
required this.backends,
|
|
required this.directory,
|
|
required this.backend,
|
|
required this.onDirectory,
|
|
required this.onBackend,
|
|
required this.onRetry,
|
|
this.onBrowse,
|
|
});
|
|
|
|
final bool loading;
|
|
final String? error;
|
|
final List<String> directories;
|
|
final List<String> backends;
|
|
final String? directory;
|
|
final String? backend;
|
|
final ValueChanged<String> onDirectory;
|
|
final ValueChanged<String> onBackend;
|
|
final VoidCallback onRetry;
|
|
|
|
/// Opens the folder picker; null hides the "Choose folder" action.
|
|
final VoidCallback? onBrowse;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (loading) return const Text('Loading directories…');
|
|
if (error case final error?) {
|
|
// A common failure says what to do; its raw detail stays behind
|
|
// Details. Anything else reads as before.
|
|
return errorAdvice(error) == null
|
|
? _message(Text('Unable to load chat options: $error'))
|
|
: _message(ErrorNotice(error: error));
|
|
}
|
|
final choices = chatDirectoryChoices(directories);
|
|
String directoryLabel(String choice) =>
|
|
chatDirectoryLabel(choice, directories);
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// Keyed by the value so a folder chosen in the picker replaces the
|
|
// dropdown's retained initial value.
|
|
KeyedSubtree(
|
|
key: ValueKey('chat-create-directory-$directory'),
|
|
child: MaterialPickerField(
|
|
fieldKey: const Key('chat-create-server-directory'),
|
|
label: chatCreatePrompt,
|
|
value: directory,
|
|
values: choices,
|
|
labelOf: directoryLabel,
|
|
onSelected: onDirectory,
|
|
),
|
|
),
|
|
if (onBrowse != null)
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: TextButton.icon(
|
|
key: const Key('chat-create-choose-folder'),
|
|
onPressed: onBrowse,
|
|
icon: const Icon(Icons.folder_open),
|
|
label: const Text(chatChooseFolderLabel),
|
|
),
|
|
),
|
|
if (backends.length > 1)
|
|
MaterialPickerField(
|
|
fieldKey: const Key('chat-create-backend'),
|
|
label: 'Chat harness',
|
|
value: backend,
|
|
values: backends,
|
|
labelOf: chatBackendLabel,
|
|
onSelected: onBackend,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _message(Widget text) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
text,
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: TextButton(onPressed: onRetry, child: const Text('Retry')),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class MaterialPickerField extends StatelessWidget {
|
|
const MaterialPickerField({
|
|
super.key,
|
|
required this.fieldKey,
|
|
required this.label,
|
|
required this.value,
|
|
required this.values,
|
|
required this.onSelected,
|
|
this.labelOf,
|
|
});
|
|
|
|
final String label;
|
|
final String? value;
|
|
final List<String> values;
|
|
final ValueChanged<String> onSelected;
|
|
final Key fieldKey;
|
|
|
|
/// The visible text of a value; the value itself is what is sent.
|
|
final String Function(String value)? labelOf;
|
|
|
|
String _text(String value) => labelOf?.call(value) ?? value;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DropdownButtonFormField<String>(
|
|
key: fieldKey,
|
|
initialValue: value,
|
|
isExpanded: true,
|
|
// Intrinsic item height: a 2x label must not be clipped by the 48px
|
|
// default, and a real path must ellipsize instead of overflowing.
|
|
itemHeight: null,
|
|
decoration: InputDecoration(labelText: label),
|
|
selectedItemBuilder: (context) => [
|
|
for (final item in values) _fieldLabel(item),
|
|
],
|
|
items: [
|
|
for (final item in values)
|
|
DropdownMenuItem(value: item, child: _fieldLabel(item)),
|
|
],
|
|
onChanged: (item) {
|
|
if (item != null) onSelected(item);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _fieldLabel(String item) {
|
|
return Text(_text(item), maxLines: 1, overflow: TextOverflow.ellipsis);
|
|
}
|
|
}
|