Skip to content

Small explorer tweaks and fixes#24

Merged
JackDerksen merged 9 commits intomainfrom
exploring
Apr 22, 2026
Merged

Small explorer tweaks and fixes#24
JackDerksen merged 9 commits intomainfrom
exploring

Conversation

@JackDerksen
Copy link
Copy Markdown
Owner

@JackDerksen JackDerksen commented Apr 22, 2026

Some small tweaks and fixes to explorer behaviour.

Highlights:

  • Writing a path in the explorer now creates a proper nested directory structure
  • Allow persisted draft edits across multiple directories
  • More descriptive messages for explorer operations

A larger explorer feature is coming soon ;)

Summary by CodeRabbit

  • New Features
    • Explorer drafts now persist unsaved changes across directory navigation
    • Support for nested paths and directory creation in explorer operations
    • Detailed deletion confirmation listings showing all targeted files and directories
    • Comprehensive write operation status messages reporting created, renamed, and deleted items
    • Status messages now display while explorer is open
    • Toast notifications display more content before wrapping

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@JackDerksen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 56 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 26 minutes and 56 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95b90f97-8b42-489b-a28f-82e5c95acd17

📥 Commits

Reviewing files that changed from the base of the PR and between c0a60ca and f3fadc5.

📒 Files selected for processing (32)
  • crates/redox-core/src/buffer/text_buffer/search.rs
  • crates/redox-tui/src/app/state/actions.rs
  • crates/redox-tui/src/app/state/analysis.rs
  • crates/redox-tui/src/app/state/editing.rs
  • crates/redox-tui/src/app/state/explorer.rs
  • crates/redox-tui/src/app/state/rain_mode.rs
  • crates/redox-tui/src/app/state/search.rs
  • crates/redox-tui/src/app/state/tests.rs
  • crates/redox-tui/src/input/cursor.rs
  • crates/redox-tui/src/input/mod.rs
  • crates/redox-tui/src/ui/mod.rs
  • crates/redox-tui/src/ui/overlays.rs
  • crates/redox-tui/src/ui/rain_animation.rs
  • crates/redox-tui/src/ui/render.rs
  • crates/redox-tui/src/ui/syntax/languages/c.rs
  • crates/redox-tui/src/ui/syntax/languages/cpp.rs
  • crates/redox-tui/src/ui/syntax/languages/css.rs
  • crates/redox-tui/src/ui/syntax/languages/go.rs
  • crates/redox-tui/src/ui/syntax/languages/html.rs
  • crates/redox-tui/src/ui/syntax/languages/javascript.rs
  • crates/redox-tui/src/ui/syntax/languages/json.rs
  • crates/redox-tui/src/ui/syntax/languages/lua.rs
  • crates/redox-tui/src/ui/syntax/languages/markdown.rs
  • crates/redox-tui/src/ui/syntax/languages/python.rs
  • crates/redox-tui/src/ui/syntax/languages/toml.rs
  • crates/redox-tui/src/ui/syntax/languages/typescript.rs
  • crates/redox-tui/src/ui/syntax/languages/yaml.rs
  • crates/redox-tui/src/ui/widgets/about.rs
  • crates/redox-tui/src/ui/widgets/command_line.rs
  • crates/redox-tui/src/ui/widgets/perf.rs
  • crates/redox-tui/src/ui/widgets/popup.rs
  • crates/redox-tui/src/ui/widgets/status_bar.rs
📝 Walkthrough

Walkthrough

Explorer state now manages per-directory drafts that persist across navigation, with each draft tracking original entries and edited text. Deletion confirmation and write operations were rewritten to handle multiple directories simultaneously, building aggregated change results. Entry parsing now supports nested relative paths with improved validation, and filesystem operations were extended accordingly. Cursor handling for the explorer popup was refactored to return cursor specifications rather than requesting them directly.

Changes

