Skip to content

Minor fixes 0810#1309

Merged
duckduckhero merged 3 commits intomainfrom
minor-fixes-0810
Aug 10, 2025
Merged

Minor fixes 0810#1309
duckduckhero merged 3 commits intomainfrom
minor-fixes-0810

Conversation

@duckduckhero
Copy link
Contributor

@duckduckhero duckduckhero commented Aug 10, 2025

Summary by cubic

Improved the template editor to sync input fields with local state and updated the system prompt to prevent generating content not found in the source material.

  • Bug Fixes

    • Fixed issues with template title and description fields not updating correctly when switching templates.
    • Updated English and Korean translation files to match code changes.
  • Prompt Update

    • Changed the system prompt to require that only information present in the source notes or transcript is included, and to state explicitly when information is missing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 10, 2025

📝 Walkthrough

Walkthrough

This update revises the local state management and change handlers in the template editor React component, updates line number references in English and Korean locale files, strengthens the instructions in a Jinja template to require strict adherence to source material when generating content sections, and adds analytics event tracking to selection popover and finder view components.

Changes

Cohort / File(s) Change Summary
Template Editor State Refactor
apps/desktop/src/components/settings/views/template.tsx
Refactored to use local state for template title (without emoji) and description, synchronized with the template prop. Change handlers now update local state and propagate combined values to the parent. Removed useCallback for handlers. No change to component signature.
Locale Reference Updates (English)
apps/desktop/src/locales/en/messages.po
Updated source code reference line numbers for several translation message entries to reflect changes in the template editor component. No changes to message content.
Locale Reference Updates (Korean)
apps/desktop/src/locales/ko/messages.po
Updated source code reference line numbers for multiple Korean translation entries, matching the line shifts in the template editor. No changes to translation content.
Jinja Template Instructions Update
crates/template/assets/enhance.system.jinja
Expanded and clarified instructions to require strict adherence to user-provided section descriptions, extraction only of information present in source material, and explicit acknowledgment when information is missing. Forbids inferring or generating unsupported content.
Analytics Tracking in Text Selection Popover
apps/desktop/src/components/editor-area/text-selection-popover.tsx
Added analytics event "source_view_clicked" on clicking the "Source" button, sending user ID with the event before invoking existing callbacks. No other logic changes.
Analytics Tracking in Finder View
apps/desktop/src/routes/app.finder.tsx
Added analytics event tracking for view changes to "tags", "contact", or "table" views, sending corresponding event names and user ID before updating the view state.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Parent Component
    participant TemplateEditor as TemplateEditor
    participant User as User

    User->>TemplateEditor: Change title/emoji/description
    TemplateEditor->>TemplateEditor: Update local state
    TemplateEditor->>Parent: Call onTemplateUpdate with updated values
    Parent-->>TemplateEditor: (Propagate new template prop if needed)
    TemplateEditor->>TemplateEditor: useEffect syncs local state if template.id changes
Loading
sequenceDiagram
    participant User as User
    participant TextSelectionPopover as TextSelectionPopover
    participant Analytics as AnalyticsService

    User->>TextSelectionPopover: Click "Source" button
    TextSelectionPopover->>Analytics: Send "source_view_clicked" event with userId
    TextSelectionPopover->>TextSelectionPopover: Invoke onAnnotate callback
    TextSelectionPopover->>TextSelectionPopover: Clear selection state
Loading
sequenceDiagram
    participant User as User
    participant FinderView as FinderView
    participant Analytics as AnalyticsService

    User->>FinderView: Change view to "tags"/"contact"/"table"
    FinderView->>Analytics: Send corresponding event with userId
    FinderView->>FinderView: Update URL search params with new view
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • changed to system instructions #1296: Refactors label and placeholder text for the description field in the template editor and updates localization strings, overlapping with this PR's changes to the template description field UI and state handling.

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch minor-fixes-0810

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

