Skip to content

fix: fix for pasting observer key in win10 cmd#50

Merged
arkanoider merged 3 commits into
mainfrom
fix-paste-observer
Apr 11, 2026
Merged

fix: fix for pasting observer key in win10 cmd#50
arkanoider merged 3 commits into
mainfrom
fix-paste-observer

Conversation

@arkanoider

@arkanoider arkanoider commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

introduced paste compatibility of key pasting in observer mode in windows 10

Summary by CodeRabbit

  • New Features
    • Observer tab accepts pasted text via common paste shortcuts (e.g., Shift+Insert, Ctrl+Shift+V, Ctrl+V delivered as key events); pasted content is filtered for control characters and appended to the shared key input.
    • Footer UI now shows platform-specific paste hints (Windows vs. others) so displayed shortcuts match your OS.

@coderabbitai

coderabbitai Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@arkanoider has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 17 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 824a00ab-fd60-428a-acf0-80fbf2066ec6

📥 Commits

Reviewing files that changed from the base of the PR and between c4c31d1 and 2c7e69f.

📒 Files selected for processing (2)
  • src/ui/key_handler/mod.rs
  • src/ui/tabs/observer_tab.rs

Walkthrough

Adds 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 observer_shared_key_input, and updates the footer to show platform-specific paste hints.

Changes

Cohort / File(s) Summary
Clipboard & Key handling
src/ui/key_handler/mod.rs
Added read_clipboard_text_best_effort() and paste-detection in handle_key_event for Shift+Insert, Ctrl+Shift+V, and Ctrl+V delivered as a key event; filters control chars and appends clipboard text to observer_shared_key_input.
Observer UI footer text
src/ui/tabs/observer_tab.rs
Replaced fixed paste hint with platform-conditional paste_hint (Windows: "Shift+Insert / Ctrl+Shift+V / right-click", non-Windows: "Ctrl+Shift+V / middle-click") and interpolated it into the footer string.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudged the clipboard, soft and bright,
I pulled the paste into the light,
Filtered the hops of control and space,
Dropped text tidy in its place,
Observer hums — a quiet, clever bite.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes adding paste support for observer key input on Windows 10, which aligns with the main changes: implementing a clipboard paste fallback in the key handler and updating the UI hint text.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-paste-observer

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d2a213e and 9126e2b.

📒 Files selected for processing (2)
  • src/ui/key_handler/mod.rs
  • src/ui/tabs/observer_tab.rs

Comment thread src/ui/tabs/observer_tab.rs

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@arkanoider arkanoider merged commit a891938 into main Apr 11, 2026
11 checks passed
@arkanoider arkanoider deleted the fix-paste-observer branch April 11, 2026 07:26
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.

1 participant