Skip to content

fix: keep File Explorer highlight in sync with the active file - #530

Open
suhailopensource wants to merge 1 commit into
VoidenHQ:betafrom
suhailopensource:bugfix/file-explorer-active-highlight
Open

fix: keep File Explorer highlight in sync with the active file#530
suhailopensource wants to merge 1 commit into
VoidenHQ:betafrom
suhailopensource:bugfix/file-explorer-active-highlight

Conversation

@suhailopensource

Copy link
Copy Markdown

Problem

Closes #528. In the File Explorer a row's highlight comes from two independent sources — the active document (activeFile.source) and react-arborist's own selection (node.isSelected, set on click and never cleared). Clicking a file sets both, but every other way of changing the active document leaves the selection stale:

  • Close all tabsactiveFile becomes null but the last-clicked row stays selected, so it remains highlighted.
  • Switch tabs from the tab baractiveFile moves while the tree selection stays on the last-clicked file, so two rows are highlighted at once.

Fix

Drive the tree selection from the active document in the existing activeFile?.source effect (apps/ui/src/core/file-system/components/FileSystemList.tsx):

  • No active document → deselectAll(), so no row stays highlighted.
  • Active document → select(source, { focus: false }) (replacing the bare scrollTo), which clears any previous selection and scrolls the row into view, so exactly one row — the active file — is lit. focus: false keeps it a purely visual sync, and a cancelled guard avoids a stale select during rapid tab switches.

Testing

  • Verified manually in the running app: closing all tabs clears the highlight, and switching tabs never leaves two rows highlighted.
  • yarn typecheck (apps/ui): no new type errors from this change.

@suhailopensource
suhailopensource force-pushed the bugfix/file-explorer-active-highlight branch from 74cffdd to c5a2863 Compare August 3, 2026 15:35
@phurpa-tsering

Copy link
Copy Markdown
Collaborator

hey @suhailopensource ,

Two issues with Shift+click range selection here:

  1. Breaks the selection anchor — FileSystemList.tsx:615: opening a file sets react-arborist's selection anchor, then this effect's deselectAll() fires on the resulting activeFile.source change and wipes it. Since selectContiguous() needs that anchor, Shift+click right after opening any file selects nothing.

  2. Highlighting is inconsistent even when selection works — TreeNode.tsx:459: the active/open file always gets the single-selection bg-active style instead of the multi-select bg-accent/20 style, so a file range never looks fully highlighted the way a folder range does.

Worth a manual pass on file Shift+click before merging — these compound.

@suhailopensource

Copy link
Copy Markdown
Author

hey @suhailopensource ,

Two issues with Shift+click range selection here:

  1. Breaks the selection anchor — FileSystemList.tsx:615: opening a file sets react-arborist's selection anchor, then this effect's deselectAll() fires on the resulting activeFile.source change and wipes it. Since selectContiguous() needs that anchor, Shift+click right after opening any file selects nothing.
  2. Highlighting is inconsistent even when selection works — TreeNode.tsx:459: the active/open file always gets the single-selection bg-active style instead of the multi-select bg-accent/20 style, so a file range never looks fully highlighted the way a folder range does.

Worth a manual pass on file Shift+click before merging — these compound.

working on it will address it by today.

The file-tree row highlight has two independent sources: the active
document (activeFile.source) and react-arborist's own selection
(node.isSelected), which is set on click and never cleared. They desync
whenever the active document changes by any means other than a tree
click — switching tabs from the tab bar, or closing all tabs — leaving
the previously selected row highlighted, or two rows highlighted at once.

Drive the tree selection from the active document instead. With an active
document, select() replaces the previous selection and scrolls the row
into view (replacing the bare scrollTo), so exactly one row is lit; with
none, only the selected ids are cleared. Both paths keep react-arborist's
selection anchor intact — deselectAll() nulls it, and selectContiguous()
(Shift+click) has no range to select without one. focus: false keeps the
sync purely visual, and a cancelled guard avoids a stale select during
rapid tab switches.

A range selection now also keeps its background on every row it covers,
including the active file, which previously kept the single-selection
style and made a file range look broken up.

Fixes VoidenHQ#528
@suhailopensource
suhailopensource force-pushed the bugfix/file-explorer-active-highlight branch from c5a2863 to 05df466 Compare August 12, 2026 09:27
@suhailopensource

Copy link
Copy Markdown
Author

@phurpa-tsering done addressed ur review comments

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