Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,7 @@ A Gateway built before the mode would start for real, so Waypoint first asks `co
The list is read from the checkout's save database (`auth.db` and `characters.db` from LocalExile's database split on, or an
old `saves.db` until the servers migrate it) through the adapter, with nothing running or built: every account with
its characters, nothing secret. Showing the section reads it; **Reload accounts** reads it again.
When a monitored server or the client stops, Waypoint checks the current workspace again before enabling account edits.

**Register** and **Create** are the dev protocol's `register`, `login` and `create_character` (the server's GettingStarted
step 8), so they work beside running servers. The character is created in Standard; the game's own creation screen offers
Expand Down
11 changes: 10 additions & 1 deletion src/Waypoint.Linux/Views/AccountsTab.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ public void Attach(Shared shared)
StopHost.IsEnabled = up;
});
shared.Workspace.Changed += () => Dispatcher.UIThread.Post(ShowAccess);
shared.LiveRunning += running => Dispatcher.UIThread.Post(ShowAccess);
shared.Monitor.Exited += (service, _) =>
{
if (service.Kind != ServiceKind.Recorder)
Dispatcher.UIThread.Post(async () => await shared.Workspace.RefreshAfterRuntimeStopAsync());
};
shared.LiveRunning += running => Dispatcher.UIThread.Post(async () =>
{
ShowAccess();
if (!running) await shared.Workspace.RefreshAfterRuntimeStopAsync();
});
L.Current.PropertyChanged += (_, _) =>
{
ShowTexts();
Expand Down
11 changes: 10 additions & 1 deletion src/Waypoint/AccountsTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ internal void Attach(Shared shared)
StopHost.IsEnabled = up;
});
shared.Workspace.Changed += () => Dispatcher.BeginInvoke(ShowAccess);
shared.LiveRunning += running => Dispatcher.BeginInvoke(ShowAccess);
shared.Monitor.Exited += (service, _) =>
{
if (service.Kind != ServiceKind.Recorder)
Dispatcher.BeginInvoke(async () => await shared.Workspace.RefreshAfterRuntimeStopAsync());
};
shared.LiveRunning += running => Dispatcher.BeginInvoke(async () =>
{
ShowAccess();
if (!running) await shared.Workspace.RefreshAfterRuntimeStopAsync();
});
L.Current.PropertyChanged += (_, _) => { AccountGrid.Items.Refresh(); CharacterGrid.Items.Refresh(); ShowAccess(); };
// Showing the section reads the list: the adapter needs no server for that.
IsVisibleChanged += async (_, e) => { if ((bool)e.NewValue) await Load(); };
Expand Down
32 changes: 25 additions & 7 deletions src/Waypoint/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sealed class Workspace(Shared shared)
readonly RuntimeClient _client = new(BridgeScripts.Extract());
readonly StringBuilder _operations = new();
bool _inspecting;
bool _runtimeStoppedDuringInspection;

/// <summary>The last successful inspection; null before the first one.</summary>
public RuntimeSnapshot? Latest { get; private set; }
Expand All @@ -34,19 +35,36 @@ sealed class Workspace(Shared shared)
/// <summary>An operation failed: its stage, why, and its log when it has one.</summary>
public event Action<string, string, string?>? Failed;

// A monitor sample can see several services exit while an inspection is in progress. Recheck once at its end
// so the last exit is reflected even if the adapter had already taken its process snapshot.
public Task RefreshAfterRuntimeStopAsync()
{
if (shared.IsLiveRunning || Latest is not ({ HasServers: true } or { GameRunning: true }
or { AccountWriteBlockedReason.Length: > 0 } or { EditConflicts.Length: > 0 })) return Task.CompletedTask;
_runtimeStoppedDuringInspection = _inspecting;
return RefreshAsync();
}

public async Task RefreshAsync()
{
if (_inspecting || shared.IsLiveRunning) return;
_inspecting = true;
try
{
var result = await _client.RunAsync(shared.Settings.ForBridge, "Inspect");
Latest = result is { Ok: true, Snapshot: not null } ? result.Snapshot : Latest;
InspectError = result.Ok ? null : result.Message;
}
catch (Exception e) when (e is IOException or UnauthorizedAccessException or System.Text.Json.JsonException or System.ComponentModel.Win32Exception)
{
InspectError = e.Message;
do
{
_runtimeStoppedDuringInspection = false;
try
{
var result = await _client.RunAsync(shared.Settings.ForBridge, "Inspect");
Latest = result is { Ok: true, Snapshot: not null } ? result.Snapshot : Latest;
InspectError = result.Ok ? null : result.Message;
}
catch (Exception e) when (e is IOException or UnauthorizedAccessException or System.Text.Json.JsonException or System.ComponentModel.Win32Exception)
{
InspectError = e.Message;
}
} while (_runtimeStoppedDuringInspection && !shared.IsLiveRunning);
}
finally { _inspecting = false; }
Changed?.Invoke();
Expand Down