Skip to content

feat: open .html files in built-in browser pane#1427

Open
shreyaspapi wants to merge 4 commits intogeneralaction:mainfrom
shreyaspapi:feat/open-html-in-browser-pane
Open

feat: open .html files in built-in browser pane#1427
shreyaspapi wants to merge 4 commits intogeneralaction:mainfrom
shreyaspapi:feat/open-html-in-browser-pane

Conversation

@shreyaspapi
Copy link
Contributor

@shreyaspapi shreyaspapi commented Mar 11, 2026

Summary

Adds the ability to open local .html/.htm files in Emdash's built-in browser pane directly from the file explorer context menu. Also fixes a pre-existing bug where the browser pane's full-screen overlay blocked mouse events on the editor and sidebar.

Changes:

  • FileTree.tsx: Added "Open in Browser Pane" context menu item for .html/.htm files. Uses useBrowser().open() to load a file:// URL in the built-in browser pane.
  • BrowserPane.tsx: Moved pointer-events-auto from the full-screen outer wrapper to the inner pane div, so the editor and sidebar remain interactive when the browser pane is open. Also updated the address bar regex to accept file:// URLs without prepending http://.

Fixes

Fixes #1421

Snapshot

To be added

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 haven't checked if new and existing unit tests pass locally with my changes

@vercel
Copy link

vercel bot commented Mar 11, 2026

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

A member of the Team first needs to authorize it.

@shreyaspapi shreyaspapi marked this pull request as ready for review March 11, 2026 20:56
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR adds "Open in Browser Pane" to the file explorer context menu for .html/.htm files and fixes a pre-existing bug where the full-screen overlay wrapper was capturing mouse events even when the browser pane was closed. Both features are implemented cleanly. A new browserPaneUtils.ts module centralises URL-related logic (isHtmlFile, normalizeAddressBarUrl, buildFileUrl) and is covered by a dedicated test file.

Key changes:

  • BrowserPane.tsx: pointer-events-auto is now correctly scoped to the inner pane <div> rather than the full-screen wrapper, so the editor and sidebar remain interactive when the pane is hidden.
  • BrowserPane.tsx: Address-bar form submission delegates to normalizeAddressBarUrl, which now preserves file:// URLs in addition to http:///https://.
  • FileTree.tsx: "Open in Browser Pane" context menu entry rendered for HTML files via isHtmlFile, properly guarded inside the node.type === 'file' branch; handleOpenInBrowser is memoised with useCallback.
  • browserPaneUtils.ts: buildFileUrl has a Windows-compatibility bug — when rootPath has no leading / (e.g. C:/Users/...), the function emits file://C:/... instead of the required file:///C:/.... A one-line guard (absPath.startsWith('/') ? absPath : \/${absPath}``) would fix this. The test suite omits Windows-style path cases, so the bug goes undetected.

Confidence Score: 4/5

  • Safe to merge for macOS/Linux users; one minor Windows path-formatting bug in buildFileUrl should be addressed before shipping on Windows.
  • The logic for the pointer-events fix and the context menu feature is correct and well-structured. The only identified defect is in buildFileUrl: on Windows, the missing leading slash before a drive letter produces a malformed file://C:/... URL. Since the app appears to primarily target macOS (e.g. "Reveal in Finder"), this is low risk in practice but worth fixing before any Windows release.
  • Pay close attention to src/renderer/lib/browserPaneUtils.ts (buildFileUrl) and its test file for the Windows path edge case.

Important Files Changed

Filename Overview
src/renderer/lib/browserPaneUtils.ts New utility module with three helpers. isHtmlFile and normalizeAddressBarUrl are correct and well-tested. buildFileUrl has a Windows path bug: omits the required third slash when rootPath doesn't start with / (e.g. C:/... on Windows), producing file://C:/... instead of file:///C:/....
src/renderer/components/BrowserPane.tsx Two clean changes: (1) pointer-events-auto moved from the full-screen wrapper to the inner pane div, correctly fixing the mouse-event blocking bug; (2) inline address-bar URL normalisation replaced with the new normalizeAddressBarUrl utility, which also adds file:// support. Both changes are correct.
src/renderer/components/FileExplorer/FileTree.tsx Adds "Open in Browser Pane" context menu item, correctly guarded by node.type === 'file' and isHtmlFile(node.name). The handleOpenInBrowser callback is properly memoised with useCallback. The callback delegates path building to buildFileUrl(rootPath, node.path), consistent with how other handlers join these two values.
src/test/renderer/browserPaneUtils.test.ts Good coverage for isHtmlFile and normalizeAddressBarUrl. buildFileUrl tests only exercise Unix-style paths; no Windows-style drive-letter paths (e.g. C:/...) are tested, leaving the Windows bug undetected.

Sequence Diagram

sequenceDiagram
    participant User
    participant FileTree
    participant browserPaneUtils
    participant BrowserProvider
    participant BrowserPane
    participant ElectronAPI

    User->>FileTree: Right-click .html file
    FileTree->>FileTree: isHtmlFile(node.name) → show menu item
    User->>FileTree: Click "Open in Browser Pane"
    FileTree->>browserPaneUtils: buildFileUrl(rootPath, node.path)
    browserPaneUtils-->>FileTree: file:///root/path/to/file.html
    FileTree->>BrowserProvider: browser.open(fileUrl)
    BrowserProvider->>BrowserProvider: navigate(fileUrl) → setUrl(fileUrl)
    BrowserProvider->>ElectronAPI: browserLoadURL(fileUrl)
    BrowserProvider->>BrowserProvider: setOpen(true)
    BrowserPane->>BrowserPane: paneVisible=true, shouldShow=true
    BrowserPane->>ElectronAPI: browserShow(bounds, fileUrl)
    ElectronAPI-->>User: HTML file rendered in browser pane
Loading

Last reviewed commit: 5043944

Ensure the joined path always starts with / before prepending file://
so Windows paths like C:/Users/... produce file:///C:/Users/... (three
slashes) instead of the malformed file://C:/... Also normalise
backslashes to forward slashes. Adds Windows path test coverage.
@arnestrickmann
Copy link
Contributor

Thanks! @shreyaspapi
Could you post a screen recording of the UX for this addition?

@shreyaspapi
Copy link
Contributor Author

Thanks! @shreyaspapi Could you post a screen recording of the UX for this addition?

Screen.Recording.2026-03-13.at.12.24.28.PM.mov

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: Open .html files in the built-in browser pane

2 participants