Skip to content

feat: unified self-upgrade (source/release/service) + /self-upgrade command + /models command with inline keyboard#44

Merged
chinkan merged 36 commits into
mainfrom
feat/self-update-models-command
Jun 17, 2026
Merged

feat: unified self-upgrade (source/release/service) + /self-upgrade command + /models command with inline keyboard#44
chinkan merged 36 commits into
mainfrom
feat/self-update-models-command

Conversation

@chinkan

@chinkan chinkan commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Two major improvements to RustFox runtime management:

1. Unified Self-Upgrade

The self_update_to_branch tool has been replaced with a unified self_upgrade() that auto-detects the deployment mode and handles all three paths:

Mode Detection Behavior
Source Cargo.toml found near binary git fetchcheckoutpullcargo build --release → spawn new binary
Release binary No Cargo.toml Downloads latest GitHub release via self_update crate → atomic binary swap
Service systemd/launchd service file exists Same as above + cargo install --path . + rustfox --service install rerender + systemctl restart

New user-facing command: /self-upgrade [branch] — bypasses the LLM, shows inline per-step progress via live edit_message_text, then auto-restarts.

Improved LLM tool: self_upgrade(branch, mode) — renamed from self_update_to_branch, adds mode param (auto/source/release), properly sets restart_pending flag for deferred restart.

2. /models Command

Browse and switch OpenRouter models at runtime without restart:

Input Behavior
/models Shows current model + usage help
/models <exact-id> Validates against API, saves to config.toml, hot-reloads
/models <keyword> Fuzzy searches id and name fields — top 5 shown as inline keyboard buttons

Inline keyboard: Search results show tappable buttons (callback query handler saves model + edits message). Cancel button included. set_model() persists to config.toml via TOML round-trip and updates an in-memory RwLock — next LLM call picks up the new model immediately.

Technical Changes

File Change
Cargo.toml Added self_update = \0.44\
src/learning.rs New self_upgrade(), restart_bot(), is_service_installed(), detect_deployment_mode(), find_project_root()
src/agent.rs restart_pending: AtomicBool, current_model: RwLock<String>, config_path, set_model(), updated chat_completion call, renamed dispatch arm
src/llm.rs ModelInfo struct + fetch_models()
src/tools.rs Renamed self_update_to_branchself_upgrade with mode param
src/platform/telegram.rs /self-upgrade command (inline progress), /models command (smart search + inline keyboard), callback query handler, restart check
src/main.rs Pass config_path to Agent
scripts/services/rustfox.service.template Restart=on-failureRestart=always

Verification

  • cargo check
  • cargo clippy -- -D warnings
  • cargo fmt --all -- --check
  • cargo test — 371 unit + 14 integration tests, all pass ✅

chinkan added 30 commits June 16, 2026 11:08
…mbiguity, add edge case, command registration, TOML round-trip note, background tasks note
… modes, /self-upgrade command, /models command, self_update crate
…s channel, remove redundant imports, combine parse_command dispatch
…tion, cache is_service_installed, handle UpToDate status
… log service restart failures, verify new binary starts, fix Windows sc query false-positive
@chinkan chinkan merged commit 9b94af2 into main Jun 17, 2026
5 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