Skip to content

Open mousse:// links on the phone: chips in messages, in-app navigation, links from outside the app - #50

Merged
TheAnimatrix merged 1 commit into
mainfrom
phone-links
Dec 1, 2026
Merged

TheAnimatrix merged 1 commit into
mainfrom
phone-links

Conversation

@TheAnimatrix

@TheAnimatrix TheAnimatrix commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

On 0.1.3, a mousse://thread/… link in a reply was a few coloured words that did nothing when tapped (checked on real data, this PC's Mousse paired with an emulator running a release-path build). A bare mousse://thread/<id> was plain text. A link opened from outside the app only handled mousse://pair. The cause: the Markdown readers only made http(s) links tappable, and the link code from #32 only ran on the bot panel's rows and the demo's sample data.

This PR makes every mousse:// link a place in the app.

One grammar in the core (core/src/links.rs, tests in links_tests.rs). It covers all of desktop's forms: mousse://thread/<id>, mousse://thread/<node>:<id>, mousse://bot/<id> (mentions, [@Name](mousse://bot/…)), mousse://bot/<id>/message/<id>, mousse://pair…#<ticket>, and anything else under mousse:// (for example mousse://net/join?…). It reads Markdown links, <…> and bare addresses, and skips code. Ids, node ids, length and characters are checked strictly. Reading a link never does anything but name a place. docs/phone-links.md lists desktop's grammar with file references.

Lookup by id (core/src/thread_peek.rs). A linked thread the home doesn't list (a hidden one, a subagent, an archived one) is fetched with routed.thread.snapshot without the transcript, from the computer the link names, or from every paired computer. It is asked one at a time and retried on Busy (desktop limits a device's parallel snapshots). Answers are kept for 20 seconds, 128 at most. Desktop's thread_not_found (from OwnerRoutes) reads as "can't open here", not as a failure.

One link component per platform. Android draws a chip in the line of text (android/ui/…/LinkChip.kt). iOS draws chips under the message, because SwiftUI text can't hold a button (ios/MousseUI/…/LinkChip.swift). A thread chip shows the thread's title and its live state (Working, Needs you, Paused, Archived). A thread the phone can't open says why: Can't open here, Other computer, or Offline. The chips are a full line tall. A long press offers Open, Copy link and Share.

Opening (MessageLinks.kt / MessageLinks.swift). A thread opens over the screen it was tapped on, and Back returns there. A bot link opens that bot's chat, and a pairing link opens pairing. Any link the phone can't open shows a short note with the address and Copy link, and never reaches the browser.

From outside the app. Android's intent filter takes mousse://thread, mousse://bot and mousse://pair, and iOS already registers mousse. The core checks the address first. A pairing link opens pairing. A thread or bot link waits until the home is up (it also works from a cold start), and while a computer is still connecting the lookup waits up to 6 seconds.

Needs desktop changes (written up in docs/phone-links.md, desktop not changed here):

  1. Bots' own threads and private threads are refused to every device as thread_not_found (OwnerRoutes.sharedThread). A bot-level read route and distinct refusal codes are needed.
  2. Threads on a computer the phone isn't paired with: no route relays a thread read to the person's other computers.
  3. No phone-facing reply gives a computer's own node id (net.info), so a nod_…:<id> link is resolved by asking every paired computer for the id.

Coordinates with M20 (message rows) and M25 (composer). The change stays in the link parser, the link component and navigation. Markdown files gain only the call sites.

Checks

  • CI: Rust (fmt, clippy, tests incl. links_tests.rs for every form and malformed ids/node ids/lengths/characters), Android (build + MarkdownParserTest), iOS (build + check-markdown.swift): green.
  • Real data: this PC's Mousse paired with an emulator on a release-path build. A thread with each link kind (same computer, hidden, subagent, another computer, a bot's own run, a bot helper, bare address, bot mention, address in code). Before (0.1.3) and after below. Tapped each: same-computer, hidden and subagent threads open and Back returns to the chat; the other-computer, bot-run and bot-helper links say why they can't open; the bot mention says the bot isn't shared with this phone; the code stays text.
  • Outside the app (adb shell am start -a VIEW -d mousse://…), warm and cold start: a thread link opens that thread once the home is up; a pairing link opens pairing.
  • Demo screen walk: link fixtures added to the demo world and the component gallery.
  • Not tested: a real phone, iOS on a device (iOS checked only by CI build).

Review

One independent review found 14 issues; 12 are fixed in the last commit:

  • iOS: a link from outside while the app was open did nothing and the next one opened the old link ($pending sends before it stores). It now uses the value it receives.
  • A computer that couldn't be asked (offline, connecting) is no longer kept as the answer; it is asked again on the next look. Chips ask again after 20 s (3 s after a failure). Both platforms keep at most 128 lookups, and a block of text shows at most 8 chips.
  • Lookups take turns per computer (two at a time), so one slow computer doesn't hold up the others.
  • Android uses an outside link once: reopening from Recents or after the process was killed doesn't open it again. Checked on the emulator.
  • A bare or <…> pairing address is plain text on both platforms, as in the core.
  • Android: Back from a thread opened by a link inside a bot-panel thread returns to that thread (the panel's stack is saved with the screen).
  • iOS: opening a thread from a link no longer marks it seen, so a link only navigates.
  • Android: a thread that takes a while to look up opens only if the person is still where they tapped, as on iOS.
  • The core's link finder: ) ends an address, ]( without [ isn't a link, an address inside a word isn't one, and an address in a link's own words is its label.
  • A thread that links to itself isn't pushed twice.
  • Outside links wait at most a minute for the home on both platforms, so one that came before pairing isn't opened later.

Left as is: a pairing link from outside replacing a pairing preview already on screen (as before this PR; the person still confirms before anything joins), and iOS putting an outside link's thread in place of the screens already open (iOS's home holds one screen above it).

A re-check of those fixes found three Android navigation edge cases they caused, and one parser mismatch. All four are fixed in the next commit:

  • Each home screen's saved state is kept by its place in the stack, so a thread that is open twice (a link back to it) keeps two separate states.
  • Every screen pushed again, including a link back to the thread underneath. A thread that links to itself now takes an extra Back, as on iOS.
  • Any screen opening or closing, also inside a thread's own stack, stops a slow lookup from opening its thread late.
  • Both Markdown parsers, like the core, don't start an address after _.

@TheAnimatrix
TheAnimatrix marked this pull request as ready for review December 1, 2026 06:08
@TheAnimatrix
TheAnimatrix merged commit e838e49 into main Dec 1, 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