From ec70ce8c918f90362b4bd5cbb5e1a84959a859d7 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 22 Oct 2024 18:17:42 -0700 Subject: [PATCH 1/3] Display error message on failed WebView page load (#1072) closes #1023 --- frontend/app/view/webview/webview.less | 19 +++++++++++ frontend/app/view/webview/webview.tsx | 44 ++++++++++++++++---------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/frontend/app/view/webview/webview.less b/frontend/app/view/webview/webview.less index ed104a478..d84d5ccda 100644 --- a/frontend/app/view/webview/webview.less +++ b/frontend/app/view/webview/webview.less @@ -9,6 +9,7 @@ overflow: hidden; padding: 0; margin: 0; + user-select: none; // try to force pixel alignment to prevent // subpixel rendering artifacts @@ -16,6 +17,24 @@ will-change: transform; } +.webview-error { + display: flex; + position: absolute; + background-color: black; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 100; + div { + font-size: x-large; + color: red; + display: flex; + margin: auto; + padding: 30px; + } +} + .block-frame-div-url { background: rgba(255, 255, 255, 0.1); diff --git a/frontend/app/view/webview/webview.tsx b/frontend/app/view/webview/webview.tsx index 376e8e9c5..d9f038a73 100644 --- a/frontend/app/view/webview/webview.tsx +++ b/frontend/app/view/webview/webview.tsx @@ -13,7 +13,7 @@ import { fireAndForget } from "@/util/util"; import clsx from "clsx"; import { WebviewTag } from "electron"; import { Atom, PrimitiveAtom, atom, useAtomValue } from "jotai"; -import React, { memo, useEffect, useState } from "react"; +import { Fragment, createRef, memo, useEffect, useRef, useState } from "react"; import "./webview.less"; let webviewPreloadUrl = null; @@ -68,8 +68,8 @@ export class WebViewModel implements ViewModel { this.refreshIcon = atom("rotate-right"); this.viewIcon = atom("globe"); this.viewName = atom("Web"); - this.urlInputRef = React.createRef(); - this.webviewRef = React.createRef(); + this.urlInputRef = createRef(); + this.webviewRef = createRef(); this.mediaPlaying = atom(false); this.mediaMuted = atom(false); @@ -477,7 +477,7 @@ const WebView = memo(({ model, onFailLoad }: WebViewProps) => { const defaultSearch = useAtomValue(defaultSearchAtom); let metaUrl = blockData?.meta?.url || defaultUrl; metaUrl = model.ensureUrlScheme(metaUrl, defaultSearch); - const metaUrlRef = React.useRef(metaUrl); + const metaUrlRef = useRef(metaUrl); // The initial value of the block metadata URL when the component first renders. Used to set the starting src value for the webview. const [metaUrlInitial] = useState(metaUrl); @@ -485,6 +485,8 @@ const WebView = memo(({ model, onFailLoad }: WebViewProps) => { const [webContentsId, setWebContentsId] = useState(null); const [domReady, setDomReady] = useState(false); + const [errorText, setErrorText] = useState(""); + function setBgColor() { const webview = model.webviewRef.current; if (!webview) { @@ -532,6 +534,7 @@ const WebView = memo(({ model, onFailLoad }: WebViewProps) => { return; } const navigateListener = (e: any) => { + setErrorText(""); model.handleNavigate(e.url); }; const newWindowHandler = (e: any) => { @@ -554,7 +557,9 @@ const WebView = memo(({ model, onFailLoad }: WebViewProps) => { if (e.errorCode === -3) { console.warn("Suppressed ERR_ABORTED error", e); } else { - console.error(`Failed to load ${e.validatedURL}: ${e.errorDescription}`); + const errorMessage = `Failed to load ${e.validatedURL}: ${e.errorDescription}`; + console.error(errorMessage); + setErrorText(errorMessage); if (onFailLoad) { const curUrl = model.webviewRef?.current.getURL(); onFailLoad(curUrl); @@ -608,17 +613,24 @@ const WebView = memo(({ model, onFailLoad }: WebViewProps) => { }, []); return ( - + + + {errorText && ( +
+
{errorText}
+
+ )} +
); }); From 9cccc585d4a6b7a02169fb0acc2ac4760d5d3edd Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 22 Oct 2024 18:52:34 -0700 Subject: [PATCH 2/3] Add config to direct folks to alternative issue sources (#1104) --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 14 ++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 3de761fb7..084c8f9d2 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,4 +1,4 @@ -name: Bug Report +name: 🐞 Bug Report description: Create a bug report to help us improve. title: "[Bug]: " labels: ["bug", "triage"] diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..179e68f59 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: true +contact_links: + - name: Reporting a security vulnerability + url: https://github.com/wavetermdev/waveterm/blob/main/SECURITY.md + about: Please review our security policy for more details + - name: General Question + url: https://github.com/wavetermdev/waveterm/discussions + about: Have a question on something? Start a new discussion thread. + - name: Engage with us directly on Discord + url: https://discord.gg/XfvZ334gwU + about: Join our Discord server to get updates on new features, bug fixes, and more. + - name: Review open issues + url: https://github.com/wavetermdev/waveterm/issues + about: Please check if your issue isn't already there. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index 75f0b4652..e7a2e3f6e 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,4 +1,4 @@ -name: Feature Request +name: 🚀 Feature Request / Idea description: Suggest a new idea for this project. title: "[Feature]: " labels: ["enhancement", "triage"] From fdab5eabd7f8c8cd65797bf5bd170dc3fa3c268d Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 22 Oct 2024 18:55:44 -0700 Subject: [PATCH 3/3] Remove extra security policy direction (#1105) --- .github/ISSUE_TEMPLATE/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 179e68f59..cd5fa92c2 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,5 @@ blank_issues_enabled: true contact_links: - - name: Reporting a security vulnerability - url: https://github.com/wavetermdev/waveterm/blob/main/SECURITY.md - about: Please review our security policy for more details - name: General Question url: https://github.com/wavetermdev/waveterm/discussions about: Have a question on something? Start a new discussion thread.