Skip to content

feat(native): haptics that components own - #488

Merged
Makisuo merged 7 commits into
mainfrom
t3/ios-haptics-long-press
Nov 15, 2026
Merged

Makisuo merged 7 commits into
mainfrom
t3/ios-haptics-long-press

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

iOS haptics, owned by components rather than features.

The rule (apps/web-foldkit/src/platform/feedback.ts): feature code never asks for a haptic. Each component plays the one its kind of interaction means:

Kind Played by
selection Switch, Checkbox, Radio, ChoiceBox, an unselected tab (Tabs, TabStrip)
impact a context menu opening as a sheet (already there, now named)
success / warning / error a Toast of that kind

Plain buttons, links, navigation and typing play nothing. The browser and the desktop shells play nothing either.

How it works

  • Presses: the component marks the element that carries the press handler with data-native-feedback. The Rune host plays the haptic inside on_press, as the finger lifts and before the event reaches the runtime, so there's no round trip (host/src/feedback.rs, render/handlers.rs).
  • Outcomes: Toaster.push returns a PlayToastFeedback command for success, warning and error toasts. It goes over the bridge as { feedback }.
  • iOS maps the kinds to UISelectionFeedbackGenerator, UIImpactFeedbackGenerator (medium) and UINotificationFeedbackGenerator (host/ios/src/system.rs). SystemUi.haptic() is replaced by feedback(kind).

Verification

  • bun run typecheck passes, and the full web-foldkit vitest suite passes: 2644 tests, including new scene tests (the switch is marked and a disabled one isn't, only an unselected radio is marked) and a toaster test (only outcome toasts play).
  • The native runtime's vitest suite (79 tests) and cargo test --lib (162) pass. The new host test checks that only a marked press plays, exactly once, and that the click still goes through.
  • iOS Simulator, built with NATIVE_DEBUG=1: the simulator can't play haptics, so the host logs each one.
    [host] haptic Selection   # Messages → Files tab
    [host] haptic Selection   # Files → Messages tab
                              # pressing the selected tab again: nothing
    [host] haptic Success     # Copy Text → "Copied!" toast
    
  • Not verified: how each haptic feels on a real iPhone. That needs a TestFlight build.

Next in the stack: #489 (long-press menus).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added selection feedback for enabled switches, checkboxes, radio buttons, and choice-box items, plus unselected tabs.
    • Added success, warning, and error feedback for matching toast notifications, and impact feedback when opening phone menus.
    • Added iOS support for selection, impact, success, warning, and error feedback. Unsupported feedback names are logged.
  • Documentation
    • Documented iOS feedback options, debug logging, and simulator limitations.

Makisuo and others added 3 commits November 15, 2026 14:00
A press on a Switch, Checkbox, Radio, ChoiceBox or unselected tab plays the
selection haptic on iOS, marked `data-native-feedback` and played by the host
as the finger lifts, before the runtime hears the press. Success, warning and
error toasts play their outcome. Features never ask for one; the vocabulary
and the rule for when each plays live in `platform/feedback.ts`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st its own ids

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o plays them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maple-review-bot

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

The change adds typed feedback requests for native control presses, menu opening, and success, warning, and error toasts. The native renderer plays marked press feedback before dispatching events. The iOS host maps feedback kinds to UIKit generators.

Changes: Feedback delivery

Layer / File(s) Summary
Feedback types and platform helpers
apps/native/host/src/feedback.rs, apps/native/host/src/lib.rs, apps/web-foldkit/src/platform/feedback.ts, apps/web-foldkit/src/platform/system-ui.ts, apps/native/src/ios.ts
The web and native code define five feedback kinds and helpers for attribute-based press feedback and system UI playback. The iOS request carries a feedback kind.
Control press feedback
apps/web-foldkit/src/ui/*, apps/native/host/src/render/*, apps/native/host/src/tests.rs
Enabled controls add selection feedback metadata when applicable. The native renderer plays parsed feedback before dispatching press events. Tests check control attributes and native press behavior.
iOS feedback playback
apps/native/host/ios/src/*, apps/native/README.md
The iOS bridge parses feedback requests, and the host installs a player that maps feedback kinds to UIKit generators. The documentation describes haptics and debug logging.
Toast outcome feedback
apps/web-foldkit/src/overlay/toaster.ts, apps/web-foldkit/src/test/toast-fixtures.ts, apps/web-foldkit/src/overlay/toaster.test.ts, apps/web-foldkit/src/app/*
Success, warning, and error toast requests add a feedback command. The command calls the platform helper and emits a completion message. Toast tests resolve the command before draining applicable toasts.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant UIControl
  participant NativeRenderer
  participant FeedbackPlayer
  participant UIKit
  UIControl->>NativeRenderer: press with data-native-feedback
  NativeRenderer->>FeedbackPlayer: play parsed feedback kind
  FeedbackPlayer->>UIKit: invoke matching feedback generator
Loading
Merge Risk: Minimal · up to b20dc

This change moves iOS haptic feedback into the UI components and adds feedback for toast outcomes. It is covered by tests and has no known defects. Real-device haptic feel still needs a TestFlight check, which does not block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(native): haptics that components own" matches the main change. The PR moves haptic decisions into UI components: they mark elements with data-native-feedback, and the host plays feedba…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(native): haptics that components own" matches the main change. The PR moves haptic decisions into UI components: they mark elements with data-native-feedback, and the host plays feedback on press. Toast outcomes also trigger feedback through a PlayToastFeedback command, and the iOS system layer replaces haptic() with feedback(kind). The title names the primary change and uses the conventional commit prefix, so it is a clear and specific summary.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1fc28d73-6e5a-4c43-b8bd-57979018601a
Commits

Reviewing files that changed from the base of the PR and between df4ede8 and 1945678.

Files selected for processing: 2

  • apps/web-foldkit/src/app/shell.scene.test.ts
  • apps/web-foldkit/src/overlay/toaster.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maple-review-bot

This comment has been minimized.

@Makisuo

Makisuo commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Maple's F1 note is addressed in df4ede8: scene tests now pin the haptic mark on an unselected tab (and its absence on the selected and the disabled tab), on a Checkbox (none when disabled), and on a ChoiceBox row (none on a disabled or read-only row).

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 74.04% 37704 / 50923
🔵 Statements 73% 42892 / 58749
🔵 Functions 61.7% 13481 / 21848
🔵 Branches 61.44% 21341 / 34733
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/web-foldkit/src/overlay/toaster.ts 82.14% 91.66% 75% 80.76% 53-56, 94-95
apps/web-foldkit/src/platform/feedback.ts 75% 100% 50% 100% 30
apps/web-foldkit/src/platform/system-ui.ts 100% 100% 100% 100%
apps/web-foldkit/src/test/toast-fixtures.ts 100% 100% 100% 100%
apps/web-foldkit/src/ui/aria-radio.ts 92.3% 88.88% 66.66% 92.3% 113
apps/web-foldkit/src/ui/checkbox.ts 100% 95.23% 100% 100%
apps/web-foldkit/src/ui/choice-box.ts 96.15% 91.86% 91.89% 95.52% 73-74, 80-81
apps/web-foldkit/src/ui/menu-view.ts 58.51% 69.93% 46.77% 58.82% 55, 80-118, 130-137, 153-174, 181-202, 298, 449, 538-545, 549-578
apps/web-foldkit/src/ui/radio.ts 100% 95.83% 100% 100%
apps/web-foldkit/src/ui/switch.ts 100% 93.75% 100% 100%
apps/web-foldkit/src/ui/tab-strip.ts 100% 83.33% 100% 100%
apps/web-foldkit/src/ui/tabs.ts 100% 100% 100% 100%
Generated in workflow #2362 for commit b20dc50 by the Vitest Coverage Report Action

… svg and paint without empty spreads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maple-review-bot

This comment has been minimized.

…ress

# Conflicts:
#	apps/web-foldkit/src/app/shell.scene.test.ts
#	packages/foldkit-rune/src/target.ts
@maple-review-bot

This comment has been minimized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Makisuo

Makisuo commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Maple's F2 note: the toaster test now asserts the replaced toast runs exactly one WaitBeforeDismissal (a doubled timer fails it) rather than pinning the exact command list, which the repo's test-slop(no-exact-name-list) lint forbids; the haptic command is pinned by its own test. Commit b20dc50.

@maple-review-bot

maple-review-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. Only the toaster test changed since the last pass and it now catches the defect F2 described; native haptic feel is still unverified on a device.
no findings · tests covered · risk medium

Component-owned iOS haptics: presses are marked with data-native-feedback and played in the host's on_press, outcome toasts return a PlayToastFeedback command, and iOS maps each kind to a UIKit generator. Nothing new is wrong in the file that changed since the last pass.

Fixed since the last review

  • ✅ F2 · toContain stops pinning the toaster's timer command set

b20dc50 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@Makisuo
Makisuo added this pull request to stack #490 November 15, 2026 13:58
@Makisuo
Makisuo merged commit bd2a2a3 into main Nov 15, 2026
8 checks passed
@Makisuo
Makisuo deleted the t3/ios-haptics-long-press branch November 15, 2026 13:58
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