Skip to content

Conversation

@midigofrank
Copy link
Collaborator

@midigofrank midigofrank commented Feb 9, 2026

Description

  • Add diverged_workflows/2 function to return list of workflow names that have diverged between sandbox and target projects
  • Update merge modal to display specific workflow names in a bullet list when divergence is detected
Screenshot 2026-02-09 at 11 36 49

Fixes #4001

Validation steps

  1. Create a sandbox project
  2. Pick any workflow in the sandbox project and add a job
  3. Go back to the sandboxes page for the project and click to merge the sandbox.
  4. The merge modal should list your workflow as diverged, like in the attached screenshot

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Add diverged_workflows/2 function to return list of workflow names that
have diverged between sandbox and target projects, rather than just a
boolean flag. Update merge modal to display these specific workflow
names in a bullet list when divergence is detected.

This helps users make informed decisions about whether to proceed with
a merge by showing exactly which workflows will be affected.

Fixes #4001
@github-project-automation github-project-automation bot moved this to New Issues in v2 Feb 9, 2026
@midigofrank midigofrank self-assigned this Feb 9, 2026
@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.36%. Comparing base (7f11217) to head (ee52247).

Files with missing lines Patch % Lines
lib/lightning/projects/merge_projects.ex 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4396      +/-   ##
==========================================
- Coverage   89.38%   89.36%   -0.02%     
==========================================
  Files         425      425              
  Lines       20051    20052       +1     
==========================================
- Hits        17923    17920       -3     
- Misses       2128     2132       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@midigofrank
Copy link
Collaborator Author

@josephjclark let me know your thoughts on the wording

- Remove dbg() call from diverged workflows conditional check
- Extract duplicate diverged workflows logic into reusable helper function
- Simplifies code maintenance by centralizing the workflow divergence check
@josephjclark
Copy link
Collaborator

Something is up here Frank - I see the warning even if the branches haven't diverged

Divergence means that the parent project changed since the sandbox was forked. So the head version in the parent is not in the sandbox's history.

@doc """
Returns the list of workflow names that have diverged between source and target projects.

Compares version hashes for workflows with matching names. A workflow is considered
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep:

A workflow is considered
diverged if it exists in both projects but has different version hashes.

this isn't quite right: a workflow is diverged if the parent head is not in the workflow's history.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, great catch!! Let me add tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josephjclark I have fixed this but I think there is another issue we need to fix. Currently, we're squashing the hashes if the source(cli, app) is the same. This means the workflows will always diverge after making a change because we will squash the "cloned" hash

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, it's bad. We don't clone the versions at all when creating sandbox

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually #3958 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, it's bad. We don't clone the versions at all when creating sandbox

I lied, we do clone the versions during forking: https://github.com/OpenFn/lightning/blob/main/lib/lightning/projects/sandboxes.ex#L558

…rison

Update divergence detection to properly identify when parent project has
changed since fork. A workflow now diverges only if the parent's current
HEAD version is absent from the sandbox's version history, not just when
the two HEADs differ.

This allows sandboxes that have pulled parent updates and moved forward
to correctly show no divergence, while still detecting true conflicts
where parent and sandbox evolved independently.

Changes:
- Modify get_workflow_version_hashes_by_name to return all version hashes
  grouped by workflow name instead of just HEAD hash
- Update diverged_workflows/2 to check if parent HEAD exists in sandbox
  history list
- Refactor has_diverged?/2 to delegate to diverged_workflows/2
- Add comprehensive tests validating version history comparison logic
@josephjclark
Copy link
Collaborator

@midigofrank I don't want to merge this until we've done the demo release - so I'm gonna pause review today. I'll review all your sandbox PRs together (maybe EOD tomorrow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

sandboxes: when projects have diverged, tell me which workflows are in conflict

2 participants