Skip to content

Conversation

@MikeGarde
Copy link
Owner

Overview

This branch introduces a configuration-driven, concurrent run experience with a user-visible progress bar in interactive mode. It adds per-repo overrides, a centralized config model, and batched LLM interactions to improve throughput while keeping the UI responsive. The changes unify configuration across CLI, environment, and per-repo TOML, and enable safe concurrent summarization of file changes.

Changes

  • UX Enhancements
    • Added a progress bar for interactive runs using indicatif (new dependency: indicatif = "0.18.2").
    • Progress visualizes per-file processing and final commit message generation, finishing with a "Done." message.
  • Per-Project Configuration
    • New commitbot.toml for centralized settings, including per-repo overrides.
    • Global defaults:
      • model default: gpt-5-nano
      • optional OpenAI-style API key with fallback sources
      • max_concurrent_requests default: 4
    • Multi-source configuration precedence: CLI flags > environment > per-repo TOML > default TOML > hardcoded defaults.
    • New per-repo discovery and overlay logic so repo-level settings can tailor behavior.
  • CLI and Config Loading
    • CLI option --max added (optional usize) to control concurrency; preserves default behavior when not supplied.
    • OPENAI_API_KEY is no longer sourced from Clap env; API key comes from CLI, environment, or config.
    • Config loading now uses FileConfigRoot/FileConfig with repo-aware resolution (git::detect_repo_id) and merging of defaults + per-repo overrides.
  • Git and LLM Client
    • Added detect_repo_id() to derive owner/repo from git remote URLs (SSH/HTTPS formats) for per-repo resolution.
    • LlmClient trait extended with Send + Sync bounds to support concurrent usage.
  • Runtime and Concurrency
    • Introduced Arc/Mutex-based concurrency primitives and thread-scoped execution for per-file LLM summarizations.
    • Implemented batched, concurrency-limited summarization governed by max_concurrent_requests, with progress kept responsive.
    • Interactive flow wired to load and pass config into run_interactive.
  • Misc
    • Minor formatting and clarity improvements around the concurrency setup and flow.

Testing / Validation

  • Interactive run: verify the progress bar appears and updates as files are processed and summarize messages are generated; final message shows "Done."
  • Concurrency: set --max to various values (including 1 and higher) to observe behavior and ensure progress tracking remains accurate.
  • Configuration precedence:
    • Confirm CLI-specified max and API key override env/config values.
    • Confirm per-repo TOML overrides apply when present (owner/repo from git).
    • Ensure defaults are used when no overrides are provided.
  • API key errors: verify a clear error is shown when OPENAI_API_KEY is missing after all config sources are considered.
  • Stability: ensure thread-safety in concurrent summarization paths.

Notes / Risks

  • Introducing indicatif adds a runtime dependency; ensure downstream environments render progress bars correctly (TTY requirements).
  • Concurrency changes rely on thread-safe LLM interactions; existing code paths should continue to function under single-threaded scenarios.
  • Per-repo config loading adds complexity; ensure existing users without a TOML config aren’t affected.
  • If the repository’s git remote URL parsing changes, per-repo resolution could fail; monitor for edge cases in detect_repo_id.

## Dependencies
- Introduced indicatif = "0.18.2" as a new dependency to enable CLI progress visuals.
- Rationale: Provides a lightweight, reliable progress bar for long-running interactive tasks; laid groundwork for visual feedback in the run flow.

## Interactive Flow
- Introduced a progress bar in the interactive run flow to visualize progress while generating commit messages for file changes.
- Import indicatif::{ProgressBar, ProgressStyle} to support progress visuals.
- Initialize a ProgressBar in run_interactive sized to total file_changes plus one for completion.
- Increment the bar for each file processed (including ignored ones) to keep the UI in sync with work.
- Increment again when a file's summary is generated.
- Finalize the progress bar after creating the final commit message, finishing with a "Done." message.
- This is a UX enhancement; no core logic or commit content changes are introduced.
## Documentation
- Introduced per-project config discovery and multi-method access in README to reflect concurrency/config goals.
- Updated per-project TOML example to include a header ["user/repo"] and concrete override, demonstrating per-repo scope.
- Removed the privacy notice from README to focus on configuration and usage.
- Fixed EOF newline formatting for cleaner diffs.

## Config
- Introduced new commitbot.toml to centralize concurrency and model settings.
- Introduced global defaults:
  - default model (gpt-5-nano)
  - optional OpenAI-style API key with fallback to environment
  - max_concurrent_requests defaulting to 4
- Made configuration multi-source aware with precedence: CLI flags > environment variables > per-repo TOML overrides > default TOML section > hardcoded defaults.

## CLI Arguments
- Introduced new global CLI option --max (Max concurrent requests to the LLM API) as an optional usize.
- Represented as an Option<usize> to preserve existing default behavior when not supplied.
- Removed Clap’s env-based lookup for OPENAI_API_KEY; api_key is now sourced only from CLI input (or other config sources).

## Configuration Loading
- Added max_concurrent_requests to Config, wired through CLI (--max), env var (COMMITBOT_MAX_CONCURRENT_REQUESTS), and config file with default of 4.
- Expanded configuration precedence to support multiple sources: CLI > environment > per-repo TOML overrides > default TOML section > hardcoded defaults.
- Introduced FileConfigRoot and FileConfig to represent default and per-repo overrides.
- Implemented repo-aware config resolution via git::detect_repo_id; per-repo config overlays default config.
- Refactored loading: load_file_config now returns a FileConfigRoot; from_sources merges defaults with per-repo overrides.
- Updated error handling: OPENAI_API_KEY must be provided via CLI, environment, or config file; clearer error if missing.

## Git Utilities
- Introduced detect_repo_id() in src/git.rs to derive "owner/repo" from git remote.origin.url supporting SSH/HTTPS formats; returns Some or None non-fatally.

## LLM Client
- Introduced Send + Sync bounds for LlmClient trait to enable safe concurrent usage across threads.

## Main Runtime
- Introduced concurrency primitives (Arc/Mutex) and thread-scoped execution to run per-file LLM summarizations concurrently.
- Introduced batched, concurrency-limited summarization logic governed by max_concurrent_requests; progress tracking remains responsive.
- Wired configuration through to interactive flow: run_interactive now accepts Config; main passes loaded config to run_interactive.
- Minor formatting and clarity improvements around concurrency setup and flow.
@MikeGarde MikeGarde merged commit 05c4552 into main Nov 9, 2025
@MikeGarde MikeGarde deleted the async branch November 9, 2025 23:39
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.

2 participants