Cohort / File(s) Summary
Explorer State Refactoring
crates/redox-tui/src/app/state/explorer.rs
Replaced single original_entries with per-directory directory_drafts HashMap. Deletion confirmation logic rewritten to compute deletions per draft and build multi-line confirmation tokens. Write operation now iterates across all drafts, applies filesystem changes, and aggregates results into AppliedExplorerChanges. Entry parsing extended to support nested relative paths with normalized segment handling and parent directory preservation.
Test Updates
crates/redox-tui/src/app/state/tests.rs
Updated existing write/delete tests with precise status assertions. Added new tests for nested path creation, unsaved draft persistence across navigation, cached multi-directory draft application, and mixed delete/create confirmation flows. Enhanced startup about/explorer navigation escape handling with detailed assertions.
UI Rendering Updates
crates/redox-tui/src/lib.rs, crates/redox-tui/src/ui/widgets/explorer.rs
draw_explorer_popup_view now returns Option<CursorSpec> instead of (), computing cursor offset adjustments and delegating cursor request to caller. draw_buffer_view now captures returned cursor spec and conditionally hides cursor when status toast occludes it. Added test for status toast rendering while explorer is open.
Toast Layout
crates/redox-tui/src/ui/widgets/toast.rs
Increased TOAST_MAX_TEXT_WIDTH constant from 25 to 40, allowing wrapped toast messages to render with greater width before truncation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditorState as EditorState
    participant ExplorerState as ExplorerState<br/>(Drafts)
    participant FileSystem as FileSystem
    participant BufferSync as BufferSync

    User->>EditorState: Navigate to directory
    EditorState->>ExplorerState: Save current directory draft
    EditorState->>ExplorerState: Load target directory draft

    User->>EditorState: Edit explorer entries
    EditorState->>ExplorerState: Update draft text

    User->>EditorState: Press 'w' to write
    EditorState->>ExplorerState: Iterate all directory drafts
    
    loop For each directory draft
        ExplorerState->>ExplorerState: Parse draft text to entries
        ExplorerState->>ExplorerState: Compute deletes/renames/creates
        ExplorerState->>FileSystem: Apply filesystem changes
        FileSystem->>ExplorerState: Return operation results
        ExplorerState->>ExplorerState: Aggregate into AppliedExplorerChanges
    end

    ExplorerState->>BufferSync: Sync renamed/deleted/created file buffers
    ExplorerState->>EditorState: Update status with aggregated changes
    EditorState->>User: Display detailed change summary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hops through folders, drafts in hand,
Each directory now understands,
Multi-path writes, nested creations grand,
Explorer persists across every land!
Status toasts shine bright when changes stand,
A rabbit's refactor, perfectly planned. 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive terms like "Small tweaks and fixes" that don't convey the main scope of the significant changes to the explorer feature. Consider a more specific title that reflects the primary changes, such as: "Support per-directory drafts and nested path creation in explorer" or "Enhance explorer with draft persistence and nested directory support".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch exploring

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/redox-tui/src/app/state/explorer.rs (1)

777-782: ⚠️ Potential issue | 🟠 Major

Reject nested path prefix conflicts before applying changes.

The duplicate-name check allows incompatible entries such as foo and foo/bar.txt, or deleting foo/ while creating foo/bar.txt. The later delete/create loops can partially mutate the tree or produce contradictory summaries. Validate normalized path components up front so file entries cannot be ancestors of other entries, and creations under deleted directories are rejected unless that directory remains.

Also applies to: 879-897

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

Inline comments:
In `@crates/redox-tui/src/app/state/explorer.rs`:
- Around line 483-506: The current loop applies drafts immediately which can
cause parent renames/deletes to invalidate cached child drafts and leave partial
filesystem changes; instead, implement a two-phase plan: first iterate
explorer.directory_drafts and desired_entries_by_dir to produce a write plan
(collecting per-dir results from apply_explorer_changes for each draft path)
while detecting renamed or deleted ancestors and remapping or dropping any child
drafts under those ancestors, storing results into an
AppliedExplorerChanges-like structure without mutating the FS; then execute the
concrete filesystem mutations and call sync_session_after_explorer_write using
that resolved plan. Use the existing symbols (explorer.directory_drafts,
apply_explorer_changes, AppliedExplorerChanges,
explorer_delete_confirmation_token, sync_session_after_explorer_write) to locate
code, ensure errors during the planning phase still clear
explorer_delete_confirmation_token and report status but do not apply partial
writes, and only perform actual writes once the plan is finalized.
- Around line 970-985: The confirmation list currently flattens per-directory
targets causing ambiguous duplicate names; update
format_explorer_delete_confirmation to include the directory context (prefix
each target with the dir_path or group targets under their dir_path) when
building targets by using explorer_delete_confirmation_targets(dir_path,
deletions) or by mapping its results to format "{dir_path}/{target}" so entries
are unambiguous, keep the noun/count logic unchanged, and apply the same fix to
the other similar confirmation formatter mentioned in the review (the companion
formatter that builds multi-directory prompts) so both delete and the other
multi-dir confirmation outputs include directory prefixes or grouped lists.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

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: 66ab800c-a00a-4a42-a0b2-74d167320914

📥 Commits

Reviewing files that changed from the base of the PR and between 3198025 and c0a60ca.

📒 Files selected for processing (5)
  • crates/redox-tui/src/app/state/explorer.rs
  • crates/redox-tui/src/app/state/tests.rs
  • crates/redox-tui/src/lib.rs
  • crates/redox-tui/src/ui/widgets/explorer.rs
  • crates/redox-tui/src/ui/widgets/toast.rs

Comment thread crates/redox-tui/src/app/state/explorer.rs Outdated
Comment thread crates/redox-tui/src/app/state/explorer.rs
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@JackDerksen JackDerksen merged commit 11098d7 into main Apr 22, 2026
2 checks passed
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