0 ? array_values(array_filter($all, fn($m) => (int)($m['epoch'] ?? 0) > $since)) : $all; $lastAll = $all ? end($all) : null; json_response([ 'success' => true, 'thread' => $thread, 'messages' => array_slice($messages, -50), // `awaiting` replaces `unread`: the server keeps no read state, so an unread // counter could never clear. Who spoke last is knowable. 'awaiting' => (bool)($lastAll && ($lastAll['author'] ?? '') !== 'hermes'), 'cursor' => $lastAll ? (int)($lastAll['epoch'] ?? 0) : 0, ]);