Skip to content

Conversation

@dorgold
Copy link

@dorgold dorgold commented Jun 6, 2025

Addresses: #438

Summary by CodeRabbit

  • Bug Fixes
    • Improved tag handling to ensure automatic tags are correctly removed from documents after processing, preventing potential re-processing loops.
    • Enhanced tag management to avoid duplicate tags when updating documents.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

Walkthrough

The changes update the handling of the autoTag in document processing. In background.go, the autoTag is now always appended to the RemoveTags slice for each document suggestion, ensuring its removal after processing. In paperless.go, the explicit removal of autoTag from the suggested tags list is eliminated.

Changes

File(s) Change Summary
background.go Ensures autoTag is appended to RemoveTags for each suggestion; sorts and compacts the slice.
paperless.go Removes code that explicitly deleted autoTag from the suggested tags list during document updates.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler
    participant Background
    participant PaperlessClient

    Scheduler->>Background: processAutoTagDocuments()
    loop For each document suggestion
        Background->>Background: Append autoTag to RemoveTags, sort & compact
    end
    Background->>PaperlessClient: UpdateDocuments(suggestions)
    PaperlessClient->>PaperlessClient: Update documents (no explicit autoTag removal from tags)
Loading

Possibly related PRs

Poem

A tag once stuck, now set to go,
With careful code, we make it so.
No more loops that never end,
Uniqueness rules as we amend.
The autoTag hops off with glee—
Clean as a bunny, document spree!
🐇✨


📜 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 32d04eb and a8b4191.

📒 Files selected for processing (2)
  • background.go (1 hunks)
  • paperless.go (0 hunks)
💤 Files with no reviewable changes (1)
  • paperless.go
🔇 Additional comments (2)
background.go (2)

135-135: Minor formatting improvement.

The error formatting has been corrected for better consistency.


125-131:

✅ Verification successful

Excellent fix for preventing reprocessing loops.

The implementation correctly ensures that autoTag is removed after processing by adding it to the RemoveTags slice. The use of slices.Sort and slices.Compact appropriately handles potential duplicates if autoTag was already present in RemoveTags.

This change effectively addresses the PR objective by moving tag removal responsibility from paperless.go to the background processing logic, which should resolve the issue where the OCR complete tag wasn't being added when PDF_OCR_COMPLETE_TAG == AUTO_TAG.

To ensure the fix works as intended, please verify that autoTag is properly defined and accessible in this scope:


🏁 Script executed:

#!/bin/bash
# Verify autoTag variable definition and usage
ast-grep --pattern 'autoTag'

Length of output: 836


🏁 Script executed:

#!/bin/bash
# Display the package declaration and imports in background.go
sed -n '1,20p' background.go

Length of output: 475


Approve: autoTag Removal Logic Verified

The change correctly appends autoTag to RemoveTags and de-duplicates it using slices.Sort and slices.Compact. We’ve confirmed that autoTag is declared as a package-level variable in main.go and is accessible within background.go. No further changes are required.

✨ 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.

@icereed
Copy link
Owner

icereed commented Jun 6, 2025

Hey, awesome for fixing this. I believe there can be some side effects if you do “undo” on an auto processed document. Could you check that? I’m not a lot online at the moment as I’m traveling.

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