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

fix: fix app.mjs panic and create settings.json on startup #481

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

tylerslaton
Copy link
Contributor

@tylerslaton tylerslaton commented Sep 10, 2024

There were some issues that were not caught in the last PR because a lot of the reviewers already had settings files. I didn't catch it while programming the settings page up for the same reason, to fix this this PR does 3 things.

  1. The socket server now will use default settings if the settings file does not exist. This shouldn't happen, but just in case. This was an issue because of...
  2. Create the settings.json file in the correct place, it was previously in the workspace dir which was incorrect. We now also only create it if it doesn't already exist.
  3. Fixes an issue where the users could not set browser settings persistently. (noticed while fixing the root issue, but was not a cause of the root issue).

#480
https://acorn-io.slack.com/archives/C03FU91U4SX/p1725985732395979

@tylerslaton tylerslaton marked this pull request as ready for review September 10, 2024 17:13
g-linville
g-linville previously approved these changes Sep 10, 2024
// If the app settings file doesn't exist, create it with default settings.
if (!existsSync(config.appSettingsFile)) {
writeFileSync(
config.appSettingsFile, // created in config.mjs
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think this comment is out of date?

Suggested change
config.appSettingsFile, // created in config.mjs
config.appSettingsFile,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its new, I added it just now. What's wrong with it?

headless: true,
},
};
if (existsSync(settingsLocation)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: probably more safe to use default setting when file exists and parsing is correct, otherwise fallback to default file. In case the setting file is corrupted...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@StrongMonkey Can you take another look? I added some things to defend against malformed files.

StrongMonkey
StrongMonkey previously approved these changes Sep 10, 2024
@tylerslaton tylerslaton merged commit e6f2a4a into gptscript-ai:main Sep 10, 2024
1 check passed
@tylerslaton tylerslaton deleted the issue-480 branch September 10, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants