Skip to content

feat: Concurrent executions with indexedDB #1235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: feature/distributed-demo
Choose a base branch
from

Conversation

Microchesst
Copy link
Contributor

Pull Request Template

Title

Implement Concurrent Digital Twin Execution with IndexedDB Integration

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Security patch
  • UI/UX improvement

Description

This PR implements concurrent execution for Digital Twins with IndexedDB integration. Users can now start multiple executions of the same Digital Twin simultaneously, with execution history persisted in the browser's IndexedDB. The implementation includes a new execution history data model, IndexedDB service, and UI components to display and manage execution history.

##Working on Testing

  • Added unit tests for the IndexedDB service and Redux store
  • Manually tested concurrent execution functionality
  • Verified persistence of execution history across browser sessions
  • Fixed existing tests to accommodate the new functionality

Impact

  • Improves user experience by allowing multiple executions to run in parallel
  • Adds local persistence of execution history using IndexedDB
  • Enhances the UI with execution history list and status indicators

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have added tests for all the new code and any changes made to existing code.
  • I have made corresponding changes to the documentation.

@Microchesst
Copy link
Contributor Author

I know the test are not working currently. Its just to show the feature, i will work on the test. I am having trouble with getting test of redux to work 😕

@prasadtalasila
Copy link
Contributor

@Microchesst thanks for the PR. I will get back to you by Monday.

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

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

@Microchesst Thanks for the PR. The feature looks really nice. Please see the comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

please move all the *.ts files in route/digitaltwins/execute to model/backend/gitlab/execution directory. Do remember to

  1. create an interface for each class so that testing becomes easier. The interfaces related to pipelines can be kept in model/backend/gitlab/execution/interfaces.ts
  2. always have preview/ code depend on stable codebase rather than other way around

Copy link
Contributor

Choose a reason for hiding this comment

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

This file can be placed in src/route/digitaltwins.ts. Do remember to create an inerface / type for the IndexDBService class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make src/database/digitaltwins.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a redux slice, can it be placed in model/...?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do think about the appropriate location for these slices. Is it src/store or src/model/store?

Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 84.55446% with 78 lines in your changes missing coverage. Please review.

Project coverage is 89.97%. Comparing base (664266b) to head (047f00d).

Current head 047f00d differs from pull request most recent head 9d3f7e3

Please upload reports for the commit 9d3f7e3 to get more accurate results.

Files with missing lines Patch % Lines
client/src/preview/store/executionHistory.slice.ts 75.70% 26 Missing ⚠️
client/src/preview/services/indexedDBService.ts 82.40% 22 Missing ⚠️
client/src/preview/util/digitalTwin.ts 82.25% 11 Missing ⚠️
...eview/route/digitaltwins/execute/pipelineChecks.ts 68.96% 9 Missing ⚠️
...review/route/digitaltwins/execute/pipelineUtils.ts 80.00% 5 Missing ⚠️
...view/components/execution/ExecutionHistoryList.tsx 94.44% 4 Missing ⚠️
...view/route/digitaltwins/execute/pipelineHandler.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           feature/distributed-demo    #1235      +/-   ##
============================================================
- Coverage                     92.08%   89.97%   -2.11%     
============================================================
  Files                            92       96       +4     
  Lines                          2526     2982     +456     
  Branches                        406      497      +91     
============================================================
+ Hits                           2326     2683     +357     
- Misses                          197      296      +99     
  Partials                          3        3              
Files with missing lines Coverage Δ
client/src/preview/components/asset/AssetCard.tsx 88.70% <100.00%> (ø)
client/src/preview/components/asset/LogButton.tsx 100.00% <100.00%> (ø)
...t/src/preview/components/asset/StartStopButton.tsx 100.00% <100.00%> (ø)
client/src/preview/model/executionHistory.ts 100.00% <100.00%> (ø)
...c/preview/route/digitaltwins/execute/LogDialog.tsx 100.00% <100.00%> (ø)
client/src/preview/store/digitalTwin.slice.ts 97.05% <ø> (ø)
...view/route/digitaltwins/execute/pipelineHandler.ts 97.56% <94.73%> (-2.44%) ⬇️
...view/components/execution/ExecutionHistoryList.tsx 94.44% <94.44%> (ø)
...review/route/digitaltwins/execute/pipelineUtils.ts 85.93% <80.00%> (-7.95%) ⬇️
...eview/route/digitaltwins/execute/pipelineChecks.ts 84.50% <68.96%> (-15.50%) ⬇️
... and 3 more

... and 1 file with indirect coverage changes

Components Coverage Δ
Website 89.97% <84.55%> (-2.11%) ⬇️
Lib Microservice ∅ <ø> (∅)
🚀 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.

@prasadtalasila
Copy link
Contributor

@Microchesst please move your pure typescript files (*.ts) to model/backend/gitlab/execution.

@prasadtalasila
Copy link
Contributor

The redux slices can be placed on model/backend/gitlab/state and import the same into the aggregation modules in src/store.

Copy link
Contributor

Choose a reason for hiding this comment

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

please change the following line.

    "test:e2e": "yarn config:test && yarn build:prod && playwright test -c ./playwright.config.ts",

@prasadtalasila prasadtalasila requested a review from Copilot May 24, 2025 19:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds concurrent execution support for Digital Twins by persisting and managing execution history in IndexedDB and enhancing the UI to display and control multiple runs.

  • Migrate digital-twin state and actions to model/backend/gitlab slices and introduce IndexedDB schema/service.
  • Introduce ExecutionHistoryLoader for initial load and polling, plus ExecutionHistoryList, updated dialogs/buttons to surface history.
  • Extend pipeline handlers (pipelineUtils, pipelineHandler, pipelineChecks) to create, track, and update concurrent executions.

Reviewed Changes

Copilot reviewed 65 out of 65 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
client/src/preview/route/digitaltwins/execute/LogDialog.tsx Fetch execution history via thunk and render ExecutionHistoryList instead of inline logs
client/src/preview/route/digitaltwins/editor/Sidebar.tsx Updated selectDigitalTwinByName import to new model/backend slice
client/src/preview/route/digitaltwins/create/CreateDTDialog.tsx Switched setDigitalTwin import to new model/backend slice
client/src/preview/components/execution/ExecutionHistoryLoader.tsx New component to load all history on startup and poll running executions
client/src/preview/components/execution/ExecutionHistoryList.tsx New list component displaying sorted history with stop/delete controls and log details
client/src/preview/components/asset/StartStopButton.tsx Show running count, integrate handleStart, and replace loading indicator
client/src/preview/components/asset/LogButton.tsx Add badge count for history entries and disable logic based on execution count
client/src/preview/components/asset/DetailsButton.tsx Updated selectDigitalTwinByName import path
client/src/preview/components/asset/AssetCard.tsx Initialize logButtonDisabled to false and pass assetName to LogButton
client/src/preview/components/asset/AssetBoard.tsx Updated setShouldFetchDigitalTwins import to new model/backend slice
client/src/model/backend/gitlab/types/executionHistory.ts New ExecutionStatus, JobLog, ExecutionHistoryEntry, and IndexedDB schema/types
client/src/model/backend/gitlab/state/executionHistory.slice.ts New slice with CRUD thunks, selectors, and polling logic for concurrent execution tracking
client/src/model/backend/gitlab/state/digitalTwin.slice.ts Aligned JobLog type import and added selectDigitalTwins selector
client/src/model/backend/gitlab/execution/pipelineUtils.ts Refactored pipeline state helpers to support execution history updates and concurrent flows
client/src/model/backend/gitlab/execution/pipelineHandler.ts Updated handleStart/handleStop to dispatch history fetch and pass executionId
client/src/model/backend/gitlab/execution/pipelineChecks.ts Enhanced status checks to update IndexedDB, handle timeouts, and use new interfaces
client/src/model/backend/gitlab/execution/interfaces.ts Defined PipelineStatusParams and PipelineHandlerDispatch for typed thunk usage
client/src/database/digitalTwins.ts IndexedDB service implementation conforming to new schema for persisting execution history
client/src/AppProvider.tsx Registered ExecutionHistoryLoader at the app root
client/package.json Added uuid, @types/uuid, fake-indexeddb and updated dependencies for IndexedDB and IDs
Comments suppressed due to low confidence (3)

client/src/preview/components/execution/ExecutionHistoryLoader.tsx:15

  • ExecutionHistoryLoader handles initial data fetch and polling but has no associated unit or integration tests. Consider adding tests to cover its effect logic and cleanup of the interval.
const ExecutionHistoryLoader: React.FC = () => {

client/src/preview/route/digitaltwins/execute/LogDialog.tsx:27

  • [nitpick] The component is named LogDialog but now presents execution history. Consider renaming it to ExecutionHistoryDialog for clarity and consistency with its content.
function LogDialog({ showLog, setShowLog, name }: LogDialogProps) {

client/src/model/backend/gitlab/execution/pipelineChecks.ts:76

  • Calling digitalTwin.getExecutionHistoryById assumes the DigitalTwin class exposes that method, but IndexedDB access should use indexedDBService. Replace this with indexedDBService.getExecutionHistoryById to avoid runtime errors.
const pipelineId = executionId

Comment on lines +55 to +57
const setButtonText = () => {}; // Dummy function since we don't need to change button text
handleStart(
'Start',
Copy link
Preview

Copilot AI May 24, 2025

Choose a reason for hiding this comment

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

The call to handleStart always passes 'Start' and you’ve removed any buttonText state, so the UI can never switch to 'Stop'. This breaks the stop functionality—consider managing a local buttonText state or passing the current executionId to toggle correctly.

Suggested change
const setButtonText = () => {}; // Dummy function since we don't need to change button text
handleStart(
'Start',
const newButtonText = buttonText === 'Start' ? 'Stop' : 'Start';
setButtonText(newButtonText);
handleStart(
newButtonText,

Copilot uses AI. Check for mistakes.

}
}, [dispatch, name, showLog]);

const handleViewLogs = () => {};
Copy link
Preview

Copilot AI May 24, 2025

Choose a reason for hiding this comment

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

handleViewLogs is defined with no parameters but ExecutionHistoryList expects onViewLogs to accept an executionId: string. Either implement log fetching there or remove the unused callback.

Suggested change
const handleViewLogs = () => {};
const handleViewLogs = (executionId: string) => {
console.log(`View logs for execution ID: ${executionId}`);
};

Copilot uses AI. Check for mistakes.

Comment on lines +317 to +318
(jobLog: JobLog, index: number) => (
<div key={index} style={{ marginBottom: '16px' }}>
Copy link
Preview

Copilot AI May 24, 2025

Choose a reason for hiding this comment

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

[nitpick] Using the array index as a React key can lead to rendering issues if logs change order or new logs are inserted. Use a stable identifier (e.g., jobLog.jobName or a combined ID) instead.

Suggested change
(jobLog: JobLog, index: number) => (
<div key={index} style={{ marginBottom: '16px' }}>
(jobLog: JobLog) => (
<div key={jobLog.jobName} style={{ marginBottom: '16px' }}>

Copilot uses AI. Check for mistakes.

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