Merge branch 'ws-files-viewer'
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../data/directory_listing.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
@@ -68,38 +70,50 @@ class _FilesPanelState extends State<FilesPanel> {
|
||||
if (controller.missingDirectory) {
|
||||
return const _FilesMessage('This chat has no working directory.');
|
||||
}
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
children: [
|
||||
FilesHeader(controller: controller, filter: _filter),
|
||||
if (controller.error != null)
|
||||
ChatErrorNotice(
|
||||
message: controller.error!,
|
||||
onRetry: controller.retry,
|
||||
),
|
||||
if (controller.loading && listing == null)
|
||||
const Expanded(child: ChatLoadingIndicator())
|
||||
else if (listing != null && entries.isEmpty && !controller.loading)
|
||||
Expanded(
|
||||
child: _FilesMessage(
|
||||
controller.filter.isEmpty
|
||||
? 'This folder is empty.'
|
||||
: 'No files match your filter.',
|
||||
),
|
||||
return Theme(
|
||||
data: usesCupertinoHost(context)
|
||||
? ThemeData(
|
||||
brightness: CupertinoTheme.brightnessOf(context),
|
||||
colorSchemeSeed: CupertinoTheme.of(context).primaryColor,
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: controller.view == FilesViewMode.grid
|
||||
? _grid(entries)
|
||||
: _list(entries),
|
||||
),
|
||||
if (listing?.truncated == true)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text('Some entries are not shown.'),
|
||||
),
|
||||
],
|
||||
: Theme.of(context),
|
||||
child: Builder(
|
||||
builder: (context) => Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
children: [
|
||||
FilesHeader(controller: controller, filter: _filter),
|
||||
if (controller.error != null)
|
||||
ChatErrorNotice(
|
||||
message: controller.error!,
|
||||
onRetry: controller.retry,
|
||||
),
|
||||
if (controller.loading && listing == null)
|
||||
const Expanded(child: ChatLoadingIndicator())
|
||||
else if (listing != null &&
|
||||
entries.isEmpty &&
|
||||
!controller.loading)
|
||||
Expanded(
|
||||
child: _FilesMessage(
|
||||
controller.filter.isEmpty
|
||||
? 'This folder is empty.'
|
||||
: 'No files match your filter.',
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: controller.view == FilesViewMode.grid
|
||||
? _grid(entries)
|
||||
: _list(entries),
|
||||
),
|
||||
if (listing?.truncated == true)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text('Some entries are not shown.'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ ArtifactPreviewFormat filePreviewFormat(String contentType, String name) {
|
||||
lower.endsWith('.htm')) {
|
||||
return ArtifactPreviewFormat.html;
|
||||
}
|
||||
if (mime == 'text/plain' &&
|
||||
!lower.endsWith('.md') &&
|
||||
!lower.endsWith('.markdown')) {
|
||||
return ArtifactPreviewFormat.text;
|
||||
}
|
||||
return artifactPreviewFormat(contentType, name);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import '../../artifacts/ui/artifact_external_open.dart';
|
||||
import '../../artifacts/ui/artifact_viewer_fetch.dart';
|
||||
import '../../artifacts/ui/artifact_viewer_page.dart';
|
||||
import '../data/directory_listing.dart';
|
||||
import '../ui/transcript/chat_markdown_view.dart';
|
||||
import 'files_download.dart';
|
||||
import 'files_details.dart';
|
||||
import 'files_preview.dart';
|
||||
@@ -79,6 +80,7 @@ class FilesViewer {
|
||||
configuredEndpoint: endpoint,
|
||||
downloadUrl: urls.download.toString(),
|
||||
previewFormat: filePreviewFormat,
|
||||
markdownBuilder: (context, text) => ChatMarkdownView(text: text),
|
||||
fetch: fetch,
|
||||
openExternal: openExternal,
|
||||
fileBridge: bridge,
|
||||
|
||||
@@ -210,10 +210,15 @@ void main() {
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: FilesPanel(controller: controller)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
Theme.of(tester.element(find.byType(ListTile).first)).brightness,
|
||||
Brightness.dark,
|
||||
);
|
||||
await tester.tap(find.text('archive.zip'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Download'), findsOneWidget);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
2026-11-07T00:00:00Z INFO release build complete
|
||||
Reference in New Issue
Block a user