A bot's identity was one of seven hues, and the hue picked both its colour and its stone shape. Now its colour is free and its stone is its own: - `bots.color` holds any `#rrggbb`, `bots.stone` the flat-cut shape it's drawn on. `bots.hue` stays as the palette column they replaced, read only as a fallback; `src/scripts/move-bot-colour-to-owners.ts` backfills an install from it (safe to rerun). - `src/utils/bot-color.ts` is the only place a colour is validated or resolved (`resolveBotColor`/`resolveBotStone` carry the old hue forward, `botColorNeedsPaperFace` flips the eyes to paper on a very dark body), and `src/utils/bot-stone-props.ts` gives every row its props, so a row saved before this still renders as it did. - `BotStone` takes the colour as the body's SVG `fill`, the one documented exception to the token rule: an arbitrary hex has no token to point at. `UnreadDot` follows it. - The picker keeps the palette tiles (still shape and colour together) and adds a native swatch and a hex field, so a custom colour keeps its stone. Same place as before: the header avatar's modal and Settings > Bots, for crew managers. The coordinator stays hue-less. - A recolour reaches other open tabs through `pushBotUpdated`.
53 lines
2.3 KiB
TypeScript
53 lines
2.3 KiB
TypeScript
import BotAvatar from "@/src/components/general/bot-avatar";
|
|
import type { BotFace } from "@/src/dict/bot-dict";
|
|
import botStoneProps from "@/src/utils/bot-stone-props";
|
|
import type { CronJobWithNames } from "@/src/types";
|
|
import SettingsListRow from "@/src/pages/admin/settings/(partials)/settings-list-row";
|
|
import SettingsRowAction from "@/src/pages/admin/settings/(partials)/settings-row-action";
|
|
import routineSubtitle from "../(utils)/routine-subtitle";
|
|
|
|
type Props = {
|
|
cron_job: CronJobWithNames;
|
|
busy?: boolean;
|
|
onToggle: () => void;
|
|
onEdit: () => void;
|
|
onDelete: () => void;
|
|
};
|
|
|
|
/**
|
|
* One routine: its bot's avatar, its name (Paused or Done when it is),
|
|
* whose it is and when it runs, then Chat, Pause or Resume, Edit, Delete.
|
|
*/
|
|
export default function RoutineRow({ cron_job, busy, onToggle, onEdit, onDelete }: Props) {
|
|
const title = cron_job.title || `Routine ${cron_job.id}`;
|
|
const done = Boolean(cron_job.max_runs && Number(cron_job.run_count || 0) >= cron_job.max_runs);
|
|
const chat_url = cron_job.workspace_id
|
|
? `/admin/workspaces/${cron_job.workspace_id}/bots/${cron_job.bot_id}`
|
|
: `/admin/bots/${cron_job.bot_id}`;
|
|
|
|
return (
|
|
<SettingsListRow
|
|
avatar={
|
|
<BotAvatar
|
|
image_media_id={cron_job.bot_image_media_id}
|
|
{...botStoneProps({ color: cron_job.bot_color, stone: cron_job.bot_stone, hue: cron_job.bot_hue })}
|
|
face={(cron_job.bot_face || "idle") as BotFace}
|
|
/>
|
|
}
|
|
title={title}
|
|
badge={cron_job.enabled ? undefined : done ? "Done" : "Paused"}
|
|
subtitle={routineSubtitle({ cron_job })}
|
|
>
|
|
<SettingsRowAction title={`Chat with ${cron_job.bot_name || "the bot"}`} label="Chat" href={chat_url} />
|
|
<SettingsRowAction
|
|
title={cron_job.enabled ? `Pause ${title}` : `Resume ${title}`}
|
|
label={cron_job.enabled ? "Pause" : "Resume"}
|
|
disabled={busy}
|
|
onClick={onToggle}
|
|
/>
|
|
<SettingsRowAction title={`Edit ${title}`} label="Edit" disabled={busy} onClick={onEdit} />
|
|
<SettingsRowAction title={`Delete ${title}`} label="Delete" disabled={busy} onClick={onDelete} />
|
|
</SettingsListRow>
|
|
);
|
|
}
|