Conversation
Summary of ChangesHello, 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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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); | ||
| } |
There was a problem hiding this comment.
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);
}| 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); | ||
| } |
There was a problem hiding this comment.
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);
}| 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); | ||
| } |
There was a problem hiding this comment.
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);
}| 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); | ||
| } |
There was a problem hiding this comment.
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);
}|
Wait, looks like I lost owner permission to the repos. Emm |
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.