-
-
Notifications
You must be signed in to change notification settings - Fork 78
Draft PR for HTTP based copy and paste functionality #368
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
Changes from all commits
b96a88e
0c39a0c
3d838e4
a9038e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ export class LinuxKeyboard { | |
| this.sendKeyEvent(code, KEY_RELEASE) | ||
| } | ||
| this.sync() | ||
| } else if (key.length === 1) { | ||
| } else if (key.length > 0) { | ||
| this.injectText(key) | ||
|
Comment on lines
+36
to
37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Do not log clipboard characters. When As per path instructions, security review must check sensitive data exposure in TypeScript code. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| } else { | ||
| console.warn("[LinuxKeyboard] Unknown key:", key) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ export class WindowsKeyboard { | |
| }) | ||
| } | ||
| this.sendInput(events.length, events) | ||
| } else if (key.length === 1) { | ||
| } else if (key.length > 0) { | ||
| this.injectText(key) | ||
|
Comment on lines
+43
to
44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
file=$(fd -t f 'keyboard\.ts$' . | head -n 1)
printf '%s\n' "FILE=$file"
ast-grep outline "$file"
printf '%s\n' '--- relevant source ---'
cat -n "$file" | sed -n '1,130p'
printf '%s\n' '--- related usages ---'
rg -n -C 4 'injectText|KEYEVENTF_UNICODE|wScan|charCodeAt' . --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.jsx'Repository: AOSSIE-Org/Rein Length of output: 16821 🌐 Web query:
💡 Result: When using the SendInput function with the KEYEVENTF_UNICODE flag, the KEYBDINPUT structure's wScan member is limited to a 16-bit WORD [1][2][3]. This design restricts a single KEYEVENTF_UNICODE event to representing a single UTF-16 code unit [4][5]. To handle Unicode characters that reside outside the Basic Multilingual Plane (BMP)—which require UTF-16 surrogate pairs (high surrogate and low surrogate)—you must split the character into its two constituent 16-bit code units [4][6][5]. The industry-standard approach for synthesizing this input is to treat each surrogate as an individual keystroke [4][5]. Specifically, you must send a sequence of four events for a single non-BMP character: 1. Down event for the high surrogate (wScan = high surrogate, dwFlags = KEYEVENTF_UNICODE) [4][5] 2. Up event for the high surrogate (wScan = high surrogate, dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP) [4][5] 3. Down event for the low surrogate (wScan = low surrogate, dwFlags = KEYEVENTF_UNICODE) [4][5] 4. Up event for the low surrogate (wScan = low surrogate, dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP) [4][5] While some legacy discussions suggested alternative timing (e.g., sending both "down" events before both "up" events) [7], the consensus among common implementations and library maintainers is to process each UTF-16 code unit as a complete down/up keystroke cycle [8][9][5]. The target application's message loop, via TranslateMessage, will correctly reassemble these surrogate code units into the appropriate character [1]. Note: When using KEYEVENTF_UNICODE, wVk must be set to zero [1][2]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
node - <<'JS'
const fs = require("fs");
const path = "src/server/drivers/windows/keyboard.ts";
const source = fs.readFileSync(path, "utf8");
if (!source.includes("for (const ch of text)") ||
!source.includes("const c = ch.charCodeAt(0)")) {
throw new Error("The reported implementation pattern was not found");
}
const samples = ["😀", "𝄞"];
for (const text of samples) {
const codePointItems = [...text];
const codeUnitItems = Array.from({ length: text.length }, (_, i) =>
text.charCodeAt(i)
);
console.log(JSON.stringify({
text,
utf16Length: text.length,
codePointItems: codePointItems.length,
currentWScanValues: codePointItems.map(ch => ch.charCodeAt(0)),
requiredWScanValues: codeUnitItems,
currentKeyEvents: codePointItems.length * 2,
requiredKeyEvents: codeUnitItems.length * 2,
}));
}
JSRepository: AOSSIE-Org/Rein Length of output: 467 Preserve UTF-16 surrogate pairs in For astral characters such as 🤖 Prompt for AI Agents |
||
| } else { | ||
| console.warn("[Keyboard] Unknown key and not a single character:", key) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.