refactor: cleanup

This commit is contained in:
cogwheel0
2025-09-02 00:04:21 +05:30
parent 1b65743b06
commit 66935d1b0f
8 changed files with 29 additions and 39 deletions

View File

@@ -198,10 +198,10 @@ class _AssistantMessageWidgetState extends ConsumerState<AssistantMessageWidget>
String _pretty(dynamic v, {int max = 1200}) {
try {
final pretty = const JsonEncoder.withIndent(' ').convert(v);
return pretty.length > max ? pretty.substring(0, max) + '\n' : pretty;
return pretty.length > max ? '${pretty.substring(0, max)}\n' : pretty;
} catch (_) {
final s = v?.toString() ?? '';
return s.length > max ? s.substring(0, max) + '' : s;
return s.length > max ? '${s.substring(0, max)}' : s;
}
}

View File

@@ -1164,11 +1164,9 @@ class _ModernChatInputState extends ConsumerState<ModernChatInput>
_textSub?.cancel();
_textSub = stream.listen(
(text) async {
final updated =
(_baseTextAtStart.isEmpty
? ''
: (_baseTextAtStart.trimRight() + ' ')) +
text;
final updated = _baseTextAtStart.isEmpty
? text
: '${_baseTextAtStart.trimRight()} $text';
_controller.value = TextEditingValue(
text: updated,
selection: TextSelection.collapsed(offset: updated.length),