Skip to content

browse screenshot: relative paths starting with . are misidentified as CSS selectors #495

Closed

Description

@FeilixX

Summary

browse screenshot ./path/to/file.png and browse screenshot .gstack/screenshots/page.png fail with:

screenshot: Unexpected token "/" while parsing css selector "./path/to/file.png"

Absolute paths work fine: browse screenshot /tmp/file.png ✅

Root Cause

In browse/src/meta-commands.ts line ~119, the argument classifier checks:

if (arg.startsWith('@e') || arg.startsWith('@c') || arg.startsWith('.') || arg.startsWith('#') || arg.includes('[')) {
  targetSelector = arg;
} else {
  outputPath = arg;
}

Any argument starting with . is classified as a CSS class selector. This catches relative paths like ./screenshots/page.png and .gstack/reports/page.png.

Suggested Fix

Add a file path check before the selector check:

const isFilePath = arg.includes('/') && /\.(png|jpe?g|webp|pdf)$/i.test(arg);
if (isFilePath) {
  outputPath = arg;
} else if (arg.startsWith('@e') || arg.startsWith('@c') || arg.startsWith('.') || arg.startsWith('#') || arg.includes('[')) {
  targetSelector = arg;
} else {
  outputPath = arg;
}

A file path containing / and ending with an image extension is unambiguously not a CSS selector.

Reproduction

$B goto "http://example.com"
$B screenshot /tmp/works.png          # ✅ works
$B screenshot ./fails.png             # ❌ "Unexpected token /"
$B screenshot .gstack/also-fails.png  # ❌ same error

Environment

  • gstack v0.11.18.2
  • WSL2 Ubuntu 24.04

Activity

  1. added a commit that references this issue on Mar 25, 2026
    e2b8567
  2. added a commit that references this issue on Mar 27, 2026
    b343ba2
  3. added a commit that references this issue on Mar 27, 2026
    3525c25
  4. added a commit that references this issue on Mar 29, 2026
    6e48660
  5. added a commit that references this issue on Mar 29, 2026
    e16f681
  6. added a commit that references this issue on May 30, 2026
    c6f397b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions