feat(app): register native Settings on the shared live session

This commit is contained in:
2026-10-21 18:55:50 +01:00
parent 7b327f012b
commit d05aa0cfbc
15 changed files with 278 additions and 54 deletions
+9 -4
View File
@@ -18,13 +18,14 @@ enum RunSubscriptionState { pending, live, refused }
/// `subscribe` on every connected transition because a new socket has no
/// watch, and drops it deliberately with `unsubscribe` when the app stops.
class AppSession extends ChangeNotifier {
AppSession({required this.endpoint, PipelinesClient? client})
: _client = client ?? PipelinesClient() {
AppSession({required Uri? endpoint, PipelinesClient? client})
: _initialEndpoint = endpoint,
_client = client ?? PipelinesClient() {
_states = _client.states.listen(_onState);
_frames = _client.frames.listen(_onFrame);
}
final Uri? endpoint;
final Uri? _initialEndpoint;
final PipelinesClient _client;
late final StreamSubscription<ConnectionState> _states;
late final StreamSubscription<JsonMap> _frames;
@@ -36,6 +37,10 @@ class AppSession extends ChangeNotifier {
String? _subscribeRequest;
ApiGateway get gateway => _client;
/// Settings controls the same transport; it must never create another socket.
PipelinesClient get client => _client;
Uri? get endpoint => _client.endpoint ?? _initialEndpoint;
ConnectionState get connection => _connection;
bool get connected => _connection.kind == ConnectionKind.connected;
@@ -62,7 +67,7 @@ class AppSession extends ChangeNotifier {
/// Retries now: reopens a disconnected socket, or repeats a refused watch on
/// a healthy one.
Future<void> retry() async {
if (connected) {
if (_client.state.kind == ConnectionKind.connected) {
resubscribe();
return;
}