Migrate tinybase to sqlite, starting from templates#5032
Merged
Conversation
✅ Deploy Preview for unsigned-char ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote canceled.
|
✅ Deploy Preview for char-cli-web canceled.
|
There was a problem hiding this comment.
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.
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.
2041bb9 to
dab8fbc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.