Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Oct 27, 2025

Summary

Previously, CharmManager.get() defaulted to running charms (runIt=true), causing unnecessary charm execution for read/write operations. This PR changes the default to false and ensures all callers explicitly pass the runIt parameter.

Changes

  • Changed default runIt from true to false in:

  • Updated CLI lib functions to explicitly pass runIt:

    • Pass false for read/write operations: inspect, get, set, apply, getsrc, setsrc
    • Pass true for operations requiring execution: call, render
  • Updated shell AppView to pass runIt: true when displaying active charm

Benefits

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 charms
  • ct charm inspect - Inspect charm data
  • ct charm view - Display view
  • ct charm get - Get cell value
  • ct charm set - Set cell value
  • ct charm apply - Apply input
  • ct charm getsrc - Get source
  • ct charm setsrc - Set source
  • ct charm rm - Remove charm
  • ct charm link - Link charms
  • ct charm map - Display map

Commands 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 step
  • ct charm new --start - Optionally starts new charm
  • ct dev - Local testing environment

Technical Notes

TypeScript Type Complexity

Initial attempt to make runIt a required parameter (no default) caused TypeScript OOM during type checking. The issue was removing the middle overload signature with optional runIt?.

Solution: Preserved all three overload signatures to avoid type explosion, only changed the default value in the implementation.

Testing

  • ✅ All CLI tests pass
  • ✅ Type checker completes without OOM
  • ✅ Verified on both main and branch

Test Plan

  • Run deno test in packages/cli
  • Verify type checking doesn't OOM
  • Test ct charm commands 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

    • CharmManager.get default runIt=false.
    • CharmsController.get adds runIt (default false) and forwards it.
    • CLI: pass false for inspect/get/set/apply/getsrc/setsrc; true for call/render.
    • Shell AppView: pass true when loading the active charm.
    • Preserved existing overloads; only changed the default to avoid TypeScript perf issues.
  • Migration

    • Update external get() call sites to pass runIt.
    • Use true when execution/state refresh is needed (call, render, step); otherwise false.
    • If you relied on implicit execution before, set runIt=true to keep behavior.

…eter

Previously, CharmManager.get() defaulted to running charms (runIt=true),
causing unnecessary charm execution for read/write operations. This change
makes the default false and requires all callers to explicitly pass the
runIt parameter.

Changes:
- Change default runIt from true to false in CharmManager.get() and CharmsController.get()
- Update CLI lib functions to explicitly pass runIt:
  - Pass false for read/write operations (inspect, get, set, apply, getsrc, setsrc)
  - Pass true for operations requiring execution (call, render)
- Update shell AppView to pass runIt: true when displaying active charm

Benefits:
- Eliminates unnecessary charm runs for 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)

Technical notes:
- Preserved all three overload signatures to avoid TypeScript type explosion
- Only changed the default value in the implementation
- All tests pass without type checker OOM

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

- fix script to not exit early without printing an error message when charm is not found
@seefeldb seefeldb merged commit b07537b into main Oct 28, 2025
8 checks passed
@seefeldb seefeldb deleted the fix/do-not-run-charms-unless-necessary branch October 28, 2025 21:02
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.

3 participants