mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
web-evals: remove usehooks-ts shim; reuse shared storage parsing
This commit is contained in:
parent
de4256d1d4
commit
28c49b1e42
3 changed files with 5 additions and 29 deletions
|
|
@ -9,6 +9,7 @@ import type { Run, TaskMetrics as _TaskMetrics, Task } from "@roo-code/evals"
|
|||
import type { ToolName } from "@roo-code/types"
|
||||
|
||||
import { formatCurrency, formatDuration, formatTokens, formatToolUsageSuccessRate } from "@/lib/formatters"
|
||||
import { deserializeBoolean } from "@/lib/storage"
|
||||
import { useRunStatus } from "@/hooks/use-run-status"
|
||||
import { killRun } from "@/actions/runs"
|
||||
import {
|
||||
|
|
@ -255,18 +256,6 @@ export function Run({ run }: { run: Run }) {
|
|||
const [showKillDialog, setShowKillDialog] = useState(false)
|
||||
const [isKilling, setIsKilling] = useState(false)
|
||||
|
||||
function deserializeBoolean(value: string): boolean {
|
||||
// Support both raw-string storage and default `useLocalStorage` JSON serialization.
|
||||
if (value === "true") return true
|
||||
if (value === "false") return false
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(value)
|
||||
return typeof parsed === "boolean" ? parsed : false
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const [groupByStatus, setGroupByStatus] = useLocalStorage<boolean>("evals-group-by-status", false, {
|
||||
serializer: (value: boolean) => String(value),
|
||||
deserializer: deserializeBoolean,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import {
|
|||
ITERATIONS_DEFAULT,
|
||||
} from "@/lib/schemas"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { deserializeNumber, deserializeString, deserializeStringArray } from "@/lib/storage"
|
||||
import { deserializeEnum, deserializeNumber, deserializeStringArray } from "@/lib/storage"
|
||||
|
||||
import { loadRooLastModelSelection, saveRooLastModelSelection } from "@/lib/roo-last-model-selection"
|
||||
import { normalizeCreateRunForSubmit } from "@/lib/normalize-create-run"
|
||||
|
|
@ -106,6 +106,8 @@ type ConfigSelection = {
|
|||
popoverOpen: boolean
|
||||
}
|
||||
|
||||
const SUITE_VALUES: ReadonlySet<"full" | "partial"> = new Set(["full", "partial"])
|
||||
|
||||
export function NewRun() {
|
||||
const router = useRouter()
|
||||
const modelSelectionsByProviderRef = useRef<Record<string, ModelSelection[]>>({})
|
||||
|
|
@ -143,7 +145,7 @@ export function NewRun() {
|
|||
})
|
||||
const [savedSuite, setSavedSuite] = useLocalStorage<"full" | "partial">("evals-suite", "full", {
|
||||
serializer: (value: "full" | "partial") => value,
|
||||
deserializer: (raw: string) => (deserializeString(raw) === "partial" ? "partial" : "full"),
|
||||
deserializer: (raw: string) => deserializeEnum(raw, SUITE_VALUES, "full"),
|
||||
initializeWithValue: false,
|
||||
})
|
||||
const [savedExercises, setSavedExercises] = useLocalStorage<string[]>("evals-exercises", [], {
|
||||
|
|
|
|||
15
apps/web-evals/src/types/usehooks-ts.d.ts
vendored
15
apps/web-evals/src/types/usehooks-ts.d.ts
vendored
|
|
@ -1,15 +0,0 @@
|
|||
declare module "usehooks-ts" {
|
||||
import type { Dispatch, SetStateAction } from "react"
|
||||
|
||||
export type UseLocalStorageOptions<T> = {
|
||||
serializer?: (value: T) => string
|
||||
deserializer?: (value: string) => T
|
||||
initializeWithValue?: boolean
|
||||
}
|
||||
|
||||
export function useLocalStorage<T>(
|
||||
key: string,
|
||||
initialValue: T | (() => T),
|
||||
options?: UseLocalStorageOptions<T>,
|
||||
): [T, Dispatch<SetStateAction<T>>, () => void]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue