Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ab75743
feat: add ai search entrance
asjqkkkk May 6, 2025
3323a5c
chore: revamp search recent list
asjqkkkk May 6, 2025
2582a68
feat: revamp preview widget
asjqkkkk May 7, 2025
2c853df
feat: support click the 'Ask ai button'
asjqkkkk May 7, 2025
a15d910
feat: support go to trash when there is no search results
asjqkkkk May 7, 2025
9304b63
feat: support AI overview
asjqkkkk May 7, 2025
faf81a3
Merge branch 'main' into feat/desktop/search
asjqkkkk May 8, 2025
f6a7667
fix: typo issue
asjqkkkk May 8, 2025
989d5e9
fix: empty trash item name
asjqkkkk May 8, 2025
3c12079
chore: replace some Dividers to AFDividers
asjqkkkk May 8, 2025
689a9b3
chore: improve some code logic
asjqkkkk May 8, 2025
a34d7ec
chore: update some icon color
asjqkkkk May 8, 2025
16ef6a3
Merge branch 'main' into feat/desktop/search
asjqkkkk May 8, 2025
cd484cb
fix: some UI issue
asjqkkkk May 8, 2025
a3bf5a3
chore: adjust some paddings
asjqkkkk May 8, 2025
a70cf7c
fix: align issue for reference sources
asjqkkkk May 9, 2025
df8891b
fix: change clear icon's hover effect
asjqkkkk May 9, 2025
ff4b8fd
fix: clear search field will not make it unfocus
asjqkkkk May 9, 2025
a6d620b
chore: make 'Ask AI' button scroll with list
asjqkkkk May 9, 2025
f9c02cb
chore: change the size of search panel
asjqkkkk May 9, 2025
58e59c3
fix: change mobile search field cancel icon
asjqkkkk May 9, 2025
ffcf14e
feat: support preview panel for recent pages
asjqkkkk May 9, 2025
ed880ef
fix: some UI issues
asjqkkkk May 9, 2025
3ad0ba3
fix: hover to show the reference sources
asjqkkkk May 9, 2025
285e91f
fix: some padding issues
asjqkkkk May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:appflowy/plugins/ai_chat/application/chat_input_control_cubit.da
import 'package:appflowy/plugins/ai_chat/presentation/layout_define.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy/workspace/application/command_palette/command_palette_bloc.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
Expand Down Expand Up @@ -74,6 +75,7 @@ class _DesktopPromptInputState extends State<DesktopPromptInput> {

WidgetsBinding.instance.addPostFrameCallback((_) {
focusNode.requestFocus();
checkForAskingAI();
});
}

Expand Down Expand Up @@ -221,6 +223,26 @@ class _DesktopPromptInputState extends State<DesktopPromptInput> {
);
}

void checkForAskingAI() {
final paletteBloc = context.read<CommandPaletteBloc?>(),
paletteState = paletteBloc?.state;
final isAskingAI = paletteState?.askAI ?? false;
if (!isAskingAI) return;
final query = paletteState?.query ?? '';
if (query.isEmpty) return;
final sources =
(paletteState?.askAISources ?? []).map((e) => e.id).toList();
final metadata =
context.read<AIPromptInputBloc?>()?.consumeMetadata() ?? {};
final promptState = context.read<AIPromptInputBloc?>()?.state;
final predefinedFormat = promptState?.predefinedFormat;
if (sources.isNotEmpty) {
widget.onUpdateSelectedSources(sources);
}
widget.onSubmitted.call(query, predefinedFormat, metadata);
paletteBloc?.add(CommandPaletteEvent.askedAI());
}

void startMentionPageFromButton() {
if (overlayController.isShowing) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

Expand Down Expand Up @@ -53,3 +55,46 @@ class ViewAncestorState with _$ViewAncestorState {
ancestor: ViewAncestor.empty(),
);
}

