Skip to content
Merged
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
29 changes: 25 additions & 4 deletions PolyPilot/Components/ExpandedSessionView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
private string? _prUrl;
private string _prLabel = "PR";
private string? _lastPrCheckedDir;
private string? _lastExpandedSessionId;

private List<SkillInfo>? availableSkills;
private List<AgentInfo>? availableAgents;
Expand Down Expand Up @@ -772,17 +773,37 @@
if (PlatformHelper.IsDesktop)
{
var dir = Session.WorkingDirectory;
if (!string.IsNullOrEmpty(dir) && dir != _lastPrCheckedDir)
var sessionSwitched = Session.SessionId != _lastExpandedSessionId;
_lastExpandedSessionId = Session.SessionId;

if (sessionSwitched)
{
_prUrl = null;
_prLabel = "PR";
}

if (!string.IsNullOrEmpty(dir))
{
_lastPrCheckedDir = dir;
_ = FetchPrUrlAsync(dir);
if (dir != _lastPrCheckedDir)
{
_lastPrCheckedDir = dir;
_ = FetchPrUrlAsync(dir);
}
else if (sessionSwitched && _prUrl == null)
{
// Only re-check when user switches to this session, not on every render
_ = FetchPrUrlAsync(dir);
}
}
}
}

private async Task FetchPrUrlAsync(string dir)
{
_prUrl = await PrLinkService.GetPrUrlForDirectoryAsync(dir);
var capturedId = Session.SessionId;
var url = await PrLinkService.GetPrUrlForDirectoryAsync(dir);
if (Session.SessionId != capturedId) return;
_prUrl = url;
if (_prUrl != null)
{
var lastSlash = _prUrl.LastIndexOf('/');
Expand Down
19 changes: 16 additions & 3 deletions PolyPilot/Components/Layout/SessionListItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,28 @@
private string _prLabel = "PR";
private string? _lastPrCheckedDir;
private string? _renderSignature;
private bool _wasActive;

protected override void OnParametersSet()
{
if (!PlatformHelper.IsDesktop) return;
var dir = GetSessionDirectory();
if (!string.IsNullOrEmpty(dir) && dir != _lastPrCheckedDir)

// Re-check PR when session becomes active (user clicks it) and we don't have a PR yet
var becameActive = IsActive && !_wasActive;
_wasActive = IsActive;

if (!string.IsNullOrEmpty(dir))
{
_lastPrCheckedDir = dir;
_ = FetchPrUrlAsync(dir);
if (dir != _lastPrCheckedDir)
{
_lastPrCheckedDir = dir;
_ = FetchPrUrlAsync(dir);
}
else if (becameActive && _prUrl == null)
{
_ = FetchPrUrlAsync(dir);
}
}
}

Expand Down