refactor(cli): make charm execution explicit via required runIt parameter #1967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Previously,
CharmManager.get()defaulted to running charms (runIt=true), causing unnecessary charm execution for read/write operations. This PR changes the default tofalseand ensures all callers explicitly pass therunItparameter.Changes
Changed default
runItfromtruetofalsein:CharmManager.get()(packages/charm/src/manager.ts)CharmsController.get()(packages/charm/src/ops/charms-controller.ts)Updated CLI lib functions to explicitly pass
runIt:falsefor read/write operations:inspect,get,set,apply,getsrc,setsrctruefor operations requiring execution:call,renderUpdated shell
AppViewto passrunIt: truewhen displaying active charmBenefits
✅ Eliminates unnecessary charm runs for commands like
ct charm ls,inspect,get,set, etc.✅ Makes code intent explicit at every call site
✅ Improves performance by avoiding unnecessary work
✅ Maintains correct behavior for commands that need execution (
call,render,step)Commands That No Longer Run Charms
ct charm ls- List charmsct charm inspect- Inspect charm datact charm view- Display viewct charm get- Get cell valuect charm set- Set cell valuect charm apply- Apply inputct charm getsrc- Get sourcect charm setsrc- Set sourcect charm rm- Remove charmct charm link- Link charmsct charm map- Display mapCommands That Still Run Charms (As Intended)
ct charm call- Executes handler (needs charm running)ct charm render- Renders UI (needs latest state)ct charm step- Explicitly runs one stepct charm new --start- Optionally starts new charmct dev- Local testing environmentTechnical Notes
TypeScript Type Complexity
Initial attempt to make
runIta required parameter (no default) caused TypeScript OOM during type checking. The issue was removing the middle overload signature with optionalrunIt?.Solution: Preserved all three overload signatures to avoid type explosion, only changed the default value in the implementation.
Testing
Test Plan
deno testinpackages/clict charmcommands manually (if desired)🤖 Generated with Claude Code
Summary by cubic
Make charm execution opt-in by requiring an explicit runIt flag for get(). This avoids unintended runs for read/write operations and improves CLI and shell performance.
Refactors
Migration