|
| 1 | +# Scanner architecture |
| 2 | + |
| 3 | +The scanner has four boundaries: content, traversal, presentation and execution. |
| 4 | +All desktop scanning shares the Rust `Session<Technique>` lifecycle and |
| 5 | +`scanning_runtime::Adapter` platform boundary. Local and Remote switches feed |
| 6 | +that same session. No item scanner captures keys, runs native input, persists |
| 7 | +settings or owns a timer thread. |
| 8 | + |
| 9 | +## Adding an item scanner |
| 10 | + |
| 11 | +Use `scan_items::ItemScanner<Action>` with a small typed action enum. Supply |
| 12 | +`scan_tree::Node::Group` nodes with stable group IDs and `Leaf` action identities. |
| 13 | +Group IDs must be unique among siblings; leaf identities must be unique within |
| 14 | +their group. They must identify the operation, not its current label or bounds. |
| 15 | +The `rows` convenience constructor is for fixed row layouts: its positional row |
| 16 | +IDs are not suitable when groups can reorder. Supply explicit groups in that case. |
| 17 | +Empty groups are removed. Explicitly identified groups retain their identity even |
| 18 | +with one child. Anonymous branches and fixed single-item rows collapse as before. |
| 19 | + |
| 20 | +Call `handle` with normalized switch actions and `advance` with elapsed time only |
| 21 | +when the containing session permits movement. The core owns the interval, |
| 22 | +direction, completed passes, suspension and nested Back navigation. Read its |
| 23 | +navigator to build a presentation. Do not add a second interval in the provider. |
| 24 | +`Policy` preserves the existing menu/keyboard differences during migration: |
| 25 | +menus resume their selection; keyboards resume at the root. Keyboard manual |
| 26 | +steps reset completed passes; existing menu manual steps do not. |
| 27 | + |
| 28 | +Use `replace` when action availability or layout structure changes. Identified |
| 29 | +groups and leaves retain their selection through reordering; a removed target |
| 30 | +returns to the nearest surviving ancestor's first item with a full interval. |
| 31 | +Any changed content invalidates pending activation. Identical content preserves |
| 32 | +both timing and pending activation. Update labels and bounds separately when the |
| 33 | +available actions have not changed. Do not put captured text into action IDs. |
| 34 | + |
| 35 | +Before asynchronous execution, call `begin_activation` and retain the returned |
| 36 | +revision. While pending, the core does not advance or select. Complete with that |
| 37 | +same revision; stale or repeated completions return false. Restart and content |
| 38 | +replacement cancel pending activation. The runtime's existing input generation |
| 39 | +checks remain authoritative across whole-session replacement, disconnect and |
| 40 | +capture cancellation; an item revision is local to one scanner instance. |
| 41 | + |
| 42 | +The tests in `scan_items` provide a platform-free example using editing actions, |
| 43 | +including reordered content, cancellation, exactly-once completion and timing. |
| 44 | + |
| 45 | +## Existing providers |
| 46 | + |
| 47 | +- `scan_menu` supplies typed menu actions and tile geometry. It delegates traversal |
| 48 | + to the item scanner and retains its existing three-column layout and parent stack. |
| 49 | +- `scan_keyboard` supplies keys, modifiers, pages, prediction availability and |
| 50 | + geometry. It delegates traversal and pending activation to the item scanner. |
| 51 | + Prediction tokens still guard insertion, and queued prediction replacement |
| 52 | + remains a keyboard policy. Unchanged suggestions never restart the interval. |
| 53 | +- `point_scan` retains its continuous movement strategy and uses the shared |
| 54 | + navigator for grid scanning. `point_workflow` composes point, menus, countdown, |
| 55 | + keyboard and execution-error stages within one session. |
| 56 | +- Native hosts render `Frame` without activating Switchify. Domain actions are |
| 57 | + executed through the existing typed workflow requests and platform adapters. |
| 58 | + |
| 59 | +## Following stages |
| 60 | + |
| 61 | +Issue #801 adds validated shared settings and per-area overrides to this core. |
| 62 | +Issue #802 adds a main-window React content adapter and foreground/modal ownership. |
| 63 | +Those stages do not require individual screens to implement traversal or timers. |
| 64 | +They must preserve the current input generation checks, cleanup, native focus, |
| 65 | +point countdown cancellation and Remote behaviour. |
0 commit comments