feat: the files panel uses the server's gitignored setting

- OpenChamber keeps filesViewShowGitignored in its profile settings (the web
  UI's "Display gitignored files"); the client now reads it in
  refreshChatSettings instead of starting from a local false, so a server
  that shows ignored files shows them here too
- toggling "Show git-ignored files" writes the same key back through
  PUT /api/config/settings (surface=mobile) and reloads the listing; a
  failed save restores the previous value and reports the error
- while the panel is open, a change to the setting from another client
  reloads the list with the new filter
- version 0.6.3+603; tests cover reading, writing and rollback
This commit is contained in:
blumia committed 2026-11-27 17:44:36 +08:00
1 parent 8ac36b1fb1
commit ba3c820186
6 files changed
+154 -9

No files matched your search

+33
View File
@@ -109,6 +109,11 @@ class AppState extends ChangeNotifier {
/// `allowPromptingSubagentSessions`).
bool allowPromptingSubagentSessions = false;
/// Server setting (`filesViewShowGitignored`): the files panel also lists
/// files git ignores. Shared with the web UI's profile settings; off when
/// the server has never written it.
bool showGitignored = false;
/// OpenChamber's own agent tools — the web client's 通用 page: what the
/// agent may do inside a chat, and what it may know about the person and the
/// project. Server-backed (`/api/config/settings`), shared with the web UI;
@@ -203,6 +208,7 @@ class AppState extends ChangeNotifier {
followUpBehavior = normalizeFollowUp(settings['followUpBehavior']);
allowPromptingSubagentSessions =
settings['allowPromptingSubagentSessions'] == true;
showGitignored = settings['filesViewShowGitignored'] == true;
_applyToolSettings(settings);
notifyListeners();
} catch (_) {}
@@ -264,6 +270,33 @@ class AppState extends ChangeNotifier {
}
}
/// Shows or hides gitignored files in the files panel and writes the same
/// server setting the web UI keeps (`filesViewShowGitignored`). The switch
/// moves at once; a failed save puts the previous value back.
Future<bool> setShowGitignored(bool value) async {
final before = showGitignored;
if (value == before) return true;
showGitignored = value;
notifyListeners();
final cl = client;
if (cl == null) return true;
try {
final settings =
await cl.saveSettings({'filesViewShowGitignored': value});
if (client != cl) return true;
showGitignored = settings['filesViewShowGitignored'] as bool? ?? value;
notifyListeners();
return true;
} catch (e) {
if (client == cl) {
showGitignored = before;
_lastError = trArgs('Couldn\'t save: {0}', [e]);
notifyListeners();
}
return false;
}
}
Future<void> init() async {
connections = await storage.connections();
if (connections.isNotEmpty) {