From 9941de4505915118049485d041289b6837718d87 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Tue, 24 Mar 2026 21:03:59 +0800 Subject: [PATCH] refactor(web): keep assistant home free of global sidebar --- lib/app/app_shell_web.dart | 8 ++++++-- test/web/web_ui_browser_test.dart | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/app/app_shell_web.dart b/lib/app/app_shell_web.dart index a2bd4e9f..a399a24a 100644 --- a/lib/app/app_shell_web.dart +++ b/lib/app/app_shell_web.dart @@ -83,6 +83,8 @@ class _AppShellState extends State { child: LayoutBuilder( builder: (context, constraints) { final isMobile = constraints.maxWidth < 900; + final showWorkspaceSidebar = + currentDestination != WorkspaceDestination.assistant; final expandedSidebarWidth = _clampSidebarWidth( _sidebarExpandedWidth ?? _defaultSidebarWidth( @@ -142,7 +144,8 @@ class _AppShellState extends State { return Row( children: [ - if (_sidebarState != AppSidebarState.hidden) + if (showWorkspaceSidebar && + _sidebarState != AppSidebarState.hidden) SidebarNavigation( currentSection: currentDestination, sidebarState: _sidebarState, @@ -183,7 +186,8 @@ class _AppShellState extends State { controller.toggleAssistantNavigationDestination, availableDestinations: controller.capabilities.allowedDestinations, ), - if (_sidebarState == AppSidebarState.expanded) + if (showWorkspaceSidebar && + _sidebarState == AppSidebarState.expanded) PaneResizeHandle( axis: Axis.horizontal, onDelta: (delta) { diff --git a/test/web/web_ui_browser_test.dart b/test/web/web_ui_browser_test.dart index d398e600..1218c6c7 100644 --- a/test/web/web_ui_browser_test.dart +++ b/test/web/web_ui_browser_test.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:xworkmate/app/app.dart'; +import 'package:xworkmate/widgets/sidebar_navigation.dart'; void main() { testWidgets('web shell aligns with app workspace layout and expanded pages', ( @@ -37,6 +38,7 @@ void main() { findsOneWidget, ); expect(find.text('连接设置'), findsNothing); + expect(find.byType(SidebarNavigation), findsNothing); await tester.tap( find.byKey(const Key('assistant-workspace-chrome-toggle')), @@ -108,20 +110,29 @@ void main() { ); await tester.tap( - find.byKey(const ValueKey('assistant-focus-add-tasks')), + find.byKey(const ValueKey('assistant-focus-add-settings')), ); await tester.pumpAndSettle(); expect( - find.byKey(const ValueKey('assistant-focus-open-page-tasks')), + find.byKey(const ValueKey('assistant-focus-open-page-settings')), findsOneWidget, ); await tester.tap( - find.byKey(const ValueKey('assistant-focus-open-page-tasks')), + find.byKey(const ValueKey('assistant-focus-open-page-settings')), ); await tester.pumpAndSettle(); + expect(find.byType(SidebarNavigation), findsOneWidget); + await tester.tap( + find.byKey(const ValueKey('sidebar-favorite-tasks')), + ); + await tester.pumpAndSettle(); + + await tester.tap(find.text('自动化')); + await tester.pumpAndSettle(); + expect(find.text('任务工作台'), findsOneWidget); await tester.tap(find.text('设置').last);