Skip to content

Pill: drag from anywhere, keep its state while dragged, never render empty - #32

Merged
ofcRS merged 8 commits into
mainfrom
fix/pill-drag-and-empty
Nov 18, 2026
Merged

ofcRS merged 8 commits into
mainfrom
fix/pill-drag-and-empty

Conversation

@ofcRS

@ofcRS ofcRS commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Three user-reported pill bugs, each traced to its mechanism and filmed before/after with pillsandbox (new press: / move: / release steps drive a real drag through the pill's own window; --start-delay / --start-block give a start from the pill the app's timing).

1. No place to start a drag

Cause. The peek dock is four fields, and each was a SwiftUI Button (DictationPillView.swift, PillDockTile). A Button takes the press, so the capsule's .gesture(DragGesture) never started from the dock — which is all the resting pill ever shows under the pointer. Filmed: a press on the dock and a 240 pt move leave the dock in place while the pointer slides off it.

Fix. One DragGesture(minimumDistance: 0) for the whole capsule: past PillGeometry.dragThreshold (6 pt) it drags, below it it is a click on whatever is under it. The dock's fields are no longer Buttons (still buttons to VoiceOver, still squash when pressed). Real buttons (Stop, a prompt's answers, ✕, a fault's action) keep their press and never drag. Cursor: open hand on the body that only drags, pointing hand where a click acts, closed hand while dragging (DictationPillModel.cursor, re-asserted on every pointer move — the app is never active, so cursor rects don't run). No grip mark: the whole pill drags, and the bars' widths stay as tuned.

2. The dragged pill collapsed and jumped

Causes.

  • AppKit delivers a tracking area's exit mid-drag. With the pointer off the dock, handleHover(false) started the 450 ms linger and setPeeking(false) → show(.idle) sank the dock into its edge at the OLD saved spot during the drag.
  • The drag placed the panel with dockedCenter only, skipping the clamp the settled pill gets (activeOrigin), so the dock (thicker than the reference size) dropped 11 pt on the first drag frame.

Fix. A drag session (isDragging): the pill keeps its phase, size and peek until the drop; hover changes don't collapse it; every show/hide that arrives meanwhile is held and the latest lands at the drop (upcomingState/currentState report it, so the coordinator's ownership rules still hold); the pointer is re-read at the drop, so a dock dropped with the pointer off it tucks at its new place. Settled and dragged panels both go through PillGeometry.dockedOrigin, so a press that hasn't moved moves nothing. A drag whose mouse-up never reached the gesture is dropped as soon as the left button is up.

3. An empty pill while active

Causes.

  • A phase change during a drag (a dictation finishing, a capture starting): transition grows the panel into a stage and offsets the capsule on it; the next dragMoved() wrote the dragged frame over the stage without zeroing the offset, so the capsule was drawn off its own window — empty or half-cut — and the spring's settle then threw the panel back to where the drag began. Filmed: before-done-drag frames 90–92.
  • A start from the dock ran the .rise cue, whose content stays hidden until the capsule "has left the edge": from the dock (already out) that is a dock-sized empty capsule, frozen for as long as the main thread is busy starting the capture (Recorder.start() / DictationCapture.start() run on it). Filmed in a real screen grab too.
  • The settle relied on withAnimation(_:completionCriteria:_:completion:), which never fired for a transition that starts a move and a reshape in the same turn — every rise and sink. The panel stayed a stage, the dock's surface stayed held, until the next morph (for the whole length of a meeting).
  • settle() dropped a phase still waiting for its turn (the generation bump), so a settle in that turn (a drag starting) could leave the new phase never applied.

Fix. The drag session above; a start from the dock morphs (content visible from the first frame); the panel settles on a timer from PillMotion.settleDelay (KleothCore, tested); settle() lands a pending phase at once; hover and peek decisions read the phase still to land (upcomingPhase), so a hover can no longer peek the dock over a .listening asked for in the same turn.

Tests

  • PillDragTests (5 new, KleothCore): no jump at drag start on every edge for the dock, a bar and the reference panel; the dock clamped inward; the grabbed point stays under the pointer; click vs drag threshold; settle waits for the last beat.
  • swift build && swift test: 790 tests. swift build --package-path app, swift test --package-path app. KLEOTH_NO_INSTALL=1 bash app/make-app.sh release with its smoke test.

