v0.2.0: bubble for Android 0.2.0 — chat search, swipe for unread, faster chat opening

Desktop:
- Search lists chats whose own name matches first, so a named group
  isn't pushed out of the top 8 by chats that merely include a member.

Android (Rabbit R1) app, 0.2.0:
- Pull the chat list past its top for a search box (name, person,
  number, then group members; archived chats too; Back clears it).
- Swipe right to left marks a chat unread / read over a magenta band;
  left to right still archives (SwipeActions replaces SwipeArchive).
- Google Voice chats don't offer voice notes in the paperclip bubble.
- Chats open with their newest 60 messages, then the full history;
  marking read (and the Google Voice network call) waits until they're
  on screen. Cached pictures show at once, and one slow download no
  longer blocks the other images. Fixed a contacts reload race.
- Sandbox data gains filler chats, a named group and a 4,000-message chat.

Also: the Android app, Google Voice support, media, export, emoji and
the other work since the first commit, and a CLAUDE.md carrying the
privacy rule.
This commit is contained in:
2026-11-06 02:19:56 -08:00
parent 241a44f0ee
commit cde8cc6c55
116 changed files with 13014 additions and 379 deletions
+121
View File
@@ -0,0 +1,121 @@
// Message signing ("WAA" / BotGuard). Google Voice's web client attaches a
// signature, computed by an obfuscated script Google serves, to every text it
// sends; sends without one work but get rate-limited sooner. Like
// mautrix-gvoice's electron.mjs, we run Google's script in a hidden window,
// locked down so it can't load anything else, and ask it for signatures.
//
// Everything here is best-effort: on any failure the send goes out unsigned.
import { BrowserWindow, session } from 'electron'
import crypto from 'node:crypto'
import { USER_AGENT, type GVoice } from './client'
const EXPIRY = 60 * 60_000
const TIMEOUT = 10_000
const ABOUT_URLS = new Set(['https://voice.google.com/', 'https://voice.google.com/about', 'https://voice.google.com/u/0/about'])
// Runs inside the hidden page.
const LOAD_SCRIPT = (src: string): Promise<void> =>
new Promise((resolve, reject) => {
const s = document.createElement('script')
s.src = src
s.onload = () => resolve()
s.onerror = () => reject(new Error('script failed to load'))
document.head.appendChild(s)
})
type Payload = { message_ids: string; destinations: string; thread_id: string } | undefined
const RUN_PROGRAM = (globalName: string, program: string, payload: Payload): Promise<string> =>
new Promise((resolve, reject) => {
const vm = (window as unknown as Record<string, { a: (...args: unknown[]) => void }>)[globalName]
if (!vm) return reject(new Error('signer not loaded'))
vm.a(
program,
(fn1: (cb: (r: string) => void, args: unknown[]) => void) => fn1((r) => resolve(r), [payload, undefined, undefined, undefined]),
true,
undefined,
() => undefined
)
})
const b64sha256 = (s: string): string => crypto.createHash('sha256').update(s).digest('base64')
const withTimeout = <T>(p: Promise<T>, ms: number): Promise<T> =>
Promise.race([p, new Promise<T>((_, reject) => setTimeout(() => reject(new Error('timed out')), ms))])
export class WaaSigner {
private win?: BrowserWindow
private ready?: Promise<void>
private initedAt = 0
private program = ''
private globalName = ''
private scriptUrl = ''
constructor(private gv: GVoice) {}
private async open(): Promise<BrowserWindow> {
if (this.win && !this.win.isDestroyed()) return this.win
const ses = session.fromPartition('gvoice-waa') // in-memory, no Google cookies
ses.webRequest.onBeforeRequest((d, cb) => cb({ cancel: !(ABOUT_URLS.has(d.url) || d.url === this.scriptUrl) }))
ses.webRequest.onHeadersReceived((d, cb) => {
const headers = { ...d.responseHeaders }
for (const k of Object.keys(headers)) if (k.toLowerCase() === 'content-security-policy') delete headers[k]
cb({ responseHeaders: headers })
})
const win = new BrowserWindow({
show: false,
webPreferences: { session: ses, sandbox: true, contextIsolation: true, nodeIntegration: false }
})
await win.loadURL('https://voice.google.com/about', { userAgent: USER_AGENT })
this.win = win
return win
}
private init(): Promise<void> {
this.ready = (async () => {
const waa = await this.gv.createWaa()
const win = await this.open()
this.program = waa.program
this.globalName = waa.globalName
const url = waa.interpreterUrl.startsWith('//') ? 'https:' + waa.interpreterUrl : waa.interpreterUrl
if (url !== this.scriptUrl) {
this.scriptUrl = url
await win.webContents.executeJavaScript(`(${LOAD_SCRIPT.toString()})(${JSON.stringify(url)})`)
}
this.initedAt = Date.now()
// The web client checks in once with an empty payload.
void this.run(undefined)
.then((sig) => this.gv.pingWaa(sig))
.catch(() => undefined)
})()
this.ready.catch(() => (this.ready = undefined))
return this.ready
}
private async run(payload: Payload): Promise<string> {
const js = `(${RUN_PROGRAM.toString()})(${JSON.stringify(this.globalName)}, ${JSON.stringify(this.program)}, ${JSON.stringify(payload)})`
return withTimeout(this.win!.webContents.executeJavaScript(js) as Promise<string>, TIMEOUT)
}
// Signature for a send, or undefined if one couldn't be had.
async sign(threadId: string, recipients: string[], transactionId: number): Promise<string | undefined> {
try {
if (!this.ready || Date.now() - this.initedAt > EXPIRY) await this.init()
else await this.ready
const sig = await this.run({
message_ids: b64sha256(String(transactionId)),
destinations: b64sha256(recipients.join('|')),
thread_id: b64sha256(threadId)
})
return sig || undefined
} catch (e) {
console.warn('[gvoice] signing failed, sending unsigned:', (e as Error).message)
return undefined
}
}
close(): void {
if (this.win && !this.win.isDestroyed()) this.win.destroy()
this.win = undefined
this.ready = undefined
}
}