feat(app): section titles read as dividers; one Rendered/Raw switch per definition; schedule rows with labelled facts and a status pill

This commit is contained in:
2026-10-23 22:09:46 +01:00
parent c467872ee3
commit b44cecf35c
10 changed files with 355 additions and 77 deletions
@@ -1,3 +1,4 @@
import '../../../../ui/layout/section_heading.dart';
import 'package:flutter/cupertino.dart';
import '../../../../core/api_gateway.dart';
@@ -61,10 +62,14 @@ class CupertinoSessionList extends StatelessWidget {
return [
for (final group in groups)
CupertinoListSection.insetGrouped(
header: Text(
groups.length > 1
? '${section.title} · ${group.directory.isEmpty ? 'No directory' : group.directory}'
: section.title,
// Styled as a section divider, not as another chat row.
header: Builder(
builder: (context) => Text(
groups.length > 1
? '${section.title} · ${group.directory.isEmpty ? 'No directory' : group.directory}'
: section.title,
style: SectionHeadingStyle.of(context).title,
),
),
children: [for (final session in group.sessions) ..._row(session)],
),
@@ -1,3 +1,4 @@
import '../../../../ui/layout/section_heading.dart';
import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
@@ -44,7 +45,7 @@ class MaterialSessionList extends StatelessWidget {
Widget build(BuildContext context) {
return ListView(
children: [
for (final section in sections) _section(section),
for (final section in sections) _section(context, section),
if (emptyMessage != null)
ListTile(
title: Text(emptyMessage!),
@@ -59,10 +60,16 @@ class MaterialSessionList extends StatelessWidget {
);
}
Widget _section(ChatSessionSection section) {
Widget _section(BuildContext context, ChatSessionSection section) {
final groups = groupChatSessions(section.sessions);
final heading = SectionHeadingStyle.of(context);
return ExpansionTile(
title: Text(section.title),
// Styled as a section divider, not as another chat row.
title: Text(section.title, style: heading.title),
backgroundColor: heading.background.withValues(alpha: 0.35),
collapsedBackgroundColor: heading.background,
shape: Border(left: BorderSide(color: heading.accent, width: 3)),
collapsedShape: Border(left: BorderSide(color: heading.accent, width: 3)),
initiallyExpanded: true,
children: [
for (final group in groups) ...[
@@ -72,6 +79,7 @@ class MaterialSessionList extends StatelessWidget {
leading: const Icon(Icons.folder_outlined),
title: Text(
group.directory.isEmpty ? 'No directory' : group.directory,
style: heading.title.copyWith(fontWeight: FontWeight.w600),
),
),
// Material's native list separator between rows in a group, the
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/text/markdown_source_view.dart';
import '../../chat/ui/transcript/chat_markdown_view.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/graph_protocol.dart';
@@ -32,7 +33,7 @@ const String rawStageDefinitionTitle = 'Raw stage definition';
/// fetched and no run visit is read, so the pane cannot imply that the stage
/// executed. Unknown stage declarations get an explicit missing state; every
/// declared stage also keeps its exact JSON below the structured fields.
class StageDefinitionView extends StatelessWidget {
class StageDefinitionView extends StatefulWidget {
const StageDefinitionView({
super.key,
required this.graph,
@@ -48,11 +49,21 @@ class StageDefinitionView extends StatelessWidget {
final String pipelineName;
final int version;
@override
State<StageDefinitionView> createState() => _StageDefinitionViewState();
}
class _StageDefinitionViewState extends State<StageDefinitionView> {
// One switch for every authored text block; raw is the exact text.
bool _raw = true;
String get _identity =>
'${pipelineName.isEmpty ? 'Pipeline' : pipelineName} \u00b7 v$version';
'${widget.pipelineName.isEmpty ? 'Pipeline' : widget.pipelineName} \u00b7 v${widget.version}';
@override
Widget build(BuildContext context) {
final graph = widget.graph;
final stageKey = widget.stageKey;
final style = _StageDefinitionStyle.of(context);
final stage = stageDefinitionFor(graph, stageKey);
final terminal = isTerminalTarget(stageKey);
@@ -67,6 +78,13 @@ class StageDefinitionView extends StatelessWidget {
children: [
Text(_identity, style: style.muted),
const SizedBox(height: 16),
if (fields.any((field) => field.block)) ...[
MarkdownModeSwitch(
raw: _raw,
onChanged: (raw) => setState(() => _raw = raw),
),
const SizedBox(height: 16),
],
if (stage == null && !terminal)
Text(unknownStageDefinition, style: style.value)
else ...[
@@ -75,7 +93,7 @@ class StageDefinitionView extends StatelessWidget {
const SizedBox(height: 16),
],
for (final field in fields)
_StageDefinitionFieldView(field: field, style: style),
_StageDefinitionFieldView(field: field, style: style, raw: _raw),
if (terminal && fields.isEmpty)
Text(noStageDefinitionDetails, style: style.muted),
if (stage != null) ...[
@@ -140,10 +158,15 @@ Future<void> openStageDefinition(
/// One labelled field: a compact row for scalars, a selectable block when the
/// value is multi-line authored text.
class _StageDefinitionFieldView extends StatelessWidget {
const _StageDefinitionFieldView({required this.field, required this.style});
const _StageDefinitionFieldView({
required this.field,
required this.style,
required this.raw,
});
final StageDefinitionField field;
final _StageDefinitionStyle style;
final bool raw;
@override
Widget build(BuildContext context) {
@@ -155,14 +178,10 @@ class _StageDefinitionFieldView extends StatelessWidget {
Text(field.label, style: style.label),
const SizedBox(height: 4),
// An authored text block (a prompt) is markdown: rendered or raw.
if (field.block)
MarkdownSourceView(
text: field.value,
raw: _SelectableDefinitionText(
value: field.value,
style: style.value,
),
)
if (field.block && raw)
_SelectableDefinitionText(value: field.value, style: style.value)
else if (field.block)
ChatMarkdownView(text: field.value)
else
Text(field.value, style: style.value),
],
@@ -1,5 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../ui/adaptive/host.dart';
import '../../domain/saved_schedule.dart';
import '../list/schedule_list_format.dart';
import 'schedule_pipeline_styles.dart';
@@ -28,46 +31,59 @@ class SchedulePipelineRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final id = schedule.id;
final body = schedulePipelineBodyStyle(context);
final title = body?.copyWith(fontWeight: FontWeight.w700);
return Padding(
key: scheduleRowKey(id),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Semantics(
container: true,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// The name, bold, with its state as a coloured pill.
Row(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(
scheduleDisplayName(schedule),
style: schedulePipelineBodyStyle(context),
),
child: Text(scheduleDisplayName(schedule), style: title),
),
const SizedBox(width: 8),
Text(
scheduleStatusLabel(schedule),
style: schedulePipelineStatusStyle(context, schedule.enabled),
_StatusPill(enabled: schedule.enabled),
],
),
const SizedBox(height: 8),
// Labelled facts several to a line: when, which version, next.
Wrap(
spacing: 16,
runSpacing: 6,
children: [
_Fact(
icon: Icons.schedule,
cupertinoIcon: CupertinoIcons.clock,
label: 'When',
value: scheduleRuleSummary(schedule),
),
_Fact(
icon: Icons.push_pin_outlined,
cupertinoIcon: CupertinoIcons.pin,
label: 'Version',
value: schedulePinnedVersionValue(schedule),
),
_Fact(
icon: Icons.event_outlined,
cupertinoIcon: CupertinoIcons.calendar,
label: 'Next',
value: scheduleNextDueValue(schedule),
),
],
),
const SizedBox(height: 4),
Text(
'Pinned ${schedulePinnedVersionValue(schedule)} · '
'${scheduleRuleSummary(schedule)}',
style: schedulePipelineMutedStyle(context),
),
if (schedule.prompt.isNotEmpty) ...[
const SizedBox(height: 4),
Text(schedule.prompt, style: schedulePipelineBodyStyle(context)),
const SizedBox(height: 8),
// The prompt it sends, as a quote under the facts.
_Quote(text: schedule.prompt, style: body),
],
const SizedBox(height: 4),
Text(
'$scheduleNextPrefix${scheduleNextDueValue(schedule)}',
style: schedulePipelineMutedStyle(context),
),
const SizedBox(height: 4),
Wrap(
spacing: 8,
runSpacing: 4,
@@ -112,3 +128,98 @@ class SchedulePipelineRow extends StatelessWidget {
);
}
}
/// Enabled (green) or Paused (grey).
class _StatusPill extends StatelessWidget {
const _StatusPill({required this.enabled});
final bool enabled;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final color = enabled
? (cupertino
? CupertinoColors.systemGreen.resolveFrom(context)
: Colors.green.shade700)
: (cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant);
return DecoratedBox(
decoration: ShapeDecoration(
color: color.withValues(alpha: 0.14),
shape: const StadiumBorder(),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: Text(
enabled ? 'Enabled' : 'Paused',
style: TextStyle(
color: color,
fontWeight: FontWeight.w700,
fontSize: 12,
),
),
),
);
}
}
/// One labelled fact: an icon, a bold label and its value.
class _Fact extends StatelessWidget {
const _Fact({
required this.icon,
required this.cupertinoIcon,
required this.label,
required this.value,
});
final IconData icon;
final IconData cupertinoIcon;
final String label;
final String value;
@override
Widget build(BuildContext context) {
final muted = schedulePipelineMutedStyle(context);
final cupertino = usesCupertinoHost(context);
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(cupertino ? cupertinoIcon : icon, size: 16, color: muted?.color),
const SizedBox(width: 4),
Text('$label ', style: muted?.copyWith(fontWeight: FontWeight.w700)),
Flexible(child: Text(value, style: muted)),
],
);
}
}
/// The schedule's prompt as a quote: a side bar and up to three lines.
class _Quote extends StatelessWidget {
const _Quote({required this.text, required this.style});
final String text;
final TextStyle? style;
@override
Widget build(BuildContext context) {
final line = usesCupertinoHost(context)
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(left: BorderSide(color: line, width: 3)),
),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 10),
child: Text(
text,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: style,
),
),
);
}
}