private async handleCheckNodeState()

in src/panels/TcpDumpPanel.ts [131:209]


    private async handleCheckNodeState(node: NodeName, webview: MessageSink<ToWebViewMsgDef>) {
        const podNames = await this.getPodNames();
        if (failed(podNames)) {
            webview.postCheckNodeStateResponse({
                node,
                succeeded: false,
                errorMessage: `Failed to get debug pod names:\n${podNames.error}`,
                isDebugPodRunning: false,
                runningCapture: null,
                completedCaptures: [],
            });
            return;
        }

        const isDebugPodRunning = podNames.result.includes(getPodName(node));
        if (!isDebugPodRunning) {
            webview.postCheckNodeStateResponse({
                node,
                succeeded: true,
                errorMessage: null,
                isDebugPodRunning,
                runningCapture: null,
                completedCaptures: [],
            });
            return;
        }

        const waitResult = await this.waitForPodReady(node);
        if (failed(waitResult)) {
            webview.postCheckNodeStateResponse({
                node,
                succeeded: false,
                errorMessage: `Pod ${getPodName(node)} is not ready:\n${waitResult.error}`,
                isDebugPodRunning,
                runningCapture: null,
                completedCaptures: [],
            });
            return;
        }

        const runningCaptureProcs = await this.getRunningCaptures(node);
        if (failed(runningCaptureProcs)) {
            webview.postCheckNodeStateResponse({
                node,
                succeeded: false,
                errorMessage: `Failed to read running captures:\n${runningCaptureProcs.error}`,
                isDebugPodRunning,
                runningCapture: null,
                completedCaptures: [],
            });
            return;
        }

        const runningCapture = runningCaptureProcs.result.length > 0 ? runningCaptureProcs.result[0].capture : null;
        const completedCaptures = await this.getCompletedCaptures(
            node,
            runningCaptureProcs.result.map((p) => p.capture),
        );
        if (failed(completedCaptures)) {
            webview.postCheckNodeStateResponse({
                node,
                succeeded: false,
                errorMessage: `Failed to read completed captures:\n${completedCaptures.error}`,
                isDebugPodRunning,
                runningCapture,
                completedCaptures: [],
            });
            return;
        }

        webview.postCheckNodeStateResponse({
            node,
            succeeded: true,
            errorMessage: null,
            isDebugPodRunning,
            runningCapture,
            completedCaptures: completedCaptures.result,
        });
    }