()((set, get) => ({
current.client?.disconnect();
- const endpoint = resolveEndpoint();
- const transportOptions = resolveTransportOptions();
+ // Determine which connection to use
+ let targetConnectionId = connectionId || current.selectedConnectionId;
+
+ // If no explicit connection specified, check available connections
+ if (!targetConnectionId) {
+ const connections = current.availableConnections;
+
+ if (connections.length === 0) {
+ // No connections available - show modal
+ set({ showConnectionModal: true });
+ return;
+ } else if (connections.length === 1) {
+ // Auto-connect to the only available connection
+ targetConnectionId = connections[0].id;
+ } else {
+ // Multiple connections - show modal for selection
+ set({ showConnectionModal: true });
+ return;
+ }
+ }
+
+ // Find the connection details
+ const connection = current.availableConnections.find((c) => c.id === targetConnectionId);
+ if (!connection) {
+ set({
+ connectionState: "error",
+ connectionError: "Selected connection not found",
+ });
+ return;
+ }
+
+ const endpoint = connection.id;
+ const transportOptions = connection.mode === "wasm" ? { channelName: endpoint } : undefined;
const client = new DebuggerClient({
- mode: appConfig.mode,
+ mode: connection.mode,
endpoint,
transportOptions,
});
+ // Subscribe to transport state changes to keep connectionState in sync
+ client.onTransportStateChange((state, event) => {
+ console.log("Transport state changed:", state, event);
+
+ if (state === "closed") {
+ const currentClient = get().client;
+ // Only update if this is still the active client
+ if (currentClient === client) {
+ set({
+ connectionState: "error",
+ connectionError: "Connection closed",
+ });
+ }
+ } else if (state === "open") {
+ const currentClient = get().client;
+ if (currentClient === client) {
+ set({
+ connectionState: "connected",
+ });
+ }
+ }
+ });
+
set({
connectionState: "connecting",
connectionError: undefined,
endpoint,
client,
+ selectedConnectionId: targetConnectionId,
+ showConnectionModal: false,
});
try {
diff --git a/index.html b/index.html
index 79b0b57..04b1197 100644
--- a/index.html
+++ b/index.html
@@ -89,7 +89,7 @@ Latest CI/CD downloads
Go to the builds page.
WASM embed
- Open Debugger for WASM embed | Open Debugger w/ mock server
+ Open Devtools for WASM embed
@@ -369,7 +369,9 @@
Historical Downloads
-
+
+
+