Skip to content

Fix cross-platform URL opening on Windows and Linux - #36

Merged
brianlovin merged 3 commits into
mainfrom
cursor/cross-platform-url-open-4ee3
Aug 23, 2026
Merged

Fix cross-platform URL opening on Windows and Linux#36
brianlovin merged 3 commits into
mainfrom
cursor/cross-platform-url-open-4ee3

Conversation

@brianlovin

@brianlovin brianlovin commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Supersedes #35 (thanks @jensrot for the original idea and the README OpenTUI credit fix). That PR correctly added a platform-aware open helper and pointed the OpenTUI credit at anomalyco/opentui, but its code path had blockers this change avoids.

Why

onOpenUrl hardcoded macOS open, so opening articles failed on Windows and Linux even though optionalDependencies already ship binaries for those platforms.

What changed

  • Local openUrl helper in src/index.ts using execFile (no shell interpolation of the URL):
    • darwin: open <url>
    • win32: cmd /c start "" <url> (start is a cmd builtin, not an executable)
    • linux (and others): xdg-open <url>
  • README Credits: OpenTUI link now points at https://github.com/anomalyco/opentui

Why not merge #35 as-is

  1. Unused/wrong import { open } from "fs"
  2. exec('start "" "…") fails on Windows because start is not an executable
  3. Shell-interpolated exec(\… "${url}"`)` breaks on quotes/spaces

No new dependency. Helper stays in src/index.ts to match the existing clipboard platform split in src/app.ts.

Follow-up: flaky story-list scroll test

CI on this PR (and the last two docs-only pushes to main) failed should scroll down to show off-screen selected story. Unrelated to URL opening.

Root cause: selectStory called scrollToStory only after await getPostById(). selectedIndex updates synchronously, but list scroll waited on the HNPWA network. renderer.idle() does not wait for fetch. When the request is slow or hung, scrollTop stays 0 — matching CI (currentSelectedIndex === 14, scrollTop === 0). The sibling “scroll up” test does more navigation and often wins the race.

Fix: scroll immediately from the last laid-out frame, before the detail fetch. Ignore zero-size layout metrics so a stale 0×0 frame cannot reset scrollTop. The down-scroll test now hangs fetch so this cannot regress on network timing.

Do not merge.

Open in Web Open in Cursor 

cursoragent and others added 3 commits August 23, 2026 17:08
Open story URLs with execFile on darwin, win32, and linux so Windows
uses cmd /c start and URLs are passed as arguments, not interpolated
into a shell string. Also point the OpenTUI credit at anomalyco/opentui.

Co-authored-by: Brian Lovin <brianlovin@users.noreply.github.com>
scrollToStory ran after await getPostById, so a slow or hung HNPWA
request left selectedIndex updated and scrollTop at 0. Scroll
immediately from the last laid-out frame, ignore zero-size layout
metrics, and lock the regression with a hanging-fetch test.

Co-authored-by: Brian Lovin <brianlovin@users.noreply.github.com>
Attach preconnect so the hanging/404 fetch stubs satisfy typeof fetch.

Co-authored-by: Brian Lovin <brianlovin@users.noreply.github.com>
@brianlovin
brianlovin marked this pull request as ready for review August 23, 2026 17:16
@brianlovin
brianlovin merged commit 2440308 into main Aug 23, 2026
3 checks passed
@brianlovin
brianlovin deleted the cursor/cross-platform-url-open-4ee3 branch August 23, 2026 17:18
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.

2 participants