Skip to content

Integrate intocps/workspace and fetch workbench links from services API #1464

Closed
Copilot wants to merge 7 commits intofeature/distributed-demofrom
copilot/integrate-new-workspace
Closed

Integrate intocps/workspace and fetch workbench links from services API #1464
Copilot wants to merge 7 commits intofeature/distributed-demofrom
copilot/integrate-new-workspace

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Pull Request Template

Title

Fix React hooks violations, eslint errors, and runtime crash in workspace integration

Type of Change

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

Description

The workbench page crashes at runtime with React error #310 ("Rendered more hooks than during the previous render") because getWorkbenchLinkValues calls useSelector and useUserLink (which itself calls useSelector) inside a forEach loop — violating React's rules of hooks.

Additionally, eslint flagged 6 errors across 4 files, and qlty flagged multiple Array#push() calls.

Core fix — envUtil.ts

  • Rename getWorkbenchLinkValuesuseWorkbenchLinkValues (it's a hook)
  • Extract buildUserLink pure function for use inside .map(), replacing the hook-in-loop pattern
  • Hoist all useSelector calls to function top level
  • Replace imperative forEach + push with filter().map() + spread
// Before: hooks called in loop → React error #310
Object.entries(services).forEach(([serviceKey, service]) => {
  const link = useUserLink(useAppURL(), service.endpoint); // ← hook in loop
  workbenchLinkValues.push({ key: iconKey, link });
});

// After: pure function in map, hooks at top level
const serviceLinks = Object.entries(services)
  .filter(([serviceKey]) => serviceKeyToIconKey[serviceKey])
  .map(([serviceKey, service]) => ({
    key: serviceKeyToIconKey[serviceKey],
    link: buildUserLink(appURL, username, service.endpoint),
  }));
return [...serviceLinks, ...previewLinks];

ESLint fixes

  • Remove unused waitFor import in Workbench.test.tsx
  • Replace as anyas ReturnType<typeof fetchWorkspaceServices> in workspaceServices.slice.test.ts
  • Replace Function type → (state: Record<string, unknown>) => unknown in envUtil.test.ts
  • Remove unused WorkspaceService import in slice test

Cascading renames

Updated all references from getWorkbenchLinkValuesuseWorkbenchLinkValues in Workbench.tsx, global_mocks.tsx, envUtil.test.ts, Workbench.test.tsx, and LinkButtons.tsx docstring.

Testing

All existing test suites pass after changes:

  • Unit: 34 suites, 284 tests
  • Integration: 11 suites, 44 tests
  • Preview unit: 46 suites, 338 tests
  • Preview int: 23 suites, 78 tests

yarn syntax (eslint) passes with zero errors. yarn build succeeds.

Impact

Fixes a runtime crash on the workbench page. No API or behavioral changes — only the exported function name changes from getWorkbenchLinkValues to useWorkbenchLinkValues.

Additional Information

React error #310 reference: https://react.dev/errors/310

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.
Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE]Integrate new workspace</issue_title>
<issue_description>## Describe the feature

As a user I want to use new workspace So That latest Ubuntu can be used in user workspace.

Describe the problems your feature request solves

The current code base uses ml-workspace-minimal. Instead the intocps/workspace image available on docker hub must be used.

docker pull intocps/workspace:latest

This image provides upgraded versions of services and the operating system from Ubuntu 20.04 to Ubuntu 24.04.

Describe the solution you'd like

Use New Workspace

Use intocps/workspace image available on docker hub.

docker pull intocps/workspace:latest

This image provides list of services at a URL of user workspace. For example, the user workspace of user1 of the DTaaS hosted at https://foo.com, provides listing of services at https://foo.com/user1/services. The format of JSON services is here.

{
  "desktop": {
    "name": "Desktop",
    "description": "Virtual Desktop Environment",
    "endpoint": "tools/vnc?path=user1%2Ftools%2Fvnc%2Fwebsockify"
  },
  "vscode": {
    "name": "VS Code",
    "description": "VS Code IDE",
    "endpoint": "tools/vscode"
  },
  "notebook": {
    "name": "Jupyter Notebook",
    "description": "Jupyter Notebook",
    "endpoint": ""
  },
  "lab": {
    "name": "Jupyter Lab",
    "description": "Jupyter Lab IDE",
    "endpoint": "lab"
  }
}

See the Documentation

Update Client Config

The format of client config must be updated from

if (typeof window !== 'undefined') {
  window.env = {
    REACT_APP_ENVIRONMENT: 'test',
    REACT_APP_URL: 'http://localhost:4000/',
    REACT_APP_URL_BASENAME: '',
    REACT_APP_URL_DTLINK: '/lab',
    REACT_APP_URL_LIBLINK: '',
    REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
    REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
    REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
    REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
    REACT_APP_WORKBENCHLINK_LIBRARY_PREVIEW: '/preview/library',
    REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

    REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
    REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com',
    REACT_APP_REDIRECT_URI: 'http://localhost:4000/Library',
    REACT_APP_LOGOUT_REDIRECT_URI: 'http://localhost:4000/',
    REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
  };
};

to new format given below.

