refactor(desktop): move Tauri remote proxy into packages/server

This commit is contained in:
Shantur Rathore
2026-04-19 13:18:30 +01:00
parent d456ae5837
commit d0ddefc168
13 changed files with 1808 additions and 71 deletions

View File

@@ -16,6 +16,7 @@ import { showAlertDialog } from "../stores/alerts"
import { openSettings, settingsOpen } from "../stores/settings-screen"
import { openExternalUrl } from "../lib/external-url"
import { serverApi } from "../lib/api-client"
import { runtimeEnv } from "../lib/runtime-env"
import { openRemoteServerWindow } from "../lib/native/remote-window"
const codeNomadLogo = new URL("../images/CodeNomad-Icon.png", import.meta.url).href
@@ -332,7 +333,15 @@ const FolderSelectionView: Component<FolderSelectionViewProps> = (props) => {
})
if (openWindow) {
await openRemoteServerWindow(profile)
const windowUrl =
runtimeEnv.host === "tauri"
? (await serverApi.createRemoteProxySession({
baseUrl: profile.baseUrl,
skipTlsVerify: profile.skipTlsVerify,
})).windowUrl
: undefined
await openRemoteServerWindow(profile, windowUrl)
await markRemoteServerConnected(profile.id)
}

View File

@@ -12,6 +12,8 @@ import type {
SpeechTranscriptionResponse,
SideCar,
ServerMeta,
RemoteProxySessionCreateRequest,
RemoteProxySessionCreateResponse,
RemoteServerProbeRequest,
RemoteServerProbeResponse,
VoiceModeStateResponse,
@@ -256,6 +258,12 @@ export const serverApi = {
body: JSON.stringify(payload),
})
},
createRemoteProxySession(payload: RemoteProxySessionCreateRequest): Promise<RemoteProxySessionCreateResponse> {
return request<RemoteProxySessionCreateResponse>("/api/remote-proxy/sessions", {
method: "POST",
body: JSON.stringify(payload),
})
},
fetchAuthStatus(): Promise<{ authenticated: boolean; username?: string; passwordUserProvided?: boolean }> {
return request<{ authenticated: boolean; username?: string; passwordUserProvided?: boolean }>("/api/auth/status")
},

View File

@@ -6,14 +6,19 @@ export interface RemoteWindowOpenPayload {
id: string
name: string
baseUrl: string
entryUrl?: string
skipTlsVerify: boolean
}
export async function openRemoteServerWindow(profile: Pick<RemoteServerProfile, "id" | "name" | "baseUrl" | "skipTlsVerify">): Promise<void> {
export async function openRemoteServerWindow(
profile: Pick<RemoteServerProfile, "id" | "name" | "baseUrl" | "skipTlsVerify">,
entryUrl?: string,
): Promise<void> {
const payload: RemoteWindowOpenPayload = {
id: profile.id,
name: profile.name,
baseUrl: profile.baseUrl,
entryUrl,
skipTlsVerify: profile.skipTlsVerify,
}

View File

@@ -37,6 +37,7 @@ declare global {
id: string
name: string
baseUrl: string
entryUrl?: string
skipTlsVerify: boolean
}) => Promise<{ ok: boolean }>
}