Skip to content

Feat google ai studio#189

Open
Tabby-rohit wants to merge 3 commits into
prem-k-r:mainfrom
Tabby-rohit:Feat--google-ai-studio
Open

Feat google ai studio#189
Tabby-rohit wants to merge 3 commits into
prem-k-r:mainfrom
Tabby-rohit:Feat--google-ai-studio

Conversation

@Tabby-rohit

@Tabby-rohit Tabby-rohit commented Apr 21, 2026

Copy link
Copy Markdown

📌 Description

This PR adds Google AI Studio as a quick-access AI tool in the dashboard

🎨 Visual Changes (Screenshots / Videos)

image

🔗 Related Issues

New Feature #177

✅ Checklist

  • I have read and followed the Contributing Guidelines.
  • My code follows the project's coding style and conventions.
  • I have tested my changes thoroughly to ensure expected behavior.
  • I have verified compatibility across Chrome and Firefox (additional browsers if applicable).
  • I have attached relevant visual evidence (screenshots/videos) if applicable.
  • I have updated the CHANGELOG.md under the appropriate categories with all my changes in this PR.

Overview

Adds Google AI Studio as a new quick-access AI tool in the AI Tools navigation bar, alongside existing tools like ChatGPT, Gemini, and Claude.

Changes

index.html

  • Added a new AI Tools shortcut entry linking to https://ai.google/studio/ with icon and label (id="googleAIStudio"), positioned after the existing Gemini entry

locales/en.js

  • Added English localization string googleAIStudio: "Google AI Studio" in the AI Tools section

scripts/ai-tools.js

  • Updated the default AI tool registry to include googleAIStudio at order: 2, shifting subsequent tools' order values accordingly
  • Added mergeAIToolsSettings(savedSettings) helper function to normalize persisted localStorage settings by filtering unknown tool IDs, deduplicating entries, and appending missing tools from current defaults
  • Modified applyAIToolsSettings() to use the new normalization helper and persist updated normalized arrays to localStorage with deep-compare validation
  • Modified showAIToolsSettings() to use mergeAIToolsSettings() for initialization instead of prior fallback logic

Related Issue

Implements New Feature #177

Testing

Author verified changes across Chrome and Firefox browsers

Overview

This PR adds Google AI Studio as a new quick-access AI tool to the dashboard, implementing feature #177. Changes include a new UI shortcut, English localization, and updates to the AI tools registry with refactored settings management logic.

Changes

index.html

  • Added new <a href="https://ai.google/studio/"> entry in the AI Tools shortcuts section with a label element id="googleAIStudio" and icon SVG, positioned after Gemini and before Copilot.

locales/en.js

  • Added English localization: "googleAIStudio": "Google AI Studio" in the AI Tools section.

scripts/ai-tools.js

  • Updated default AI tool registry: inserted { id: "googleAIStudio", visible: true, order: 2 }, shifting order values for subsequent tools (copilot, claude, deepseek) and preserving other entries.
  • Added mergeAIToolsSettings(savedSettings) to normalize persisted aiToolsSettings by:
    • Filtering unknown tool IDs
    • Deduplicating entries
    • Interpreting string entries as visible tools and object entries as hidden tools
    • Appending any missing tools from current defaults
  • Modified applyAIToolsSettings() to compute normalized settings via mergeAIToolsSettings() and only persist to localStorage when the normalized result differs from stored data (deep-compare using JSON.stringify).
  • Modified showAIToolsSettings() to initialize the settings form using mergeAIToolsSettings() instead of the prior fallback logic.
  • Other integrations: applyAIToolsSettings() is invoked on DOMContentLoaded and after saving settings; showAIToolsSettings() is used by the AI Tools edit button.

Testing

Author verified changes across Chrome and Firefox.

Checklist

Contributing guidelines, coding style, testing, browser compatibility, visuals, and CHANGELOG update items marked complete by author.

@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 58e2af74-0da7-444a-bf8a-4c83d4961c0b

