Skip to content

refactor(apex-debugger): move sf-CLI check to debugger, drop core isCLIInstalled - W-23291340#7674

Merged
mshanemc merged 9 commits into
developfrom
sm/W-23291340-add-iscliinstalled-to-terminalservice-mi
Jul 6, 2026
Merged

refactor(apex-debugger): move sf-CLI check to debugger, drop core isCLIInstalled - W-23291340#7674
mshanemc merged 9 commits into
developfrom
sm/W-23291340-add-iscliinstalled-to-terminalservice-mi

Conversation

@mshanemc

@mshanemc mshanemc commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Migrated apex-debugger's ISV setup gate off the core extension's isCLIInstalled (sfdx --version) onto services TerminalService.simpleExec (sf --version). The CLI-presence check is composed inline at the call site — simpleExec({ command: 'sf --version', parse: () => true }).pipe(catchTag('TerminalServiceError', () => false)) — because it has a single consumer and the catch-to-false semantics are the debugger's policy, not a shared-service concern. Services keeps only the simpleExec primitive.
  • Finished converting that activation block to Effect idiom (Effect.log, Effect.tryPromise + IsvAuthSetupError tagged error, catchTag for the non-fatal ISV-setup-failure path).
  • Dropped isCLIInstalled from salesforcedx-vscode-core (util, API export, tests) — apex-debugger was its sole consumer.

Design note

Earlier revisions added isCliInstalled to TerminalService. Reverted: a single consumer plus consumer-specific catch-to-false semantics don't justify widening the shared services API. The check now lives where its policy lives; simpleExec remains the shared seam.

Reviewer notes

  • mediumpackages/salesforcedx-vscode-apex-debugger/src/index.ts (activateEffect): the ISV gate needs ~7 mocks to test because activateEffect mixes vscode registration, TerminalService resolution, ISV setup, and telemetry. Could extract the "check CLI → run ISV setup → catchTag warn" block into its own small Effect. Not applied — reshapes activation structure; the added test covers all 3 branches and passes.
  • lowpackages/salesforcedx-vscode-apex-debugger/src/index.ts: the migrated ISV catch keeps only e.message, dropping the stack the old console.error(e) captured. Fix would add a cause field to IsvAuthSetupError — a design decision on the error type, not applied.
  • lowsimpleExec injects SF_JSON_TO_STDOUT/FORCE_COLOR for any sf command even though sf --version doesn't use them. Harmless.

Test plan

  • Install built VSIXs; open a project with isvDebuggerSid/isvDebuggerUrl config → confirm "Setting up ISV Debugger environment variables" logs and sf:isv_debug_project context becomes true.
  • Open a non-ISV project → confirm the ISV setup branch is skipped.
  • Temporarily rename sf off PATH → confirm the gate goes false (setup skipped) with no crash.

What issues does this PR fix or reference?

@W-23291340@


🤖 Generated by auto-build pipeline. Original WI: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002dmx8MYAQ/view

mshanemc and others added 7 commits July 2, 2026 13:59
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…- W-23291340

Finish Effect migration of the ISV setup block (Effect.log, Effect.tryPromise +
IsvAuthSetupError, catchTag) and drop the core isCLIInstalled gate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- avoid `any` in activation.test.ts (narrow casts, matching repo pattern)
- concise plan wording (fragments, numerals)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rovide - W-23291340

Effect.provide narrowing left a TerminalService R leak against the effect's
never-R type; cast the provided effect to match, mirroring orgOpen.test.ts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mshanemc
mshanemc marked this pull request as ready for review July 2, 2026 21:32
@mshanemc
mshanemc requested a review from a team as a code owner July 2, 2026 21:32
@mshanemc
mshanemc requested review from randi274 and removed request for randi274 July 2, 2026 21:32
…alled - W-23291340

isCliInstalled had a single consumer (apex-debugger) and baked a
consumer-specific catch-to-false policy into the shared TerminalService
seam. Move the check to the debugger: compose simpleExec('sf --version')
+ catchTag inline where the policy lives; services keeps only the
simpleExec primitive.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mshanemc mshanemc changed the title refactor(services): add isCliInstalled to TerminalService, migrate debugger, drop core isCLIInstalled - W-23291340 refactor(apex-debugger): move sf-CLI check to debugger, drop core isCLIInstalled - W-23291340 Jul 4, 2026
…3291340

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mshanemc

mshanemc commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

/ai-auto approve

@peternhale peternhale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Peer-approved on behalf of @mshanemc per /ai-auto approve

@mshanemc
mshanemc merged commit 987cd4c into develop Jul 6, 2026
64 checks passed
@mshanemc
mshanemc deleted the sm/W-23291340-add-iscliinstalled-to-terminalservice-mi branch July 6, 2026 13:16
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