Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more insertAt options #69

Merged
merged 9 commits into from
Sep 11, 2024
Merged

Add more insertAt options #69

merged 9 commits into from
Sep 11, 2024

Conversation

justyns
Copy link
Owner

@justyns justyns commented Sep 11, 2024

Related to #59

We can now replace selected text, current item/paragraph, and there's a "smart" option that tries to do what's best.

ai-smart-rewrite

Summary by CodeRabbit

  • New Features

    • Added new sections to the documentation, including "What are LLMs?", "Requirements", "Development Status", and "Getting Started" to enhance user guidance.
    • Expanded functionality of text insertion options in the plugin for more flexible text manipulation based on user selection.
  • Documentation

    • Restructured and expanded documentation for the SilverBullet AI plugin to improve clarity and user experience.
  • Bug Fixes

    • Enhanced error handling in text insertion functions to improve robustness and user notifications.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

Walkthrough

The pull request introduces enhancements to the documentation and functionality of the SilverBullet AI plugin. Key changes include the restructuring of documentation to clarify the integration of Large Language Models (LLMs) and the addition of new utility functions for text manipulation. The insertAiPromptFromTemplate function has been expanded to support new insertion types, while error handling has been improved. Additionally, a new function, getParagraph, has been implemented to identify paragraphs based on cursor position, enhancing the overall capabilities of the plugin.

Changes

Files Change Summary
docs/index.md Restructured documentation for the SilverBullet AI plugin, adding sections on LLMs, requirements, and getting started.
src/editorUtils.ts Added getParagraph function to identify paragraphs based on cursor position.
src/prompts.ts Enhanced insertAiPromptFromTemplate function with new insertion types and improved error handling.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b385b8a and 1672c11.

Files selected for processing (2)
  • docs/index.md (1 hunks)
  • src/prompts.ts (5 hunks)
Additional context used
Path-based instructions (2)
docs/index.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

src/prompts.ts (1)

Pattern **/*.ts: Review these typescript files for best practices, readability, and DRY.

Additional comments not posted (6)
docs/index.md (2)

5-7: LGTM!

The new section "What are LLMs?" provides a clear and concise explanation of Large Language Models, enhancing the reader's understanding of the technology behind the plugin.


9-33: Great additions to the documentation!

The new sections "Requirements", "Development Status", and "Getting Started" significantly improve the documentation's structure and user-friendliness:

  • The "Requirements" section clearly outlines the necessary components for using the plugin, aiding users in setting up the tool effectively.
  • The "Development Status" section encourages user engagement by inviting them to report issues and share feature ideas, fostering a community-driven approach to development.
  • The "Getting Started" section provides a clear pathway for new users to begin using the plugin, enhancing the overall user experience.

These changes make the documentation more informative and accessible to users.

src/prompts.ts (4)

15-15: LGTM!

The new import statement for getPageLength, getParagraph, and getSelectedText from ./editorUtils.ts is necessary to support the additional insertion types and improve the functionality of the insertAiPromptFromTemplate function.


156-172: LGTM!

The new local variables, such as currentParagraph, selectedText, smartReplaceType, and smartReplaceText, are necessary to store and manage data related to the new insertion types. These variables improve the function's ability to handle various text manipulation scenarios, making it more versatile and user-friendly.


185-192: Great improvement in error handling!

The enhanced error handling with try-catch blocks around critical operations, such as fetching the current page text, cursor position, current item, current paragraph, and selected text, significantly improves the robustness of the insertAiPromptFromTemplate function.

By logging any issues encountered during these critical operations and communicating them to the user through notifications, the function can gracefully handle errors and provide a better user experience.

Also applies to: 226-227, 236-242, 252-254


381-384: LGTM!

The additional properties selectedText, currentParagraph, smartReplaceType, and smartReplaceText in the globalMetadata object provide more context for rendering templates and enriching chat messages. These changes support the new insertion types and improve the overall functionality of the insertAiPromptFromTemplate function by allowing for more flexible and context-aware text manipulation.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Outside diff range and nitpick comments (3)
docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md (1)

15-24: Refine the user instructions and make the assistant responses more engaging.

Consider making the following improvements:

  1. Simplify the user instructions at line 24 to make them more concise. For example:
Rewrite the text, correcting grammar and improving clarity. Preserve meaning, facts and formatting. Return only the rewritten text.
  1. Make the assistant responses more engaging by adding personality. For example, at line 16:
**assistant**: Great! What's the title of the note you'd like me to help with?
docs/index.md (1)

34-34: Consider making the backup warning more prominent.

The warning about backing up notes before using the plug is important. Consider making it more prominent by:

  • Moving it to the top of the document, perhaps right after the "Requirements" section.
  • Using a more eye-catching formatting, like a colored box or a different font.

This will ensure users don't miss this critical piece of advice.

Tools
LanguageTool

[grammar] ~34-~34: The word “backup” is a noun. The verb is spelled with a space.
Context: ...I Core Library]] > Warning: Please backup your notes before using this plug. It i...

(NOUN_VERB_CONFUSION)

src/editorUtils.ts (1)

86-126: Optimize the function and remove debugging statements.

The function correctly identifies and returns the paragraph containing the cursor position. However, consider the following improvements:

  1. Remove or comment out the console log statements used for debugging purposes.
  2. Optimize the function by avoiding the use of slice and join methods inside the loops. Instead, you can keep track of the start and end line numbers and use them to extract the paragraph text outside the loops.

Here's an optimized version of the function:

export function getParagraph(text: string, pos: number): {
  from: number;
  to: number;
  text: string;
} {
  const lines = text.split("\n");
  let currentPos = 0;
  let start = 0;
  let end = text.length;
+  let startLine = 0;
+  let endLine = lines.length - 1;

  for (let i = 0; i < lines.length; i++) {
    const lineLength = lines[i].length + 1;

    if (currentPos <= pos && pos < currentPos + lineLength) {
-      // Look backwards for the start of the paragraph
-      console.log("Looking backwards for the start of the paragraph");
      for (let j = i; j >= 0; j--) {
        if (j === 0 || lines[j - 1].trim() === "") {
-          start = j === 0 ? 0 : lines.slice(0, j).join("\n").length + 1;
+          startLine = j;
          break;
        }
      }
-      // Look forwards for the end of the paragraph
-      console.log("Looking forwards for the end of the paragraph");
      for (let k = i; k < lines.length; k++) {
        if (k === lines.length - 1 || lines[k + 1].trim() === "") {
-          end = lines.slice(0, k + 1).join("\n").length;
+          endLine = k;
          break;
        }
      }
      break;
    }
    currentPos += lineLength;
  }
-  console.log("Found paragraph", text.slice(start, end));
+  start = startLine === 0 ? 0 : lines.slice(0, startLine).join("\n").length + 1;
+  end = lines.slice(0, endLine + 1).join("\n").length;
  return {
    from: start,
    to: end,
    text: text.slice(start, end),
  };
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 59adc08 and b385b8a.

Files selected for processing (7)
  • docs/Changelog.md (2 hunks)
  • docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md (1 hunks)
  • docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md (1 hunks)
  • docs/Templated Prompts.md (1 hunks)
  • docs/index.md (1 hunks)
  • src/editorUtils.ts (1 hunks)
  • src/prompts.ts (5 hunks)
Additional context used
Path-based instructions (7)
docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

docs/index.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

src/editorUtils.ts (1)

Pattern **/*.ts: Review these typescript files for best practices, readability, and DRY.

docs/Templated Prompts.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

docs/Changelog.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

src/prompts.ts (1)

Pattern **/*.ts: Review these typescript files for best practices, readability, and DRY.

LanguageTool
docs/index.md

[grammar] ~34-~34: The word “backup” is a noun. The verb is spelled with a space.
Context: ...I Core Library]] > Warning: Please backup your notes before using this plug. It i...

(NOUN_VERB_CONFUSION)

docs/Templated Prompts.md

[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...tain child items. * selectedText: Text the user has currently selected. *...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...tly selected. * currentParagraph: Text of the current paragraph where the...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~84-~84: Loose punctuation mark.
Context: ...r is located. * smartReplaceType: Indicates the type of content being rep...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~84-~84: To form a complete sentence, be sure to include a subject.
Context: ... when using the 'replace-smart' option. Can be 'selected-text', 'current-item', or ...

(MISSING_IT_THERE)


[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...t-paragraph'. * smartReplaceText: The text that will be replaced when usi...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~94-~94: Loose punctuation mark.
Context: .... The valid options are: * cursor: Inserts at the current cursor position ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~108-~108: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...he selection. - If no text is selected but the cursor is within a list item or tas...

(COMMA_COMPOUND_SENTENCE_2)


[style] ~109-~109: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... task, it replaces the entire item. - If neither of the above applies, it replac...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

Markdownlint
docs/Templated Prompts.md

82-82: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


83-83: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


84-84: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


85-85: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


94-94: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


95-95: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


96-96: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


97-97: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


98-98: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


99-99: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


100-100: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


101-101: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


102-102: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


103-103: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


104-104: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


105-105: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


106-106: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

Biome
src/prompts.ts

[error] 281-281: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 290-290: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 306-306: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 320-320: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (17)
docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md (1)

1-24: The AI prompt template looks good overall!

The file follows the expected structure for defining an AI prompt, with appropriate metadata and a clear description. The chat-based interaction flow is well-designed.

docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md (1)

1-24: Apply the same suggestions as AI Rewrite - Grammar.md.

This file has a very similar structure and content as the previously reviewed file. The same suggestions apply here:

  1. Simplify the user instructions at line 24 to make them more concise.
  2. Make the assistant responses more engaging by adding personality.

Refer to the previous review for examples.

docs/index.md (1)

1-34: The documentation changes look great!

The new sections provide valuable context and guidance for users:

  • Explaining what LLMs are
  • Clearly listing the requirements
  • Mentioning the development status and encouraging user feedback
  • Providing a getting started guide

The changes make the documentation more comprehensive and user-friendly. Great job!

Tools
LanguageTool

[grammar] ~34-~34: The word “backup” is a noun. The verb is spelled with a space.
Context: ...I Core Library]] > Warning: Please backup your notes before using this plug. It i...

(NOUN_VERB_CONFUSION)

docs/Templated Prompts.md (4)

82-82: LGTM!

The addition of selectedText global metadata variable is approved. It provides useful context about the user's current selection to the templated prompts.

Tools
LanguageTool

[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...tain child items. * selectedText: Text the user has currently selected. *...

(UNLIKELY_OPENING_PUNCTUATION)

Markdownlint

82-82: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


83-83: LGTM!

The addition of currentParagraph global metadata variable is approved. It provides useful context about the current paragraph to the templated prompts.

Tools
LanguageTool

[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...tly selected. * currentParagraph: Text of the current paragraph where the...

(UNLIKELY_OPENING_PUNCTUATION)

Markdownlint

83-83: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


84-85: LGTM!

The addition of smartReplaceType and smartReplaceText global metadata variables is approved. They provide useful context about the content being replaced when using the 'replace-smart' option in templated prompts.

Tools
LanguageTool

[uncategorized] ~84-~84: Loose punctuation mark.
Context: ...r is located. * smartReplaceType: Indicates the type of content being rep...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~84-~84: To form a complete sentence, be sure to include a subject.
Context: ... when using the 'replace-smart' option. Can be 'selected-text', 'current-item', or ...

(MISSING_IT_THERE)


[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...t-paragraph'. * smartReplaceText: The text that will be replaced when usi...

(UNLIKELY_OPENING_PUNCTUATION)

Markdownlint

84-84: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


85-85: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


92-110: LGTM!

The addition of new insertAt options for templated prompts is approved. These options provide more granular control over content insertion and replacement, significantly enhancing the functionality of templated prompts.

Tools
LanguageTool

[uncategorized] ~94-~94: Loose punctuation mark.
Context: .... The valid options are: * cursor: Inserts at the current cursor position ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~108-~108: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...he selection. - If no text is selected but the cursor is within a list item or tas...

(COMMA_COMPOUND_SENTENCE_2)


[style] ~109-~109: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... task, it replaces the entire item. - If neither of the above applies, it replac...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

Markdownlint

94-94: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


95-95: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


96-96: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


97-97: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


98-98: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


99-99: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


100-100: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


101-101: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


102-102: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


103-103: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


104-104: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


105-105: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


106-106: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)

docs/Changelog.md (1)

18-30: LGTM!

The changelog entry accurately documents the addition of new insertAt options for templated prompts and the addition of template prompts for rewriting text. The changes are well-described and provide a clear overview of the enhancements made to the templated prompts functionality.

src/prompts.ts (9)

15-15: LGTM!

The code changes are approved.


120-122: LGTM!

The code changes are approved.


156-166: LGTM!

The code changes are approved.


168-172: LGTM!

The code changes are approved.


185-192: LGTM!

The code changes are approved.


194-227: LGTM!

The code changes are approved.


229-243: LGTM!

The code changes are approved.


245-254: LGTM!

The code changes are approved.


381-384: LGTM!

The code changes are approved.

docs/index.md Outdated Show resolved Hide resolved
src/prompts.ts Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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 and nitpick comments (1)
src/prompts.ts (1)

280-338: LGTM, but consider using optional chaining to simplify the code.

The updated switch statement with cases for the new insertion types, such as replace-selection, replace-paragraph, and replace-smart, significantly enhances the functionality of the insertAiPromptFromTemplate function. These additions provide more flexible text manipulation options based on user selection or cursor position, making the function more versatile and user-friendly.

The replace-smart case, in particular, offers a more intelligent experience by prioritizing text replacement based on the availability of selected text, current item text, or current paragraph text.

To further simplify the code and avoid potential errors, consider using optional chaining as suggested by the static analysis tool. For example, you can change the following lines:

-if (selectedText && selectedText.text) {
+if (selectedText?.text) {

-if (currentParagraph && currentParagraph.text) {
+if (currentParagraph?.text) {

-if (selectedText && selectedText.text) {
+if (selectedText?.text) {

-if (currentParagraph && currentParagraph.text) {
+if (currentParagraph?.text) {

Do you want me to apply these changes or open a GitHub issue to track this improvement?

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b385b8a and 1672c11.

Files selected for processing (2)
  • docs/index.md (1 hunks)
  • src/prompts.ts (5 hunks)
Additional context used
Path-based instructions (2)
docs/index.md (1)

Pattern **/*.md: Review these markdown files. They are written for a markdown note taking tool called Silverbullet, and may contain extra syntax not typically found in markdown.

