Skip to content

feat(motion): add Handoff::select safe selection-indicator helper and tighten motion truth matrix active check - #574

Merged
CommaBot merged 2 commits into
mainfrom
feat/motion-handoff-select
Dec 6, 2026
Merged

CommaBot merged 2 commits into
mainfrom
feat/motion-handoff-select

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds motion::Handoff::select — a hard-to-misuse selection-indicator helper that encapsulates the Handoff::part lifecycle so downstream tab strips, tab bars, and sidebar pills cannot accidentally collapse handoffs into 1-frame snaps — and closes the 1 P2 + 1 Nit follow-up from #573.

Motivation & Adoption Plan

Low-level Handoff::part(seen, gave=...) requires callers to keep seen(at) > 0.0 across synchronous signal flips and to reset outgoing ways (part.still()) only inside gave. Callers that naively pass fn(_) { if active() { 1.0 } else { 0.0 } } or call part.still() immediately when active() turns false silently turn every tab/selection switch into a 1-frame snap because active() flips before the incoming peer runs came.

Built-in packages/lg segmented controls and bottom tabs use glass::DampedDrag (interactive finger-draggable pill with gesture projection), whereas downstream desktop tab strips, tab bars, and sidebar selection indicators use motion::Handoff for click/keyboard selection-pill glide — Handoff::select is the direct drop-in replacement for those downstream Handoff::part callers.

Changes

  1. packages/motion/src/handoff.pion:
    • Added pub fn Handoff::select(self, v, active, spec?, tag?, carries?) -> HandPart:
      • Tracks internal showing and left_at (seen(at) = if showing && at <= left_at { 1.0 } else { 0.0 }) so same-timestamp switches hand off smoothly regardless of reactive watcher registration order, while clearing selection (active -> false with no peer taking over) expires immediately on later timestamps (at > left_at) instead of ghost-gliding from an invisible prior item.
      • Calls part.still() only inside gave, preserving live mid-flight geometry and velocity across rapid switches and reversals (A -> B -> C, A -> B -> A).
      • Starts still on initial mount (takes=false) and cleans up cleanly on v disposal (part.gone(), clearing part_ref so zero RC cycles remain).
    • Updated both HandPart::came and HandPart::other_near window checks from < to <= so Handoff::new(within=0.0) allows same-timestamp handoffs consistently.
    • Documented the Handoff::part caveat and pointed selection-indicator callers to Handoff::select.
  2. packages/motion/src/zz_invar_handoff_select_test.pion:
    • Regression tests (pionc fmt --check clean) covering: initial mount at rest, forward (0 -> 2) and reverse (2 -> 0) mid-flight continuity (strict "a motion said is not at rest" check + ground_drawn.dx), rapid mid-flight reversals (0 -> 1 -> 2), empty-selection clear + wait past move_most_ms (dx == 0, no ghost glide), 1-frame reduced_motion, active-tab disposal (dx == 0 + idle), and Handoff::new(within=0.0) forward & reverse watcher orders.
  3. packages/lg/src/motion_truth_matrix_test.pion (fix(view,lg): unmount View::show/pick leaves immediately under reduced_motion and expand Motion Truth Matrix to 18/18 Truth C #573 review follow-up):
    • Tightened mt_assert_active to require "a motion said is not at rest" and fixed pionc fmt indentation.

Verification (pvg-office-1, pion@c6c6dd79a7, PION_STRICT_STUB=1)

  • pionc fmt --check on both modified test files: PASS
  • scripts/invar check --json: 58/58 PASS
  • scripts/invar audit --json --require-reactive: 0 errors / 0 warnings
  • pionc test packages/motion: 43 passed / 0 failed
  • Handoff::select (2 tests) under MBUI_TEST_MOTION=judge across 60 / 120 / 24 FPS: 3/3 PASS
  • pionc test packages/kit: 75 passed / 0 failed
  • pionc test packages/lg --filter "lg_motion_truth_": 3/3 PASS

@CommaBot
CommaBot merged commit 1305db2 into main Dec 6, 2026
3 checks passed
@CommaBot
CommaBot deleted the feat/motion-handoff-select branch December 6, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants