|
| 1 | +--- |
| 2 | +name: Remove legacy org browser |
| 3 | +overview: Remove the legacy org browser from salesforcedx-vscode-core, remove the toggle setting, and make the new org browser in salesforcedx-vscode-org-browser the only implementation. Addresses a few feature gaps first. |
| 4 | +todos: |
| 5 | + - id: refresh-cache |
| 6 | + content: Fix refresh to actually invalidate cache (invalidation methods on service, refreshType calls them) |
| 7 | + status: completed |
| 8 | + - id: delete-old-source |
| 9 | + content: Delete orgBrowser/ dir and commands/retrieveMetadata/ dir from core |
| 10 | + status: pending |
| 11 | + - id: cleanup-core-index |
| 12 | + content: Remove setupOrgBrowser function, orgBrowser imports, and call site from core's index.ts |
| 13 | + status: pending |
| 14 | + - id: cleanup-core-settings |
| 15 | + content: Remove USE_LEGACY_ORG_BROWSER constant and getUseLegacyOrgBrowser() method |
| 16 | + status: pending |
| 17 | + - id: cleanup-core-packagejson |
| 18 | + content: Remove metadata view/container, old commands, old menus, old setting, walkthrough from core package.json + nls |
| 19 | + status: pending |
| 20 | + - id: remove-toggle-new |
| 21 | + content: Remove when clause from org-browser view and early-exit guard from org-browser activation |
| 22 | + status: pending |
| 23 | + - id: update-e2e-tests |
| 24 | + content: Delete or rewrite orgBrowser.e2e.ts automation test |
| 25 | + status: pending |
| 26 | + - id: verify |
| 27 | + content: Run compile, lint, effect LS, test, bundle, test:web, test:desktop (org-browser + affected), knip, check:dupes |
| 28 | + status: pending |
| 29 | +isProject: false |
| 30 | +--- |
| 31 | + |
| 32 | +# Remove Legacy Org Browser and Make New Org Browser the Default |
| 33 | + |
| 34 | +## Old vs New: Feature Comparison |
| 35 | + |
| 36 | +### Things the new org browser does BETTER |
| 37 | + |
| 38 | +- **File presence indicators**: Shows pass-filled/circle-outline icons for whether a component exists locally. Old has no equivalent. |
| 39 | +- **Effect-TS architecture**: Proper service layers, managed runtime, structured error handling. |
| 40 | +- **In-memory caching** with TTL (5-30 min) vs old file-based JSON caching. |
| 41 | +- **Custom object fields**: Correct `Object__c.Field__c` fullNames suitable for retrieve. Old used display strings. |
| 42 | +- **Collapse All**: New has it; old does not. |
| 43 | +- **Overwrite confirmation**: New shows count of components that will be overwritten. Old used a generic modal. |
| 44 | + |
| 45 | +### Gaps in the new org browser (need fixing before migration) |
| 46 | + |
| 47 | +1. **Refresh cache invalidation**: `refreshType()` fires `onDidChangeTreeData` but never passes `refresh=true` to the cache, so the refresh button re-renders stale data. Old file-based cache actually re-fetches. |
| 48 | +2. **No walkthrough**: Old contributes a 3-step walkthrough (`sf.org-browser`) in core's [package.json](packages/salesforcedx-vscode-core/package.json) lines 895-931. New has none. |
| 49 | + |
| 50 | +### Intentional omissions (acceptable to drop) |
| 51 | + |
| 52 | +- **Folder/folderType retrieve**: Metadata API doesn't support retrieve with `*` for folder types. New org browser correctly disables retrieve for `folder` and `folderType` nodes (menu `when` clause only shows retrieve for `type`, `customObject`, `component`). `getRetrieveMembers` returns `[]` for those nodes; no changes needed. |
| 53 | +- **Separate "Retrieve and Open" command**: New auto-opens when retrieving a single component (`members.length === 1`). Same UX, one fewer button. |
| 54 | +- **Separate component-level refresh command**: New uses a single `refreshType` that works on any expandable node. |
| 55 | +- **Org root node**: Old had an `Org` node at the root. New starts directly with metadata types -- cleaner. |
| 56 | +- **EmptyNode / "No components available"**: New shows nothing for empty types (VS Code's tree handles this natively with the welcome content). |
| 57 | + |
| 58 | +## Migration Plan |
| 59 | + |
| 60 | +### Phase 1: Fix gaps in the new org browser |
| 61 | + |
| 62 | +#### 1. Fix refresh cache invalidation |
| 63 | + |
| 64 | +**Problem:** `refreshType` fires `onDidChangeTreeData` but VS Code's `TreeDataProvider.getChildren(element?)` only ever passes one arg, so the `refresh` param (default `false`) is never `true`. Cache is never invalidated. |
| 65 | + |
| 66 | +**Fix — separate invalidation methods on the service (SRP):** |
| 67 | + |
| 68 | +1. Add three invalidation methods to `MetadataDescribeService`: |
| 69 | + |
| 70 | +- `invalidateDescribe()` — invalidates `describeCache` |
| 71 | +- `invalidateListMetadata(type, folder?)` — invalidates `listMetadataCache` entry |
| 72 | +- `invalidateSObjectDescribe(objectName)` — invalidates `sobjectDescribeCache` entry |
| 73 | + |
| 74 | +1. Remove `forceRefresh` param from `describe()` and `listMetadata()` — dead code (never reached via VS Code's `getChildren`). |
| 75 | +2. Remove `refresh` param from `getChildrenOfTreeItem` and `getChildren`. |
| 76 | +3. `refreshType(node)` runs an Effect that resolves the service and calls the right invalidation based on `node.kind`, then fires `onDidChangeTreeData(node)`. No flag needed. |
| 77 | + |
| 78 | +**Node kind → invalidation mapping:** |
| 79 | + |
| 80 | +- `undefined` (root/title bar) → `invalidateDescribe()` |
| 81 | +- `type` → `invalidateListMetadata(xmlName)` |
| 82 | +- `folderType` → `invalidateListMetadata(xmlName + 'Folder')` |
| 83 | +- `folder` → `invalidateListMetadata(xmlName, folderName)` |
| 84 | +- `customObject` → `invalidateSObjectDescribe(objectName)` |
| 85 | + |
| 86 | +**Files:** |
| 87 | + |
| 88 | +- [metadataDescribeService.ts](packages/salesforcedx-vscode-services/src/core/metadataDescribeService.ts): add invalidation methods, remove `forceRefresh` params |
| 89 | +- [metadataTypeTreeProvider.ts](packages/salesforcedx-vscode-org-browser/src/tree/metadataTypeTreeProvider.ts): `refreshType` calls invalidation, remove `refresh` plumbing |
| 90 | + |
| 91 | +### Phase 2: Remove legacy org browser from core |
| 92 | + |
| 93 | +#### 2a. Delete old source files |
| 94 | + |
| 95 | +- `packages/salesforcedx-vscode-core/src/orgBrowser/` (6 files: `browser.ts`, `index.ts`, `metadataCmp.ts`, `metadataOutlineProvider.ts`, `metadataType.ts`, `nodeTypes.ts`) |
| 96 | +- `packages/salesforcedx-vscode-core/src/commands/retrieveMetadata/` (7 files: `componentNodeDescriber.ts`, `libraryRetrieveSourcePathExecutor.ts`, `nodeDescriber.ts`, `retrieveComponent.ts`, `retrieveDescriber.ts`, `retrieveDescriberFactory.ts`, `typeNodeDescriber.ts`) |
| 97 | +- Verify: `packages/salesforcedx-vscode-core/src/commands/retrieveMetadata/retrieveMetadataTrigger.ts` -- check if it's also only used by the old org browser |
| 98 | + |
| 99 | +#### 2b. Clean up core's index.ts |
| 100 | + |
| 101 | +- Remove `import { orgBrowser } from './orgBrowser'` ([index.ts](packages/salesforcedx-vscode-core/src/index.ts) line 76) |
| 102 | +- Remove `import { retrieveComponent, RetrieveMetadataTrigger }` |
| 103 | +- Remove the entire `setupOrgBrowser` function (lines 154-176) |
| 104 | +- Remove the call to `setupOrgBrowser` from `activate()` |
| 105 | + |
| 106 | +#### 2c. Clean up core's constants and settings |
| 107 | + |
| 108 | +- Remove `USE_LEGACY_ORG_BROWSER` from [constants.ts](packages/salesforcedx-vscode-core/src/constants.ts) line 34 |
| 109 | +- Remove `getUseLegacyOrgBrowser()` from [salesforceCoreSettings.ts](packages/salesforcedx-vscode-core/src/settings/salesforceCoreSettings.ts) lines 106-108 |
| 110 | + |
| 111 | +#### 2d. Clean up core's package.json |
| 112 | + |
| 113 | +From [package.json](packages/salesforcedx-vscode-core/package.json): |
| 114 | + |
| 115 | +- Remove the `metadata` view container (line 204-208) -- keep `conflicts` container |
| 116 | +- Remove the `metadata` view (lines 217-223) |
| 117 | +- Remove menu entries scoped to `view == metadata` (lines 234-255): `sf.metadata.view.type.refresh`, `sf.metadata.view.component.refresh`, `sf.retrieve.component`, `sf.retrieve.open.component` |
| 118 | +- Remove command palette `when: false` entries for `sf.retrieve.component` and `sf.retrieve.open.component` (lines 468-474) |
| 119 | +- Remove command palette entries for `sf.metadata.view.type.refresh` and `sf.metadata.view.component.refresh` (lines 560-566) |
| 120 | +- Remove command definitions for all 4 old commands (lines 715-745) |
| 121 | +- Remove the `useLegacyOrgBrowser` setting (lines 838-842) |
| 122 | +- Remove the `sf.org-browser` walkthrough (lines 895-931) OR update it to reference the new org browser commands |
| 123 | + |
| 124 | +#### 2e. Clean up core's package.nls.json |
| 125 | + |
| 126 | +Remove i18n keys for the removed commands, setting description, and walkthrough strings. |
| 127 | + |
| 128 | +### Phase 3: Remove toggle from the new org browser |
| 129 | + |
| 130 | +#### 3a. Remove `when` clause from org-browser's view |
| 131 | + |
| 132 | +In [org-browser package.json](packages/salesforcedx-vscode-org-browser/package.json) line 250, remove `"when": "!config.salesforcedx-vscode-core.useLegacyOrgBrowser"` so the view always shows. |
| 133 | + |
| 134 | +#### 3b. Remove early-exit guard in activation |
| 135 | + |
| 136 | +In [org-browser index.ts](packages/salesforcedx-vscode-org-browser/src/index.ts) lines 24-30, remove the `useLegacyOrgBrowser` check that exits early. |
| 137 | + |
| 138 | +### Phase 4: Update automation tests |
| 139 | + |
| 140 | +#### 4a. Update or remove legacy e2e test |
| 141 | + |
| 142 | +[orgBrowser.e2e.ts](packages/salesforcedx-vscode-automation-tests/test/specs/orgBrowser.e2e.ts) sets `useLegacyOrgBrowser: true` and tests the old org browser. Either: |
| 143 | + |
| 144 | +- Delete it (the new org browser has its own Playwright tests), or |
| 145 | +- Rewrite it to test the new org browser (remove the setting toggle, update selectors) |
| 146 | + |
| 147 | +### Phase 5: Move walkthrough to org-browser package (optional) |
| 148 | + |
| 149 | +Move the `sf.org-browser` walkthrough from core to org-browser package. Update content for the new org browser: |
| 150 | + |
| 151 | +**Step 1 — Open Org Browser** |
| 152 | + |
| 153 | +- Open via cloud icon in Primary Sidebar → metadata container (same `workbench.view.extension.metadata`). |
| 154 | +- New: in-memory cache with TTL (5–30 min); no `.sfdx` file-based cache. |
| 155 | + |
| 156 | +**Step 2 — Browse and Refresh** |
| 157 | + |
| 158 | +- Metadata types at root; expand to see components. |
| 159 | +- Folder types (Report, Dashboard, Document, EmailTemplate): expand type → folders → components. |
| 160 | +- File presence: pass-filled icon = exists locally; circle-outline = not in project. |
| 161 | +- Custom Object fields: show `Object__c.Field__c` fullNames. |
| 162 | +- Refresh: inline icon on type/folderType/folder; Collapse All in title bar. |
| 163 | + |
| 164 | +**Step 3 — Retrieve** |
| 165 | + |
| 166 | +- Retrieve icon on: type (all components), customObject (all fields), component (single). |
| 167 | +- No retrieve on folderType or folder nodes (API doesn't support `*`); retrieve individual components inside folders. |
| 168 | +- Overwrite confirmation shows count of components to overwrite. |
| 169 | +- Single-component retrieve auto-opens the file. |
| 170 | + |
| 171 | +**Assets**: Move `images/walkthrough/org-browser.png` from core to org-browser; update or replace if UI differs. Add nls keys to org-browser's package.nls.json. |
| 172 | + |
| 173 | +### Phase 6: Verification |
| 174 | + |
| 175 | +Per [verification skill](/.claude/skills/verification/SKILL.md): |
| 176 | + |
| 177 | +1. `npm run compile` |
| 178 | +2. `npm run lint` |
| 179 | +3. `npx effect-language-service diagnostics --project tsconfig.json` (or `--file` for affected packages) — fix reported issues; read_lints does not surface Effect LS |
| 180 | +4. `npm run test` |
| 181 | +5. `npm run vscode:bundle` |
| 182 | +6. E2E: `npm run test:web -w salesforcedx-vscode-org-browser -- --retries 0`, then `npm run test:desktop -w salesforcedx-vscode-org-browser -- --retries 0`. If core/services changed: run their test:web/test:desktop as well. |
| 183 | +7. `npx knip` |
| 184 | +8. `npm run check:dupes` |
0 commit comments