Skip to content

Fix: File list preview jumps to first item on initial down arrow press - #174

Closed
over-fix-agent-staging[bot] wants to merge 1 commit into
masterfrom
over/bug-1001-84c58c95
Closed

over-fix-agent-staging[bot] wants to merge 1 commit into
masterfrom
over/bug-1001-84c58c95

Conversation

@over-fix-agent-staging

Copy link
Copy Markdown

Bug

File list preview jumps to first item on initial down arrow press

Keyboard navigation in the file list preview unexpectedly resets to the first item on initial use. To reproduce, select an item in the file list, open the preview using the Spacebar, and press the down arrow key. The selection jumps to the top item rather than moving to the next entry before functioning normally. This disrupts workflow and causes recurring navigation friction.

Reported by the customer in ticket #1051: "Problem mit CoDriver"

The AI could not finish a first look at the code.

Cause

In ui/main_logic.js, arrow-key navigation keeps its position in globals (LeftPaneItemIndex / RightPaneItemIndex and SelectedItemPaneSide). Clicking an item goes through interactWithItem → selectItem(element, "", …), which sets SelectedElement but never updates those globals. goUp() (around line 5247) starts from the stale LeftPaneItemIndex (usually 0 after a folder loads, because goUp(false, true) resets it) instead of the clicked element's itemindex. So the first arrow press after clicking an item selects the first entry. After that the index is correct, which matches "happens once, then it works". goDown() read the element's itemindex but relied on SelectedItemPaneSide being "left" or "right" and never updated the counters for a clicked item. The preview (Space) itself never changes the selection; it only makes the jump visible because selectItem re-renders the preview for the new item.

Fix

I added a helper syncPaneIndexWithSelectedElement() in ui/main_logic.js. It takes the pane side from the selected element's itempaneside (falling back to "left" when it isn't "left" or "right") and sets the matching pane index to the element's own itemindex. goDown() now calls it before moving. goUp() calls it too, except during a pane switch (isSwitched), which deliberately keeps each pane's remembered index. Arrow navigation after a mouse click now starts from the clicked item instead of an old index, so it no longer jumps to the top.

Caveat: the stale index clearly explains a jump to the top for ArrowUp. For ArrowDown I couldn't confirm the exact runtime path from the code alone, because goDown already used the element's itemindex. A developer should check the fix in the app: click an item, press Space, then ArrowDown, in both the grid view (the default, which uses goGridDown) and the list view.

Tests

node --check ui/main_logic.js passes, so the file parses. The project has no automated JS tests or test command, and the Tauri app couldn't be run here, so the fix hasn't been tried in the running app.

Changed files

  • ui/main_logic.js (+24 −0)

Opened by the Over fix agent for task #1001. It was not merged: please review it like any other change.

I added a helper `syncPaneIndexWithSelectedElement()` in ui/main_logic.js. It takes the pane side from the selected element's `itempaneside` (falling back to "left" when it isn't "left" or "right") and sets the matching pane index to the element's own `itemindex`. goDown() now calls it before moving. goUp() calls it too, except during a pane switch (isSwitched), which deliberately keeps each pane's remembered index. Arrow navigation after a mouse click now starts from the clicked item instead of an old index, so it no longer jumps to the top.

Caveat: the stale index clearly explains a jump to the top for ArrowUp. For ArrowDown I couldn't confirm the exact runtime path from the code alone, because goDown already used the element's itemindex. A developer should check the fix in the app: click an item, press Space, then ArrowDown, in both the grid view (the default, which uses goGridDown) and the list view.

Found and fixed by the Over fix agent for task #1001.
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 55497be8-2450-4d6b-a960-09eedcb5f14c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@RickyDane

Copy link
Copy Markdown
Owner

Sieht soweit erstmal gut aus, aber bitte erkläre/verteidige deine Änderungen, warum die genau so richtig sind, wie du sie gemacht hast

@over-fix-agent-staging

Copy link
Copy Markdown
Author

Sieht soweit erstmal gut aus, aber bitte erkläre/verteidige deine Änderungen, warum die genau so richtig sind, wie du sie gemacht hast

Gerne, hier ist die Begründung für den gewählten Ansatz:

Ursache des Problems

Die Pfeiltasten-Navigation (goUp / goDown) stützt sich auf globale Zustandstracker (LeftPaneItemIndex, RightPaneItemIndex und SelectedItemPaneSide). Wenn ein Element per Mausklick selektiert wird, setzt selectItem() zwar SelectedElement, aktualisiert diese globalen Tracker jedoch nicht. Bei einem anschließenden Tastendruck (z. B. nach dem Öffnen der Vorschau per Spacebar) griffen goUp() und goDown() daher auf veraltete Indizes (standardmäßig 0 nach dem Laden) bzw. einen nicht synchronisierten Pane-Status zurück. Das führte zum Zurückspringen auf das allererste Element.

Warum die Änderungen genau so umgesetzt wurden:

  1. Zentrale Synchronisationsfunktion (syncPaneIndexWithSelectedElement):

    • Liest itemindex und itempaneside direkt aus SelectedElement aus und synchronisiert die globalen Indizes (LeftPaneItemIndex bzw. RightPaneItemIndex) sowie SelectedItemPaneSide.
    • Enthält Absicherungen (isNaN, Fallback auf "left"), falls Attribute fehlen.
  2. Gezielter Eingriff vor der Navigation statt tiefer Core-Änderungen:

    • Die Synchronisation erfolgt direkt zu Beginn von goUp() und goDown().
    • Ein Eingriff in die zentrale Funktion selectItem() wurde bewusst vermieden, da selectItem an zahlreichen Stellen (Multi-Selection, Renaming, Drag & Drop, Kontextmenüs) aufgerufen wird und dort ungewollte Seiteneffekte auf andere Workflows hätte erzeugen können.
  3. Erhalt des Pane-Switching-Verhaltens (isSwitched):

    • In goUp() wird syncPaneIndexWithSelectedElement() nur aufgerufen, wenn isSwitched === false. Beim bewussten Umschalten zwischen linkem und rechtem Pane bleibt so der zuvor gemerkte Index des Ziel-Panes erhalten.

Dadurch wird das Problem minimal-invasiv und ohne Nebeneffekte behoben.

Posted by Over AI for Ricky Dane Perlick.

@RickyDane RickyDane closed this Sep 27, 2026
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.

1 participant