|
|
@@ -6,18 +6,26 @@ import { useGlobalSync } from "./global-sync"
|
|
|
import { useGlobalSDK } from "./global-sdk"
|
|
|
import { Project } from "@opencode-ai/sdk/v2"
|
|
|
|
|
|
-const PASTEL_COLORS = [
|
|
|
- "#FCEAFD", // pastel pink
|
|
|
- "#FFDFBA", // pastel peach
|
|
|
- "#FFFFBA", // pastel yellow
|
|
|
- "#BAFFC9", // pastel green
|
|
|
- "#EAF6FD", // pastel blue
|
|
|
- "#EFEAFD", // pastel lavender
|
|
|
- "#FEC8D8", // pastel rose
|
|
|
- "#D4F0F0", // pastel cyan
|
|
|
- "#FDF0EA", // pastel coral
|
|
|
- "#C1E1C1", // pastel mint
|
|
|
-]
|
|
|
+const AVATAR_COLOR_KEYS = ["pink", "mint", "orange", "purple", "cyan", "lime"] as const
|
|
|
+
|
|
|
+export type AvatarColorKey = (typeof AVATAR_COLOR_KEYS)[number]
|
|
|
+
|
|
|
+export function isAvatarColorKey(value: string): value is AvatarColorKey {
|
|
|
+ return AVATAR_COLOR_KEYS.includes(value as AvatarColorKey)
|
|
|
+}
|
|
|
+
|
|
|
+export function getAvatarColors(key?: string) {
|
|
|
+ if (key && isAvatarColorKey(key)) {
|
|
|
+ return {
|
|
|
+ background: `var(--avatar-background-${key})`,
|
|
|
+ foreground: `var(--avatar-text-${key})`,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ background: "var(--surface-info-base)",
|
|
|
+ foreground: "var(--text-base)",
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
type Dialog = "provider" | "model" | "connect"
|
|
|
|
|
|
@@ -58,11 +66,11 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
|
|
|
connect: {},
|
|
|
dialog: {},
|
|
|
})
|
|
|
- const usedColors = new Set<string>()
|
|
|
+ const usedColors = new Set<AvatarColorKey>()
|
|
|
|
|
|
- function pickAvailableColor() {
|
|
|
- const available = PASTEL_COLORS.filter((c) => !usedColors.has(c))
|
|
|
- if (available.length === 0) return PASTEL_COLORS[Math.floor(Math.random() * PASTEL_COLORS.length)]
|
|
|
+ function pickAvailableColor(): AvatarColorKey {
|
|
|
+ const available = AVATAR_COLOR_KEYS.filter((c) => !usedColors.has(c))
|
|
|
+ if (available.length === 0) return AVATAR_COLOR_KEYS[Math.floor(Math.random() * AVATAR_COLOR_KEYS.length)]
|
|
|
return available[Math.floor(Math.random() * available.length)]
|
|
|
}
|
|
|
|