fix(ui): refresh the run session id live, close the stale handoff pane

A task selected before its run started kept LatestRunSessionId null, so the
roadblock reply box and Continue stayed dead until it was re-selected.

The handoff left the Phase 1-2 tile open so its last message could be read, but
its process is gone by then and the terminal renders empty -- a dead
placeholder. It is closed on handoff now.

Also drops the WARN flood from worktree cleanup (already-unregistered worktree
and already-deleted branch are normal outcomes, not failures) and replaces the
fixed sleep in UsageGate_TransitionLogging_FiresOncePerChange with the polling
helper that already sits three lines below it in the same file.
This commit is contained in:
mika kuns
2026-08-06 10:20:54 +02:00
parent 56f7d64f07
commit f106c890b3
5 changed files with 79 additions and 22 deletions
@@ -143,8 +143,15 @@ public sealed class WorktreeMaintenanceService
}
catch (Exception ex)
{
_logger.LogWarning(ex,
"git worktree remove failed for {Path}; falling back to directory delete", row.Path);
// "is not a working tree" means git already forgot this worktree (pruned, or
// removed by hand). Deleting the directory is then the whole job, not a fallback
// from a real failure -- warning about it floods the footer log strip when a
// batch of stale rows is cleaned up.
if (IsAlreadyUnregistered(ex))
_logger.LogDebug(ex, "git no longer tracks {Path}; deleting the directory", row.Path);
else
_logger.LogWarning(ex,
"git worktree remove failed for {Path}; falling back to directory delete", row.Path);
try { if (Directory.Exists(row.Path)) Directory.Delete(row.Path, recursive: true); }
catch (Exception delEx)
{
@@ -186,8 +193,12 @@ public sealed class WorktreeMaintenanceService
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Failed to delete branch {Branch} for worktree {Path}",
row.BranchName, row.Path);
// Already deleted -- the normal case once the branch has been merged.
if (IsBranchAlreadyGone(ex))
_logger.LogDebug(ex, "branch {Branch} was already deleted", row.BranchName);
else
_logger.LogWarning(ex, "Failed to delete branch {Branch} for worktree {Path}",
row.BranchName, row.Path);
}
}
}
@@ -197,5 +208,12 @@ public sealed class WorktreeMaintenanceService
return (true, branchDeleted);
}
// Both are "already done" outcomes, not failures — see the call sites.
private static bool IsAlreadyUnregistered(Exception ex) =>
ex.Message.Contains("is not a working tree", StringComparison.OrdinalIgnoreCase);
private static bool IsBranchAlreadyGone(Exception ex) =>
ex.Message.Contains("' not found", StringComparison.Ordinal);
private sealed record WorktreeRow(string TaskId, string Path, string BranchName, string? WorkingDir);
}