No issues found across 4 files. Review in cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (2)
apps/desktop/src/components/settings/views/template.tsx (2)

83-86: Remove debug logs (PII risk + noisy in production)

Console logs can leak user data and clutter logs. Remove or guard behind a dev flag.

-  console.log("now in template editor");
-  console.log("template: ", template);
-  console.log("isBuiltinTemplate: ", isBuiltinTemplate);
+  // Consider using a scoped logger with DEBUG level in development only.

88-95: Emoji regex likely unreliable across runtimes; multi-codepoint emojis not handled

Using \p{Emoji} is not consistently supported in JS RegExp property escapes, and it won’t capture multi-codepoint/grapheme emoji sequences (e.g., family, skin tones). Prefer a robust approach.

Option A (robust): use the emoji-regex RGI set.

+// import emojiRegex from "emoji-regex/RGI_Emoji.js";
-  const extractEmojiFromTitle = (title: string) => {
-    const emojiMatch = title.match(/^(\p{Emoji})\s*/u);
-    return emojiMatch ? emojiMatch[1] : "📄";
-  };
+  const extractEmojiFromTitle = (title: string) => {
+    // @ts-ignore: depends on emoji-regex package
+    const re = emojiRegex();
+    const m = title.match(re);
+    return m && m.index === 0 ? m[0] : "📄";
+  };
 
-  const getTitleWithoutEmoji = (title: string) => {
-    return title.replace(/^(\p{Emoji})\s*/u, "");
-  };
+  const getTitleWithoutEmoji = (title: string) => {
+    // @ts-ignore
+    const re = emojiRegex();
+    const m = title.match(re);
+    return m && m.index === 0 ? title.slice(m[0].length).replace(/^\s+/, "") : title;
+  };

Option B (no dependency): use Extended_Pictographic and ZWJ chain heuristic.

-  const extractEmojiFromTitle = (title: string) => {
-    const emojiMatch = title.match(/^(\p{Emoji})\s*/u);
-    return emojiMatch ? emojiMatch[1] : "📄";
-  };
+  const LEADING_EMOJI_RE = /^\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?)*\s*/u;
+  const extractEmojiFromTitle = (title: string) => {
+    const m = title.match(LEADING_EMOJI_RE);
+    return m ? m[0].trim() : "📄";
+  };
 
-  const getTitleWithoutEmoji = (title: string) => {
-    return title.replace(/^(\p{Emoji})\s*/u, "");
-  };
+  const getTitleWithoutEmoji = (title: string) => {
+    return title.replace(LEADING_EMOJI_RE, "");
+  };
🧹 Nitpick comments (7)
crates/template/assets/enhance.system.jinja (1)

36-37: Fidelity rules are solid; consider standardizing the fallback phrasing

The stricter guidance is great. To ensure consistent outputs, suggest prescribing the exact sentence to use when a section has no relevant info.

-CRITICAL: Only include information that exists in the source material. If the transcript or raw notes do not contain information relevant to a specific section, explicitly say so. Do not generate, infer, or create content that is not directly supported by the source material.
+CRITICAL: Only include information that exists in the source material. If the transcript or raw notes do not contain information relevant to a specific section, explicitly say so using the sentence: "No relevant information found in the provided materials." Do not generate, infer, or create content that is not directly supported by the source material.
apps/desktop/src/components/settings/views/template.tsx (6)

97-100: Local controlled state: good; consider trimming and normalizing

Controlled fields are correct. Consider trimming leading spaces when composing title and ensuring we don’t persist trailing space when title is empty.

-  const [titleText, setTitleText] = useState(() => getTitleWithoutEmoji(template.title || ""));
+  const [titleText, setTitleText] = useState(() => getTitleWithoutEmoji(template.title || "").trim());

103-109: Sync only on id may miss upstream edits to same template

If parent updates title/description for the same template id (e.g., external rename), local state won’t reflect it. Consider syncing on value changes with guard checks.

-  useEffect(() => {
-    setTitleText(getTitleWithoutEmoji(template.title || ""));
-    setDescriptionText(template.description || "");
-    setSelectedEmoji(extractEmojiFromTitle(template.title || ""));
-  }, [template.id]);
+  useEffect(() => {
+    const nextTitle = getTitleWithoutEmoji(template.title || "");
+    if (nextTitle !== titleText) setTitleText(nextTitle);
+    const nextDesc = template.description || "";
+    if (nextDesc !== descriptionText) setDescriptionText(nextDesc);
+    const nextEmoji = extractEmojiFromTitle(template.title || "");
+    if (nextEmoji !== selectedEmoji) setSelectedEmoji(nextEmoji);
+    // eslint-disable-next-line react-hooks/exhaustive-deps
+  }, [template.title, template.description]);

110-118: Title updates on every keystroke may cause heavy upstream churn

Pushing updates on each keypress can be expensive if it fans out (API, persistence). Consider debouncing or committing on blur/enter.

-  const handleChangeTitle = (e: React.ChangeEvent<HTMLInputElement>) => {
+  const handleChangeTitle = (e: React.ChangeEvent<HTMLInputElement>) => {
     const newTitle = e.target.value;
     setTitleText(newTitle); // Update local state immediately
-    const fullTitle = selectedEmoji + " " + newTitle;
-    onTemplateUpdate({ ...template, title: fullTitle });
+    // Option A: commit on blur or Enter; Option B: debounce
+    // const fullTitle = `${selectedEmoji} ${newTitle}`.trim();
+    // debouncedUpdate({ ...template, title: fullTitle });
   };

If helpful, I can wire a small useDebouncedCallback here.


119-125: Ensure clean composition and avoid trailing space when title is empty

Minor UX polish: avoid saving "📄 " when titleText is empty.

-    const fullTitle = emoji + " " + titleText; // Use local state
+    const fullTitle = (emoji + " " + titleText).trim();

126-131: Description updates on each keystroke: consider debouncing

Same rationale as title; optional, depending on persistence costs.

-    onTemplateUpdate({ ...template, description: newDescription });
+    // debouncedUpdate({ ...template, description: newDescription });

153-153: Comment style: prefer “why” over “what” per guidelines

“This is unchanged” states what. Either remove it or explain why it’s intentionally unchanged (e.g., to preserve existing UX).

-            {/* Emoji Selector - unchanged */}
+            {/* Keep existing emoji grid UX for familiarity; only binding changed to local state */}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06b5d60 and 6a32375.

📒 Files selected for processing (4)
  • apps/desktop/src/components/settings/views/template.tsx (5 hunks)
  • apps/desktop/src/locales/en/messages.po (7 hunks)
  • apps/desktop/src/locales/ko/messages.po (7 hunks)
  • crates/template/assets/enhance.system.jinja (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/settings/views/template.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-latest)
🔇 Additional comments (16)
apps/desktop/src/locales/en/messages.po (7)

335-338: Ref update: “Add a system instruction...” looks correct

Reference to template.tsx:236 matches the code.


675-680: Ref update: “Delete” looks correct

Reference to template.tsx:218 matches the code.


717-720: Ref update: “Duplicate” looks correct

Reference to template.tsx:206 matches the code.


733-736: Ref update: “Emoji” looks correct

Reference to template.tsx:168 matches the code.


1312-1315: Ref update: “Sections” looks correct

Reference to template.tsx:243 matches the code.


1437-1440: Ref update: “System Instruction” looks correct

Reference to template.tsx:230 matches the code.


1541-1544: No off-by-one error: “Untitled Template” is correctly referenced at line 192
The placeholder={t\Untitled Template`}call is on line 192 inapps/desktop/src/components/settings/views/template.tsx, so the .po` entry is accurate.

apps/desktop/src/locales/ko/messages.po (7)

335-338: Ref update: “Add a system instruction...” looks correct

Reference to template.tsx:236 matches the code. msgstr intentionally empty is acceptable if pending translation.


675-680: Ref update: “Delete” looks correct

Reference to template.tsx:218 matches the code.


717-720: Ref update: “Duplicate” looks correct

Reference to template.tsx:206 matches the code.


733-736: Ref update: “Emoji” looks correct

Reference to template.tsx:168 matches the code.


1312-1315: Ref update: “Sections” looks correct

Reference to template.tsx:243 matches the code.


1437-1440: Ref update: “System Instruction” looks correct

Reference to template.tsx:230 matches the code.


1541-1544: No off-by-one: Untitled Template is correctly referenced on line 192
Confirmed that the placeholder={t\Untitled Template`}call resides on line 192 intemplate.tsx, so the existing #: …/template.tsx:192entry inmessages.po` is accurate.

apps/desktop/src/components/settings/views/template.tsx (2)

189-189: Controlled Input binding: LGTM

Binding to titleText aligns with local state.


234-234: Controlled Textarea binding: LGTM

Binding to descriptionText aligns with local state.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/desktop/src/components/editor-area/text-selection-popover.tsx (1)

98-101: Guard analytics call and confirm identifier semantics

  • Guard against undefined userId to avoid sending events with an invalid distinct_id.
  • Please confirm userId is a stable, non-PII identifier permitted by your analytics data policy.

Proposed minimal guard:

-    analyticsCommands.event({
-      event: "source_view_clicked",
-      distinct_id: userId,
-    });
+    if (userId) {
+      analyticsCommands.event({
+        event: "source_view_clicked",
+        distinct_id: userId,
+      });
+    }
apps/desktop/src/routes/app.finder.tsx (2)

181-196: Reduce duplication and guard userId in analytics dispatch

Current if/else chain is repetitive. You can map views to event names and gate on userId.

-    if (newView === "tags") {
-      analyticsCommands.event({
-        event: "finder_tags_view",
-        distinct_id: userId,
-      });
-    } else if (newView === "contact") {
-      analyticsCommands.event({
-        event: "finder_contact_view",
-        distinct_id: userId,
-      });
-    } else if (newView === "table") {
-      analyticsCommands.event({
-        event: "finder_table_view",
-        distinct_id: userId,
-      });
-    }
+    const eventName = (
+      { tags: "finder_tags_view", contact: "finder_contact_view", table: "finder_table_view" } as const
+    )[newView];
+    if (eventName && userId) {
+      analyticsCommands.event({ event: eventName, distinct_id: userId });
+    }

181-196: Consider a single event with view as a property

To simplify downstream analysis and reduce event cardinality, consider emitting one event (e.g., finder_view_changed) with a view property instead of multiple event names (if supported by your analytics SDK).

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a32375 and 0c6490b.

📒 Files selected for processing (2)
  • apps/desktop/src/components/editor-area/text-selection-popover.tsx (3 hunks)
  • apps/desktop/src/routes/app.finder.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/editor-area/text-selection-popover.tsx
  • apps/desktop/src/routes/app.finder.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (4)
apps/desktop/src/components/editor-area/text-selection-popover.tsx (2)

5-6: Imports LGTM

useHypr and analyticsCommands are both used. No unused imports.


25-25: User ID from context

Access via useHypr is consistent with the rest of the app. No issues spotted.

apps/desktop/src/routes/app.finder.tsx (2)

8-8: Import usage confirmed

analyticsCommands is used below. No unused imports.


181-196: Intentional omission? Track folder/calendar as well

Are folder and calendar intentionally excluded from analytics? If not, consider adding them for coverage parity.

@duckduckhero duckduckhero merged commit 08cde8e into main Aug 10, 2025
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 29, 2025
@ComputelessComputer ComputelessComputer deleted the minor-fixes-0810 branch December 14, 2025 15:23
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