Use bridge session client for desktop gateway runtime

This commit is contained in:
Haitao Pan 2026-04-11 09:59:21 +08:00
parent 4763e7853b
commit bf33d90d33
5 changed files with 23 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import '../runtime/gateway_acp_client.dart';
import '../runtime/codex_runtime.dart';
import '../runtime/codex_config_bridge.dart';
import '../runtime/code_agent_node_orchestrator.dart';
import '../runtime/go_gateway_runtime_desktop_client.dart';
import '../runtime/assistant_artifacts.dart';
import '../runtime/desktop_thread_artifact_service.dart';
import '../runtime/external_code_agent_acp_desktop_transport.dart';
@ -142,6 +143,7 @@ class AppController extends ChangeNotifier {
gateway: GatewayRuntime(
store: storeInternal,
identityStore: DeviceIdentityStore(storeInternal),
sessionClient: GoGatewayRuntimeDesktopClient(),
allowDirectSocketFallbackOnSessionClientFailure:
shouldBlockEmbeddedAgentLaunch(
isAppleHost: Platform.isIOS || Platform.isMacOS,

View File

@ -100,6 +100,9 @@ class GatewayRuntime extends ChangeNotifier with GatewayRuntimeHelpersInternal {
appendLogInternal(this, level, category, message);
}
@visibleForTesting
bool get usesSessionClient => sessionClientInternal != null;
Future<void> initialize() async {
sessionUpdatesInternal ??= sessionClientInternal?.updates.listen(
_handleSessionUpdateInternal,

View File

@ -46,6 +46,8 @@ class GoAcpStdioBridge {
Stream<Map<String, dynamic>> get notifications =>
_notificationsController.stream;
bool get isStarted => _process != null || _startupFuture != null;
Future<Map<String, dynamic>> request({
required String method,
required Map<String, dynamic> params,

View File

@ -67,6 +67,9 @@ class GoGatewayRuntimeDesktopClient implements GatewayRuntimeSessionClient {
@override
Future<void> disconnect({required String runtimeId}) async {
if (!_bridge.isStarted) {
return;
}
await _request(
method: 'xworkmate.gateway.disconnect',
params: <String, dynamic>{'runtimeId': runtimeId},

View File

@ -0,0 +1,13 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:xworkmate/app/app_controller_desktop_core.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('default desktop controller wires gateway runtime through bridge client', () {
final controller = AppController();
addTearDown(controller.dispose);
expect(controller.runtime.usesSessionClient, isTrue);
});
}