| 23 | |
| 24 | /** Initialize the RPC client. Call once on TUI startup. */ |
| 25 | export function initRpcClient(directory: string): void { |
| 26 | const storageDir = getStorageDir(); |
| 27 | // Bump the generation before replacing the client so late notification |
| 28 | // responses from a disposed client are ignored (the WS socket observes the |
| 29 | // new generation and abandons its in-flight connect). |
| 30 | rpcGeneration += 1; |
| 31 | rpcClient = new MagicContextRpcClient(storageDir, directory); |
| 32 | } |
| 33 | |
| 34 | export function getRpcGeneration(): number { |
| 35 | return rpcGeneration; |