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

WIP - Add remote service interactions #6

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

Conversation

artl93
Copy link
Owner

@artl93 artl93 commented Dec 31, 2024

No description provided.

- Improve test runtimes (set FakeTimeProvider dates on start, not using SetUTCNow())
- Updated `GetUserConfigurationForDayAsync` to always enable the remote provider.
- Simplified lambda expressions for `RemoteUserStateProvider` and `HiddenForm` in `Program.cs`.
- Refactored `IScreenTimeStateClient` creation in `ServiceCollectionExtensions.cs` to directly instantiate `ScreenTimeLocalService`.
- Changed `IUserConfigurationProvider` registration logic to check for "develop" or "live" instead of "local" or "live".
- Introduced `SendHeartbeatAsync` method in `IUserConfigurationProvider` and implemented it in `LocalUserConfigurationProvider`.
- Updated `RemoteUserConfigurationProvider` to send heartbeat data via HTTP POST.
- Modified `SwitchableUserConfigurationProvider` to utilize the new heartbeat method.
- Refactored variable declaration in `HiddenForm.cs` for clarity.
- Simplified `AddScreenTimeClient` method in `Program.cs` and `ServiceCollectionExtensions` by removing unnecessary parameters.
- Added `cacheFileExtension` constant in `RemoteUserStateProvider` for better cache file management.
- Enhanced `LogHeartbeat` method in `ScreenTimeLocalService` to log and send heartbeat signals.
Updated solution files `screentime.sln` and `services.sln` to include a new project reference for `ScreenTIme.Common`. Modified `ScreenTimeService.csproj` to utilize functionalities from `ScreenTIme.Common`.
(no backend storage yet)
@artl93 artl93 requested a review from Copilot January 2, 2025 00:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 24 out of 39 changed files in this pull request and generated 3 comments.

Files not reviewed (15)
  • client.sln: Language not supported
  • screentime.sln: Language not supported
  • services.sln: Language not supported
  • src/ScreenTIme.Common/ScreenTIme.Common.csproj: Language not supported
  • src/ScreenTimeClient/ExtensionResponseArgs.cs: Evaluated as low risk
  • src/ScreenTimeClient/ComputerStateEventArgs.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/UserConfigurationResponseEventArgs.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/UserConfigurationRegistryReader.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserMessage.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserConfiguration.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserStatus.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/UserConfigurationEventArgs.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserActivityState.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/IUserConfigurationReader.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/LocalUserConfigurationProvider.cs: Evaluated as low risk
Comments suppressed due to low confidence (3)

src/ScreenTimeClient/Configuration/SwitchableUserConfigurationProvider.cs:41

  • Redundant null check for localProvider. It is already initialized in the constructor.
if (localProvider is null)

src/ScreenTimeClient/Configuration/SwitchableUserConfigurationProvider.cs:52

  • Redundant null check for localProvider. It is already initialized in the constructor.
if (localProvider is null)

src/ScreenTimeClient/Configuration/IUserConfigurationProvider.cs:14

  • [nitpick] The parameter name 'v' is ambiguous. It should be renamed to something more descriptive, like 'minutes'.
public Task RequestExtensionAsync(int v);

@artl93 artl93 requested a review from Copilot January 4, 2025 03:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 67 out of 82 changed files in this pull request and generated 2 comments.

Files not reviewed (15)
  • client.sln: Language not supported
  • screentime.sln: Language not supported
  • services.sln: Language not supported
  • src/ScreenTIme.Common/ScreenTIme.Common.csproj: Language not supported
  • src/ScreenTimeClient/ComputerStateEventArgs.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserMessage.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserStatus.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserActivityState.cs: Evaluated as low risk
  • .github/workflows/dotnet-desktop.yml: Evaluated as low risk
  • src/ScreenTIme.Common/DailyConfiguration.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/DailyConfigurationRegistryReader.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/DailyConfigurationLocalProvider.cs: Evaluated as low risk
  • src/ScreenTIme.Common/Heartbeat.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/DailyConfigurationEventArgs.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserState.cs: Evaluated as low risk
Comments suppressed due to low confidence (4)

src/ScreenTimeClient/Configuration/DailyConfigurationRemoteProvider.cs:8

  • [nitpick] The parameter name 'connectionProvider' should be consistent with the rest of the class, where 'serviceClient' is used. Rename 'connectionProvider' to 'serviceClient'.
public class DailyConfigurationRemoteProvider(ScreenTimeServiceClient connectionProvider, ILogger<DailyConfigurationRemoteProvider> logger) : IDailyConfigurationProvider, IDisposable

src/ScreenTimeClient/Configuration/ClientConfigurationRegistryReader.cs:7

  • The variable name _baseKey should be renamed to BaseKey to follow naming conventions.
const string _baseKey = @"HKEY_CURRENT_USER\Software\ScreenTime";

src/ScreenTimeClient/Configuration/ClientConfigurationRegistryReader.cs:18

  • [nitpick] The method name GetRegistryIntValue should be reviewed for clarity and consistency.
private static int GetRegistryIntValue(string key, string valueName, int defaultValue)

src/ScreenTIme.Common/Extensions.cs:12

  • The parameter name 'requestId' should be renamed to 'RequestId' to follow the PascalCase naming convention.
public record AdminExtensionRequest(Guid requestId, User User, DateTimeOffset SubmissionDate, TimeSpan Duration);


# Build the application to populate the obj folder with RuntimeIdentifiers
- name: Build the application
run: dotnet build $env:Solution_Name
Copy link
Preview

Copilot AI Jan 4, 2025

Choose a reason for hiding this comment

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

The build command does not correctly use the Configuration environment variable. It should be passed as an argument to the dotnet build command.

Suggested change
run: dotnet build $env:Solution_Name
run: dotnet build $env:Solution_Name --configuration ${{ matrix.configuration }}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@artl93 artl93 requested a review from Copilot January 6, 2025 07:05

Choose a reason for hiding this comment

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

Copilot reviewed 70 out of 85 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • client.sln: Language not supported
  • screentime.sln: Language not supported
  • services.sln: Language not supported
  • src/ScreenTIme.Common/ScreenTIme.Common.csproj: Language not supported
  • src/ScreenTimeClient/Configuration/DailyConfigurationLocalProvider.cs: Evaluated as low risk
  • .github/workflows/dotnet-service.yml: Evaluated as low risk
  • src/ScreenTIme.Common/DailyConfiguration.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/DailyConfigurationRemoteProvider.cs: Evaluated as low risk
  • src/ScreenTimeClient/Configuration/DailyConfigurationRegistryReader.cs: Evaluated as low risk
  • src/ScreenTimeClient/ComputerStateEventArgs.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserMessage.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserStatus.cs: Evaluated as low risk
  • src/ScreenTIme.Common/UserActivityState.cs: Evaluated as low risk
  • .github/workflows/dotnet-desktop.yml: Evaluated as low risk
  • src/ScreenTIme.Common/Heartbeat.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)

src/ScreenTimeClient/Configuration/ClientConfigurationRegistryReader.cs:25

  • The 'else' statement after 'if (objectValue == null)' is redundant and can be removed for cleaner code.
else if (objectValue is int intValue)
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.

1 participant