Skip to content

Commit a23bbc0

Browse files
Copilotsawka
andauthored
Remove embedded docsite, always use live docs.waveterm.dev (#2503)
Removes the embedded Docusaurus build from the application. The help view now always loads from https://docs.waveterm.dev/ instead of serving a locally bundled copy. This eliminates package size constraints on documentation content (e.g., videos) and removes unnecessary build/packaging overhead. **Backend changes:** - Deleted `pkg/docsite` package entirely - Removed docsite handler from `pkg/web/web.go` - Simplified `emain/docsite.ts` to return constant URL instead of probing for embedded docs **Frontend changes:** - Removed embedded URL translation logic from `helpview.tsx` - Homepage URL now uses constant instead of IPC call **Build configuration:** - Removed `docsite:build:embedded` task and all references - Removed `dist/docsite/**/*` from electron-builder asarUnpack - Removed `build-embedded` script from docs package.json Net result: -141 lines, +9 lines across 8 files. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > right now we build a docusaurus project to run both the online docs at docs.waveterm.dev AND to embed into the application. but this limits what we can show in the docs (especially large things like videos etc.) > > the internal docs already fall back to the website when it cannot find the embedded docs. > > i'd like to update the build and packaging etc to no longer build the embedded doc site. i'd also like to have the "help" view always render the live doc site at https://docs.waveterm.dev. </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
1 parent 2bf1bcc commit a23bbc0

File tree

10 files changed

+6
-156
lines changed

10 files changed

+6
-156
lines changed

Taskfile.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ tasks:
2323
- dev
2424
deps:
2525
- npm:install
26-
- docsite:build:embedded
2726
- build:backend
2827
env:
2928
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
@@ -37,7 +36,6 @@ tasks:
3736
- start
3837
deps:
3938
- npm:install
40-
- docsite:build:embedded
4139
- build:backend
4240
env:
4341
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
@@ -109,32 +107,13 @@ tasks:
109107
- docs:npm:install
110108
- storybook:build
111109

112-
docsite:build:embedded:
113-
desc: Build the embedded docsite and copy it to dist/docsite
114-
sources:
115-
- "docs/*"
116-
- "docs/src/**/*"
117-
- "docs/docs/**/*"
118-
- "docs/static/**/*"
119-
generates:
120-
- "dist/docsite/**/*"
121-
cmds:
122-
- cd docs && npm run build-embedded
123-
- task: copyfiles:'docs/build/':'dist/docsite'
124-
env:
125-
EMBEDDED: "true"
126-
USE_SIMPLE_CSS_MINIFIER: "true"
127-
deps:
128-
- docs:npm:install
129-
130110
package:
131111
desc: Package the application for the current platform.
132112
cmds:
133113
- npm run build:prod && npm exec electron-builder -- -c electron-builder.config.cjs -p never {{.CLI_ARGS}}
134114
deps:
135115
- clean
136116
- npm:install
137-
- docsite:build:embedded
138117
- build:backend
139118

140119
build:frontend:dev:

docs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"docusaurus": "docusaurus",
66
"start": "docusaurus start",
77
"build": "docusaurus build",
8-
"build-embedded": "npm run build",
98
"swizzle": "docusaurus swizzle",
109
"deploy": "docusaurus deploy",
1110
"clear": "docusaurus clear",

electron-builder.config.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const config = {
3636
},
3737
asarUnpack: [
3838
"dist/bin/**/*", // wavesrv and wsh binaries
39-
"dist/docsite/**/*", // the static docsite
4039
"dist/schema/**/*", // schema files for Monaco editor
4140
],
4241
mac: {

emain/docsite.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

emain/emain.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import * as services from "../frontend/app/store/services";
1010
import { initElectronWshrpc, shutdownWshrpc } from "../frontend/app/store/wshrpcutil-base";
1111
import { fireAndForget, sleep } from "../frontend/util/util";
1212
import { AuthKey, configureAuthKeyRequestInjection } from "./authkey";
13-
import { initDocsite } from "./docsite";
14-
import { initIpcHandlers } from "./emain-ipc";
1513
import {
1614
getActivityState,
1715
getForceQuit,
@@ -22,6 +20,7 @@ import {
2220
setWasActive,
2321
setWasInFg,
2422
} from "./emain-activity";
23+
import { initIpcHandlers } from "./emain-ipc";
2524
import { log } from "./emain-log";
2625
import { makeAppMenu, makeDockTaskbar } from "./emain-menu";
2726
import {
@@ -350,7 +349,6 @@ async function appMain() {
350349
checkIfRunningUnderARM64Translation(fullConfig);
351350
ensureHotSpareTab(fullConfig);
352351
await relaunchBrowserWindows();
353-
await initDocsite();
354352
setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe
355353
setTimeout(sendDisplaysTDataEvent, 5000);
356354

emain/preload.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ contextBridge.exposeInMainWorld("api", {
1414
getConfigDir: () => ipcRenderer.sendSync("get-config-dir"),
1515
getHomeDir: () => ipcRenderer.sendSync("get-home-dir"),
1616
getAboutModalDetails: () => ipcRenderer.sendSync("get-about-modal-details"),
17-
getDocsiteUrl: () => ipcRenderer.sendSync("get-docsite-url"),
1817
getWebviewPreload: () => ipcRenderer.sendSync("get-webview-preload"),
1918
getZoomFactor: () => ipcRenderer.sendSync("get-zoom-factor"),
2019
openNewWindow: () => ipcRenderer.send("open-new-window"),

frontend/app/view/helpview/helpview.tsx

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { BlockNodeModel } from "@/app/block/blocktypes";
5-
import { getApi, globalStore, WOS } from "@/app/store/global";
5+
import { globalStore, WOS } from "@/app/store/global";
66
import { RpcApi } from "@/app/store/wshclientapi";
77
import { TabRpcClient } from "@/app/store/wshrpcutil";
88
import { WebView, WebViewModel } from "@/app/view/webview/webview";
9-
import { fireAndForget } from "@/util/util";
10-
import { atom, useAtomValue } from "jotai";
11-
import { useCallback } from "react";
9+
import { atom } from "jotai";
1210

13-
const docsiteWebUrl = "https://docs.waveterm.dev/";
14-
const baseUrlRegex = /http[s]?:\/\/([^:\/])+(:\d+)?/;
11+
const docsiteUrl = "https://docs.waveterm.dev/?ref=app";
1512

1613
class HelpViewModel extends WebViewModel {
1714
get viewComponent(): ViewComponent {
@@ -44,24 +41,10 @@ class HelpViewModel extends WebViewModel {
4441
},
4542
];
4643
});
47-
this.homepageUrl = atom(getApi().getDocsiteUrl());
44+
this.homepageUrl = atom(docsiteUrl);
4845
this.viewType = "help";
4946
this.viewIcon = atom("circle-question");
5047
this.viewName = atom("Help");
51-
52-
/*
53-
Add callback to take the current embedded docsite url and return the equivalent page in the public docsite.
54-
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.
55-
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
56-
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.
57-
*/
58-
this.modifyExternalUrl = (url: string) => {
59-
const strippedDocsiteUrl = getApi().getDocsiteUrl().replace(baseUrlRegex, "");
60-
const strippedCurUrl = url.replace(baseUrlRegex, "").replace(strippedDocsiteUrl, "");
61-
const newUrl = docsiteWebUrl + strippedCurUrl;
62-
console.log("modify-external-url", url, newUrl);
63-
return newUrl;
64-
};
6548
}
6649

6750
setZoomFactor(factor: number | null) {
@@ -141,32 +124,9 @@ class HelpViewModel extends WebViewModel {
141124
}
142125

143126
function HelpView(props: ViewComponentProps<HelpViewModel>) {
144-
const model = props.model;
145-
const homepageUrl = useAtomValue(model.homepageUrl);
146-
147-
// Effect to update the docsite base url when the app restarts, since the webserver port is dynamic
148-
const onFailLoad = useCallback(
149-
(url: string) =>
150-
fireAndForget(async () => {
151-
const newDocsiteUrl = getApi().getDocsiteUrl();
152-
153-
// Correct the homepage URL, if necessary
154-
if (newDocsiteUrl !== homepageUrl) {
155-
await model.setHomepageUrl(newDocsiteUrl, "block");
156-
}
157-
158-
// Correct the base URL of the current page, if necessary
159-
const newBaseUrl = baseUrlRegex.exec(newDocsiteUrl)?.[0];
160-
const curBaseUrl = baseUrlRegex.exec(url)?.[0];
161-
if (curBaseUrl && newBaseUrl && curBaseUrl !== newBaseUrl) {
162-
model.loadUrl(url.replace(curBaseUrl, newBaseUrl), "fix-fail-load");
163-
}
164-
}),
165-
[homepageUrl]
166-
);
167127
return (
168128
<div className="w-full h-full">
169-
<WebView {...props} onFailLoad={onFailLoad} />
129+
<WebView {...props} />
170130
</div>
171131
);
172132
}

frontend/types/custom.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ declare global {
8686
getHomeDir: () => string; // get-home-dir
8787
getWebviewPreload: () => string; // get-webview-preload
8888
getAboutModalDetails: () => AboutModalDetails; // get-about-modal-details
89-
getDocsiteUrl: () => string; // get-docsite-url
9089
getZoomFactor: () => number; // get-zoom-factor
9190
showContextMenu: (workspaceId: string, menu?: ElectronContextMenuItem[]) => void; // contextmenu-show
9291
onContextMenuClick: (callback: (id: string) => void) => void; // contextmenu-click

pkg/docsite/docsite.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

pkg/web/web.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/gorilla/mux"
2323
"github.com/wavetermdev/waveterm/pkg/aiusechat"
2424
"github.com/wavetermdev/waveterm/pkg/authkey"
25-
"github.com/wavetermdev/waveterm/pkg/docsite"
2625
"github.com/wavetermdev/waveterm/pkg/filestore"
2726
"github.com/wavetermdev/waveterm/pkg/panichandler"
2827
"github.com/wavetermdev/waveterm/pkg/remote/fileshare"
@@ -443,7 +442,6 @@ func MakeUnixListener() (net.Listener, error) {
443442
return rtn, nil
444443
}
445444

446-
const docsitePrefix = "/docsite/"
447445
const schemaPrefix = "/schema/"
448446

449447
// blocking
@@ -470,7 +468,6 @@ func RunWebServer(listener net.Listener) {
470468
gr.HandleFunc("/api/post-chat-message", WebFnWrap(WebFnOpts{AllowCaching: false}, aiusechat.WaveAIPostMessageHandler))
471469

472470
// Other routes without timeout
473-
gr.PathPrefix(docsitePrefix).Handler(http.StripPrefix(docsitePrefix, docsite.GetDocsiteHandler()))
474471
gr.PathPrefix(schemaPrefix).Handler(http.StripPrefix(schemaPrefix, schema.GetSchemaHandler()))
475472

476473
handler := http.Handler(gr)

0 commit comments

Comments
 (0)