Repository navigation
fix(android): delete characters with KEYCODE_DEL when typing backspaces #4269
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 1 commit
23e5f29
ee076e4
715d175
1a390c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'agent-device': patch | ||
| --- | ||
|
|
||
| Fix Android text input typing `\b` backspaces as literal characters into fields instead of deleting characters. Sequences composed entirely of backspaces are now dispatched via `KEYCODE_DEL` keyevents across all Android input targets. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,13 +45,26 @@ import type { AndroidHelperSessionOptions } from './snapshot-helper-types.ts'; | |
| */ | ||
| const ANDROID_INPUT_TEXT_CHUNK_SIZE = 8; | ||
|
|
||
| function isAndroidBackspaceSequence(text: string): boolean { | ||
| if (text.length === 0) return false; | ||
| for (let i = 0; i < text.length; i++) { | ||
| if (text.charCodeAt(i) !== 0x08) return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| export async function typeAndroid(device: DeviceInfo, text: string, delayMs = 0): Promise<void> { | ||
| const providerText = resolveAndroidTextInjector(device); | ||
| if (providerText) { | ||
| await providerText({ action: 'type', text, delayMs }); | ||
| emitAndroidTextDiagnostic('type', 'provider-native', text); | ||
| return; | ||
| } | ||
| if (isAndroidBackspaceSequence(text)) { | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| await clearFocusedText(device, text.length); | ||
|
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. P1: This new typing path treats failed delete keyevents as success because Prompt for AI agents
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| emitAndroidTextDiagnostic('type', 'adb-shell', text); | ||
| return; | ||
| } | ||
| const channel = await admitAndroidTextChannel(device, 'type', text); | ||
| if (channel.backend === 'test-ime') { | ||
| await typeAndroidImeHelper(device, channel.packageName, text, delayMs); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.