Skip to content

Commit c8b8a3a

Browse files
Merge pull request #1632 from QueryaHub/review/settings-perf-mcp
fix(settings): Preferences without wrong-state flashes, MCP pane polish, a fake Data Grid switch removed
2 parents b10423c + 6427b15 commit c8b8a3a

7 files changed

Lines changed: 530 additions & 169 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- **Demo Marketplace themes were named `${manifest.name}`** — the generated theme.json now carries the real name (the demo catalog is only used with `--dart-define=QUERYA_MARKETPLACE_MOCK=true`).
2424
- **In-app update of a package install (AUR, `.deb`, `.rpm`)** — the updater no longer downloads a zip and quits when the app lives in `/opt/querya-desktop` (owned by root): the update dialog says how to update it (`yay -Syu querya-desktop`, `apt`, `dnf`) with a *Copy update command* button, or offers the release page for any other folder the user cannot write. If an in-place replace fails anyway, the app is started again and the reason is logged to `~/.local/state/querya-update.log`, instead of staying closed.
2525

26+
- **Preferences no longer flash a wrong state** — the MCP Server pane showed the server switch off, "No SQL connections" and "No calls yet" for a moment on every visit before the real values jumped in; it now draws them only once loaded. Panes you visited stay as they were (no reload, their own scroll position: Shortcuts no longer opens half-scrolled after another pane).
27+
- **Data Grid preferences: removed "Confirm DML staging applications"** — it changed the SQL destructive-query confirmation (DROP / TRUNCATE / DELETE) and controlled nothing else.
28+
- **About shows the real version** instead of a hardcoded 0.4.17.
29+
- **MCP Server pane** — MongoDB connections can be shared (the server already had MongoDB tools), type badges use product names, the `querya-mcp` path is on its own line, copying configs and regenerating the token are separate, and recent calls are rows with a status icon.
30+
2631
### Planned
2732

2833
- Planned 0.5.0 — live Marketplace download and install

‎benchmark/app_perf_bench.dart‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import 'package:querya_desktop/core/storage/local_db.dart';
3131
import 'package:querya_desktop/core/theme/theme_controller.dart';
3232
import 'package:querya_desktop/features/connections/connections_panel.dart';
3333
import 'package:querya_desktop/features/erd/erd_view.dart';
34+
import 'package:querya_desktop/features/settings/preferences_dialog.dart';
3435
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
3536
import 'package:querya_desktop/features/workspace/result_grid_view.dart';
3637
import 'package:vm_service/vm_service.dart' as vms;
@@ -108,6 +109,12 @@ Future<void> _runAll() async {
108109
await _wait(1500);
109110
await _scenario('idle_workspace', () => _wait(1500));
110111

112+
await _preferencesScenarios();
113+
if (only.isNotEmpty &&
114+
only.split(',').every((id) => id.trim().startsWith('prefs_'))) {
115+
return; // nothing after this point was asked for
116+
}
117+
111118
await _scenario('sidebar_toggle', () async {
112119
for (var i = 0; i < 8; i++) {
113120
(_findState((s) => s.runtimeType.toString() == '_MainContentSplitState')
@@ -268,6 +275,68 @@ Future<void> _runAll() async {
268275
dynamic _workspace() =>
269276
_findState((s) => s.runtimeType.toString() == 'GenericSqlWorkspaceState')!;
270277

278+
/// Preferences over the workspace: the dialog sits on a full-window frosted
279+
/// backdrop, so these show what one repaint inside it costs.
280+
Future<void> _preferencesScenarios() async {
281+
Element dialog() => _find((e) =>
282+
e.widget.runtimeType.toString() == '_PreferencesDialogContent')!;
283+
284+
await _scenario('prefs_open', () async {
285+
showPreferencesDialog(_find((e) => e.widget is ConnectionsPanel)!);
286+
await _waitFor(() => _findText('General Settings') != null, 'Preferences');
287+
await _wait(600);
288+
});
289+
await _scenario('prefs_idle', () => _wait(1500));
290+
await _scenario('prefs_hover', () => _hoverOver(dialog(), 3000));
291+
// One scenario per category: switching to it builds its pane from scratch.
292+
for (final label in const [
293+
'Appearance', 'SQL & Editor', 'Data Grid', 'Extensions',
294+
'MCP Server', 'Shortcuts', 'About & Storage', 'General',
295+
]) {
296+
final id = 'prefs_cat_${label.split(' ').first.toLowerCase()}';
297+
await _scenario(id, () => _tap(_byText(label)));
298+
}
299+
await _scenario('prefs_reopen', () async {
300+
await _tap(_byText('Close'));
301+
await _wait(500);
302+
showPreferencesDialog(_find((e) => e.widget is ConnectionsPanel)!);
303+
await _waitFor(() => _findText('General Settings') != null, 'Preferences');
304+
await _wait(600);
305+
});
306+
await _tap(_byText('Shortcuts'));
307+
await _scenario('prefs_scroll', () => _scrollLoop(
308+
dialog, Axis.vertical, 10, 3000, minExtent: 100));
309+
await _scenario('prefs_typing', () async {
310+
final search = _findState((s) =>
311+
s is EditableTextState &&
312+
s.widget.controller.runtimeType == TextEditingController) as EditableTextState;
313+
var text = '';
314+
for (final ch in 'mcp server token'.split('')) {
315+
text += ch;
316+
search.updateEditingValue(TextEditingValue(
317+
text: text,
318+
selection: TextSelection.collapsed(offset: text.length),
319+
));
320+
await _wait(90);
321+
}
322+
search.updateEditingValue(TextEditingValue.empty);
323+
await _wait(300);
324+
});
325+
await _tap(_byText('MCP Server'));
326+
await _scenario('prefs_toggle', () async {
327+
final share = _find((e) => '${e.widget.key}'.contains('mcp_share_'));
328+
if (share == null) {
329+
stdout.writeln('BENCH skip: no shareable connection');
330+
return;
331+
}
332+
for (var i = 0; i < 6; i++) {
333+
await _tap(share);
334+
}
335+
});
336+
await _tap(_byText('Close'));
337+
await _wait(600);
338+
}
339+
271340
/// Puts [sql] into the active query tab, runs it and waits for the run to end.
272341
Future<void> _runInActiveTab(String sql) async {
273342
final ws = _workspace();

‎lib/features/settings/preferences_about_section.dart‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart' as material;
2+
import 'package:package_info_plus/package_info_plus.dart';
23
import 'package:querya_desktop/core/extensions/extension_paths.dart';
34
import 'package:querya_desktop/core/platform/open_directory.dart';
45
import 'package:querya_desktop/core/storage/app_data_root.dart';
@@ -8,13 +9,28 @@ import 'package:querya_desktop/shared/widgets/widgets.dart';
89
import 'package:url_launcher/url_launcher_string.dart';
910
import 'package:querya_desktop/core/ui/querya_control_tokens.dart';
1011

11-
class PreferencesAboutSection extends StatelessWidget {
12+
class PreferencesAboutSection extends material.StatefulWidget {
1213
const PreferencesAboutSection({super.key});
1314

14-
static const String appVersion = '0.4.17';
1515
static const String githubRepoUrl =
1616
'https://github.com/QueryaHub/Querya-Desktop';
1717

18+
@override
19+
material.State<PreferencesAboutSection> createState() =>
20+
_PreferencesAboutSectionState();
21+
}
22+
23+
class _PreferencesAboutSectionState
24+
extends material.State<PreferencesAboutSection> {
25+
// Created once: a future made in build() would restart on every rebuild of
26+
// the dialog (every keystroke in its search) and make these rows flicker.
27+
late final Future<String> _version = PackageInfo.fromPlatform()
28+
.then((i) => i.version)
29+
.catchError((Object _) => '');
30+
late final Future<bool> _portable = AppDataRoot.isPortableMode();
31+
32+
static const githubRepoUrl = PreferencesAboutSection.githubRepoUrl;
33+
1834
@override
1935
Widget build(BuildContext context) {
2036
final theme = Theme.of(context);
@@ -68,9 +84,14 @@ class PreferencesAboutSection extends StatelessWidget {
6884
.large()
6985
.foreground(),
7086
const material.SizedBox(height: 2),
71-
const Text('Version $appVersion (Desktop Build)')
72-
.muted()
73-
.small(),
87+
FutureBuilder<String>(
88+
future: _version,
89+
builder: (context, snapshot) => Text(
90+
snapshot.data?.isNotEmpty == true
91+
? 'Version ${snapshot.data} (Desktop Build)'
92+
: 'Desktop Build',
93+
).muted().small(),
94+
),
7495
const material.SizedBox(height: 4),
7596
const Text('Fast, native multi-database management studio.')
7697
.muted()
@@ -91,7 +112,7 @@ class PreferencesAboutSection extends StatelessWidget {
91112
const material.SizedBox(height: 12),
92113

93114
FutureBuilder<bool>(
94-
future: AppDataRoot.isPortableMode(),
115+
future: _portable,
95116
builder: (context, snapshot) {
96117
final isPortable = snapshot.data ?? false;
97118
if (!isPortable) return const SizedBox.shrink();

0 commit comments

Comments
 (0)