Skip to content

🗿 Sculptor: Refactor TimetableFilters to Compound Components#247

Open
ldsgroups225 wants to merge 1 commit intomasterfrom
sculptor/refactor-timetable-filters-10317478516982637236
Open

🗿 Sculptor: Refactor TimetableFilters to Compound Components#247
ldsgroups225 wants to merge 1 commit intomasterfrom
sculptor/refactor-timetable-filters-10317478516982637236

Conversation

@ldsgroups225
Copy link
Copy Markdown
Owner

@ldsgroups225 ldsgroups225 commented Apr 4, 2026

What

Refactored the TimetableFilters component to use the Compound Components pattern, eliminating prop-drilling and a heavy 15-prop monolithic signature.

Why

The original component suffered from severe boolean prop proliferation (classesPending, teachersPending, contextPending) and rigid internal structure. By delegating the rendering logic to the parent via TimetableFilters.FilterSelect, the consumer (schedules.tsx) gains direct control over its layout and specific loading states without polluting the child component.

Patterns Used

  • Compound Components Pattern: TimetableFilters (Container) + TimetableFilters.ViewSwitcher + TimetableFilters.FiltersContainer + TimetableFilters.FilterSelect.
  • Composition over Configuration: Moved conditional view rendering up to the page level.
  • Replaced duplicated code (Skeleton + Select combo) with a generic, reusable FilterSelect abstraction.

PR created automatically by Jules for task 10317478516982637236 started by @ldsgroups225

Summary by CodeRabbit

  • Refactor
    • Restructured timetable filters component into a composition-based structure with dedicated sub-components (ViewSwitcher, FilterSelect, FiltersContainer).
    • Updated filter loading state management to be handled at the page level rather than through prop drilling.
    • Improved maintainability by reducing component complexity and prop passing.

@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

The pull request refactors the TimetableFilters component from a monolithic structure with ~15 props into a Compound Components pattern with reusable sub-components (ViewSwitcher, FilterSelect, FiltersContainer). The consumer (schedules.tsx) is updated to compose these new sub-components, shifting responsibility for load states to the page level rather than drilling props into the filter component.

Changes

Cohort / File(s) Summary
Documentation
.jules/sculptor.md
Added entry documenting the Compound Components refactoring pattern applied to TimetableFilters, including the shift from prop drilling to consumer-level load state management.
Component Structure
apps/school/src/components/timetables/timetable-filters.tsx
Converted monolithic TimetableFilters into a wrapper component with attached sub-components: ViewSwitcher, FilterSelect (a generic parameterized select component with skeleton loading), and FiltersContainer. Removed prior mode-specific inline filter UIs and prop drilling logic.
Consumer Integration
apps/school/src/routes/_auth/schedules.tsx
Updated filter usage to compose new FilterSelect sub-components conditionally by view mode, with load/disabled logic handled at page level. Added TeacherListItem import for option mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A monolith breaks into pieces neat,
Compound components make the pattern complete!
No prop drilling, just composition so fine,
Each filter sub-component shines in line!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: refactoring TimetableFilters to use the Compound Components pattern, which is the primary objective of the PR.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sculptor/refactor-timetable-filters-10317478516982637236

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

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

Inline comments:
In `@apps/school/src/components/timetables/timetable-filters.tsx`:
- Around line 4-5: The FilterSelect component currently imports and uses
motion.div directly; change the import to use LazyMotion and domAnimation and
swap to the lightweight m element so animations load via the lazy feature
bundle: import LazyMotion and domAnimation and the m factory (symbols:
LazyMotion, domAnimation, m), wrap the component's animation root with
<LazyMotion features={domAnimation}>...</LazyMotion>, and replace motion.div
usages inside FilterSelect with m.div (or corresponding m.* elements) to ensure
the lazy feature bundle pattern is applied.

In `@apps/school/src/routes/_auth/schedules.tsx`:
- Around line 211-238: The teacher and classroom FilterSelects should be
disabled when there is no resolved school year to prevent a dead-end UI; update
the two TimetableFilters.FilterSelect components (the ones rendered when
viewMode === 'teacher' and viewMode === 'classroom') to pass disabled={true} (or
disabled={!effectiveSchoolYear}) and optionally isLoading={true} when the
resolved/effective school year context (e.g., effectiveSchoolYear / resolvedYear
from your year context) is missing; keep the existing value/onChange handlers
(selectedTeacherId/setSelectedTeacherId and
selectedClassroomId/setSelectedClassroomId) but ensure the selector UI reflects
the disabled state so users cannot interact with them when year context is
unavailable.
🪄 Autofix (Beta)

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: 6c6d1f77-dce6-4738-8a02-83d99d1f5e06

📥 Commits

Reviewing files that changed from the base of the PR and between 7e37ef8 and 0a5fc48.

📒 Files selected for processing (3)
  • .jules/sculptor.md
  • apps/school/src/components/timetables/timetable-filters.tsx
  • apps/school/src/routes/_auth/schedules.tsx

Comment on lines 4 to +5
import { motion } from 'motion/react'
import * as React from 'react'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n apps/school/src/components/timetables/timetable-filters.tsx

Repository: ldsgroups225/Yeko

Length of output: 4289


Use LazyMotion with domAnimation for motion components.

The FilterSelect component uses motion.div directly without the required lazy feature bundle pattern. Update the imports and wrap the animation container accordingly.

Suggested fix
-import { motion } from 'motion/react'
+import { LazyMotion, domAnimation, m } from 'motion/react'
 import * as React from 'react'
