Skip to content

Include empty clientCache configs on init#10167

Merged
itsrakhil merged 6 commits intomainfrom
caching
Mar 25, 2026
Merged

Include empty clientCache configs on init#10167
itsrakhil merged 6 commits intomainfrom
caching

Conversation

@itsrakhil
Copy link
Copy Markdown
Contributor

Adds clientCache: {} to the init SDK configurations for Web, Swift, Kotlin, and Dart when initialized via the Firebase CLI. This ensures that client-side caching is enabled by default for all newly created SDK configurations.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Firebase CLI's SDK initialization process by automatically configuring client-side caching for various platforms. This change ensures that applications using the generated SDKs will have caching enabled out-of-the-box, improving performance and user experience, especially for realtime features. The new configuration is conditionally applied based on an experimental flag, allowing for controlled rollout and testing.

Highlights

  • Default Client-Side Caching: Enabled client-side caching by default for newly generated SDK configurations (Web, Swift, Kotlin, Dart) when initialized via the Firebase CLI, by adding clientCache: {}.
  • New Experiment Flag: Introduced a new experiment flag, fdcrealtime, which controls the conditional injection of the clientCache configuration.
  • SDK Generation Logic Refinement: Updated the SDK generation logic to dynamically detect and set react and angular flags for JavaScript SDKs and improved the check for existing SDK configurations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new fdcrealtime experiment and updates the addSdkGenerateToConnectorYaml function. The changes enable conditional injection of clientCache into generated JavaScript, Dart, Kotlin, and Swift SDK configurations when the fdcrealtime experiment is active. Additionally, the logic for detecting existing SDK configurations and applying framework-specific settings for JavaScript SDKs has been refined. The review feedback highlights that the current implementation for injecting clientCache and updating framework detection only applies to newly generated SDK configurations, and suggests modifying existing configurations to improve the idempotency and robustness of the firebase init dataconnect:sdk command.

