Skip to content

Use localhost corpus connection where running when on localhost#2193

Merged
cesine merged 8 commits into
mainfrom
test-prototypedev
Jan 26, 2026
Merged

Use localhost corpus connection where running when on localhost#2193
cesine merged 8 commits into
mainfrom
test-prototypedev

Conversation

@cesine
Copy link
Copy Markdown
Member

@cesine cesine commented Jan 24, 2026

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @cesine, 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 introduces a placeholder comment to guide future development on connection handling within the application. The comment outlines a strategy to prioritize localhost connections when the application is running in a CouchApp environment, aiming to optimize local development and deployment scenarios.

Highlights

  • Code Comment: Added a 'TODO' comment in 'App.js' to suggest future logic for handling connections, specifically to try localhost first when running in a CouchApp 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
Copy Markdown

@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 adds a TODO comment to handle database connection logic for CouchApps running on localhost. The work is currently incomplete. My review includes a suggestion to implement the logic described in the TODO to correctly select the database connection based on the execution environment, which aligns with the pull request's objective.

Comment thread backbone_client/app/App.js Outdated
Comment on lines 143 to 144
// TODO if on localhost, try localhost first, then try the remote server
var connection = appself.get("authentication").get("userPrivate").get("mostRecentIds").connection;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This TODO comment indicates that the logic for selecting the database connection is incomplete. To align with the pull request's goal of using the corpus connection from the running CouchApp, you should implement the logic to prioritize the local CouchApp's database when the application is running in that environment.

Here's a suggestion to detect if the app is running as a CouchApp on localhost, parse the database name from the URL, and use it to create a new connection object. If this is not the case, it falls back to the user's most recent connection.

        var connection;
        // If running as a CouchApp on localhost, use the current database connection.
        if (OPrime.isCouchApp() && window.location.href.indexOf("localhost") > -1) {
          var pathParts = window.location.pathname.replace(/^\//, "").split("/");
          var dbname = pathParts[0];
          if (dbname && dbname[0] !== "_") { // Don't use system dbs like _users
            connection = {
              dbname: dbname,
              protocol: window.location.protocol + "//",
              domain: window.location.hostname,
              port: window.location.port || "",
              userFriendlyServerName: "Localhost"
            };
          }
        }

        // Fallback to the user's most recent connection
        if (!connection) {
          connection = appself.get("authentication").get("userPrivate").get("mostRecentIds").connection;
        }

@cesine cesine changed the title WIP use corpus connection where running when in couchapp Use localhost corpus connection where running when on localhost Jan 26, 2026
@cesine cesine marked this pull request as ready for review January 26, 2026 03:17
@cesine cesine merged commit 4322bb1 into main Jan 26, 2026
1 check passed
@cesine cesine deleted the test-prototypedev branch January 26, 2026 03:31
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.

1 participant