Merge branch 'run/artifacts-collapsed' into integrate/bars-artifacts

This commit is contained in:
2026-10-31 00:29:54 +00:00
8 changed files with 79 additions and 2 deletions
@@ -53,6 +53,7 @@ class ArtifactGalleryPage extends StatefulWidget {
this.markdownBuilder = chatMarkdownText,
this.fileBridge = const ArtifactFileBridge(),
this.embedded = false,
this.initiallyCollapsed = false,
});
final List<JsonMap> steps;
@@ -71,6 +72,10 @@ class ArtifactGalleryPage extends StatefulWidget {
/// page bar, since the detail already names the run.
final bool embedded;
/// Run artifact views opt into collapsed groups; standalone gallery pages
/// preserve their established open layout.
final bool initiallyCollapsed;
@override
State<ArtifactGalleryPage> createState() => _ArtifactGalleryPageState();
}
@@ -386,6 +391,7 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
onSelected: _select,
configuredEndpoint: widget.configuredEndpoint,
fetch: widget.fetch,
initiallyCollapsed: widget.initiallyCollapsed,
);
if (widget.embedded) return body;
if (usesCupertinoHost(context)) {
@@ -40,6 +40,7 @@ class ArtifactVisitList extends StatefulWidget {
this.onSelected,
this.configuredEndpoint = '',
this.fetch = fetchArtifact,
this.initiallyCollapsed = true,
});
final Widget? header;
@@ -54,6 +55,11 @@ class ArtifactVisitList extends StatefulWidget {
final String configuredEndpoint;
final ArtifactFetch fetch;
/// Whether the artifact sections begin closed. Run artifact galleries use
/// the default; this remains configurable for composed hosts that explicitly
/// want to restore their own open state.
final bool initiallyCollapsed;
/// The layout last chosen, kept for the app's lifetime.
static ArtifactGalleryMode lastMode = ArtifactGalleryMode.grid;
@@ -64,8 +70,24 @@ class ArtifactVisitList extends StatefulWidget {
class _ArtifactVisitListState extends State<ArtifactVisitList> {
ArtifactGalleryMode _mode = ArtifactVisitList.lastMode;
/// Sections the operator closed, by their key.
final Set<String> _closed = {};
/// Sections the operator closed, by their key. Artifact groups start closed
/// so a run with many visits does not open every file list at once.
late final Set<String> _closed;
@override
void initState() {
super.initState();
_closed = widget.initiallyCollapsed
? {
for (final group in widget.groups)
if (group.artifacts.isNotEmpty)
'${group.stageKey}\u0000${group.visit}\u0000artifacts',
for (final group in widget.groups)
if (group.documents.isNotEmpty)
'${group.stageKey}\u0000${group.visit}\u0000documents',
}
: <String>{};
}
void _toggle(String key) => setState(() {
if (!_closed.remove(key)) _closed.add(key);
@@ -451,6 +451,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
steps: runDetailArtifactSteps(widget.run),
executing: runDetailExecuting(widget.run),
configuredEndpoint: widget.configuredEndpoint,
initiallyCollapsed: true,
embedded: true,
);
case RunDetailTab.changes:
@@ -39,6 +39,7 @@ class RunVisitArtifacts extends StatelessWidget {
steps: runSteps.isEmpty ? <JsonMap>[step] : runSteps,
focusIndex: runSteps.isEmpty ? 0 : visitIndex,
configuredEndpoint: configuredEndpoint,
initiallyCollapsed: true,
embedded: true,
),
);