Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ tasks:
- dev
deps:
- npm:install
- docsite:build:embedded
- build:backend
env:
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
Expand All @@ -37,7 +36,6 @@ tasks:
- start
deps:
- npm:install
- docsite:build:embedded
- build:backend
env:
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
Expand Down Expand Up @@ -109,32 +107,13 @@ 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:
- npm run build:prod && npm exec electron-builder -- -c electron-builder.config.cjs -p never {{.CLI_ARGS}}
deps:
- clean
- npm:install
- docsite:build:embedded
- build:backend

build:frontend:dev:
Expand Down
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion electron-builder.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const config = {
},
asarUnpack: [
"dist/bin/**/*", // wavesrv and wsh binaries
"dist/docsite/**/*", // the static docsite
"dist/schema/**/*", // schema files for Monaco editor
],
mac: {
Expand Down
33 changes: 0 additions & 33 deletions emain/docsite.ts

This file was deleted.

4 changes: 1 addition & 3 deletions emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -350,7 +349,6 @@ async function appMain() {
checkIfRunningUnderARM64Translation(fullConfig);
ensureHotSpareTab(fullConfig);
await relaunchBrowserWindows();
await initDocsite();
setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe
setTimeout(sendDisplaysTDataEvent, 5000);

Expand Down
1 change: 0 additions & 1 deletion emain/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
50 changes: 5 additions & 45 deletions frontend/app/view/helpview/helpview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/?ref=app";

class HelpViewModel extends WebViewModel {
get viewComponent(): ViewComponent {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -141,32 +124,9 @@ class HelpViewModel extends WebViewModel {
}

function HelpView(props: ViewComponentProps<HelpViewModel>) {
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 (
<div className="w-full h-full">
<WebView {...props} onFailLoad={onFailLoad} />
<WebView {...props} />
</div>
);
}
Comment on lines 126 to 132
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Consider adding error handling for network failures.

The removal of the onFailLoad callback means users will see a browser error page if they're offline or if the docs site is inaccessible. This degrades the user experience without providing any context.

Consider implementing:

  • A custom error message when the docs site fails to load
  • An indicator that help requires an internet connection
  • A retry mechanism or link to open docs in browser

Would you like me to suggest an implementation for graceful error handling when the docs site is unavailable?

🤖 Prompt for AI Agents
In frontend/app/view/helpview/helpview.tsx around lines 126 to 132, the WebView
no longer handles load failures so users see the browser error page when offline
or the docs site is down; restore graceful error handling by adding an
onFailLoad handler prop to WebView that sets component state (error message and
offline flag), renders a small fallback UI in place of the WebView showing a
clear custom error message and an indicator that help requires internet, and
provide actions to retry loading (re-render WebView or call reload), and an
“Open in external browser” link (or fallback to local embedded docs) so users
can recover. Ensure the handler captures the load error details for logging and
use accessible buttons for retry/open-external.

Expand Down
1 change: 0 additions & 1 deletion frontend/types/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 0 additions & 47 deletions pkg/docsite/docsite.go

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -443,7 +442,6 @@ func MakeUnixListener() (net.Listener, error) {
return rtn, nil
}

const docsitePrefix = "/docsite/"
const schemaPrefix = "/schema/"

// blocking
Expand All @@ -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)
Expand Down
Loading