feat(app): on a phone an open pipeline, run or chat is its own page over the tabs

This commit is contained in:
2026-10-23 22:58:49 +01:00
parent 700ba6f820
commit 7cbfbbbb61
8 changed files with 418 additions and 76 deletions
+52 -32
View File
@@ -1,3 +1,5 @@
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import 'dart:async';
import 'package:flutter/material.dart';
@@ -163,49 +165,67 @@ class _ChatScreenState extends State<ChatScreen> {
}
}
/// The open chat is its own page over the tabs on a phone.
final DetailPageHost _page = DetailPageHost();
@override
void dispose() {
_page.dispose();
_sessions.dispose();
super.dispose();
}
Widget _thread(String selected, VoidCallback onBack) {
final row = _rowFor(selected);
final start = _startNotice;
return ChatThreadView(
key: ValueKey<String>('chat-session-$selected'),
gateway: widget.gateway,
sessionId: selected,
title: '${row?['title'] ?? ''}'.trim(),
session: row,
syncToken: widget.syncToken,
scrollPositions: _scrollPositions,
initialNotice: start != null && start.id == selected
? start.notice
: null,
onBack: onBack,
onModelChanged: (applied) => _modelChanged(selected, applied),
onCreatedSession: _openCreated,
onSessionRenamed: (title) => _renamed(selected, title),
onSessionClosed: _closed,
);
}
@override
Widget build(BuildContext context) {
final selected = _selected;
final row = selected == null ? null : _rowFor(selected);
final start = _startNotice;
// On a phone an open chat is its own page over the tabs; a wide window
// keeps it in the tab, beside the destination rail.
final narrow = MediaQuery.sizeOf(context).width < kDetailPageMaxWidth;
_page.sync(
context,
selected: selected != null && narrow,
destination: AppDestination.chat,
onClosed: _back,
builder: (context) => selected == null
? const SizedBox.shrink()
: _thread(selected, () => Navigator.of(context).maybePop()),
);
final list = ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: narrow ? null : selected,
);
if (narrow) return list;
return Stack(
children: [
Offstage(
offstage: selected != null,
child: ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
),
),
if (selected != null)
ChatThreadView(
key: ValueKey<String>('chat-session-$selected'),
gateway: widget.gateway,
sessionId: selected,
title: '${row?['title'] ?? ''}'.trim(),
session: row,
syncToken: widget.syncToken,
scrollPositions: _scrollPositions,
initialNotice: start != null && start.id == selected
? start.notice
: null,
onBack: _back,
onModelChanged: (applied) => _modelChanged(selected, applied),
onCreatedSession: _openCreated,
onSessionRenamed: (title) => _renamed(selected, title),
onSessionClosed: _closed,
),
Offstage(offstage: selected != null, child: list),
if (selected != null) _thread(selected, _back),
],
);
}
+31 -15
View File
@@ -1,3 +1,5 @@
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -78,6 +80,9 @@ class PipelinesScreen extends StatefulWidget {
class _PipelinesScreenState extends State<PipelinesScreen> {
late PipelinesController _controller;
/// The open pipeline is its own page over the tabs on a phone.
final DetailPageHost _page = DetailPageHost();
/// Counts route stage requests so a re-read detail cannot replay an old one.
int _stageRequest = 0;
@@ -132,6 +137,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
@override
void dispose() {
_page.dispose();
_controller.dispose();
super.dispose();
}
@@ -180,21 +186,31 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
final body = LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= kPipelinesWideBreakpoint;
if (!wide) {
return _controller.hasSelection
? PipelineDetailPanel(
controller: _controller,
gateway: widget.gateway,
showBack: true,
onRunStarted: widget.onRunStarted,
onViewPipelineRuns: widget.onViewPipelineRuns,
stageKey: stageKey,
stagePipelineId: widget.initialPipelineId,
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
)
: PipelineListPanel(controller: _controller);
}
// On a phone an open pipeline is its own page over the tabs.
_page.sync(
context,
selected: _controller.hasSelection && !wide,
destination: AppDestination.pipelines,
onClosed: _controller.clearSelection,
builder: (context) => AnimatedBuilder(
animation: _controller,
builder: (context, _) => ShellBar(
title: _controller.detail?.displayName,
child: PipelineDetailPanel(
controller: _controller,
gateway: widget.gateway,
showBack: false,
onRunStarted: widget.onRunStarted,
onViewPipelineRuns: widget.onViewPipelineRuns,
stageKey: stageKey,
stagePipelineId: widget.initialPipelineId,
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
),
),
),
);
if (!wide) return PipelineListPanel(controller: _controller);
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
+42 -26
View File
@@ -3,6 +3,8 @@ import 'dart:async';
import 'package:flutter/widgets.dart';
import '../../core/api_gateway.dart';
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../ui/adaptive/host.dart';
import '../attention/notify/notification_controller.dart';
import '../attention/runtime/attention_controller.dart';
@@ -98,6 +100,9 @@ class _RunsScreenState extends State<RunsScreen> {
/// named run consumes it, whether or not that run is waiting.
bool _decideConsumed = false;
/// The open run is its own page over the tabs.
final DetailPageHost _page = DetailPageHost();
@override
void initState() {
super.initState();
@@ -224,41 +229,52 @@ class _RunsScreenState extends State<RunsScreen> {
controller.removeListener(_selectionChanged);
controller.removeListener(_pipelineFilterChanged);
controller.removeListener(_detailChanged);
_page.dispose();
controller.dispose();
super.dispose();
}
Widget _detail(VoidCallback onBack) => RunDetailView(
controller: controller,
gateway: widget.gateway,
onBack: onBack,
onRunOpened: _select,
onOpenPipeline: widget.onOpenPipeline,
initialStageKey: widget.initialStageKey,
initialVisit: widget.initialVisit,
);
@override
Widget build(BuildContext context) {
final selected = controller.selectedRunId != null;
// On a phone an open run is its own page over the tabs; a wide window
// keeps it in the tab, beside the destination rail.
final narrow = MediaQuery.sizeOf(context).width < kDetailPageMaxWidth;
_page.sync(
context,
selected: selected && narrow,
destination: AppDestination.runs,
onClosed: _back,
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
);
final list = AnimatedBuilder(
animation: controller,
builder: (context, _) => RunsList(
active: !selected,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
),
);
if (narrow) return list;
return Stack(
children: [
AnimatedBuilder(
animation: controller,
builder: (context, _) => Offstage(
offstage: selected,
child: RunsList(
active: !selected,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
),
),
),
if (selected)
RunDetailView(
controller: controller,
gateway: widget.gateway,
onBack: _back,
onRunOpened: _select,
onOpenPipeline: widget.onOpenPipeline,
initialStageKey: widget.initialStageKey,
initialVisit: widget.initialVisit,
),
Offstage(offstage: selected, child: list),
if (selected) _detail(_back),
],
);
}