From 89bcf805bc9ed74538bea259014e38d23f621cb8 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 7 Feb 2026 22:25:12 -0700 Subject: [PATCH] Fix editor hang when launched without orchestrator The JsonRpcClient was reading from stdin on startup, blocking forever when no orchestrator process was piped in. Now defaults to disconnected state and skips RPC calls, falling back to sample content. Co-Authored-By: Claude Opus 4.6 --- editor/src/main.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/editor/src/main.cpp b/editor/src/main.cpp index 3ed30d1..8d3bbc6 100644 --- a/editor/src/main.cpp +++ b/editor/src/main.cpp @@ -24,24 +24,30 @@ private: FILE* rpc_in; // For receiving responses from orchestrator public: - JsonRpcClient() : rpc_out(stdout), rpc_in(stdin) {} - - // Constructor that could connect to orchestrator process (simplified for now) - JsonRpcClient(FILE* out, FILE* in) : rpc_out(out), rpc_in(in) {} - + bool connected; + + JsonRpcClient() : rpc_out(nullptr), rpc_in(nullptr), connected(false) {} + + // Constructor that connects to orchestrator process + JsonRpcClient(FILE* out, FILE* in) : rpc_out(out), rpc_in(in), connected(out && in) {} + + bool isConnected() const { return connected; } + json call(const std::string& method, const json& params = json::object()) { + if (!connected) return json(nullptr); + // Create the JSON-RPC request json request = json::object({ {"jsonrpc", "2.0"}, {"method", method}, {"params", params}, - {"id", 1} // Simple ID for this example + {"id", 1} }); - + // Send the request to the orchestrator fprintf(rpc_out, "%s\n", request.dump().c_str()); fflush(rpc_out); - + // Read the response from the orchestrator char buffer[4096]; if (fgets(buffer, sizeof(buffer), rpc_in)) { @@ -58,7 +64,7 @@ public: return json(nullptr); } } - + return json(nullptr); } };