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