Skip to content

feat(terminal): detect and open URLs from terminal output#1434

Open
yashdev9274 wants to merge 2 commits intogeneralaction:mainfrom
yashdev9274:feat-yd-#1369
Open

feat(terminal): detect and open URLs from terminal output#1434
yashdev9274 wants to merge 2 commits intogeneralaction:mainfrom
yashdev9274:feat-yd-#1369

Conversation

@yashdev9274
Copy link
Contributor

  • Added functionality to extract URLs from terminal output during the 'run' phase.
  • Implemented a dropdown to select and open detected URLs in the browser.
  • Introduced a function to standardize URL formats.
  • Updated electron API types to include for URL handling.

Summary

This PR adds a feature that allows users to quickly open detected localhost URLs (from running dev servers) directly in their system browser from the run terminal toolbar.

Fixes

Fixes #1369

Snapshot

Feat-.1369.mp4

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • This change requires a documentation update

Mandatory Tasks

  • I have self-reviewed the code
  • A decent size PR without self-review might be rejected

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project (pnpm run format)
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my PR needs changes to the documentation
  • I have checked if my changes generate no new warnings (pnpm run lint)
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked if new and existing unit tests pass locally with my changes

- Added functionality to extract URLs from terminal output during the 'run' phase.
- Implemented a dropdown to select and open detected URLs in the browser.
- Introduced a  function to standardize URL formats.
- Updated electron API types to include  for URL handling.
@vercel
Copy link

vercel bot commented Mar 12, 2026

@yashdev9274 is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR adds a quality-of-life feature that detects localhost URLs emitted during the run lifecycle phase and surfaces a one-click button (or a dropdown when multiple ports are found) in the terminal toolbar to open them in the system browser. The approach — hooking into the existing onLifecycleEvent stream via normalizeUrl — fits naturally into the component's event-listener pattern.

Key findings:

  • Side effect inside state updater (TaskTerminalPanel.tsx line 120–125): setSelectedUrl is called inside the setDetectedUrls updater function. Updaters must be pure; this can fire extra times in React StrictMode / concurrent mode. The two setState calls should be separated.
  • HTTPS display label broken (TaskTerminalPanel.tsx line 698): The port label shortening only replaces http://localhost:, so HTTPS URLs are displayed verbatim instead of as port: XXXX.
  • Tooltip likely non-functional for multiple URLs (TaskTerminalPanel.tsx line 681): TooltipTrigger asChild wraps a Select composite component, which does not forward hover events to the underlying DOM node — the tooltip will not appear in the multi-URL case.
  • Unused type declaration (electron-api.d.ts line 623): onHostPreviewEvent is declared but never called; it appears to be a leftover from an earlier design and should be removed or documented.

Confidence Score: 2/5

  • Not safe to merge as-is — contains a React anti-pattern in a state updater and a broken display path for HTTPS URLs.
  • Two logic-level bugs (side effect in state updater, HTTPS label mismatch) need to be fixed before shipping. The tooltip-over-Select issue means the multi-URL tooltip silently does nothing. The unused onHostPreviewEvent type adds dead surface area to the public API surface.
  • src/renderer/components/TaskTerminalPanel.tsx requires the most attention — it contains three of the four issues found.

Important Files Changed

Filename Overview
src/renderer/components/TaskTerminalPanel.tsx Adds URL detection and open-in-browser UI to the run toolbar. Contains a side effect in a state updater, a broken HTTPS URL display label, and a likely non-functional tooltip when multiple URLs are detected (TooltipTrigger asChild wrapping a Select).
src/shared/urls.ts Adds normalizeUrl which extracts and normalises localhost-family URLs from a string. Logic is correct; catches parse errors gracefully. Minor: no blank line between the constants and the new function.
src/renderer/types/electron-api.d.ts Adds onHostPreviewEvent type declaration and openExternal method. onHostPreviewEvent is not used anywhere in the implementation — appears to be unused dead code from a previous design iteration.

Sequence Diagram

sequenceDiagram
    participant Main as Main Process
    participant Renderer as TaskTerminalPanel
    participant normalizeUrl as normalizeUrl (urls.ts)
    participant State as React State
    participant Electron as electronAPI.openExternal

    Main->>Renderer: onLifecycleEvent({ phase: 'run', status: 'line', line: '...URL...' })
    Renderer->>normalizeUrl: normalizeUrl(data.line)
    normalizeUrl-->>Renderer: "http://localhost:3000/"
    Renderer->>State: setDetectedUrls([...prev, url])
    Renderer->>State: setSelectedUrl(url) [first URL only]
    Note over Renderer: UI renders Globe/ExternalLink button

    alt Single URL
        Renderer->>Electron: openExternal(selectedUrl) on button click
    else Multiple URLs
        Renderer->>Electron: openExternal(value) on Select change
    end

    Main->>Renderer: onLifecycleEvent({ phase: 'run', status: 'done' | 'error' })
    Renderer->>State: setDetectedUrls([]), setSelectedUrl(null)
    Note over Renderer: URL button disappears
Loading

Last reviewed commit: 721477c

- Updated logic to set the selected URL when a new URL is detected.
- Wrapped URL selection dropdown in a span for better layout control.
- Improved URL formatting in the dropdown to handle both HTTP and HTTPS protocols.
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.

Feature: Quick-open button in run terminal to open app in browser

1 participant