fix(backend): use remote version cache offline#9304
Conversation
Greptile SummaryThis PR fixes offline mode for remote version resolution by (1) making The previously-flagged issues (in-memory Confidence Score: 5/5Safe to merge — all previously flagged concerns are addressed and the new tests validate the offline cache path end-to-end. All remaining findings are P2 or below. The core logic is correct, the centralised fallback removes duplication, and No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI
participant Backend
participant Cache as CacheManager
Note over CLI,Cache: Offline latest resolution (after this PR)
CLI->>Backend: latest_version(None, None)
Backend->>Backend: latest_stable_version()
alt fast path returns Some(version)
Backend-->>CLI: Ok(Some(version))
else fast path returns Ok(None)
Backend->>Backend: latest_version_for_query("latest", None)
Backend->>Backend: list_remote_versions_with_info()
Backend->>Cache: get_cached()
alt in-memory hit (cache_async / cache)
Cache-->>Backend: Ok(versions)
else disk read
Cache->>Cache: parse() → read msgpack.z
Cache-->>Backend: Ok(versions) or Err
end
alt versions found
Backend-->>CLI: Ok(Some(latest))
else no cache
Backend-->>CLI: Ok(vec![]) → Ok(None)
end
end
Reviews (2): Last reviewed commit: "fix(backend): use remote version cache o..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request enhances offline capabilities and improves the robustness of version resolution. Key changes include updating list_remote_versions_with_info to retrieve cached versions when in offline mode and implementing a fallback in latest_version to use the version list if the fast-path latest_stable_version returns no result. Comprehensive tests were added to cover these offline and fallback scenarios. The review feedback suggests further improving resilience by extending the fallback logic to handle errors from the fast-path call, ensuring the system can still resolve versions using cached data during transient network failures.
ea83ed4 to
de5765d
Compare
Summary
latestresolution through the shared list/cache path instead of backend-specific fast pathslatest_stable_version()miss to the genericlatestmatcher centrally inBackend::latest_versionRoot Cause
Backend::list_remote_versions_with_info()returned an empty list before consultingremote_versions.msgpack.zwheneverofflinewas enabled. Plainlatestresolution also called backend-specific fast paths first, which can returnNoneor attempt backend-specific network work before the cached list path gets a chance to resolve a version.Validation
cargo fmt --checkcargo test backend::latest_version_tests -- --nocapturecargo test cache::tests -- --nocapturegit diff --checkThis PR was generated by an AI coding assistant.