extension ViewAncestorTextExtension on ViewAncestorState {
Widget buildPath(BuildContext context, {TextStyle? style}) {
final theme = AppFlowyTheme.of(context);
final ancestors = ancestor.ancestors;
final textStyle = style ??
theme.textStyle.caption.standard(color: theme.textColorScheme.tertiary);
return LayoutBuilder(
builder: (context, constrains) {
final List<String> displayPath = ancestors.map((e) => e.name).toList();
if (displayPath.isEmpty) return const SizedBox.shrink();
final style = theme.textStyle.caption
.standard(color: theme.textColorScheme.tertiary);
TextPainter textPainter =
_buildTextPainter(displayPath.join(' / '), textStyle);
textPainter.layout(maxWidth: constrains.maxWidth);
if (textPainter.didExceedMaxLines && displayPath.length > 2) {
displayPath.removeAt(displayPath.length - 2);
displayPath.insert(displayPath.length - 1, '...');
}
textPainter = _buildTextPainter(displayPath.join(' / '), textStyle);
textPainter.layout(maxWidth: constrains.maxWidth);
while (textPainter.didExceedMaxLines && displayPath.length > 3) {
displayPath.removeAt(displayPath.length - 2);
textPainter = _buildTextPainter(displayPath.join(' / '), textStyle);
textPainter.layout(maxWidth: constrains.maxWidth);
}
return Text(
displayPath.join(' / '),
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
);
},
);
}

TextPainter _buildTextPainter(String text, TextStyle style) => TextPainter(
text: TextSpan(text: text, style: style),
maxLines: 1,
textDirection: TextDirection.ltr,
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ class DateCellEditorBloc
} else {
if (option == ReminderOption.none) {
// remove reminder from reminder bloc and cell data
_reminderBloc.add(ReminderEvent.removeReminder(reminderId: state.reminderId));
_reminderBloc
.add(ReminderEvent.removeReminder(reminderId: state.reminderId));
await _updateCellReminderId("");
} else {
// Update reminder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class DateTransactionHandler extends MentionTransactionHandler {
final reminderId = data.$2[MentionBlockKeys.reminderId];

if (reminderId case String _ when reminderId.isNotEmpty) {
getIt<ReminderBloc>().add(ReminderEvent.removeReminder(reminderId: reminderId));
getIt<ReminderBloc>()
.add(ReminderEvent.removeReminder(reminderId: reminderId));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
} else {
final rootContext = widget.editorState.document.root.context;
if (rootContext != null && _reminderId != null) {
rootContext
.read<ReminderBloc?>()
?.add(ReminderEvent.removeReminder(reminderId: _reminderId!));
rootContext.read<ReminderBloc?>()?.add(
ReminderEvent.removeReminder(reminderId: _reminderId!),
);
}
_updateBlock(selectedDay, includeTime: _includeTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ApplicationWidget extends StatefulWidget {
class _ApplicationWidgetState extends State<ApplicationWidget> {
late final GoRouter routerConfig;

final _commandPaletteNotifier = ValueNotifier<bool>(false);
final _commandPaletteNotifier = ValueNotifier(CommandPaletteNotifierValue());

final themeBuilder = AppFlowyDefaultTheme();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ class CommandPaletteBloc
_GoingToAskAI event,
Emitter<CommandPaletteState> emit,
) {
emit(state.copyWith(askAI: true));
emit(state.copyWith(askAI: true, askAISources: event.sources));
}

FutureOr<void> _onAskedAI(
_AskedAI event,
Emitter<CommandPaletteState> emit,
) {
emit(state.copyWith(askAI: false));
emit(state.copyWith(askAI: false, askAISources: null));
}

bool _isActiveSearch(String searchId) =>
Expand Down Expand Up @@ -325,7 +325,9 @@ class CommandPaletteEvent with _$CommandPaletteEvent {
@Default(null) String? workspaceId,
}) = _WorkspaceChanged;
const factory CommandPaletteEvent.clearSearch() = _ClearSearch;
const factory CommandPaletteEvent.gointToAskAI() = _GoingToAskAI;
const factory CommandPaletteEvent.gointToAskAI({
@Default(null) List<SearchSourcePB>? sources,
}) = _GoingToAskAI;
const factory CommandPaletteEvent.askedAI() = _AskedAI;
}

Expand Down Expand Up @@ -358,6 +360,7 @@ class CommandPaletteState with _$CommandPaletteState {
required bool searching,
required bool generatingAIOverview,
@Default(false) bool askAI,
@Default(null) List<SearchSourcePB>? askAISources,
@Default([]) List<TrashPB> trash,
@Default(null) String? searchId,
}) = _CommandPaletteState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ extension GetIcon on ResultIconPB {
lineHeight: lineHeight,
)
: null;
} else if (ty == ResultIconTypePB.Icon) {
} else if (iconType == ResultIconTypePB.Icon ||
iconType == ResultIconTypePB.Url) {
if (_resultIconValueTypes.contains(iconValue)) {
return FlowySvg(
getViewSvg(),
Expand Down
Loading
Loading