feat(chat): Add loading state for conversation title and model selector

This commit is contained in:
cogwheel0
2025-12-15 20:31:40 +05:30
parent 8fa69fc165
commit 9ec7fdadde

View File

@@ -1502,11 +1502,14 @@ class _ChatPageState extends ConsumerState<ChatPage> {
trimmedConversationTitle.isNotEmpty)
? trimmedConversationTitle
: null;
// Watch loading state for app bar skeleton
final isLoadingConversation = ref.watch(isLoadingConversationProvider);
final formattedModelName = selectedModel != null
? _formatModelDisplayName(selectedModel.name)
: null;
final modelLabel = formattedModelName ?? l10n.chooseModel;
final hasConversationTitle = displayConversationTitle != null;
final hasConversationTitle =
displayConversationTitle != null || isLoadingConversation;
final TextStyle modelTextStyle = hasConversationTitle
? AppTypography.small.copyWith(
color: context.conduitTheme.textSecondary,
@@ -1746,8 +1749,27 @@ class _ChatPageState extends ConsumerState<ChatPage> {
: LayoutBuilder(
builder: (context, constraints) {
// Build title pill (tappable for context menu)
// Show skeleton when loading, actual title otherwise
Widget? titlePill;
if (displayConversationTitle != null) {
if (isLoadingConversation) {
// Show skeleton pill while loading conversation
titlePill = _buildAppBarPill(
context: context,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: Spacing.md,
vertical: Spacing.xs,
),
child: ConduitLoading.skeleton(
width: 120,
height: 18,
borderRadius: BorderRadius.circular(
AppBorderRadius.sm,
),
),
),
);
} else if (displayConversationTitle != null) {
titlePill = GestureDetector(
onTap: () {
final conversation = ref.read(
@@ -1795,7 +1817,28 @@ class _ChatPageState extends ConsumerState<ChatPage> {
}
// Build model selector pill
final modelPill = GestureDetector(
// Show skeleton when loading, actual model selector otherwise
final Widget modelPill;
if (isLoadingConversation) {
// Show skeleton pill while loading conversation
modelPill = _buildAppBarPill(
context: context,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: Spacing.sm,
vertical: Spacing.xs,
),
child: ConduitLoading.skeleton(
width: 80,
height: 14,
borderRadius: BorderRadius.circular(
AppBorderRadius.sm,
),
),
),
);
} else {
modelPill = GestureDetector(
onTap: () async {
final modelsAsync = ref.read(modelsProvider);
@@ -1875,15 +1918,40 @@ class _ChatPageState extends ConsumerState<ChatPage> {
),
),
);
}
return Column(
mainAxisSize: MainAxisSize.min,
children: [
if (titlePill != null) ...[
titlePill,
AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOut,
switchOutCurve: Curves.easeIn,
child: KeyedSubtree(
key: ValueKey(
isLoadingConversation
? 'loading'
: 'title-$displayConversationTitle',
),
child: titlePill,
),
),
const SizedBox(height: Spacing.xs),
],
modelPill,
AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOut,
switchOutCurve: Curves.easeIn,
child: KeyedSubtree(
key: ValueKey(
isLoadingConversation
? 'model-loading'
: 'model-$modelLabel',
),
child: modelPill,
),
),
if (isReviewerMode)
Padding(
padding: const EdgeInsets.only(