The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { ProjectIconOverride } from "@t3tools/contracts"; |
| 2 | |
| 3 | import type { |
| 4 | SidebarProjectGroupMember, |
| 5 | SidebarProjectSnapshot, |
| 6 | } from "../../sidebarProjectGrouping"; |
| 7 | import type { Project } from "../../types"; |
| 8 | |
| 9 | export const SCRATCH_PROJECT_TITLE = "No project"; |
| 10 | const SCRATCH_PROJECT_ICON = { |
| 11 | kind: "lucide", |
| 12 | name: "message-square-dashed", |
| 13 | color: "gray", |
| 14 | } as const satisfies ProjectIconOverride; |
| 15 | |
| 16 | export function scopeProjectSettingsGroup( |
| 17 | group: SidebarProjectSnapshot, |
| 18 | members: readonly SidebarProjectGroupMember[], |
| 19 | ): SidebarProjectSnapshot { |
| 20 | const representative = |
| 21 | members.find( |
| 22 | (member) => member.environmentId === group.environmentId && member.id === group.id, |
| 23 | ) ?? members[0]!; |
| 24 | return { ...group, ...representative, memberProjects: members }; |
| 25 | } |
| 26 | |
| 27 | export function projectGroupTitleNeedsUpdate( |
| 28 | members: ReadonlyArray<Pick<Project, "title" | "hasCustomTitle">>, |
| 29 | nextTitle: string, |
| 30 | wasEdited: boolean, |
| 31 | ): boolean { |
| 32 | return ( |
| 33 | wasEdited && |
| 34 | members.some((member) => member.title !== nextTitle || member.hasCustomTitle !== true) |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | export function defaultProjectIcon(project: Pick<Project, "isScratch">) { |
| 39 | return { faviconPath: null, projectIcon: project.isScratch ? SCRATCH_PROJECT_ICON : null }; |
| 40 | } |
| 41 | |
| 42 | export function hasDefaultProjectIcon( |
| 43 | project: Pick<Project, "isScratch" | "faviconPath" | "projectIcon">, |
| 44 | ): boolean { |
| 45 | if (project.faviconPath != null) return false; |
| 46 | const icon = project.projectIcon ?? null; |
| 47 | if (!project.isScratch) return icon === null; |
| 48 | return ( |
| 49 | icon?.kind === "lucide" && |
| 50 | icon.name === SCRATCH_PROJECT_ICON.name && |
| 51 | icon.color === SCRATCH_PROJECT_ICON.color |
| 52 | ); |
| 53 | } |