Conversation
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Warning Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories. 📝 WalkthroughWalkthroughThis pull request introduces a complete CLI application called Crumbs for tracking AI agent progress on long-running tasks. The change includes dependencies for async runtime (tokio), command-line parsing (clap), database operations (sqlx with SQLite), and error handling. The implementation provides a domain layer with strongly-typed wrappers, a SQLite persistence layer with sessions and crumbs tables, command handlers for registration and logging, and comprehensive documentation covering CLI behavior, session lifecycle, and storage design. Configuration and CI workflows are updated to support SQLx offline mode and database migration during testing. 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (6)
migrations/20260308173619_create-sessions-and-crumbs.sql (1)
13-20: Add an index for session-scoped crumb listing.The new read path filters by
session_idand orders bycreated_at; without a matching index, this becomes a scan + sort ascrumbsgrows.Suggested change
CREATE TABLE crumbs ( id INTEGER PRIMARY KEY NOT NULL, session_id INTEGER NOT NULL, message TEXT NOT NULL, state TEXT, created_at INTEGER NOT NULL, FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE ); + +CREATE INDEX idx_crumbs_session_id_created_at + ON crumbs(session_id, created_at);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@migrations/20260308173619_create-sessions-and-crumbs.sql` around lines 13 - 20, Add a composite index to speed up session-scoped crumb queries that filter by session_id and order by created_at: create an index on crumbs(session_id, created_at) (or crumbs(session_id, created_at DESC) if you always sort newest-first) so that queries against the crumbs table using session_id and ordering by created_at use the index; name it something like idx_crumbs_session_created_at and add the CREATE INDEX statement in the same migration so it runs alongside the crumbs table creation..github/workflows/main.yml (1)
69-78: SQLx versions are currently aligned; ensureSQLX_VERSIONstays synchronized with workspace dependencies during updates.The workflow pins
SQLX_VERSION: 0.8.6, which matches bothCargo.toml(0.8.6) andCargo.lock(0.8.6 across all sqlx packages). However,cargo sqlx prepare --checkis sensitive to CLI/crate version misalignment. When bumping SQLx in the future, remember to update bothCargo.tomland theSQLX_VERSIONenvironment variable in lockstep to avoid unexpected failures.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/main.yml around lines 69 - 78, The workflow pins SQLX_VERSION (used by the Install sqlx-cli step) to 0.8.6; when updating the sqlx crate you must update SQLX_VERSION in the env block to match the workspace Cargo.toml/Cargo.lock version so `cargo sqlx prepare --check` stays compatible—locate SQLX_VERSION and SQLX_FEATURES in the .github workflow and set SQLX_VERSION to the same version string as the sqlx dependency in Cargo.toml (and update Cargo.lock via cargo update) whenever you bump sqlx.docs/storage.md (1)
27-27: Minor documentation inaccuracy: column name.The documentation refers to
session_idas a field, but the actual migration defines the primary key column asid(seemigrations/20260308173619_create-sessions-and-crumbs.sql). Consider updating toidfor accuracy, or clarifying thatsession_idrefers to the conceptual identifier exposed via the API.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/storage.md` at line 27, Update the docs to match the actual schema: replace the reference to `session_id` in docs/storage.md with the primary key column name `id` (as defined in migrations/20260308173619_create-sessions-and-crumbs.sql), or explicitly note that `session_id` is the API-level identifier that maps to the `id` column in the database; ensure the documentation uses `id` when referring to the DB column and clarifies any API-to-DB naming differences.docs/cli.md (1)
18-18: Minor inconsistency:task_titlevstitleterminology.The documentation uses
task_title(lines 18, 28, 44), but the actual CLI argument defined insrc/args.rsis namedtitle. Consider aligning the documentation terminology with the code to avoid confusion.📝 Suggested terminology fix
-- `agent_name` and `task_title` are required at the start of the session. +- `agent_name` and `title` are required at the start of the session.-- `task_title`: a short human-readable title describing the task +- `title`: a short human-readable title describing the task-- `task_title` is a required display label, not the session identifier. +- `title` is a required display label, not the session identifier.Also applies to: 28-28, 44-44
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/cli.md` at line 18, Documentation uses the term "task_title" but the actual CLI argument is named "title"; update all occurrences of "task_title" (including the instances on lines 18, 28, 44) to "title" so the docs match the CLI argument name (also keep "agent_name" as-is), ensuring any examples or descriptions reference the CLI arg "title" used by the Args/CLI definition.src/cmds/mod.rs (2)
128-140: Inconsistent validation:session_idnot validated inhandle_list_crumbs.Unlike
handle_log_crumb(line 100), which validatessession_idviaSessionId::try_from, this function passes the rawi64directly toget_crumbs. For consistency and to reject invalid inputs early (e.g., negative IDs), consider adding validation here as well.♻️ Add session_id validation for consistency
pub async fn handle_list_crumbs( pool: &Pool<Sqlite>, session_id: i64, ) -> Result<(), ListCrumbsError> { + let session_id = SessionId::try_from(session_id) + .map_err(|msg| ListCrumbsError::Unexpected(anyhow::anyhow!(msg)))?; - let crumbs = get_crumbs(pool, session_id).await?; + let crumbs = get_crumbs(pool, session_id.get()).await?; println!( "{}",Alternatively, you could add an
InvalidInputvariant toListCrumbsErrorfor symmetry with other error types.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmds/mod.rs` around lines 128 - 140, handle_list_crumbs currently accepts a raw i64 session_id and calls get_crumbs directly; add the same input validation used in handle_log_crumb by converting the i64 into SessionId via SessionId::try_from(session_id) and return/map any conversion error into an appropriate ListCrumbsError (or add an InvalidInput variant) before calling get_crumbs with the validated SessionId; update the call site in handle_list_crumbs to pass the validated SessionId and ensure error mapping matches the existing error-handling pattern.
70-70: Consider logging whencurrent_branchfails.Using
unwrap_or(None)silently swallows git errors (e.g., git not installed, command failures). While treating failures as "no branch" is reasonable for non-git directories, logging a debug/warning message would aid troubleshooting when the user expects branch detection to work.♻️ Optional: Add tracing for git failures
- let branch = current_branch(&path).unwrap_or(None); + let branch = current_branch(&path).unwrap_or_else(|e| { + tracing::debug!("couldn't determine git branch: {e}"); + None + });Note: This would require adding
tracingas a dependency if not already present.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmds/mod.rs` at line 70, Replace the silent unwrap_or(None) on current_branch(&path) with error-aware handling: call current_branch(&path), match its Result, and on Err log a debug/warning that includes the error and the path (e.g., using tracing::debug!/warn!), while still treating errors as None for downstream logic; leave the successful Ok(Some(branch)) and Ok(None) paths unchanged. Ensure you reference the branch variable assignment (previously let branch = current_branch(&path).unwrap_or(None);) and import/use tracing if not already present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@migrations/20260308173619_create-sessions-and-crumbs.sql`:
- Around line 1-20: The CREATE TABLE statements for sessions and crumbs should
not include IF NOT EXISTS so the migration fails if those tables already exist
with an incompatible schema; update the CREATE TABLE lines for sessions and
crumbs in migrations/20260308173619_create-sessions-and-crumbs.sql by removing
the IF NOT EXISTS clauses (keep the column definitions and the FOREIGN KEY
(session_id) REFERENCES sessions(id) ON DELETE CASCADE intact) so the migration
will error loudly on pre-existing tables.
In `@README.md`:
- Around line 8-9: Update the README text that describes the project so “long
running tasks” is hyphenated as “long-running tasks”; locate the sentence
containing the project name crumbs and replace the phrase in that sentence (the
string "long running tasks") with "long-running tasks" to correct the
user-facing copy.
---
Nitpick comments:
In @.github/workflows/main.yml:
- Around line 69-78: The workflow pins SQLX_VERSION (used by the Install
sqlx-cli step) to 0.8.6; when updating the sqlx crate you must update
SQLX_VERSION in the env block to match the workspace Cargo.toml/Cargo.lock
version so `cargo sqlx prepare --check` stays compatible—locate SQLX_VERSION and
SQLX_FEATURES in the .github workflow and set SQLX_VERSION to the same version
string as the sqlx dependency in Cargo.toml (and update Cargo.lock via cargo
update) whenever you bump sqlx.
In `@docs/cli.md`:
- Line 18: Documentation uses the term "task_title" but the actual CLI argument
is named "title"; update all occurrences of "task_title" (including the
instances on lines 18, 28, 44) to "title" so the docs match the CLI argument
name (also keep "agent_name" as-is), ensuring any examples or descriptions
reference the CLI arg "title" used by the Args/CLI definition.
In `@docs/storage.md`:
- Line 27: Update the docs to match the actual schema: replace the reference to
`session_id` in docs/storage.md with the primary key column name `id` (as
defined in migrations/20260308173619_create-sessions-and-crumbs.sql), or
explicitly note that `session_id` is the API-level identifier that maps to the
`id` column in the database; ensure the documentation uses `id` when referring
to the DB column and clarifies any API-to-DB naming differences.
In `@migrations/20260308173619_create-sessions-and-crumbs.sql`:
- Around line 13-20: Add a composite index to speed up session-scoped crumb
queries that filter by session_id and order by created_at: create an index on
crumbs(session_id, created_at) (or crumbs(session_id, created_at DESC) if you
always sort newest-first) so that queries against the crumbs table using
session_id and ordering by created_at use the index; name it something like
idx_crumbs_session_created_at and add the CREATE INDEX statement in the same
migration so it runs alongside the crumbs table creation.
In `@src/cmds/mod.rs`:
- Around line 128-140: handle_list_crumbs currently accepts a raw i64 session_id
and calls get_crumbs directly; add the same input validation used in
handle_log_crumb by converting the i64 into SessionId via
SessionId::try_from(session_id) and return/map any conversion error into an
appropriate ListCrumbsError (or add an InvalidInput variant) before calling
get_crumbs with the validated SessionId; update the call site in
handle_list_crumbs to pass the validated SessionId and ensure error mapping
matches the existing error-handling pattern.
- Line 70: Replace the silent unwrap_or(None) on current_branch(&path) with
error-aware handling: call current_branch(&path), match its Result, and on Err
log a debug/warning that includes the error and the path (e.g., using
tracing::debug!/warn!), while still treating errors as None for downstream
logic; leave the successful Ok(Some(branch)) and Ok(None) paths unchanged.
Ensure you reference the branch variable assignment (previously let branch =
current_branch(&path).unwrap_or(None);) and import/use tracing if not already
present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3dff7032-f01c-44ad-99a3-87bf77a8034f
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (35)
.coderabbit.yaml.github/workflows/main.yml.github/workflows/pr.yml.gitignore.sqlx/query-1508e9677acbf94fd66e73f7370c3b01990ba4843bcc36bef24cd23338d01c2d.json.sqlx/query-449d5ba79f4971e20dd4da7b63339ad300ebc464378d529ed5cc5a0bfab1c1bc.json.sqlx/query-44d278d7c896965a84ed079fbe29784463c8aeaa75ee704da622bb82ddfdd122.json.sqlx/query-98cb8a5593558194a5fe99841f4d27b1e1c60ef52bb5afd05a15f5dffc61ace8.json.sqlx/query-9dd6373c706b79b0120cdd81f7fa466232e30bfc98296ed9a14141754b91f933.json.sqlx/query-9f502e469c9296db886da44d1eb943941dbadfadfa58fd3353b563cee5cd071f.json.sqlx/query-a4a60a3aae79ffde0bf9c787143058921df722bfe4d07a85d505a8f172694345.json.sqlx/query-f07aa1122394baaacdc6d452c1387e6dae362f55a1c927bafd81a5c116f0c49a.jsonAGENTS.mdCargo.tomlREADME.mddocs/README.mddocs/cli.mddocs/intro.mddocs/session-lifecycle.mddocs/storage.mddocs/tui.mdjustfilemigrations/20260308173619_create-sessions-and-crumbs.sqlsrc/app.rssrc/args.rssrc/cmds/mod.rssrc/domain/mod.rssrc/errors.rssrc/main.rssrc/persistence/crumb.rssrc/persistence/mod.rssrc/persistence/pool.rssrc/persistence/session.rssrc/utils/git.rssrc/utils/mod.rs
|
Warning Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
No description provided.