Ensure any documentation makes sense and is good.

src/prompts.ts (1)

Pattern **/*.ts: Review these typescript files for best practices, readability, and DRY.

Additional comments not posted (6)
docs/index.md (2)

5-7: LGTM!

The new section "What are LLMs?" provides a clear and concise explanation of Large Language Models, enhancing the reader's understanding of the technology behind the plugin.


9-33: Great additions to the documentation!

The new sections "Requirements", "Development Status", and "Getting Started" significantly improve the documentation's structure and user-friendliness:

  • The "Requirements" section clearly outlines the necessary components for using the plugin, aiding users in setting up the tool effectively.
  • The "Development Status" section encourages user engagement by inviting them to report issues and share feature ideas, fostering a community-driven approach to development.
  • The "Getting Started" section provides a clear pathway for new users to begin using the plugin, enhancing the overall user experience.

These changes make the documentation more informative and accessible to users.

src/prompts.ts (4)

15-15: LGTM!

The new import statement for getPageLength, getParagraph, and getSelectedText from ./editorUtils.ts is necessary to support the additional insertion types and improve the functionality of the insertAiPromptFromTemplate function.


156-172: LGTM!

The new local variables, such as currentParagraph, selectedText, smartReplaceType, and smartReplaceText, are necessary to store and manage data related to the new insertion types. These variables improve the function's ability to handle various text manipulation scenarios, making it more versatile and user-friendly.


185-192: Great improvement in error handling!

The enhanced error handling with try-catch blocks around critical operations, such as fetching the current page text, cursor position, current item, current paragraph, and selected text, significantly improves the robustness of the insertAiPromptFromTemplate function.

By logging any issues encountered during these critical operations and communicating them to the user through notifications, the function can gracefully handle errors and provide a better user experience.

Also applies to: 226-227, 236-242, 252-254


381-384: LGTM!

The additional properties selectedText, currentParagraph, smartReplaceType, and smartReplaceText in the globalMetadata object provide more context for rendering templates and enriching chat messages. These changes support the new insertion types and improve the overall functionality of the insertAiPromptFromTemplate function by allowing for more flexible and context-aware text manipulation.

@justyns justyns merged commit a9e8043 into main Sep 11, 2024
3 checks passed
@justyns justyns deleted the template-options branch September 11, 2024 05:38
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