From 7ba4381bfff70f43249d1fe85a6fe370de786027 Mon Sep 17 00:00:00 2001 From: AJ Avezzano Date: Fri, 3 Apr 2026 19:14:37 -0400 Subject: [PATCH] fix: TempoMapEditor crash on missing count_in + registry URL + Ollama schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Defensive default for count_in in TempoMapEditor prevents crash when AI omits field - Fix hardcoded GitHub registry URL → git.avezzano.io/the_og/clicktrack-registry - Add response_format json_schema to Ollama provider so count_in is always required Co-Authored-By: Claude Sonnet 4.6 --- components/TempoMapEditor.tsx | 8 ++++++-- lib/analysis/providers/ollama.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/TempoMapEditor.tsx b/components/TempoMapEditor.tsx index 3f1bb54..447e938 100644 --- a/components/TempoMapEditor.tsx +++ b/components/TempoMapEditor.tsx @@ -34,7 +34,11 @@ export default function TempoMapEditor({ ctpDoc, readOnly = false, }: TempoMapEditorProps) { - const { metadata, count_in, sections } = ctpDoc; + const { + metadata, + count_in = { enabled: false, bars: 2, use_first_section_tempo: true }, + sections, + } = ctpDoc; return (
@@ -117,7 +121,7 @@ export default function TempoMapEditor({

Interactive editor coming soon — contribute via the{" "} community registry diff --git a/lib/analysis/providers/ollama.ts b/lib/analysis/providers/ollama.ts index d350485..364cec2 100644 --- a/lib/analysis/providers/ollama.ts +++ b/lib/analysis/providers/ollama.ts @@ -2,7 +2,7 @@ import 'server-only'; import type { CTPDocument } from "@/lib/ctp/schema"; import type { AnalysisInput, AnalysisProvider } from "@/lib/analysis/providers"; -import { SYSTEM_PROMPT } from "./anthropic"; +import { SYSTEM_PROMPT, CTP_SCHEMA } from "./anthropic"; function getBaseUrl(): string { return process.env.OLLAMA_BASE_URL ?? "http://localhost:11434"; @@ -44,6 +44,13 @@ async function callOllama(model: string, userMessage: string): Promise { "\n\nRespond with valid JSON only. Do not add any explanation or markdown. Your entire response must be a single valid JSON object matching the schema.", }, ], + response_format: { + type: "json_schema", + json_schema: { + name: "CTPDocument", + schema: CTP_SCHEMA, + }, + }, stream: false, }), signal: AbortSignal.timeout(120000), // 2-minute timeout for slow local models