Skip to content

Start claude-smart backend during install#61

Merged
yyiilluu merged 1 commit into
mainfrom
codex/nonblocking-install-startup
May 26, 2026
Merged

Start claude-smart backend during install#61
yyiilluu merged 1 commit into
mainfrom
codex/nonblocking-install-startup

Conversation

@yyiilluu
Copy link
Copy Markdown
Contributor

@yyiilluu yyiilluu commented May 26, 2026

Summary

  • move expensive claude-smart install recovery out of SessionStart by removing unconditional installer hooks
  • start the Reflexio backend during install, including the current-install fast path
  • make missing dependency recovery schedule detached installer runs from backend/dashboard/hook paths

Tests

  • node --check plugin/scripts/codex-hook.js && node --check bin/claude-smart.js
  • uv run pytest tests/test_install_scripts.py tests/test_cli_install.py tests/test_codex_support.py
  • bash plugin/scripts/backend-service.sh status -> running on http://localhost:8071

Summary by CodeRabbit

  • New Features

    • Backend service now automatically starts during plugin installation and setup.
  • Improvements

    • Installation and dependency recovery processes now run asynchronously in the background, preventing blockages and improving responsiveness.
    • Session startup initialization streamlined with explicit multi-step sequence for better reliability.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 859292ea-91cf-4094-b84c-69c45eaf7cb0

📥 Commits

Reviewing files that changed from the base of the PR and between 44d70a4 and 05bb09c.

📒 Files selected for processing (10)
  • bin/claude-smart.js
  • plugin/hooks/codex-hooks.json
  • plugin/hooks/hooks.json
  • plugin/scripts/backend-service.sh
  • plugin/scripts/codex-hook.js
  • plugin/scripts/dashboard-service.sh
  • plugin/scripts/hook_entry.sh
  • plugin/scripts/smart-install.sh
  • tests/test_codex_support.py
  • tests/test_install_scripts.py

📝 Walkthrough

Walkthrough

The PR refactors installer and service startup behavior. Backend service startup is introduced with host configuration; hook SessionStart is refactored to separate setup from installation; and installer execution throughout the codebase is converted from synchronous to detached background spawning. Tests are updated to validate the new patterns.

Changes

Backend service startup and detached installer refactoring

Layer / File(s) Summary
Backend service startup infrastructure
bin/claude-smart.js
runPluginService now accepts envOverrides to merge into spawned script environment. New startBackendService(pluginRoot, host) passes CLAUDE_SMART_HOST to backend-service.sh. Claude Code and Codex install flows both invoke backend startup with their respective host values.
Hook configuration refactoring
plugin/hooks/hooks.json, plugin/hooks/codex-hooks.json
hooks.json SessionStart replaces smart-install.sh with ensure-plugin-root.sh, hook_entry.sh session-start, backend-service.sh, and dashboard-service.sh. codex-hooks.json SessionStart replaces smart-install.sh with ensure-plugin-root.sh and reduces timeout from 300 to 10.
Detached installer pattern across service and hook scripts
plugin/scripts/codex-hook.js, plugin/scripts/backend-service.sh, plugin/scripts/dashboard-service.sh, plugin/scripts/hook_entry.sh
All installer recovery paths convert from synchronous spawnSync execution to detached background spawning via startInstallerDetached() or claude_smart_spawn_detached. codex-hook.js replaces blocking runInstaller() with startInstallerDetached() and removes prependRuntimePath() calls. Service scripts and hook entry spawn smart-install.sh detached with CLAUDE_SMART_BOOTSTRAPPING=1 when dependencies are missing, logging "recovery scheduled; skipping".
Smart installer backend service startup integration
plugin/scripts/smart-install.sh
New start_backend_service() helper conditionally starts backend-service.sh in the background. Invoked in the "install complete" path before continue signal and in the success path before writing the success marker. Completion messages updated to reflect backend startup and dashboard auto-start behavior.
Test validation of new patterns
tests/test_install_scripts.py, tests/test_codex_support.py
Service recovery tests assert detached installer spawning and "recovery scheduled; skipping" messages. Hook/install flow tests verify smart-install.sh runs only in Setup hook, not runtime SessionStart. Codex hook tests validate startInstallerDetached(root, reason) pattern. Codex environment test verifies .env contains local CLI, embedding, and read-only settings. SessionStart hook command dispatch validation updated for refactored sequence.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ReflexioAI/claude-smart#25: Backend startup now passes CLAUDE_SMART_HOST via environment override, which integrates with backend-service.sh logic that selects Codex compatibility based on host value.
  • ReflexioAI/claude-smart#26: Both PRs refactor Codex hook bootstrap and SessionStart hook commands in codex-hooks.json, with this PR moving to detached installer patterns and the other introducing Reflexio cache integration.
  • ReflexioAI/claude-smart#32: Both PRs modify smart-install.sh bootstrap flow; this PR adds backend/dashboard startup scheduling while the other ensures installer idempotency with file locking.

🐰 Backend now springs to life with grace,
Detached from sync, at its own pace,
Hooks guide the way, setup first and fast,
While installers work—no more held up last!

✨ 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/nonblocking-install-startup

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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 4278ad3 into main May 26, 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