Comment on lines +395 to 404
if (experiments.isEnabled("fdcrealtime")) {
javascriptSdk.clientCache = {};
}
if (!isArray(generate?.javascriptSdk)) {
generate.javascriptSdk = generate.javascriptSdk ? [generate.javascriptSdk] : [];
}
if (!generate.javascriptSdk.some((s) => s.outputDir === javascriptSdk.outputDir)) {
const existing = generate.javascriptSdk.find((s) => s.outputDir === javascriptSdk.outputDir);
if (!existing) {
generate.javascriptSdk.push(javascriptSdk);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic only adds clientCache to newly created SDK configurations. If a configuration for this outputDir already exists, it is not modified. This means clientCache won't be added if it's missing. Similarly, the refactoring to detect React/Angular frameworks is only applied to new configurations.

Consider updating the logic to modify existing configurations. This would make firebase init dataconnect:sdk more robust and idempotent, ensuring that running it again updates configurations with new defaults or detected frameworks.

      if (!isArray(generate?.javascriptSdk)) {
        generate.javascriptSdk = generate.javascriptSdk ? [generate.javascriptSdk] : [];
      }
      const existing = generate.javascriptSdk.find((s) => s.outputDir === javascriptSdk.outputDir);
      if (existing) {
        if (experiments.isEnabled("fdcrealtime") && !existing.clientCache) {
          existing.clientCache = {};
        }
        existing.react = javascriptSdk.react;
        existing.angular = javascriptSdk.angular;
      } else {
        if (experiments.isEnabled("fdcrealtime")) {
          javascriptSdk.clientCache = {};
        }
        generate.javascriptSdk.push(javascriptSdk);
      }

Comment on lines +412 to 421
if (experiments.isEnabled("fdcrealtime")) {
dartSdk.clientCache = {};
}
if (!isArray(generate?.dartSdk)) {
generate.dartSdk = generate.dartSdk ? [generate.dartSdk] : [];
}
if (!generate.dartSdk.some((s) => s.outputDir === dartSdk.outputDir)) {
const existing = generate.dartSdk.find((s) => s.outputDir === dartSdk.outputDir);
if (!existing) {
generate.dartSdk.push(dartSdk);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the web platform case, this logic only adds clientCache to newly created Dart SDK configurations. If a configuration for this outputDir already exists, it is not modified.

To make init more robust, consider updating existing configurations if they are missing the clientCache.

      if (!isArray(generate?.dartSdk)) {
        generate.dartSdk = generate.dartSdk ? [generate.dartSdk] : [];
      }
      const existing = generate.dartSdk.find((s) => s.outputDir === dartSdk.outputDir);
      if (existing) {
        if (experiments.isEnabled("fdcrealtime") && !existing.clientCache) {
          existing.clientCache = {};
        }
      } else {
        if (experiments.isEnabled("fdcrealtime")) {
          dartSdk.clientCache = {};
        }
        generate.dartSdk.push(dartSdk);
      }

Comment on lines +429 to 438
if (experiments.isEnabled("fdcrealtime")) {
kotlinSdk.clientCache = {};
}
if (!isArray(generate?.kotlinSdk)) {
generate.kotlinSdk = generate.kotlinSdk ? [generate.kotlinSdk] : [];
}
if (!generate.kotlinSdk.some((s) => s.outputDir === kotlinSdk.outputDir)) {
const existing = generate.kotlinSdk.find((s) => s.outputDir === kotlinSdk.outputDir);
if (!existing) {
generate.kotlinSdk.push(kotlinSdk);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic only adds clientCache to newly created Kotlin SDK configurations, but doesn't update existing ones.

To improve idempotency, consider updating existing configurations if they are missing the clientCache when the fdcrealtime experiment is enabled.

      if (!isArray(generate?.kotlinSdk)) {
        generate.kotlinSdk = generate.kotlinSdk ? [generate.kotlinSdk] : [];
      }
      const existing = generate.kotlinSdk.find((s) => s.outputDir === kotlinSdk.outputDir);
      if (existing) {
        if (experiments.isEnabled("fdcrealtime") && !existing.clientCache) {
          existing.clientCache = {};
        }
      } else {
        if (experiments.isEnabled("fdcrealtime")) {
          kotlinSdk.clientCache = {};
        }
        generate.kotlinSdk.push(kotlinSdk);
      }

Comment on lines +449 to 458
if (experiments.isEnabled("fdcrealtime")) {
swiftSdk.clientCache = {};
}
if (!isArray(generate?.swiftSdk)) {
generate.swiftSdk = generate.swiftSdk ? [generate.swiftSdk] : [];
}
if (!generate.swiftSdk.some((s) => s.outputDir === swiftSdk.outputDir)) {
const existing = generate.swiftSdk.find((s) => s.outputDir === swiftSdk.outputDir);
if (!existing) {
generate.swiftSdk.push(swiftSdk);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic only adds clientCache to newly created Swift SDK configurations. Existing configurations are not updated.

To make the init command more robust, consider updating existing configurations to include clientCache if it's missing and the experiment is enabled.

      if (!isArray(generate?.swiftSdk)) {
        generate.swiftSdk = generate.swiftSdk ? [generate.swiftSdk] : [];
      }
      const existing = generate.swiftSdk.find((s) => s.outputDir === swiftSdk.outputDir);
      if (existing) {
        if (experiments.isEnabled("fdcrealtime") && !existing.clientCache) {
          existing.clientCache = {};
        }
      } else {
        if (experiments.isEnabled("fdcrealtime")) {
          swiftSdk.clientCache = {};
        }
        generate.swiftSdk.push(swiftSdk);
      }

@itsrakhil itsrakhil requested a review from fredzqm March 24, 2026 23:06
Copy link
Copy Markdown
Contributor

@fredzqm fredzqm left a comment

Choose a reason for hiding this comment

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

Stamp it. Same PR as #10077

@fredzqm
Copy link
Copy Markdown
Contributor

fredzqm commented Mar 24, 2026

Wait, looks like I lost owner permission to the repos. Emm

@itsrakhil itsrakhil merged commit b60bbfd into main Mar 25, 2026
47 checks passed
@itsrakhil itsrakhil deleted the caching branch March 25, 2026 20:52
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.

4 participants