Skip to content

Conversation

@lmac-1
Copy link
Collaborator

@lmac-1 lmac-1 commented Nov 7, 2025

Description

This PR improves the history panel experience in the collaborative editor by fixing critical bugs that prevented navigation to the "view all history" page and adding a version mismatch warning to prevent user confusion.

Closes #3814 and point 1 of #3940

History page 500 error when navigating from collaborative editor

image
  • Frontend: Fix workflow ID extraction in MiniHistory - was taking "collaborate" instead of the actual UUID from /w/:id/collaborate URLs
  • Backend: Handle nil case in humanize_workflow when workflow not found
  • Impact: "View History" button now works from collaborative editor

Feature: Version mismatch warning banner

Shows a warning when viewing latest workflow but selected run was executed on an older version. Prevents confusion when workflow structure has changed since the run executed. Appears when:

  • Run selected AND viewing "latest" AND versions differ

Example message:

image

⚠️ This run was executed on version 66, but you're viewing version 67. Steps shown may not match the current workflow structure.

Testing

  • All existing tests passing
  • 8 new unit tests for version mismatch detection hook

Validation steps

Version mismatch warning:
You have two choices

  1. Pick an existing workflow where the structure has changed over time in the last 20 runs
  2. Make an update to an existing workflow and click Save

Once you have a workflow where the latest version is different to previous version:

  1. Select an old run while viewing "latest" -> Banner appears
  2. Switch to matching snapshot version -> Banner disappears
  3. Deselect run -> Banner disappears

Bug fix:

  1. Open workflow in collaborative editor -> Click the little icon next to "View full history" (marked in screenshot above)
  2. Verify history page loads AND that it has the correct content (it previously crashed)

Additional notes for the reviewer

I tried to make the banner look similar to existing banner in LiveView using Tailwind colours.

AI Usage

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

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Pre-submission checklist

  • I have performed a self-review of my 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

Display warning banner when viewing latest workflow version but selected
run was executed on an older version. This prevents user confusion when
workflow structure has changed since the run executed (jobs added,
removed, or modified).

Features:
- VersionMismatchBanner component using bg-yellow-100 styling to match
  other warning elements (VersionDropdown, credential badges)
- useVersionMismatch hook encapsulating detection logic
- Full-width banner at top of canvas, consistent with LiveView alerts
- 8 passing tests covering all edge cases and null safety

The banner shows when:
- A run is selected from history
- Viewing "latest" workflow (not a specific snapshot)
- Run's version differs from current workflow version
Fixes two related bugs that prevented the history page from loading when
navigating from the collaborative editor:

1. Backend: Fix MatchError crash in humanize_workflow
   - Handle nil case when Enum.find doesn't find the workflow
   - Previously crashed with "no match of right hand side value: nil"
   - Now returns empty string when workflow not found

2. Frontend: Fix workflow ID extraction in MiniHistory
   - Extract workflow ID from position [1] instead of last element
   - Previously took "collaborate" instead of the actual workflow UUID
   - Now works for both /w/:id and /w/:id/collaborate URLs

The bug occurred when clicking "View History" from the collaborative
editor because the frontend was sending workflow_id="collaborate" which
the backend couldn't find, causing a 500 error.
@github-project-automation github-project-automation bot moved this to New Issues in v2 Nov 7, 2025
@lmac-1 lmac-1 requested review from stuartc and taylordowns2000 and removed request for taylordowns2000 November 7, 2025 14:54
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.79%. Comparing base (9cad92e) to head (899f337).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3941   +/-   ##
=======================================
  Coverage   88.79%   88.79%           
=======================================
  Files         422      422           
  Lines       18772    18772           
=======================================
+ Hits        16668    16669    +1     
+ Misses       2104     2103    -1     

☔ 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.

@lmac-1 lmac-1 removed the request for review from stuartc November 7, 2025 16:48
Adds test case to cover the nil branch when a workflow_id filter
references a workflow that doesn't exist in the workflows list.
@lmac-1
Copy link
Collaborator Author

lmac-1 commented Nov 7, 2025

This one is ready for review @stuartc @taylordowns2000 @theroinaochieng ☺️. Probably one for Monday now.

@lmac-1
Copy link
Collaborator Author

lmac-1 commented Nov 7, 2025

@stuartc I decided to put the version mismatch stuff in a hook to not overcomplicate components. There's also a test to test the logic of the hook.

Copy link
Member

@taylordowns2000 taylordowns2000 left a comment

Choose a reason for hiding this comment

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

the history navigation link works perfectly, but I'm seeing two bugs in the version matching stuff:

  1. when going to an old run, it should take you to that version—not keep you on latest and show the mismatch banner. (play around with this feature on the legacy canvas to see how it should work.)
  2. i'm seeing all the nodes collapse into the middle.

Both of these show up in the video here: https://www.loom.com/share/5fd45ef0e7bf4911a56bf511c03729c4

@github-project-automation github-project-automation bot moved this from New Issues to In review in v2 Nov 12, 2025
@elias-ba elias-ba self-requested a review November 12, 2025 20:04
Copy link
Contributor

@elias-ba elias-ba left a comment

Choose a reason for hiding this comment

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

Hey @lmac-1 this is looking great to me from a code point of view. I alkso clicked tested and it looks great. I will leave the UI approvals to Taylor. @taylordowns2000 just wanna flag that the nodes collapsing issue might be out of scope of this work. It has became rare now but it's still happening from time to time in the app on main. I think we may need to have a proper issue for it and do deep diagnostic for it. I do think that it's deeply related to nodes positionning and layout algorithm.

@elias-ba elias-ba force-pushed the history-tidying-bugs branch 2 times, most recently from 5a92ab4 to 899f337 Compare November 12, 2025 20:36
@lmac-1
Copy link
Collaborator Author

lmac-1 commented Nov 13, 2025

Hey @taylordowns2000 thanks for the Loom, yes that makes sense, will take a look! I didn't realise that the version should update at the top.

And for the nodes collapsing, I have also been seeing it a bit in other bits of dev work that I'm working on in other branches / main, but not sure what are the exact steps to replicate. Seems to be a bit random. As @elias-ba suggested, it might be worth diving deeper into that in a separate issue. Will try to keep an eye out for it though to see what is causing it.

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.

Canvas: View a Run on the Canvas

4 participants