Skip to content

fix: keep optimizer defaults local by default#79

Merged
yyiilluu merged 1 commit into
mainfrom
codex/validate-reflexioai-services
Jun 18, 2026
Merged

fix: keep optimizer defaults local by default#79
yyiilluu merged 1 commit into
mainfrom
codex/validate-reflexioai-services

Conversation

@yyiilluu

@yyiilluu yyiilluu commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep claude-smart local-script optimizer defaults scoped to local Reflexio by default.
  • Preserve an explicit override for hosted Reflexio via CLAUDE_SMART_ENABLE_OPTIMIZER=1 and disable via 0/false-like values.
  • Update the dashboard optimizer setting to represent Auto, Enabled, and Disabled modes.

Changes

  • Gate SessionStart optimizer default writes based on Reflexio URL locality.
  • Add regression coverage for local default, hosted skip, and hosted force-enable behavior.
  • Align dashboard settings parsing/writing and developer docs with the new auto/local-only default.

Test Plan

  • PYTHONPATH=plugin/src uv run ruff check plugin/src/claude_smart/events/session_start.py plugin/src/claude_smart/reflexio_adapter.py
  • PYTHONPATH=plugin/src uv run ruff format --check plugin/src/claude_smart/events/session_start.py plugin/src/claude_smart/reflexio_adapter.py tests/test_events.py
  • PYTHONPATH=plugin/src uv run pytest --no-cov tests/test_events.py
  • npm run lint
  • npx tsc --noEmit

Summary by CodeRabbit

Release Notes

  • New Features

    • Claude Code optimizer control now offers three modes (Auto, Enabled, Disabled) instead of a simple toggle, with intelligent defaults that respect local vs. hosted deployments.
  • Documentation

    • Updated configuration documentation to clarify optimizer behavior and available settings.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR replaces the binary CLAUDE_SMART_ENABLE_OPTIMIZER flag with a tri-state OptimizerMode ("auto" | "enabled" | "disabled"). The new default is "auto", which enables optimizer defaults only when the Reflexio URL points to a local host; hosted URLs are skipped unless CLAUDE_SMART_ENABLE_OPTIMIZER=1 is set explicitly. The dashboard switches from a boolean toggle to a three-option Select control.

Changes

Optimizer tri-state mode rollout

Layer / File(s) Summary
OptimizerMode type contract
plugin/dashboard/lib/types.ts
Introduces the exported OptimizerMode = "auto" | "enabled" | "disabled" union and updates all four optimizer fields in ClaudeCodeHookConfig from boolean/boolean | null to OptimizerMode/OptimizerMode | null.
Python: local-only optimizer eligibility
plugin/src/claude_smart/events/session_start.py
Adds _OPTIMIZER_ENV, _LOCAL_REFLEXIO_HOSTS constants and the _should_apply_optimizer_defaults / _is_local_reflexio_url helpers; replaces the inline env-var check in handle with _should_apply_optimizer_defaults(adapter); converts mark_stall_notified try/except to contextlib.suppress.
Dashboard: settings parsing and persistence
plugin/dashboard/lib/claude-settings-file.ts
Imports OptimizerMode; replaces boolean parseEnabled with parseOptimizerMode (off-like strings → "disabled"); changes effective-value fallback from true to "auto"; updates write path so "auto" deletes the env key while "enabled"/"disabled" write "1"/"0".
Dashboard: optimizer Select UI
plugin/dashboard/app/configure/env/page.tsx
Replaces the Switch toggle with a Select dropdown (Auto / Enabled / Disabled); updates updateOptimizer handler to accept OptimizerMode and derive effectiveValue/localValue; updates formatSettingValue to render mode labels.
Tests, docstrings, and docs
tests/test_events.py, plugin/src/claude_smart/reflexio_adapter.py, DEVELOPER.md
Adds url to existing Adapter stubs; adds two new tests for hosted-Reflexio skip-by-default and force-enable behaviors; updates apply_optimizer_defaults docstring and DEVELOPER.md env var row to reflect the new auto default.

Sequence Diagram(s)

sequenceDiagram
  participant SessionStart
  participant Helper as _should_apply_optimizer_defaults
  participant URLCheck as _is_local_reflexio_url
  participant Adapter as ReflexioAdapter

  SessionStart->>Helper: _should_apply_optimizer_defaults(adapter)
  Helper->>Helper: read CLAUDE_SMART_ENABLE_OPTIMIZER
  alt env = "0" / "disabled"
    Helper-->>SessionStart: False
  else env = "1" / "enabled"
    Helper-->>SessionStart: True
  else env not set
    Helper->>URLCheck: _is_local_reflexio_url(adapter.url)
    URLCheck-->>Helper: True if localhost/127.0.0.1/::1
    Helper-->>SessionStart: True (local) or False (hosted)
  end
  SessionStart->>Adapter: apply_optimizer_defaults() [if True]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Three states now where one boolean stood,
auto hops local, as any smart rabbit would.
No more forced-on for the wide open web,
unless you set 1 to let optimizer spread!
The carrot is smarter, the burrow knows best. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: keep optimizer defaults local by default' directly and clearly summarizes the main objective of the changeset: changing optimizer behavior to be local-only by default rather than enabled globally.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/validate-reflexioai-services

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yyiilluu yyiilluu merged commit 76c4076 into main Jun 18, 2026
6 of 7 checks passed
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