Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions desktop/cli/commands/prefs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const KEYS = [
["appearance.textSize", "small | default | large | larger", "The size of the text"],
["appearance.font", list(THEMES.fonts.map((font) => font.id)), "The font"],
["appearance.bubble", "theme | #rrggbb", "The color of your messages"],
["appearance.agentMessages", "canvas | bubbles", "How agent messages are shown"],
["appearance.agentBubble", "theme | #rrggbb", "The default color of agent message bubbles"],
["appearance.avatarAnimations", "on | off", "Animate bot avatars while they work"],
["foldTools", "on | off", "Fold the steps of a finished reply into one line"],
["showThinking", "on | off", "Show the bot's thinking"],
Expand Down
11 changes: 9 additions & 2 deletions desktop/cli/commands/workspace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ function voiceOf(options) {
function botFields(options) {
if (options.instructions !== undefined && options["instructions-file"] !== undefined) throw usage("Give --instructions or --instructions-file, not both.");
const voice = voiceOf(options);
let bubbleColor;
if (options["bubble-color"] !== undefined) {
const raw = String(options["bubble-color"]).trim();
bubbleColor = raw === "" || raw.toLowerCase() === "default" ? "" : raw;
}
return {
...(options.name !== undefined && { name: options.name }),
...(options.role !== undefined && { role: options.role }),
...(options.instructions !== undefined && { instructions: options.instructions }),
...(options["instructions-file"] !== undefined && { instructions: fileText(options["instructions-file"]) }),
...(options.model !== undefined && { model: options.model }),
...(bubbleColor !== undefined && { bubbleColor }),
...(voice !== undefined && { voice }),
};
}
Expand All @@ -56,6 +62,7 @@ const BOT_OPTIONS = {
instructions: { type: "string", value: "text", about: "How the bot should work" },
"instructions-file": { type: "string", value: "path", about: "The same, from a file" },
model: { type: "string", value: "provider/model", about: "Its model, as `botkins models` names it (\"\" for the default)" },
"bubble-color": { type: "string", value: "hex|default", about: "Message bubble color for this bot (#rrggbb, or \"default\" to reset)" },
};
/** The options that give a bot a voice of its own. Only `bots edit` has them. */
const VOICE_OPTIONS = {
Expand Down Expand Up @@ -308,7 +315,7 @@ export const workspace = {
},
add: {
summary: "Add a bot",
usage: "botkins bots add <name> [--role <text>] [--instructions <text> | --instructions-file <path>] [--model <provider/model>]",
usage: "botkins bots add <name> [--role <text>] [--instructions <text> | --instructions-file <path>] [--model <provider/model>] [--bubble-color <hex|default>]",
options: BOT_OPTIONS,
async run(context) {
if (context.args.length !== 1) throw usage("Give the bot a name.");
Expand All @@ -317,7 +324,7 @@ export const workspace = {
},
edit: {
summary: "Change a bot",
usage: "botkins bots edit <bot> [--name <text>] [--role <text>] [--instructions <text> | --instructions-file <path>] [--model <provider/model>] [--reading-provider <provider>] [--reading-model <model>] [--reading-voice <voice>] [--reading-speed <0.5-2>] [--live-provider <provider>] [--live-model <model>] [--live-voice <voice>] [--same-voice]",
usage: "botkins bots edit <bot> [--name <text>] [--role <text>] [--instructions <text> | --instructions-file <path>] [--model <provider/model>] [--bubble-color <hex|default>] [--reading-provider <provider>] [--reading-model <model>] [--reading-voice <voice>] [--reading-speed <0.5-2>] [--live-provider <provider>] [--live-model <model>] [--live-voice <voice>] [--same-voice]",
options: { name: { type: "string", value: "text", about: "A new name" }, ...BOT_OPTIONS, ...VOICE_OPTIONS },
details: "With no option, the bot opens in your editor ($VISUAL, $EDITOR, else vi) as JSON: change its name, role, instructions or model and save. The voice options give the bot a voice of its own, over Settings › Voice: only what you name changes, and an empty value goes back to Settings. The keys stay in Settings › Voice.",
async run(context) {
Expand Down
10 changes: 10 additions & 0 deletions desktop/desktop/agents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ export function summaryField(value) {
return value.trim();
}

export function bubbleColorField(value) {
if (value === null || value === "") return null;
if (typeof value === "string") {
const trimmed = value.trim();
if (!trimmed) return null;
if (/^#[0-9a-f]{6}$/i.test(trimmed)) return trimmed.toLowerCase();
}
throw new Error("Choose a bubble color as #rrggbb, or leave it empty for default.");
}

/** Brings older workspace files up to the agent-management model. Runs on every load. */
export function migrateAgents(state) {
state.sections ??= [];
Expand Down
27 changes: 21 additions & 6 deletions desktop/desktop/link/methods.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,29 @@ export function remoteArgs(method, args, { deviceId, uploads } = {}) {
args = [{ ...args[0], bundle: templateBundle(args[0].bundle) }];
}
if (method === "updateBot" && args[1]?.bundle !== undefined) throw new Error("A template bundle is installed when a bot is created.");
// A bot's own voice ("bot-voice-v1"): only the shape the computer keeps; null clears it. Anything else is refused with a sentence.
if ((method === "updateBot" || method === "addBot") && args[method === "addBot" ? 0 : 1]?.voice !== undefined) {
// A bot's own voice ("bot-voice-v1") and bubble color: only the shapes the computer keeps; null/"" clears them.
if (method === "updateBot" || method === "addBot") {
const at = method === "addBot" ? 0 : 1;
const data = args[at];
if (data === null || typeof data !== "object" || Array.isArray(data)) return args;
const next = [...args];
next[at] = { ...data, voice: botVoiceField(data.voice) };
return next;
if (data && typeof data === "object" && !Array.isArray(data) && (data.voice !== undefined || data.bubbleColor !== undefined)) {
const next = [...args];
const patched = { ...data };
if (data.voice !== undefined) patched.voice = botVoiceField(data.voice);
if (data.bubbleColor !== undefined) {
if (data.bubbleColor === null || data.bubbleColor === "") {
patched.bubbleColor = null;
} else if (typeof data.bubbleColor === "string") {
const trimmed = data.bubbleColor.trim();
if (!trimmed) patched.bubbleColor = null;
else if (/^#[0-9a-f]{6}$/i.test(trimmed)) patched.bubbleColor = trimmed.toLowerCase();
else throw new Error("Choose a bubble color as #rrggbb, or leave it empty for default.");
} else {
throw new Error("Choose a bubble color as #rrggbb, or leave it empty for default.");
}
}
next[at] = patched;
return next;
}
}
return fileArgs(method, args) ?? pluginArgs(method, args) ?? marketArgs(method, args) ?? marketV2Args(method, args) ?? catalogArgs(method, args) ?? mcpAppArgs(method, args) ?? claudeArtifactArgs(method, args) ?? providerArgs(method, args) ?? appUpdateArgs(method, args) ?? projectArtifactArgs(method, args) ?? jobArgs(method, args) ?? spaceArgs(method, args) ?? args;
}
Expand Down
13 changes: 13 additions & 0 deletions desktop/desktop/preferences.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const DEFAULT_FONT = THEMES.defaultFont;
export const TEXT_SIZES = ["small", "default", "large", "larger"];
export const BACKDROPS = ["clean", "mesh", "botkins", "grid"];
export const DEFAULT_BACKDROP = "clean";
export const AGENT_MESSAGE_MODES = ["canvas", "bubbles"];
export const DEFAULT_AGENT_MESSAGES = "canvas";
// The theme everyone had before Ink became the usual one. It was saved for everyone, picked or
// not, so by itself it doesn't show that a person chose it.
const OLD_DEFAULT = "botkins";
Expand Down Expand Up @@ -62,6 +64,8 @@ export function appearanceField(saved) {
appearance.font = fontPick ?? DEFAULT_FONT;
appearance.fontPicked = fontPick != null;
if (!(appearance.bubble === "theme" || /^#[0-9a-f]{6}$/i.test(appearance.bubble))) appearance.bubble = "theme";
if (!AGENT_MESSAGE_MODES.includes(appearance.agentMessages)) appearance.agentMessages = DEFAULT_AGENT_MESSAGES;
if (!(appearance.agentBubble === "theme" || /^#[0-9a-f]{6}$/i.test(appearance.agentBubble))) appearance.agentBubble = "theme";
if (typeof appearance.avatarAnimations !== "boolean") appearance.avatarAnimations = true;
return appearance;
}
Expand Down Expand Up @@ -178,6 +182,10 @@ export const defaultSettings = {
font: "system",
fontPicked: false,
bubble: "theme",
// How agent messages are displayed in chats: "canvas" (default) or "bubbles".
agentMessages: DEFAULT_AGENT_MESSAGES,
// Default color for agent message bubbles: "theme" or a #rrggbb hex color.
agentBubble: "theme",
// Large avatars draw a still pose while idle; active and outcome states can move.
avatarAnimations: true,
// Background presets from before themes. Kept as saved, for an earlier version to read.
Expand Down Expand Up @@ -284,6 +292,11 @@ export function changeSettings(settings, patch) {
!(
appearance.bubble === "theme" ||
/^#[0-9a-f]{6}$/i.test(appearance.bubble)
) ||
!AGENT_MESSAGE_MODES.includes(appearance.agentMessages) ||
!(
appearance.agentBubble === "theme" ||
/^#[0-9a-f]{6}$/i.test(appearance.agentBubble)
)
)
throw new Error("Invalid appearance choice");
Expand Down
4 changes: 3 additions & 1 deletion desktop/desktop/terminal/control-prefs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// and got a yes. The command line does that (`--yes`, or the question at a terminal). A caller that is the
// person gives the mark itself.
import { backgroundField } from "../startup.mjs";
import { appearanceField, BACKDROPS, clarificationPrompts, defaultSettings, FONT_IDS, sidebarField, SIDEBAR, TEXT_SIZES, THEME_IDS, TOOL_CALL_TIMEOUT_MAX } from "../preferences.mjs";
import { AGENT_MESSAGE_MODES, appearanceField, BACKDROPS, clarificationPrompts, defaultSettings, FONT_IDS, sidebarField, SIDEBAR, TEXT_SIZES, THEME_IDS, TOOL_CALL_TIMEOUT_MAX } from "../preferences.mjs";
import { HARNESSES } from "../harness/index.mjs";
import { AUTO_SUMMARIZE_MAX, AUTO_SUMMARIZE_MIN } from "../summaries.mjs";
import { MAC_LEVELS, MAC_TOOLS } from "../mactools.mjs";
Expand Down Expand Up @@ -45,6 +45,8 @@ export const PREFERENCES = {
"appearance.textSize": choice(TEXT_SIZES, "The size of the text"),
"appearance.font": choice(FONT_IDS, "The font"),
"appearance.bubble": { type: "color", about: "The color of your messages: theme, or a color such as #3366cc" },
"appearance.agentMessages": choice(AGENT_MESSAGE_MODES, "How agent messages are shown: canvas or bubbles"),
"appearance.agentBubble": { type: "color", about: "The default color of agent message bubbles: theme, or a color such as #3366cc" },
"appearance.avatarAnimations": switches("Animate bot avatars while they work"),
foldTools: switches("For older apps: fold the steps of a finished reply into one line (each window's Steps setting is in Settings › Chat)"),
showThinking: switches("Show the bot's thinking; off hides it in each window where nobody picked Thinking in Settings › Chat"),
Expand Down
5 changes: 4 additions & 1 deletion desktop/desktop/terminal/control.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function controlApi(service) {
instructions: entry.instructions,
...(entry.model && { model: entry.model }),
...(entry.voice && { voice: entry.voice }),
...(entry.bubbleColor && { bubbleColor: entry.bubbleColor }),
...(entry.primary && { primary: true }),
chats: state().chats.filter((chat) => chat.botId === entry.id && !chat.temporary).length,
working: state().chats.some((chat) => chat.botId === entry.id && workspace.active.has(chat.id)),
Expand Down Expand Up @@ -456,6 +457,7 @@ export function controlApi(service) {
role: entry.role ?? "",
...(entry.model && { model: entry.model }),
...(entry.voice && { voice: entry.voice }),
...(entry.bubbleColor && { bubbleColor: entry.bubbleColor }),
...(entry.primary && { primary: true }),
chats: (snapshot.chats ?? []).filter((chat) => chat.botId === entry.id && !chat.temporary).length,
working: (snapshot.chats ?? []).some((chat) => chat.botId === entry.id && Boolean(snapshot.active?.[chat.id])),
Expand All @@ -475,14 +477,15 @@ export function controlApi(service) {
name,
role: typeof data.role === "string" && data.role.trim() ? data.role : "Assistant",
instructions: typeof data.instructions === "string" && data.instructions.trim() ? data.instructions : "Help with what you are asked, clearly and briefly.",
...(data.bubbleColor !== undefined && { bubbleColor: data.bubbleColor }),
});
if (model) await workspace.setModel("bot", id, model);
return botView(bot(id));
},
async "bots.edit"([ref, patch = {}]) {
const found = bot(ref);
const fields = {};
for (const key of ["name", "role", "instructions"]) if (patch[key] !== undefined) fields[key] = patch[key];
for (const key of ["name", "role", "instructions", "bubbleColor"]) if (patch[key] !== undefined) fields[key] = patch[key];
// A voice of its own: what is named changes and the rest stays; "" goes back to Settings › Voice; null clears it all.
if (patch.voice !== undefined) fields.voice = patch.voice === null ? null : mergeVoice(found.voice, patch.voice);
if (Object.keys(fields).length) handlers.updateBot(found.id, fields);
Expand Down
11 changes: 10 additions & 1 deletion desktop/desktop/workspace.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import {
validateAttachments,
} from "./canvas.mjs";
import { holderSessions, migrateChatSessions, migrateSessionHolder } from "./providers/sessions.mjs";
import { Agents, instructionsField, migrateAgents, summaryField } from "./agents.mjs";
import { Agents, bubbleColorField, instructionsField, migrateAgents, summaryField } from "./agents.mjs";
import { linkLooks, lookField, migrateLooks, nextLook } from "./looks.mjs";
import { starterById } from "./starters.mjs";
import { botVoiceField } from "./link/voice.mjs";
Expand Down Expand Up @@ -954,6 +954,10 @@ export class Workspace {
// A voice of the bot's own (desktop/link/voice.mjs, botVoiceField): checked here, and kept only when something is set.
const voice = data.voice === undefined ? null : botVoiceField(data.voice);
if (voice) bot.voice = voice;
if (data.bubbleColor !== undefined) {
const bubbleColor = bubbleColorField(data.bubbleColor);
if (bubbleColor) bot.bubbleColor = bubbleColor;
}
if (person !== "owner") bot.createdBy = person;
return this.installBot(bot, data.bundle, undefined, opts);
}
Expand Down Expand Up @@ -1010,6 +1014,11 @@ export class Workspace {
if (voice) bot.voice = voice;
else delete bot.voice;
}
if (data.bubbleColor !== undefined) {
const bubbleColor = bubbleColorField(data.bubbleColor);
if (bubbleColor) bot.bubbleColor = bubbleColor;
else delete bot.bubbleColor;
}
this.save();
}
mainChat(botId, person = "owner") {
Expand Down
66 changes: 65 additions & 1 deletion desktop/src/BotProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { BotAvatar, activityLabel, botActivity } from "./Avatar";
import { BotStudio } from "./BotStudio";
import { availableHeads, lookOf, sameLook } from "./botkins";
import { AGENT_BUBBLE_SWATCHES, inkOn } from "./themes";
import ModelPicker from "./ModelPicker";
import { openProviderSettings } from "./providers";
import { ChatRow, deleteBot, keepsMainChats, useAsk, type PageActions } from "./Pages";
Expand Down Expand Up @@ -123,8 +124,10 @@ export default function BotProfile({
role: bot.role,
summary: bot.summary ?? "",
instructions: bot.instructions,
bubbleColor: bot.bubbleColor ?? "",
};
const [draft, setDraft] = useState(initial);
const [customBubbleHex, setCustomBubbleHex] = useState(bot.bubbleColor || AGENT_BUBBLE_SWATCHES[1].hex);
const [look, setLook] = useState<BotLook>(() => lookOf(bot));
const [editAvatar, setEditAvatar] = useState(false);
const [avatarSaving, setAvatarSaving] = useState(false);
Expand All @@ -142,9 +145,11 @@ export default function BotProfile({
const panels = state.panels.filter((p) => p.botId === bot.id && !p.hidden).length;
const own = lookOf(bot);
const lookChanged = !sameLook(look, own);
const bubbleColorChanged = draft.bubbleColor.trim().toLowerCase() !== initial.bubbleColor.trim().toLowerCase();
const dirty =
lookChanged ||
(Object.keys(initial) as (keyof typeof initial)[]).some((k) => draft[k].trim() !== initial[k].trim());
bubbleColorChanged ||
(["name", "role", "summary", "instructions"] as const).some((k) => draft[k].trim() !== initial[k].trim());
const valid = draft.name.trim() && draft.role.trim() && draft.instructions.trim();
const field = (k: keyof typeof draft) => ({
value: draft[k],
Expand All @@ -163,6 +168,7 @@ export default function BotProfile({
summary: draft.summary.trim(),
instructions: draft.instructions.trim(),
...(lookChanged ? { look } : {}),
...(bubbleColorChanged ? { bubbleColor: draft.bubbleColor.trim() || null } : {}),
});
setSaved(true);
setEditAvatar(false);
Expand Down Expand Up @@ -296,6 +302,63 @@ export default function BotProfile({
Instructions
<textarea rows={6} required maxLength={30000} {...field("instructions")} />
</label>
<div className="profile-bubble-field">
<div className="profile-bubble-head">
<span>Message bubble color</span>
<small>Used when Agent messages are set to Bubbles in Appearance.</small>
</div>
<div className="bubble-swatches">
<button
type="button"
className={"bubble-default-btn" + (!draft.bubbleColor ? " on" : "")}
aria-pressed={!draft.bubbleColor}
onClick={() => {
setSaved(false);
setDraft((d) => ({ ...d, bubbleColor: "" }));
}}
>
Default
</button>
{AGENT_BUBBLE_SWATCHES.map((swatch) => {
const on = draft.bubbleColor.toLowerCase() === swatch.hex.toLowerCase();
return (
<button
key={swatch.hex}
type="button"
className={"bubble-swatch" + (on ? " on" : "")}
title={swatch.name}
aria-label={swatch.name}
aria-pressed={on}
style={{ background: swatch.hex }}
onClick={() => {
setSaved(false);
setCustomBubbleHex(swatch.hex);
setDraft((d) => ({ ...d, bubbleColor: swatch.hex }));
}}
/>
);
})}
<input
type="color"
aria-label="Custom message bubble color"
className="set-color"
value={draft.bubbleColor || customBubbleHex}
onChange={(e) => {
setSaved(false);
setCustomBubbleHex(e.target.value);
setDraft((d) => ({ ...d, bubbleColor: e.target.value }));
}}
/>
{draft.bubbleColor && (
<span
className="profile-bubble-chip"
style={{ background: draft.bubbleColor, color: inkOn(draft.bubbleColor) }}
>
{draft.bubbleColor.toUpperCase()}
</span>
)}
</div>
</div>
<div className="profile-save">
<button className="btn primary" disabled={!dirty || !valid || saving}>
{saving ? "Saving…" : "Save"}
Expand All @@ -306,6 +369,7 @@ export default function BotProfile({
className="btn soft"
onClick={() => {
setDraft(initial);
setCustomBubbleHex(bot.bubbleColor || AGENT_BUBBLE_SWATCHES[1].hex);
setLook(lookOf(bot));
setEditAvatar(false);
}}
Expand Down
Loading
Loading