Skip to content

feat(native): a long press opens a row's menu as the system's - #489

Merged
Makisuo merged 12 commits into
t3/ios-haptics-long-pressfrom
t3/ios-long-press-menus
Nov 15, 2026
Merged

Makisuo merged 12 commits into
t3/ios-haptics-long-pressfrom
t3/ios-long-press-menus

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #488. Merge that first.

A long press on a row opens the row's own menu as the iOS system menu.

The abstraction: Menu.longPressMenu(h, { menu, entries, native, toParentMessage }) in ui/menu-view.ts. It takes the same Menu model and entries a "⋯" trigger opens and emits the context-menu island. The choice comes back as the same ChoseFromNativeMenu, so a feature handles one path whatever the trigger was. It adds nothing when the entries aren't all words, and nothing in a browser. Underneath it, nativeContextMenu (platform/native-island.ts) takes the menu island's NativeMenuItem list plus an optional quick row.

Uses

  • Sidebar channel and DM rows: each row's menu inputs are defined once (rowMenu, dmMenu) and shared by the dots button and the long press. That gives Mute, Favorite, the Move to section submenu, Settings, and Delete/Leave in red.
  • Message rows: moved onto the same path. contextMenuEntries now carries its words (textValue, which also gives the web menu typeahead), and the separate label/group builder is deleted. Quick reactions stay on top.
  • Host (host/ios/src/context_menu.rs): builds the menu with the menu island's own builder, so submenus, checked, disabled and destructive items all work. When regions are nested, the innermost one under the finger wins.

Verification

  • bun run typecheck passes, and the full web-foldkit suite passes: 2644 tests, including ui/menu-long-press.scene.test.ts (a row carries its entries, words and symbols; a choice goes through the menu's own update; a menu without words gets nothing). The native suites and cargo test --lib also pass.
  • iOS Simulator, offline fixture:
    • A long press on #support opens its menu. Choosing Mute logs GotRowMenuMessage/ChoseFromNativeMenu, then channelMember.update.
    • A message's menu renders as before, and 👍 logs ChoseNativeAction, then messageReaction.toggle.
    • Holding a row and lifting doesn't navigate.
  • A review sub-agent went over the whole stack. Its four low-severity findings are fixed: grouping now shared with the menu island, the quick-row constant renamed, no haptic on a disabled tab, and corrected feedback docs.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added long-press context menus for chat messages, channels, and direct messages on supported native devices.
    • Message menus include quick reactions and actions such as reply, copy, pin, and—when available—edit, thread reply, and delete.
    • Channel and direct-message menus provide relevant options, including mute, favorite, and channel settings.
    • Menus support separators and submenus, and indicate selected items where applicable.

Makisuo and others added 5 commits November 15, 2026 14:06
`Menu.longPressMenu` puts a menu's own entries on an element as the iOS
`context-menu` island, so a long press opens the same menu its "⋯" trigger
does and the choice comes back as the same `ChoseFromNativeMenu`. Sidebar
channel and DM rows get it; message rows move onto the same items
(`nativeMenuItems`, their entries now carrying their words) with their quick
reactions above. The host builds the menu with the `menu` island's builder,
and a press on nested regions opens the innermost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…land does

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

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

This change adds native long-press context menus for chat messages and sidebar channel and DM rows. It shares menu entries between web and native presentations, adds quick reactions for messages, and updates iOS menu parsing and rendering to use item lists and grouped separators.

Changes: Native context menus

Layer / File(s) Summary
Native menu contract and iOS rendering
apps/web-foldkit/src/platform/native-island.ts, apps/native/host/ios/src/context_menu.rs, apps/native/host/ios/src/islands.rs, apps/native/README.md
The native context-menu contract supports items and optional quick choices. The iOS host groups menu items, selects the smallest matching visible region, and renders quick choices.
Reusable web long-press menu adapter
apps/web-foldkit/src/ui/menu-view.ts, apps/web-foldkit/src/ui/menu-long-press.scene.test.ts
longPressMenu converts eligible menu entries into native context-menu attributes and maps a selected key to a menu message. Tests cover menu properties, selection state, and entries without text.
Chat message context menus
apps/web-foldkit/src/page/chat/overlays.ts, apps/web-foldkit/src/page/chat/row-context.ts, apps/web-foldkit/src/page/chat/channel/messages.scene.test.ts
Message rows use shared context-menu entries for native menus. Quick reactions are included, and edit and delete entries remain conditional on message ownership.
Sidebar channel and DM context menus
apps/web-foldkit/src/shell/channels-sidebar/items.ts, apps/web-foldkit/src/shell/channels-sidebar/menus.ts, apps/web-foldkit/src/shell/channels-sidebar/view.ts, apps/web-foldkit/src/shell/channels-sidebar/long-press.scene.test.ts
Channel and DM rows attach native long-press menus. The menu entries also appear in the corresponding dots menus.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MessageRow
  participant MenuView
  participant NativeIsland
  participant iOSContextMenu
  MessageRow->>MenuView: provide menu entries and quick choices
  MenuView->>NativeIsland: create context-menu attributes
  NativeIsland->>iOSContextMenu: send context-menu island properties
  iOSContextMenu-->>NativeIsland: return selected item key
  NativeIsland-->>MenuView: emit change event
  MenuView-->>MessageRow: map selection to a menu message
Loading

Possibly related PRs

Merge Risk: Low · up to 210f1

Long-press menus for chat messages and sidebar rows work as described. In the narrow case where a nested island has exactly the same visible bounds as its parent, a press may open the parent's menu instead of the child's. This is a minor, self-contained edge case that a small tie-break fix resolves, and it is low risk to merge.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution failed

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

@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

childAttributes(
nativeContextMenu(
h,
{ items: found, quick: { choices: TOP_EMOJIS, prefix: Overlays.NATIVE_REACTION } },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Message row's new context-menu props shape is pinned by no test

F1 · Warning · tests

The row's island props change from {reactions, reactionPrefix, groups} to {items, quick} — a contract with context_menu.rs:163 that no test pins on either side; menu-long-press.scene.test.ts only exercises longPressMenu on a synthetic view. A mismatch between the two renders an empty system menu and nothing fails.

Add a scene test over `rowLongPress` (or a rendered message row) asserting `data-native-props` carries `items` and `quick.choices`/`quick.prefix`.
🤖 Prompt to fix with an AI agent
In `apps/web-foldkit/src/page/chat/row-context.ts:181`: Message row's new `context-menu` props shape is pinned by no test.

The row's island props change from `{reactions, reactionPrefix, groups}` to `{items, quick}` — a contract with `context_menu.rs:163` that no test pins on either side; `menu-long-press.scene.test.ts` only exercises `longPressMenu` on a synthetic view. A mismatch between the two renders an empty system menu and nothing fails.

Suggested fix: Add a scene test over `rowLongPress` (or a rendered message row) asserting `data-native-props` carries `items` and `quick.choices`/`quick.prefix`.

Verify the problem exists at that location before changing it, and keep the fix to those lines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9baf011: messages.scene.test.ts now renders the channel and pins both rows' exact data-native-props (own and other's message: items with words, symbols and destructive, quick.choices/quick.prefix) plus the row's change handler. I checked it fails if the shape drifts (renaming quick breaks it).

@maple-review-bot

This comment has been minimized.

@maple-review-bot

This comment has been minimized.

@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

),
}),
rowMenuView(h, menu),
rowLongPress(h, menu),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Sidebar rows' long-press menus are wired by no test

F2 · Warning · tests

rowLongPress/dmLongPress reach the rows only through positional args of channelItem/dmItem, and no test pins that a sidebar row carries the island. One rowMenuEntries leaf losing its textValue makes nativeMenuItems return None, so a sidebar row's menu silently disappears on iOS with every test green; only the message row is pinned.

Render the sidebar in a scene test and assert a channel row and a DM row each carry `data-native="context-menu"` with their entries' words (Mute, Favorite, Move to section, Settings, Leave / Hide conversation).
🤖 Prompt to fix with an AI agent
In `apps/web-foldkit/src/shell/channels-sidebar/view.ts:151`: Sidebar rows' long-press menus are wired by no test.

`rowLongPress`/`dmLongPress` reach the rows only through positional args of `channelItem`/`dmItem`, and no test pins that a sidebar row carries the island. One `rowMenuEntries` leaf losing its `textValue` makes `nativeMenuItems` return `None`, so a sidebar row's menu silently disappears on iOS with every test green; only the message row is pinned.

Suggested fix: Render the sidebar in a scene test and assert a channel row and a DM row each carry `data-native="context-menu"` with their entries' words (Mute, Favorite, Move to section, Settings, Leave / Hide conversation).

Verify the problem exists at that location before changing it, and keep the fix to those lines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 210f1dd: shell/channels-sidebar/long-press.scene.test.ts renders the sidebar's sections with a channel and a DM row and pins each row's exact context-menu props (Mute, Favorite, Settings, Leave / Hide conversation, with symbols and danger), plus that the dots' menu island carries the identical items. Checked it fails when a row entry loses its textValue.

…e items as their dots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 sidebar scene test changed since the last pass; it asserts the props the code actually emits at this head.
no findings · tests covered · risk low

A long press on a sidebar or message row now opens the row's own menu as the iOS system menu, built from the same entries its "⋯" trigger uses. The one file new since the last pass is the sidebar scene test, and it holds.

  • longPressMenu renders a row's menu entries as a context-menu island, nothing when an entry lacks words
  • rowLongPress/dmLongPress share rowMenu/dmMenu with each row's dots trigger
  • The iOS host builds the menu with the menu island's own builder

Before merge

210f1dd · 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
10 checks passed
@Makisuo
Makisuo deleted the t3/ios-long-press-menus branch November 15, 2026 13:58
@maple-review-bot

Copy link
Copy Markdown

Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 74.1% 37739 / 50923
🔵 Statements 73.08% 42935 / 58749
🔵 Functions 61.86% 13522 / 21858
🔵 Branches 61.6% 21387 / 34719
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/web-foldkit/src/page/chat/overlays.ts 67.83% 54.14% 62% 67.27% 43, 156, 159-160, 232-233, 318-319, 326-332, 410-456, 468-522, 529-530, 547-549, 576-615, 621, 623-624, 635, 680-681
apps/web-foldkit/src/page/chat/row-context.ts 49.58% 17.02% 37.28% 56.98% 44-45, 53-54, 56-57, 59-60, 62, 67-68, 93-94, 97-111, 115-118, 121-138, 176, 182, 204, 211, 223, 225-232, 239-306, 349
apps/web-foldkit/src/platform/native-island.ts 100% 75% 100% 100%
apps/web-foldkit/src/shell/channels-sidebar/items.ts 67.92% 36% 50% 67.44% 63-72, 83-115, 152-184, 198-205, 214-225, 230, 237, 241-259, 267-283, 287-308, 314-328
apps/web-foldkit/src/shell/channels-sidebar/menus.ts 54.12% 30.3% 61.53% 54.54% 119-125, 162-174, 195-205, 242-243, 275-284, 300-307, 313-336
apps/web-foldkit/src/shell/channels-sidebar/view.ts 78.72% 61.44% 73.33% 82.35% 99-103, 167, 346-370, 400-410, 473-474, 509-518
apps/web-foldkit/src/ui/menu-view.ts 60% 69.93% 50% 60.48% 56, 81-119, 131-138, 154-175, 182-203, 299, 472, 561-568, 572-601
Generated in workflow #2363 for commit 210f1dd by the Vitest Coverage Report Action

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