📥 Commits

Reviewing files that changed from the base of the PR and between f934c4d and c275b6f.

📒 Files selected for processing (1)
  • index.html

📝 Walkthrough

Walkthrough

Adds a new "Google AI Studio" AI tool entry (UI + locale) and updates AI tools settings handling with a normalization function that merges, de-duplicates, and preserves ordering of persisted tool settings.

Changes

Cohort / File(s) Summary
UI Markup
index.html
Inserted a new AI tools shortcut link for "Google AI Studio" (https://ai.google/studio/) including an icon SVG and a label element id="googleAIStudio".
Localization
locales/en.js
Added English locale key "googleAIStudio": "Google AI Studio" under AI tools.
AI Tools Configuration & Settings
scripts/ai-tools.js
Added googleAIStudio to default catalog at order 2 and adjusted orders for other tools; introduced mergeAIToolsSettings(savedSettings) to normalize/de-duplicate persisted settings; changed applyAIToolsSettings() and showAIToolsSettings() to use normalized settings and only persist when different.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant UI as UI (index.html)
    participant Manager as AI Tools Manager (scripts/ai-tools.js)
    participant Storage as localStorage

    User->>UI: open settings / click AI tools
    UI->>Manager: request showAIToolsSettings()
    Manager->>Storage: read savedSettings
    Storage-->>Manager: savedSettings
    Manager->>Manager: mergeAIToolsSettings(savedSettings)
    Manager-->>UI: generateAIToolsForm(normalizedSettings)
    UI->>User: render AI tools form (includes Google AI Studio)

    User->>UI: apply changes
    UI->>Manager: applyAIToolsSettings(userChanges)
    Manager->>Manager: mergeAIToolsSettings(userChanges)
    Manager->>Storage: write normalized settings if changed
    Storage-->>Manager: confirm write
    Manager-->>UI: update UI state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

ui/ux

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feat google ai studio' is partially related to the changeset—it mentions the main feature being added but lacks clarity and proper formatting (missing punctuation/capitalization). Consider improving the title to be more descriptive and properly formatted, such as 'Add Google AI Studio as quick-access AI tool' for better clarity in commit history.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive and follows the template structure with clear sections, visual evidence, completed checklist items, and detailed change documentation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@Tabby-rohit

Copy link
Copy Markdown
Author

I reopened the PR from another branch
Old PR : #184

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/ai-tools.js`:
- Around line 29-59: mergeAIToolsSettings allows duplicate entries and can throw
when Object.keys(item) is called on null/non-object; update the loop that
handles savedSettings to first validate object items with a guard like item &&
typeof item === "object" && !Array.isArray(item") before using
Object.keys(item), compute toolId accordingly, and before pushing into
normalizedSettings check !seenToolIds.has(toolId) to avoid duplicates while
still adding seenToolIds.add(toolId); ensure this logic references
mergeAIToolsSettings, seenToolIds, normalizedSettings, aiTools and the
Object.keys(item) use so malformed savedSettings entries are ignored and
duplicates are deduplicated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ab0d1451-d11e-4de2-b19e-a30b2562d286

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab1739 and f934c4d.

📒 Files selected for processing (3)
  • index.html
  • locales/en.js
  • scripts/ai-tools.js

Comment thread scripts/ai-tools.js
Comment on lines +29 to +59
function mergeAIToolsSettings(savedSettings) {
const normalizedSettings = [];
const seenToolIds = new Set();

if (Array.isArray(savedSettings)) {
savedSettings.forEach((item) => {
let toolId;
let isVisible = true;

if (typeof item === "string") {
toolId = item;
} else {
toolId = Object.keys(item)[0];
isVisible = false;
}

if (aiTools.some(tool => tool.id === toolId)) {
seenToolIds.add(toolId);
normalizedSettings.push(isVisible ? toolId : { [toolId]: false });
}
});
}

aiTools.forEach((tool) => {
if (!seenToolIds.has(tool.id)) {
normalizedSettings.push(tool.visible ? tool.id : { [tool.id]: false });
}
});

return normalizedSettings;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Demonstrate that the current normalization keeps duplicates and throws on null.

node <<'NODE'
const aiTools = [
  { id: "chatGPT", visible: true },
  { id: "gemini", visible: true },
];

function mergeAIToolsSettings(savedSettings) {
  const normalizedSettings = [];
  const seenToolIds = new Set();

  if (Array.isArray(savedSettings)) {
    savedSettings.forEach((item) => {
      let toolId;
      let isVisible = true;

      if (typeof item === "string") {
        toolId = item;
      } else {
        toolId = Object.keys(item)[0];
        isVisible = false;
      }

      if (aiTools.some(tool => tool.id === toolId)) {
        seenToolIds.add(toolId);
        normalizedSettings.push(isVisible ? toolId : { [toolId]: false });
      }
    });
  }

  aiTools.forEach((tool) => {
    if (!seenToolIds.has(tool.id)) {
      normalizedSettings.push(tool.visible ? tool.id : { [tool.id]: false });
    }
  });

  return normalizedSettings;
}

console.log("Duplicate case:", JSON.stringify(mergeAIToolsSettings(["chatGPT", "chatGPT"])));

try {
  mergeAIToolsSettings([null]);
} catch (error) {
  console.log("Null case throws:", error.name);
}
NODE

Repository: prem-k-r/MaterialYouNewTab

Length of output: 144


🏁 Script executed:

cat -n scripts/ai-tools.js | sed -n '25,65p'

Repository: prem-k-r/MaterialYouNewTab

Length of output: 1613


Deduplicate and validate saved entries before normalizing them.

seenToolIds is populated but never checked before pushing to normalizedSettings, so duplicated entries survive normalization. Additionally, the code calls Object.keys(item) without validating that item is a valid object, which throws a TypeError if item is null or any non-object type—a malformed backup/localStorage value can break AI tools initialization.

The proposed fix adds:

  1. Deduplication check: !seenToolIds.has(toolId) before pushing
  2. Type validation: item && typeof item === "object" && !Array.isArray(item) before calling Object.keys()
🐛 Proposed fix
 function mergeAIToolsSettings(savedSettings) {
     const normalizedSettings = [];
     const seenToolIds = new Set();
+    const validToolIds = new Set(aiTools.map(tool => tool.id));
 
     if (Array.isArray(savedSettings)) {
         savedSettings.forEach((item) => {
             let toolId;
             let isVisible = true;
 
             if (typeof item === "string") {
                 toolId = item;
-            } else {
+            } else if (item && typeof item === "object" && !Array.isArray(item)) {
                 toolId = Object.keys(item)[0];
                 isVisible = false;
+            } else {
+                return;
             }
 
-            if (aiTools.some(tool => tool.id === toolId)) {
+            if (validToolIds.has(toolId) && !seenToolIds.has(toolId)) {
                 seenToolIds.add(toolId);
                 normalizedSettings.push(isVisible ? toolId : { [toolId]: false });
             }
         });
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/ai-tools.js` around lines 29 - 59, mergeAIToolsSettings allows
duplicate entries and can throw when Object.keys(item) is called on
null/non-object; update the loop that handles savedSettings to first validate
object items with a guard like item && typeof item === "object" &&
!Array.isArray(item") before using Object.keys(item), compute toolId
accordingly, and before pushing into normalizedSettings check
!seenToolIds.has(toolId) to avoid duplicates while still adding
seenToolIds.add(toolId); ensure this logic references mergeAIToolsSettings,
seenToolIds, normalizedSettings, aiTools and the Object.keys(item) use so
malformed savedSettings entries are ignored and duplicates are deduplicated.

@prem-k-r prem-k-r added enhancement New feature or request refactor Code improvement without changing behavior labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactor Code improvement without changing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants