Skip to content

Conversation

@tomkis
Copy link
Collaborator

@tomkis tomkis commented Dec 15, 2025

Summary

Opens agentstack UI based on active server.

Linked Issues

Fixes #1715

Documentation

  • No Docs Needed:

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 15, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tomkis, 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 resolves an issue where the AgentStack CLI's ui command consistently opened a fixed local UI URL. It introduces logic to identify the currently active server from the application's configuration and constructs the appropriate UI URL based on that information. If no active server is found, it gracefully falls back to the default local UI. This enhancement improves the user experience by ensuring the UI command correctly navigates to the relevant AgentStack instance.

Highlights

  • Dynamic UI URL Resolution: The AgentStack UI now dynamically determines the URL to open based on the currently active server configuration, rather than always defaulting to a hardcoded local address.
  • Active Server Integration: The Configuration and auth_manager.active_server are utilized to retrieve the active server, ensuring the UI opens to the correct instance if one is active.
  • Localhost Port Adjustment: For local servers identified with ports like 8333, the UI URL is automatically adjusted to port 8334 to correctly access the UI, using regular expressions for pattern matching.
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.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 15, 2025
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

This pull request updates the ui command to open the web interface for the currently active server, instead of always defaulting to localhost. The implementation correctly identifies local servers to adjust the port for the UI. My review focuses on making this detection more robust and secure by improving the regular expressions used. I've suggested a change to prevent potential issues if the server URL contains credentials and to expand the detection of local server addresses.

Comment on lines +119 to +120
if re.search(r"(localhost|127\.0\.0\.1):8333", active_server):
ui_url = re.sub(r":8333", ":8334", active_server)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using re.sub with a simple string replacement for the port is risky as it could replace :8333 in other parts of the URL, like a password if credentials are present. This is a security concern. Also, the regex for detecting a local server could be more comprehensive to include other loopback addresses like 0.0.0.0 and [::1].

I suggest using a more specific regex in both re.search and re.sub to make the replacement safer and the detection more robust. Using a backreference in re.sub ensures only the port following the matched host is replaced.

Suggested change
if re.search(r"(localhost|127\.0\.0\.1):8333", active_server):
ui_url = re.sub(r":8333", ":8334", active_server)
if re.search(r"(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\]):8333", active_server):
ui_url = re.sub(r"((?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])):8333", r"\1:8334", active_server, count=1)

@tomkis tomkis merged commit bdad9c0 into main Dec 15, 2025
9 of 10 checks passed
@tomkis tomkis deleted the fix/1715-open-ui-for-active-server branch December 15, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI - agentstack ui command always opens localhost regardless of active server

3 participants