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
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:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -4,6 +4,7 @@ import '../../integrations/platform/device_experience.dart';
|
||||
import 'touch_project_navigation.dart';
|
||||
import '../media/media_panel.dart';
|
||||
|
||||
import 'package:cutdex_ui/icons.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
|
||||
import 'dart:async';
|
||||
@@ -36,6 +37,9 @@ import '../../integrations/agent/agent_models.dart';
|
||||
|
||||
import 'widgets/name_dialog.dart';
|
||||
import 'conversation_sidebar.dart';
|
||||
import 'chat_header.dart';
|
||||
import 'sidebar_category_tabs.dart';
|
||||
import 'sidebar_navigation_controller.dart';
|
||||
|
||||
typedef ProjectRenamer = Future<bool> Function(RecentProject project);
|
||||
|
||||
@@ -44,7 +48,11 @@ class ProjectSidebar extends ConsumerStatefulWidget {
|
||||
super.key,
|
||||
required this.agent,
|
||||
this.navigationOnly = false,
|
||||
this.chatOnly = false,
|
||||
this.chatPanelActions = const [],
|
||||
this.resourcesSelected = false,
|
||||
this.onResourcesSelected,
|
||||
this.librarySelected = false,
|
||||
this.externalWindowFrame = false,
|
||||
this.experience = DeviceExperience.desktop,
|
||||
this.onNavigationComplete,
|
||||
@@ -66,7 +74,11 @@ class ProjectSidebar extends ConsumerStatefulWidget {
|
||||
|
||||
final Widget agent;
|
||||
final bool navigationOnly;
|
||||
final bool chatOnly;
|
||||
final List<Widget> chatPanelActions;
|
||||
final bool resourcesSelected;
|
||||
final ValueChanged<bool>? onResourcesSelected;
|
||||
final bool librarySelected;
|
||||
final bool externalWindowFrame;
|
||||
final DeviceExperience experience;
|
||||
final VoidCallback? onNavigationComplete;
|
||||
@@ -90,6 +102,13 @@ class ProjectSidebar extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
ProjectState get _projectState =>
|
||||
ref.read(projectsProvider).value ?? widget.state;
|
||||
SidebarNavigationContext _navigationContext(ProjectState state) =>
|
||||
(projectId: state.activeProject?.id, timelineId: state.visibleTimelineId);
|
||||
late final _navigation = SidebarNavigationController(
|
||||
_navigationContext(_projectState),
|
||||
);
|
||||
bool _resourcesVisited = false;
|
||||
bool get _touch => widget.experience != DeviceExperience.desktop;
|
||||
bool _projectHeaderHovered = false;
|
||||
@@ -115,10 +134,17 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
_projectSelection.value = widget.selectedProjectId;
|
||||
final ids = widget.state.recent.map((project) => project.id).toSet();
|
||||
_groupWidgets.removeWhere((id, _) => !ids.contains(id));
|
||||
_navigation.update(_navigationContext(_projectState));
|
||||
if (oldWidget.mode != widget.mode ||
|
||||
oldWidget.resourcesSelected != widget.resourcesSelected ||
|
||||
oldWidget.librarySelected != widget.librarySelected) {
|
||||
_navigation.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_navigation.dispose();
|
||||
_projectSelection.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -150,11 +176,15 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
}
|
||||
|
||||
void _selectProjectFromNavigation(RecentProject project) {
|
||||
_navigation.cancel();
|
||||
widget.onSelectProject?.call(project);
|
||||
if (widget.navigationOnly) _finishNavigation();
|
||||
}
|
||||
|
||||
void _newConversation() => _conversations.newConversation();
|
||||
void _newConversation() {
|
||||
_navigation.cancel();
|
||||
_conversations.newConversation();
|
||||
}
|
||||
|
||||
Future<void> _newConversationForProject(RecentProject project) async {
|
||||
_cutProjectsMenu.close();
|
||||
@@ -162,52 +192,75 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
!project.availability.canOpen) {
|
||||
return;
|
||||
}
|
||||
if (widget.state.activeProject?.id != project.id) {
|
||||
final opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.open(project.path, expectedId: project.id);
|
||||
if (!opened || !mounted) return;
|
||||
final navigation = _navigation.begin(project.id);
|
||||
bool isCurrent() => mounted && navigation();
|
||||
try {
|
||||
if (_projectState.activeProject?.id != project.id) {
|
||||
final opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.open(project.path, expectedId: project.id, isCurrent: isCurrent);
|
||||
if (!opened || !isCurrent()) return;
|
||||
}
|
||||
if (!isCurrent() || _projectState.activeProject?.id != project.id) return;
|
||||
_newConversation();
|
||||
widget.onModeChanged(WorkspaceMode.agent);
|
||||
_finishNavigation();
|
||||
} finally {
|
||||
_navigation.finish(navigation);
|
||||
}
|
||||
_newConversation();
|
||||
widget.onModeChanged(WorkspaceMode.agent);
|
||||
_finishNavigation();
|
||||
}
|
||||
|
||||
Future<void> _selectConversation(ConversationMetadata item) async {
|
||||
_cutProjectsMenu.close();
|
||||
if (ref.read(projectsProvider).value?.projectBusy == true) return;
|
||||
await _conversations.rememberSelection(item);
|
||||
final currentProject = widget.state.activeProject?.id;
|
||||
if (currentProject != item.projectId) {
|
||||
final project = widget.state.recent
|
||||
.where((entry) => entry.id == item.projectId)
|
||||
.firstOrNull;
|
||||
if (project == null || !project.availability.canOpen) return;
|
||||
var opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.open(
|
||||
project.path,
|
||||
expectedId: project.id,
|
||||
timelineId: item.timelineId,
|
||||
);
|
||||
if (!opened) {
|
||||
opened = await ref
|
||||
final navigation = _navigation.begin(
|
||||
item.projectId,
|
||||
timelineId: item.timelineId,
|
||||
);
|
||||
bool isCurrent() => mounted && navigation();
|
||||
try {
|
||||
await _conversations.rememberSelection(item);
|
||||
if (!isCurrent()) return;
|
||||
final currentProject = _projectState.activeProject?.id;
|
||||
if (currentProject != item.projectId) {
|
||||
final project = _projectState.recent
|
||||
.where((entry) => entry.id == item.projectId)
|
||||
.firstOrNull;
|
||||
if (project == null || !project.availability.canOpen) return;
|
||||
var opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.open(project.path, expectedId: project.id);
|
||||
.open(
|
||||
project.path,
|
||||
expectedId: project.id,
|
||||
timelineId: item.timelineId,
|
||||
isCurrent: isCurrent,
|
||||
);
|
||||
if (!isCurrent()) return;
|
||||
if (!opened) {
|
||||
_navigation.useProjectDefault(navigation);
|
||||
opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.open(project.path, expectedId: project.id, isCurrent: isCurrent);
|
||||
}
|
||||
if (!opened) return;
|
||||
} else if (_projectState.timeline?.id != item.timelineId &&
|
||||
_projectState.timelines.any(
|
||||
(timeline) => timeline.id == item.timelineId,
|
||||
)) {
|
||||
final opened = await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.openTimeline(item.projectId, item.timelineId);
|
||||
if (!opened) return;
|
||||
}
|
||||
if (!opened) return;
|
||||
} else if (widget.state.timeline?.id != item.timelineId &&
|
||||
widget.state.timelines.any(
|
||||
(timeline) => timeline.id == item.timelineId,
|
||||
)) {
|
||||
await ref
|
||||
.read(projectsProvider.notifier)
|
||||
.openTimeline(item.projectId, item.timelineId);
|
||||
if (!isCurrent() || _projectState.activeProject?.id != item.projectId) {
|
||||
return;
|
||||
}
|
||||
_conversations.activate(item);
|
||||
widget.onModeChanged(WorkspaceMode.agent);
|
||||
_finishNavigation();
|
||||
} finally {
|
||||
_navigation.finish(navigation);
|
||||
}
|
||||
if (!mounted || widget.state.activeProject?.id != item.projectId) return;
|
||||
_conversations.activate(item);
|
||||
widget.onModeChanged(WorkspaceMode.agent);
|
||||
_finishNavigation();
|
||||
}
|
||||
|
||||
Future<void> _renameConversation(ConversationMetadata item) async {
|
||||
@@ -254,7 +307,7 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
),
|
||||
),
|
||||
);
|
||||
if (selected == null) return;
|
||||
if (selected == null || !mounted) return;
|
||||
await _conversations.updateMetadata(item.copyWith(providerId: selected));
|
||||
}
|
||||
|
||||
@@ -266,16 +319,12 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
.read(projectsProvider.notifier)
|
||||
.removeRecentProject(project.id);
|
||||
if (!removed || !mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(context.l10n.projectRemoved),
|
||||
action: SnackBarAction(
|
||||
label: context.l10n.undo,
|
||||
onPressed: () => ref
|
||||
.read(projectsProvider.notifier)
|
||||
.restoreRecentProject(project, index),
|
||||
),
|
||||
),
|
||||
ErrorNotificationHost.of(context).showMessage(
|
||||
content: Text(context.l10n.projectRemoved),
|
||||
actionLabel: context.l10n.undo,
|
||||
onAction: () => ref
|
||||
.read(projectsProvider.notifier)
|
||||
.restoreRecentProject(project, index),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -325,7 +374,32 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
) ==
|
||||
true;
|
||||
|
||||
Widget _conversationRow(ConversationMetadata item) => Consumer(
|
||||
List<Widget> _conversationActions(ConversationMetadata item) => [
|
||||
AppMenuItem(
|
||||
label: context.l10n.rename,
|
||||
onPressed: () => _renameConversation(item),
|
||||
),
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentMoveToTrash,
|
||||
onPressed: () => _trashConversation(item),
|
||||
),
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentRelinkProvider,
|
||||
onPressed: () => _relinkProvider(item),
|
||||
),
|
||||
const AppMenuSeparator(),
|
||||
AppMenuItem(
|
||||
label: '${context.l10n.agentDeleteForever}…',
|
||||
destructive: true,
|
||||
onPressed: () => _deleteForever(item),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _conversationRow(
|
||||
ConversationMetadata item, {
|
||||
VoidCallback? onSelected,
|
||||
bool inMenu = false,
|
||||
}) => Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final active = ref.watch(
|
||||
projectsProvider.select(
|
||||
@@ -338,44 +412,40 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
.select((value) => value.selectedId == item.id),
|
||||
) &&
|
||||
active;
|
||||
List<Widget> actions(BuildContext context) => [
|
||||
AppMenuItem(
|
||||
label: context.l10n.rename,
|
||||
onPressed: () => _renameConversation(item),
|
||||
),
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentMoveToTrash,
|
||||
onPressed: () => _trashConversation(item),
|
||||
),
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentRelinkProvider,
|
||||
onPressed: () => _relinkProvider(item),
|
||||
),
|
||||
const AppMenuSeparator(),
|
||||
AppMenuItem(
|
||||
label: '${context.l10n.agentDeleteForever}…',
|
||||
destructive: true,
|
||||
onPressed: () => _deleteForever(item),
|
||||
),
|
||||
];
|
||||
if (inMenu) {
|
||||
return AppContextMenu(
|
||||
itemsBuilder: (_) => _conversationActions(item),
|
||||
child: AppMenuItem(
|
||||
key: ValueKey('sidebar-conversation-${item.id}'),
|
||||
label: item.title,
|
||||
selectOption: true,
|
||||
selected: selected,
|
||||
onPressed: onSelected ?? () => _selectConversation(item),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (_touch) {
|
||||
return TouchConversationTile(
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
selected: selected,
|
||||
onSelect: () => _selectConversation(item),
|
||||
actions: actions,
|
||||
onSelect: onSelected ?? () => _selectConversation(item),
|
||||
actions: (_) => _conversationActions(item),
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: AppSidebarMetrics.rowPadding,
|
||||
child: AppContextMenu(
|
||||
itemsBuilder: actions,
|
||||
itemsBuilder: (_) => _conversationActions(item),
|
||||
child: Material(
|
||||
color: selected
|
||||
? AppSidebarColors.of(context).hover
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(AppSidebarMetrics.radius),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppTheme.isDesktop(context)
|
||||
? AppRadius.large
|
||||
: AppSidebarMetrics.radius,
|
||||
),
|
||||
child: InkWell(
|
||||
key: ValueKey('sidebar-conversation-${item.id}'),
|
||||
hoverColor: selected
|
||||
@@ -383,28 +453,61 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
: AppSidebarColors.of(context).hover,
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(AppSidebarMetrics.radius),
|
||||
onTap: () => _selectConversation(item),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppTheme.isDesktop(context)
|
||||
? AppRadius.large
|
||||
: AppSidebarMetrics.radius,
|
||||
),
|
||||
onTap: onSelected ?? () => _selectConversation(item),
|
||||
child: SizedBox(
|
||||
height: AppSidebarMetrics.rowHeight,
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: AppSidebarMetrics.textInset,
|
||||
end: AppSidebarMetrics.cellPadding,
|
||||
),
|
||||
child: Text(
|
||||
item.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppSidebarTypography.style(
|
||||
context,
|
||||
fontSize: AppSidebarMetrics.conversationFontSize,
|
||||
height: AppSidebarMetrics.conversationLineHeight,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.sidebarRow
|
||||
: AppSidebarMetrics.rowHeight,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (selected && AppTheme.isDesktop(context))
|
||||
PositionedDirectional(
|
||||
start: AppSidebarMetrics.cellPadding,
|
||||
top: 8,
|
||||
bottom: 8,
|
||||
width: 2,
|
||||
child: IgnorePointer(
|
||||
child: DecoratedBox(
|
||||
key: ValueKey(
|
||||
'sidebar-conversation-selection-${item.id}',
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
start: AppSidebarMetrics.textInset,
|
||||
end: AppSidebarMetrics.cellPadding,
|
||||
),
|
||||
child: Text(
|
||||
item.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppSidebarTypography.style(
|
||||
context,
|
||||
fontSize: AppTheme.isDesktop(context)
|
||||
? 13
|
||||
: AppSidebarMetrics.conversationFontSize,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? 20 / 13
|
||||
: AppSidebarMetrics.conversationLineHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -592,6 +695,130 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_navigation.update(_navigationContext(_projectState));
|
||||
ref.listen(
|
||||
projectsProvider.select(
|
||||
(value) =>
|
||||
value.value == null ? null : _navigationContext(value.requireValue),
|
||||
),
|
||||
(_, next) {
|
||||
if (next != null) _navigation.update(next);
|
||||
},
|
||||
);
|
||||
if (widget.chatOnly) {
|
||||
final snapshot = ref.watch(conversationSidebarProvider).value;
|
||||
final projectId = widget.state.activeProject?.id;
|
||||
final conversations =
|
||||
snapshot?.groups[projectId] ?? const <ConversationMetadata>[];
|
||||
final selectedId = ref.watch(
|
||||
conversationSelectionProvider(projectId)
|
||||
.select((value) => value.selectedId),
|
||||
);
|
||||
final selected = conversations
|
||||
.where((item) => item.id == selectedId)
|
||||
.firstOrNull;
|
||||
return Material(
|
||||
key: const Key('project-chat-sidebar'),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
children: [
|
||||
ChatHeader(
|
||||
key: ValueKey(('chat-header', projectId)),
|
||||
title: selected?.title ?? context.l10n.agentUntitledConversation,
|
||||
busy: widget.state.projectBusy,
|
||||
onNew: _newConversation,
|
||||
panelActions: widget.chatPanelActions,
|
||||
actions: selected == null
|
||||
? const []
|
||||
: _conversationActions(selected),
|
||||
historyBuilder: (menuContext, close) => ChatHistoryMenu(
|
||||
entries: [
|
||||
for (final item in conversations)
|
||||
(id: item.id, title: item.title),
|
||||
],
|
||||
selectedId: selectedId,
|
||||
error: _conversationError,
|
||||
onSelect: (id) {
|
||||
close();
|
||||
_selectConversation(
|
||||
conversations.firstWhere((item) => item.id == id),
|
||||
);
|
||||
},
|
||||
itemBuilder: (_, id, onSelect) => _conversationRow(
|
||||
conversations.firstWhere((item) => item.id == id),
|
||||
onSelected: onSelect,
|
||||
inMenu: true,
|
||||
),
|
||||
footer: _trashed.isEmpty
|
||||
? null
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Divider(),
|
||||
Padding(
|
||||
padding: ChatHistoryMenu.sectionPadding,
|
||||
child: Text(
|
||||
context.l10n.agentTrash,
|
||||
key: const Key('project-chat-trash-title'),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
for (final item in _trashed)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: ChatHistoryMenu.contentInset,
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 28,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTheme.toolbarTextStyle(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
for (final restore in [true, false])
|
||||
IconButton(
|
||||
tooltip: restore
|
||||
? context.l10n.agentRestore
|
||||
: context.l10n.agentDeleteForever,
|
||||
style: IconButton.styleFrom(
|
||||
fixedSize: const Size.square(24),
|
||||
minimumSize: const Size.square(24),
|
||||
maximumSize: const Size.square(24),
|
||||
padding: EdgeInsets.zero,
|
||||
iconSize: 14,
|
||||
tapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
onPressed: () => restore
|
||||
? _restoreConversation(item)
|
||||
: _deleteForever(item),
|
||||
icon: Icon(
|
||||
restore
|
||||
? AppIcons.undo
|
||||
: AppIcons.delete,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(child: widget.agent),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final compact = MediaQuery.sizeOf(context).height < 520;
|
||||
final headerHeight = widget.externalWindowFrame
|
||||
? 0.0
|
||||
@@ -601,8 +828,12 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
? AppControlSize.panelHeader
|
||||
: AppControlSize.headerButton;
|
||||
final modeTop = headerHeight;
|
||||
final modeHeader = SizedBox(
|
||||
key: const Key('project-content-header'),
|
||||
final legacyModeHeader = SizedBox(
|
||||
key: Key(
|
||||
!_touch && widget.navigationOnly
|
||||
? 'sidebar-window-header'
|
||||
: 'project-content-header',
|
||||
),
|
||||
height:
|
||||
modeTop +
|
||||
(_touch ? AppSidebarMetrics.modeHeight : 0) +
|
||||
@@ -713,7 +944,7 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
),
|
||||
const SizedBox(width: AppSpacing.small),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
AppIcons.expandMore,
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
),
|
||||
],
|
||||
@@ -725,13 +956,89 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
],
|
||||
),
|
||||
);
|
||||
final sectionHeader = !_touch && widget.externalWindowFrame
|
||||
? SizedBox(
|
||||
key: Key(
|
||||
widget.navigationOnly
|
||||
? 'sidebar-projects-header'
|
||||
: 'project-content-header',
|
||||
),
|
||||
height: AppDesktopMetrics.panelHeader,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
widget.resourcesSelected
|
||||
? AppIcons.mediaLibrary
|
||||
: AppIcons.folder,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
key: !widget.resourcesSelected && !widget.librarySelected
|
||||
? const Key('projects-heading')
|
||||
: null,
|
||||
widget.resourcesSelected
|
||||
? context.l10n.materials
|
||||
: widget.librarySelected
|
||||
? context.l10n.navigationLibrary
|
||||
: context.l10n.projects,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
),
|
||||
if (!widget.resourcesSelected && !widget.librarySelected)
|
||||
IconButton(
|
||||
key: const Key('create-project'),
|
||||
tooltip: context.l10n.newProject,
|
||||
onPressed: widget.onCreateProject,
|
||||
icon: const Icon(AppIcons.add, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: legacyModeHeader;
|
||||
final modeHeader = !_touch && widget.navigationOnly
|
||||
? Column(
|
||||
key: const Key('project-content-header'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!widget.externalWindowFrame) legacyModeHeader,
|
||||
if (widget.librarySelected)
|
||||
SizedBox(
|
||||
height: AppDesktopMetrics.panelHeader,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(context.l10n.navigationLibrary),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
SidebarCategoryTabs(
|
||||
mediaSelected: widget.resourcesSelected,
|
||||
onSelected: widget.onResourcesSelected,
|
||||
),
|
||||
if (widget.externalWindowFrame &&
|
||||
!widget.resourcesSelected &&
|
||||
!widget.librarySelected)
|
||||
sectionHeader,
|
||||
],
|
||||
)
|
||||
: sectionHeader;
|
||||
final projectList = SingleChildScrollView(
|
||||
key: const Key('sidebar-projects-conversations'),
|
||||
primary: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (widget.mode == WorkspaceMode.agent || widget.navigationOnly)
|
||||
if ((widget.mode == WorkspaceMode.agent || widget.navigationOnly) &&
|
||||
(_touch || !widget.externalWindowFrame))
|
||||
MouseRegion(
|
||||
onEnter: (_) => setState(() => _projectHeaderHovered = true),
|
||||
onExit: (_) => setState(() => _projectHeaderHovered = false),
|
||||
@@ -813,7 +1120,11 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
onExpansionChanged: (value) =>
|
||||
setState(() => _showTrash = value),
|
||||
trailing: _trashed.isEmpty
|
||||
? null
|
||||
? Icon(
|
||||
_showTrash
|
||||
? AppIcons.expandLess
|
||||
: AppIcons.expandMore,
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: _emptyTrash,
|
||||
child: Text(context.l10n.agentEmptyTrash),
|
||||
@@ -838,28 +1149,25 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
color: AppSidebarColors.of(context).secondary,
|
||||
),
|
||||
),
|
||||
trailing: PopupMenuButton<String>(
|
||||
tooltip: context.l10n.agentConversationActions,
|
||||
onSelected: (value) {
|
||||
if (value == 'restore') {
|
||||
_restoreConversation(item);
|
||||
}
|
||||
if (value == 'delete') _deleteForever(item);
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
height: AppMenuMetrics.rowHeight,
|
||||
value: 'restore',
|
||||
child: Text(context.l10n.agentRestore),
|
||||
trailing: AppDropdownMenu(
|
||||
items: [
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentRestore,
|
||||
onPressed: () => _restoreConversation(item),
|
||||
),
|
||||
PopupMenuItem(
|
||||
height: AppMenuMetrics.rowHeight,
|
||||
value: 'delete',
|
||||
child: Text(
|
||||
context.l10n.agentDeleteForever,
|
||||
),
|
||||
AppMenuItem(
|
||||
label: context.l10n.agentDeleteForever,
|
||||
destructive: true,
|
||||
onPressed: () => _deleteForever(item),
|
||||
),
|
||||
],
|
||||
builder: (context, toggle, focus) => IconButton(
|
||||
focusNode: focus,
|
||||
onPressed: toggle,
|
||||
icon: const Icon(AppIcons.more),
|
||||
tooltip:
|
||||
context.l10n.agentConversationActions,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -883,20 +1191,38 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
child: _touch
|
||||
? projectList
|
||||
: IndexedStack(
|
||||
index: widget.resourcesSelected ? 1 : 0,
|
||||
index: widget.librarySelected
|
||||
? 2
|
||||
: widget.resourcesSelected
|
||||
? 1
|
||||
: 0,
|
||||
children: [
|
||||
TickerMode(
|
||||
enabled: !widget.resourcesSelected,
|
||||
enabled:
|
||||
!widget.resourcesSelected &&
|
||||
!widget.librarySelected,
|
||||
child: projectList,
|
||||
),
|
||||
TickerMode(
|
||||
enabled: widget.resourcesSelected,
|
||||
child: _resourcesVisited
|
||||
? MediaPanel(
|
||||
projectId: widget.state.activeProject?.id,
|
||||
onSelectProject: widget.onSelectProject,
|
||||
)
|
||||
: Center(child: Text(context.l10n.projectsNone)),
|
||||
enabled:
|
||||
widget.resourcesSelected &&
|
||||
!widget.librarySelected,
|
||||
child: ExcludeFocus(
|
||||
excluding:
|
||||
!widget.resourcesSelected ||
|
||||
widget.librarySelected,
|
||||
child: _resourcesVisited
|
||||
? MediaPanel(
|
||||
projectId: widget.state.activeProject?.id,
|
||||
onSelectProject: widget.onSelectProject,
|
||||
)
|
||||
: Center(
|
||||
child: Text(context.l10n.projectsNone),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox.expand(
|
||||
key: Key('resource-library-empty'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -924,7 +1250,6 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
VerticalDivider(
|
||||
key: const Key('sidebar-chat-divider'),
|
||||
width: 1,
|
||||
thickness: 1,
|
||||
color: AppTheme.sidebarDividerColor(context),
|
||||
),
|
||||
Expanded(
|
||||
@@ -981,7 +1306,7 @@ class _ProjectSidebarState extends ConsumerState<ProjectSidebar> {
|
||||
onPressed: widget.onExpandEditor,
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(
|
||||
Icons.vertical_split_outlined,
|
||||
AppIcons.splitVertical,
|
||||
size: AppIconSize.header,
|
||||
),
|
||||
),
|
||||
@@ -1122,7 +1447,9 @@ class _ProjectsHeader extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppSidebarTypography.style(
|
||||
context,
|
||||
fontSize: AppSidebarMetrics.sectionFontSize,
|
||||
fontSize: AppTheme.isDesktop(context)
|
||||
? 13
|
||||
: AppSidebarMetrics.sectionFontSize,
|
||||
weight: FontWeight.w500,
|
||||
color: AppSidebarColors.of(context).section,
|
||||
),
|
||||
@@ -1131,7 +1458,7 @@ class _ProjectsHeader extends StatelessWidget {
|
||||
if (onPressed != null) ...[
|
||||
const SizedBox(width: AppSpacing.tiny),
|
||||
Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
AppIcons.expandMore,
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
color: AppSidebarColors.of(context).secondary,
|
||||
),
|
||||
@@ -1152,7 +1479,7 @@ class _ProjectsHeader extends StatelessWidget {
|
||||
dimension: AppSidebarMetrics.actionSize,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.more_horiz,
|
||||
AppIcons.more,
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
color: AppSidebarColors.of(context).tertiary,
|
||||
),
|
||||
@@ -1172,7 +1499,7 @@ class _ProjectsHeader extends StatelessWidget {
|
||||
tooltip: context.l10n.newProject,
|
||||
onPressed: onCreateProject,
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(Icons.add, size: AppSidebarMetrics.iconSize),
|
||||
icon: const Icon(AppIcons.add, size: AppSidebarMetrics.iconSize),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1187,6 +1514,38 @@ Color _sidebarItemHighlightColor(BuildContext context) =>
|
||||
ButtonStyle sidebarActionButtonStyle(BuildContext context) =>
|
||||
AppTheme.iconButtonStyle(context);
|
||||
|
||||
ButtonStyle _projectActionButtonStyle(BuildContext context) {
|
||||
if (!AppTheme.isDesktop(context)) return sidebarActionButtonStyle(context);
|
||||
final colors = AppSidebarColors.of(context);
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
return sidebarActionButtonStyle(context).copyWith(
|
||||
foregroundColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.disabled)) return colors.disabled;
|
||||
if (states.contains(WidgetState.hovered) ||
|
||||
states.contains(WidgetState.focused) ||
|
||||
states.contains(WidgetState.pressed)) {
|
||||
return accent;
|
||||
}
|
||||
return colors.secondary;
|
||||
}),
|
||||
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
overlayColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.disabled)) return Colors.transparent;
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
return accent.withValues(alpha: .16);
|
||||
}
|
||||
if (states.contains(WidgetState.hovered) ||
|
||||
states.contains(WidgetState.focused)) {
|
||||
return accent.withValues(alpha: .10);
|
||||
}
|
||||
return Colors.transparent;
|
||||
}),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _availabilityLabel(
|
||||
BuildContext context,
|
||||
ProjectAvailability availability,
|
||||
@@ -1228,7 +1587,7 @@ class _ProjectTile extends StatelessWidget {
|
||||
List<Widget> _menuItems(BuildContext context) => [
|
||||
AppMenuItem(
|
||||
label: context.l10n.rename,
|
||||
icon: Icons.drive_file_rename_outline,
|
||||
icon: AppIcons.rename,
|
||||
onPressed: project.availability.canOpen ? onRename : null,
|
||||
),
|
||||
if (sidebarStyle) ...[
|
||||
@@ -1248,14 +1607,20 @@ class _ProjectTile extends StatelessWidget {
|
||||
'${sidebarStyle ? 'sidebar-project' : 'open-project'}-${project.id}',
|
||||
),
|
||||
minTileHeight: sidebarStyle
|
||||
? AppSidebarMetrics.rowHeight
|
||||
? (AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.sidebarRow
|
||||
: AppSidebarMetrics.rowHeight)
|
||||
: project.availability.canOpen
|
||||
? 36
|
||||
: 48,
|
||||
minVerticalPadding: 0,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: sidebarStyle ? 0 : AppSpacing.small,
|
||||
),
|
||||
contentPadding: sidebarStyle
|
||||
? EdgeInsetsDirectional.only(
|
||||
end: AppTheme.isDesktop(context)
|
||||
? AppSidebarMetrics.cellPadding
|
||||
: 0,
|
||||
)
|
||||
: const EdgeInsets.symmetric(horizontal: AppSpacing.small),
|
||||
horizontalTitleGap: sidebarStyle
|
||||
? AppSidebarMetrics.iconGap
|
||||
: AppSpacing.small,
|
||||
@@ -1264,7 +1629,9 @@ class _ProjectTile extends StatelessWidget {
|
||||
titleAlignment: ListTileTitleAlignment.center,
|
||||
selected: active,
|
||||
selectedTileColor: sidebarStyle
|
||||
? Colors.transparent
|
||||
? AppTheme.isDesktop(context)
|
||||
? AppSidebarColors.of(context).hover
|
||||
: Colors.transparent
|
||||
: _sidebarItemHighlightColor(context),
|
||||
textColor: project.availability.canOpen
|
||||
? null
|
||||
@@ -1273,7 +1640,11 @@ class _ProjectTile extends StatelessWidget {
|
||||
? null
|
||||
: Theme.of(context).disabledColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.extraLarge),
|
||||
borderRadius: BorderRadius.circular(
|
||||
sidebarStyle && AppTheme.isDesktop(context)
|
||||
? AppRadius.large
|
||||
: AppRadius.extraLarge,
|
||||
),
|
||||
),
|
||||
hoverColor: sidebarStyle
|
||||
? AppSidebarColors.of(context).hover
|
||||
@@ -1283,7 +1654,9 @@ class _ProjectTile extends StatelessWidget {
|
||||
leading: sidebarStyle
|
||||
? SizedBox(
|
||||
width: AppSidebarMetrics.iconSlotWidth,
|
||||
height: AppSidebarMetrics.rowHeight,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? AppDesktopMetrics.sidebarRow
|
||||
: AppSidebarMetrics.rowHeight,
|
||||
child: IconButton(
|
||||
key: ValueKey('sidebar-project-toggle-${project.id}'),
|
||||
tooltip: expanded
|
||||
@@ -1294,22 +1667,18 @@ class _ProjectTile extends StatelessWidget {
|
||||
onPressed: onToggleExpanded,
|
||||
icon: Icon(
|
||||
!project.availability.canOpen
|
||||
? Icons.folder_off_outlined
|
||||
? AppIcons.folderUnavailable
|
||||
: hovered
|
||||
? (expanded
|
||||
? Icons.keyboard_arrow_down
|
||||
: Icons.chevron_right)
|
||||
: (expanded
|
||||
? Icons.folder_open_outlined
|
||||
: Icons.folder_outlined),
|
||||
? (expanded ? AppIcons.expandMore : AppIcons.chevronRight)
|
||||
: (expanded ? AppIcons.folderOpen : AppIcons.folder),
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
project.availability.canOpen
|
||||
? Icons.folder_outlined
|
||||
: Icons.folder_off_outlined,
|
||||
? AppIcons.folder
|
||||
: AppIcons.folderUnavailable,
|
||||
size: 18,
|
||||
),
|
||||
title: Text(
|
||||
@@ -1319,6 +1688,15 @@ class _ProjectTile extends StatelessWidget {
|
||||
style: sidebarStyle
|
||||
? AppSidebarTypography.style(
|
||||
context,
|
||||
fontSize: AppTheme.isDesktop(context)
|
||||
? 13
|
||||
: AppSidebarMetrics.fontSize,
|
||||
height: AppTheme.isDesktop(context)
|
||||
? 20 / 13
|
||||
: AppSidebarMetrics.lineHeight,
|
||||
weight: AppTheme.isDesktop(context)
|
||||
? FontWeight.w500
|
||||
: FontWeight.w400,
|
||||
color: project.availability.canOpen
|
||||
? AppSidebarColors.of(context).primary
|
||||
: AppSidebarColors.of(context).disabled,
|
||||
@@ -1364,11 +1742,13 @@ class _ProjectTile extends StatelessWidget {
|
||||
builder: (context, toggle) => IconButton(
|
||||
key: ValueKey('sidebar-project-more-${project.id}'),
|
||||
onPressed: toggle,
|
||||
style: sidebarActionButtonStyle(context),
|
||||
style: _projectActionButtonStyle(context),
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(
|
||||
Icons.more_horiz,
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
icon: Icon(
|
||||
AppIcons.more,
|
||||
size: AppTheme.isDesktop(context)
|
||||
? 14
|
||||
: AppSidebarMetrics.iconSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1380,11 +1760,13 @@ class _ProjectTile extends StatelessWidget {
|
||||
key: ValueKey('new-agent-conversation-${project.id}'),
|
||||
tooltip: context.l10n.agentNewConversation,
|
||||
onPressed: onNewConversation,
|
||||
style: sidebarActionButtonStyle(context),
|
||||
style: _projectActionButtonStyle(context),
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(
|
||||
Icons.edit_square,
|
||||
size: AppSidebarMetrics.iconSize,
|
||||
icon: Icon(
|
||||
AppIcons.edit,
|
||||
size: AppTheme.isDesktop(context)
|
||||
? 14
|
||||
: AppSidebarMetrics.iconSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user