Skip to content

Default Templates v1 #1126

Merged
duckduckhero merged 8 commits intomainfrom
default-templates-final
Jul 10, 2025
Merged

Default Templates v1 #1126
duckduckhero merged 8 commits intomainfrom
default-templates-final

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 10, 2025

📝 Walkthrough

Walkthrough

The changes update template handling and presentation in both the frontend and backend. The frontend modifies template labels, truncates template titles for display, and updates translation references. The backend removes a foreign key constraint, adjusts template listing to include all templates, and introduces a migration to insert default templates into the database.

Changes

Files/Paths Change Summary
apps/desktop/src/components/editor-area/floating-button.tsx Changed the label for the "auto" template option from "Hyprnote Default" to "No Template (Default)".
apps/desktop/src/components/editor-area/note-header/listen-button.tsx Truncates template titles >20 chars with ellipsis in dropdown; adds styling to dropdown; prevents text wrapping.
apps/desktop/src/locales/en/messages.po
apps/desktop/src/locales/ko/messages.po
Updated source code line references for translation entries; no changes to message strings or translations.
crates/db-user/src/lib.rs Added templates_migration_1.sql to the MIGRATIONS array (from 18 to 19 entries).
crates/db-user/src/templates_migration.sql Removed foreign key constraint from templates.user_id to humans.id.
crates/db-user/src/templates_migration_1.sql New migration script: inserts multiple default templates into the templates table using INSERT OR IGNORE.
crates/db-user/src/templates_ops.rs list_templates no longer filters by user_id; test expects 2 templates initially instead of 0.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant Backend
    participant Database

    User->>Frontend: Open template selection UI
    Frontend->>Backend: Request list_templates(user_id)
    Backend->>Database: SELECT * FROM templates
    Database-->>Backend: Return all templates (no user_id filter)
    Backend-->>Frontend: Return template list
    Frontend->>User: Display templates (truncate long titles, show "No Template (Default)")
Loading

Possibly related PRs

  • Template Selector Merge  #1089: Introduced the template selection UI and logic in the floating button component, directly related to the label change for the "auto" template option.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)
Updating git repository `https://github.com/RustAudio/cpal`

error: failed to load source for dependency cpal

Caused by:
Unable to update https://github.com/RustAudio/cpal?rev=51c3b43#51c3b43c

Caused by:
failed to create directory /usr/local/git/db/cpal-476cd1dd23dbc279

Caused by:
Permission denied (os error 13)

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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
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: 1

🔭 Outside diff range comments (1)
crates/db-user/src/templates_ops.rs (1)

89-104: Test logic is inconsistent and confusing.

The test expects 2 templates initially (line 89) but then expects only 1 template after inserting a new one (line 104). This doesn't make logical sense - after inserting a template, the count should increase, not decrease.

 let templates = db.list_templates(&human.id).await.unwrap();
 assert_eq!(templates.len(), 2);

 let _template = db
     .upsert_template(Template {
         id: uuid::Uuid::new_v4().to_string(),
         user_id: human.id.clone(),
         title: "test".to_string(),
         description: "test".to_string(),
         sections: vec![],
         tags: vec![],
     })
     .await
     .unwrap();

 let templates = db.list_templates(&human.id).await.unwrap();
-assert_eq!(templates.len(), 1);
+assert_eq!(templates.len(), 3);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e00062d and 63a7729.

📒 Files selected for processing (8)
  • apps/desktop/src/components/editor-area/floating-button.tsx (1 hunks)
  • apps/desktop/src/components/editor-area/note-header/listen-button.tsx (1 hunks)
  • apps/desktop/src/locales/en/messages.po (2 hunks)
  • apps/desktop/src/locales/ko/messages.po (2 hunks)
  • crates/db-user/src/lib.rs (2 hunks)
  • crates/db-user/src/templates_migration.sql (1 hunks)
  • crates/db-user/src/templates_migration_1.sql (1 hunks)
  • crates/db-user/src/templates_ops.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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".

**/*.{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".

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • apps/desktop/src/components/editor-area/floating-button.tsx
  • apps/desktop/src/components/editor-area/note-header/listen-button.tsx
  • crates/db-user/src/templates_ops.rs
  • crates/db-user/src/lib.rs
🧬 Code Graph Analysis (2)
apps/desktop/src/components/editor-area/note-header/listen-button.tsx (2)
packages/ui/src/components/ui/select.tsx (2)
  • SelectContent (174-174)
  • SelectItem (174-174)
plugins/windows/src/ext.rs (1)
  • title (140-152)
crates/db-user/src/templates_ops.rs (1)
crates/db-core/src/lib.rs (1)
  • conn (17-22)
⏰ 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: ci
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (8)
apps/desktop/src/components/editor-area/floating-button.tsx (1)

283-283: LGTM: Improved label clarity for template selection

The updated label "No Template (Default)" is more descriptive and clearer than the previous "Hyprnote Default", making it obvious to users that this option will proceed without applying any template.

crates/db-user/src/templates_migration.sql (1)

1-8: Foreign key constraint removal confirmed

No FOREIGN KEY or REFERENCES clauses are present in crates/db-user/src/templates_migration.sql, confirming that the user_id foreign key to the humans table has been removed. No further action required.

apps/desktop/src/locales/en/messages.po (1)

896-896: Routine localization reference updates

These line number updates correctly reflect the new positions of the "Pause" and "Stop" messages in the source code after recent changes to listen-button.tsx.

Also applies to: 1054-1054

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

896-896: Routine localization reference updates

These line number updates correctly reflect the new positions of the "Pause" and "Stop" messages in the source code, maintaining consistency with the English localization file.

Also applies to: 1054-1054

crates/db-user/src/lib.rs (1)

132-132: LGTM: New template migration properly added and verified

  • The MIGRATIONS array has been extended to 19 entries, including the new template migration.
  • Verified that crates/db-user/src/templates_migration_1.sql exists and contains 197 lines.
apps/desktop/src/components/editor-area/note-header/listen-button.tsx (2)

339-339: Good UX improvements for template selection dropdown.

The added CSS classes improve the dropdown experience by limiting height, enabling scrolling, and maintaining consistent width with the trigger.


343-352: Template title truncation logic is well-implemented.

The truncation logic properly handles long template titles and the whitespace-nowrap class ensures consistent layout. The 20-character limit with ellipsis provides a good balance between readability and UI consistency.

crates/db-user/src/templates_migration_1.sql (1)

1-197: Approve placeholder user_id usage

Verified that the templates table defines user_id as TEXT NOT NULL with no foreign‐key constraint, so using "placeholder" does not violate any schema rules.

Comment on lines +10 to +12
let _user_id = user_id.into();

let mut rows = conn.query("SELECT * FROM templates", ()).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unused parameter or update method signature.

The user_id parameter is no longer used in the query logic. Consider either:

  1. Removing the parameter entirely if user-specific filtering is no longer needed
  2. Updating the method documentation to clarify the behavioral change
 pub async fn list_templates(
     &self,
-    user_id: impl Into<String>,
 ) -> Result<Vec<Template>, crate::Error> {
     let conn = self.conn()?;

-    let _user_id = user_id.into();
-
     let mut rows = conn.query("SELECT * FROM templates", ()).await?;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let _user_id = user_id.into();
let mut rows = conn.query("SELECT * FROM templates", ()).await?;
pub async fn list_templates(
&self,
) -> Result<Vec<Template>, crate::Error> {
let conn = self.conn()?;
let mut rows = conn.query("SELECT * FROM templates", ()).await?;
🤖 Prompt for AI Agents
In crates/db-user/src/templates_ops.rs around lines 10 to 12, the user_id
parameter is declared but not used in the function logic. To fix this, either
remove the user_id parameter from the function signature if it is no longer
needed, or update the method documentation to clearly state that user-specific
filtering has been removed and the parameter is unused.

@duckduckhero duckduckhero merged commit 8d8b1c2 into main Jul 10, 2025
6 checks passed
@duckduckhero duckduckhero deleted the default-templates-final branch July 10, 2025 08:13
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