sync-event toasts, image pull ordering, stale banner field diff
- replace chat-bot sync notifications with a dedicated relay_sync_events queue: POST/GET /api/sync-events, drained by /api/relay/poll and surfaced as stacking toasts via caldav.js. Old /api/chat/bot removed, bot=1 rows purged on bootstrap, orange bot rendering dropped from relay UI. Chat thread stays clean. - collab pull: fetch attachments BEFORE applying the body so the moment state.cards reflects the new reference the file is on disk. Fixes the "preview shows broken/missing image, editor shows it" race where the browser cached the 404 between attachment landing and user re-render. - detail stale banner now compares title/body/color/tags in addition to updated_at — robust against second-granularity timestamp collisions and any other case where updated_at doesn't tick but content differs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
26f95ba079
commit
1966f8f4c0
10 files changed
+170
-75
No files matched your search
+26
-5
@@ -189,14 +189,31 @@ $chatColNames = array_column($chatCols, 'name');
|
||||
if (!in_array('seen', $chatColNames)) {
|
||||
$db->exec('ALTER TABLE chat_messages ADD COLUMN seen INTEGER NOT NULL DEFAULT 0');
|
||||
}
|
||||
// Bot notifications: automated sync confirmations ("alice synced: My Card").
|
||||
// `bot` column = 1 means the UI renders it as a system notification in the
|
||||
// orange accent color instead of a regular chat bubble.
|
||||
if (!in_array('bot', $chatColNames)) {
|
||||
$db->exec('ALTER TABLE chat_messages ADD COLUMN bot INTEGER NOT NULL DEFAULT 0');
|
||||
// Sync-notification cleanup: the bot=1 chat messages turned out to clutter
|
||||
// the chat thread. The feature moved to its own `relay_sync_events` queue
|
||||
// (see below). Drop any leftover bot rows so they stop showing up in
|
||||
// users' threads. The `bot` column stays on disk (SQLite ALTER DROP needs
|
||||
// a full table rebuild — not worth it for an ignored nullable column).
|
||||
if (in_array('bot', $chatColNames)) {
|
||||
$db->exec('DELETE FROM chat_messages WHERE bot = 1');
|
||||
}
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS idx_chat_sender_state ON chat_messages(sender_id, id)');
|
||||
|
||||
// Sync-event notifications: replaces the old bot-chat mechanism. When a
|
||||
// client syncs a card they received, they POST here; the sender polls
|
||||
// GET /api/sync-events and surfaces each as a transient toast. Rows are
|
||||
// short-lived — we drop fetched ones after an hour, unfetched after a day.
|
||||
$db->exec('CREATE TABLE IF NOT EXISTS relay_sync_events (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
recipient_id INTEGER NOT NULL,
|
||||
sender_username TEXT NOT NULL,
|
||||
body TEXT NOT NULL,
|
||||
fetched INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (recipient_id) REFERENCES tenants(id) ON DELETE CASCADE
|
||||
)');
|
||||
$db->exec('CREATE INDEX IF NOT EXISTS idx_sync_events_recipient ON relay_sync_events(recipient_id, id)');
|
||||
|
||||
// Collaborative buckets: shared among multiple tenants. Each bucket has one
|
||||
// owner and a membership set. Buckets persist (not ephemeral) since they are
|
||||
// the container for ongoing collaboration — cleanup only when deleted.
|
||||
@@ -300,6 +317,10 @@ $db->exec("DELETE FROM messages WHERE created_at < datetime('now', '-24 hours')"
|
||||
$db->exec("DELETE FROM attachments WHERE created_at < datetime('now', '-24 hours')");
|
||||
// Chat: 7 days, longer than card sync but still ephemeral
|
||||
$db->exec("DELETE FROM chat_messages WHERE created_at < datetime('now', '-7 days')");
|
||||
// Sync events are transient toasts — drop fetched ones after an hour,
|
||||
// everything after 24h regardless (sender was offline too long to care).
|
||||
$db->exec("DELETE FROM relay_sync_events WHERE fetched = 1 AND created_at < datetime('now', '-1 hour')");
|
||||
$db->exec("DELETE FROM relay_sync_events WHERE created_at < datetime('now', '-24 hours')");
|
||||
// Collab-card tombstones: 7 days so late pollers still see the delete.
|
||||
$db->exec("DELETE FROM collab_cards WHERE deleted = 1 AND updated_at < datetime('now', '-7 days')");
|
||||
// Collab-card locks: drop everything past its TTL on every request.
|
||||
|
||||
Reference in new issue
Block a user