Improve file operations, layout memory, and drive status.
Add a sequential file-operations queue with pause, reorder, and optional auto-clear; persist window size and tree width; show free space; and clear leftover indexing status. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,7 @@ public sealed partial class NavNodeViewModel : ObservableObject
|
||||
[ObservableProperty] private string _status = "";
|
||||
[ObservableProperty] private bool _isOffline;
|
||||
[ObservableProperty] private bool _childrenLoaded;
|
||||
[ObservableProperty] private bool _isDropTarget;
|
||||
|
||||
public ObservableCollection<NavNodeViewModel> Children { get; } = [];
|
||||
public string Glyph { get; init; } = "\uE8B7";
|
||||
@@ -321,6 +322,37 @@ public sealed class NavigationTreeViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ApplySourceStateAsync(long sourceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var source = await _sources.GetAsync(sourceId, cancellationToken).ConfigureAwait(true);
|
||||
if (source is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var node = FindBySourceId(Roots, sourceId)
|
||||
?? (source.LastRootPath is null ? null : FindByPath(Roots, source.LastRootPath));
|
||||
if (node is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
node.Status = FormatStatus(source);
|
||||
node.IsOffline = source.Status == SourceStatus.Offline;
|
||||
}
|
||||
|
||||
public static string FormatStatus(Source source)
|
||||
=> source.Status switch
|
||||
{
|
||||
SourceStatus.Offline => source.LastSeenUtc is null
|
||||
? "Offline"
|
||||
: $"Offline · Last seen {source.LastSeenUtc.Value.ToLocalTime():d}",
|
||||
SourceStatus.Scanning => "Indexing",
|
||||
SourceStatus.Stale => "May be out of date",
|
||||
SourceStatus.Error => "Error",
|
||||
_ => source.IsIndexed ? "Indexed" : ""
|
||||
};
|
||||
|
||||
public static bool PathsEqual(string a, string b)
|
||||
{
|
||||
if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -362,16 +394,7 @@ public sealed class NavigationTreeViewModel
|
||||
{
|
||||
Label = source.DisplayName,
|
||||
Path = source.LastRootPath ?? source.DisplayName,
|
||||
Status = source.Status switch
|
||||
{
|
||||
SourceStatus.Offline => source.LastSeenUtc is null
|
||||
? "Offline"
|
||||
: $"Offline · Last seen {source.LastSeenUtc.Value.ToLocalTime():d}",
|
||||
SourceStatus.Scanning => "Indexing",
|
||||
SourceStatus.Stale => "May be out of date",
|
||||
SourceStatus.Error => "Error",
|
||||
_ => source.IsIndexed ? "Indexed" : ""
|
||||
},
|
||||
Status = FormatStatus(source),
|
||||
IsOffline = source.Status == SourceStatus.Offline,
|
||||
Glyph = source.Kind == SourceKind.Removable ? "\uE88E" : source.Kind.IsNetwork() ? "\uE968" : "\uEDA2",
|
||||
SourceId = source.Id,
|
||||
@@ -489,6 +512,30 @@ public sealed class NavigationTreeViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
private static NavNodeViewModel? FindBySourceId(IEnumerable<NavNodeViewModel> nodes, long sourceId)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (node.IsPlaceholder)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.SourceId == sourceId)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
|
||||
var child = FindBySourceId(node.Children, sourceId);
|
||||
if (child is not null)
|
||||
{
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static NavNodeViewModel? FindByPath(IEnumerable<NavNodeViewModel> nodes, string path)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
|
||||
Reference in New Issue
Block a user