Skip to content

feat: Add shelf exclusion filter to BookStack connector#894

Open
vorsengineer wants to merge 1 commit intoMODSetter:mainfrom
vorsengineer:feature/bookstack-shelf-exclusion
Open

feat: Add shelf exclusion filter to BookStack connector#894
vorsengineer wants to merge 1 commit intoMODSetter:mainfrom
vorsengineer:feature/bookstack-shelf-exclusion

Conversation

@vorsengineer
Copy link

@vorsengineer vorsengineer commented Mar 20, 2026

Summary

  • Add shelf exclusion filter to BookStack connector — lets users choose which shelves to include/exclude from indexing
  • New POST /api/v1/bookstack/shelves endpoint to fetch shelves for the picker UI
  • Shelf picker added to both the connect form and config/edit view
  • Fully backward compatible — no migration needed, stored in existing connector config JSON

Motivation

BookStack organizes content in a Shelves > Books > Chapters > Pages hierarchy. Teams often have shelves that shouldn't be indexed into certain search spaces (e.g., internal/private shelves, archives). This feature gives users control over what gets synced.

FIX #892

Screenshots

The shelf picker appears in the connector setup after clicking "Load Shelves":

  • Checkbox list shows all shelves with book counts
  • Unchecked shelves are excluded (shown with "Excluded" badge)
  • Excluded shelves shown as removable red badges below the list

Changes

Backend (3 files)

  • bookstack_connector.py: Added get_all_shelves(), build_book_to_shelf_map(), and excluded_shelf_ids parameter to page fetching methods
  • bookstack_indexer.py: Reads BOOKSTACK_EXCLUDED_SHELF_IDS from connector config
  • search_source_connectors_routes.py: New POST /bookstack/shelves endpoint

Frontend (3 files)

  • bookstack-connect-form.tsx: Shelf picker with "Load Shelves" button
  • bookstack-config.tsx: Same shelf picker on the edit view
  • connectors-api.service.ts: listBookStackShelves() method

API Changes

  • New endpoint: POST /api/v1/bookstack/shelves (accepts credentials, returns shelves with books)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement
  • Refactoring (no functional changes)
  • Documentation update
  • Dependencies update
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Testing

  • I have tested this locally
  • Manual/QA testing done
    • Verified shelf picker loads correctly with valid credentials
    • Verified excluded shelves are filtered during indexing
    • Verified existing connectors without exclusions still work (backward compat)
    • Verified periodic sync respects exclusion list

Quality Checklist

  • My code follows the coding standards of this project
  • I have updated the documentation if necessary
  • I have not added any unnecessary dependencies
  • There are no lint errors in my changes
  • All existing tests still pass

🤖 Generated with Claude Code

High-level PR Summary

This PR adds shelf exclusion filtering to the BookStack connector, allowing users to selectively choose which shelves to include or exclude during indexing. The implementation includes a new backend endpoint (POST /api/v1/bookstack/shelves) to fetch available shelves, enhanced filtering logic in the connector and indexer to respect excluded shelf IDs stored in the connector configuration, and a shelf picker UI in both the connector setup and edit views. The feature is fully backward compatible with no database migrations required, as the exclusion list is stored in the existing connector config JSON field.

⏱️ Estimated Review Time: 15-30 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/routes/search_source_connectors_routes.py
2 surfsense_web/lib/apis/connectors-api.service.ts
3 surfsense_backend/app/connectors/bookstack_connector.py
4 surfsense_backend/app/tasks/connector_indexers/bookstack_indexer.py
5 surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/bookstack-connect-form.tsx
6 surfsense_web/components/assistant-ui/connector-popup/connector-configs/components/bookstack-config.tsx

Need help? Join our Discord

Analyze latest changes

Add the ability to exclude specific BookStack shelves from indexing,
allowing users to control which content gets synced into a search space.

Backend:
- Add get_all_shelves() and build_book_to_shelf_map() to BookStackConnector
- Add excluded_shelf_ids parameter to get_all_pages() and get_pages_by_date_range()
- Read BOOKSTACK_EXCLUDED_SHELF_IDS from connector config in the indexer
- Add POST /api/v1/bookstack/shelves endpoint for frontend shelf picker

Frontend:
- Add shelf picker to bookstack-connect-form.tsx (initial setup)
- Add shelf picker to bookstack-config.tsx (edit view)
- Add listBookStackShelves() to connectors-api.service.ts
- Shelves loaded on-demand via "Load Shelves" button after credentials entered
- Checkbox UI: checked = included, unchecked = excluded
- Excluded shelf IDs stored as BOOKSTACK_EXCLUDED_SHELF_IDS in connector config

Fully backward compatible - existing connectors without excluded shelf IDs
continue to index all pages. No database migration needed.

Ref MODSetter#892

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 20, 2026

@vorsengineer is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on 54e56e1..b8ea6e6

  Severity     Location     Issue     Delete  
High surfsense_backend/app/connectors/bookstack_connector.py:210 KeyError in shelf map building
✅ Files analyzed, no issues (4)

surfsense_backend/app/tasks/connector_indexers/bookstack_indexer.py
surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/bookstack-connect-form.tsx
surfsense_web/components/assistant-ui/connector-popup/connector-configs/components/bookstack-config.tsx
surfsense_web/lib/apis/connectors-api.service.ts

@MODSetter
Copy link
Owner

@vorsengineer Thanks for your contributions. Can you please raise both PRs on the dev branch?

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.

feat: Add shelf exclusion filter to BookStack connector

2 participants