Normalize minus key sequences and return 400 for invalid keys - #364
Conversation
rgarcia
left a comment
There was a problem hiding this comment.
reviewed — the change itself is safe for existing callers (everything the normalizer rewrites was already a hard xdotool error, and both matched error strings only come from xdotool's forbidden-character check, so they're input-deterministic). requesting changes for the generated spec drift; the rest is optional.
suggestions
server/openapi.yaml:6616—openapi-3.0.yamland the embedded spec inlib/oapi/oapi.goweren't regenerated;GetSwagger()on this branch still serves the oldkeysdescription. runmake oapi-generateand commitserver/cmd/api/api/computer.go:40—Ctrl++(zoom in) isn't handled. xdotool drops empty tokens, so it exits 0 and silently presses onlyCtrl. consider mapping a trailing empty segment toplusfor symmetry withCtrl+-
questions
server/cmd/api/api/computer.go:52— unknown keysyms (ctrl+wat) still return 200 since xdotool printsNo such key name ... Ignoring it.and exits 0. fine, just noting the 400 only covers forbidden punctuation, not all invalid keys
nits
server/cmd/api/api/computer.go:178,287—hold_keyson click_mouse / move_mouse aren't normalized; optional consistencyserver/cmd/api/api/computer_test.go:173— add"-": "minus"and"Ctrl++": "Ctrl++"cases to pin the split/join edgesserver/cmd/api/api/computer_test.go:195— fixtures usectrl+wat, which xdotool wouldn't actually reject;ctrl+-is the realistic example
|
addressed the required generated-spec drift in also added the bare-minus and unchanged |
rgarcia
left a comment
There was a problem hiding this comment.
approving — verified on b4e3911:
lib/oapi/oapi.goregenerated;GetSwagger()now serves the newkeysdescription (checked by loading the embedded spec in a test)openapi-3.0.yamlis gitignored as an intermediate, so no drift there — my earlier note was wrong on that filego test ./cmd/api/api/andgo vetpass locally; Bugbot and CI green on the new commit- minus-only scope is fine;
Ctrl++can be a follow-up if agents hit it
b4e3911 to
3469a2d
Compare
|
rebased onto
|
rgarcia
left a comment
There was a problem hiding this comment.
re-approving on 41a73e8 — confirmed the rebase is clean:
git diff origin/main...HEADoutsideoapi.gois byte-identical to the commit I approvedoapi.gonon-blob delta vsmainis only the twokeyscomment lines;GetSwagger()serves the new descriptiongo test -race ./cmd/api/api/,go vet, Bugbot and CI green on the new head
…ess-key # Conflicts: # server/lib/oapi/oapi.go
## Summary - document that each `--key` value accepts one X11 keysym or chord - add canonical `Ctrl+minus` and repeated-key examples - direct users to `computer type --text` for text input ## Rollout Merge after kernel/kernel-images#364 is deployed so the documented punctuation form is supported by the runtime. ## Testing - `make test` - `make build` - `./bin/kernel browsers computer press-key --help` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Only README and CLI flag help text change; no execution or API behavior is modified. > > **Overview** > **Documentation-only** update for `kernel browsers computer press-key`: the `--key` flag is now described as one **X11 keysym or chord per value** (e.g. `Return`, `Ctrl+t`, `Ctrl+minus`), with the same wording in **README** and in **cobra `--help`** via `cmd/browsers.go`. > > The README also adds guidance to pass **repeated or sequential** presses as multiple `--key` arguments and to use **`computer type --text`** for literal text instead of `press-key`. **No runtime or parsing behavior changes** in this PR; the PR notes pairing with a separate kernel-images deploy for the documented punctuation forms. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a6c31db. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
summary
minuskeysymwhy
Agents commonly express zoom-out as
Ctrl+-. xdotool requiresCtrl+minus, and treating that mismatch as an internal error causes SDKs to retry a deterministic invalid request.testing
go vet ./...go test -race $(go list ./... | grep -v /e2e$)Note
Low Risk
Localized to press-key input normalization and error mapping; behavior change is more correct client errors and accepting
Ctrl+-aliases.Overview
Press key handling now accepts common shorthand like
Ctrl+-by normalizing hyphen segments to xdotool’sminuskeysym (with whitespace trimmed around+), for bothkeysandhold_keys.When xdotool rejects a key sequence (
Invalid key sequence/Failure converting key sequence), the API returns a 400 validation error instead of 500, so clients won’t retry deterministic bad input. OpenAPI docs describe punctuation keys (Ctrl+minus,Ctrl+-alias). Unit tests cover normalization and error classification.Reviewed by Cursor Bugbot for commit 15d375f. Bugbot is set up for automated code reviews on this repo. Configure here.