fix: fix for pasting observer key in win10 cmd#50
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 17 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdds clipboard-paste handling for the Observer tab: a helper reads clipboard text via arboard; key-event handling detects common paste shortcuts, filters control characters, appends text to Changes
Sequence DiagramsequenceDiagram
participant User as User
participant KeyHandler as Key Handler
participant Clipboard as Clipboard (arboard)
participant AppState as App State
participant UI as Observer UI
User->>KeyHandler: Press paste shortcut (Shift+Ins / Ctrl+Shift+V / Ctrl+V)
KeyHandler->>Clipboard: read_clipboard_text_best_effort()
alt Clipboard returns text
Clipboard-->>KeyHandler: Some(text)
KeyHandler->>KeyHandler: Filter control characters
KeyHandler->>AppState: Append filtered text to observer_shared_key_input
KeyHandler-->>User: Consume event
else Clipboard empty or error
Clipboard-->>KeyHandler: None (warning logged)
KeyHandler-->>User: Do not consume event
end
AppState->>UI: Update observer input display
UI-->>User: Render pasted content
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/ui/key_handler/mod.rs (1)
271-295: Normalize and bound pasted observer keys before appending.Line 290 appends arbitrary filtered text with no hex/length guard. Since this field represents a 64-char hex key, enforce that at paste time to prevent hidden invalid growth.
Suggested refactor
if let Tab::Admin(AdminTab::Observer) = app.active_tab { @@ if is_paste_shortcut { if let Some(text) = read_clipboard_text_best_effort() { - let filtered: String = text.chars().filter(|c| !c.is_control()).collect(); + let remaining = 64usize.saturating_sub(app.observer_shared_key_input.len()); + let filtered: String = text + .chars() + .filter(|c| c.is_ascii_hexdigit()) + .take(remaining) + .collect(); if !filtered.is_empty() { app.observer_shared_key_input.push_str(&filtered); return Some(true); } } } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/ui/key_handler/mod.rs` around lines 271 - 295, The observer paste handling currently appends arbitrary filtered text to app.observer_shared_key_input; change it to normalize and bound pasted content to a 64-char hex key: after obtaining text from read_clipboard_text_best_effort() and stripping control chars, trim whitespace, strip any leading "0x"/"0X", retain only hex characters [0-9a-fA-F], convert to lowercase (or a consistent case), then compute remaining = 64usize.saturating_sub(app.observer_shared_key_input.len()) and append only up to remaining characters of the cleaned hex string to app.observer_shared_key_input; only append if at least one character is added and return Some(true) as before (affects symbols: app.observer_shared_key_input, read_clipboard_text_best_effort, AdminTab::Observer, Tab::Admin).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ui/tabs/observer_tab.rs`:
- Around line 167-175: Update the paste hint string used when building the
footer so it includes "Ctrl+V" to match the accepted paste keys in the observer
key handler; modify the paste_hint variable (used in the Paragraph::new footer
construction in observer_tab.rs) to add "Ctrl+V" for both Windows and
non-Windows branches (so the final help text matches the paste handling
implemented in src/ui/key_handler/mod.rs).
---
Nitpick comments:
In `@src/ui/key_handler/mod.rs`:
- Around line 271-295: The observer paste handling currently appends arbitrary
filtered text to app.observer_shared_key_input; change it to normalize and bound
pasted content to a 64-char hex key: after obtaining text from
read_clipboard_text_best_effort() and stripping control chars, trim whitespace,
strip any leading "0x"/"0X", retain only hex characters [0-9a-fA-F], convert to
lowercase (or a consistent case), then compute remaining =
64usize.saturating_sub(app.observer_shared_key_input.len()) and append only up
to remaining characters of the cleaned hex string to
app.observer_shared_key_input; only append if at least one character is added
and return Some(true) as before (affects symbols: app.observer_shared_key_input,
read_clipboard_text_best_effort, AdminTab::Observer, Tab::Admin).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f06eaf7d-3ab3-4356-b8ea-32b5ae688c17
📒 Files selected for processing (2)
src/ui/key_handler/mod.rssrc/ui/tabs/observer_tab.rs
There was a problem hiding this comment.
Reviewed this PR on the latest head (2c7e69f). The Windows paste fallback is a good fix for terminals that do not emit bracketed paste events, and the implementation is scoped correctly to the Observer tab. The clipboard read is best-effort with safe logging, control characters are stripped before insertion, and the UI footer now provides platform-specific guidance, which improves usability. I also validated locally with cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, and cargo test, all passing. Looks good to merge.
Summary
introduced paste compatibility of key pasting in observer mode in windows 10
Summary by CodeRabbit