fix(settings): ensure manual bridge configuration is applied correctly and improve storage fallback

This commit is contained in:
Haitao Pan 2026-04-17 17:41:02 +08:00
parent a7362f651e
commit f06e20479a
3 changed files with 13 additions and 1162 deletions

File diff suppressed because it is too large Load Diff

View File

@ -123,7 +123,6 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
);
await widget.controller.settingsController.saveSnapshot(nextSettings);
if (isManual && _bridgeTokenController.text.isNotEmpty) {
await widget.controller.settingsController.saveSecretValueByRef(
nextSettings.acpBridgeServerModeConfig.selfHosted.passwordRef,
@ -132,6 +131,8 @@ class _SettingsPageState extends State<SettingsPage> {
module: 'Manual',
);
}
await widget.controller.saveSettings(nextSettings);
_lastSavedAccountBaseUrl = nextSettings.accountBaseUrl;
_lastSavedAccountIdentifier = nextSettings.accountUsername;
_lastSavedBridgeUrl = nextSettings.acpBridgeServerModeConfig.selfHosted.serverUrl;

View File

@ -143,7 +143,17 @@ class StoreLayoutResolver {
await _resolvePath(_supportRootPathResolver) ??
await _defaultSupportRootPath();
if (supportRootPath == null) {
throw StateError('Cannot resolve persistent storage root.');
// Fallback to a temporary directory instead of failing fast with an error.
// This ensures the app remains usable in "memory-only" or "ephemeral" mode.
final tempDir = await Directory.systemTemp.createTemp('xworkmate-fallback-');
final layout = StoreLayout(
rootDirectory: tempDir,
configDirectory: await ensureDirectory('${tempDir.path}/config'),
tasksDirectory: await ensureDirectory('${tempDir.path}/tasks'),
secretDirectory: await ensureDirectory('${tempDir.path}/secrets'),
);
_cached = layout;
return layout;
}
final appDataRootPath =
await _resolvePath(_appDataRootPathResolver) ?? supportRootPath;