File tree Expand file tree Collapse file tree
session/components/note-input
store/tinybase/persister/session/save Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type { LanguageModel } from "ai";
33import { commands as analyticsCommands } from "@hypr/plugin-analytics" ;
44
55import { getEligibility } from "./eligibility" ;
6+ import { isGeneratedNoteTitle } from "./title" ;
67
78import type { Store as MainStore } from "~/store/tinybase/store/main" ;
89import { INDEXES } from "~/store/tinybase/store/main" ;
@@ -37,25 +38,11 @@ type EnhancerDeps = {
3738 getSelectedTemplateId : ( ) => string | undefined ;
3839} ;
3940
40- const UUID_TITLE_RE =
41- / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i;
42- const ISO_TITLE_RE = / ^ \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } / ;
43-
4441function shouldHydrateTemplateTitle (
4542 currentTitle : string | null | undefined ,
4643 templateId : string ,
4744) {
48- const title = currentTitle ?. trim ( ) ;
49- if ( ! title ) {
50- return true ;
51- }
52-
53- return (
54- title === "Summary" ||
55- title === templateId ||
56- UUID_TITLE_RE . test ( title ) ||
57- ISO_TITLE_RE . test ( title )
58- ) ;
45+ return isGeneratedNoteTitle ( currentTitle , templateId ) ;
5946}
6047
6148let instance : EnhancerService | null = null ;
Original file line number Diff line number Diff line change 1+ const UUID_TITLE_RE =
2+ / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i;
3+ const ISO_TITLE_RE = / ^ \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } / ;
4+
5+ export function isGeneratedNoteTitle (
6+ title : string | null | undefined ,
7+ templateId ?: string ,
8+ ) : boolean {
9+ const trimmed = title ?. trim ( ) ;
10+ if ( ! trimmed ) {
11+ return true ;
12+ }
13+
14+ return (
15+ trimmed === "Summary" ||
16+ ( ! ! templateId && trimmed === templateId ) ||
17+ UUID_TITLE_RE . test ( trimmed ) ||
18+ ISO_TITLE_RE . test ( trimmed )
19+ ) ;
20+ }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import { useAITaskTask } from "~/ai/hooks";
3737import { useLanguageModel , useLLMConnectionStatus } from "~/ai/hooks" ;
3838import { extractPlainText } from "~/search/contexts/engine/utils" ;
3939import { getEnhancerService } from "~/services/enhancer" ;
40+ import { isGeneratedNoteTitle } from "~/services/enhancer/title" ;
4041import { useHasTranscript } from "~/session/components/shared" ;
4142import { useEnsureDefaultSummary } from "~/session/hooks/useEnhancedNotes" ;
4243import {
@@ -90,10 +91,6 @@ function getStoredNoteMarkdown(content: string | undefined) {
9091 return json2md ( parseJsonContent ( trimmed ) ) . trim ( ) ;
9192}
9293
93- const UUID_TITLE_RE =
94- / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i;
95- const ISO_TITLE_RE = / ^ \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } / ;
96-
9794function getEnhancedNoteTitle ( {
9895 rawTitle,
9996 templateTitle,
@@ -108,13 +105,7 @@ function getEnhancedNoteTitle({
108105 return templateTitle || "Summary" ;
109106 }
110107
111- const isGeneratedTitle =
112- title === "Summary" ||
113- title === templateId ||
114- UUID_TITLE_RE . test ( title ) ||
115- ISO_TITLE_RE . test ( title ) ;
116-
117- if ( isGeneratedTitle && templateTitle ) {
108+ if ( isGeneratedNoteTitle ( title , templateId ) && templateTitle ) {
118109 return templateTitle ;
119110 }
120111
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 type TablesContent ,
1313 type WriteOperation ,
1414} from "~/store/tinybase/persister/shared" ;
15+ import { isGeneratedNoteTitle } from "~/services/enhancer/title" ;
1516import type { Store } from "~/store/tinybase/store/main" ;
1617
1718type DocumentItem = [ ParsedDocument , string ] ;
@@ -142,8 +143,11 @@ function getEnhancedNoteFilename(
142143 enhancedNote : ReturnType < typeof iterateTableRows < "enhanced_notes" > > [ number ] ,
143144) : string {
144145 if ( enhancedNote . template_id ) {
146+ const title = enhancedNote . title as string | undefined ;
147+ const useTitle =
148+ title && ! isGeneratedNoteTitle ( title , enhancedNote . template_id ) ;
145149 const safeName = sanitizeFilename (
146- enhancedNote . title || enhancedNote . template_id ,
150+ useTitle ? title : enhancedNote . template_id ,
147151 ) ;
148152 return `${ safeName } .md` ;
149153 }
You can’t perform that action at this time.
0 commit comments