Skip to content

Add "Sync now" to the app: check the server at once - #16

Open
dkgs2000 wants to merge 1 commit into
mainfrom
claude/sync-now-button
Open

dkgs2000 wants to merge 1 commit into
mainfrom
claude/sync-now-button

Conversation

@dkgs2000

Copy link
Copy Markdown
Owner

What

The service's sync control request looks at every folder the drive keeps current, but only the end-to-end scripts sent it. The app now offers it as Sync now:

  • in the notification area icon's menu, above Start / Stop / Restart syncing;
  • on the Status page, beside Open folder.

It can be pressed for a running drive that is connected. That includes an offline drive, where it has the service try the server again at once. It is disabled while the service starts or could not start the drive, and while a start, stop or save is under way.

How it behaves

  • While the run goes, the button and the menu item are disabled and read "Checking the server...", and the icon's tooltip says the same. Stop and Restart stay available.
  • The run finished and the server answered: nothing is said; what changed shows in the folders and under Recent activity.
  • The server cannot be reached: the drive goes offline and the notification every drive going offline gets says why, once. A drive that was already offline is told again. For that case the app first waits for the service to say the drive is back online, for as long as the service's own check of the server takes (10 s, plus 2), so a server that answers again is not reported as unreachable.
  • The run did not finish (it failed, took over five minutes, or the service stopped by itself): a message says so. Not when the user stopped or restarted syncing meanwhile.

Changes

  • ServiceControl.RequestSyncAsync(syncRoot, timeout, cancellationToken) returns whether the run finished. ServiceControl.SyncRequestTimeout is a little more than the service's own limit for a run, so the service's answer comes first. Connecting has its own 5 s limit (SendAsync takes an optional connectTimeout): without a service, connecting to a pipe goes on trying for as long as it is given.
  • DriveSnapshot.CanSyncNow, IDriveApp.Checking and IDriveApp.SyncNowAsync; TrayApp.SyncNowAsync does the above.
  • SyncRootConnection.ListingTimeout is public, so the app's wait follows it.
  • docs/user-guide.md describes Sync now under the icon's menu and the Status page; docs/architecture.md mentions it for the app.

Tests

  • ServiceControlTests: the request is answered only once the run has finished; a failed run, a service that stops meanwhile, a service that does not know the request and no service all give false; a request whose answer may take long still learns soon that no service is there.
  • MainFormLayoutTests: a new "checking the server" state goes through the layout checks at every size and scale, and SyncNow_IsOfferedForAConnectedDrive_AndSaysWhileItChecks pins when the button shows, when it can be pressed and what it reads.
  • dotnet test .\OpenCfDrive.slnx with rclone on PATH: 305 passed, 0 failed, 0 skipped.
  • Pressed for real, through UI Automation, in a Debug copy of the app with its own settings file, against a stand-in service (a ServiceControlServer holding the drive's mutex): a run that succeeds, one that fails, an offline drive whose server answers again, one that stays offline, and a drive that goes offline during the run. Each gave the behaviour above, with exactly one notification where one is due.

Notes for merging

  • claude/folder-poll-backoff touches some of the same files. Expect one small conflict: the Status page's button row in MainForm.Status.cs (both add a button to Theme.ButtonRow(...)). The other edits were kept away from that branch's lines.
  • Possible follow-up, after the backoff change is in: an offline service answers sync before its check of the server has finished, which is why the app waits on the "back online" pulse with a time limit. If the service answered only once that check is done, the app could drop the limit.

🤖 Generated with Claude Code

The service's "sync" control request looks at every folder the drive
keeps current, but only the end-to-end scripts sent it. The app now
offers it as "Sync now", in the notification area icon's menu and on
the Status page beside Open folder, for a running drive that is
connected (offline too, where it has the service try the server again).

ServiceControl.RequestSyncAsync sends the request and waits for the
run. It is given a little more than the service lets a run take, and
connecting has its own short limit, so no service is known at once
rather than after those five minutes.

While the run goes, the button and the menu item are disabled and read
"Checking the server...", as does the icon's tooltip; syncing can still
be stopped. A run that did not finish gets a message, unless the user
stopped or restarted syncing meanwhile. A server that cannot be reached
is told by the notification a drive going offline always gets, once:
also for a drive that was offline before, after the service had the
time its own check of the server takes to say that it is back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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