Skip to content

Conversation

@AshishViradiya153
Copy link
Contributor

@AshishViradiya153 AshishViradiya153 commented Jun 17, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved cache updates when deleting or moving documents and folders, ensuring the document list reflects changes accurately whether viewing a folder or filtered list.
    • Enhanced cache mutation logic to support different data shapes, resulting in more robust and consistent UI updates after document actions.
    • Updated breadcrumb navigation to use more reliable keys, improving stability and preventing potential rendering issues.

@AshishViradiya153 AshishViradiya153 requested a review from mfts as a code owner June 17, 2025 08:59
@vercel
Copy link

vercel bot commented Jun 17, 2025

@AshishViradiya153 is attempting to deploy a commit to the mftsio Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

The updates refine cache mutation and optimistic UI update logic for document deletion and movement, ensuring correct handling of different data shapes and query parameters. Breadcrumb key assignments were improved for React fragments and dropdown items. No exported function signatures were changed, and no control flow or error handling logic was altered.

Changes

File(s) Change Summary
components/documents/actions/delete-documents-modal.tsx Refined cache mutation after deletion to differentiate between folder and general document views, using query parameters when needed.
components/documents/document-card.tsx Enhanced deletion cache mutation to handle both array and object-with-documents data shapes, incorporating query parameters.
lib/documents/move-documents.ts Updated optimistic UI mutation to support both array and object-with-documents data shapes during document move; changed revalidate option syntax.
components/layouts/breadcrumb.tsx Improved React key assignments for fragments and dropdown items; changed fragment syntax for clarity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Cache
    participant Server

    User->>UI: Delete Document/Folder
    UI->>Server: Send delete request
    Server-->>UI: Confirm deletion
    UI->>Cache: Mutate cache
    alt Viewing folder
        Cache->>Cache: Mutate /documents/folder/[folderPathName]
    else General documents view
        Cache->>Cache: Mutate /documents with query params (search, sort, page, limit)
    end
    UI->>User: Update UI to reflect deletion
Loading
sequenceDiagram
    participant User
    participant UI
    participant Cache
    participant Server

    User->>UI: Move Document(s)
    UI->>Server: Send move request
    Server-->>UI: Confirm move
    UI->>Cache: Mutate cache
    alt Cache data is { documents: [...] }
        Cache->>Cache: Filter moved docs from documents array
    else Cache data is array
        Cache->>Cache: Filter moved docs from array
    end
    UI->>User: Update UI to reflect move
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-17T09_16_24_786Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28262a4 and ac58763.

📒 Files selected for processing (1)
  • lib/documents/move-documents.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/documents/move-documents.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 1

🧹 Nitpick comments (4)
components/layouts/breadcrumb.tsx (1)

296-315: Remove redundant keys inside the Fragment for cleaner markup

React.Fragment already owns the key for every iteration, so the nested BreadcrumbItem key={"item-${index}"} duplicates information and can trigger “key prop on non-list element” lint warnings.

-  <BreadcrumbItem key={`item-${index}`}>
+  <BreadcrumbItem>

This keeps a single source of truth for reconciliation keys.

components/documents/actions/delete-documents-modal.tsx (1)

142-167: Query-string construction logic duplicated across components

The same “build query string from search|sort|page|limit” block now exists here and in document-card.tsx. Extracting it to a tiny helper (e.g. lib/utils/buildDocumentQuery.ts) removes duplication and ensures both callers stay in sync with future param additions.

No functional bug – purely a maintainability gain.

components/documents/document-card.tsx (2)

134-145: Query-string assembly duplicated & a minor edge-case

This block is identical to the logic added in the delete-modal. Moving the code to a shared util (see previous comment) avoids divergence.

Edge-case: when neither search nor sort is present but the user is on page > 1, pagination params are silently dropped, so cache keys for pages > 1 won’t be mutated. Consider always appending page/limit when they differ from defaults.


155-178: Safe-guard when currentData.documents is missing

else if (currentData.documents) assumes truthiness; if the field exists but is undefined, the clause is skipped and the function returns the unfiltered data (good) but still evaluates the final return currentData after running an unnecessary branch. Compact the logic and add an Array.isArray guard to prevent surprises.

-} else if (currentData.documents) {
+} else if (Array.isArray(currentData?.documents)) {

Minor, yet avoids a potential runtime error if documents is not an array.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0dbbdf and 28262a4.

📒 Files selected for processing (4)
  • components/documents/actions/delete-documents-modal.tsx (2 hunks)
  • components/documents/document-card.tsx (2 hunks)
  • components/layouts/breadcrumb.tsx (8 hunks)
  • lib/documents/move-documents.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
components/layouts/breadcrumb.tsx (1)
components/ui/dropdown-menu.tsx (1)
  • DropdownMenuItem (192-192)
components/documents/document-card.tsx (1)
lib/types.ts (1)
  • DocumentWithLinksAndLinkCountAndViewCount (26-39)
🪛 Biome (1.9.4)
lib/documents/move-documents.ts

[error] 29-29: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
components/layouts/breadcrumb.tsx (1)

54-62: Composite key is a solid improvement
Switching from the bare index to a composite ${folder.path}-${index} key avoids subtle re-ordering bugs when folders with identical indexes are rendered in different lists.

@vercel
Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
papermark ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 2:21pm

@mfts mfts merged commit afec163 into mfts:main Jun 27, 2025
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants