Skip to content

Commit e9d7162

Browse files
Eggmansworldclaude
andcommitted
Show the currently processing file in the status line (v0.1.4)
The strip above the activity log used to echo the last completed log line, so during a run it always trailed one file behind — misleading when a multi-gigabyte file sits in the hasher for minutes. The engine now raises an ItemStarted callback the moment an item begins hashing (full-hash and incremental paths both), and the strip shows that in-flight file as "» name" while a run is active. Completed items keep flowing into the log below as before, and outside a run the strip falls back to the last log line. Worker threads only write a volatile field; the drawer's existing 150 ms timer publishes it to the UI, so even thousands of tiny items per second cannot flood the UI thread. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 77961d0 commit e9d7162

6 files changed

Lines changed: 37 additions & 3 deletions

File tree

‎src/DatfileCreator.Core/DatEngine.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public sealed class EngineCallbacks
1818
public Action<string, int>? Folder { get; init; }
1919
/// <summary>Processing entered a new subfolder within the job (relative path).</summary>
2020
public Action<string>? Subfolder { get; init; }
21+
/// <summary>Item processing started: (basename). Fires from worker threads.</summary>
22+
public Action<string>? ItemStarted { get; init; }
2123
/// <summary>Item completed: (total done so far).</summary>
2224
public Action<int>? Progress { get; init; }
2325
/// <summary>Item hashed OK: (basename, diagnostic detail or "").</summary>
@@ -520,6 +522,7 @@ void EmitSubfolderMarker(string itemPath)
520522
// Returns (result-or-null, errorDetail-or-null)
521523
(object? Result, string? Error) SafeWork(string itemPath)
522524
{
525+
cb.ItemStarted?.Invoke(Path.GetFileName(itemPath));
523526
try
524527
{
525528
if (isMixed)

‎src/DatfileCreator.Core/IncrementalUpdate.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ static long ParseSize(string? raw)
530530
string fname = Path.GetFileName(item);
531531
bool carried = false;
532532
string hashDiag = "";
533+
cb.ItemStarted?.Invoke(fname);
533534
try
534535
{
535536
if (isZipped)

‎src/DatfileCreatorStudio/DatfileCreatorStudio.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
1010
<AssemblyName>DatfileCreatorStudio</AssemblyName>
1111
<RootNamespace>DatfileCreatorStudio</RootNamespace>
12-
<Version>0.1.3</Version>
12+
<Version>0.1.4</Version>
1313
<Authors>Eggman</Authors>
1414
<Product>Datfile Creator Studio</Product>
1515
</PropertyGroup>

‎src/DatfileCreatorStudio/ViewModels/LogDrawerViewModel.cs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public LogDrawerViewModel()
6464
_timer.Tick += (_, _) =>
6565
{
6666
FlushPending();
67+
if (CurrentFile != _currentFilePending)
68+
CurrentFile = _currentFilePending;
6769
if (_stopwatch.IsRunning)
6870
Elapsed = _stopwatch.Elapsed.ToString(@"hh\:mm\:ss");
6971
};
@@ -74,14 +76,36 @@ public LogDrawerViewModel()
7476
private bool _isExpanded;
7577

7678
[ObservableProperty]
79+
[NotifyPropertyChangedFor(nameof(ActivityLine))]
7780
private bool _isRunning;
7881

7982
[ObservableProperty]
8083
private string _statusText = "Idle";
8184

8285
[ObservableProperty]
86+
[NotifyPropertyChangedFor(nameof(ActivityLine))]
8387
private string _lastLine = "";
8488

89+
// ── Currently-processing file ────────────────────────────────────────
90+
// Worker threads report every item as it STARTS via SetCurrentFile; the
91+
// 150 ms timer publishes the latest value on the UI thread, so the strip
92+
// shows what is being hashed right now (a big zip can sit here for
93+
// minutes) while completed items keep flowing into the log as before.
94+
95+
/// <summary>Written from engine worker threads; read by the UI timer.</summary>
96+
private volatile string _currentFilePending = "";
97+
98+
[ObservableProperty]
99+
[NotifyPropertyChangedFor(nameof(ActivityLine))]
100+
private string _currentFile = "";
101+
102+
/// <summary>Thread-safe: record the item whose processing just began.</summary>
103+
public void SetCurrentFile(string name) => _currentFilePending = name;
104+
105+
/// <summary>The strip's activity text: in-flight file while running, last log line otherwise.</summary>
106+
public string ActivityLine =>
107+
IsRunning && CurrentFile.Length > 0 ? "» " + CurrentFile : LastLine;
108+
85109
[ObservableProperty]
86110
private string _elapsed = "";
87111

@@ -126,6 +150,8 @@ public void OnRunStarted(string summary)
126150
{
127151
Append(LogKind.Info, "");
128152
Append(LogKind.Phase, "> " + summary);
153+
_currentFilePending = "";
154+
CurrentFile = "";
129155
IsRunning = true;
130156
IsExpanded = true;
131157
StatusText = "Running";
@@ -162,6 +188,8 @@ public void OnRunCompleted(bool ok, int errorCount, bool stopped)
162188
Elapsed = _stopwatch.Elapsed.ToString(@"hh\:mm\:ss");
163189
IsRunning = false;
164190
IsIndeterminate = false;
191+
_currentFilePending = "";
192+
CurrentFile = "";
165193

166194
(StatusText, StatusBrush) = (stopped, ok, errorCount) switch
167195
{

‎src/DatfileCreatorStudio/ViewModels/MainWindowViewModel.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ private async Task StartAsync()
434434
if (rel is not ("." or ""))
435435
Drawer.Append(LogKind.Subfolder, " [dir] " + rel);
436436
},
437+
ItemStarted = name => Drawer.SetCurrentFile(name),
437438
Progress = done =>
438439
Dispatcher.UIThread.Post(() => Drawer.OnProgress(done)),
439440
ItemHashed = (name, detail) =>

‎src/DatfileCreatorStudio/Views/Controls/LogDrawer.axaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
<TextBlock Grid.Column="4" Text="{Binding ItemsText}" FontSize="12"
3737
Foreground="{DynamicResource AppSubtleTextBrush}"
3838
VerticalAlignment="Center" Margin="0,0,16,0"/>
39-
<TextBlock Grid.Column="5" Text="{Binding LastLine}" FontSize="12"
39+
<TextBlock Grid.Column="5" Text="{Binding ActivityLine}" FontSize="12"
4040
FontFamily="Cascadia Mono,Consolas,DejaVu Sans Mono,Liberation Mono,monospace"
4141
Foreground="{DynamicResource AppSubtleTextBrush}"
42-
TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="0,0,12,0"/>
42+
TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="0,0,12,0"
43+
ToolTip.Tip="While a run is active this shows the file being processed right now; completed items scroll into the log below"/>
4344

4445
<Button Grid.Column="6" Classes="icon" Click="OnCopyLogClick"
4546
ToolTip.Tip="Copy the full log to the clipboard" VerticalAlignment="Center">

0 commit comments

Comments
 (0)