💄 Optimize thoughts

This commit is contained in:
2025-11-15 21:15:41 +08:00
parent 5e9341a19c
commit a9c8f49797
3 changed files with 75 additions and 76 deletions

View File

@@ -608,7 +608,9 @@ class FileListView extends HookConsumerWidget {
previewWidget = getFileIcon(file, size: 48);
break;
case 'text':
previewWidget = FutureBuilder<String>(
previewWidget = Container(
color: Theme.of(context).colorScheme.surfaceContainer,
child: FutureBuilder<String>(
future: ref
.read(apiClientProvider)
.get(uri)
@@ -617,10 +619,11 @@ class FileListView extends HookConsumerWidget {
(context, snapshot) =>
snapshot.hasData
? SingleChildScrollView(
padding: EdgeInsets.all(24),
child: Text(
snapshot.data!,
style: const TextStyle(
fontSize: 8,
fontSize: 9,
fontFamily: 'monospace',
),
maxLines: 20,
@@ -628,6 +631,7 @@ class FileListView extends HookConsumerWidget {
),
)
: const Center(child: CircularProgressIndicator()),
),
);
break;
case 'application' when file.mimeType == 'application/pdf':

View File

@@ -32,15 +32,8 @@ class ThoughtContent extends StatelessWidget {
// Streaming text with spinner
if (streamingText.isNotEmpty) {
final isStreamingError = streamingText.startsWith('Error:');
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Container(
padding:
isStreamingError
? const EdgeInsets.all(8)
: EdgeInsets.zero,
return Container(
padding: isStreamingError ? const EdgeInsets.all(8) : EdgeInsets.zero,
decoration:
isStreamingError
? BoxDecoration(
@@ -57,9 +50,7 @@ class ThoughtContent extends StatelessWidget {
extraBlockSyntaxList: [ProposalBlockSyntax()],
textStyle: Theme.of(context).textTheme.bodyMedium!.copyWith(
color:
isStreamingError
? Theme.of(context).colorScheme.error
: null,
isStreamingError ? Theme.of(context).colorScheme.error : null,
),
extraGenerators: [
ProposalGenerator(
@@ -71,20 +62,6 @@ class ThoughtContent extends StatelessWidget {
),
],
),
),
),
const SizedBox(width: 8),
SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).colorScheme.primary,
),
),
),
],
);
}
return const SizedBox.shrink();

View File

@@ -719,11 +719,28 @@ class ThoughtItem extends StatelessWidget {
spacing: 8,
children: [
// Main content
ThoughtContent(
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Flexible(
child: ThoughtContent(
isStreaming: isStreaming,
streamingText: streamingText,
thought: thought,
),
),
if (isStreaming && isAI)
SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2.5,
padding: const EdgeInsets.all(4),
),
),
],
),
// Reasoning chunks (streaming only)
if (reasoningChunks.isNotEmpty)
@@ -743,7 +760,10 @@ class ThoughtItem extends StatelessWidget {
),
// Token count and model name (for completed AI thoughts only)
if (!isStreaming && isAI && thought != null)
if (!isStreaming &&
isAI &&
thought != null &&
!thought!.id.startsWith('error-'))
TokenInfo(thought: thought!),
// Proposals (for completed AI thoughts only)
@@ -752,8 +772,6 @@ class ThoughtItem extends StatelessWidget {
proposals: proposals,
onProposalAction: _handleProposalAction,
),
if (isStreaming && isAI) LinearProgressIndicator(),
],
),
),