Skip to content

added new settings dialog + settings manager #113

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

ibetitsmike
Copy link
Contributor

@ibetitsmike ibetitsmike commented May 29, 2025

Closes: #57 & #55

Adds:

  • SettingsManager that manages settings located in AppData
  • Settings views to manage the settings
  • StartupManager that allows to control registry access to enable load on startup

image

@ibetitsmike ibetitsmike marked this pull request as ready for review June 2, 2025 11:14
@ibetitsmike ibetitsmike requested a review from deansheather June 2, 2025 11:14
@ibetitsmike ibetitsmike force-pushed the mike/57-starting-coder-desktop-on-boot branch from 9037758 to bad5320 Compare June 3, 2025 13:54
@ibetitsmike ibetitsmike requested a review from deansheather June 3, 2025 13:55
string exe = Process.GetCurrentProcess().MainModule!.FileName;
try
{
using var key = Registry.CurrentUser.OpenSubKey(RunKey, writable: true)
Copy link
Member

Choose a reason for hiding this comment

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

Is there any (easy) way we can clean this up on uninstall?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can, but this will also basically clear the setting every team you update (I believe you run the uninstall then too, right)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow up here: #121

/// </summary>
bool ConnectOnLaunch { get; set; }
/// <returns></returns>
public T? GetFromCache();
Copy link
Member

Choose a reason for hiding this comment

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

Rather than have this, Read should probably return from cache by default. I know this goes against a point I made in a previous review but if we're going with the Read/Write API then it should just be all in

Copy link
Member

Choose a reason for hiding this comment

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

Also, Read should probably not fail if it failed to read/parse the file. IDK what good behavior is, but I think for now just returning a default config is OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is definitely going against this comment :D
#113 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I'm like 50/50 on whether we should crash or just use the default config... IDK what the best option is. For now with a single option maybe it's fine to just keep going, but in the future if we add config options that are more sensitive to being clobbered it might be bad to just ignore a parse failure...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it throws an exception now and I think that's OK considering - if you fail to operate the file there's a high likelihood that the feature won't work ata ll.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's fair. We can revisit this if it's causing issues

Comment on lines 152 to 165
public interface ISettings
{
/// <summary>
/// Gets the version of the settings schema.
/// FileName where the settings are stored.
/// </summary>
int Version { get; }
static abstract string SettingsFileName { get; }

/// <summary>
/// FileName where the settings are stored.
/// Gets the version of the settings schema.
/// </summary>
static abstract string SettingsFileName { get; }
int Version { get; }

ISettings Clone();
}
Copy link
Member

Choose a reason for hiding this comment

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

You could separate this into ISettings with the Version field, and a new interface like ICloneable<T>

public interface ICloneable<T> {
  T Clone();
}

which avoids the casting required after calling Clone() in Read()

// deserialize; fall back to default(T) if empty or malformed
var result = JsonSerializer.Deserialize<T>(json)!;
_cachedSettings = result;
return result;
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be cloned.

@@ -1,4 +1,5 @@
using Google.Protobuf.WellKnownTypes;
using Serilog;
Copy link
Member

Choose a reason for hiding this comment

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

I think this got added by mistake, I can't see any code that uses it

{
_connectSettings = settingsCache.Clone();
}
var settingsCache = settingsManager.Read();
Copy link
Member

Choose a reason for hiding this comment

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

This code seems like it's not doing anything. Read is async, and _connectSettings doesn't get populated. It's not going to be easy cuz it's async but there are existing patterns in other view models with async gets in the ctor

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.

Support starting Coder Desktop on boot
2 participants