From 192c7baf2f8a8add4961e4604aa407ec19a6e95f Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Mon, 6 Apr 2026 16:24:31 -0700 Subject: [PATCH] fix: align web+mobile types with backend (categories, output types, field names, durationMs telemetry) --- backend/src/lib/copilot-transform.ts | 3 ++- mobile/src/api/note-prompts.ts | 10 +++++++--- web/src/app/(app)/prompts/page.tsx | 4 ++-- web/src/components/RunPromptModal.test.tsx | 2 +- web/src/components/SmartActionsPanel.test.tsx | 4 ++-- web/src/lib/prompt-client.ts | 2 +- web/src/lib/types.ts | 9 +++++---- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend/src/lib/copilot-transform.ts b/backend/src/lib/copilot-transform.ts index b1010ad..fbb48a9 100644 --- a/backend/src/lib/copilot-transform.ts +++ b/backend/src/lib/copilot-transform.ts @@ -62,6 +62,7 @@ export async function runCopilotTransform(action: CopilotAction, text: string): const maxRetries = 3; const baseDelayMs = 1000; + const startMs = Date.now(); for (let attempt = 0; attempt < maxRetries; attempt++) { try { const result = await withTimeout(provider.chatCompletion({ @@ -74,7 +75,7 @@ export async function runCopilotTransform(action: CopilotAction, text: string): }), 60_000); const out = result.content.trim(); if (out.length > 0) { - trackEvent('copilot_transform', 'system', { action, durationMs: String(Date.now()) }); + trackEvent('copilot_transform', 'system', { action, durationMs: String(Date.now() - startMs) }); return out; } break; // empty response — fall through to heuristic diff --git a/mobile/src/api/note-prompts.ts b/mobile/src/api/note-prompts.ts index f7e6739..32795e6 100644 --- a/mobile/src/api/note-prompts.ts +++ b/mobile/src/api/note-prompts.ts @@ -2,7 +2,7 @@ import { getApiClient } from './client'; export type PromptCategory = 'transform' | 'extract' | 'generate' | 'analyze' | 'export'; export type PromptInputType = 'text' | 'image' | 'text+image' | 'multi-note'; -export type PromptOutputType = 'new_note' | 'artifact' | 'update_note'; +export type PromptOutputType = 'new_note' | 'artifact' | 'replace' | 'inline'; export type MobilePromptTemplate = { id: string; @@ -12,15 +12,16 @@ export type MobilePromptTemplate = { category: PromptCategory; inputType: PromptInputType; outputType: PromptOutputType; - builtIn: boolean; + isBuiltin: boolean; }; export type RunPromptInput = { templateId: string; noteId: string; workspaceId: string; + inputText?: string; imageUrl?: string; - parameters?: Record; + variables?: Record; }; export type RunPromptOutput = { @@ -29,6 +30,9 @@ export type RunPromptOutput = { outputType: PromptOutputType; model?: string; usage?: { promptTokens: number; completionTokens: number; totalTokens: number }; + approvalState?: string; + createdNoteId?: string; + createdArtifactId?: string; }; export async function listPromptTemplates(): Promise { diff --git a/web/src/app/(app)/prompts/page.tsx b/web/src/app/(app)/prompts/page.tsx index 040e5bb..4457c76 100644 --- a/web/src/app/(app)/prompts/page.tsx +++ b/web/src/app/(app)/prompts/page.tsx @@ -60,8 +60,8 @@ export default function PromptsPage() { ? templates : templates.filter((t) => t.category === activeCategory); - const builtIn = filtered.filter((t) => t.builtIn); - const custom = filtered.filter((t) => !t.builtIn); + const builtIn = filtered.filter((t) => t.isBuiltin); + const custom = filtered.filter((t) => !t.isBuiltin); return ( { diff --git a/web/src/components/SmartActionsPanel.test.tsx b/web/src/components/SmartActionsPanel.test.tsx index 2936d20..a859787 100644 --- a/web/src/components/SmartActionsPanel.test.tsx +++ b/web/src/components/SmartActionsPanel.test.tsx @@ -4,8 +4,8 @@ import { render, screen } from "@testing-library/react"; // Mock prompt-client vi.mock("@/lib/prompt-client", () => ({ listPromptTemplates: vi.fn().mockResolvedValue([ - { id: "t1", slug: "summarize", name: "Summarize", description: "Summarize note", category: "transform", inputType: "text", outputType: "new_note", builtIn: true }, - { id: "t2", slug: "bulletize", name: "Bullet Points", description: "Bullets", category: "transform", inputType: "text", outputType: "replace", builtIn: true }, + { id: "t1", slug: "summarize", name: "Summarize", description: "Summarize note", category: "transform", inputType: "text", outputType: "new_note", isBuiltin: true }, + { id: "t2", slug: "bulletize", name: "Bullet Points", description: "Bullets", category: "transform", inputType: "text", outputType: "replace", isBuiltin: true }, ]), runPrompt: vi.fn().mockResolvedValue({ content: "Result", templateSlug: "summarize", outputType: "new_note" }), suggestTags: vi.fn().mockResolvedValue(["tag1", "tag2"]), diff --git a/web/src/lib/prompt-client.ts b/web/src/lib/prompt-client.ts index ed8b75a..e564238 100644 --- a/web/src/lib/prompt-client.ts +++ b/web/src/lib/prompt-client.ts @@ -23,7 +23,7 @@ export async function getPromptTemplate(id: string): Promise { } export async function createPromptTemplate( - input: Omit, + input: Omit, ): Promise { const api = createNotesApiClient(); return api.fetch("/note-prompts", { diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index f26f67c..cc71003 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -177,9 +177,9 @@ export type NoteRelationshipDoc = { // ── Smart Actions / Prompt types ── -export type PromptCategory = "transform" | "extract" | "generate" | "analysis" | "vision" | "export" | "custom"; +export type PromptCategory = "transform" | "extract" | "generate" | "analyze" | "export"; export type PromptInputType = "text" | "image" | "text+image" | "multi-note"; -export type PromptOutputType = "new_note" | "artifact" | "update_note" | "replace" | "clipboard"; +export type PromptOutputType = "new_note" | "artifact" | "replace" | "inline"; export interface PromptTemplate { id: string; @@ -189,7 +189,7 @@ export interface PromptTemplate { category: PromptCategory; inputType: PromptInputType; outputType: PromptOutputType; - builtIn: boolean; + isBuiltin: boolean; systemPrompt?: string; userPromptTemplate?: string; } @@ -198,8 +198,9 @@ export interface RunPromptInput { templateId: string; noteId: string; workspaceId: string; + inputText?: string; imageUrl?: string; - parameters?: Record; + variables?: Record; } export interface RunPromptOutput {