@@
-    <motion.div
-      initial={{ opacity: 0, scale: 0.95 }}
-      animate={{ opacity: 1, scale: 1 }}
-      className="
-        w-full space-y-1.5
-        sm:w-[240px]
-      "
-    >
+    <LazyMotion features={domAnimation}>
+      <m.div
+        initial={{ opacity: 0, scale: 0.95 }}
+        animate={{ opacity: 1, scale: 1 }}
+        className="
+          w-full space-y-1.5
+          sm:w-[240px]
+        "
+      >
@@
-    </motion.div>
+      </m.div>
+    </LazyMotion>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/school/src/components/timetables/timetable-filters.tsx` around lines 4 -
5, The FilterSelect component currently imports and uses motion.div directly;
change the import to use LazyMotion and domAnimation and swap to the lightweight
m element so animations load via the lazy feature bundle: import LazyMotion and
domAnimation and the m factory (symbols: LazyMotion, domAnimation, m), wrap the
component's animation root with <LazyMotion
features={domAnimation}>...</LazyMotion>, and replace motion.div usages inside
FilterSelect with m.div (or corresponding m.* elements) to ensure the lazy
feature bundle pattern is applied.

Comment on lines +211 to +238
{viewMode === 'teacher' && (
<TimetableFilters.FilterSelect
label={t.teachers.title()}
placeholder={t.teachers.select()}
value={selectedTeacherId}
onChange={setSelectedTeacherId}
isLoading={false}
options={(teachers || []).map((teacher: TeacherListItem) => ({
value: teacher.id,
label: teacher.user?.name || '',
icon: <div className="bg-success size-2 rounded-full" />
}))}
/>
)}

{viewMode === 'classroom' && (
<TimetableFilters.FilterSelect
label={t.spaces.title()}
placeholder={t.spaces.availability.title()}
value={selectedClassroomId}
onChange={setSelectedClassroomId}
options={(classrooms || []).map(c => ({
value: c.id,
label: c.name,
icon: <div className="bg-primary size-2 rounded-full" />
}))}
/>
)}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Disable teacher/classroom selectors when year context is unavailable.

These selectors stay interactive even when no effective school year is resolved, but timetable rendering is still blocked by the year gate. That creates a dead-end UI state.

Suggested fix
             {viewMode === 'teacher' && (
               <TimetableFilters.FilterSelect
                 label={t.teachers.title()}
                 placeholder={t.teachers.select()}
                 value={selectedTeacherId}
                 onChange={setSelectedTeacherId}
                 isLoading={false}
+                disabled={!effectiveYearId || contextPending}
                 options={(teachers || []).map((teacher: TeacherListItem) => ({
                   value: teacher.id,
                   label: teacher.user?.name || '',
                   icon: <div className="bg-success size-2 rounded-full" />
                 }))}
               />
             )}

             {viewMode === 'classroom' && (
               <TimetableFilters.FilterSelect
                 label={t.spaces.title()}
                 placeholder={t.spaces.availability.title()}
                 value={selectedClassroomId}
                 onChange={setSelectedClassroomId}
+                disabled={!effectiveYearId || contextPending}
                 options={(classrooms || []).map(c => ({
                   value: c.id,
                   label: c.name,
                   icon: <div className="bg-primary size-2 rounded-full" />
                 }))}
               />
             )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{viewMode === 'teacher' && (
<TimetableFilters.FilterSelect
label={t.teachers.title()}
placeholder={t.teachers.select()}
value={selectedTeacherId}
onChange={setSelectedTeacherId}
isLoading={false}
options={(teachers || []).map((teacher: TeacherListItem) => ({
value: teacher.id,
label: teacher.user?.name || '',
icon: <div className="bg-success size-2 rounded-full" />
}))}
/>
)}
{viewMode === 'classroom' && (
<TimetableFilters.FilterSelect
label={t.spaces.title()}
placeholder={t.spaces.availability.title()}
value={selectedClassroomId}
onChange={setSelectedClassroomId}
options={(classrooms || []).map(c => ({
value: c.id,
label: c.name,
icon: <div className="bg-primary size-2 rounded-full" />
}))}
/>
)}
{viewMode === 'teacher' && (
<TimetableFilters.FilterSelect
label={t.teachers.title()}
placeholder={t.teachers.select()}
value={selectedTeacherId}
onChange={setSelectedTeacherId}
isLoading={false}
disabled={!effectiveYearId || contextPending}
options={(teachers || []).map((teacher: TeacherListItem) => ({
value: teacher.id,
label: teacher.user?.name || '',
icon: <div className="bg-success size-2 rounded-full" />
}))}
/>
)}
{viewMode === 'classroom' && (
<TimetableFilters.FilterSelect
label={t.spaces.title()}
placeholder={t.spaces.availability.title()}
value={selectedClassroomId}
onChange={setSelectedClassroomId}
disabled={!effectiveYearId || contextPending}
options={(classrooms || []).map(c => ({
value: c.id,
label: c.name,
icon: <div className="bg-primary size-2 rounded-full" />
}))}
/>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/school/src/routes/_auth/schedules.tsx` around lines 211 - 238, The
teacher and classroom FilterSelects should be disabled when there is no resolved
school year to prevent a dead-end UI; update the two
TimetableFilters.FilterSelect components (the ones rendered when viewMode ===
'teacher' and viewMode === 'classroom') to pass disabled={true} (or
disabled={!effectiveSchoolYear}) and optionally isLoading={true} when the
resolved/effective school year context (e.g., effectiveSchoolYear / resolvedYear
from your year context) is missing; keep the existing value/onChange handlers
(selectedTeacherId/setSelectedTeacherId and
selectedClassroomId/setSelectedClassroomId) but ensure the selector UI reflects
the disabled state so users cannot interact with them when year context is
unavailable.

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