if (typeof window !== 'undefined') {
  window.env = {
    REACT_APP_ENVIRONMENT: 'test',
    REACT_APP_URL: 'http://localhost:4000/',
    REACT_APP_URL_BASENAME: '',
    REACT_APP_URL_DTLINK: '/lab',
    REACT_APP_URL_LIBLINK: '',

    REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
    REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com',
    REACT_APP_REDIRECT_URI: 'http://localhost:4000/Library',
    REACT_APP_LOGOUT_REDIRECT_URI: 'http://localhost:4000/',
    REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
  };
};

The required workbench links for

  • REACT_APP_WORKBENCHLINK_VNCDESKTOP
  • REACT_APP_WORKBENCHLINK_VSCODE
  • REACT_APP_WORKBENCHLINK_JUPYTERLAB
  • REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK

must be derived from the services json fetched from https://foo.com/user1/services. Fetch this json object once and place it in redux store. Further references to the services can be fulfilled by referring to the json object stored in redux store.

Client Code Updates

The following parts of code base must be updated.

  • client/config: update the config formats in all of these files
  • client/src/ and client/test: update code to fulfill the requirement. The core of the changes might be required in client/src/util but check for cascading changes in other parts of the code base. The code in client/src/model do not need to be updated

Update Docker Compose Files

Update the developer docker compose files to use the intocps/workspace:latest in the place of mltooling/ml-workspace-minimal:0.13.2.

Success Criterion

Checklist:

  • New workspace links work after integration with the new workspace
  • Unit and integration tests are updated and run successfully
  • Test coverage is improved
  • All the changes linked of code have more than 90% test coverage
  • Code review issues raised by Copilot are addressed
  • No qlty issues
    </issue_description>

<agent_instructions>Use "System Architect" custom agent to make proper plan of implementation and then implement the feature.</agent_instructions>

##...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… docker compose files

- Create workspaceServices Redux slice for fetching/storing workspace services
- Update envUtil to derive workbench links from Redux services state
- Update Workbench component to fetch services from API
- Remove REACT_APP_WORKBENCHLINK_* from all config files
- Update env.d.ts type definitions
- Update configUtil.ts validation keys
- Replace mltooling/ml-workspace-minimal:0.13.2 with intocps/workspace:latest

Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
@qltysh
Copy link

qltysh bot commented Feb 12, 2026

❌ 1 blocking issue (2 total)

Tool Category Rule Count
ruff Style Incorrect formatting, autoformat by running qlty fmt. 1
qlty Structure Function with many returns (count = 5): checkRunningExecutions 1

@qltysh one-click actions:

  • Auto-fix formatting (qlty fmt && git push)

…ation

- Update envUtil tests to use Redux-based services instead of env vars
- Update Workbench unit test with dispatch mock
- Update Workbench integration test with services in Redux store
- Update Config test to remove workbench link assertion
- Add workspaceServices.slice tests with 100% coverage

Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
…ervice keys

Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
Copilot AI changed the title [WIP] Add integration of new workspace for Ubuntu 24.04 Integrate intocps/workspace and fetch workbench links from services API Feb 12, 2026
Copilot AI requested a review from prasadtalasila February 12, 2026 18:08
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.96%. Comparing base (0b82a89) to head (2a50965).
⚠️ Report is 1 commits behind head on feature/distributed-demo.

⚠️ Current head 2a50965 differs from pull request most recent head f8b9707

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

Additional details and impacted files
@@                      Coverage Diff                      @@
##           feature/distributed-demo    #1464       +/-   ##
=============================================================
+ Coverage                     80.10%   96.96%   +16.86%     
=============================================================
  Files                            14        5        -9     
  Lines                          1940      264     -1676     
=============================================================
- Hits                           1554      256     -1298     
+ Misses                          386        8      -378     

see 19 files with indirect coverage changes

Components Coverage Δ
Website ∅ <ø> (∅)
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.

…gration

- Rename getWorkbenchLinkValues to useWorkbenchLinkValues (follows React hooks naming convention since it calls useSelector)
- Extract buildUserLink pure function to avoid calling hooks inside loops (fixes React error #310)
- Replace multiple Array#push() calls with spread operator
- Remove unused waitFor import from Workbench.test.tsx
- Replace 'as any' with proper ReturnType<typeof fetchWorkspaceServices> in tests
- Replace unsafe Function type with typed selector parameter in envUtil.test.ts
- Remove unused WorkspaceService import from slice test

Co-authored-by: prasadtalasila <9206466+prasadtalasila@users.noreply.github.com>
Copilot AI changed the title Integrate intocps/workspace and fetch workbench links from services API Fix React hooks violations, eslint errors, and runtime crash in workspace integration Feb 13, 2026
@sonarqubecloud
Copy link

@prasadtalasila prasadtalasila changed the title Fix React hooks violations, eslint errors, and runtime crash in workspace integration Integrate intocps/workspace and fetch workbench links from services API Feb 13, 2026
@prasadtalasila prasadtalasila deleted the copilot/integrate-new-workspace branch February 22, 2026 10:37
@prasadtalasila prasadtalasila restored the copilot/integrate-new-workspace branch February 22, 2026 10:38
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.

[FEATURE]Integrate new workspace

2 participants