Skip to content

feat: new deploy diff#1352

Open
doc-han wants to merge 7 commits intomainfrom
diff-stuff
Open

feat: new deploy diff#1352
doc-han wants to merge 7 commits intomainfrom
diff-stuff

Conversation

@doc-han
Copy link
Copy Markdown
Collaborator

@doc-han doc-han commented Apr 2, 2026

Short Description

A one or two-sentence description of what this PR does.

Fixes #1182

Implementation Details

A more detailed breakdown of the changes, including motivations (if not provided in the issue).

QA Notes

List any considerations/cases/advice for testing/QA here.

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

Release branch checklist

Delete this section if this is not a release PR.

If this IS a release branch:

  • Run pnpm changeset version from root to bump versions
  • Run pnpm install
  • Commit the new version numbers
  • Run pnpm changeset tag to generate tags
  • Push tags git push --tags

Tags may need updating if commits come in after the tags are first generated.

@github-project-automation github-project-automation bot moved this to New Issues in Core Apr 2, 2026
@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 2, 2026

Issue I'm dealing with while doing manual testing. cc: @josephjclark
trying to get this resolved at the moment

Screenshot 2026-04-02 at 7 48 50 AM

@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 2, 2026

Issue I'm dealing with while doing manual testing. cc: @josephjclark trying to get this resolved at the moment

The fix for this bug I was facing was sitting all the base in https://github.com/OpenFn/kit/blob/main/packages/project/src/util/base-merge.ts
The call to assign over there was mutating the value of target in-place making it lose the methods on workflows.

@doc-han doc-han marked this pull request as ready for review April 7, 2026 10:45
@doc-han doc-han requested a review from josephjclark April 7, 2026 10:51
@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: changing the id of a step results in this error:

[CLI] ✘ TypeError: Cannot read properties of undefined (reading 'name')
    at file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:279:57
    at Array.map (<anonymous>)
    at generateHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:276:46)
    at Workflow.getVersionHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:462:12)
    at findLocallyChangedWorkflows (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2277:35)
    at syncProjects (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2412:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async handler (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2507:24)
    at async parse (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:4126:12)

@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: removing the configuration key doesn't seem to generate a diff (in the rich or the json one). But it should result in a change in the state.json right? I wonder if that's a wider bug

@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: changes to edges don't seem to manifest in the rich diff (I do see them in JSON)

Copy link
Copy Markdown
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

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

Looks really cool!

I've tested around a bit and found some issues. But before we go too much further I'm not sure the architecture is right, and I'd like to dig into that a bit with you later

}

export const reportDiff = (
const printStepChanges = (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we move this out of the main deploy.ts and into its own file?

lines.push(` - body: ${summary}`);
}

if (lines.length) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just thinking aloud

Instead of one function which generates ANd prints the diff at the same time, what if we have a generateDiff and a printDiff? Where the generator creates a data structure that makes printing super easy, but is also unit testable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually, just poking around, I've reminded myself that the project package has its own project-diff function, which basically does exactly that: returns a simple data structure to represent the diff (I think the the CLI then returns it)

Maybe the best approach to this then is to add a workflow-diff file (or maybe just a diff file with two functions) which can handle all the logic of generating a diff. And does complicated stuff like tracking id changes (renames, basically)


for (const step of remoteSteps) {
if (!localById[step.id]) {
logger.always(c.yellow(` ${step.id || step.name}: removed`));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think a remove step should come out in red. I also think an added step should come out in green

const added = Math.max(0, localLines - remoteLines);
const removed = Math.max(0, remoteLines - localLines);
const summary =
added === 0 && removed === 0 ? '<changed>' : `<+${added}/-${removed}>`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd like to colour that summary - new stuff in green and removed stuff in red.

But actually, aren't added and removed mutually exclusive? In which case you just want to say like +1 lines or -1 lines


// TODO: I want to report diff HERE, after the merged state and stuff has been built
if (remoteProject) {
if (options.jsonDiff) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Before we print the diff, can we add a line saying something like:

"This will make the following changes to the remote project"

const localAdaptor = step.adaptor ?? step.adaptors?.[0];
const remoteAdaptor = remote.adaptor ?? remote.adaptors?.[0];
if (localAdaptor !== remoteAdaptor) {
lines.push(` - adaptor: ${remoteAdaptor} -> ${localAdaptor}`);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This stuff is nice - but I'd like a better way to control which keys generate this from/to diff

lines.push(` - name: "${remote.name}" -> "${step.name}"`);
}

const localAdaptor = step.adaptor ?? step.adaptors?.[0];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Doesn't the serialized format ensure a consistent typing on step.adaptor?

@github-project-automation github-project-automation bot moved this from New Issues to In review in Core Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

new deploy diff

3 participants