Conversation
📝 WalkthroughWalkthroughA new Svelte component Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4829feb879
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <button | ||
| class="ml-auto hover:text-foreground" | ||
| onclick={onClearImage} | ||
| title="Clear search" |
There was a problem hiding this comment.
Set clear button type explicitly
Both clear controls are plain <button> elements without type="button", so if this component is rendered inside a form they will submit the form by default when clicked. That can trigger unintended navigation or requests while the user is only trying to clear search state; set type="button" on these icon buttons to keep behavior predictable.
Useful? React with 👍 / 👎.
| class="flex h-10 w-full items-center rounded-md border border-input bg-background px-3 py-2 pl-8 text-sm {dragOver | ||
| ? 'ring-2 ring-primary' | ||
| : ''}" |
There was a problem hiding this comment.
Use
cn() for conditional Tailwind classes
The class list is built with inline string interpolation, but the frontend guidelines in docs/coding-guidelines/frontend.md ask to compose conditional Tailwind classes with cn() from $lib/utils. Switching to cn() here will keep class composition consistent with project style and reduce fragile string formatting in class attributes.
Useful? React with 👍 / 👎.
| </button> | ||
| <button | ||
| class="ml-auto hover:text-foreground" | ||
| onclick={onClearImage} |
There was a problem hiding this comment.
Rename callback to match text-mode clear behavior
In text mode, the X clear control calls onClearImage, which makes the API misleading because this handler is also responsible for clearing text-only searches. This naming mismatch increases the chance of incorrect wiring by future callers; use a neutral callback name (for example onClearSearch) or call onClearText in this branch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.svelte (1)
53-60: Consider renamingonClearImagetoonClearfor semantic clarity.In the text-only branch (no
activeImage), the clear button callsonClearImage, which is semantically confusing since there's no image to clear. Based on the parent layout's usage pattern (context snippet 1), this callback is meant to perform a "full clear" regardless of state.Renaming
onClearImagetoonClearoronClearSearchwould better communicate its purpose as the general clear action.♻️ Suggested refactor
interface Props { activeImage: string | null; submittedQueryText: string; previewUrl: string | null; dragOver: boolean; - onClearImage: () => void; + onClear: () => void; onClearText: () => void; } let { activeImage, submittedQueryText, previewUrl, dragOver, - onClearImage, + onClear, onClearText }: Props = $props();Then update both clear buttons to use
onclick={onClear}.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.svelte` around lines 53 - 60, Rename the prop/callback onClearImage to a semantically clearer name (e.g., onClear or onClearSearch) across the component and update all usages; change the prop definition/acceptance and every place that referenced onClearImage (including both clear buttons’ onclick handlers) to the new name so the handler represents a full clear action even when activeImage is falsy, and update any parent component prop passed into ActiveSearchDisplay to match the new identifier.lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.test.ts (1)
5-13: Consider resetting mocks inbeforeEachfor test isolation.The
defaultPropsobject containsvi.fn()mocks that persist across all tests. While current tests that assert on callbacks create fresh mocks, this pattern could lead to flaky tests if future assertions rely ondefaultProps.onClearImageordefaultProps.onClearTextcall counts.♻️ Suggested improvement for test isolation
describe('ActiveSearchDisplay', () => { - const defaultProps = { + let defaultProps: { + activeImage: string | null; + submittedQueryText: string; + previewUrl: string | null; + dragOver: boolean; + onClearImage: ReturnType<typeof vi.fn>; + onClearText: ReturnType<typeof vi.fn>; + }; + + beforeEach(() => { + defaultProps = { activeImage: null, submittedQueryText: '', previewUrl: null, dragOver: false, onClearImage: vi.fn(), onClearText: vi.fn() }; + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.test.ts` around lines 5 - 13, The tests reuse the defaultProps object with vi.fn() mocks which can leak call state between tests; add a beforeEach that calls vi.clearAllMocks() and re-initializes defaultProps so onClearImage and onClearText are fresh functions before each test (e.g., reassign defaultProps = { ..., onClearImage: vi.fn(), onClearText: vi.fn(), ... }) and update any tests that referenced the original object to use the new instance to ensure isolation for ActiveSearchDisplay tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.svelte`:
- Around line 53-60: Rename the prop/callback onClearImage to a semantically
clearer name (e.g., onClear or onClearSearch) across the component and update
all usages; change the prop definition/acceptance and every place that
referenced onClearImage (including both clear buttons’ onclick handlers) to the
new name so the handler represents a full clear action even when activeImage is
falsy, and update any parent component prop passed into ActiveSearchDisplay to
match the new identifier.
In
`@lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.test.ts`:
- Around line 5-13: The tests reuse the defaultProps object with vi.fn() mocks
which can leak call state between tests; add a beforeEach that calls
vi.clearAllMocks() and re-initializes defaultProps so onClearImage and
onClearText are fresh functions before each test (e.g., reassign defaultProps =
{ ..., onClearImage: vi.fn(), onClearText: vi.fn(), ... }) and update any tests
that referenced the original object to use the new instance to ensure isolation
for ActiveSearchDisplay tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: adbed708-3bd7-4cf1-b5f7-a5b1802ab773
📒 Files selected for processing (2)
lightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.sveltelightly_studio_view/src/lib/components/GridSearch/ActiveSearchDisplay/ActiveSearchDisplay.test.ts
What has changed and why?
(Delete this: Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.)
How has it been tested?
(Delete this: Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.)
Did you update CHANGELOG.md?
Overview
This PR introduces a new
ActiveSearchDisplaySvelte component that provides an inline search status display for the GridSearch functionality. The component conditionally renders either active image information or submitted query text, with associated clear actions and visual feedback for drag-over interactions.Changes
New Component: ActiveSearchDisplay.svelte
dragOveris trueProps interface:
activeImage: string | null- Currently active image filenamesubmittedQueryText: string- Submitted search query textpreviewUrl: string | null- Optional preview image URLdragOver: boolean- Drag-over state for visual feedbackonClearImage: () => void- Callback for clearing active imageonClearText: () => void- Callback for clearing query textTest Suite: ActiveSearchDisplay.test.ts
alttext andsrcattributesonClearTextcallbackImpact
This component extends the GridSearch functionality with proper state display and user interaction handling, fully covered by tests.