Skip to content

refactor(views): group per-module view modules into views packages - #865

Merged
pchopinet merged 1 commit into
mainfrom
refactor/views-packages
Aug 28, 2026
Merged

refactor(views): group per-module view modules into views packages#865
pchopinet merged 1 commit into
mainfrom
refactor/views-packages

Conversation

@pchopinet

Copy link
Copy Markdown
Member

Summary

Six modules had grown a flat sprawl of views_<topic>.py files at their root - thirteen in chat, ten in mail - which buried the module's actual entry points under a wall of near-identical filenames. Each now exposes a views/ package with an empty __init__.py and topic-named modules, the same shape services/ and files/viewsets/ already use. No behaviour changes: every move is a rename plus the import-depth adjustment it forces.

Changes

  • chat, mail, files, core, projects and calendar each gain a views/ package. vault keeps its flat pair, two files do not warrant a package.
  • Each module's original views.py is renamed after what it actually holds (chat/views/conversations.py, mail/views/accounts.py, files/views/files.py); views/views.py is never the answer.
  • Two files that mixed unrelated concerns are split along the separators their authors had already written: core/views.py into modules.py + search.py, calendar/views.py into calendars.py + events.py.
  • projects/viewsets.py moves to projects/views/viewsets.py so everything view-shaped sits together. files/viewsets/ stays where it is, it holds mixins rather than views.
  • CLAUDE.md gains a Views section fixing the convention: a flat views.py while it fits, a views/ package from the second module onward, never views_<topic>.py at the module root.

Testing

chat 774, mail 623, core 232, projects 889, calendar 441, plus users, vault, notes, dashboard, ai, notifications and imports: all green, and chat runs the exact same 774 tests as before the move. ruff check and manage.py check clean.

files (6) and common (4) fail identically on the base commit, verified by replaying those targets in a throwaway worktree at HEAD~1. Pre-existing Windows-only breakage (cp1252 decode in the palette lockstep test, trash directory layout), untouched here.

One real regression surfaced and was fixed: test_api_attachments.py patched workspace.projects.viewsets.MAX_UPLOAD_BYTES, a path the move invalidated.

Notes

Review focus is the import rewrites. Moving a view one directory deeper changes every relative import inside it, including the ~30 lazy ones sitting in function bodies to break cycles. Sibling views now import each other by module name (from .conversations import _trigger_bot_response); from ..views import ... would resolve to the empty __init__.py and fail.

Keeping __init__.py empty is deliberate rather than incidental: a stale @patch("workspace.chat.views._trigger_bot_response") now raises AttributeError, where a compatibility re-export would have bound the alias and left the real call site unmocked with the test still green.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 17 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 89b56a73-34c4-4f35-8094-8ce8e086f66e

📥 Commits

Reviewing files that changed from the base of the PR and between 8b050f2 and 528db1f.

📒 Files selected for processing (70)
  • CLAUDE.md
  • workspace/calendar/tests/test_external_calendar.py
  • workspace/calendar/ui/static/calendar/ui/js/calendar_polls.js
  • workspace/calendar/urls.py
  • workspace/calendar/views/__init__.py
  • workspace/calendar/views/calendars.py
  • workspace/calendar/views/events.py
  • workspace/calendar/views/external.py
  • workspace/calendar/views/polls.py
  • workspace/chat/tests/test_interactions.py
  • workspace/chat/tests/test_message_posting.py
  • workspace/chat/urls.py
  • workspace/chat/views/__init__.py
  • workspace/chat/views/attachments.py
  • workspace/chat/views/avatar.py
  • workspace/chat/views/bots.py
  • workspace/chat/views/calls.py
  • workspace/chat/views/conversations.py
  • workspace/chat/views/goals.py
  • workspace/chat/views/interactions.py
  • workspace/chat/views/messages.py
  • workspace/chat/views/pins.py
  • workspace/chat/views/scheduled.py
  • workspace/chat/views/search.py
  • workspace/chat/views/threads.py
  • workspace/chat/views/typing.py
  • workspace/common/tests/e2e/base.py
  • workspace/core/tests/test_sse.py
  • workspace/core/urls.py
  • workspace/core/views/__init__.py
  • workspace/core/views/activity.py
  • workspace/core/views/changelog.py
  • workspace/core/views/health.py
  • workspace/core/views/modules.py
  • workspace/core/views/search.py
  • workspace/core/views/sse.py
  • workspace/files/tests/test_locking.py
  • workspace/files/urls.py
  • workspace/files/views/__init__.py
  • workspace/files/views/files.py
  • workspace/files/views/graph.py
  • workspace/files/views/share_links.py
  • workspace/files/views/tags.py
  • workspace/files/views/thumbnails.py
  • workspace/files/views/wopi.py
  • workspace/mail/services/notifications.py
  • workspace/mail/tests/test_attachment_save_to_files.py
  • workspace/mail/tests/test_oauth2.py
  • workspace/mail/tests/test_rules_actions.py
  • workspace/mail/ui/urls.py
  • workspace/mail/urls.py
  • workspace/mail/views/__init__.py
  • workspace/mail/views/accounts.py
  • workspace/mail/views/attachments.py
  • workspace/mail/views/compose.py
  • workspace/mail/views/contacts.py
  • workspace/mail/views/extractions.py
  • workspace/mail/views/folders.py
  • workspace/mail/views/labels.py
  • workspace/mail/views/messages.py
  • workspace/mail/views/oauth2.py
  • workspace/mail/views/rules.py
  • workspace/projects/tests/test_api_attachments.py
  • workspace/projects/urls.py
  • workspace/projects/views/__init__.py
  • workspace/projects/views/actions.py
  • workspace/projects/views/calendar.py
  • workspace/projects/views/search.py
  • workspace/projects/views/viewsets.py
  • workspace/urls.py

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.

@pchopinet
pchopinet force-pushed the refactor/views-packages branch from 4822f46 to d4a5a01 Compare August 28, 2026 09:30
Six modules had accumulated a flat sprawl of views_<topic>.py siblings at
their root - thirteen of them in chat, ten in mail. Each now exposes a
views/ package with an empty __init__.py and topic-named modules, matching
the shape services/ and files/viewsets/ already use.

Two files that mixed unrelated concerns were split along the separators
their authors had already written: core/views.py into modules.py and
search.py, calendar/views.py into calendars.py and events.py.

vault keeps its flat pair - two files do not warrant a package.
@pchopinet
pchopinet force-pushed the refactor/views-packages branch from d4a5a01 to 528db1f Compare August 28, 2026 09:33
@pchopinet
pchopinet merged commit d128222 into main Aug 28, 2026
38 checks passed
@pchopinet
pchopinet deleted the refactor/views-packages branch August 28, 2026 09:38
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