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

feat: Save user preference for crashes after confirmation dialog #417

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions src/config/comfySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import log from 'electron-log/main';
export const DEFAULT_SETTINGS: ComfySettingsData = {
'Comfy-Desktop.AutoUpdate': true,
'Comfy-Desktop.SendStatistics': true,
'Comfy-Desktop.AlwaysSendCrashReports': false,
'Comfy.ColorPalette': 'dark',
'Comfy.UseNewMenu': 'Top',
'Comfy.Workflow.WorkflowTabsPosition': 'Topbar',
Expand All @@ -15,6 +16,7 @@ export const DEFAULT_SETTINGS: ComfySettingsData = {
export interface ComfySettingsData {
'Comfy-Desktop.AutoUpdate': boolean;
'Comfy-Desktop.SendStatistics': boolean;
'Comfy-Desktop.AlwaysSendCrashReports': boolean;
'Comfy.Server.LaunchArgs': Record<string, string>;
[key: string]: unknown;
}
Expand All @@ -39,11 +41,16 @@ export class ComfySettings {
this.settings = JSON.parse(fileContent);
}

public saveSettings() {
fs.writeFileSync(this.filePath, JSON.stringify(this.settings), 'utf-8');
Copy link
Member

Choose a reason for hiding this comment

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

This is very problematic as the file content can be newer than the snapshot state when we read it during electron app start.

}

get<K extends keyof ComfySettingsData>(key: K): ComfySettingsData[K] {
return this.settings[key] ?? DEFAULT_SETTINGS[key];
}

set<K extends keyof ComfySettingsData>(key: K, value: ComfySettingsData[K]) {
this.settings[key] = value;
this.saveSettings();
}
}
13 changes: 10 additions & 3 deletions src/services/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ class SentryLogging {
beforeSend: async (event) => {
this.filterEvent(event);

const alwaysSendCrashReports = this.comfyDesktopApp?.comfySettings?.get('Comfy-Desktop.AlwaysSendCrashReports');

if (
event.extra?.comfyUIExecutionError ||
this.comfyDesktopApp?.comfySettings.get('Comfy-Desktop.SendStatistics')
this.comfyDesktopApp?.comfySettings.get('Comfy-Desktop.SendStatistics') ||
alwaysSendCrashReports
) {
return event;
}
Expand All @@ -28,11 +31,15 @@ class SentryLogging {
title: 'Send Crash Report',
message: `An error occurred: ${errorType}`,
detail: `${errorMessage}\n\nWould you like to send the crash to the team?`,
buttons: ['Send Report', 'Do not send crash report'],
buttons: ['Send Report', 'Always send crash reports', 'Do not send crash report'],
type: 'error',
});

return response === 0 ? event : null;
if (response === 1) {
this.comfyDesktopApp?.comfySettings?.set('Comfy-Desktop.AlwaysSendCrashReports', true);
}

return response !== 2 ? event : null;
},
integrations: [
Sentry.childProcessIntegration({
Expand Down
Loading