v0.9.8: bubble for Android 0.7.8 — a text that doesn't go out is loud: closing mid-send asks first, sends stranded by a quit come back as Not sent, and failures pop up a notification, a red banner and a mark in the chat list

This commit is contained in:
2026-11-20 10:00:02 -08:00
parent 512f481ba3
commit 11037a7770
11 changed files with 302 additions and 28 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "voipms-desktop", "name": "voipms-desktop",
"productName": "bubble", "productName": "bubble",
"version": "0.9.7", "version": "0.9.8",
"description": "Signal-style desktop SMS client for voip.ms", "description": "Signal-style desktop SMS client for voip.ms",
"author": "trav <trav@teafry.me>", "author": "trav <trav@teafry.me>",
"private": true, "private": true,
+17
View File
@@ -5,6 +5,7 @@ import path from 'node:path'
import type { Conversation, Direction, MediaRef, Message, MessageKind, MessageStatus, SearchHit } from '@shared/types' import type { Conversation, Direction, MediaRef, Message, MessageKind, MessageStatus, SearchHit } from '@shared/types'
import { SNIPPET_END, SNIPPET_START } from '@shared/types' import { SNIPPET_END, SNIPPET_START } from '@shared/types'
import { fixVoipDst } from './voipms' import { fixVoipDst } from './voipms'
import { SIM_DID } from '@shared/phone'
const SCHEMA_VERSION = 12 const SCHEMA_VERSION = 12
@@ -265,6 +266,20 @@ export class MessageDb {
this.db.prepare(`UPDATE messages SET status = 'failed', error = ? WHERE id = ?`).run(error ?? null, tempId) this.db.prepare(`UPDATE messages SET status = 'failed', error = ? WHERE id = ?`).run(error ?? null, tempId)
} }
// At startup: sends a previous run left 'pending' (it quit or crashed
// mid-send, and that send's retry loop died with it). Nothing will ever
// finish them, so they become failed: shown as Not sent with Retry, never
// resent on their own (by now they may be stale). If one did go out, the
// next poll still replaces it (reconcileSent matches failed rows too).
// Over the Rabbit's SIM they stay pending: those wait in relay_outbox.
failOrphanedSends(error: string): Message[] {
const rows = this.db
.prepare(`SELECT id FROM messages WHERE id < 0 AND status = 'pending' AND direction = 'out' AND did != ?`)
.all(SIM_DID) as { id: number }[]
for (const { id } of rows) this.markFailed(id, error)
return rows.map(({ id }) => this.getMessage(id)!).filter(Boolean)
}
// Sent messages that turned up in a poll take the place of our local // Sent messages that turned up in a poll take the place of our local
// pending/failed copies (same text, sent around the same time). A send whose // pending/failed copies (same text, sent around the same time). A send whose
// reply never came back may still have gone out; this is how we find out. // reply never came back may still have gone out; this is how we find out.
@@ -337,6 +352,8 @@ export class MessageDb {
json_extract(last.media_json, '$[0]') AS lastMedia, json_extract(last.media_json, '$[0]') AS lastMedia,
(SELECT COUNT(*) FROM messages m WHERE m.did = l.did AND m.contact = l.contact AND m.direction = 'in' (SELECT COUNT(*) FROM messages m WHERE m.did = l.did AND m.contact = l.contact AND m.direction = 'in'
AND m.ts > MAX(COALESCE(r.last_read_ts, 0), @floor)) AS unread, AND m.ts > MAX(COALESCE(r.last_read_ts, 0), @floor)) AS unread,
(SELECT COUNT(*) FROM messages m WHERE m.did = l.did AND m.contact = l.contact AND m.id < 0
AND m.status = 'failed') AS failed,
r.archived_at IS NOT NULL AS archived, r.archived_at IS NOT NULL AS archived,
COALESCE(r.marked_unread, 0) AS markedUnread, COALESCE(r.marked_unread, 0) AS markedUnread,
r.name AS name r.name AS name
+50 -1
View File
@@ -26,7 +26,7 @@ import { SendMediaType } from './gvoice/schema'
import { clearGvSession, exportCookies, gvTransport, hasGvSession, importCookies, parseCookies, signInWindow } from './gvoice/session' import { clearGvSession, exportCookies, gvTransport, hasGvSession, importCookies, parseCookies, signInWindow } from './gvoice/session'
import { gvMessageId, GvSyncEngine } from './gvoice/sync' import { gvMessageId, GvSyncEngine } from './gvoice/sync'
import { WaaSigner } from './gvoice/waa' import { WaaSigner } from './gvoice/waa'
import { clearNotifications, closeAllNotifications, notifyNew, sweepNotifications } from './notify' import { clearNotifications, closeAllNotifications, notifyNew, notifyUnsent, sweepNotifications } from './notify'
import * as rabbit from './rabbit' import * as rabbit from './rabbit'
import { checkUrl, clearRelayConfig, loadRelayConfig, newKey, RelayEngine, saveRelayConfig, SIM_DID } from './relay' import { checkUrl, clearRelayConfig, loadRelayConfig, newKey, RelayEngine, saveRelayConfig, SIM_DID } from './relay'
@@ -138,6 +138,7 @@ function startRelay(): void {
relay.on('messages', onNewMessages) relay.on('messages', onNewMessages)
relay.on('changed', readStateChanged) relay.on('changed', readStateChanged)
relay.on('status', () => send('relayStatus', relay?.status())) relay.on('status', () => send('relayStatus', relay?.status()))
relay.on('unsent', (m: Message) => alertUnsent([m]))
relay.start() relay.start()
} }
@@ -421,6 +422,7 @@ function enqueue<T>(key: string, job: () => Promise<T>): Promise<T> {
async function deliver(m: Omit<NewMessage, 'id'>, attempt: () => Promise<number>): Promise<void> { async function deliver(m: Omit<NewMessage, 'id'>, attempt: () => Promise<number>): Promise<void> {
const engine = providerOf(m.did) === 'gvoice' ? gvSync : sync const engine = providerOf(m.did) === 'gvoice' ? gvSync : sync
const tempId = db.insertPending(m) const tempId = db.insertPending(m)
sending.add(tempId)
send('conversationsChanged') send('conversationsChanged')
try { try {
await enqueue(`${m.did}:${m.contact}`, () => await enqueue(`${m.did}:${m.contact}`, () =>
@@ -432,11 +434,49 @@ async function deliver(m: Omit<NewMessage, 'id'>, attempt: () => Promise<number>
}) })
) )
} finally { } finally {
sending.delete(tempId)
const after = db.getMessage(tempId)
if (after?.status === 'failed') alertUnsent([after])
send('conversationsChanged') send('conversationsChanged')
engine?.burst() engine?.burst()
} }
} }
// voip.ms / Google Voice sends still being worked on (their retry loops live
// only in this process, so quitting now strands them).
const sending = new Set<number>()
// Always, whatever the notification setting, and even with the window focused:
// a text that didn't go out has to be impossible to miss.
function alertUnsent(msgs: Message[]): void {
if (!msgs.length) return
notifyUnsent(msgs, { db, contacts, onClick: openFromNotification })
if (win && !win.isDestroyed()) win.flashFrame(true)
}
// Closing or quitting with a text still on its way: ask first. Returns
// whether to go ahead.
let leaveAnyway = false
function okToLeave(): boolean {
if (leaveAnyway || !sending.size) return true
const n = sending.size
const opts: Electron.MessageBoxSyncOptions = {
type: 'warning',
title: 'Still sending',
message: n > 1 ? `${n} texts are still sending` : 'A text is still sending',
detail:
"If bubble closes now it can't finish, and it will most likely not go out. " +
'It will show as Not sent next time, with a Retry button.',
buttons: ['Keep bubble open', 'Quit anyway'],
defaultId: 0,
cancelId: 0
}
const choice = win && !win.isDestroyed() ? dialog.showMessageBoxSync(win, opts) : dialog.showMessageBoxSync(opts)
if (choice !== 1) return false
leaveAnyway = true
return true
}
const voipAttempt = (call: (api: VoipMs) => Promise<number>) => (): Promise<number> => { const voipAttempt = (call: (api: VoipMs) => Promise<number>) => (): Promise<number> => {
if (!api) throw new VoipMsError('not_signed_in') if (!api) throw new VoipMsError('not_signed_in')
return call(api) return call(api)
@@ -789,6 +829,10 @@ function createWindow(): void {
// from firing, leaving a windowless process holding the single-instance lock. // from firing, leaving a windowless process holding the single-instance lock.
for (const ev of ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'resize', 'focus', 'blur'] as const) for (const ev of ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'resize', 'focus', 'blur'] as const)
win.on(ev as 'resize', sendWindowState) win.on(ev as 'resize', sendWindowState)
win.on('close', (e) => {
if (!okToLeave()) e.preventDefault()
})
win.on('focus', () => win?.flashFrame(false))
win.on('closed', () => { win.on('closed', () => {
win = undefined win = undefined
app.quit() app.quit()
@@ -808,6 +852,7 @@ app.whenReady().then(async () => {
moveToBubbleData() moveToBubbleData()
settings = loadSettings() settings = loadSettings()
db = new MessageDb(path.join(getDataDir(), 'messages.db')) db = new MessageDb(path.join(getDataDir(), 'messages.db'))
const orphans = db.failOrphanedSends("bubble closed before this finished sending, so it most likely didn't go out.")
if (SANDBOX) seedDemo(db) if (SANDBOX) seedDemo(db)
dids = JSON.parse(db.get('dids') ?? '[]') as Did[] dids = JSON.parse(db.get('dids') ?? '[]') as Did[]
media = new MediaStore(path.join(getDataDir(), 'media'), db, (url, at) => { media = new MediaStore(path.join(getDataDir(), 'media'), db, (url, at) => {
@@ -836,6 +881,9 @@ app.whenReady().then(async () => {
if (gvNumber() && (await hasGvSession())) startGvSync() if (gvNumber() && (await hasGvSession())) startGvSync()
startRelay() startRelay()
// Once contacts can name the chat.
if (orphans.length) setTimeout(() => alertUnsent(orphans), 3000)
void dailySnapshot() void dailySnapshot()
setInterval(() => void dailySnapshot(), 60 * 60 * 1000) setInterval(() => void dailySnapshot(), 60 * 60 * 1000)
}) })
@@ -844,6 +892,7 @@ let quitting = false
app.on('before-quit', (e) => { app.on('before-quit', (e) => {
if (quitting || !db) return if (quitting || !db) return
e.preventDefault() e.preventDefault()
if (!okToLeave()) return
quitting = true quitting = true
closeAllNotifications() closeAllNotifications()
sync?.stop() sync?.stop()
+31 -1
View File
@@ -4,6 +4,7 @@ import { Notification } from 'electron'
import { formatNumber, groupMembers, isGroup } from '@shared/phone' import { formatNumber, groupMembers, isGroup } from '@shared/phone'
import type { ContactDirectory } from './contacts' import type { ContactDirectory } from './contacts'
import type { MessageDb, NewMessage } from './db' import type { MessageDb, NewMessage } from './db'
import type { Message } from '@shared/types'
import { reactionPreview } from '@shared/reactions' import { reactionPreview } from '@shared/reactions'
import { editPreview } from '@shared/edits' import { editPreview } from '@shared/edits'
@@ -21,6 +22,9 @@ export interface NotifyDeps {
// reading the conversation in the app can take them back out of the list. // reading the conversation in the app can take them back out of the list.
const live = new Map<string, Set<Notification>>() const live = new Map<string, Set<Notification>>()
// "Not sent" alerts, kept referenced for their click handlers.
const unsent = new Set<Notification>()
const convKey = (did: string, contact: string): string => `${did}\n${contact}` const convKey = (did: string, contact: string): string => `${did}\n${contact}`
// The conversation's been read: its notifications are stale. // The conversation's been read: its notifications are stale.
@@ -45,6 +49,8 @@ export function sweepNotifications(isUnread: (did: string, contact: string) => b
export function closeAllNotifications(): void { export function closeAllNotifications(): void {
for (const shown of live.values()) for (const n of shown) n.close() for (const shown of live.values()) for (const n of shown) n.close()
live.clear() live.clear()
for (const n of unsent) n.close()
unsent.clear()
} }
const nameOf = (contacts: ContactDirectory, n: string): string => contacts.lookup(n)?.name ?? formatNumber(n) const nameOf = (contacts: ContactDirectory, n: string): string => contacts.lookup(n)?.name ?? formatNumber(n)
@@ -58,7 +64,7 @@ export function conversationTitle(db: MessageDb, contacts: ContactDirectory, did
.join(', ') .join(', ')
} }
function preview(m: NewMessage): string { function preview(m: Pick<NewMessage, 'body' | 'media'>): string {
const reaction = reactionPreview(m.body) const reaction = reactionPreview(m.body)
if (reaction) return reaction if (reaction) return reaction
const edit = editPreview(m.body) const edit = editPreview(m.body)
@@ -98,3 +104,27 @@ export function notifyNew(msgs: NewMessage[], { db, contacts, onClick }: NotifyD
n.show() n.show()
} }
} }
// Your text didn't go out. Unlike new messages this pops up (normal urgency)
// and stays until clicked or dismissed: a send that fails quietly is the
// worst thing a phone can do.
export function notifyUnsent(msgs: Message[], { db, contacts, onClick }: NotifyDeps): void {
if (!Notification.isSupported()) return
const byConv = new Map<string, Message[]>()
for (const m of msgs) byConv.set(convKey(m.did, m.contact), [...(byConv.get(convKey(m.did, m.contact)) ?? []), m])
for (const list of byConv.values()) {
const { did, contact } = list[0]
const who = conversationTitle(db, contacts, did, contact)
const n = new Notification({
title: list.length > 1 ? `${list.length} texts to ${who} weren't sent` : `Text to ${who} wasn't sent`,
body: list.length > 1 ? 'Open the chat to retry or delete them.' : `“${preview(list[0]) || 'Your message'}” · ${list[0].error ?? 'Open the chat to retry it.'}`,
urgency: 'critical'
})
// Kept referenced like the others so the click survives; not filed under
// `live`, so reading the chat doesn't take it back down.
unsent.add(n)
n.on('click', () => onClick({ did, contact }))
n.on('close', () => unsent.delete(n))
n.show()
}
}
+5 -1
View File
@@ -297,7 +297,11 @@ export class RelayEngine extends EventEmitter {
if (temp === undefined || temp === null) return if (temp === undefined || temp === null) return
const tempId = Number(temp) const tempId = Number(temp)
if (isInt(p.msgId)) this.db.confirmPending(tempId, p.msgId) if (isInt(p.msgId)) this.db.confirmPending(tempId, p.msgId)
else this.db.markFailed(tempId, typeof p.error === 'string' ? `Rabbit: ${p.error}` : "The Rabbit couldn't send it.") else {
this.db.markFailed(tempId, typeof p.error === 'string' ? `Rabbit: ${p.error}` : "The Rabbit couldn't send it.")
const m = this.db.getMessage(tempId)
if (m) this.emit('unsent', m)
}
this.db.db.prepare('DELETE FROM kv WHERE key = ?').run(key) this.db.db.prepare('DELETE FROM kv WHERE key = ?').run(key)
this.emit('changed', 'sent') this.emit('changed', 'sent')
} }
+13 -1
View File
@@ -6,7 +6,7 @@ import type { ConvKey, Jump } from '../App'
import { chatsWith, convName, dayLabel, sameDay, senderName, senderShortName } from '../format' import { chatsWith, convName, dayLabel, sameDay, senderName, senderShortName } from '../format'
import { Avatar } from './Avatar' import { Avatar } from './Avatar'
import { Composer, type ComposerHandle } from './Composer' import { Composer, type ComposerHandle } from './Composer'
import { CloseIcon, DownIcon, SearchIcon, UpIcon } from './Icons' import { AlertIcon, CloseIcon, DownIcon, SearchIcon, UpIcon } from './Icons'
import { conversationMedia, Lightbox } from './Lightbox' import { conversationMedia, Lightbox } from './Lightbox'
import { MessageBubble } from './MessageBubble' import { MessageBubble } from './MessageBubble'
import { DEFAULT_QUICK_REACTIONS, reactionText, sameEmoji, type Reaction } from '@shared/reactions' import { DEFAULT_QUICK_REACTIONS, reactionText, sameEmoji, type Reaction } from '@shared/reactions'
@@ -166,6 +166,8 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
return [{ label: sel ? 'Copy' : 'Copy text', onSelect: () => void navigator.clipboard.writeText(sel || m.body) }] return [{ label: sel ? 'Copy' : 'Copy text', onSelect: () => void navigator.clipboard.writeText(sel || m.body) }]
} }
const unsent = useMemo(() => (messages ?? []).filter((m) => m.status === 'failed'), [messages])
const indexOf = useCallback((id: number) => rows.findIndex((r) => r.kind === 'msg' && r.m.id === id), [rows]) const indexOf = useCallback((id: number) => rows.findIndex((r) => r.kind === 'msg' && r.m.id === id), [rows])
const flash = useCallback((id: number) => { const flash = useCallback((id: number) => {
@@ -402,6 +404,16 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
)} )}
</div> </div>
{unsent.length > 0 && (
<div className="unsent-banner" role="alert">
<AlertIcon />
<span className="unsent-text">
<b>{unsent.length > 1 ? `${unsent.length} of your texts weren't sent.` : "Your text wasn't sent."}</b> Retry or delete{' '}
{unsent.length > 1 ? 'them' : 'it'} below.
</span>
<button onClick={() => scrollTo(unsent[0].id)}>Show</button>
</div>
)}
<Composer ref={composer} conv={conv} isNew={isNew} smsDids={smsDids} gvNumber={gvNumber} onChangeDid={onChangeDid} /> <Composer ref={composer} conv={conv} isNew={isNew} smsDids={smsDids} gvNumber={gvNumber} onChangeDid={onChangeDid} />
{dragging && <div className="drop-hint">Drop to attach</div>} {dragging && <div className="drop-hint">Drop to attach</div>}
{lightbox && ( {lightbox && (
@@ -117,7 +117,15 @@ const ConversationRow = memo(function ConversationRow({
<span className="row-time">{shortTime(conv.lastTs)}</span> <span className="row-time">{shortTime(conv.lastTs)}</span>
</div> </div>
<div className="row-bottom"> <div className="row-bottom">
<span className="row-preview">{preview}</span> <span className="row-preview">
{conv.failed > 0 && <b className="row-unsent">Not sent · </b>}
{preview}
</span>
{conv.failed > 0 && (
<span className="badge unsent" title={conv.failed > 1 ? `${conv.failed} texts weren't sent` : "A text wasn't sent"}>
!
</span>
)}
{conv.unread > 0 ? ( {conv.unread > 0 ? (
<span className="badge">{conv.unread > 99 ? '99+' : conv.unread}</span> <span className="badge">{conv.unread > 99 ? '99+' : conv.unread}</span>
) : ( ) : (
+17 -3
View File
@@ -90,6 +90,9 @@ interface Props {
onMediaLoad: () => void onMediaLoad: () => void
} }
// A send still going after this long gets a visible "Still sending…".
const SLOW_SEND_MS = 15_000
export const MessageBubble = memo(function MessageBubble({ m, sender, onSenderMenu, reactions, onShowReactions, onMenu, versions, onShowEdits, groupStart, groupEnd, flash, highlight, onOpenMedia, onMediaMenu, onMediaLoad }: Props) { export const MessageBubble = memo(function MessageBubble({ m, sender, onSenderMenu, reactions, onShowReactions, onMenu, versions, onShowEdits, groupStart, groupEnd, flash, highlight, onOpenMedia, onMediaMenu, onMediaLoad }: Props) {
const media = m.media ?? [] const media = m.media ?? []
const cls = [ const cls = [
@@ -137,6 +140,11 @@ export const MessageBubble = memo(function MessageBubble({ m, sender, onSenderMe
{m.status === 'pending' && ( {m.status === 'pending' && (
<span className="status" title="Sending…"> <span className="status" title="Sending…">
<ClockIcon /> <ClockIcon />
{/* Appears once a send has taken a while (the negative delay
counts time already spent, so it survives re-renders). */}
<span className="slow-send" style={{ animationDelay: `${SLOW_SEND_MS - (Date.now() - m.ts)}ms` }}>
Still sending…
</span>
</span> </span>
)} )}
</span> </span>
@@ -152,10 +160,16 @@ export const MessageBubble = memo(function MessageBubble({ m, sender, onSenderMe
</button> </button>
)} )}
{m.status === 'failed' && ( {m.status === 'failed' && (
<div className="failed-row"> <div className="failed-row" role="alert">
<AlertIcon /> Not sent{m.error ? `: ${m.error}` : ''} · <span className="failed-why">
<button onClick={() => void window.api.retryFailed(m.id).catch(() => undefined)}>Retry</button>· <AlertIcon /> <b>Not sent.</b> {m.error ?? ''}
</span>
<span className="failed-actions">
<button className="failed-retry" onClick={() => void window.api.retryFailed(m.id).catch(() => undefined)}>
Retry
</button>
<button onClick={() => void window.api.deleteFailed(m.id)}>Delete</button> <button onClick={() => void window.api.deleteFailed(m.id)}>Delete</button>
</span>
</div> </div>
)} )}
</div> </div>
+143 -18
View File
@@ -527,9 +527,6 @@ mark {
.msg.out:not(.g-end) .bubble { .msg.out:not(.g-end) .bubble {
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
} }
.msg.failed .bubble {
opacity: 0.6;
}
.bubble a { .bubble a {
color: inherit; color: inherit;
text-decoration: underline; text-decoration: underline;
@@ -548,21 +545,85 @@ mark {
background: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.9);
color: #1b1b1b; color: #1b1b1b;
} }
/* A text that didn't go out: loud, never a quiet little icon. */
.msg.failed .bubble {
outline: 2px solid var(--danger);
outline-offset: 2px;
}
.failed-row { .failed-row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end;
flex-wrap: wrap; flex-wrap: wrap;
gap: 4px; gap: 6px 10px;
font-size: 12px; max-width: 75%;
margin: 6px 0 4px auto;
padding: 6px 10px;
border-radius: 8px;
background: color-mix(in srgb, var(--danger) 14%, transparent);
color: var(--danger); color: var(--danger);
margin-top: 3px; font-size: 13px;
}
.failed-why {
display: inline-flex;
align-items: center;
gap: 5px;
}
.failed-actions {
display: inline-flex;
gap: 6px;
} }
.failed-row button { .failed-row button {
border: 0; border: 1px solid var(--danger);
border-radius: 6px;
background: none; background: none;
color: var(--danger); color: var(--danger);
text-decoration: underline; font: inherit;
padding: 0 2px; font-weight: 600;
padding: 2px 10px;
}
.failed-row button.failed-retry {
background: var(--danger);
color: #fff;
}
.slow-send {
margin-left: 3px;
opacity: 0;
animation: slow-send 0s forwards;
}
@keyframes slow-send {
to {
opacity: 1;
}
}
.unsent-banner {
flex: none;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
background: var(--danger);
color: #fff;
font-size: 14px;
}
.unsent-banner .unsent-text {
flex: 1;
}
.unsent-banner button {
border: 1px solid #fff;
border-radius: 6px;
background: none;
color: #fff;
font: inherit;
font-weight: 600;
padding: 3px 12px;
}
.badge.unsent {
background: var(--danger);
color: #fff;
}
.row-unsent {
color: var(--danger);
} }
/* ---------- composer ---------- */ /* ---------- composer ---------- */
@@ -2290,9 +2351,6 @@ mark {
.msg.out:not(.g-end) .bubble { .msg.out:not(.g-end) .bubble {
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
} }
.msg.failed .bubble {
opacity: 0.6;
}
.bubble a { .bubble a {
color: inherit; color: inherit;
text-decoration: underline; text-decoration: underline;
@@ -2311,21 +2369,80 @@ mark {
background: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.9);
color: #1b1b1b; color: #1b1b1b;
} }
/* A text that didn't go out: loud, never a quiet little icon. */
.msg.failed .bubble {
outline: 2px solid var(--danger);
outline-offset: 2px;
}
.failed-row { .failed-row {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end;
flex-wrap: wrap; flex-wrap: wrap;
gap: 4px; gap: 6px 10px;
font-size: 12px; max-width: 75%;
margin: 6px 0 4px auto;
padding: 6px 10px;
border-radius: 8px;
background: color-mix(in srgb, var(--danger) 14%, transparent);
color: var(--danger); color: var(--danger);
margin-top: 3px; font-size: 13px;
}
.failed-why {
display: inline-flex;
align-items: center;
gap: 5px;
}
.failed-actions {
display: inline-flex;
gap: 6px;
} }
.failed-row button { .failed-row button {
border: 0; border: 1px solid var(--danger);
border-radius: 6px;
background: none; background: none;
color: var(--danger); color: var(--danger);
text-decoration: underline; font: inherit;
padding: 0 2px; font-weight: 600;
padding: 2px 10px;
}
.failed-row button.failed-retry {
background: var(--danger);
color: #fff;
}
.slow-send {
margin-left: 3px;
opacity: 0;
animation: slow-send 0s forwards;
}
.unsent-banner {
flex: none;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
background: var(--danger);
color: #fff;
font-size: 14px;
}
.unsent-banner .unsent-text {
flex: 1;
}
.unsent-banner button {
border: 1px solid #fff;
border-radius: 6px;
background: none;
color: #fff;
font: inherit;
font-weight: 600;
padding: 3px 12px;
}
.badge.unsent {
background: var(--danger);
color: #fff;
}
.row-unsent {
color: var(--danger);
} }
/* ---------- composer ---------- */ /* ---------- composer ---------- */
@@ -3428,6 +3545,14 @@ select {
background: var(--highlight-text); background: var(--highlight-text);
color: var(--highlight); color: var(--highlight);
} }
.row.active .badge.unsent {
background: var(--danger);
color: #fff;
box-shadow: 0 0 0 1.5px #fff;
}
.row.active .row-unsent {
color: inherit;
}
.sync-footer { .sync-footer {
border-top: 0; border-top: 0;
padding-top: 0; padding-top: 0;
+1
View File
@@ -61,6 +61,7 @@ export interface Conversation {
lastSender?: string // sender of the last message, in group chats lastSender?: string // sender of the last message, in group chats
name?: string // a name you gave the conversation (local only) name?: string // a name you gave the conversation (local only)
unread: number unread: number
failed: number // your texts here that didn't send (shown loudly until retried or deleted)
markedUnread: boolean // manually marked unread (shown as a dot) markedUnread: boolean // manually marked unread (shown as a dot)
archived: boolean archived: boolean
} }
+14
View File
@@ -203,6 +203,20 @@ describe('MessageDb', () => {
expect(db.getMessage(t)?.error).toBe('nope') expect(db.getMessage(t)?.error).toBe('nope')
}) })
it('fails sends a previous run left pending, except over the SIM, and counts them per chat', () => {
const t1 = db.insertPending({ did: '5550001111', contact: 'a', direction: 'out', body: 'stranded', ts: 1000 })
const t2 = db.insertPending({ did: 'sim', contact: 'a', direction: 'out', body: 'waits for the Rabbit', ts: 1001 })
const orphans = db.failOrphanedSends('closed mid-send')
expect(orphans.map((m) => m.id)).toEqual([t1])
expect(db.getMessage(t1)).toMatchObject({ status: 'failed', error: 'closed mid-send' })
expect(db.getMessage(t2)?.status).toBe('pending')
expect(db.listConversations().find((c) => c.did === '5550001111')?.failed).toBe(1)
expect(db.listConversations().find((c) => c.did === 'sim')?.failed).toBe(0)
// Still matched if it turns out it did go out.
expect(db.reconcileSent([{ ...msg(50, 'a', 'stranded', 1000, 'out') }])).toEqual([t1])
expect(db.listConversations().find((c) => c.did === '5550001111')?.failed).toBe(0)
})
describe('reconcileSent', () => { describe('reconcileSent', () => {
const MIN = 60_000 const MIN = 60_000
const pending = (body: string, ts: number): number => db.insertPending({ did: '5550001111', contact: 'a', direction: 'out', body, ts }) const pending = (body: string, ts: number): number => db.insertPending({ did: '5550001111', contact: 'a', direction: 'out', body, ts })