fix(workflows): keep the version history tab alive without a cascading workspace - #994
Open
RalfvandenBurg wants to merge 1 commit into
Conversation
…g workspace VersionHistoryTab takes its workspace as a [CascadingParameter] of the concrete WorkflowDefinitionWorkspace type, so a host that cascades a workspace of any other type leaves the parameter null. Downstream hosts hit this by copying WorkflowDefinitionWorkspace into their own namespace to change what it instantiates: the copy still cascades itself and still renders this package's un-forked WorkflowProperties, but the cascaded value no longer matches the type this tab asks for. The tab then dereferenced Workspace unconditionally. OnInitialized threw a NullReferenceException into an error boundary, and IDisposable.Dispose threw a second one from the disposal batch of the renderer, where no boundary can catch it - so opening the tab terminated the whole Blazor circuit and every other page in the Studio went dead behind "An error has occurred. This application may no longer respond until reloaded." Version history is the only one of the four workflow property tabs that reaches for the workspace this way; Properties, Variables and Input/Output take the definition as an ordinary parameter, which is why nothing else broke. Workspace is now nullable and every use tolerates its absence: the version list still loads and is browsable, while the actions that genuinely need a workspace (view, rollback, delete, bulk delete) report no edit permission and return early. Loss of the auto-refresh subscription is the only behaviour given up, and only in hosts where the parameter was already null. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
PR author is not in the allowed authors list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
VersionHistoryTabtakes its workspace as a[CascadingParameter]of the concreteWorkflowDefinitionWorkspacetype:Any host that cascades a workspace of a different type leaves that parameter
null. Downstream hosts reach this state by copyingWorkflowDefinitionWorkspaceinto their own namespace to change whichWorkflowEditorit instantiates: the copy still does<CascadingValue Value="this">and still renders this package's un-forkedWorkflowProperties, but the cascaded value no longer matches the type this tab asks for.Because both dereferences were unconditional, opening the tab produced two exceptions:
The first is caught by an error boundary. The second is thrown from
Dispose()inside the renderer's disposal batch, where no boundary can catch it — so it terminates the entire Blazor circuit. The user seesAn error has occurred. This application may no longer respond until reloaded.and every other page in the Studio is dead until they reload, not just this tab.Version history is the only one of the four workflow property tabs that reaches for the workspace this way —
Properties,VariablesandInput/Outputtake the definition as an ordinary parameter — which is why nothing else broke.The change
Workspacebecomes nullable and every use tolerates its absence:OnInitialized/Dispose— subscribe and unsubscribe only when a workspace is present, so nothing can throw during the disposal batch.IsReadOnly→trueandHasWorkflowEditPermission→falsewhen there is no workspace, which disables bulk actions, rollback and delete through the existingCanRollback/CanDeletechecks.ViewVersionAsync,OnRollbackClicked,OnDeleteClicked,OnBulkDeleteClicked— return early rather than dereference.The version list itself still loads and is browsable, since it only needs
DefinitionIdandIWorkflowDefinitionService. The one behaviour given up is the auto-refresh subscription, and only in hosts where the parameter was alreadynull.This is deliberately the conservative fix. The underlying design question — that this tab depends on a concrete component type while its siblings depend on
IWorkspace, which today carries onlyIsReadOnlyandHasWorkflowEditPermission— would needIWorkspacewidened withWorkflowDefinitionUpdated,DisplayWorkflowDefinitionVersionAsync,DisplayLatestWorkflowDefinitionVersionAsync,IsSelectedDefinitionandGetSelectedDefinition. Happy to follow up with that if you would prefer it over the guards.Tests
VersionHistoryTabMissingWorkspaceTestsrenders the tab with no cascading workspace and pins three things: the version list loads, disposal does not throw, and the edit actions are disabled. All three fail onmainwithNullReferenceExceptionatVersionHistoryTab.OnInitialized()and pass with this change.Elsa.Studio.Workflows.Tests: 210/210 pass.Elsa.Studio.Workflowsbuilds with 0 warnings.🤖 Generated with Claude Code