Skip to content

feat(file-browser): open compact drawer from edge swipe - #304

Open
DrJsPBs wants to merge 4 commits into
daggerhashimoto:masterfrom
DrJLabs:feat/file-tree-edge-swipe-open
Open

feat(file-browser): open compact drawer from edge swipe#304
DrJsPBs wants to merge 4 commits into
daggerhashimoto:masterfrom
DrJLabs:feat/file-tree-edge-swipe-open

Conversation

@DrJsPBs

@DrJsPBs DrJsPBs commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

What

Add a compact-layout left-edge touch swipe gesture that opens the file explorer drawer.

Why

This gives touchscreen users a second way to open the compact file browser without removing or changing the existing button-based toggle.

How

  • add a useEdgeSwipeToOpen hook in src/features/file-browser/hooks/ to detect a narrow left-edge touch swipe and call the drawer opener only after a deliberate horizontal threshold
  • wire that hook into src/App.tsx, where compact layout and drawer visibility already live, and render a compact-only swipe zone when the drawer is collapsed
  • keep the existing header button toggle unchanged
  • add hook-level and App-level regression tests for swipe-open, vertical-cancel, and secondary-touch behavior

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🔧 Refactor / chore (no functional change)

Checklist

  • npm run lint passes
  • npm run build && npm run build:server succeeds
  • npm test -- --run passes
  • New features include tests
  • UI changes include a screenshot or screen recording

Screenshots

Not included. The change is a touch gesture opener and was verified through automated tests and live service validation.

Test Evidence

  • npm run lint
  • npm run build
  • npm run build:server
  • npm test -- --run

Full test result from the latest run:

  • 139 test files passed
  • 1814 tests passed

Notes:

  • Existing unrelated React act(...) warnings still appear in the suite, but the run exits successfully.
  • Contributor guide item about opening an issue first for non-trivial changes was not satisfied in this workflow; no issue was linked.

Summary by CodeRabbit

  • New Features

    • Left-edge swipe to open the file browser in compact layout (disabled in kanban view). Swipe must start at the left edge and be predominantly horizontal.
  • Tests

    • Added end-to-end and unit tests covering swipe opening, vertical-drift cancellation, non-touch ignoring, multi-touch handling, disabling mid-swipe, and app-level visibility gating for compact layout.

DrJsPBs added 2 commits April 18, 2026 14:09
Add a compact-layout left-edge touch swipe opener for the file explorer drawer while preserving the existing button toggle and file-tree long-press behavior. Also cover the new gesture with hook and App-level tests.
Stabilize the compact drawer swipe open callback and simplify the swipe hook to avoid root-level rerenders on pointer moves. Also ignore secondary touches during an active swipe and cover that behavior in the hook tests.
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36e0db2b-5251-4138-b0d9-c17090a91bb9

📥 Commits

Reviewing files that changed from the base of the PR and between 6101107 and 1cf4ea2.

📒 Files selected for processing (4)
  • src/App.test.tsx
  • src/App.tsx
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.test.ts
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.ts
✅ Files skipped from review due to trivial changes (1)
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/App.test.tsx
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.ts

📝 Walkthrough

Walkthrough

Edge-swipe-to-open for the compact file browser was added: a new useEdgeSwipeToOpen hook, App integration that wires pointer handlers when compact/non-kanban/collapsed, and tests covering hook behavior and App integration gestures. (50 words)

Changes

Cohort / File(s) Summary
Edge Swipe Hook
src/features/file-browser/hooks/useEdgeSwipeToOpen.ts, src/features/file-browser/hooks/useEdgeSwipeToOpen.test.ts
New exported hook implementing left-edge touch swipe detection and open callback; comprehensive unit tests for edge zone, horizontal threshold, vertical-drift cancellation, multi-touch, pointer-type filtering, and disabled-state behavior.
App Integration & Tests
src/App.tsx, src/App.test.tsx
App now imports/initializes useEdgeSwipeToOpen when isCompactLayout && viewMode !== 'kanban' && fileBrowserCollapsed; root element gains data-testid="app-shell" and pointer handlers bound to the hook. Added integration tests stubbing matchMedia to validate open vs. cancelled gestures.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant App
    participant useEdgeSwipeToOpen
    participant FileBrowserState

    User->>App: pointerDown at left edge (touch)
    App->>useEdgeSwipeToOpen: onPointerDown(event)
    useEdgeSwipeToOpen->>useEdgeSwipeToOpen: capture pointer, record start coords

    User->>App: pointerMove (predominantly horizontal)
    App->>useEdgeSwipeToOpen: onPointerMove(event)
    useEdgeSwipeToOpen->>useEdgeSwipeToOpen: compute deltas, check vertical drift
    alt horizontal threshold reached
        useEdgeSwipeToOpen->>App: invoke onOpen()
        App->>FileBrowserState: set fileBrowserCollapsed = false
        FileBrowserState->>App: render file-tree-panel
    else vertical drift exceeded
        useEdgeSwipeToOpen->>useEdgeSwipeToOpen: abort gesture, release capture
    end

    User->>App: pointerUp/pointerCancel
    App->>useEdgeSwipeToOpen: onPointerUp/Cancel(event)
    useEdgeSwipeToOpen->>useEdgeSwipeToOpen: reset gesture state
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I nudge the edge with a curious paw,

Files unfold where they once withdrew —
A flutter, a glide, the panel draws near,
Hooray! The compact world blooms anew. 🌿✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(file-browser): open compact drawer from edge swipe' clearly and specifically summarizes the main feature addition—enabling touch-based edge swipe gesture to open the file drawer in compact layout.
Description check ✅ Passed The PR description comprehensively covers all required template sections: What, Why, and How; includes Type of Change selection; provides detailed checklist completion; and explains test validation with results and notes about contributor guide non-compliance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/App.tsx`:
- Around line 1061-1072: The transparent fixed overlay (rendered when
compactFileBrowserSwipeEnabled) blocks taps on underlying compact controls;
instead move the pointer event listeners off that z-20 div and attach them to a
top-level container that already spans the viewport (e.g., app shell/root
container) in the capture phase using the same handlers
(compactFileBrowserSwipe.bind.onPointerDown/onPointerMove/onPointerUp/onPointerCancel),
and keep the hook’s internal clientX <= EDGE_SWIPE_ZONE_PX guard so only
edge-originating gestures start the swipe; alternatively, if you must keep an
element, ensure it does not intercept normal taps (e.g., pointer-events: none by
default and enable only when a pointerdown originates inside EDGE_SWIPE_ZONE_PX)
to avoid blocking underlying buttons.

In `@src/features/file-browser/hooks/useEdgeSwipeToOpen.ts`:
- Around line 31-80: The reset() helper currently clears pointerIdRef and
startRef but never releases any active pointer capture; update reset() to, if
pointerIdRef.current is non-null, attempt
eventTarget.releasePointerCapture(pointerIdRef.current) on the element that had
capture (wrap in try/catch because capture may be unavailable) before nulling
refs, and ensure onPointerDown stores the currentTarget (or otherwise can locate
the element) so reset can release on the same element; additionally add a
useEffect watching enabled that when enabled flips to false calls reset() (and
run reset() on unmount) to clear gesture state mid-stream; reference
functions/refs: reset, onPointerDown, pointerIdRef, startRef, onPointerMove,
onPointerUp, onPointerCancel, and add the useEffect for enabled cleanup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3e890d5d-556a-4b61-bb04-160fbec71b6d

📥 Commits

Reviewing files that changed from the base of the PR and between f4259c3 and 6101107.

📒 Files selected for processing (4)
  • src/App.test.tsx
  • src/App.tsx
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.test.ts
  • src/features/file-browser/hooks/useEdgeSwipeToOpen.ts

Comment thread src/App.tsx Outdated
Comment thread src/features/file-browser/hooks/useEdgeSwipeToOpen.ts
DrJsPBs and others added 2 commits April 18, 2026 15:27
Move compact drawer swipe detection onto the app shell capture path so the edge gesture no longer overlays or blocks existing controls. Also release pointer capture and reset gesture state when the hook is disabled or unmounted.
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