Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

When git operations fail in TUI mode, error messages were printed directly to stdout, breaking the terminal layout and corrupting progress displays. This PR fixes the corruption issue while ensuring users are informed about failures.

Changes

  • internal/sync/sync.go: Guard all fmt.Printf calls with s.opts.Verbose checks

    • Error messages in syncSingleRepo (2 locations)
    • Dry-run messages in syncWorker and syncSingleRepo (4 locations)
  • internal/tui/screens/sync_progress.go: Add error tracking and display

    • Added failedRepos map to capture error messages during sync
    • Modified worker goroutines to pass error information through result channels
    • Display failed repositories with detailed error messages in completion summary
    • Repository names are sorted alphabetically for consistent display

In TUI mode, the syncer runs with Verbose: false and Git in quiet mode, so all progress is communicated via callbacks (s.reportProgress). The unguarded print statements bypassed that mechanism, breaking the layout. Errors are now captured and displayed in a dedicated section after sync completes.

Example

Code changes:

// Before
if err := s.cloneRepo(ctx, repo, localPath); err != nil {
    result.Failed[repoName] = err
    s.reportProgress(repoName, ProgressFailed, err.Error())
    fmt.Printf("Failed to clone %s: %v\n", repoName, err)  // Always prints
}

// After
if err := s.cloneRepo(ctx, repo, localPath); err != nil {
    result.Failed[repoName] = err
    s.reportProgress(repoName, ProgressFailed, err.Error())
    if s.opts.Verbose {
        fmt.Printf("Failed to clone %s: %v\n", repoName, err)  // Only in verbose mode
    }
}

UI changes:

Results:
  ● Cloned: 80
  ● Updated: 30
  ● Failed: 3

Failed repositories:
  • Dids/ports
    git clone failed: error: invalid path 'japanese/prn/Makefile' fatal: unable to checkout working tree
  • owner/repo2
    git clone failed: ...
  • owner/repo3
    git pull failed: ...
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix TUI breaking when a checkout/sync fails</issue_title>
<issue_description>Here's example output of what happens when it fails to checkout/sync a repo, it breaks the layout and messes up the progress bar:

 Syncing...


 ████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  68%

 ⡿  [80/118] Dids/ports: syncing
 ████████████████████████████████████████████████████████████████████████████░░░░░░░░░░░░░░░░░░░  80%
 Progress: 80 / 118 repositories
 ⣷  [94/118] Dids/SupportKit: syncing

 Progress: 94 / 118 repositories










────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Failed to clone Dids/ports: git clone failed: Cloning into 'C:\Users\didan\Downloads\githubby_1.0.9_windows_amd64\Dids\p
orts'...
error: invalid path 'japanese/prn/Makefile'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 30, 2026 08:28
… in non-verbose mode

Co-authored-by: Dids <3455449+Dids@users.noreply.github.com>
Co-authored-by: Dids <3455449+Dids@users.noreply.github.com>
@Dids
Copy link
Contributor

Dids commented Jan 30, 2026

@copilot Blindly suppressing errors is a no go. The user needs to be aware of errors, so they should be shown somewhere, either during sync, after the sync or as dialogs of some sort. You decide the best approach here, but think about the UI and UX for the TUI approach.

Copilot AI changed the title [WIP] Fix TUI breaking when a checkout or sync fails Fix TUI corruption on git clone/sync failures Jan 30, 2026
Copilot AI requested a review from Dids January 30, 2026 08:32
Copilot AI and others added 2 commits January 30, 2026 08:36
Co-authored-by: Dids <3455449+Dids@users.noreply.github.com>
Co-authored-by: Dids <3455449+Dids@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot Blindly suppressing errors is a no go. The user needs to be aware of errors, so they should be shown somewhere, either during sync, after the sync or as dialogs of some sort. You decide the b...

You're absolutely right. I've updated the implementation to display error messages to users while still preventing TUI corruption.

The errors now appear in a dedicated "Failed repositories" section in the completion summary, showing:

  • Repository name
  • Full error message (e.g., "git clone failed: error: invalid path 'japanese/prn/Makefile'...")
  • Sorted alphabetically for easy scanning

This approach keeps the TUI layout clean during sync (no stdout interference) while ensuring users see exactly what went wrong after sync completes.

Changes in commits:

  • 2bc7085: Added error tracking and display
  • 584e151: Sorted failed repos alphabetically

Copilot AI changed the title Fix TUI corruption on git clone/sync failures Fix TUI corruption on git clone/sync failures and display error details Jan 30, 2026
@Dids Dids marked this pull request as ready for review January 30, 2026 08:42
@Dids Dids merged commit eab632a into master Jan 30, 2026
8 checks passed
@Dids Dids deleted the copilot/fix-tui-issue-checkout-sync branch January 30, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix TUI breaking when a checkout/sync fails

2 participants