Not verified by film (needs eyes on the real app)

  • A real mouse drag of the dock and of a meeting bar; the cursor shapes (open/closed/pointing hand) over an inactive app.
  • A prompt's Record / Never and a fault's action/✕ after the gesture change: synthetic film clicks can't fire .borderless buttons (AppKit tracking loop) — not with the old view either.
  • Liquid Glass dock → bar morph on screen (films see only the pill's own pixels).
  • Reduce Motion (not toggled: it is a system setting on the user's Mac).

No version bump.

…iming

PillGeometry.dockedOrigin places a docked panel (anchor + clamp) for both the
settled pill and a drag, so a press that has not moved moves nothing (the drag
skipped the clamp: the peek dock dropped 11 pt). Drag threshold, grab offset and
drag-along helpers, and PillMotion (spring durations + settleDelay), all tested.
…empty

- Every point of the capsule but a real button drags past a 6 pt threshold; a
  press that does not travel is a click. The peek dock's fields were Buttons, so
  the dock could not be dragged at all and the pointer slid off it.
- A drag keeps the pill's phase, size and peek until the drop: requests that
  arrive meanwhile (a dictation ending, a meeting starting) land at the drop; a
  hover exit no longer collapses the dock mid-drag.
- Phase changes during a drag drew the capsule outside its panel (empty or
  half-cut) and the settle threw the panel back to where the drag began.
- The panel settles on a timer (PillMotion): SwiftUI's completion never fired
  for a rise or a sink, so the panel stayed a stage with the dock's surface held.
- settle() lands a phase still waiting for its turn instead of dropping it.
- A start from the dock morphs instead of rising, whose hidden content showed a
  dock-sized empty capsule.
- Open-hand cursor on the body that drags, closed while dragging.
press:<spot> / move:<dx>:<dy> / release drive a drag through the pill's own
window (synthesized events, a film pointer instead of the cursor, the tracking
area's mid-drag exit emulated); --start-delay / --start-block give a start from
the pill the app's async meeting start and blocking dictation capture; fired
actions print in film mode; the film pointer is drawn on the frames.
PillPress decides click or drag from the pointer's travel ON SCREEN and never
calls a press that became a drag a click. PillDragHold holds requests during a
drag (latest wins) except a capture going hot. PillTransitionLedger keeps the
transition generation and its pending shape, which a settle lands instead of
dropping. alongCapsule maps a screen point onto the capsule's own axis.
- The controller owns the press, measured on screen: a drag dropped without
  the gesture can no longer end as a click, and a press while the dock opens
  is a click on the field it aims at (resolved on the settled dock).
- show() drops a released drag before cancelling the auto-hide, and hideTask
  is never reassigned without a cancel: a held phase's replayed timer no longer
  dismisses the phase that came after it.
- A 0.25 s button watch ends a drag whose mouse-up was lost; a capture going
  hot is never held by a drag: its bar shows at once where the pill is dragged.
- VoiceOver gets the capsule's click as named actions.
@ofcRS

ofcRS commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Review round (6 items) — fixed on this branch:

  1. A dropped drag could still click (real in code; not reproducible by film — the capsule-local translation after a drop stayed ≥ 27 pt in films). The press is now measured on screen and owned by the controller (PillPress): a press that became a drag is never a click, however its drop came about. Test: PillPressTests.aDragIsNeverAClick.
  2. A replayed phase's auto-hide leaked (reproduced: r2-before — a .saved held in a drag, dropped by show(.listening), dismissed the live dictation 3.8 s later). show() drops a released drag first, then cancels the timer; hideTask is never reassigned without a cancel. After: .listening stays.
  3. A lost mouse-up held the pill (reproduced: r3-before — a meeting starting mid-drag never got its bar). A 0.25 s button watch drops the drag; and a capture going hot (.armed/.listening/.recording/.meeting) is never held — it shows at once at the dragged spot and the drag goes on (PillDragHold). After: the bar appears mid-drag and keeps moving with it.
  4. A press while the dock opens was no click (reproduced: r4-before). Threshold on screen; the field resolved on the settled dock at release. After: the same press records the meeting.
  5. VoiceOver: the capsule now carries named actions (Dismiss, Stop dictation, Keep listening hands-free, Show in Finder, Open in History). Not verified with VoiceOver.
  6. Tests: PillPressTests (8) — screen-space click/drag, the settled-field mapping on every edge, the drag hold (latest wins, hot never held), and the transition ledger (a settle lands the pending shape; only the latest transition lands). Timer and button-watch paths are not pure (Tasks, NSEvent) and are covered by films.

swift test 798, app build + tests, release build + smoke all green.

@ofcRS
ofcRS merged commit 9c9f511 into main Nov 18, 2026
3 checks passed
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.

1 participant