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: browser settings in the settings page #440

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

g-linville
Copy link
Member

@g-linville g-linville commented Sep 5, 2024

for #321

Signed-off-by: Grant Linville <grant@acorn.io>
Comment on lines +9 to +25
function browserSettingsLocation() {
const homeDir = os.homedir();
let configDir;
if (os.platform() === 'darwin') {
configDir =
process.env.XDG_CONFIG_HOME ||
join(homeDir, 'Library', 'Application Support');
} else if (os.platform() === 'win32') {
configDir = join(homeDir, 'AppData', 'Local');
} else if (os.platform() === 'linux') {
configDir = process.env.XDG_CONFIG_HOME || join(homeDir, '.config');
} else {
throw new Error('Unsupported platform');
}

return join(configDir, 'acorn', 'browsersettings.json');
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I hate how this function is duplicated from actions/browser.tsx. But I'm not sure if there is a way for me to define it in one place and have it be callable from both places. Please let me know if there is a way to do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

That I personally know of, no. I've had a lot of similar headaches. Ideally we'd make a global lib package that both the Next app and electron could import. To do that right though I think we'd need the socket server and config code to be in typescript so it isn't super simple in just this PR.

@@ -31,6 +31,7 @@ async function startServer() {
process.env.WORKSPACE_DIR = config.workspaceDir;
process.env.GPTSCRIPT_GATEWAY_URL = config.gatewayUrl;
process.env.GPTSCRIPT_OPENAPI_REVAMP = 'true';
process.env.GPTSCRIPT_BROWSER_SETTINGS_FILE = config.browserSettingsFile;
Copy link
Member Author

Choose a reason for hiding this comment

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

This environment variable is read by the browser tool itself so that it knows where to look for its settings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that for various tools that have settings that they will all have their own settings files?

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose so, but right now the browser tool is the only tool that reads any kind of settings file for itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. No need to prematurely optimize yet, just wanted to understand for the future.

Signed-off-by: Grant Linville <grant@acorn.io>
@g-linville g-linville marked this pull request as ready for review September 5, 2024 19:17
ryanhopperlowe
ryanhopperlowe previously approved these changes Sep 6, 2024
tylerslaton
tylerslaton previously approved these changes Sep 6, 2024
Copy link
Contributor

@tylerslaton tylerslaton left a comment

Choose a reason for hiding this comment

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

Had a small nit I'd like to see implemented and some questions as well. However, I'll approve since this functionally does as it sets out to do.

@@ -31,6 +31,7 @@ async function startServer() {
process.env.WORKSPACE_DIR = config.workspaceDir;
process.env.GPTSCRIPT_GATEWAY_URL = config.gatewayUrl;
process.env.GPTSCRIPT_OPENAPI_REVAMP = 'true';
process.env.GPTSCRIPT_BROWSER_SETTINGS_FILE = config.browserSettingsFile;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that for various tools that have settings that they will all have their own settings files?

actions/browser.tsx Show resolved Hide resolved
Comment on lines 86 to 87
<Tooltip
content="Use Default Session will use your existing default Google Chrome session. When this setting is enabled, Chrome must be closed before running the browser tool."
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Right now this goes all the way to the edge of my app and its a little hard to read. Screenshot 2024-09-06 at 9 38 07 AM
Suggested change
<Tooltip
content="Use Default Session will use your existing default Google Chrome session. When this setting is enabled, Chrome must be closed before running the browser tool."
<Tooltip
classNames={{base: "w-1/2"}}
content="Use Default Session will use your existing default Google Chrome session. When this setting is enabled, Chrome must be closed before running the browser tool."
Could we add that max width so it looks more like this? Screenshot 2024-09-06 at 9 43 40 AM

Comment on lines +9 to +25
function browserSettingsLocation() {
const homeDir = os.homedir();
let configDir;
if (os.platform() === 'darwin') {
configDir =
process.env.XDG_CONFIG_HOME ||
join(homeDir, 'Library', 'Application Support');
} else if (os.platform() === 'win32') {
configDir = join(homeDir, 'AppData', 'Local');
} else if (os.platform() === 'linux') {
configDir = process.env.XDG_CONFIG_HOME || join(homeDir, '.config');
} else {
throw new Error('Unsupported platform');
}

return join(configDir, 'acorn', 'browsersettings.json');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

That I personally know of, no. I've had a lot of similar headaches. Ideally we'd make a global lib package that both the Next app and electron could import. To do that right though I think we'd need the socket server and config code to be in typescript so it isn't super simple in just this PR.

thedadams
thedadams previously approved these changes Sep 6, 2024
Signed-off-by: Grant Linville <grant@acorn.io>
@g-linville
Copy link
Member Author

Pushing a change dismissed the previous approvals for some reason, so reviews re-requested.

@g-linville
Copy link
Member Author

Wow that was fast lol

@g-linville g-linville merged commit 71377ca into gptscript-ai:main Sep 6, 2024
1 check passed
@g-linville g-linville deleted the browser-settings-menu branch September 6, 2024 14:13
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