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

Make comfy settings instance accessible from anywhere #863

Merged
merged 7 commits into from
Feb 9, 2025

Conversation

christian-byrne
Copy link
Contributor

@christian-byrne christian-byrne commented Feb 7, 2025

Changes ComfySettings to use same initialization and access pattern as DesktopConfig, making the current instance accessible from any module.

This enables the Sentry class to check whether the user consents to metrics during the installation process, so that installation errors can be manually captured and sent to Sentry. Previously, Sentry was not able to easily access the current settings instance.

┆Issue is synchronized with this Notion page by Unito

@christian-byrne christian-byrne requested review from a team as code owners February 7, 2025 23:02
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Feb 7, 2025
@christian-byrne christian-byrne marked this pull request as draft February 7, 2025 23:41
@christian-byrne christian-byrne marked this pull request as ready for review February 7, 2025 23:50
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 8, 2025
const comfySettings = new ComfySettings(installWizard.basePath);
await comfySettings.loadSettings();
const installation = new ComfyInstallation('started', installWizard.basePath, this.telemetry, comfySettings);
const installation = new ComfyInstallation('started', installWizard.basePath, this.telemetry);
InstallationManager.setReinstallHandler(installation);
Copy link
Contributor Author

@christian-byrne christian-byrne Feb 8, 2025

Choose a reason for hiding this comment

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

Previously, installWizard would read existing settings, add install options, then write, then installationManager would initialize settings.

Now, installWizard does the same as before but also initializes the settings instance at the same time, making it unecessary for installationManager to do it.

@christian-byrne christian-byrne changed the title Make comfy settings a singleton Make comfy settings instance accessible from any module Feb 8, 2025
@christian-byrne christian-byrne changed the title Make comfy settings instance accessible from any module Make comfy settings instance accessible from anywhere Feb 8, 2025
Copy link
Contributor

@webfiltered webfiltered left a comment

Choose a reason for hiding this comment

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

We have one bug left to squash for 0.4.18, then this PR can be merged immediately after the release is cut.

@@ -102,9 +115,13 @@ export class ComfySettings implements IComfySettings {
const fileContent = await fs.readFile(this.filePath, 'utf8');
// TODO: Reimplement with validation and error reporting.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.settings = JSON.parse(fileContent);
this.settings = { ...this.settings, ...JSON.parse(fileContent) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Flagging just in case: Not sure if this is a runtime change to settings or not (e.g. if setting has been changed in existing user file then later reset, does this result in a net change?).

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 9, 2025
@webfiltered webfiltered merged commit 01697a0 into main Feb 9, 2025
7 checks passed
@webfiltered webfiltered deleted the cb-settings-singleton branch February 9, 2025 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants