mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
tui: pass dynamic port to frontend
Frontend now receives the server port via window.__OPENCODE__.port, allowing it to connect when using a random free port instead of hardcoded 4096
This commit is contained in:
parent
58e66dd3d1
commit
86f7cc17ae
3 changed files with 9 additions and 8 deletions
|
|
@ -15,8 +15,14 @@ import { GlobalSDKProvider } from "./context/global-sdk"
|
|||
import { SessionProvider } from "./context/session"
|
||||
import { Show } from "solid-js"
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__OPENCODE__?: { updaterEnabled?: boolean; port?: number }
|
||||
}
|
||||
}
|
||||
|
||||
const host = import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "127.0.0.1"
|
||||
const port = import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"
|
||||
const port = window.__OPENCODE__?.port ?? import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"
|
||||
|
||||
const url =
|
||||
new URLSearchParams(document.location.search).get("url") ||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,8 @@ pub fn run() {
|
|||
.initialization_script(format!(
|
||||
r#"
|
||||
window.__OPENCODE__ ??= {{}};
|
||||
window.__OPENCODE__.updaterEnabled = {updater_enabled}
|
||||
window.__OPENCODE__.updaterEnabled = {updater_enabled};
|
||||
window.__OPENCODE__.port = {port};
|
||||
"#
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -47,12 +47,6 @@ const platform: Platform = {
|
|||
},
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__OPENCODE__?: { updaterEnabled?: boolean }
|
||||
}
|
||||
}
|
||||
|
||||
render(() => {
|
||||
onMount(() => {
|
||||
if (window.__OPENCODE__?.updaterEnabled) runUpdater()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue