Skip to content

Parallel-history detection at modal open (S2) #385

Closed

Description

@vybe

Summary

Detect parallel-history conflicts before rendering GitConflictModal and show a third recovery option.

Context

Problem P2: When the agent's branch and main have parallel history (diverged commits, not linear), both UI buttons fail:

  • "Pull First" replays the same conflicting commit, fails identically
  • "Force Push" overwrites remote with stale history

The backend already computes ahead/behind. Adding common_ancestor_sha enables the frontend to detect this case.

Acceptance Criteria

Backend

  • Add common_ancestor_sha and/or common_ancestor_age_days to /api/git/status response
  • Compute via git merge-base HEAD origin/main

Frontend detection

  • Before rendering GitConflictModal, check:
    • common_ancestor is empty or very old
    • behind > 0
  • If parallel history detected, render different modal

New modal for parallel history

  • Title: "Your agent cannot sync" (plain English, not "Push Conflict")
  • Body explains: "Main has N new commits. Your agent has M local commits. The histories diverged."
  • Third button: "Adopt latest upstream (preserve my state)" → triggers S3 endpoint
  • Keep "Force Push" as secondary option with warning

Label-agnostic

  • Don't hardcode "main" in user-facing copy — some repos use master, trunk, etc.

Technical Notes

Files to modify:

  • docker/base-image/agent_server/routers/git.py — add common_ancestor_sha to status
  • src/frontend/src/components/GitConflictModal.vue — conditional rendering
  • src/frontend/src/composables/useGitSync.js — detection logic

Depends on #384 (S3) for the "Adopt latest upstream" action.

Part of Epic #381

Activity

  1. added
    priority-p2
    type-feature
    on Apr 18, 2026
  2. added a commit that references this issue on Apr 23, 2026
  3. added
    complexity-low
    theme-reliability
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p2theme-reliabilitytype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions