From e1e8d097be5207cf3fe753e5c1b45f6398cf5103 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sat, 17 Jan 2026 09:56:34 +0100 Subject: [PATCH] chore: pr feedbacks --- AGENTS.md | 15 ++--- app/client/lib/utils.ts | 8 +++ .../repositories/components/doctor-report.tsx | 20 +++--- app/client/modules/repositories/tabs/info.tsx | 1 + app/schemas/restic.ts | 1 + app/server/modules/repositories/doctor.ts | 63 ++++++++++++++----- .../repositories/repositories.service.ts | 25 ++++---- app/server/utils/json.ts | 11 ++++ 8 files changed, 99 insertions(+), 45 deletions(-) create mode 100644 app/server/utils/json.ts diff --git a/AGENTS.md b/AGENTS.md index 9d09ac2c..28983921 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ Zerobyte is a backup automation tool built on top of Restic that provides a web - **Validation**: ArkType for runtime schema validation - **Styling**: Tailwind CSS v4 + Radix UI components - **Architecture**: Unified application structure (not a monorepo) -- **Code Quality**: Biome (formatter & linter) +- **Code Quality**: Oxfmt for formatting, Oxlint for linting ## Repository Structure @@ -75,14 +75,11 @@ bun run gen:api-client ### Code Quality ```bash -# Format and lint (Biome) -bunx biome check --write . +# Format +bunx oxfmt format --write -# Format only -bunx biome format --write . - -# Lint only -bunx biome lint . +# Lint +bun run lint ``` ## Architecture @@ -240,8 +237,6 @@ On startup, the server detects available capabilities (see `core/capabilities.ts ## Important Notes -- **Code Style**: Uses Biome with tabs (not spaces), 120 char line width, double quotes -- **Imports**: Organize imports is disabled in Biome - do not auto-organize - **TypeScript**: Uses `"type": "module"` - all imports must include extensions when targeting Node/Bun - **Validation**: Prefer ArkType over Zod - it's used throughout the codebase - **Database**: Timestamps are stored as Unix epoch integers, not ISO strings diff --git a/app/client/lib/utils.ts b/app/client/lib/utils.ts index 211eb300..f3cb121c 100644 --- a/app/client/lib/utils.ts +++ b/app/client/lib/utils.ts @@ -28,3 +28,11 @@ export function slugify(input: string): string { .replace(/[_]{2,}/g, "_") .trim(); } + +export function safeJsonParse(input: string): T | null { + try { + return JSON.parse(input) as T; + } catch { + return null; + } +} diff --git a/app/client/modules/repositories/components/doctor-report.tsx b/app/client/modules/repositories/components/doctor-report.tsx index e2608873..7709523e 100644 --- a/app/client/modules/repositories/components/doctor-report.tsx +++ b/app/client/modules/repositories/components/doctor-report.tsx @@ -1,7 +1,7 @@ import { AlertCircle, CheckCircle2 } from "lucide-react"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "~/client/components/ui/collapsible"; import { formatDateTime } from "~/client/lib/datetime"; -import { cn } from "~/client/lib/utils"; +import { cn, safeJsonParse } from "~/client/lib/utils"; type DoctorStep = { step: string; @@ -15,13 +15,13 @@ type DoctorResult = { steps: DoctorStep[]; completedAt: number; }; -export const DoctorReport = ({ - result, - repositoryStatus, -}: { + +type Props = { result?: DoctorResult | null; repositoryStatus: string | null; -}) => { +}; + +export const DoctorReport = ({ result, repositoryStatus }: Props) => { return (

Doctor Report

@@ -30,10 +30,10 @@ export const DoctorReport = ({ Completed {formatDateTime(result.completedAt)}
{result.steps.map((step) => ( - +
- {step.step.replace("_", " ")} + {step.step.replaceAll("_", " ")} {step.success ? ( ) : ( @@ -45,7 +45,7 @@ export const DoctorReport = ({
{step.output && (
-												{step.output.startsWith("{") ? JSON.stringify(JSON.parse(step.output), null, 2) : step.output}
+												{safeJsonParse(step.output) ? JSON.stringify(safeJsonParse(step.output), null, 2) : step.output}
 											
)} {step.error && ( @@ -68,7 +68,7 @@ export const DoctorReport = ({ )}

No doctor report available.

diff --git a/app/client/modules/repositories/tabs/info.tsx b/app/client/modules/repositories/tabs/info.tsx index c135f2bf..a2aeee9a 100644 --- a/app/client/modules/repositories/tabs/info.tsx +++ b/app/client/modules/repositories/tabs/info.tsx @@ -137,6 +137,7 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {