Skip to content

Commit 3c74208

Browse files
authored
Merge pull request #7650 from AppFlowy-IO/display_plugin_version
chore: show plugin version
2 parents 9c25769 + 5ae3f42 commit 3c74208

File tree

13 files changed

+135
-211
lines changed

13 files changed

+135
-211
lines changed

frontend/appflowy_flutter/lib/workspace/application/settings/ai/download_offline_ai_app_bloc.dart

Lines changed: 0 additions & 41 deletions
This file was deleted.

frontend/appflowy_flutter/lib/workspace/application/settings/ai/local_ai_setting_panel_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class LocalAISettingPanelBloc
4444
) async {
4545
event.when(
4646
updateAIState: (LocalAIPB pluginState) {
47-
if (pluginState.isPluginExecutableReady) {
47+
if (pluginState.pluginDownloaded) {
4848
emit(
4949
state.copyWith(
5050
runningState: pluginState.state,

frontend/appflowy_flutter/lib/workspace/application/settings/ai/plugin_state_bloc.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ class PluginStateBloc extends Bloc<PluginStateEvent, PluginStateState> {
9191
);
9292
break;
9393
case RunningStatePB.Running:
94-
emit(const PluginStateState(action: PluginStateAction.running()));
94+
emit(
95+
PluginStateState(
96+
action: PluginStateAction.running(aiState.pluginVersion),
97+
),
98+
);
9599
break;
96100
case RunningStatePB.Stopped:
97101
emit(
@@ -140,7 +144,7 @@ class PluginStateAction with _$PluginStateAction {
140144
const factory PluginStateAction.unknown() = _Unknown;
141145
const factory PluginStateAction.readToRun() = _ReadyToRun;
142146
const factory PluginStateAction.initializingPlugin() = _InitializingPlugin;
143-
const factory PluginStateAction.running() = _PluginRunning;
147+
const factory PluginStateAction.running(String version) = _PluginRunning;
144148
const factory PluginStateAction.restartPlugin() = _RestartPlugin;
145149
const factory PluginStateAction.lackOfResource(String desc) = _LackOfResource;
146150
}

frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/plugin_state.dart

Lines changed: 15 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import 'package:appflowy/core/helpers/url_launcher.dart';
21
import 'package:appflowy/generated/flowy_svgs.g.dart';
32
import 'package:appflowy/generated/locale_keys.g.dart';
4-
import 'package:appflowy/workspace/application/settings/ai/download_offline_ai_app_bloc.dart';
53
import 'package:appflowy/workspace/application/settings/ai/plugin_state_bloc.dart';
64
import 'package:appflowy/workspace/presentation/settings/pages/setting_ai_view/init_local_ai.dart';
75
import 'package:easy_localization/easy_localization.dart';
8-
import 'package:flowy_infra/size.dart';
96
import 'package:flowy_infra_ui/style_widget/button.dart';
107
import 'package:flowy_infra_ui/style_widget/text.dart';
118
import 'package:flowy_infra_ui/widget/spacing.dart';
12-
import 'package:flutter/gestures.dart';
139
import 'package:flutter/material.dart';
1410
import 'package:flutter_bloc/flutter_bloc.dart';
1511

@@ -27,7 +23,10 @@ class PluginStateIndicator extends StatelessWidget {
2723
unknown: () => const SizedBox.shrink(),
2824
readToRun: () => const _PrepareRunning(),
2925
initializingPlugin: () => const InitLocalAIIndicator(),
30-
running: () => const _LocalAIRunning(),
26+
running: (version) => _LocalAIRunning(
27+
key: ValueKey(version),
28+
version: version,
29+
),
3130
restartPlugin: () => const _RestartPluginButton(),
3231
lackOfResource: (desc) => _LackOfResource(desc: desc),
3332
);
@@ -88,7 +87,9 @@ class _RestartPluginButton extends StatelessWidget {
8887
}
8988

9089
class _LocalAIRunning extends StatelessWidget {
91-
const _LocalAIRunning();
90+
const _LocalAIRunning({required this.version, super.key});
91+
92+
final String version;
9293

9394
@override
9495
Widget build(BuildContext context) {
@@ -113,6 +114,14 @@ class _LocalAIRunning extends StatelessWidget {
113114
color: Color(0xFF2E7D32),
114115
),
115116
const HSpace(6),
117+
if (version.isNotEmpty)
118+
Flexible(
119+
child: FlowyText(
120+
"($version) ",
121+
fontSize: 11,
122+
color: const Color(0xFF1E4620),
123+
),
124+
),
116125
Flexible(
117126
child: FlowyText(
118127
LocaleKeys.settings_aiPage_keys_localAIRunning.tr(),
@@ -131,95 +140,6 @@ class _LocalAIRunning extends StatelessWidget {
131140
}
132141
}
133142

134-
class OpenOrDownloadOfflineAIApp extends StatelessWidget {
135-
const OpenOrDownloadOfflineAIApp({required this.onRetry, super.key});
136-
137-
final VoidCallback onRetry;
138-
139-
@override
140-
Widget build(BuildContext context) {
141-
return BlocProvider(
142-
create: (context) => DownloadOfflineAIBloc(),
143-
child: BlocBuilder<DownloadOfflineAIBloc, DownloadOfflineAIState>(
144-
builder: (context, state) {
145-
return Column(
146-
crossAxisAlignment: CrossAxisAlignment.start,
147-
children: [
148-
RichText(
149-
maxLines: 3,
150-
textAlign: TextAlign.left,
151-
text: TextSpan(
152-
children: <TextSpan>[
153-
TextSpan(
154-
text:
155-
"${LocaleKeys.settings_aiPage_keys_offlineAIInstruction1.tr()} ",
156-
style: Theme.of(context)
157-
.textTheme
158-
.bodySmall!
159-
.copyWith(height: 1.5),
160-
),
161-
TextSpan(
162-
text:
163-
" ${LocaleKeys.settings_aiPage_keys_offlineAIInstruction2.tr()} ",
164-
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
165-
fontSize: FontSizes.s14,
166-
color: Theme.of(context).colorScheme.primary,
167-
height: 1.5,
168-
),
169-
recognizer: TapGestureRecognizer()
170-
..onTap = () => afLaunchUrlString(
171-
"https://docs.appflowy.io/docs/appflowy/product/appflowy-ai-offline",
172-
),
173-
),
174-
TextSpan(
175-
text:
176-
" ${LocaleKeys.settings_aiPage_keys_offlineAIInstruction3.tr()} ",
177-
style: Theme.of(context)
178-
.textTheme
179-
.bodySmall!
180-
.copyWith(height: 1.5),
181-
),
182-
TextSpan(
183-
text:
184-
"${LocaleKeys.settings_aiPage_keys_offlineAIDownload1.tr()} ",
185-
style: Theme.of(context)
186-
.textTheme
187-
.bodySmall!
188-
.copyWith(height: 1.5),
189-
),
190-
TextSpan(
191-
text:
192-
" ${LocaleKeys.settings_aiPage_keys_offlineAIDownload2.tr()} ",
193-
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
194-
fontSize: FontSizes.s14,
195-
color: Theme.of(context).colorScheme.primary,
196-
height: 1.5,
197-
),
198-
recognizer: TapGestureRecognizer()
199-
..onTap =
200-
() => context.read<DownloadOfflineAIBloc>().add(
201-
const DownloadOfflineAIEvent.started(),
202-
),
203-
),
204-
TextSpan(
205-
text:
206-
" ${LocaleKeys.settings_aiPage_keys_offlineAIDownload3.tr()} ",
207-
style: Theme.of(context)
208-
.textTheme
209-
.bodySmall!
210-
.copyWith(height: 1.5),
211-
),
212-
],
213-
),
214-
),
215-
],
216-
);
217-
},
218-
),
219-
);
220-
}
221-
}
222-
223143
class _LackOfResource extends StatelessWidget {
224144
const _LackOfResource({required this.desc});
225145

frontend/resources/translations/ar-SA.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3217,4 +3217,4 @@
32173217
"rewrite": "إعادة كتابة",
32183218
"insertBelow": "أدخل أدناه"
32193219
}
3220-
}
3220+
}

frontend/resources/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3202,4 +3202,4 @@
32023202
"rewrite": "Rewrite",
32033203
"insertBelow": "Insert below"
32043204
}
3205-
}
3205+
}

frontend/resources/translations/ko-KR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3185,4 +3185,4 @@
31853185
"rewrite": "다시 작성",
31863186
"insertBelow": "아래에 삽입"
31873187
}
3188-
}
3188+
}

frontend/rust-lib/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/rust-lib/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFl
152152
# To update the commit ID, run:
153153
# scripts/tool/update_local_ai_rev.sh new_rev_id
154154
# ⚠️⚠️⚠️️
155-
af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
156-
af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
157-
af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }
155+
af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "4b3d50cbec2f58be2ac385231b8f585f1555e282" }
156+
af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "4b3d50cbec2f58be2ac385231b8f585f1555e282" }
157+
af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "4b3d50cbec2f58be2ac385231b8f585f1555e282" }

frontend/rust-lib/flowy-ai/src/entities.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,20 +585,17 @@ pub struct LocalAIPB {
585585
#[pb(index = 1)]
586586
pub enabled: bool,
587587

588-
#[pb(index = 2)]
589-
pub is_plugin_executable_ready: bool,
590-
591-
#[pb(index = 3, one_of)]
588+
#[pb(index = 2, one_of)]
592589
pub lack_of_resource: Option<String>,
593590

594-
#[pb(index = 4)]
591+
#[pb(index = 3)]
595592
pub state: RunningStatePB,
596-
}
597593

598-
#[derive(Default, ProtoBuf, Clone, Debug)]
599-
pub struct LocalAIAppLinkPB {
600-
#[pb(index = 1)]
601-
pub link: String,
594+
#[pb(index = 4, one_of)]
595+
pub plugin_version: Option<String>,
596+
597+
#[pb(index = 5)]
598+
pub plugin_downloaded: bool,
602599
}
603600

604601
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]

0 commit comments

Comments
 (0)