emdash icon indicating copy to clipboard operation
emdash copied to clipboard

fix(browser): make tabs not always reload in the in app browser

Open janburzinski opened this issue 5 months ago • 2 comments

Description

  • in app browser tabs not reloading on refocus

Screenshot/Recording (if applicable)

https://streamable.com/4hdjuw

Checklist
  • [X] I kept this PR small and focused
  • [X] I ran a self-review before opening this PR
  • [X] I ran the relevant local checks or explained why not
  • [X] I updated docs when behavior or setup changed
  • [X] I added or updated tests when behavior changed, or explained why not
  • [X] I only added comments where the logic is not obvious
  • [X] I used Conventional Commits for commit messages and, when possible, the PR title

janburzinski avatar Jun 16 '26 17:06 janburzinski

Greptile Summary

This PR fixes in-app browser tabs reloading on refocus by keeping all browser panes mounted at all times (toggled via display:none through ShowHide) rather than unmounting and remounting the active pane on each tab switch. A visible prop is threaded into BrowserPane so setActiveBrowser is correctly called whenever a tab becomes active, and a new useEffect in PaneContent clears the active browser reference when the user switches away to a non-browser tab.

  • BrowserPane gains a visible prop; the setActiveBrowser effect now guards on !visible and includes visible in its dependency array, ensuring the main process is notified on every tab activation.
  • PaneContent pre-renders all browser tabs via ShowHide and handles the "navigated away from browser" case with a dedicated effect that calls setActiveBrowser(null) when activeBrowserId becomes null.
  • The .filter() call that produces browserTabs is missing a TypeScript type predicate, so the result is ResolvedTab[] and the subsequent tab.browserId access is a likely compilation error.

Confidence Score: 4/5

Safe to merge once the TypeScript type predicate issue in pane-content.tsx is resolved; the core tab-switching logic is correct.

The filter call in pane-content.tsx lacks a type predicate, leaving browserTabs typed as ResolvedTab[]. Accessing tab.browserId in the subsequent .map() would be a TypeScript compilation error unless the team's tsconfig is unusually lenient. The rest of the logic is sound and correctly addresses the tab-reload regression.

apps/emdash-desktop/src/renderer/features/tasks/view/pane-content.tsx — the missing type predicate on the filter call.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/renderer/features/tasks/view/pane-content.tsx Switches from conditionally rendering the active BrowserPane to rendering all browser tabs via ShowHide; adds a useEffect to call setActiveBrowser(null) when no browser tab is active — but the .filter() lacks a type predicate, likely causing a TypeScript compilation error on tab.browserId.
apps/emdash-desktop/src/renderer/features/browser/browser-pane.tsx Adds a visible prop; guards setActiveBrowser with !visible and adds visible to the dependency array so it fires correctly when the tab becomes active rather than only on initial mount.

Reviews (2): Last reviewed commit: "fix(browser): update active pane on tab ..." | Re-trigger Greptile

greptile-apps avatar Jun 16 '26 17:06 greptile-apps

@greptileai

janburzinski avatar Jun 16 '26 17:06 janburzinski

LGTM — thank you for the fix. Merging this.

One thing I noticed while testing: when I switch away from a task that has a browser tab open, then come back and re-enter that tab, the browser reloads.

I think we should prevent this self-reload behavior entirely if possible, since it can interrupt the user’s state. @janburzinski - I would propose to do this in a separate PR.

arnestrickmann avatar Jun 16 '26 22:06 arnestrickmann