From c3f65183b3bb0692a562fe577a0432288177ba2f Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Tue, 5 Nov 2024 20:08:48 -0800 Subject: [PATCH] Show forum link when error is encountered. (#192) * Add forum link to error. * Prettier. --- package.json | 2 ++ src/constants.ts | 3 ++- src/main.ts | 5 ++++ src/preload.ts | 3 +++ src/renderer/index.tsx | 12 ++------- src/renderer/screens/ProgressOverlay.tsx | 31 ++++++++++++++++++++++-- yarn.lock | 19 +++++++++++++++ 7 files changed, 62 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index e0895b4e..c1623bc4 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,8 @@ "electron-log": "^5.2.0", "electron-store": "8.2.0", "jest": "^29.7.0", + "linkify-react": "^4.1.3", + "linkifyjs": "^4.1.3", "react": "^18.3.1", "react-dom": "^18.3.1", "systeminformation": "^5.23.5", diff --git a/src/constants.ts b/src/constants.ts index c43ab425..96c22a0d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -24,10 +24,11 @@ export const IPC_CHANNELS = { OPEN_PATH: 'open-path', OPEN_LOGS_PATH: 'open-logs-path', OPEN_DEV_TOOLS: 'open-dev-tools', + OPEN_FORUM: 'open-forum', } as const; export const COMFY_ERROR_MESSAGE = - 'Was not able to start ComfyUI. Please check the logs for more details. You can open it from the tray icon.'; + 'Was not able to start ComfyUI. Please check the logs for more details. You can open it from the Help menu. Please report issues to: https://forum.comfy.org'; export const COMFY_FINISHING_MESSAGE = 'Finishing...'; diff --git a/src/main.ts b/src/main.ts index 72e042f2..ce143c12 100644 --- a/src/main.ts +++ b/src/main.ts @@ -188,6 +188,10 @@ if (!gotTheLock) { } } }); + ipcMain.handle(IPC_CHANNELS.OPEN_FORUM, () => { + shell.openExternal('https://forum.comfy.org'); + }); + ipcMain.handle(IPC_CHANNELS.OPEN_DIALOG, (event, options: Electron.OpenDialogOptions) => { log.info('Open dialog'); return dialog.showOpenDialogSync({ @@ -204,6 +208,7 @@ if (!gotTheLock) { return modelConfigPath; }); ipcMain.on(IPC_CHANNELS.OPEN_PATH, (event, folderPath: string) => { + log.info(`Opening path: ${folderPath}`); shell.openPath(folderPath); }); ipcMain.on(IPC_CHANNELS.OPEN_DEV_TOOLS, () => { diff --git a/src/preload.ts b/src/preload.ts index 148e10b4..daab7a74 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -87,6 +87,9 @@ const electronAPI = { const modelConfigPath = await electronAPI.getModelConfigPath(); ipcRenderer.send(IPC_CHANNELS.OPEN_PATH, modelConfigPath); }, + openForum: () => { + ipcRenderer.invoke(IPC_CHANNELS.OPEN_FORUM); + }, /** * Open the developer tools window. */ diff --git a/src/renderer/index.tsx b/src/renderer/index.tsx index ebe7f087..ff4c5c6a 100644 --- a/src/renderer/index.tsx +++ b/src/renderer/index.tsx @@ -30,6 +30,7 @@ const Home: React.FC = () => { const [status, setStatus] = useState('Starting...'); const [logs, setLogs] = useState([]); const [defaultInstallLocation, setDefaultInstallLocation] = useState(''); + const electronAPI: ElectronAPI = (window as any)[ELECTRON_BRIDGE_API]; const updateProgress = useCallback(({ status: newStatus }: ProgressUpdate) => { log.info(`Setting new status: ${newStatus}`); @@ -59,10 +60,7 @@ const Home: React.FC = () => { }, []); useEffect(() => { - const electronAPI: ElectronAPI = (window as any)[ELECTRON_BRIDGE_API]; - electronAPI.onProgressUpdate(updateProgress); - electronAPI.onLogMessage((message: string) => { log.info(`Received log message: ${message}`); addLogMessage(message); @@ -70,17 +68,11 @@ const Home: React.FC = () => { }, [updateProgress, addLogMessage]); useEffect(() => { - const electronAPI: ElectronAPI = (window as any)[ELECTRON_BRIDGE_API]; - electronAPI.onDefaultInstallLocation((location: string) => { setDefaultInstallLocation(location); }); }, []); - if (showSetup === null) { - return <> Loading ....; - } - if (showSetup) { return (
@@ -91,7 +83,7 @@ const Home: React.FC = () => { return (
- + electronAPI.openForum()} />
); }; diff --git a/src/renderer/screens/ProgressOverlay.tsx b/src/renderer/screens/ProgressOverlay.tsx index 75053716..fe35d398 100644 --- a/src/renderer/screens/ProgressOverlay.tsx +++ b/src/renderer/screens/ProgressOverlay.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { COMFY_ERROR_MESSAGE, COMFY_FINISHING_MESSAGE } from 'src/constants'; import AnimatedLogDisplay from './AnimatedLogDisplay'; +import Linkify from 'linkify-react'; const loadingTextStyle: React.CSSProperties = { marginBottom: '20px', @@ -45,14 +46,40 @@ const logContainerStyle: React.CSSProperties = { interface ProgressOverlayProps { status: string; logs: string[]; + openForum: () => void; } -const ProgressOverlay: React.FC = ({ status, logs }) => { +const linkStyle: React.CSSProperties = { + color: '#3391ff', // Bright blue that works well on dark background + textDecoration: 'underline', + cursor: 'pointer', +}; + +const ProgressOverlay: React.FC = ({ status, logs, openForum }) => { + const linkOptions = { + render: ({ attributes, content }: { attributes: any; content: string }) => { + const { href, ...props } = attributes; + return ( + { + e.preventDefault(); + openForum(); + }} + > + {content} + + ); + }, + }; + return (
- {status} + {status}
{status !== COMFY_FINISHING_MESSAGE && status !== COMFY_ERROR_MESSAGE && } diff --git a/yarn.lock b/yarn.lock index a47e26ad..5fb9b9f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4868,6 +4868,8 @@ __metadata: eslint-plugin-import: "npm:^2.25.0" husky: "npm:^9.1.6" jest: "npm:^29.7.0" + linkify-react: "npm:^4.1.3" + linkifyjs: "npm:^4.1.3" lint-staged: "npm:^15.2.10" prettier: "npm:^3.3.3" react: "npm:^18.3.1" @@ -8618,6 +8620,23 @@ __metadata: languageName: node linkType: hard +"linkify-react@npm:^4.1.3": + version: 4.1.3 + resolution: "linkify-react@npm:4.1.3" + peerDependencies: + linkifyjs: ^4.0.0 + react: ">= 15.0.0" + checksum: 10c0/c8c0e96301c3fbe5df19110dd778f4f0004f7c2f127fecb192ba9d4cf3e581d59f7d99ab0311c72a99cf039f5b34421e6ce71f2fcdd90f51655d7736fed4b370 + languageName: node + linkType: hard + +"linkifyjs@npm:^4.1.3": + version: 4.1.3 + resolution: "linkifyjs@npm:4.1.3" + checksum: 10c0/9fb71da06ee710b5587c8b61ff9a0e45303d448f61fab135e44652cff95c09c1abe276158a72384cff6f35a2371d1cec33dfaa7e5280b71dbb142b43d210c75a + languageName: node + linkType: hard + "lint-staged@npm:^15.2.10": version: 15.2.10 resolution: "lint-staged@npm:15.2.10"