Let a bot take any colour
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`.
This commit is contained in:
@@ -5,7 +5,7 @@ import { AppData } from "@/src/data/app-data";
|
||||
import pushBotCreated from "@/src/bots-queue/push-bot-created";
|
||||
import createBot from "@/src/functions/backend/db/bots/create-bot";
|
||||
import addBotToWorkspace from "@/src/functions/backend/db/workspaces/add-bot-to-workspace";
|
||||
import pickFreeHue from "@/src/utils/pick-free-hue";
|
||||
import pickFreeColor from "@/src/utils/pick-free-color";
|
||||
import botRef from "@/src/utils/bot-ref";
|
||||
import type { HarnessTool } from "../../types";
|
||||
|
||||
@@ -76,19 +76,24 @@ export default function createBotTool({
|
||||
);
|
||||
}
|
||||
|
||||
const hues =
|
||||
const colors =
|
||||
(
|
||||
await BunSQLite.sql<BUN_SQLITE_COBBLE_BOTS>({
|
||||
sql: `SELECT hue FROM bots`,
|
||||
sql: `SELECT color FROM bots`,
|
||||
values: [],
|
||||
})
|
||||
).payload || [];
|
||||
|
||||
const { color, stone } = pickFreeColor({
|
||||
taken: colors.map((bot) => bot.color),
|
||||
});
|
||||
|
||||
const bot_id = await createBot({
|
||||
user_id,
|
||||
name: args.name,
|
||||
role: args.role,
|
||||
hue: pickFreeHue({ taken: hues.map((bot) => bot.hue) }),
|
||||
color,
|
||||
stone,
|
||||
system_prompt: args.instructions,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { z } from "zod";
|
||||
import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
|
||||
import { AppData } from "@/src/data/app-data";
|
||||
import type { BotHue } from "@/src/dict/bot-dict";
|
||||
import grabCrewWorkers from "@/src/functions/backend/db/bots/grab-crew-workers";
|
||||
import updateBot from "@/src/functions/backend/db/bots/update-bot";
|
||||
import { paletteColor, resolveBotStone } from "@/src/utils/bot-color";
|
||||
import type { HarnessTool } from "../../types";
|
||||
|
||||
type Params = {
|
||||
@@ -24,7 +24,8 @@ type Args = {
|
||||
/**
|
||||
* Lets the coordinator change an existing crew member: its name, its
|
||||
* one-line job, and its core instructions (the start of its prompt in its
|
||||
* own chat and in every workspace). Its hue and picture stay as they are.
|
||||
* own chat and in every workspace). Its colour, stone and picture stay as
|
||||
* they are.
|
||||
* Workspace-only instructions have their own tool
|
||||
* (`set_bot_workspace_instructions`).
|
||||
*/
|
||||
@@ -71,7 +72,13 @@ export default function updateBotTool({ user_id, workers }: Params): HarnessTool
|
||||
bot_id: worker.id,
|
||||
name: args.name ?? worker.name ?? "Bot",
|
||||
role: args.role ?? worker.role ?? "",
|
||||
hue: (worker.hue || "ember") as BotHue,
|
||||
/**
|
||||
* Never changed here: the user's pick is theirs. A bot saved
|
||||
* before colours were free keeps the colour it showed.
|
||||
*/
|
||||
color:
|
||||
worker.color || paletteColor({ hue: worker.hue }) || "#e4572e",
|
||||
stone: resolveBotStone({ stone: worker.stone, hue: worker.hue }),
|
||||
system_prompt: args.instructions ?? worker.system_prompt ?? "",
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user