Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.
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
17 changes: 13 additions & 4 deletions PolyPilot/Components/Layout/SessionSidebar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2426,8 +2426,9 @@ else
var baseBranch = await GetDefaultRemoteBranch(repoRoot);
if (baseBranch != null)
{
// Fetch latest and create branch from the upstream default
await RunProcessAsync("git", "fetch --quiet upstream 2>/dev/null || git fetch --quiet origin", repoRoot);
// Best-effort fetch — continue offline from cached refs
try { await RunProcessAsync("git", "fetch --quiet upstream 2>/dev/null || git fetch --quiet origin", repoRoot); }
catch { /* offline is fine — use cached refs */ }
await RunProcessAsync("git", $"checkout -b {branchName} {baseBranch}", repoRoot);
}
else
Expand Down Expand Up @@ -2518,8 +2519,15 @@ Important conventions:

private static void LaunchCopilotInTerminal(string workingDir, string promptFile)
{
// Resolve the actual CLI binary path from settings instead of assuming 'copilot' is on PATH
var settings = ConnectionSettings.Load();
var cliPath = CopilotService.ResolveCopilotCliPath(settings.CliSource);
if (string.IsNullOrEmpty(cliPath))
throw new InvalidOperationException("Copilot CLI binary not found. Check Settings → CLI Source.");

if (OperatingSystem.IsWindows())
{
var psCli = cliPath.Replace("'", "''");
// Write a PowerShell script that sends the prompt as the first message
var psScript = Path.Combine(Path.GetTempPath(), $"polypilot-launch-{Guid.NewGuid():N}.ps1");
File.WriteAllText(psScript,
Expand All @@ -2528,7 +2536,7 @@ Important conventions:
$"Write-Host \"─────────────────────────────────────────\"\n" +
$"Write-Host \"\"\n" +
$"$prompt = Get-Content '{promptFile}' -Raw\n" +
$"copilot --yolo -i \"$prompt\"\n");
$"& '{psCli}' --yolo -i \"$prompt\"\n");

// Launch in a new Windows Terminal / cmd window
var psi = new System.Diagnostics.ProcessStartInfo("powershell.exe",
Expand All @@ -2541,6 +2549,7 @@ Important conventions:
}
else
{
var safeCli = PlatformHelper.ShellEscape(cliPath);
// Write a shell script that sends the prompt as the first message
var shellScript = Path.Combine(Path.GetTempPath(), $"polypilot-launch-{Guid.NewGuid():N}.sh");
File.WriteAllText(shellScript,
Expand All @@ -2552,7 +2561,7 @@ Important conventions:
// --yolo grants all permissions
// -i (--interactive) sends the prompt then stays interactive for follow-ups
// (-p exits after completion; -i keeps the session open)
$"copilot --yolo -i \"$(cat '{promptFile}')\"\n");
$"{safeCli} --yolo -i \"$(cat '{promptFile}')\"\n");
System.Diagnostics.Process.Start("chmod", $"+x \"{shellScript}\"")?.WaitForExit();

// Use 'open -a Terminal <script>' — launches Terminal.app as a fully independent
Expand Down
8 changes: 6 additions & 2 deletions PolyPilot/Services/RepoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,13 @@ public virtual async Task<WorktreeInfo> CreateWorktreeAsync(string repoId, strin
var repo = _state.Repositories.FirstOrDefault(r => r.Id == repoId)
?? throw new InvalidOperationException($"Repository '{repoId}' not found.");

// Fetch latest from origin (prune to clean up deleted remote branches)
// Fetch latest from origin (prune to clean up deleted remote branches).
// Best-effort: continue offline so worktree creation still works from cached refs.
if (!skipFetch)
await RunGitAsync(repo.BareClonePath, ct, "fetch", "--prune", "origin");
{
try { await RunGitAsync(repo.BareClonePath, ct, "fetch", "--prune", "origin"); }
catch (Exception ex) { Console.WriteLine($"[RepoManager] Fetch failed (continuing offline): {ex.Message}"); }
}

// Determine base ref
var baseRef = baseBranch ?? await GetDefaultBranch(repo.BareClonePath, ct);
Expand Down