Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show forum link when error is encountered. #192

Merged
merged 2 commits into from
Nov 6, 2024
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export const IPC_CHANNELS = {
GET_MODEL_CONFIG_PATH: 'get-model-config-path',
OPEN_PATH: 'open-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...';

Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -201,6 +205,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, () => {
Expand Down
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 2 additions & 10 deletions src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Home: React.FC = () => {
const [status, setStatus] = useState('Starting...');
const [logs, setLogs] = useState<string[]>([]);
const [defaultInstallLocation, setDefaultInstallLocation] = useState<string>('');
const electronAPI: ElectronAPI = (window as any)[ELECTRON_BRIDGE_API];

const updateProgress = useCallback(({ status: newStatus }: ProgressUpdate) => {
log.info(`Setting new status: ${newStatus}`);
Expand Down Expand Up @@ -59,28 +60,19 @@ 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);
});
}, [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 (
<div style={bodyStyle}>
Expand All @@ -91,7 +83,7 @@ const Home: React.FC = () => {

return (
<div style={bodyStyle}>
<ProgressOverlay status={status} logs={logs} />
<ProgressOverlay status={status} logs={logs} openForum={() => electronAPI.openForum()} />
</div>
);
};
Expand Down
31 changes: 29 additions & 2 deletions src/renderer/screens/ProgressOverlay.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -45,14 +46,40 @@ const logContainerStyle: React.CSSProperties = {
interface ProgressOverlayProps {
status: string;
logs: string[];
openForum: () => void;
}

const ProgressOverlay: React.FC<ProgressOverlayProps> = ({ status, logs }) => {
const linkStyle: React.CSSProperties = {
color: '#3391ff', // Bright blue that works well on dark background
textDecoration: 'underline',
cursor: 'pointer',
};

const ProgressOverlay: React.FC<ProgressOverlayProps> = ({ status, logs, openForum }) => {
const linkOptions = {
render: ({ attributes, content }: { attributes: any; content: string }) => {
const { href, ...props } = attributes;
return (
<a
{...props}
href={href}
style={linkStyle}
onClick={(e) => {
e.preventDefault();
openForum();
}}
>
{content}
</a>
);
},
};

return (
<div style={outerContainerStyle}>
<div style={containerStyle}>
<div style={loadingTextStyle} id="loading-text">
{status}
<Linkify options={linkOptions}>{status}</Linkify>
</div>
<div style={logContainerStyle}>
{status !== COMFY_FINISHING_MESSAGE && status !== COMFY_ERROR_MESSAGE && <AnimatedLogDisplay logs={logs} />}
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading