feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s

This commit is contained in:
lingjhf committed 2026-10-09 01:56:01 +08:00
1 parent aa5255d1e4
commit 2e0033ce2d
260 files changed
+43963 -5591

No files matched your search

+67 -47
View File
@@ -5,12 +5,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../integrations/editor_tools.dart';
import 'package:cutdex_ui/icons.dart';
import 'package:cutdex_ui/widgets.dart';
import 'package:cutdex_ui/theme.dart';
import '../../integrations/mcp/mcp_settings.dart';
import 'settings_layout.dart';
import '../../settings/settings_operation.dart';
import '../../shared/widgets/error_notification_host.dart';
class McpSettingsPanel extends ConsumerStatefulWidget {
const McpSettingsPanel({super.key, this.workspace});
@@ -53,38 +55,42 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
final settings = ref.watch(mcpSettingsProvider);
final value = settings.asData?.value;
final ids = widget.workspace;
final connection = ids == null
? null
: ref.watch(editorMcpConnectionProvider(ids.$1, ids.$2));
final status = value?.enabled != true
? context.l10n.disabled
: ids == null
? context.l10n.waitingForProject
: connection!.hasError
? context.l10n.startFailed
: connection.isLoading
? context.l10n.starting
: context.l10n.running;
return SettingsPageSection(
title: 'MCP',
icon: Icons.terminal_outlined,
icon: AppIcons.terminal,
children: [
AppField(
label: context.l10n.mcpService,
description: settings.isLoading
? context.l10n.loadingSettings
: status,
orientation: AppFieldOrientation.horizontal,
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: AppSwitch(
semanticLabel: context.l10n.mcpService,
value: value?.enabled ?? false,
onChanged: value == null || operation.isLoading
? null
: (enabled) => _toggle(enabled, value),
),
),
Consumer(
builder: (context, ref, _) {
final connection = ids == null
? null
: ref.watch(editorMcpConnectionProvider(ids.$1, ids.$2));
final status = value?.enabled != true
? context.l10n.disabled
: ids == null
? context.l10n.waitingForProject
: connection!.hasError
? context.l10n.startFailed
: connection.isLoading
? context.l10n.starting
: context.l10n.running;
return AppField(
label: context.l10n.mcpService,
description: settings.isLoading
? context.l10n.loadingSettings
: status,
orientation: AppFieldOrientation.horizontal,
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: AppSwitch(
semanticLabel: context.l10n.mcpService,
value: value?.enabled ?? false,
onChanged: value == null || operation.isLoading
? null
: (enabled) => _toggle(enabled, value),
),
),
);
},
),
if (value != null) ...[
AppField(
@@ -95,6 +101,7 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
child: TextFormField(
style: AppTheme.inputTextStyle(context),
cursorHeight: AppTheme.inputCursorHeight(context),
textAlignVertical: TextAlignVertical.center,
initialValue: '${value.port}',
enabled: !value.enabled && !operation.isLoading,
keyboardType: TextInputType.number,
@@ -111,13 +118,13 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
label: context.l10n.accessToken,
child: IconButton(
tooltip: context.l10n.copyAccessToken,
icon: const Icon(Icons.copy_outlined),
icon: const Icon(AppIcons.copy),
onPressed: () async {
await Clipboard.setData(ClipboardData(text: value.token));
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(context.l10n.accessTokenCopied)),
);
ErrorNotificationHost.of(
context,
).showMessage(content: Text(context.l10n.accessTokenCopied));
}
},
),
@@ -128,22 +135,35 @@ class _McpSettingsPanelState extends ConsumerState<McpSettingsPanel> {
onPressed: () => ref.invalidate(mcpSettingsProvider),
child: Text(context.l10n.loadMcpFailed),
),
if (value?.enabled == true && connection?.hasError == true) ...[
Text(
context.l10n.mcpStartError(
context.l10n.errorMessage(connection!.error!),
),
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
TextButton(
onPressed: operation.isLoading
Consumer(
builder: (context, ref, _) {
final connection = ids == null
? null
: () => ref.invalidate(
editorMcpConnectionProvider(ids!.$1, ids.$2),
: ref.watch(editorMcpConnectionProvider(ids.$1, ids.$2));
if (value?.enabled != true || connection?.hasError != true) {
return const SizedBox.shrink();
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
context.l10n.mcpStartError(
context.l10n.errorMessage(connection!.error!),
),
child: Text(context.l10n.retryStart),
),
],
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
TextButton(
onPressed: operation.isLoading
? null
: () => ref.invalidate(
editorMcpConnectionProvider(ids!.$1, ids.$2),
),
child: Text(context.l10n.retryStart),
),
],
);
},
),
if (error != null)
Text(
error,