Loading files
442335385This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/openharness-1322671404.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
442335385This file is pinned to the selected release. Download the original to open it in your design tool.
import 'local_key_value_store.dart';
/// Remembers an agent choice, independently of a machine, profile or permission.
class AgentPreference {
AgentPreference(this.storage);
final LocalKeyValueStore? storage;
static const _key = 'new_agent_engine';
String? value;
Future<void>? _loading;
Future<void> _writes = Future.value();
int _revision = 0;
Future<void> load() => _loading ??= _read();
Future<void> _read() async {
final revision = _revision;
try {
final stored = await storage?.read(_key);
if (revision == _revision && revision == 0) value = stored;
} catch (_) {
/* A missing preference never blocks a new agent. */
}
}
Future<void> select(String engine) {
_revision++;
value = engine;
return _writes = _writes.then((_) async {
try {
await storage?.write(_key, engine);
} catch (_) {
/* Keep the current choice usable if persistence fails. */
}
});
}
}