Skip to content

Migrate tinybase to sqlite, starting from templates#5032

Merged
yujonglee merged 8 commits intomainfrom
migrate-template-to-sqlite
Apr 14, 2026
Merged

Migrate tinybase to sqlite, starting from templates#5032
yujonglee merged 8 commits intomainfrom
migrate-template-to-sqlite

Conversation

@yujonglee
Copy link
Copy Markdown
Contributor

No description provided.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2026

Deploy Preview for unsigned-char ready!

Name Link
🔨 Latest commit fae5772
🔍 Latest deploy log https://app.netlify.com/projects/unsigned-char/deploys/69ddeb537737db0008684c30
😎 Deploy Preview https://deploy-preview-5032--unsigned-char.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit fae5772
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/69ddeb538c5add0008363d5b

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 14, 2026

Deploy Preview for char-cli-web canceled.

Name Link
🔨 Latest commit fae5772
🔍 Latest deploy log https://app.netlify.com/projects/char-cli-web/deploys/69ddeb53c9918f000850e055

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Filename uses default title instead of template title
    • Updated getEnhancedNoteFilename to detect generated placeholder titles ("Summary", UUID, ISO, template_id) via the shared isGeneratedNoteTitle utility and fall back to template_id for the filename instead of using the not-yet-hydrated title.
  • ✅ Fixed: Duplicated regex constants across two files
    • Extracted UUID_TITLE_RE, ISO_TITLE_RE, and the generated-title detection logic into a shared services/enhancer/title.ts module, removing the duplicated definitions from both enhancer/index.ts and header.tsx.

Create PR

Or push these changes by commenting:

@cursor push 9008e0e2d3
Preview (9008e0e2d3)
diff --git a/apps/desktop/src/services/enhancer/index.ts b/apps/desktop/src/services/enhancer/index.ts
--- a/apps/desktop/src/services/enhancer/index.ts
+++ b/apps/desktop/src/services/enhancer/index.ts
@@ -3,6 +3,7 @@
 import { commands as analyticsCommands } from "@hypr/plugin-analytics";
 
 import { getEligibility } from "./eligibility";
+import { isGeneratedNoteTitle } from "./title";
 
 import type { Store as MainStore } from "~/store/tinybase/store/main";
 import { INDEXES } from "~/store/tinybase/store/main";
@@ -37,25 +38,11 @@
   getSelectedTemplateId: () => string | undefined;
 };
 
-const UUID_TITLE_RE =
-  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
-const ISO_TITLE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
-
 function shouldHydrateTemplateTitle(
   currentTitle: string | null | undefined,
   templateId: string,
 ) {
-  const title = currentTitle?.trim();
-  if (!title) {
-    return true;
-  }
-
-  return (
-    title === "Summary" ||
-    title === templateId ||
-    UUID_TITLE_RE.test(title) ||
-    ISO_TITLE_RE.test(title)
-  );
+  return isGeneratedNoteTitle(currentTitle, templateId);
 }
 
 let instance: EnhancerService | null = null;

diff --git a/apps/desktop/src/services/enhancer/title.ts b/apps/desktop/src/services/enhancer/title.ts
new file mode 100644
--- /dev/null
+++ b/apps/desktop/src/services/enhancer/title.ts
@@ -1,0 +1,20 @@
+const UUID_TITLE_RE =
+  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+const ISO_TITLE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
+
+export function isGeneratedNoteTitle(
+  title: string | null | undefined,
+  templateId?: string,
+): boolean {
+  const trimmed = title?.trim();
+  if (!trimmed) {
+    return true;
+  }
+
+  return (
+    trimmed === "Summary" ||
+    (!!templateId && trimmed === templateId) ||
+    UUID_TITLE_RE.test(trimmed) ||
+    ISO_TITLE_RE.test(trimmed)
+  );
+}

diff --git a/apps/desktop/src/session/components/note-input/header.tsx b/apps/desktop/src/session/components/note-input/header.tsx
--- a/apps/desktop/src/session/components/note-input/header.tsx
+++ b/apps/desktop/src/session/components/note-input/header.tsx
@@ -37,6 +37,7 @@
 import { useLanguageModel, useLLMConnectionStatus } from "~/ai/hooks";
 import { extractPlainText } from "~/search/contexts/engine/utils";
 import { getEnhancerService } from "~/services/enhancer";
+import { isGeneratedNoteTitle } from "~/services/enhancer/title";
 import { useHasTranscript } from "~/session/components/shared";
 import { useEnsureDefaultSummary } from "~/session/hooks/useEnhancedNotes";
 import {
@@ -90,10 +91,6 @@
   return json2md(parseJsonContent(trimmed)).trim();
 }
 
-const UUID_TITLE_RE =
-  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
-const ISO_TITLE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
-
 function getEnhancedNoteTitle({
   rawTitle,
   templateTitle,
@@ -108,13 +105,7 @@
     return templateTitle || "Summary";
   }
 
-  const isGeneratedTitle =
-    title === "Summary" ||
-    title === templateId ||
-    UUID_TITLE_RE.test(title) ||
-    ISO_TITLE_RE.test(title);
-
-  if (isGeneratedTitle && templateTitle) {
+  if (isGeneratedNoteTitle(title, templateId) && templateTitle) {
     return templateTitle;
   }
 

diff --git a/apps/desktop/src/store/tinybase/persister/session/save/note.ts b/apps/desktop/src/store/tinybase/persister/session/save/note.ts
--- a/apps/desktop/src/store/tinybase/persister/session/save/note.ts
+++ b/apps/desktop/src/store/tinybase/persister/session/save/note.ts
@@ -12,6 +12,7 @@
   type TablesContent,
   type WriteOperation,
 } from "~/store/tinybase/persister/shared";
+import { isGeneratedNoteTitle } from "~/services/enhancer/title";
 import type { Store } from "~/store/tinybase/store/main";
 
 type DocumentItem = [ParsedDocument, string];
@@ -142,8 +143,11 @@
   enhancedNote: ReturnType<typeof iterateTableRows<"enhanced_notes">>[number],
 ): string {
   if (enhancedNote.template_id) {
+    const title = enhancedNote.title as string | undefined;
+    const useTitle =
+      title && !isGeneratedNoteTitle(title, enhancedNote.template_id);
     const safeName = sanitizeFilename(
-      enhancedNote.title || enhancedNote.template_id,
+      useTitle ? title : enhancedNote.template_id,
     );
     return `${safeName}.md`;
   }

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread apps/desktop/src/store/tinybase/persister/session/save/note.ts
Comment thread apps/desktop/src/session/components/note-input/header.tsx
Comment thread apps/desktop/src/services/enhancer/index.ts
@yujonglee yujonglee force-pushed the migrate-template-to-sqlite branch from 2041bb9 to dab8fbc Compare April 14, 2026 07:15
@yujonglee yujonglee merged commit 040e4eb into main Apr 14, 2026
23 of 25 checks passed
@yujonglee yujonglee deleted the migrate-template-to-sqlite branch April 14, 2026 07:26
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fae5772. Configure here.

Comment thread apps/desktop/src/templates/queries.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant