-
Notifications
You must be signed in to change notification settings - Fork 1k
Fetch active Firebase Project from Studio Workspace when running in Studio #8904
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @samedson, 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 aims to enhance the Firebase CLI's ability to work seamlessly within the Firebase Studio environment. It introduces the necessary API definitions and logic to fetch project information directly from a Firebase Studio workspace, allowing the CLI to automatically configure itself with the correct Firebase project when running in that specific environment. This is a foundational step towards deeper integration with Firebase Studio.
Highlights
- Firebase Studio Integration: I've introduced new functionality to integrate the Firebase CLI with Firebase Studio. This allows the CLI to automatically determine the active Firebase project based on a Studio workspace, but only when the
MONOSPACE_ENV
environment variable is set. - New API Endpoint: A new API origin,
studioWorkspaceApiOrigin
, has been added insrc/api.ts
to define the base URL for the Firebase Studio Workspace API (https://monospace-pa.googleapis.com
). A correspondingClient
instance (studioWorkspaceClient
) has been set up insrc/management/projects.ts
to interact with this API. - Workspace Project Resolution: A new asynchronous function
getStudioWorkspace
has been added tosrc/management/projects.ts
. This function fetches details for a given workspace ID from the Studio API. TheCommand
class insrc/command.ts
now includes anapplyStudioWorkspace
method that callsgetStudioWorkspace
(currently with a hardcoded IDstudio-74855340
and multiple TODOs for dynamic ID fetching) and, if successful, sets the CLI's active project (options.project
) to thefirebaseProjectId
returned by the Studio workspace. - Debugging Aid: A
console.log
statement has been temporarily added insrc/apiv2.ts
to output thefetchURL
for debugging purposes during API requests.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
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. ↩
There was a problem hiding this 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 functionality to fetch project information from Firebase Studio. The changes add a new API endpoint, a client to call it, and logic in the Command
class to use this information to set the project context when running inside a Studio environment.
My review has identified a few high-priority issues that should be addressed before merging:
- There are several
console.log
andconsole.error
statements that appear to be for debugging. These should be removed or replaced with the project's standard logger. - A hardcoded workspace ID is used. This will prevent the feature from being used in any other context and should be replaced with a dynamic method for retrieving the workspace ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one suggestion
} | ||
|
||
async function writeStudioProjectToConfigStore(options: Options, studioProjectId: string) { | ||
if (options.projectRoot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious what the desired behavior should be without a project root. This is when there's no firebase.json in your directory chain?
I did a quick sanity check and noticed there's different behavior when you have a firebase.json and when you don't:
➜ firebase-tools git:(fetch-project-from-studio) MONOSPACE_ENV=1 WORKSPACE_SLUG="studio-48028039" firebase apps:list
✔ Preparing the list of your Firebase apps
No apps found.
➜ firebase-tools git:(fetch-project-from-studio) touch firebase.json
➜ firebase-tools git:(fetch-project-from-studio) ✗ MONOSPACE_ENV=1 WORKSPACE_SLUG="studio-48028039" firebase apps:list
? Found different active Firebase Projects in the Firebase CLI and your Firebase Studio
Workspace. Which project would you like to set as your active project? (Use arrow keys)
❯ Set greeting-generator-spibe from Firebase Studio as my active project in both places
Set dumpsterfire-6 from Firebase CLI as my active project in both places
➜ firebase-tools git:(fetch-project-from-studio) ✗ rm -f firebase.json
➜ firebase-tools git:(fetch-project-from-studio) MONOSPACE_ENV=1 WORKSPACE_SLUG="studio-48028039" firebase use dumpsterfire-5
Error: firebase use must be run from a Firebase project directory.
Run firebase init to start a project directory in the current folder.
My hunch is a lot of apps won't have a firebase.json for their studio project.
So maybe the user experience is:
- ✅ If you haven't called firebase use, then we use the studio project, no conflict resolution.
- ✅ If you have called firebase use, it'll force you through the
init
flow, which creates a firebase.json
So lots of words to say, this seems fine to me, but what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was pretty much my thinking as well when I noticed this edge case - if you're not in a Firebase project directory, we can't set your active project, we just pick up your studio project.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8904 +/- ##
==========================================
- Coverage 52.18% 50.76% -1.42%
==========================================
Files 418 497 +79
Lines 30694 32947 +2253
Branches 6348 6844 +496
==========================================
+ Hits 16018 16726 +708
- Misses 13234 14749 +1515
- Partials 1442 1472 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ield to trigger file watcher
cedb46b
to
491cbdb
Compare
Just rebased onto master FYI to see if it fixes the test failures |
* Fix apptesting enablement (#8905) * Fix an issue with apptesting enablement Co-authored-by: Joe Hanley <joehanley@google.com> * Fix issue where login didnt work as expected on studio (#8914) * Fix issue where login didnt work as expected on studio * Update src/commands/login.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * 14.11.2 * [firebase-release] Removed change log and reset repo after 14.11.2 release * Enable FDC API in `firebase init dataconnect` for Spark projects (#8927) * feat: address pr comments on app-* commands * Fetch active Firebase Project from Studio Workspace when running in Studio (#8904) * Disable broken VSCode integration tests (#8934) * Add userinfo.email scope when in studio (#8935) * Add userinfo.email scope when in studio * Update src/requireAuth.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/requireAuth.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * feat: Display Firestore database edition (#8926) * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. Also refactors the tests for `prettyPrintDatabase` to improve readability and maintainability. * feat: Display Firestore database edition Adds the 'Edition' to the output of the `firestore:databases:get` command. The `Database` resource in the Firestore API now includes a `databaseEdition` field. This change updates the `DatabaseResp` type to include this new field and modifies the `prettyPrintDatabase` function to display the database edition in the output table. The possible values for the edition are `STANDARD` and `ENTERPRISE`. If the edition is not specified or is `DATABASE_EDITION_UNSPECIFIED`, it will default to `STANDARD`. Also refactors the tests for `prettyPrintDatabase` to improve readability and maintainability and adds a test case for the `STANDARD` edition. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> * Formatted --------- Co-authored-by: Jake Ouellette <jakeout@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Google Open Source Bot <firebase-oss-bot@google.com> Co-authored-by: Fred Zhang <fredzqm@google.com> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Sam Edson <samedson@google.com> Co-authored-by: Ehsan <ehsann@google.com>
Description
Features:
--project
parameter will still work as an override.firebase use
to update the active project in Firebase Studio.Progress:
firebase use
to update the active projectfirebase use <new-project>
? You go through conflict resolution and then could set the project to a third project (maybe we skip conflict resolution if you are calling theuse
command)?Scenarios Tested
Sample Commands