Skip to content

Commit a2303d3

Browse files
authored
chore: hide formats when using specific ai writer commands (#7648)
* chore: hide formats for specific ai writer features * chore: use black color for selected model name
1 parent c87d9ab commit a2303d3

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DesktopPromptInput extends StatefulWidget {
2323
required this.selectedSourcesNotifier,
2424
required this.onUpdateSelectedSources,
2525
this.hideDecoration = false,
26+
this.hideFormats = false,
2627
this.extraBottomActionButton,
2728
});
2829

@@ -34,6 +35,7 @@ class DesktopPromptInput extends StatefulWidget {
3435
final ValueNotifier<List<String>> selectedSourcesNotifier;
3536
final void Function(List<String>) onUpdateSelectedSources;
3637
final bool hideDecoration;
38+
final bool hideFormats;
3739
final Widget? extraBottomActionButton;
3840

3941
@override
@@ -139,11 +141,11 @@ class _DesktopPromptInputState extends State<DesktopPromptInput> {
139141
children: [
140142
ConstrainedBox(
141143
constraints: getTextFieldConstraints(
142-
state.showPredefinedFormats,
144+
state.showPredefinedFormats && !widget.hideFormats,
143145
),
144146
child: inputTextField(),
145147
),
146-
if (state.showPredefinedFormats)
148+
if (state.showPredefinedFormats && !widget.hideFormats)
147149
Positioned.fill(
148150
bottom: null,
149151
child: TextFieldTapRegion(
@@ -168,8 +170,9 @@ class _DesktopPromptInputState extends State<DesktopPromptInput> {
168170
top: null,
169171
child: TextFieldTapRegion(
170172
child: _PromptBottomActions(
171-
showPredefinedFormats:
173+
showPredefinedFormatBar:
172174
state.showPredefinedFormats,
175+
showPredefinedFormatButton: !widget.hideFormats,
173176
onTogglePredefinedFormatSection: () =>
174177
context.read<AIPromptInputBloc>().add(
175178
AIPromptInputEvent
@@ -571,7 +574,8 @@ class PromptInputTextField extends StatelessWidget {
571574
class _PromptBottomActions extends StatelessWidget {
572575
const _PromptBottomActions({
573576
required this.sendButtonState,
574-
required this.showPredefinedFormats,
577+
required this.showPredefinedFormatBar,
578+
required this.showPredefinedFormatButton,
575579
required this.onTogglePredefinedFormatSection,
576580
required this.onStartMention,
577581
required this.onSendPressed,
@@ -581,7 +585,8 @@ class _PromptBottomActions extends StatelessWidget {
581585
this.extraBottomActionButton,
582586
});
583587

584-
final bool showPredefinedFormats;
588+
final bool showPredefinedFormatBar;
589+
final bool showPredefinedFormatButton;
585590
final void Function() onTogglePredefinedFormatSection;
586591
final void Function() onStartMention;
587592
final SendButtonState sendButtonState;
@@ -600,10 +605,12 @@ class _PromptBottomActions extends StatelessWidget {
600605
builder: (context, state) {
601606
return Row(
602607
children: [
603-
_predefinedFormatButton(),
604-
const HSpace(
605-
DesktopAIChatSizes.inputActionBarButtonSpacing,
606-
),
608+
if (showPredefinedFormatButton) ...[
609+
_predefinedFormatButton(),
610+
const HSpace(
611+
DesktopAIChatSizes.inputActionBarButtonSpacing,
612+
),
613+
],
607614
SelectModelMenu(
608615
aiModelStateNotifier:
609616
context.read<AIPromptInputBloc>().aiModelStateNotifier,
@@ -641,7 +648,7 @@ class _PromptBottomActions extends StatelessWidget {
641648

642649
Widget _predefinedFormatButton() {
643650
return PromptInputDesktopToggleFormatButton(
644-
showFormatBar: showPredefinedFormats,
651+
showFormatBar: showPredefinedFormatBar,
645652
onTap: onTogglePredefinedFormatSection,
646653
);
647654
}

frontend/appflowy_flutter/lib/ai/widgets/prompt_input/select_model_menu.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ class _ModelItem extends StatelessWidget {
173173
model.i18n,
174174
figmaLineHeight: 20,
175175
overflow: TextOverflow.ellipsis,
176-
color: isSelected ? Theme.of(context).colorScheme.primary : null,
177176
),
178177
if (model.desc.isNotEmpty)
179178
FlowyText(

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/ai/ai_writer_block_component.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ class MainContentArea extends StatelessWidget {
490490
return DesktopPromptInput(
491491
isStreaming: false,
492492
hideDecoration: true,
493+
hideFormats: [
494+
AiWriterCommand.fixSpellingAndGrammar,
495+
AiWriterCommand.improveWriting,
496+
AiWriterCommand.makeLonger,
497+
AiWriterCommand.makeShorter,
498+
].contains(state.command),
493499
textController: textController,
494500
onSubmitted: (message, format, _) {
495501
cubit.runCommand(state.command, message, format);

0 commit comments

Comments
 (0)