Repository navigation
Keys and text reach the loop as a HostEvent with a canonical Action - #1487
Merged
Merged
Conversation
W5b of the platform plan (discussion #1460). A host that is not SDL has no (sym, wcode) pair to hand the loop, so the loop's input now arrives as an app-private HostEvent: HostEvent::Key(KeyPress) and HostEvent::Text(String), beside the Lifecycle and Quit W5a added. The SDL drain decodes a key or text event into one and hands it to the same ingest_host_event every other host event reaches; ingest_key and ingest_text_commit are the old key and text branches of the drain, moved, with the same order and the same controlled-replay suppression. What a key press means is now one vocabulary. plx_ui::consts gains Action (Up .. Back, the transport keys, Exit, paging, Backspace, ClearAll, Digit, PointerHidden), raw_pair(Action) as the only builder of an SDL pair and action_of(sym, wcode) as the only decode. is_remote_bound is defined as action_of(..).is_some(), so the map has one spelling and a test grades it against the previous predicate over the whole (sym, wcode) grid. The PIN pad's digit reader moves down unchanged as pin_digit and keeps reading both fields; action_of's digit reads sym only, which is is_bound's existing term, and the wcode-only 48..=57 case is left for W5d to decide. A KeyPress holds an optional action, the edge and an optional raw pair, and its constructor refuses a press that names neither. The loop still runs its ladder on the raw pair: an unsupported key flows on as exactly the pair it was, the lab trigger and the tape keep reading a pair, and a host that sent only an action reaches the same arms through raw_pair. The FIFO's named tokens now press the pair raw_pair gives their action; chup, chdown and k: stay literal pairs. The raw-event hex log stays in the SDL drain and is still skipped under a controlled replay. Text reaches the loop as Source::Sdl, and the txt: token keeps Source::RemoteFifo through ingest_text. Nothing the tape or the keytable records changes for any event SDL produces: machine.rs, STATE_SHAPE, tests/keytable.json and the tapes are untouched, and the edge is re-derived into the state word the way bridge::key_input reads it. (A release stamped with the repeat bit, which SDL never sends, now records as a plain release.) The diff of run.rs is mostly the moved key body, dedented; its content change is the two entry points and the HostEvent arms. There is no Edit variant: it arrives with the first producer of an edit, in W9. Co-Authored-By: Claude <noreply@anthropic.com>
…one key Review follow-up to the W5b HostEvent::Key change (PR #1487). The first guard graded the decoder and showed that a hosted key and an SDL key agree, but both doors carried the pair raw_pair gave them, so a wrong mapping passed. The new native_key_effect_* tests feed the pair a television or the simulator really sends, written out as literals, through the real decoder and loop, and grade what the real consumer did: * transport, on the mounted player: PLAY (wcode 450) asks to play, PAUSE (72) to pause, PLAYPAUSE (261) for the toggle, and their alternate spellings the same; the hosted action-only press of each asks what its native key asks. * REWIND (452) commits a seek one interval back where a plain LEFT only moves a pending target; FAST-FORWARD (451) and RIGHT likewise forward. * paging, on the real Library grid in the loop rig: PAGE DOWN and CH- move the focus two rows down, PAGE UP and CH+ two rows up, graded by the exact cell. * search editing: Backspace, Clear and the simulator's Backspace (sym 8 beside BACK's wcode) edit the field. Search is graded in the Dispatcher-tier rig, because the loop rig cannot raise its keyboard on a host. * the PIN keypad types each digit by sym and by a wcode-only press in 48..=57, and nothing beside those ranges; the unbound colour button and the same wcode-only press wake nothing and abandon no armed click through note_global_press, with bound keys as the positive control. * a pointer hide is a notification whichever way it arrives (SDL bytes, a raw-only hosted press, a hosted action) and an unbound key flows on as the pair it was; an unbound key leaves a dismissed transport dismissed. * the lab trigger is const-false without lab-diagnostics, so its arm cannot be armed in a test build; what the build does is pinned instead. KeyPress::new now makes the action and the pair one key. With a raw pair the action is action_of of it, and a stated action that differs is refused; with no raw pair the action must read back from its own raw_pair, which refuses Digit(10..=255). The pointer-hide early return in ingest_key reads classify of the pair again, as before the HostEvent change, so a raw-only press with wcode 0x1e4 takes it. action() is test-only until the screens move onto it. bridge::text_owner's comment pointed at the SDL_TEXTINPUT branch of ingest_sdl_event, which moved to ingest_text_commit. Co-Authored-By: Claude <noreply@anthropic.com>
…hat broke The native_key_effect_* guards in run.rs fed a pair through the decoder and the loop, then asserted the decoded action first. A wrong classify therefore failed on the decode line and never reached the effect it was meant to show, and the native, hosted and decoded readings of one key shared one test. Each reading is now its own test, red under its own kind of break: * the NATIVE door (transport, rewind, paging): the SDL pair as literals, graded by what the player or the Library grid did. A wrong classify or page_dir reading fails these, which are what the consumers read today. * the HOSTED door of the same three: the action alone, which goes through raw_pair and KeyPress::new's round trip. A wrong raw_pair fails here, as a refusal (the .expect) or as another key's effect. * the decoded action, as one table of literal native pairs in events.rs (native_key_effect_the_native_pairs_decode_to_the_actions_they_mean). No production reader of the loop reads the action before W5d, so a wrong action_of is seen by this table and by nothing else. The pointer-hide test no longer asserts the decode either; the table owns it. Co-Authored-By: Claude <noreply@anthropic.com>
…ons showed The guard's header in run.rs, the decode table's doc in events.rs and the previous commit's message said a wrong action_of is seen by that table "and by nothing else", and that each door is red under a different break. Swapping the mapping's halves in turn (Play/Pause, PageUp/PageDown, Rewind for Left) showed otherwise: * a wrong classify or page_dir turns the NATIVE effect red, and also the hosted door and the decode table, because action_of is built on classify; * a wrong raw_pair alone turns ONLY the hosted door red, as KeyPress::new's round-trip refusal (the .expect panics); * a wrong action_of leaves every native effect green. The decode table, input.rs's decode literals and the hosted door's round trip see it; * a raw_pair and an action_of that agree on a swap pass the round trip, and turn the hosted transport test red as the effect of another key (PAUSE asks to play). The comments now say that. Comments only; no behaviour moves. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step W5b of the platform plan (discussion #1460). Keys and text reach the loop as
HostEvents, beside W5a's lifecycle and quit. A key carries a canonicalActionwhere one is defined, and the raw pair it arrived as where there is one. A platform with no SDL key codes, such as Tizen, can then deliver anActionalone. No behaviour change on webOS or the simulator, and tapes,tests/keytable.jsonand the machine'sInputKind::Keyare untouched.What changes
plx_ui::consts: added besideclassifyandis_remote_bound.Actionhas 19 variants:Up Down Left Right Ok Back Play Pause PlayPause Stop Rewind FastForward Exit PageUp PageDown Backspace ClearAll Digit(0-9) PointerHidden.raw_pair(Action)is the one pair the app builds for an action. Back is(SDLK_ESCAPE, 0)and Stop is(0, 413), the pairs the remote FIFO already sent.action_of(sym, wcode)reads in this order:classify, then paging, then the edit keys, then digits. A digit is read fromsymonly, asis_remote_boundalways did. A note there says W5d decides the wcode-only 48..=57 case.is_remote_bound(sym, wcode)is nowaction_of(..).is_some(). A whole-grid test checks it against the old predicate.pin_digitisscreens/src/profiles.rs'sdigit_of, moved unchanged. It still reads both fields, and the PIN screen calls it.app/events.rs:HostEventgainsKey(KeyPress)andText(String).KeyPresshas private fields: an optionalAction, theEdge, and an optionalRawKey. Its constructor makes a press one key:action_ofof that pair, and a stated action that differs is refused;action_of(raw_pair(a)) == Some(a)), which refusesDigit(10..=255);decode_host_eventnow also decodes SDLKEYDOWN,KEYUPandTEXTINPUT, at this build's offsets (LG and stock layouts).raw_pair.chup,chdownandk:stay literal pairs.Editvariant yet: nothing produces one. It arrives with its first producer (W9).app/run.rs:ingest_host_eventgains theKeyandTextarms. The drain's old key and text branches move, dedented, intoingest_keyandingest_text_commit.session::input, the controlled-replay return, the input damage note) and the controlled-replay suppression are as before.action: Nonetakes today's raw path. The pointer-hide early return still readsclassify(sym, wcode) == Key::PointerHiddenon the pair, as every other arm does.key type=0x300 raw=) stays in the SDL drain behind!controlled_replay, now inlog_raw_input_event.ci/list-caps.inire-keys its&ev[..48]entry to that function.textinput.rs:queue(String)is split out ofon_event. The FIFO'stxt:keepsSource::RemoteFifo, and a hostedTextisSource::Sdl.docs/remote-keys.mdfollowsdigit_ofbecomingpin_digit.The diff stat is about 900 lines, mostly the key body moved and dedented. The content change is the two entry points, the two arms, and the
constsadditions.Inventory
This is W5b step 1 (spec, W5 lane). There is one row per consumer of a raw
(sym, wcode)pair, and the Action list derived from it. Line numbers are at efad77e (W5a), where the inventory was taken.The loop (moves behind
HostEvent::Key)app/events.rs:80decode_keyrawand, viaaction_of,actiondecode_host_eventapp/events.rs:121host_wcodedecode_keyon the host onlydecode_key; the (8,482) pair is Back toclassify, Backspace to Search, both kept because raw is retainedapp/events.rs:281remote_token_keyk:<sym>,<wcode>holddown/holdrep/holdup, Lab Controlraw_pair;chup/chdown/k:stay literalremote_synth_key_*and re-enters through the SDL decoder, so it is a raw producer by designapp/run.rs:1409-1442hex logkey/text/edit type=0x.. raw=<48 bytes hex>forensic line!controlled_replay; line text must not change (many tests and docs/remote-keys.md grep it)app/run.rs:1444-1458classify(sym,wcode)thenKey::PointerHiddenearly return (both edges)Action::PointerHiddenapp/run.rs:1459-1468key_input(sym,wcode,state)boot_initialcontrolled-boot key:controlled_key_inputKey{raw}InputKind::Key{sym,wcode}app/run.rs:1469-1475enc_key(sym,wcode,down,repeat)Key{raw,edge}app/run.rs:1496-1534state&0xff != 1,state&0x100,sym == app.down_sym,is_ok(sym),on_key_up(sym, down_sym),key_input(...)RepeatGatefor directions, ungated OK), repeat-vs-fresh by rawsymidentityedge,is_oktoAction::Okdown_symcompares RAW sym (every remote transport key has sym 0, so they share slot 0); raw sym retainedapp/run.rs:1536-1552classifyresultkeyforWakePressAction::Play,Action::PlayPauseapp/run.rs:1556-1562plx_os::labcfg::is_trigger_key(sym,wcode)ordered_player_key)lab.jsonnames an arbitrary pair; const-false withoutlab-diagnosticsapp/run.rs:1563-1574begin_fresh_press(session, key, sym, wcode, ...);app/input.rsbegin_fresh_press/note_global_press/on_key_upis_bound(sym,wcode)action.is_some()replacesis_boundon the non-lab armis_boundkeeps the lab arm: needs raw pairapp/run.rs:1575-1590crate::lab::key_press(sym,wcode,...)(lab/mod.rs)app/run.rs:1620-1625key_input(sym,wcode,state & !0x100 if ordered_player_key)Key{raw, edge};edge Repeat -> Downreplacesstate & !0x100app/bridge.rs:5457key_input(sym,wcode,state)->InputKind::Key{key:canon(sym,wcode), sym, wcode, edge, at_edge}Key(Up/Down/Left/Right/Ok/Back/Other) andEdgefrom state bitsedgebootstrap/effects.rs:160)app/run.rs:1075ingress_token+app/events.rs:618dispatch_remote_tokenokdown/okup/holddown/holdrep/holdupcallremote_synth_key_*app/run.rs:3814replay_inject{"kind":"key","sym","wcode","down","repeat"}remote_synth_key_edge/remote_synth_key_repeat, i.e. back through SDLtests/replay_fixtures.pyanchors need nothing)app/run.rs:3921controlled_key_inputInputEvent<u32>Screens and ui (unchanged in W5b; each one is a W5d consumer)
screens/src/player/mod.rs:743classify_input(key,sym,wcode): Back/Stop, Up/Downscreens/src/player/mod.rs:1033-1039classify_inputscreens/src/player/mod.rs:3433classify_inputUp/Downscreens/src/player/overlay.rs:773classify_inputthenself.key(...)PlayerReq::Transportscreens/src/login.rs:2228classify_inputUp/Downscreens/src/detail/mod.rs:2365,detail/trailer.rs:72-89classify_inputviatrailer_key(key,sym,wcode)screens/src/hud_settings.rs:904-912(key, sym): Left/Right,sym == SDLK_BACKSPACE/SDLK_CLEARscreens/src/hud_settings.rs:1137classify_input == Playscreens/src/search/mod.rs:404-409(key, sym): Left/Right,SDLK_BACKSPACE,SDLK_CLEARscreens/src/library/mod.rs:1641consts::page_dir(sym,wcode)screens/src/library/recommended.rs:1112consts::page_dir(sym,wcode)screens/src/person_bio.rs:212step_page(sym)ui/src/prose_scroll.rs:149)screens/src/about_panel.rs:519scroll.step_page(sym)screens/src/tracks_panel.rs:1174step_page(sym as c_int)ui/src/prose_scroll.rs:149match sym { SDLK_UP, SDLK_DOWN }ui/src/dispatch/by_id.rs:290InputKind::Key{key:Ok, sym:tap.sym, wcode:tap.wcode}raw_pair(Ok))raw_pair(Action::Ok)instead of readingtap.sym/wcode; leave for W5d (it reads the machine's tap, not the loop)screens/src/profiles.rs:340digit_ofand:1757-1776[sym, wcode]any in 48..=57consts::pin_digitUNCHANGED in W5b (see Digit divergence below); the call site stays rawscreens/src/profiles_pin_tests.rs:48-55digit_oftableconsts::pin_digitui/src/consts.rs:322/380/433/483/488classify,classify_input,page_dir,is_bound,is_remote_boundaction_ofsubsumesclassify_inputkeeps taking the machine key + raw (W5d);is_remote_boundis re-expressed asaction_of(..).is_some()The Action list:
raw_pairand every pairaction_ofmaps to each Actionaction_of(sym, wcode)applies these in order:classify: directions bysymfirst, then Rewind/FF in either field, then PointerHidden, OK, Pause, Play, PlayPause, Stop, Exit and Back;page_dir;sym;symonly.Every row obeys
action_of(raw_pair(a)) == Some(a).raw_pair(sym, wcode)action_ofmaps these pairs to itLeft{alt:false})Left{alt:true})Right{alt:true})is_ok(sym): RETURN 13, KP_ENTER (88|1<<30), SELECT (77|1<<30, which is really End; name left alone)page_dir == -1: sym == SDLK_PAGEUP or wcode == 300 (CH up)page_dir == 1: sym == SDLK_PAGEDOWN or wcode == 301 (CH down)pin_digit(moved unchanged) reads[sym, wcode]for 48..=57, whileaction_ofreads the digit fromsymonly, asis_remote_boundalways did. In W5b the PIN screen still reads the raw pair, so nothing changes. W5d decides the wcode-only case when the PIN pad moves ontoAction::Digit.Tests
The guard: a native pair, then the decoder, then the real consumer's effect
Each case feeds the pair the set or simulator really sends, as literal bytes, and asserts what the consumer did. The path differs by case:
encode_key→decode_host_event→ the loop.input.rsunknown-pairs test go through the decoder and then thekey_inputcallingest_keymakes (native_key_input, a test-side copy of it), not the whole loop.Where a hosted platform could send the key, a second door delivers the same key as an action-only
HostEvent::Key.Transport(Some(true)), 72 asksSome(false), 261 asks the toggle. The alternates 415, 19 and 402 ask what their base key asks. Native and hosted doorsCommitSeek(50 s)and 451 commitsCommitSeek(70 s). A plain LEFT or RIGHT asks nothing and only moves the pending target. Both doorsprofiles_pin_tests.rspin_digitas before. 47, 58, (0,0), (0,504), DOWN, 450 and 72 type nothinginput.rsAction, keep the raw pair and wake no dismissed HUD. Bound keys are the controlinput.rslabcfg::is_trigger_keyis const-false withoutlab-diagnostics, so the hostsim build cannot arm one. The test pins thatevents.rsKeyPressevents.rsDigit(10)is refused, and a raw-only 0x1e4 press derivesPointerHiddenMutations. Each break was applied to the committed tree, run, and restored. A swap in
raw_pairoraction_ofalone leaves the native effect tests green, because production consumers still read the raw pair until W5d. Other guards catch it: the decode table, theinput.rsdecode literals, or the hosted door's round-trip refusal.classifyPlay/Pause swappedSome(true)), hosted refusal, decode tableraw_pairPlay/Pause swappedaction_ofPlay/Pause swappedinput.rsliteral, hosted refusalraw_pairandaction_ofPlay/Pause swapped togetherSome(true)), decode tablepage_dirup/down swappedaction_ofPageUp/PageDown swappedinput.rs, hosted refusalraw_pairPageUp/PageDown swappedclassifyREW as a plain Leftraw_pairRewind as(SDLK_LEFT, 0)KeyPress::newwithout its pair check, or without its round tripa_press_is_one_key_and_its_action_and_pair_cannot_disagreeRuns
On the committed head
d893dece5, throughtools/check-lock.py:make test-crate C=plx_ui T=consts:test result: ok. 22 passed; 0 failed; 0 ignored; 0 measured; 1753 filtered outmake test-crate C=app T=events(default features, so the LG offsets):test result: ok. 22 passed; 0 failed; 0 ignored; 0 measured; 1479 filtered outmake test-crate C=app T=native_key_effect:test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 1497 filtered outmake test-crate C=plx_screens T=native_key_effect:test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2285 filtered outmake test-hostsim T=native_key_effect:test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 1738 filtered outtest result: FAILED. 1746 passed; 2 failed. The two failures are thedeeplink_route_testspair,a_play_landing_behind_a_preview_that_never_returns_gives_upanda_play_landing_waits_for_an_abandoning_preview.9 passed; 0 failed).ef88a5b3c,make test-crate C=plx_uigavetest result: ok. 1775 passed, includingui/src/fixture.rs's pin oningest_host_event, andmake test-crate C=plx_screens T=profilesgaveok. 66 passed.make check-replay:6 fixtures, 12 replays, SAME=4 REFUSED_EXPECTED=8 unexpected=0. Every real replay isverdict=SAME.tests/keytable.json, the tapes andci/proofs.ci/check-deps.sh,ci/check-module-layers.py,ci/check-ledger-ratchet.pyandci/check-list-caps.py.Not run here:
make check,check-nodefand the ARM cross-build. This PR's own CI gates them.Television
The dev set ran the same remote-key script on this change at
ef88a5b3c. The later commits changeKeyPress::new's validation, which no SDL or FIFO press can fail. They also putingest_key's pointer-hide early return back onclassifyof the pair, as on main: for every SDL press that agrees with the action test it replaced, becauseaction_ofanswersPointerHiddenonly fromclassify's own arm.KeyPress::action()becomes test-only. The rest is tests and comments. Main (1adff841e) ran it for comparison, with one 8-minute lease per build. Each lease held two--guest --mockboots of plainmakebuilds againsttests/mock_pms.py: a library grid, and the player on the mock's verification episode. Nookwas pressed.Identity, checked before the first key of every boot:
token: using /tmp/plxnative-token (test identity)andpms: server 0 version=1.41.0.0000-synthetic.Binary. For each build, the binary's md5 matched on the host, in the app directory and at
/proc/<pid>/exe.Raw bytes. Each build logged 38
key type=0x300/0x301 raw=lines, in the same order, two edges per press:down down right,pagedown pageup,chdown chup,back;0x1e4and the unbound0x1f8, on the grid and in the player;play pause playpause ff rew stop;exit.With the
[ms]stamp stripped, the lines are byte-identical except bytes 4-7. Those hold SDL's event timestamp, whichSDL_PushEventstamps on each FIFO key; it equals the line's own[ms]stamp.Effects. Every key had the same effect on both builds:
card.0 → 6 → 12 → 13;card.25and back;0x1e4and0x1f8change nothing;Clean run. Neither build logged a crash record,
*** EXIT, panic or unknown token.Text. Text through LG's on-screen keyboard is host-graded only. The FIFO cannot reach that panel, and uinput and the keymanager luna API do not reach the app. The LG text offset is pinned byte for byte by
key_event_tests::a_text_commit_decodes_at_this_builds_offsetunder the default features.Not caused by this change: EXIT pressed on Home did not end the process on either build. SAM's close ended it. Its
running = falsearm sits behind the tree-owns-key return, on main as well.🤖 Generated with Claude Code