Skip to content

Instance View #731

Open
Zayn-Javed wants to merge 11 commits intomainfrom
instance-view-ui
Open

Instance View #731
Zayn-Javed wants to merge 11 commits intomainfrom
instance-view-ui

Conversation

@Zayn-Javed
Copy link
Copy Markdown
Contributor

Summary

  1. Instance select dropdown now shows the sorted instance (always new instance on top)

  2. Reorganized the Start/Resume/Pause/Stop buttons:

  3. Start new instance button is now conditionally shown based on whether the process has a plain start event.

  4. Added new button with spinning green icon when process is active, static black when inactive. This Button only appears when the current process version has at least one Timer Start Event

  5. Made the Resume/Pause/Stop group to a 2-icon-group. The Resume icon (Play symbol) instead of the Pause icon is now shown if the process is paused.

  6. Added GET /process/:definitionId/versions/:version/active endpoint to retrieve the real activation state of a deployed process version from the engine

  7. Activation state is fetched from the backend on every page load so navigating away and back always reflects the real state

@Zayn-Javed Zayn-Javed changed the title Instance view UI Instance View Mar 31, 2026
@github-actions

This comment has been minimized.

const { definitionId, version } = req.params;
const engine = management.getEngineWithDefinitionId(definitionId);

if (!engine) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One could potentially argue that a missing engine means that the version is in the state of "not active". In that case you could theoretically return a success here.
Maybe you should just check if the version is deployed to this engine. If not return an error and if yes return active as false if no engine is found or when the specific version is not loaded in the engine.
This way we get the semantic meaning that any version that was deployed to a machine is either in an active or inactive state and only querying for the active state of a non-existing version is considered an error.

The way this is currently implemented you get errors in the MS backend when the version is not loaded into an engine.
Steps to reproduce:

  1. Deploy a process with a timer to an engine
  2. Stop the engine (e.g. Ctrl+C in the terminal)
  3. Start the engine again
  4. Open the deployment view for the process
  5. Look in to the log of the ms backend

};
}

const process = engine._versionProcessMapping[version];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I wouldn't use these kinds of access to "private" members of the engine outside the file in which engine is defined. Maybe create a new function "isProcessVersionDeployed" similar to "undeployProcessVersion" in "engine.js" and check in there if the version is deployed in the execution environment.


const process = engine._versionProcessMapping[version];

if (!process) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See my comment about what might be considered "not active" above.

import useInstanceVariables from './use-instance-variables';
import { inlineScript, inlineUserTaskData } from '@proceed/user-task-helper';
import { toBpmnObject, getStartEvents, getElementById } from '@proceed/bpmn-helper';
import { useParams } from 'next/navigation';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This import does not seem to be used anymore.


if (!engines.length) return false;

const result = await getDeploymentActivation(engines[0], definitionId, version);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The assignment to "result" is not necessary since you are just returning it in the next step.

}
toBpmnObject(currentVersion.bpmn)
.then(async (bpmnObj) => {
const startEventIds = await getStartEvents(bpmnObj);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could skip a step by doing const startEvents = await getElementsByTagName(bpmnObj, 'bpmn:StartEvent') instead.

setHasPlainStartEvents(false);
return;
}
toBpmnObject(currentVersion.bpmn)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I would find it a bit better to use an async function instead of a promise and then a "then".
Basically

useEffect(() => {
  ...
  async function initStartEventInfo() {
    try {
      const bpmnObj = await toBpmnObject(currentVersion.bpmn);
      ...
    } catch (_) {}
  }

  initStartEventInfo();
}, [currentVersion?.bpmn]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I usually prefer to use promises. I am not sure why, but they just look cleaner and better to me :) Nevertheless, I have updated it to use an async function according to your suggestion.

useEffect(() => {
if (!currentVersion) return;
setIsActivationLoading(true);
getProcessActivationStatus(processId, activeSpaceId, currentVersion.versionId)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar as above. I think it would be nicer to use an async function instead of a promise.

setIsActivationLoading(true);
getProcessActivationStatus(processId, activeSpaceId, currentVersion.versionId)
.then(setIsProcessActivated)
.catch(() => setIsProcessActivated(true))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is a default of "true" for the process being activated better than "false"?

Copy link
Copy Markdown
Contributor Author

@Zayn-Javed Zayn-Javed Apr 2, 2026

Choose a reason for hiding this comment

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

I was also very confused about this. I think a better approach would be to use wrapServerCall here and then show the error message in case of error and then setting the value to false. Please have a look.

<Tooltip
title={instanceIsPausing ? 'Abort pausing the instance' : 'Resume the instance'}
>
{/* New middle group: Start + Activate/Deactivate */}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I would remove the "New".

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

CLOUDRUN ACTIONS

✅ Successfully created Preview Deployment.

https://pr-731---ms-server-staging-c4f6qdpj7q-ew.a.run.app

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants