Skip to content

feat(file-browser): integrate selection mode state with actionStack for back navigation - #2546

Open
AuDevTist1C wants to merge 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:feat/file-browser-selection-back-navigation
Open

feat(file-browser): integrate selection mode state with actionStack for back navigation#2546
AuDevTist1C wants to merge 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:feat/file-browser-selection-back-navigation

Conversation

@AuDevTist1C

Copy link
Copy Markdown
Contributor

Overview

Integrates the file browser's multi-item selection mode into the application-wide actionStack. This ensures that triggering a back navigation action (such as pressing a physical device back button, hardware key, or system gesture) while in selection mode cleanly exits selection mode before popping the current directory view or closing the page.

Problem Context

Previously, entering selection mode within the file browser operated independently of the global actionStack context. Consequently:

  • Initiating a back navigation action while items were actively selected would bypass the selection state overlay and immediately pop the directory or navigate away from the current workspace, resulting in lost user context.
  • Exiting selection mode via non-back UI elements (e.g., confirmation buttons or manual dismissal) did not explicitly clean up lingering state handles, risking desynchronization between active UI layers and back-stack history.

Detailed Code Changes

  • src/pages/fileBrowser/fileBrowser.js:
    • Stack Registration: Guarded entry check using !actionStack.has("fbSelection") when enabling multi-selection mode. Pushes an action descriptor:
      {
          id: "fbSelection",
          action: () => {
              isSelectionMode = false;
              toggleSelectionMode(false);
          }
      }
      This intercepts back action events to reset internal flags (isSelectionMode = false) and trigger full UI state reset via toggleSelectionMode(false).
    • Stack Cleanup: Added actionStack.remove("fbSelection") to the exit/deactivation block (else branch) to unregister the selection frame from actionStack whenever selection mode is dismissed programmatically or via explicit user confirmation/cancellation.

Architecture & System Impact

  • Navigation Safety: Establishes a modal layer for selection mode inside actionStack, prioritizing selection exit over structural application navigation.
  • Stack Idempotency: Prevents duplicate action registration via actionStack.has("fbSelection") conditional checks.
  • Lifecycle Cleanup: Ensures clean stack teardown when selection mode terminates through standard user interactions.

Verification Checklist

  • Enter Selection Mode: Verify fbSelection is present in actionStack.
  • Back Gesture / Hardware Back: Verify pressing back cancels selection mode while keeping the user inside the current folder directory.
  • Manual Mode Dismissal: Verify exiting selection mode via UI controls invokes actionStack.remove("fbSelection"), leaving no leftover frames in the stack.

(PR name and description are AI generated (Gemini 3.6 Flash))

… back navigation

Integrate the file browser's multi-item selection mode directly into the application's global `actionStack` navigation controller to provide native hardware and interface back-button support.

When users enter multi-selection mode (e.g., long-pressing a file or checking multiple items), pressing the hardware back button or triggering back-gestures previously caused the application to navigate away from the current folder entirely, losing active context. This update registers selection mode as an isolated state layer within the global `actionStack`.

* **Action Stack Registration:**
  * Upon entering selection mode, the file browser pushes a `fbSelection` state descriptor to `actionStack`.
  * The back action handler captures `fbSelection` events to intercept back navigation, clearing all checked items and exiting selection mode first before any folder pops occur.
* **Stack Lifecycle Cleanup:**
  * Implemented automatic cleanup hooks to pop or unregister the `fbSelection` entry from `actionStack` whenever selection mode is dismissed through UI confirmation, cancel buttons, or batch execution tasks.

(AI generated commit message)
@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR integrates file-browser selection mode with the global back-navigation stack.

  • Registers an fbSelection action when selection mode starts.
  • Uses back navigation to reset selection state before navigating away.
  • Removes the selection action when selection mode is dismissed explicitly.

Confidence Score: 5/5

The PR appears safe to merge, with selection-mode registration and cleanup consistent with the existing action-stack lifecycle.

Back navigation pops the selection action before invoking its callback, explicit dismissal safely removes the matching action, and page teardown clears actions registered after the file browser’s stack mark.

Important Files Changed

Filename Overview
src/pages/fileBrowser/fileBrowser.js Adds balanced action-stack registration and cleanup around file-browser selection mode without an identified actionable defect.

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser as File Browser
    participant Stack as actionStack
    User->>Browser: Enter selection mode
    Browser->>Stack: push(fbSelection)
    User->>Stack: Back navigation
    Stack->>Browser: invoke selection callback
    Browser->>Browser: toggleSelectionMode(false)
    Browser->>Stack: remove(fbSelection)
Loading

Reviews (1): Last reviewed commit: "feat: integrate file selection mode with..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant