"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.RuntimeStatusView = void 0; const vscode = __importStar(require("vscode")); class RuntimeStatusView { static viewType = "codewhale.runtimeStatus"; view; state = { kind: "offline", baseUrl: "http://127.0.0.1:7878", detail: "Runtime has not been checked yet.", }; threads = []; threadsDetail = "Connect to the runtime to load recent threads."; snapshots = []; snapshotsDetail = "Connect to the runtime to load restore points."; resolveWebviewView(view) { this.view = view; view.webview.options = { enableScripts: true }; view.webview.onDidReceiveMessage((message) => { if (message.command === "check") { void vscode.commands.executeCommand("codewhale.checkRuntime"); } else if (message.command === "start") { void vscode.commands.executeCommand("codewhale.startRuntime"); } else if (message.command === "terminal") { void vscode.commands.executeCommand("codewhale.openTerminal"); } else if (message.command === "threads") { void vscode.commands.executeCommand("codewhale.refreshAgentView"); } else if (message.command === "snapshots") { void vscode.commands.executeCommand("codewhale.refreshSnapshots"); } }); this.render(); } update(state) { this.state = state; this.render(); } updateThreads(threads, detail) { this.threads = threads; this.threadsDetail = detail; this.render(); } updateSnapshots(snapshots, detail) { this.snapshots = snapshots; this.snapshotsDetail = detail; this.render(); } render() { if (!this.view) { return; } const badge = labelFor(this.state.kind); const nonce = makeNonce(); const threadsHtml = this.threads.length > 0 ? this.threads.map((thread) => renderThread(thread)).join("") : `
${escapeHtml(this.threadsDetail)}
`; const snapshotsHtml = this.snapshots.length > 0 ? this.snapshots.map((snapshot) => renderSnapshot(snapshot)).join("") : `${escapeHtml(this.snapshotsDetail)}
`; this.view.webview.html = `${escapeHtml(this.state.detail)}
${escapeHtml(this.state.baseUrl)}