feat: register local agent project workspaces
This commit is contained in:
+20
-3
@@ -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});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user