Skip to content

Vocab Fix #1448

Merged
yujonglee merged 5 commits intomainfrom
vocab-fix
Sep 4, 2025
Merged

Vocab Fix #1448
yujonglee merged 5 commits intomainfrom
vocab-fix

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

📝 Walkthrough

Walkthrough

Adds React Query–backed persistence of “jargons” to config, integrates it into the SearchHeader replace-all flow, updates the Settings General view to a multiline Textarea with commit-on-enter behavior, and augments the system prompt template to instruct typo correction based on configured jargons.

Changes

Cohort / File(s) Summary
Desktop: SearchHeader persistence
apps/desktop/src/components/right-panel/components/search-header.tsx
Integrates useQuery, useMutation, and useQueryClient to fetch and update config.general.jargons. After successful replace-all, non-empty unique replace term is appended to jargons and persisted via setConfig, then ["config","general"] is invalidated.
Desktop: Settings General UI
apps/desktop/src/components/settings/views/general.tsx
Replaces single-line Input with multiline Textarea (rows=3, non-resizable). Adds onBlur and Enter-to-commit behavior for jargons mutation. Temporarily comments out display language UI. Data handling for jargons remains comma-separated string on commit.
Template: System prompt tweak
crates/template/assets/enhance.system.jinja
Adds directive to correct transcript typos that resemble entries in config.general.jargons (joined by commas). No other template logic changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant SH as SearchHeader (UI)
  participant RQ as React Query (QueryClient)
  participant DB as dbCommands (getConfig/setConfig)

  Note over SH: On mount / render
  SH->>RQ: useQuery(["config","general"], getConfig)
  RQ->>DB: getConfig()
  DB-->>RQ: config
  RQ-->>SH: config

  Note over U,SH: Replace All flow
  U->>SH: Click "Replace All"
  SH->>SH: replaceAll()
  alt replaceTerm non-empty AND resultCount > 0
    SH->>RQ: mutate(updateJargons(replaceTerm))
    RQ->>DB: setConfig(updated config with jargon appended)
    DB-->>RQ: success
    RQ->>RQ: invalidateQueries(["config","general"])
    RQ->>DB: refetch getConfig()
    DB-->>RQ: config (updated)
    RQ-->>SH: config (updated)
  else
    SH-->>U: No jargon update
  end
Loading
sequenceDiagram
  autonumber
  participant U as User
  participant SG as Settings > General (UI)
  participant RQ as React Query (Mutation)
  participant DB as dbCommands (setConfig)

  U->>SG: Edit jargons Textarea
  alt Blur OR Press Enter
    SG->>RQ: mutate(jargonsText)
    RQ->>DB: setConfig(jargons parsed from textarea)
    DB-->>RQ: success
    RQ->>RQ: invalidateQueries(["config","general"])
  else
    SG-->>U: Await commit
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4621787 and 71d75a2.

📒 Files selected for processing (1)
  • crates/template/assets/enhance.system.jinja (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/template/assets/enhance.system.jinja
⏰ 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 (windows, windows-latest)
  • GitHub Check: ci (macos, macos-14)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vocab-fix

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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

🧹 Nitpick comments (5)
apps/desktop/src/components/settings/views/general.tsx (3)

439-444: Let Enter add a newline; commit on Ctrl/Cmd+Enter to match a textarea’s UX.

Current handler prevents newlines, defeating the purpose of a textarea.

Apply:

-                    onKeyDown={(e) => {
-                      if (e.key === "Enter") {
-                        e.preventDefault();
-                        mutation.mutate(form.getValues());
-                        e.currentTarget.blur();
-                      }
-                    }}
+                    onKeyDown={(e) => {
+                      if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
+                        e.preventDefault();
+                        mutation.mutate(form.getValues());
+                      }
+                    }}

446-448: Clarify placeholder to reflect multi-line support.

Apply:

