Skip to content

Fix/issue 4371 migrated datasets sorting#4406

Open
Saksham-Gupta-GH wants to merge 1 commit into
zowe:mainfrom
Saksham-Gupta-GH:fix/issue-4371-migrated-datasets-sorting
Open

Fix/issue 4371 migrated datasets sorting#4406
Saksham-Gupta-GH wants to merge 1 commit into
zowe:mainfrom
Saksham-Gupta-GH:fix/issue-4371-migrated-datasets-sorting

Conversation

@Saksham-Gupta-GH

Copy link
Copy Markdown
Contributor

Proposed changes

Resolves #4371.

Previously, SharedUtils.sortTreeItems only accepted a single string for specificContext, and DatasetTree.ts passed Constants.DS_SESSION_CONTEXT + Constants.FAV_SUFFIX. Because migrated datasets use the distinct DS_MIGRATED_FILE_CONTEXT, they failed the string match and were systematically pushed to the bottom of the array during the Favorites tree sort.

This PR updates SharedUtils.sortTreeItems to accept an array of contexts (specificContext: string | string[]) and updates DatasetTree.ts to pass an array containing both the standard dataset context and the migrated dataset context, allowing them to sort together alphabetically.

Release Notes

Milestone: TBD

Changelog: Fix migrated datasets in favorites appearing at the bottom rather than sorting alphabetically

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds or improves functionality)
  • Breaking change (a change that would cause existing functionality to not work as expected)
  • Documentation (Markdown, README updates)
  • Other (please specify above in "Proposed changes" section)

Checklist

All checks must pass before this pull request is reviewed by the Zowe Explorer squad.

General

  • I have read the CONTRIBUTOR GUIDANCE wiki
  • All PR dependencies have been merged and published (if applicable)
  • A GIF or screenshot is included in the PR for visual changes
  • The pre-publish command has been executed:
    • v2 and below: yarn workspace vscode-extension-for-zowe vscode:prepublish
    • v3: pnpm --filter vscode-extension-for-zowe vscode:prepublish
  • New ZE APIs are tested with extender types that haven't adopted yet to determine breaking changes. Can use Zowe zFTP marketplace extension.

Code coverage

  • There is coverage for the code that I have added
  • I have added new unit test cases and they are passing
  • I have added at least one end-to-end test for new features to validate behavior (if applicable)
  • I have manually tested the changes

Deployment

  • I have tested new functionality with the FTP extension and profile verifying no extender profile type breakages introduced
  • I have added developer documentation (if applicable)
  • I have verified that all dependency updates (such as Zowe SDKs) in this pull request are compatible
  • Documentation should be added to Zowe Docs
  • These changes may need ported to the appropriate branches (list here):

Further comments

The unit tests in SharedUtils.unit.test.ts naturally support this modification, and the entire test suite has been run and passes locally.

@zowe-robot zowe-robot moved this from New Issues to Review/QA in Zowe Explorer for VS Code Jul 16, 2026
@Saksham-Gupta-GH
Saksham-Gupta-GH force-pushed the fix/issue-4371-migrated-datasets-sorting branch from 9b6b96d to 94196c5 Compare July 16, 2026 21:58
@pull-request-size pull-request-size Bot added size/S and removed size/M labels Jul 16, 2026
@Saksham-Gupta-GH
Saksham-Gupta-GH force-pushed the fix/issue-4371-migrated-datasets-sorting branch from 94196c5 to 01dde83 Compare July 16, 2026 22:02

@traeok traeok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The symptom ("migrated data sets always shown at the bottom") happens on load, and sortTreeItems is never called on the load path. sortTreeItems is only invoked from addFavorite / addMemberToFavorites (in-session add-time). Favorites are loaded by refreshFavorites, which reads from separate persistence buckets and concatenates migrated ones last:

const combinedLines = [
    ...this.mPersistence.readFavorites(),
    ...this.mPersistence.readVsamFavorites(),
    ...this.mPersistence.readMemberFavorites(),
    ...this.mPersistence.readMigratedFavorites(),   // appended LAST
];

refreshFavorites then pushes these into favProfileNode.children in that order with no sort. Correspondingly, updateFavorites splits migrated favorites into their own migratedFavorites bucket on save. So migrated favorites are persisted separately and always reloaded at the end of the list - and no in-memory sort survives a restart.

The correct fix is to sort each profile's children after loading - for example, call the existing, unmodified SharedUtils.sortTreeItems(favProfileNode.children, Constants.DS_SESSION_CONTEXT + Constants.FAV_SUFFIX) at the end of refreshFavorites (my manual test shows the original signature already interleaves migrated alphabetically). The string | string[] signature change is unnecessary for the real fix.

@traeok traeok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above comments for details

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.85%. Comparing base (2f75425) to head (01dde83).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4406   +/-   ##
=======================================
  Coverage   94.85%   94.85%           
=======================================
  Files         146      146           
  Lines       30936    30948   +12     
  Branches     7643     7644    +1     
=======================================
+ Hits        29344    29356   +12     
  Misses       1592     1592           

☔ View full report in Codecov by Harness.
📢 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.

@Saksham-Gupta-GH
Saksham-Gupta-GH force-pushed the fix/issue-4371-migrated-datasets-sorting branch from 01dde83 to 44d5250 Compare July 17, 2026 18:20
@Saksham-Gupta-GH
Saksham-Gupta-GH force-pushed the fix/issue-4371-migrated-datasets-sorting branch from 44d5250 to 6ab9a37 Compare July 17, 2026 18:26
This fixes zowe#4371

Signed-off-by: Saksham Gupta <sakshamgupta@Jawahars-MacBook-Air-2.local>
@Saksham-Gupta-GH
Saksham-Gupta-GH force-pushed the fix/issue-4371-migrated-datasets-sorting branch from 6ab9a37 to 34f134a Compare July 17, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review/QA

Development

Successfully merging this pull request may close these issues.

Migrated data sets in favorites are always at the bottom

3 participants