Continue roadmap: local TLS and agent review preparation
This commit is contained in:
+26
-1
@@ -48,6 +48,13 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
await _persistSettings(missingDefaults);
|
||||
}
|
||||
final savedModel = settings['selected_model'];
|
||||
final savedWorkspacePaths =
|
||||
(settings['saved_workspace_paths'] as List<dynamic>? ?? const [])
|
||||
.whereType<String>()
|
||||
.map((path) => path.trim())
|
||||
.where((path) => path.isNotEmpty)
|
||||
.toSet()
|
||||
.toList(growable: false);
|
||||
emit(
|
||||
state.copyWith(
|
||||
apiBaseUrl: _api.baseUrl,
|
||||
@@ -60,6 +67,7 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
settings['dark_mode'] is bool
|
||||
? settings['dark_mode']! as bool
|
||||
: false,
|
||||
savedWorkspacePaths: savedWorkspacePaths,
|
||||
),
|
||||
);
|
||||
if (!_settingsStore.persistenceAvailable) {
|
||||
@@ -265,7 +273,17 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
try {
|
||||
final files = await _api.listWorkspaceFiles(path);
|
||||
if (isClosed || state.selectedWorkspacePath != path) return const [];
|
||||
emit(state.copyWith(availableWorkspaceFiles: files));
|
||||
final savedPaths = [
|
||||
...state.savedWorkspacePaths.where((savedPath) => savedPath != path),
|
||||
path,
|
||||
];
|
||||
emit(
|
||||
state.copyWith(
|
||||
availableWorkspaceFiles: files,
|
||||
savedWorkspacePaths: List.unmodifiable(savedPaths),
|
||||
),
|
||||
);
|
||||
await _persistSettings({'saved_workspace_paths': savedPaths});
|
||||
return files;
|
||||
} catch (error) {
|
||||
if (!isClosed) {
|
||||
@@ -281,6 +299,13 @@ class ChatCubit extends Cubit<ChatState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> removeSavedWorkspace(String path) async {
|
||||
final savedPaths =
|
||||
state.savedWorkspacePaths.where((savedPath) => savedPath != path).toList();
|
||||
emit(state.copyWith(savedWorkspacePaths: List.unmodifiable(savedPaths)));
|
||||
return _persistSettings({'saved_workspace_paths': savedPaths});
|
||||
}
|
||||
|
||||
void selectWorkspaceFiles(List<String> paths) {
|
||||
if (state.isSending || paths.length > 3) return;
|
||||
final available = state.availableWorkspaceFiles.toSet();
|
||||
|
||||
@@ -156,6 +156,7 @@ class ChatState {
|
||||
this.selectedWorkspacePath,
|
||||
this.availableWorkspaceFiles = const [],
|
||||
this.selectedWorkspaceFiles = const [],
|
||||
this.savedWorkspacePaths = const [],
|
||||
this.isWebSearchMode = false,
|
||||
this.error,
|
||||
this.modelName = 'جارٍ اكتشاف النموذج…',
|
||||
@@ -183,6 +184,7 @@ class ChatState {
|
||||
final String? selectedWorkspacePath;
|
||||
final List<String> availableWorkspaceFiles;
|
||||
final List<String> selectedWorkspaceFiles;
|
||||
final List<String> savedWorkspacePaths;
|
||||
final bool isWebSearchMode;
|
||||
final String? error;
|
||||
final String modelName;
|
||||
@@ -214,6 +216,7 @@ class ChatState {
|
||||
bool clearSelectedWorkspacePath = false,
|
||||
List<String>? availableWorkspaceFiles,
|
||||
List<String>? selectedWorkspaceFiles,
|
||||
List<String>? savedWorkspacePaths,
|
||||
bool? isWebSearchMode,
|
||||
String? error,
|
||||
bool clearError = false,
|
||||
@@ -256,6 +259,7 @@ class ChatState {
|
||||
availableWorkspaceFiles ?? this.availableWorkspaceFiles,
|
||||
selectedWorkspaceFiles:
|
||||
selectedWorkspaceFiles ?? this.selectedWorkspaceFiles,
|
||||
savedWorkspacePaths: savedWorkspacePaths ?? this.savedWorkspacePaths,
|
||||
isWebSearchMode: isWebSearchMode ?? this.isWebSearchMode,
|
||||
error: clearError ? null : (error ?? this.error),
|
||||
modelName: modelName ?? this.modelName,
|
||||
|
||||
Reference in New Issue
Block a user