gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

feat(cli): Optimize GitHub setup with clickable links

Open jonathanh1 opened this issue 11 months ago • 1 comments

Summary

Replaces automatic browser tabs in /setup-github with inline, clickable terminal URLs. Enforces strict URL sanitization to prevent terminal injection and updates output rendering to support hyperlinks.

Details

  • New Component: LinkifiedText (packages/cli/src/ui/components/shared/LinkifiedText.tsx)
    • Reusable component that detects URLs using a strict RFC 3986 regex and renders them as clickable ink-link elements.
  • New Utility: urlUtils.ts (packages/cli/src/ui/utils/urlUtils.ts)
    • Implemented strict, security-hardened URL_REGEX to prevent terminal injection and accurately exclude trailing punctuation.
  • Modified: ToolResultDisplay.tsx (packages/cli/src/ui/components/messages/ToolResultDisplay.tsx)
    • Improved truncation logic to account for visual line wrapping, fixing layout bugs with long lines.
  • Modified: setupGithubCommand.ts (packages/cli/src/ui/commands/setupGithubCommand.ts)
    • Removed auto-open browser behavior; added formatted inline instructions with clickable links.
  • Modified: AnsiOutput.tsx (packages/cli/src/ui/components/AnsiOutput.tsx)
    • URLs in streaming output are now clickable.
  • Dependencies: Added ink-link package.

Related Issues

Fixes #12824 Part of #6691

How to Validate

  1. Run the CLI: npm start
  2. Test GitHub Setup:
    • Run /setup-github (make sure to test in a state where setup is needed).
    • Verify that links (e.g., https://aistudio.google.com/apikey) appear blue/underlined and are clickable.
    • Confirm the browser does not open automatically.
  3. Test Truncation:
    • Resize terminal to a narrow width.
    • Run a tool command that produces long output.
    • Verify the output wraps correctly and isn't prematurely truncated.

Pre-Merge Checklist

  • [x] Updated relevant documentation and README (Self-documenting UX change)
  • [x] Added/updated tests (Added urlUtils.test.ts with security partitions; updated ToolResultDisplay & LinkifiedText tests)
  • [ ] Noted breaking changes (None)
  • [x] Validated on required platforms/methods:
    • [x] MacOS
      • [x] npm run (Validated locally)
      • [ ] npx
      • [ ] Docker
      • [ ] Podman
      • [ ] Seatbelt
    • [ ] Windows
      • [ ] npm run
      • [ ] npx
      • [ ] Docker
    • [ ] Linux
      • [ ] npm run
      • [ ] npx
      • [ ] Docker

jonathanh1 avatar Dec 08 '25 20:12 jonathanh1

Summary of Changes

Hello @jonathanh1, I'm Gemini Code Assist[^1]! 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 significantly enhances the user experience of the CLI by transforming static URLs in the terminal into interactive, clickable hyperlinks. This change primarily affects the /setup-github command, which now provides inline instructions with direct links, and also extends to general streaming output. Alongside this, robust URL sanitization has been implemented to prevent potential terminal injection vulnerabilities, and the display logic for long outputs has been improved to handle line wrapping more effectively.

Highlights

  • Interactive Terminal Links: The /setup-github command now displays clickable URLs directly in the terminal for setup instructions, replacing the previous behavior of automatically opening browser tabs.
  • Robust URL Handling: Introduced a new LinkifiedText component and urlUtils.ts for strict RFC 3986 compliant URL detection, sanitization, and rendering, enhancing security against terminal injection.
  • Improved Output Truncation: The ToolResultDisplay component's truncation logic has been refined to accurately account for visual line wrapping, preventing premature truncation and layout issues with long lines.
  • Streaming Output Hyperlinks: URLs within streaming AnsiOutput are now automatically detected and rendered as clickable links.
  • New Dependency: The ink-link package has been added to enable clickable links in the Ink-based terminal UI.
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 :thumbsup: and :thumbsdown: 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.

[^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.

gemini-code-assist avatar Dec 08 '25 20:12 gemini-code-assist

Hi there! Thank you for your contribution. To keep our backlog manageable, we are closing pull requests that haven't seen maintainer activity for 30 days. If you're still working on this, please let us know!

gemini-cli[bot] avatar Mar 15 '26 19:03 gemini-cli[bot]