Skip to content

feat(browser): route all file I/O and org operations through services… - #1

Merged
peternhale merged 5 commits into
mainfrom
feat-browser-support
Aug 7, 2026
Merged

feat(browser): route all file I/O and org operations through services…#1
peternhale merged 5 commits into
mainfrom
feat-browser-support

Conversation

@peternhale

Copy link
Copy Markdown
Collaborator

… extension

Replace direct workspace.fs and Node.js module usage with browser-compatible services layer from salesforcedx-vscode-services.

File Operations (FsService):

  • Replace all workspace.fs.readFile with readFile() service wrapper
  • Replace all workspace.fs.writeFile with writeFile() service wrapper
  • Replace all workspace.fs.stat existence checks with fileOrFolderExists()
  • Add findFiles() for web-safe glob-based class file discovery

Org Operations (ApexLogService):

  • Replace @salesforce/apex-node with listLogs() and getLogBody() services
  • Remove Node-only dependencies: @salesforce/apex-node, @salesforce/core
  • Remove @apexdevtools/apex-ls (replaced with FsService.findFiles glob)
  • Retain @apexdevtools/apex-parser (string-based, browser-compatible)

Services Integration:

  • Add salesforceServices.ts: thin async/await wrappers over Effect-based API
  • Add servicesRuntime.ts: Effect ManagedRuntime initialization
  • Update Main.ts: call initServices() before extension activation
  • Add Main.web.ts: browser entry point (re-exports shared activation)

Path Operations:

  • All path manipulation now uses vscode-uri Utils (joinPath, basename, etc.)
  • Zero Node.js path module usage

Tests:

  • Update LogEventCache tests to mock salesforceServices instead of workspace.fs
  • Update RetrieveLogFile tests to mock service layer
  • Fix vscode mock Uri.joinPath to use Utils.joinPath from vscode-uri
  • All 1068 tests passing

Configuration:

  • package.json: add browser entry point, extensionDependencies, effect deps
  • tsconfig.json: add DOM lib for TextEncoder/TextDecoder types
  • Build configs: add browser bundle target for lana (Main.web.js)

Deleted:

  • lana/src/salesforce/logs/* (GetLogFile, GetLogFiles, SalesforceConnection)
  • lana/src/salesforce/setupPinoPaths.ts (pino logging setup)

Result: Single codebase runs on desktop (Node.js) and web (workspace.fs/Tooling API) with all platform-specific operations abstracted through the services layer.

📝 PR Overview

Briefly describe what the pull request does and why it is needed.

Example: "Adds a flame chart view for CPU time analysis in Apex logs to improve log analysis performance."

🛠️ Changes made

  • Change 1
  • Change 2

🧩 Type of change (check all applicable)

  • 🐛 Bug fix - something not working as expected
  • ✨ New feature – adds new functionality
  • ♻️ Refactor - internal changes with no user impact
  • ⚡ Performance Improvement
  • 📝 Documentation - README or documentation site changes
  • 🔧 Chore - dev tooling, CI, config
  • 💥 Breaking change

📷 Screenshots / gifs / video [optional]

Show off your UI changes.

🔗 Related Issues

fixes #
resolves #
closes #
related #

✅ Tests added?

  • 👍 yes
  • 🙅 no, not needed
  • 🙋 no, I need help

📚 Docs updated?

  • 🔖 README.md
  • 🔖 CHANGELOG.md
  • 📖 help site
  • 🧪 Marked any pre-release-only features (README 🧪 badge — see RELEASING.md)
  • 🙅 not needed

Anything else we need to know? [optional]

… extension

Replace direct workspace.fs and Node.js module usage with browser-compatible
services layer from salesforcedx-vscode-services.

**File Operations (FsService):**
- Replace all workspace.fs.readFile with readFile() service wrapper
- Replace all workspace.fs.writeFile with writeFile() service wrapper
- Replace all workspace.fs.stat existence checks with fileOrFolderExists()
- Add findFiles() for web-safe glob-based class file discovery

**Org Operations (ApexLogService):**
- Replace @salesforce/apex-node with listLogs() and getLogBody() services
- Remove Node-only dependencies: @salesforce/apex-node, @salesforce/core
- Remove @apexdevtools/apex-ls (replaced with FsService.findFiles glob)
- Retain @apexdevtools/apex-parser (string-based, browser-compatible)

**Services Integration:**
- Add salesforceServices.ts: thin async/await wrappers over Effect-based API
- Add servicesRuntime.ts: Effect ManagedRuntime initialization
- Update Main.ts: call initServices() before extension activation
- Add Main.web.ts: browser entry point (re-exports shared activation)

**Path Operations:**
- All path manipulation now uses vscode-uri Utils (joinPath, basename, etc.)
- Zero Node.js path module usage

**Tests:**
- Update LogEventCache tests to mock salesforceServices instead of workspace.fs
- Update RetrieveLogFile tests to mock service layer
- Fix vscode mock Uri.joinPath to use Utils.joinPath from vscode-uri
- All 1068 tests passing

**Configuration:**
- package.json: add browser entry point, extensionDependencies, effect deps
- tsconfig.json: add DOM lib for TextEncoder/TextDecoder types
- Build configs: add browser bundle target for lana (Main.web.js)

**Deleted:**
- lana/src/salesforce/logs/* (GetLogFile, GetLogFiles, SalesforceConnection)
- lana/src/salesforce/setupPinoPaths.ts (pino logging setup)

Result: Single codebase runs on desktop (Node.js) and web (workspace.fs/Tooling API)
with all platform-specific operations abstracted through the services layer.
Migrate from top-level out/ to dist/ to satisfy Code Builder Web's copy
filter, which strips out/ as desktop waste. CBWeb's reference extensions
use dist/ for both desktop (dist/) and web (dist/web/) entry points.

Changes:
- Bundler configs: update rollup.config.mjs + rolldown.config.ts output
  dirs and copy destinations from lana/out → lana/dist
- Root scripts: build:dev + watch clean lana/dist instead of lana/out
- lana/package.json: main/browser fields point to dist/ paths; vscode:bundle
  now runs the real monorepo build (pnpm -w run build) instead of placeholder
- .vscodeignore: ship !dist/ instead of !out/
- .gitignore: ignore dist/ instead of out/
- LogView.ts: load webview assets from extensionUri/dist (load-bearing runtime
  path change — index.html, bundle.js, codicon.css, icon)
- Editor globs: .vscode/launch.json outFiles + settings.json exclude/search
  updated for consistency

Webview assets (bundle.js, index.html, codicons) still originate from
log-viewer/out; only the copy destination into lana changes. Desktop and
web bundles now both land under dist/, matching CBWeb's convention and
surviving its copy filter.

Enables lana to be bundled as a built-in extension in CBWeb without
weakening CBWeb's safety exclusions.
Resolved conflicts by keeping browser-support architecture:
- Retained vscode-uri and services abstraction layer
- Integrated new features from main: resolveConfig, workspaceManager
- Adopted improved SymbolFinder with ApexSymbol candidates
- Updated dependencies and regenerated lockfile
- Replace Node path module with vscode-uri Utils for browser compatibility
- Fix OpenFileInPackage to pass fsPath string (not Uri) to showFile
- Update test mocks to provide complete Uri interface (path + fsPath)
- Normalize paths in SfdxProjectReader test mock
Add pnpm overrides to force patched versions:
- brace-expansion ^5.0.9 (was 5.0.6, fixes DoS CVEs)
- fast-uri ^4.1.2 (was 4.0.0, fixes host confusion CVEs)
- js-yaml ^4.3.1 (fixes quadratic CPU consumption)
- serialize-javascript ^7.0.5 (fixes XSS)
- uuid ^11.1.1 (fixes buffer bounds check)

All production vulnerabilities resolved (0 found in pnpm audit --prod)
@peternhale
peternhale merged commit 673830a into main Aug 7, 2026
3 checks passed
@peternhale
peternhale deleted the feat-browser-support branch August 7, 2026 19:29
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.

1 participant