Skip to content
15 linesCodeBlameRaw
1/**
2 * How a kept card shows. Pure, so it is tested apart from the service.
3 *
4 * Cards were posted by workspace agents, which g1t no longer has. Old ones
5 * still show; only their links can be pressed, since the actions they
6 * offered had an agent to answer them.
7 */
8import type { MessageCard } from "@g1t/contracts";
9
10/** A kept card as it goes out: its links kept, actions nobody answers any more dropped. */
11export function shownCard(card: MessageCard): MessageCard {
12 const { owner: _owner, ref: _ref, actions, ...rest } = card;
13 const links = (actions ?? []).filter((action) => !!action?.href);
14 return links.length ? { ...rest, actions: links } : rest;
15}