From 3935c61d982dd7d366018c54c9e14bb158f27dc1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:38:04 +0000 Subject: [PATCH 1/3] Initial plan From cfc1ba3954b69aa11e0ada8e6c772d8c30405ade Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:46:37 +0000 Subject: [PATCH 2/3] Remove embedded docsite, always use live docs.waveterm.dev Co-authored-by: sawka <2722291+sawka@users.noreply.github.com> --- Taskfile.yml | 21 ----------- docs/package.json | 1 - electron-builder.config.cjs | 1 - emain/docsite.ts | 25 ++----------- emain/emain.ts | 2 +- frontend/app/view/helpview/helpview.tsx | 50 +++---------------------- pkg/docsite/docsite.go | 47 ----------------------- pkg/web/web.go | 3 -- 8 files changed, 9 insertions(+), 141 deletions(-) delete mode 100644 pkg/docsite/docsite.go diff --git a/Taskfile.yml b/Taskfile.yml index fa0ad2a3e9..0682a00065 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -23,7 +23,6 @@ tasks: - dev deps: - npm:install - - docsite:build:embedded - build:backend env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" @@ -37,7 +36,6 @@ tasks: - start deps: - npm:install - - docsite:build:embedded - build:backend env: WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env" @@ -109,24 +107,6 @@ tasks: - docs:npm:install - storybook:build - docsite:build:embedded: - desc: Build the embedded docsite and copy it to dist/docsite - sources: - - "docs/*" - - "docs/src/**/*" - - "docs/docs/**/*" - - "docs/static/**/*" - generates: - - "dist/docsite/**/*" - cmds: - - cd docs && npm run build-embedded - - task: copyfiles:'docs/build/':'dist/docsite' - env: - EMBEDDED: "true" - USE_SIMPLE_CSS_MINIFIER: "true" - deps: - - docs:npm:install - package: desc: Package the application for the current platform. cmds: @@ -134,7 +114,6 @@ tasks: deps: - clean - npm:install - - docsite:build:embedded - build:backend build:frontend:dev: diff --git a/docs/package.json b/docs/package.json index e5acd1849f..86279e5794 100644 --- a/docs/package.json +++ b/docs/package.json @@ -5,7 +5,6 @@ "docusaurus": "docusaurus", "start": "docusaurus start", "build": "docusaurus build", - "build-embedded": "npm run build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", diff --git a/electron-builder.config.cjs b/electron-builder.config.cjs index 8d69f01f88..5a5f631cc3 100644 --- a/electron-builder.config.cjs +++ b/electron-builder.config.cjs @@ -36,7 +36,6 @@ const config = { }, asarUnpack: [ "dist/bin/**/*", // wavesrv and wsh binaries - "dist/docsite/**/*", // the static docsite ], mac: { target: [ diff --git a/emain/docsite.ts b/emain/docsite.ts index 1d7d0affc7..6ee076d2ea 100644 --- a/emain/docsite.ts +++ b/emain/docsite.ts @@ -2,32 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 import { ipcMain } from "electron"; -import { getWebServerEndpoint } from "../frontend/util/endpoints"; -import { fetch } from "../frontend/util/fetchutil"; -const docsiteWebUrl = "https://docs.waveterm.dev/"; -let docsiteUrl: string; +const docsiteUrl = "https://docs.waveterm.dev/"; ipcMain.on("get-docsite-url", (event) => { event.returnValue = docsiteUrl; }); -export async function initDocsite() { - const docsiteEmbeddedUrl = getWebServerEndpoint() + "/docsite/"; - try { - const response = await fetch(docsiteEmbeddedUrl); - if (response.ok) { - console.log("Embedded docsite is running, using embedded version for help view"); - docsiteUrl = docsiteEmbeddedUrl; - } else { - console.log( - "Embedded docsite is not running, using web version for help view", - "status: " + response?.status - ); - docsiteUrl = docsiteWebUrl; - } - } catch (error) { - console.log("Failed to fetch docsite url, using web version for help view", error); - docsiteUrl = docsiteWebUrl; - } +export function initDocsite() { + console.log("Using live docsite at", docsiteUrl); } diff --git a/emain/emain.ts b/emain/emain.ts index 99ad22541f..09050c2da5 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -350,7 +350,7 @@ async function appMain() { checkIfRunningUnderARM64Translation(fullConfig); ensureHotSpareTab(fullConfig); await relaunchBrowserWindows(); - await initDocsite(); + initDocsite(); setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe setTimeout(sendDisplaysTDataEvent, 5000); diff --git a/frontend/app/view/helpview/helpview.tsx b/frontend/app/view/helpview/helpview.tsx index 34d633982f..518d42b5fa 100644 --- a/frontend/app/view/helpview/helpview.tsx +++ b/frontend/app/view/helpview/helpview.tsx @@ -2,16 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 import { BlockNodeModel } from "@/app/block/blocktypes"; -import { getApi, globalStore, WOS } from "@/app/store/global"; +import { globalStore, WOS } from "@/app/store/global"; import { RpcApi } from "@/app/store/wshclientapi"; import { TabRpcClient } from "@/app/store/wshrpcutil"; import { WebView, WebViewModel } from "@/app/view/webview/webview"; -import { fireAndForget } from "@/util/util"; -import { atom, useAtomValue } from "jotai"; -import { useCallback } from "react"; +import { atom } from "jotai"; -const docsiteWebUrl = "https://docs.waveterm.dev/"; -const baseUrlRegex = /http[s]?:\/\/([^:\/])+(:\d+)?/; +const docsiteUrl = "https://docs.waveterm.dev/"; class HelpViewModel extends WebViewModel { get viewComponent(): ViewComponent { @@ -44,24 +41,10 @@ class HelpViewModel extends WebViewModel { }, ]; }); - this.homepageUrl = atom(getApi().getDocsiteUrl()); + this.homepageUrl = atom(docsiteUrl); this.viewType = "help"; this.viewIcon = atom("circle-question"); this.viewName = atom("Help"); - - /* - Add callback to take the current embedded docsite url and return the equivalent page in the public docsite. - The port used by the embedded docsite changes every time the app runs and the current page may be cached from a previous run so we can't trust that it matches the current embedded url. - We have a regex at the top of this file that can extract the base part of the url (i.e. http://127.0.0.1:53288). We'll use this regex to strip the base part of the url from both the current - page and the embedded docsite url. Because we host the embedded docsite at a subdirectory, we also need to strip that (hence the second replace). Then, we can build the public url from whatever's left. - */ - this.modifyExternalUrl = (url: string) => { - const strippedDocsiteUrl = getApi().getDocsiteUrl().replace(baseUrlRegex, ""); - const strippedCurUrl = url.replace(baseUrlRegex, "").replace(strippedDocsiteUrl, ""); - const newUrl = docsiteWebUrl + strippedCurUrl; - console.log("modify-external-url", url, newUrl); - return newUrl; - }; } setZoomFactor(factor: number | null) { @@ -141,32 +124,9 @@ class HelpViewModel extends WebViewModel { } function HelpView(props: ViewComponentProps) { - const model = props.model; - const homepageUrl = useAtomValue(model.homepageUrl); - - // Effect to update the docsite base url when the app restarts, since the webserver port is dynamic - const onFailLoad = useCallback( - (url: string) => - fireAndForget(async () => { - const newDocsiteUrl = getApi().getDocsiteUrl(); - - // Correct the homepage URL, if necessary - if (newDocsiteUrl !== homepageUrl) { - await model.setHomepageUrl(newDocsiteUrl, "block"); - } - - // Correct the base URL of the current page, if necessary - const newBaseUrl = baseUrlRegex.exec(newDocsiteUrl)?.[0]; - const curBaseUrl = baseUrlRegex.exec(url)?.[0]; - if (curBaseUrl && newBaseUrl && curBaseUrl !== newBaseUrl) { - model.loadUrl(url.replace(curBaseUrl, newBaseUrl), "fix-fail-load"); - } - }), - [homepageUrl] - ); return (
- +
); } diff --git a/pkg/docsite/docsite.go b/pkg/docsite/docsite.go deleted file mode 100644 index b4f029b5d7..0000000000 --- a/pkg/docsite/docsite.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2025, Command Line Inc. -// SPDX-License-Identifier: Apache-2.0 - -package docsite - -import ( - "log" - "net/http" - "os" - "path/filepath" - - "github.com/wavetermdev/waveterm/pkg/wavebase" -) - -var docsiteHandler http.Handler - -func GetDocsiteHandler() http.Handler { - docsiteStaticPath := filepath.Join(wavebase.GetWaveAppPath(), "docsite") - stat, err := os.Stat(docsiteStaticPath) - if docsiteHandler == nil { - log.Println("Docsite is nil, initializing") - if err == nil && stat.IsDir() { - log.Printf("Found static site at %s, serving\n", docsiteStaticPath) - docsiteHandler = http.FileServer(HTMLDir{http.Dir(docsiteStaticPath)}) - } else { - log.Printf("Did not find static site at %s, serving not found handler. stat: %v, err: %v\n", docsiteStaticPath, stat, err) - docsiteHandler = http.NotFoundHandler() - } - } - return docsiteHandler -} - -type HTMLDir struct { - d http.Dir -} - -func (d HTMLDir) Open(name string) (http.File, error) { - // Try name as supplied - f, err := d.d.Open(name) - if os.IsNotExist(err) { - // Not found, try with .html - if f, err := d.d.Open(name + ".html"); err == nil { - return f, nil - } - } - return f, err -} diff --git a/pkg/web/web.go b/pkg/web/web.go index d9ce7c1d47..c5571c694b 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -22,7 +22,6 @@ import ( "github.com/gorilla/mux" "github.com/wavetermdev/waveterm/pkg/aiusechat" "github.com/wavetermdev/waveterm/pkg/authkey" - "github.com/wavetermdev/waveterm/pkg/docsite" "github.com/wavetermdev/waveterm/pkg/filestore" "github.com/wavetermdev/waveterm/pkg/panichandler" "github.com/wavetermdev/waveterm/pkg/remote/fileshare" @@ -443,7 +442,6 @@ func MakeUnixListener() (net.Listener, error) { return rtn, nil } -const docsitePrefix = "/docsite/" const schemaPrefix = "/schema/" // blocking @@ -470,7 +468,6 @@ func RunWebServer(listener net.Listener) { gr.HandleFunc("/api/post-chat-message", WebFnWrap(WebFnOpts{AllowCaching: false}, aiusechat.WaveAIPostMessageHandler)) // Other routes without timeout - gr.PathPrefix(docsitePrefix).Handler(http.StripPrefix(docsitePrefix, docsite.GetDocsiteHandler())) gr.PathPrefix(schemaPrefix).Handler(http.StripPrefix(schemaPrefix, schema.GetSchemaHandler())) handler := http.Handler(gr) From 1d69c02f6ac30f768aa33c90707f977979d7b286 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 4 Nov 2025 10:11:02 -0800 Subject: [PATCH 3/3] remove unused funcs, remove from preload, remove docsite.ts --- emain/docsite.ts | 14 -------------- emain/emain.ts | 4 +--- emain/preload.ts | 1 - frontend/types/custom.d.ts | 1 - 4 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 emain/docsite.ts diff --git a/emain/docsite.ts b/emain/docsite.ts deleted file mode 100644 index 6ee076d2ea..0000000000 --- a/emain/docsite.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2025, Command Line Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { ipcMain } from "electron"; - -const docsiteUrl = "https://docs.waveterm.dev/"; - -ipcMain.on("get-docsite-url", (event) => { - event.returnValue = docsiteUrl; -}); - -export function initDocsite() { - console.log("Using live docsite at", docsiteUrl); -} diff --git a/emain/emain.ts b/emain/emain.ts index 09050c2da5..3f21e0552f 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -10,8 +10,6 @@ import * as services from "../frontend/app/store/services"; import { initElectronWshrpc, shutdownWshrpc } from "../frontend/app/store/wshrpcutil-base"; import { fireAndForget, sleep } from "../frontend/util/util"; import { AuthKey, configureAuthKeyRequestInjection } from "./authkey"; -import { initDocsite } from "./docsite"; -import { initIpcHandlers } from "./emain-ipc"; import { getActivityState, getForceQuit, @@ -22,6 +20,7 @@ import { setWasActive, setWasInFg, } from "./emain-activity"; +import { initIpcHandlers } from "./emain-ipc"; import { log } from "./emain-log"; import { makeAppMenu, makeDockTaskbar } from "./emain-menu"; import { @@ -350,7 +349,6 @@ async function appMain() { checkIfRunningUnderARM64Translation(fullConfig); ensureHotSpareTab(fullConfig); await relaunchBrowserWindows(); - initDocsite(); setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe setTimeout(sendDisplaysTDataEvent, 5000); diff --git a/emain/preload.ts b/emain/preload.ts index cc9af57031..587ed9a370 100644 --- a/emain/preload.ts +++ b/emain/preload.ts @@ -14,7 +14,6 @@ contextBridge.exposeInMainWorld("api", { getConfigDir: () => ipcRenderer.sendSync("get-config-dir"), getHomeDir: () => ipcRenderer.sendSync("get-home-dir"), getAboutModalDetails: () => ipcRenderer.sendSync("get-about-modal-details"), - getDocsiteUrl: () => ipcRenderer.sendSync("get-docsite-url"), getWebviewPreload: () => ipcRenderer.sendSync("get-webview-preload"), getZoomFactor: () => ipcRenderer.sendSync("get-zoom-factor"), openNewWindow: () => ipcRenderer.send("open-new-window"), diff --git a/frontend/types/custom.d.ts b/frontend/types/custom.d.ts index 23c51a9b95..90b3bd9427 100644 --- a/frontend/types/custom.d.ts +++ b/frontend/types/custom.d.ts @@ -86,7 +86,6 @@ declare global { getHomeDir: () => string; // get-home-dir getWebviewPreload: () => string; // get-webview-preload getAboutModalDetails: () => AboutModalDetails; // get-about-modal-details - getDocsiteUrl: () => string; // get-docsite-url getZoomFactor: () => number; // get-zoom-factor showContextMenu: (workspaceId: string, menu?: ElectronContextMenuItem[]) => void; // contextmenu-show onContextMenuClick: (callback: (id: string) => void) => void; // contextmenu-click