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

View File

@@ -32,15 +32,8 @@ class ThoughtContent extends StatelessWidget {
// Streaming text with spinner // Streaming text with spinner
if (streamingText.isNotEmpty) { if (streamingText.isNotEmpty) {
final isStreamingError = streamingText.startsWith('Error:'); final isStreamingError = streamingText.startsWith('Error:');
return Row( return Container(
crossAxisAlignment: CrossAxisAlignment.start, padding: isStreamingError ? const EdgeInsets.all(8) : EdgeInsets.zero,
children: [
Expanded(
child: Container(
padding:
isStreamingError
? const EdgeInsets.all(8)
: EdgeInsets.zero,
decoration: decoration:
isStreamingError isStreamingError
? BoxDecoration( ? BoxDecoration(
@@ -57,9 +50,7 @@ class ThoughtContent extends StatelessWidget {
extraBlockSyntaxList: [ProposalBlockSyntax()], extraBlockSyntaxList: [ProposalBlockSyntax()],
textStyle: Theme.of(context).textTheme.bodyMedium!.copyWith( textStyle: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: color:
isStreamingError isStreamingError ? Theme.of(context).colorScheme.error : null,
? Theme.of(context).colorScheme.error
: null,
), ),
extraGenerators: [ extraGenerators: [
ProposalGenerator( 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(); return const SizedBox.shrink();

View File

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