feat: register local agent project workspaces

This commit is contained in:
Hamza Ayed
2026-10-04 01:57:44 +03:00
parent d29275043a
commit 1feeb372a4
12 changed files with 806 additions and 45 deletions
@@ -271,7 +271,7 @@ class ChatCubit extends Cubit<ChatState> {
),
);
try {
final files = await _api.listWorkspaceFiles(path);
final files = await _api.registerWorkspaceProject(path);
if (isClosed || state.selectedWorkspacePath != path) return const [];
final savedPaths = [
...state.savedWorkspacePaths.where((savedPath) => savedPath != path),
@@ -300,9 +300,26 @@ class ChatCubit extends Cubit<ChatState> {
}
Future<bool> removeSavedWorkspace(String path) async {
try {
await _api.unregisterWorkspaceProject(path);
} catch (error) {
if (!isClosed) emit(state.copyWith(error: _readableError(error)));
return false;
}
final savedPaths =
state.savedWorkspacePaths.where((savedPath) => savedPath != path).toList();
emit(state.copyWith(savedWorkspacePaths: List.unmodifiable(savedPaths)));
state.savedWorkspacePaths
.where((savedPath) => savedPath != path)
.toList();
final isSelected = state.selectedWorkspacePath == path;
emit(
state.copyWith(
savedWorkspacePaths: List.unmodifiable(savedPaths),
isWorkspaceMode: isSelected ? false : null,
clearSelectedWorkspacePath: isSelected,
availableWorkspaceFiles: isSelected ? const [] : null,
selectedWorkspaceFiles: isSelected ? const [] : null,
),
);
return _persistSettings({'saved_workspace_paths': savedPaths});
}