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 a2b8f764db
commit 8c84feaa91
114 changed files with 12987 additions and 379 deletions
+26 -11
View File
@@ -2,7 +2,7 @@
import { EventEmitter } from 'node:events'
import type { MessageDb, NewMessage } from './db'
import { parseVoipDate, type RawSms, type VoipMs } from './voipms'
import { normalizeNumber } from '@shared/phone'
import { charCount, normalizeNumber, SMS_TEXT_LIMIT } from '@shared/phone'
import type { SyncStatus } from '@shared/types'
const WINDOW_DAYS = 90
@@ -19,7 +19,7 @@ function parseYmd(s: string): number {
}
export function toNewMessage(r: RawSms): NewMessage {
return {
const m: NewMessage = {
id: Number(r.id),
did: normalizeNumber(r.did),
contact: normalizeNumber(r.contact),
@@ -27,12 +27,23 @@ export function toNewMessage(r: RawSms): NewMessage {
body: r.message ?? '',
ts: parseVoipDate(r.date)
}
// With all_messages=1 every row carries the media columns, SMS included, so
// only rows that actually have media count as MMS -- or text too long for
// one SMS, which voip.ms carries as a text-only MMS.
const urls = (r.media?.length ? r.media : [r.col_media1, r.col_media2, r.col_media3]).filter((u): u is string => !!u)
if (urls.length) {
m.kind = 'mms'
m.media = urls.map((url) => ({ url }))
} else if (charCount(m.body) > SMS_TEXT_LIMIT) {
m.kind = 'mms'
}
return m
}
// Fetch every message in [from, to] (inclusive days), halving the range if a
// single call comes back full so nothing gets truncated.
export async function fetchRange(api: Pick<VoipMs, 'getSms'>, from: number, to: number, limit = PAGE_LIMIT): Promise<RawSms[]> {
const rows = await api.getSms({ from: ymd(from), to: ymd(to), limit })
export async function fetchRange(api: Pick<VoipMs, 'getMessages'>, from: number, to: number, limit = PAGE_LIMIT): Promise<RawSms[]> {
const rows = await api.getMessages({ from: ymd(from), to: ymd(to), limit })
if (rows.length < limit || to - from < DAY) return rows
const mid = from + Math.floor((to - from) / DAY / 2) * DAY
const a = await fetchRange(api, from, mid, limit)
@@ -51,7 +62,7 @@ export class SyncEngine extends EventEmitter {
private burstUntil = 0
private running = false
private backfilling = false
private polling = false
private polling?: Promise<void>
private status: SyncStatus
constructor(
@@ -81,6 +92,7 @@ export class SyncEngine extends EventEmitter {
const wanted = new Set(this.opts.dids.map(normalizeNumber))
const msgs = raw.map(toNewMessage).filter((m) => wanted.size === 0 || wanted.has(m.did))
const added = this.db.upsertMessages(msgs)
this.db.reconcileSent(added)
if (added.length) this.emit('messages', added)
}
@@ -112,22 +124,25 @@ export class SyncEngine extends EventEmitter {
}, d)
}
// Manual refresh. Joins a check that's already under way rather than
// returning early, so the caller knows when fresh results are in.
async pollNow(): Promise<void> {
await this.poll()
}
private async poll(): Promise<void> {
if (this.polling) return
this.polling = true
private poll(): Promise<void> {
this.polling ??= this.fetchRecent().finally(() => (this.polling = undefined))
return this.polling
}
private async fetchRecent(): Promise<void> {
try {
const now = Date.now()
const rows = await this.api.getSms({ from: ymd(now - DAY), to: ymd(now + DAY), limit: PAGE_LIMIT })
const rows = await this.api.getMessages({ from: ymd(now - DAY), to: ymd(now + DAY), limit: PAGE_LIMIT })
this.store(rows)
this.setStatus({ lastPoll: Date.now(), error: undefined, phase: this.backfilling ? 'backfill' : 'polling' })
} catch (e) {
this.setStatus({ phase: 'error', error: (e as Error).message })
} finally {
this.polling = false
}
}