-
Notifications
You must be signed in to change notification settings - Fork 0
feat: restricted UI bound #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe PR refactors the UI trait to accept Changes
Sequence DiagramThe functional control flow remains unchanged—Cushion flows through the same component interactions. The refactoring shifts where the type parameter is declared (trait-level vs. per-method), without altering the execution semantics, so a sequence diagram would not provide additional clarity. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The refactoring follows a consistent pattern across all affected files (trait definition → struct/impl updates → test implementation). However, coordination across multiple files and trait boundaries requires careful verification that all generic parameter usages are correctly updated. Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Summary of ChangesHello @satler-git, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant refactoring of the UI interface by making the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
1819de6 to
8924091
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the UI trait to be generic over the Cushion type and adds a 'static lifetime bound to it. This is a good architectural improvement that makes the relationship between UI and Cushion more explicit and type-safe. The changes are consistently applied across the launcher, the trait definition, and the test implementation. I've found one critical issue in the Default implementation for Launcher which will cause a compilation failure. My detailed feedback is in the comment below.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
CodSpeed Performance ReportMerging #30 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ui.rs (1)
77-80: Off‑by‑one in Buffer::has_next.At
Position { 0 }with len=2,has_nextreturns true; after onenextit returns false though one item remains. Usepos.0 < self.len().- pub fn has_next(&self, pos: &Position) -> bool { - pos.0 + 1 < self.len() - } + pub fn has_next(&self, pos: &Position) -> bool { + pos.0 < self.len() + }
♻️ Duplicate comments (1)
src/launcher.rs (1)
25-30: Add missing'statictoDefaultimpl’sCushionbound (compile error).The type itself requires
Cushion: Sync + Send + 'static; theDefaultimpl omits'static, making the impl ill‑formed. Add'static. (Echoing the prior review.)impl<Cushion, UIT, UIContext> Default for Launcher<Cushion, UIT, UIContext> where - UIT: UI<Cushion, Context = UIContext>, - UIContext: Send, - Cushion: Sync + Send, + UIT: UI<Cushion, Context = UIContext>, + UIContext: Send, + Cushion: Sync + Send + 'static, {
🧹 Nitpick comments (2)
tests/dummyui.rs (1)
50-56: Tiny naming nit:least_one→at_least_onefor clarity.- let mut least_one = false; + let mut at_least_one = false; … - if !least_one { - least_one = true; + if !at_least_one { + at_least_one = true; … - if least_one { + if at_least_one {src/launcher.rs (1)
152-166: Minor: propagate UI error context.Optional: enrich
"UI must be set…"with guidance (e.g., which builder to call) or attach.wrap_err("Launcher::set_ui not called")for easier debugging.- .ok_or_eyre("UI must be set before calling run")? + .ok_or_eyre("UI must be set before calling run (call Launcher::set_ui(...))")?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/launcher.rs(3 hunks)src/ui.rs(1 hunks)tests/dummyui.rs(1 hunks)
🔇 Additional comments (7)
tests/dummyui.rs (3)
32-37: Impl bound update matches newUI<Cushion>contract.
Cushion: Send + Sync + 'statichere mirrors the trait and launcher needs. Looks good.
40-63: Async impl matches trait’simpl Future + Sendreturn.
async fnhere yields aSendfuture given your bounds (&self: SendviaDummyUI<T,F>: Sync). No issues.
1-6: No changes required; the import path is valid.The verification confirms that
ltraitre-exportscolor_eyre(found insrc/lib.rs:4). The import intests/dummyui.rsusinguse ltrait::{…, color_eyre::eyre::Result, …}is therefore correct and idiomatic. The review comment's concern was based on an incorrect assumption.Likely an incorrect or invalid review comment.
src/launcher.rs (3)
15-18: Struct bounds align with newUI<Cushion>; good.
54-57: Method impl bounds also consistent; no action needed.
1-23: No inconsistencies found—trait bounds are already refactored correctly.All trait bounds and implementations in the codebase are already using the updated form
UI<Cushion, Context = …>:
src/launcher.rslines 15, 27, 54:UIT: UI<Cushion, Context = UIContext>✓tests/dummyui.rsline 32:impl<T, F, Cushion> UI<Cushion> for DummyUI<T, F>✓- No instances of stale bounds (e.g.,
: UIwithout parameters) exist in the codebase.The refactoring is complete.
src/ui.rs (1)
3-9: Review comment is accurate and verified.Verification confirms:
- No
Box<dyn UI<...>>,Arc<dyn UI>, or other trait object patterns exist in the codebase- UI trait correctly uses RPITIT (
impl Future + Send), making it non-object-safe by design- Generic bounds
Send + Sync + 'staticonCushionare properly applied- Trait signature aligns with expectations
The code changes are sound and the approval stands.
Summary by CodeRabbit