feat(app): match the web run detail tabs and summary shape
This commit is contained in:
@@ -1,85 +1,85 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../pipelines/pipeline_format.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
|
||||
/// The exact wording for a Summary fact the reply did not record.
|
||||
/// One recorded Summary row: the web run summary's key/value shape.
|
||||
///
|
||||
/// It is the same word the Summary's usage rows already use for an unreported
|
||||
/// value, so one absent fact never reads as `0`, `false` or an empty field.
|
||||
const String summaryUnknownValue = 'Unavailable';
|
||||
/// [monospace] marks a value the web renders as a code identifier (the content
|
||||
/// hash); [block] marks a multi-line recorded document (the diagnostic) that is
|
||||
/// drawn as its own block rather than a short row.
|
||||
typedef DetailSummaryRow = ({
|
||||
String label,
|
||||
String value,
|
||||
bool monospace,
|
||||
bool block,
|
||||
});
|
||||
|
||||
/// The run Summary's recorded facts, in the web summary's order: the current
|
||||
/// stage and the run's timing, then the latest recorded visit's effective
|
||||
/// provider/model, target and verdict.
|
||||
/// The run Summary's rows, in the web summary's order: Pipeline, Stage,
|
||||
/// Workspace, Content hash, Started, Finished, Duration, Retry of and the
|
||||
/// Diagnostic block.
|
||||
///
|
||||
/// The latest visit is the one the Graph tab opens for the current stage, so
|
||||
/// the Summary and the recorded-visit pane describe the same evidence. Tokens
|
||||
/// and cost stay in [detailUsageMetrics], their existing Summary home. A fact
|
||||
/// the server did not record reads [summaryUnknownValue].
|
||||
List<DetailMetric> detailSummaryFields(JsonMap run) {
|
||||
final steps = detailRunSteps(run);
|
||||
final stage = _text(run['current_stage']);
|
||||
final latest = _latestVisit(steps, stage);
|
||||
return [
|
||||
(label: 'Stage', value: stage ?? summaryUnknownValue),
|
||||
(
|
||||
label: 'Started',
|
||||
value:
|
||||
formatLocalTimestamp(_text(run['created_at'])) ?? summaryUnknownValue,
|
||||
),
|
||||
(
|
||||
label: 'Finished',
|
||||
value:
|
||||
formatLocalTimestamp(_text(run['finished_at'])) ??
|
||||
summaryUnknownValue,
|
||||
),
|
||||
(label: 'Duration', value: _duration(run) ?? summaryUnknownValue),
|
||||
(
|
||||
label: 'Provider/model',
|
||||
value: latest == null
|
||||
? summaryUnknownValue
|
||||
: detailVisitProviderModel(latest) ?? summaryUnknownValue,
|
||||
),
|
||||
(
|
||||
label: 'Target',
|
||||
value: latest == null
|
||||
? summaryUnknownValue
|
||||
: _text(latest['target']) ?? summaryUnknownValue,
|
||||
),
|
||||
(label: 'Verdict', value: _verdict(latest) ?? summaryUnknownValue),
|
||||
];
|
||||
}
|
||||
|
||||
/// The latest recorded visit of [stage], or the latest visit when the reply
|
||||
/// records no current stage. It is the same visit the Graph tab opens for that
|
||||
/// stage, so a fact and its Stage row never come from different visits.
|
||||
JsonMap? _latestVisit(List<JsonMap> steps, String? stage) {
|
||||
JsonMap? latest;
|
||||
for (final step in steps) {
|
||||
if (stage == null || _text(step['stage']) == stage) latest = step;
|
||||
/// Only values the server actually recorded are rows: a blank field is omitted
|
||||
/// rather than drawn as an empty or invented placeholder, exactly as
|
||||
/// `summaryRows` in the web client does. A run with no pipeline id shows its
|
||||
/// recorded pipeline name, and shows no Pipeline row at all when it recorded
|
||||
/// neither.
|
||||
List<DetailSummaryRow> detailSummaryRows(JsonMap run) {
|
||||
final rows = <DetailSummaryRow>[];
|
||||
void add(
|
||||
String label,
|
||||
String? value, {
|
||||
bool monospace = false,
|
||||
bool block = false,
|
||||
}) {
|
||||
final text = value?.trim() ?? '';
|
||||
if (text.isEmpty) return;
|
||||
rows.add((label: label, value: text, monospace: monospace, block: block));
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
|
||||
/// The run's stored duration from its own start and finish, never a live
|
||||
/// estimate and never a zero for an unfinished run.
|
||||
String? _duration(JsonMap run) {
|
||||
final pipelineId = _number(run['pipeline_id'])?.toInt() ?? 0;
|
||||
if (pipelineId > 0) {
|
||||
final version = _number(run['version'])?.toInt() ?? 0;
|
||||
add('Pipeline', 'id $pipelineId · v$version');
|
||||
} else {
|
||||
add('Pipeline', _text(run['name']));
|
||||
}
|
||||
add('Stage', _text(run['current_stage']));
|
||||
add('Workspace', _text(run['workspace']));
|
||||
add('Content hash', _text(run['content_hash']), monospace: true);
|
||||
add('Started', formatLocalTimestamp(_text(run['created_at'])));
|
||||
add('Finished', formatLocalTimestamp(_text(run['finished_at'])));
|
||||
final seconds = durationSeconds(
|
||||
_text(run['created_at']),
|
||||
_text(run['finished_at']),
|
||||
);
|
||||
return seconds == null ? null : formatDuration(seconds);
|
||||
if (seconds != null) add('Duration', formatDuration(seconds));
|
||||
final retryOf = _number(run['retry_of'])?.toInt() ?? 0;
|
||||
if (retryOf > 0) add('Retry of', 'run $retryOf');
|
||||
// A diagnostic is a recorded document: its own whitespace is preserved, but a
|
||||
// blank one is not a row.
|
||||
final diagnostic = '${run['diagnostic'] ?? ''}';
|
||||
if (diagnostic.trim().isNotEmpty) {
|
||||
rows.add((
|
||||
label: 'Diagnostic',
|
||||
value: diagnostic,
|
||||
monospace: false,
|
||||
block: true,
|
||||
));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/// The recorded verdict as the web pane spells it: the option above its
|
||||
/// reason, one part when only one was recorded, nothing when neither was.
|
||||
String? _verdict(JsonMap? step) {
|
||||
if (step == null) return null;
|
||||
final verdict = detailVisitVerdict(step);
|
||||
if (verdict == null) return null;
|
||||
final parts = [verdict.option, verdict.reason].whereType<String>();
|
||||
return parts.isEmpty ? null : parts.join('\n');
|
||||
/// The run's identity line: `run {id} · {n} recorded visits · {m} completed
|
||||
/// visits`, the same recorded/completed vocabulary the web summary and the
|
||||
/// server use.
|
||||
String detailSummaryIdentity(JsonMap run) {
|
||||
final recorded = detailRunSteps(run).length;
|
||||
final completedValue = _number(run['completed_steps'])?.toInt() ?? 0;
|
||||
final completed = completedValue < 0 ? 0 : completedValue;
|
||||
String visits(int count, String adjective) =>
|
||||
'$count $adjective ${count == 1 ? 'visit' : 'visits'}';
|
||||
return 'run ${run['id'] ?? ''} · ${visits(recorded, 'recorded')} · '
|
||||
'${visits(completed, 'completed')}';
|
||||
}
|
||||
|
||||
String? _text(dynamic value) {
|
||||
@@ -87,3 +87,6 @@ String? _text(dynamic value) {
|
||||
final text = '$value'.trim();
|
||||
return text.isEmpty ? null : text;
|
||||
}
|
||||
|
||||
num? _number(dynamic value) =>
|
||||
value is num ? value : num.tryParse('${value ?? ''}'.trim());
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
/// second, then the recorded Input, Output and Timeline.
|
||||
///
|
||||
/// The stable keys match the web client's `RUN_DETAIL_TABS`; the visible labels
|
||||
/// are the same words.
|
||||
/// are the same words. `renderedRunDetailTabs` decides which keys the strip
|
||||
/// draws, so Input and Output stay addressable without being tabs.
|
||||
enum RunDetailTab {
|
||||
summary('Summary'),
|
||||
graph('Graph'),
|
||||
|
||||
@@ -4,10 +4,16 @@ import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_summary_fields.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
|
||||
/// The Summary tab: the stored original prompt with its copy control, the
|
||||
/// run's recorded facts and the reported usage metrics. Neither the prompt nor
|
||||
/// a fact is replaced by a fallback value.
|
||||
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
|
||||
/// the stored original prompt with its copy control and the collapsible Input
|
||||
/// and Output sections.
|
||||
///
|
||||
/// The web run detail has no usage block, so no metrics are drawn here. A fact
|
||||
/// the server did not record is omitted rather than shown as an invented or
|
||||
/// `Unavailable` row; only the Input/Output empty sentences remain, and only
|
||||
/// when that section recorded nothing.
|
||||
Widget runDetailSummaryTab({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
@@ -16,88 +22,93 @@ Widget runDetailSummaryTab({
|
||||
required String? copyStatus,
|
||||
required VoidCallback onCopy,
|
||||
}) {
|
||||
final rows = detailSummaryRows(run);
|
||||
final identity = detailSummaryIdentity(run);
|
||||
final prompt = detailPrompt(run);
|
||||
final facts = detailSummaryFields(run);
|
||||
final metrics = detailUsageMetrics(run['usage']);
|
||||
if (cupertino) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return ListView(
|
||||
key: const Key('run-detail-tab-body-summary'),
|
||||
children: [
|
||||
if (prompt != null)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'Original prompt',
|
||||
style: theme.textTheme.navTitleTextStyle,
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: copying ? null : onCopy,
|
||||
child: const Text('Copy prompt'),
|
||||
),
|
||||
],
|
||||
),
|
||||
_CupertinoSelectableText(prompt),
|
||||
if (copyStatus != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Semantics(liveRegion: true, child: Text(copyStatus)),
|
||||
),
|
||||
],
|
||||
),
|
||||
_cupertinoIdentity(context, identity),
|
||||
if (rows.any((row) => !row.block))
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [
|
||||
for (final row in rows.where((row) => !row.block))
|
||||
_cupertinoRow(context, row),
|
||||
],
|
||||
),
|
||||
_cupertinoMetrics(metrics),
|
||||
_cupertinoFacts(facts),
|
||||
for (final row in rows.where((row) => row.block))
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [_cupertinoBlock(context, row)],
|
||||
),
|
||||
if (prompt != null)
|
||||
_cupertinoPrompt(
|
||||
context,
|
||||
prompt: prompt,
|
||||
copying: copying,
|
||||
copyStatus: copyStatus,
|
||||
onCopy: onCopy,
|
||||
),
|
||||
_cupertinoFieldSection(
|
||||
context,
|
||||
key: 'run-detail-summary-input',
|
||||
title: 'Input',
|
||||
value: run['input'],
|
||||
empty: visitEmptyInput,
|
||||
),
|
||||
_cupertinoFieldSection(
|
||||
context,
|
||||
key: 'run-detail-summary-output',
|
||||
title: 'Output',
|
||||
value: run['output'],
|
||||
empty: visitEmptyOutput,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return ListView(
|
||||
key: const Key('run-detail-tab-body-summary'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
if (prompt != null) ...[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Original prompt',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Copy prompt',
|
||||
onPressed: copying ? null : onCopy,
|
||||
icon: const Icon(Icons.copy),
|
||||
),
|
||||
],
|
||||
),
|
||||
SelectableText(prompt),
|
||||
if (copyStatus != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Semantics(liveRegion: true, child: Text(copyStatus)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Text(
|
||||
identity,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_materialMetrics(metrics),
|
||||
_materialFacts(facts),
|
||||
),
|
||||
),
|
||||
for (final row in rows)
|
||||
row.block ? _materialBlock(context, row) : _materialRow(context, row),
|
||||
if (prompt != null)
|
||||
_materialPrompt(
|
||||
context,
|
||||
prompt: prompt,
|
||||
copying: copying,
|
||||
copyStatus: copyStatus,
|
||||
onCopy: onCopy,
|
||||
),
|
||||
_materialFieldSection(
|
||||
context,
|
||||
key: 'run-detail-summary-input',
|
||||
title: 'Input',
|
||||
value: run['input'],
|
||||
empty: visitEmptyInput,
|
||||
),
|
||||
_materialFieldSection(
|
||||
context,
|
||||
key: 'run-detail-summary-output',
|
||||
title: 'Output',
|
||||
value: run['output'],
|
||||
empty: visitEmptyOutput,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// One recorded Input or Output field as its own tab.
|
||||
/// One recorded Input or Output field as its own tab, used by a visit pane.
|
||||
Widget runDetailFieldTab({
|
||||
required String tabKey,
|
||||
required dynamic value,
|
||||
@@ -127,64 +138,241 @@ Widget runDetailFieldTab({
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialFacts(List<DetailMetric> facts) => Column(
|
||||
children: [
|
||||
for (final fact in facts)
|
||||
ListTile(title: Text(fact.label), subtitle: Text(fact.value)),
|
||||
],
|
||||
);
|
||||
// --- Material --------------------------------------------------------------
|
||||
|
||||
Widget _cupertinoFacts(List<DetailMetric> facts) =>
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [
|
||||
for (final fact in facts)
|
||||
CupertinoListTile(
|
||||
title: Text(fact.label),
|
||||
subtitle: Text(fact.value),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _materialMetrics(List<DetailMetric> metrics) => ExpansionTile(
|
||||
title: const Text('Metrics'),
|
||||
children: [
|
||||
if (metrics.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('No reported usage.'),
|
||||
)
|
||||
else
|
||||
...metrics.map(
|
||||
(metric) =>
|
||||
ListTile(title: Text(metric.label), subtitle: Text(metric.value)),
|
||||
Widget _materialRow(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = Theme.of(context);
|
||||
final base = theme.textTheme.bodyMedium;
|
||||
return ListTile(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
title: Text(
|
||||
row.label,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
subtitle: SelectableText(
|
||||
row.value,
|
||||
style: row.monospace ? base?.copyWith(fontFamily: 'monospace') : base,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoMetrics(List<DetailMetric> metrics) =>
|
||||
CupertinoListSection.insetGrouped(
|
||||
Widget _materialBlock(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = Theme.of(context);
|
||||
return Padding(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CupertinoExpansionTile(
|
||||
title: const Text('Metrics'),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (metrics.isEmpty)
|
||||
const Text('No reported usage.')
|
||||
else
|
||||
for (final metric in metrics)
|
||||
CupertinoListTile(
|
||||
title: Text(metric.label),
|
||||
subtitle: Text(metric.value),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
row.label,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: SelectableText(
|
||||
row.value,
|
||||
style: theme.textTheme.bodySmall?.copyWith(fontFamily: 'monospace'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialFieldSection(
|
||||
BuildContext context, {
|
||||
required String key,
|
||||
required String title,
|
||||
required dynamic value,
|
||||
required String empty,
|
||||
}) {
|
||||
return ExpansionTile(
|
||||
key: ValueKey(key),
|
||||
title: Text(title),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.start,
|
||||
childrenPadding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
|
||||
children: [SelectableText(detailEmpty(value) ? empty : detailJson(value))],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialPrompt(
|
||||
BuildContext context, {
|
||||
required String prompt,
|
||||
required bool copying,
|
||||
required String? copyStatus,
|
||||
required VoidCallback onCopy,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
'Original prompt',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Copy prompt',
|
||||
onPressed: copying ? null : onCopy,
|
||||
icon: const Icon(Icons.copy),
|
||||
),
|
||||
],
|
||||
),
|
||||
SelectableText(prompt),
|
||||
if (copyStatus != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Semantics(liveRegion: true, child: Text(copyStatus)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- Cupertino -------------------------------------------------------------
|
||||
|
||||
Widget _cupertinoIdentity(BuildContext context, String identity) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 8),
|
||||
child: Text(
|
||||
identity,
|
||||
style: theme.textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoRow(BuildContext context, DetailSummaryRow row) {
|
||||
final style = CupertinoTheme.of(context).textTheme.textStyle;
|
||||
return CupertinoListTile(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
title: Text(row.label),
|
||||
subtitle: Text(
|
||||
row.value,
|
||||
style: row.monospace ? style.copyWith(fontFamily: 'monospace') : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoBlock(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Padding(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
row.label,
|
||||
style: theme.textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.tertiarySystemFill.resolveFrom(context),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
row.value,
|
||||
style: theme.textTheme.textStyle.copyWith(fontFamily: 'monospace'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoFieldSection(
|
||||
BuildContext context, {
|
||||
required String key,
|
||||
required String title,
|
||||
required dynamic value,
|
||||
required String empty,
|
||||
}) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
key: ValueKey(key),
|
||||
children: [
|
||||
CupertinoExpansionTile(
|
||||
title: Text(title),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: _CupertinoSelectableText(
|
||||
detailEmpty(value) ? empty : detailJson(value),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoPrompt(
|
||||
BuildContext context, {
|
||||
required String prompt,
|
||||
required bool copying,
|
||||
required String? copyStatus,
|
||||
required VoidCallback onCopy,
|
||||
}) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
Text('Original prompt', style: theme.textTheme.navTitleTextStyle),
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: copying ? null : onCopy,
|
||||
child: const Text('Copy prompt'),
|
||||
),
|
||||
],
|
||||
),
|
||||
_CupertinoSelectableText(prompt),
|
||||
if (copyStatus != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Semantics(liveRegion: true, child: Text(copyStatus)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _slug(String label) => label.toLowerCase().replaceAll(' ', '-');
|
||||
|
||||
/// A read-only Cupertino text control: plain, selectable text without a
|
||||
/// Material dependency, while keeping native selection and copy affordances.
|
||||
|
||||
@@ -5,9 +5,18 @@ import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'run_detail_tab.dart';
|
||||
|
||||
/// The tabs the strip renders, in the web's order: Summary first so it is the
|
||||
/// default, then the run Graph and the Timeline. Input and Output are
|
||||
/// collapsible Summary sections now, so their stable enum keys stay available
|
||||
/// for old routes but they are not separate tabs.
|
||||
const List<RunDetailTab> renderedRunDetailTabs = [
|
||||
RunDetailTab.summary,
|
||||
RunDetailTab.graph,
|
||||
RunDetailTab.timeline,
|
||||
];
|
||||
|
||||
/// The run detail's platform tab strip: a Material segmented button or a
|
||||
/// Cupertino segmented control, in the web's Summary/Graph/Input/Output/
|
||||
/// Timeline order.
|
||||
/// Cupertino segmented control, in the web's Summary/Graph/Timeline order.
|
||||
///
|
||||
/// The native control keeps every label at its intrinsic width: a narrow pane
|
||||
/// or scaled text scrolls the strip horizontally instead of squeezing or
|
||||
@@ -29,7 +38,7 @@ class RunDetailTabStrip extends StatefulWidget {
|
||||
|
||||
class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
||||
final Map<RunDetailTab, GlobalKey> _labels = {
|
||||
for (final tab in RunDetailTab.values) tab: GlobalKey(),
|
||||
for (final tab in renderedRunDetailTabs) tab: GlobalKey(),
|
||||
};
|
||||
|
||||
@override
|
||||
@@ -66,7 +75,7 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
||||
|
||||
Widget _materialControl() => SegmentedButton<RunDetailTab>(
|
||||
segments: [
|
||||
for (final tab in RunDetailTab.values)
|
||||
for (final tab in renderedRunDetailTabs)
|
||||
ButtonSegment(value: tab, label: _label(tab)),
|
||||
],
|
||||
selected: {widget.selected},
|
||||
@@ -78,7 +87,7 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
||||
groupValue: widget.selected,
|
||||
onValueChanged: widget.onSelected,
|
||||
children: {
|
||||
for (final tab in RunDetailTab.values)
|
||||
for (final tab in renderedRunDetailTabs)
|
||||
tab: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: _label(tab),
|
||||
|
||||
Reference in New Issue
Block a user