mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 18:24:21 +01:00
local web
This commit is contained in:
@@ -12,7 +12,9 @@ import Home from "@/pages"
|
|||||||
const host = import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "127.0.0.1"
|
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 = import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"
|
||||||
|
|
||||||
const url = new URLSearchParams(document.location.search).get("url") || `http://${host}:${port}`
|
const url =
|
||||||
|
new URLSearchParams(document.location.search).get("url") ||
|
||||||
|
(location.hostname.includes("opencode.ai") ? `http://${host}:${port}` : "/")
|
||||||
|
|
||||||
const root = document.getElementById("root")
|
const root = document.getElementById("root")
|
||||||
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
|
||||||
|
|||||||
@@ -358,6 +358,7 @@ function App() {
|
|||||||
|
|
||||||
event.on(SessionApi.Event.Deleted.type, (evt) => {
|
event.on(SessionApi.Event.Deleted.type, (evt) => {
|
||||||
if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
|
if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
|
||||||
|
dialog.clear()
|
||||||
route.navigate({ type: "home" })
|
route.navigate({ type: "home" })
|
||||||
toast.show({
|
toast.show({
|
||||||
variant: "info",
|
variant: "info",
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export function DialogSessionList() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
setToDelete(undefined)
|
setToDelete(undefined)
|
||||||
dialog.clear()
|
// dialog.clear()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setToDelete(option.value)
|
setToDelete(option.value)
|
||||||
|
|||||||
@@ -26,12 +26,15 @@ export const WebCommand = cmd({
|
|||||||
port,
|
port,
|
||||||
hostname,
|
hostname,
|
||||||
})
|
})
|
||||||
const url = `https://desktop.dev.opencode.ai?url=${server.url}`
|
|
||||||
UI.empty()
|
UI.empty()
|
||||||
UI.println(UI.logo(" "))
|
UI.println(UI.logo(" "))
|
||||||
UI.empty()
|
UI.empty()
|
||||||
UI.println(UI.Style.TEXT_INFO_BOLD + " Web interface: ", UI.Style.TEXT_NORMAL, url)
|
UI.println(
|
||||||
open(url).catch(() => {})
|
UI.Style.TEXT_INFO_BOLD + " Web interface: ",
|
||||||
|
UI.Style.TEXT_NORMAL,
|
||||||
|
server.url.toString(),
|
||||||
|
)
|
||||||
|
open(server.url.toString()).catch(() => {})
|
||||||
await new Promise(() => {})
|
await new Promise(() => {})
|
||||||
await server.stop()
|
await server.stop()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { Hono } from "hono"
|
import { Hono } from "hono"
|
||||||
import { cors } from "hono/cors"
|
import { cors } from "hono/cors"
|
||||||
import { stream, streamSSE } from "hono/streaming"
|
import { stream, streamSSE } from "hono/streaming"
|
||||||
|
import { proxy } from "hono/proxy"
|
||||||
import { Session } from "../session"
|
import { Session } from "../session"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { Provider } from "../provider/provider"
|
import { Provider } from "../provider/provider"
|
||||||
@@ -1696,7 +1697,15 @@ export namespace Server {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
|
.all("/*", async (c) => {
|
||||||
|
return proxy(`https://desktop.dev.opencode.ai${c.req.path}`, {
|
||||||
|
...c.req,
|
||||||
|
headers: {
|
||||||
|
host: "desktop.dev.opencode.ai",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export async function openapi() {
|
export async function openapi() {
|
||||||
|
|||||||
Reference in New Issue
Block a user