Add remote access controls

This commit is contained in:
Shantur Rathore
2025-12-03 21:52:42 +00:00
parent 976430d61c
commit 94cb741c7f
23 changed files with 1165 additions and 29 deletions

View File

@@ -0,0 +1,28 @@
import { runtimeEnv } from "../runtime-env"
export async function restartCli(): Promise<boolean> {
try {
if (runtimeEnv.host === "electron") {
const api = (window as typeof window & { electronAPI?: { restartCli?: () => Promise<unknown> } }).electronAPI
if (api?.restartCli) {
await api.restartCli()
return true
}
return false
}
if (runtimeEnv.host === "tauri") {
const tauri = (window as typeof window & { __TAURI__?: { invoke?: <T = unknown>(cmd: string, args?: Record<string, unknown>) => Promise<T> } }).__TAURI__
if (tauri?.invoke) {
await tauri.invoke("cli_restart")
return true
}
return false
}
} catch (error) {
console.error("Failed to restart CLI", error)
return false
}
return false
}

View File

@@ -4,8 +4,8 @@ import { serverApi } from "./api-client"
let cachedMeta: ServerMeta | null = null
let pendingMeta: Promise<ServerMeta> | null = null
export async function getServerMeta(): Promise<ServerMeta> {
if (cachedMeta) {
export async function getServerMeta(forceRefresh = false): Promise<ServerMeta> {
if (cachedMeta && !forceRefresh) {
return cachedMeta
}
if (pendingMeta) {