Compare commits

...

1 Commits

Author SHA1 Message Date
hikari d90691d756 feat: generate adjective-noun combo names for threads
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m24s
CI / Lint & Check (pull_request) Successful in 13m18s
CI / Build Windows (pull_request) Successful in 29m11s
2026-04-13 18:31:35 -07:00
+113 -16
View File
@@ -25,15 +25,118 @@ import type {
Thread, Thread,
} from "./types/index.ts"; } from "./types/index.ts";
const generateThreadName = (mode: Mode, text?: string): string => { const adjectives = [
if ( "Amber",
mode === "replace" "Ancient",
|| text === undefined "Arctic",
|| text.trim().length === 0 "Azure",
) { "Blazing",
return `Replace - ${new Date().toLocaleString()}`; "Celestial",
} "Cobalt",
return text.trim().slice(0, 40); "Crimson",
"Crystal",
"Dark",
"Distant",
"Ember",
"Emerald",
"Eternal",
"Ethereal",
"Fleeting",
"Frosted",
"Gilded",
"Golden",
"Hidden",
"Hollow",
"Indigo",
"Ivory",
"Jade",
"Lunar",
"Midnight",
"Mystic",
"Neon",
"Obsidian",
"Onyx",
"Opal",
"Pale",
"Pearl",
"Radiant",
"Rusted",
"Sapphire",
"Scarlet",
"Shattered",
"Silent",
"Silver",
"Spectral",
"Twilight",
"Velvet",
"Verdant",
"Veiled",
"Violet",
"Wandering",
"Wild",
"Woven",
"Arcane",
];
const nouns = [
"Abyss",
"Archive",
"Aria",
"Bloom",
"Cascade",
"Chronicle",
"Cipher",
"Compass",
"Crown",
"Dawn",
"Dream",
"Echo",
"Elegy",
"Ember",
"Equinox",
"Flame",
"Fragment",
"Garden",
"Horizon",
"Labyrinth",
"Lantern",
"Mirage",
"Mist",
"Murmur",
"Nexus",
"Nocturne",
"Oracle",
"Phantom",
"Prism",
"Requiem",
"Reverie",
"Ruin",
"Shadow",
"Shard",
"Silence",
"Solstice",
"Sonata",
"Specter",
"Storm",
"Tempest",
"Throne",
"Tide",
"Veil",
"Vortex",
"Whisper",
"Zenith",
"Sigil",
"Glyph",
"Dusk",
"Omen",
];
const generateThreadName = (): string => {
const adjectiveIndex = Math.floor(Math.random() * adjectives.length);
const nounIndex = Math.floor(Math.random() * nouns.length);
const adjective = adjectives[adjectiveIndex] ?? "Arcane";
const noun = nouns[nounIndex] ?? "Reverie";
return `${adjective} ${noun}`;
}; };
const generateId = (): string => { const generateId = (): string => {
@@ -74,13 +177,7 @@ const resolveUpdatedThread = (updatedThread: Thread): Thread => {
return updatedThread; return updatedThread;
} }
const firstTextPart = firstMessage.parts.find((part) => { const name = generateThreadName();
return part.type === "text";
});
const name = generateThreadName(
updatedThread.mode,
firstTextPart?.text,
);
return { ...updatedThread, name }; return { ...updatedThread, name };
}; };