mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
refactor: move from next js to vite and tanstack router
This commit is contained in:
54
apps/ui/src/lib/utils.ts
Normal file
54
apps/ui/src/lib/utils.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import type { AgentModel } from "@/store/app-store"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current model supports extended thinking controls
|
||||
*/
|
||||
export function modelSupportsThinking(model?: AgentModel | string): boolean {
|
||||
// All Claude models support thinking
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get display name for a model
|
||||
*/
|
||||
export function getModelDisplayName(model: AgentModel | string): string {
|
||||
const displayNames: Record<string, string> = {
|
||||
haiku: "Claude Haiku",
|
||||
sonnet: "Claude Sonnet",
|
||||
opus: "Claude Opus",
|
||||
};
|
||||
return displayNames[model] || model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate a description string with ellipsis
|
||||
*/
|
||||
export function truncateDescription(description: string, maxLength = 50): string {
|
||||
if (description.length <= maxLength) {
|
||||
return description;
|
||||
}
|
||||
return `${description.slice(0, maxLength)}...`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a file path to use forward slashes consistently.
|
||||
* This is important for cross-platform compatibility (Windows uses backslashes).
|
||||
*/
|
||||
export function normalizePath(p: string): string {
|
||||
return p.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two paths for equality, handling cross-platform differences.
|
||||
* Normalizes both paths to forward slashes before comparison.
|
||||
*/
|
||||
export function pathsEqual(p1: string | undefined | null, p2: string | undefined | null): boolean {
|
||||
if (!p1 || !p2) return p1 === p2;
|
||||
return normalizePath(p1) === normalizePath(p2);
|
||||
}
|
||||
Reference in New Issue
Block a user