Skip to content

Ask the user which backend they want to use. #10087

Merged
christhompsongoogle merged 7 commits intomainfrom
confirmBackend
Mar 16, 2026
Merged

Ask the user which backend they want to use. #10087
christhompsongoogle merged 7 commits intomainfrom
confirmBackend

Conversation

@christhompsongoogle
Copy link
Contributor

This is a little crude in that it quits if invalid but it can be re-ran.

…n that it quits if invalid but it can be re-ran.
@gemini-code-assist
Copy link
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 App Hosting migration process by introducing an interactive step for backend selection. Instead of automatically assigning a backend, users are now prompted to confirm a suggested backend or choose from a list of available options, providing greater control and clarity during the setup.

Highlights

  • User Backend Selection: Implemented an interactive prompt to allow users to confirm or choose an App Hosting backend during the migration process, moving away from automatic selection.
  • Improved Backend Discovery: If the initially suggested backend is not accepted, the tool now lists all available App Hosting backends, enabling users to make an informed choice.
  • Input Validation: Added validation for user-provided backend IDs, ensuring that only existing and valid backends can be selected, and exiting with an error if an invalid one is entered.

🧠 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.

Changelog
  • src/firebase_studio/migrate.ts
    • Added interactive prompt to ask the user which App Hosting backend they want to use.
    • Implemented logic to list available backends if the user declines the suggested default.
    • Included validation for user-entered backend IDs, throwing an error for invalid selections.
Activity
  • No specific activity beyond the initial commit and PR creation is provided in the context.
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.

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

  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
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

The pull request introduces an interactive flow for selecting an App Hosting backend, allowing users to confirm a suggested backend or choose from a list. This is a valuable improvement for user experience by providing more control to the user during the migration process. My feedback primarily focuses on improving the code's maintainability by reducing nesting in the newly added logic.

Comment on lines +408 to 436
let selectedBackendId = "";
if (studioBackend) {
backendId = studioBackend.name.split("/").pop()!;
selectedBackendId = studioBackend.name.split("/").pop()!;
} else {
selectedBackendId = backendIds[0];
}

const confirmBackend = await prompt.confirm({
message: `Would you like to use the App Hosting backend "${selectedBackendId}"?`,
default: true,
});

if (confirmBackend) {
backendId = selectedBackendId;
} else {
backendId = backends[0].name.split("/").pop()!;
logger.info("Available App Hosting backends:");
for (const id of backendIds) {
logger.info(` - ${id}`);
}

const inputBackendId = await prompt.input({
message: "Please enter the name of the backend you would like to use:",
});

if (!backendIds.includes(inputBackendId)) {
throw new FirebaseError(`Invalid backend selected: ${inputBackendId}`, { exit: 1 });
}
backendId = inputBackendId;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The interactive backend selection logic introduces significant nesting within the createFirebaseConfigs function. To improve readability and maintainability, and to adhere to the best practice of reducing nesting as much as possible (Repository Style Guide, line 30), please extract this logic into a new asynchronous helper function, for example, selectBackendInteractively. This function would encapsulate the prompts and validation, returning the chosen backendId.

Suggested change
let selectedBackendId = "";
if (studioBackend) {
backendId = studioBackend.name.split("/").pop()!;
selectedBackendId = studioBackend.name.split("/").pop()!;
} else {
selectedBackendId = backendIds[0];
}
const confirmBackend = await prompt.confirm({
message: `Would you like to use the App Hosting backend "${selectedBackendId}"?`,
default: true,
});
if (confirmBackend) {
backendId = selectedBackendId;
} else {
backendId = backends[0].name.split("/").pop()!;
logger.info("Available App Hosting backends:");
for (const id of backendIds) {
logger.info(` - ${id}`);
}
const inputBackendId = await prompt.input({
message: "Please enter the name of the backend you would like to use:",
});
if (!backendIds.includes(inputBackendId)) {
throw new FirebaseError(`Invalid backend selected: ${inputBackendId}`, { exit: 1 });
}
backendId = inputBackendId;
}
backendId = await selectBackendInteractively(backendIds, studioBackend);
References
  1. Code should avoid unnecessarily deep nesting or long periods of nesting. Handle edge cases early and exit or fold them into the general case. Consider helper functions that can completely encapsulate branching, e.g. multiple ways a variable can be populated. (link)

Copy link
Member

Choose a reason for hiding this comment

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

Good suggestion - also, do we want to use a select prompt here, or are we intentionally choosing a text input prompt to be more agent friendly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

text input for flexibility mostly - this one is coming in late so I took the simple route rather than have a complicated selector

Copy link
Member

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Approving pending fixing the test

@christhompsongoogle christhompsongoogle enabled auto-merge (squash) March 16, 2026 18:21
@christhompsongoogle christhompsongoogle merged commit 7f133d1 into main Mar 16, 2026
47 checks passed
@christhompsongoogle christhompsongoogle deleted the confirmBackend branch March 16, 2026 20:10
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