misherate blog

An earlier version of this page, kept as it was (blog commit c022187). Read the current introduction.

Introducing · gmail.misherate.com · created 30 October 2026 (an earlier link-handoff experiment dates from 24 October)

Introducing Gmail: mail links that open on any device

Gmail is a small app for one problem: a link to a mail message that works wherever it is tapped. When the assistant mentions a mail in a chat, it links to it, and its instructions say to use this app's address instead of mail.google.com, keeping the path, query and hash exactly as Gmail writes them. The app's paths mimic Gmail's own, so the same link is a valid Gmail link with only the host changed.

It is for Misha, who reads the assistant's messages on a phone and sometimes on a laptop. The page itself is public and holds no mail; everything that reads mail is members only.

How it behaves

A link looks like any Gmail link, with the host swapped: a thread by Gmail's token after #inbox/, a search after #search/, a label after #label/, or the older query-string forms with th= or permmsgid=.

The phone view has one row of chrome, which scrolls away: a search box (return searches) and one button. The button exists because the iOS Gmail app has no working deep link to a message. So it copies a search that finds the message (or the list's query) and opens the Gmail app, ready to be pasted into its search.

The app only reads. Nothing is marked read, labelled or changed.

Where it came from

It started on 24 October as a page on the apex domain that handed links to the iOS Gmail app, with message ids kept in the URL's fragment. That experiment is still there. On 30 October it became its own host, with the desktop redirect and the phone view.

The same day it changed shape twice. A version that put the whole host behind sign-in was walked back the same day: a desktop only redirects, so it never needs to sign in here, and a phone should be sent to sign-in rather than shown a signed-out page. The final split is a public page with no data and members-only data paths on the server. Later that day attachments were reworked: they had been looked up by ids that the mail API changes between fetches, and PDFs had been served under a CSP sandbox that Chrome refuses to display.

On 6 November it learned to read a second mailbox. A link names its mailbox by address the way Gmail allows, in the path or as ?authuser=, and only that mailbox is read; an address not on the app's list is refused. A plain numeric index such as /mail/u/1/ is only the order of a browser's signed-in accounts, so it names no mailbox: a thread is looked for in the first mailbox, then the second.

The token inside a Gmail link

The newer Gmail links carry tokens like FMfcg…, which the mail API doesn't accept. They turn out to be base64 rewritten in an alphabet of 40 consonants, and the base64 decodes to something like thread-f: plus the decimal form of the API's hex id. Decoding is a change of base:

const span = (a: string, b: string) =>
  Array.from({ length: b.charCodeAt(0) - a.charCodeAt(0) + 1 }, (_, i) => String.fromCharCode(a.charCodeAt(0) + i)).join("");
const LETTERS = span("A", "Z") + span("a", "z");
const BASE64 = LETTERS + span("0", "9") + "+/";
const CONSONANTS = LETTERS.replace(/[AEIOUYaeiouy]/g, ""); // the 40 letters Gmail uses

function convert(text: string, from: string, to: string): string {
  let n = 0n;
  for (const c of text) n = n * BigInt(from.length) + BigInt(from.indexOf(c));
  let out = "";
  for (; n > 0n; n /= BigInt(to.length)) out = to[Number(n % BigInt(to.length))] + out;
  return out;
}

// "FMfcg…" -> "thread-f:1880…" -> the API's hex id
const decoded = atob(convert(token, CONSONANTS, BASE64));

Tokens for threads Gmail made on the sender's side (thread-a:) have no API id at all, and the app says so rather than guessing.

Related

The assistant's mail handling has its own posts: how the hourly check does the looking in code and wakes an agent only when there is something to read, and how a single drafting rule was corrected five times in one evening.

Revision 1, 13 November 2026. The first version. All introductions.

One email per new post, at most two a day. Unsubscribe any time. Your address is kept privately and never shown.