feat(chat): Add loading state for conversation title and model selector
This commit is contained in:
@@ -1502,11 +1502,14 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
trimmedConversationTitle.isNotEmpty)
|
trimmedConversationTitle.isNotEmpty)
|
||||||
? trimmedConversationTitle
|
? trimmedConversationTitle
|
||||||
: null;
|
: null;
|
||||||
|
// Watch loading state for app bar skeleton
|
||||||
|
final isLoadingConversation = ref.watch(isLoadingConversationProvider);
|
||||||
final formattedModelName = selectedModel != null
|
final formattedModelName = selectedModel != null
|
||||||
? _formatModelDisplayName(selectedModel.name)
|
? _formatModelDisplayName(selectedModel.name)
|
||||||
: null;
|
: null;
|
||||||
final modelLabel = formattedModelName ?? l10n.chooseModel;
|
final modelLabel = formattedModelName ?? l10n.chooseModel;
|
||||||
final hasConversationTitle = displayConversationTitle != null;
|
final hasConversationTitle =
|
||||||
|
displayConversationTitle != null || isLoadingConversation;
|
||||||
final TextStyle modelTextStyle = hasConversationTitle
|
final TextStyle modelTextStyle = hasConversationTitle
|
||||||
? AppTypography.small.copyWith(
|
? AppTypography.small.copyWith(
|
||||||
color: context.conduitTheme.textSecondary,
|
color: context.conduitTheme.textSecondary,
|
||||||
@@ -1746,8 +1749,27 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
: LayoutBuilder(
|
: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
// Build title pill (tappable for context menu)
|
// Build title pill (tappable for context menu)
|
||||||
|
// Show skeleton when loading, actual title otherwise
|
||||||
Widget? titlePill;
|
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(
|
titlePill = GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final conversation = ref.read(
|
final conversation = ref.read(
|
||||||
@@ -1795,7 +1817,28 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build model selector pill
|
// 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 {
|
onTap: () async {
|
||||||
final modelsAsync = ref.read(modelsProvider);
|
final modelsAsync = ref.read(modelsProvider);
|
||||||
|
|
||||||
@@ -1875,15 +1918,40 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (titlePill != null) ...[
|
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),
|
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)
|
if (isReviewerMode)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
|
|||||||
Reference in New Issue
Block a user