-                    placeholder={t({
-                      id: "Type terms separated by commas (e.g., Blitz Meeting, PaC Squad)",
-                    })}
+                    placeholder={t({
+                      id: "Type terms separated by commas or new lines (e.g., Blitz Meeting, PaC Squad)",
+                    })}

434-449: Normalize parsing and dedupe when saving jargons.

Users will paste line-separated terms. Split on commas or newlines and de-duplicate before persisting.

In the mutation where nextGeneral is built (around Line 140), update:

// current
jargons: v.jargons.split(",").map((j) => j.trim()).filter(Boolean),

// suggested
const parsed = v.jargons
  .split(/[,\n]/g)
  .map((j) => j.trim())
  .filter(Boolean);
jargons: Array.from(new Set(parsed)),
apps/desktop/src/components/right-panel/components/search-header.tsx (2)

29-55: Avoid case-variant duplicates and needless invalidations.

  • Use case-insensitive check to prevent duplicates like “PaC Squad” vs “pac squad”.
  • Only invalidate when a write actually occurred.

Apply:

-  const updateJargonsMutation = useMutation({
-    mutationFn: async (newJargon: string) => {
+  const updateJargonsMutation = useMutation({
+    mutationFn: async (newJargon: string) => {
       if (!config.data) {
-        return;
+        return false;
       }
 
       const currentJargons = config.data.general.jargons || [];
       const trimmedJargon = newJargon.trim();
 
-      if (!trimmedJargon || currentJargons.includes(trimmedJargon)) {
-        return;
+      const exists = currentJargons.some(
+        (j) => j.localeCompare(trimmedJargon, undefined, { sensitivity: "accent" }) === 0,
+      );
+      if (!trimmedJargon || exists) {
+        return false;
       }
 
       const updatedJargons = [...currentJargons, trimmedJargon];
 
       await dbCommands.setConfig({
         ...config.data,
         general: {
           ...config.data.general,
           jargons: updatedJargons,
         },
       });
-    },
-    onSuccess: () => {
-      queryClient.invalidateQueries({ queryKey: ["config", "general"] });
-    },
+      return true;
+    },
+    onSuccess: (updated) => {
+      if (updated) {
+        queryClient.invalidateQueries({ queryKey: ["config", "general"] });
+      }
+    },
   });

151-155: Trigger jargon update with trimmed term.

Minor: ensure trimming at callsite too; avoids storing accidental whitespace.

Apply:

-      if (replaceTerm && replaceTerm.trim() && resultCount > 0) {
-        updateJargonsMutation.mutate(replaceTerm);
+      const trimmed = replaceTerm.trim();
+      if (trimmed && resultCount > 0) {
+        updateJargonsMutation.mutate(trimmed);
       }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e08391e and 4621787.

⛔ Files ignored due to path filters (2)
  • apps/desktop/src/locales/en/messages.po is excluded by !**/*.po
  • apps/desktop/src/locales/ko/messages.po is excluded by !**/*.po
📒 Files selected for processing (3)
  • apps/desktop/src/components/right-panel/components/search-header.tsx (3 hunks)
  • apps/desktop/src/components/settings/views/general.tsx (4 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. Do not add any error handling. Keep the existing one.
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/right-panel/components/search-header.tsx
  • apps/desktop/src/components/settings/views/general.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 (windows, windows-latest)
  • GitHub Check: ci (macos, macos-14)
🔇 Additional comments (4)
apps/desktop/src/components/settings/views/general.tsx (2)

28-28: Import looks correct.


305-336: Hidden “Display language” UI still has schema/watchers. Verify intent.

Field remains in the schema and watch side-effects (toast) still fire, but the control is commented out. Confirm this is intentional; otherwise, consider removing the field from schema/watch logic until re-enabled.

apps/desktop/src/components/right-panel/components/search-header.tsx (2)

1-4: Imports and React Query wiring look good.


19-27: Config query usage is appropriate.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@yujonglee yujonglee merged commit bdcd8dc into main Sep 4, 2025
7 checks passed
@yujonglee yujonglee deleted the vocab-fix branch September 4, 2025 20:20
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.

2 participants