Skip to content

feat: move out search for grid to separate component#825

Closed
ikondrat wants to merge 1 commit intomainfrom
move-out-search-component-from-layout
Closed

feat: move out search for grid to separate component#825
ikondrat wants to merge 1 commit intomainfrom
move-out-search-component-from-layout

Conversation

@ikondrat
Copy link
Copy Markdown
Contributor

What has changed and why?

This PR extracts the GridSearch component from the layout to reduce the complexity of the layout and code duplication.
There are no logic changes - just moving the component to the separate file and cleaning up the code duplication.

How has it been tested?

Ny e2e tests and visually by running make start-e2e and checking what search is still working after the refactoring

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

@ikondrat
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7bdb50c0c1

ℹ️ 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".

Comment on lines +183 to +185
if (!submittedQueryText) {
setTextEmbedding(undefined);
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve active embedding when GridSearch remounts

This effect clears global textEmbedding whenever submittedQueryText is empty, and after this refactor GridSearch is mounted in two mutually exclusive layout branches ($showPlot true/false). Toggling “Show Embeddings” remounts the component, so this branch runs on first render and drops an already-applied search filter unexpectedly.

Useful? React with 👍 / 👎.

@@ -0,0 +1,272 @@
<script lang="ts">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Split GridSearch into smaller units

The frontend guideline in docs/coding-guidelines/frontend.md asks to keep components under 100 lines, but this component is 272 lines and mixes upload logic, clipboard/drag handlers, API calls, and rendering in one file. Breaking this into smaller components/hooks would match the project style and improve maintainability.

Useful? React with 👍 / 👎.

let submittedQueryText = $state('');
let previewUrl = $state<string | null>(null);
let isUploading = $state(false);
let query_text = $state($textEmbedding ? $textEmbedding.queryText : '');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Rename query_text to camelCase

The frontend naming guideline requires camelCase for variables, but query_text uses snake_case. Renaming it (for example to queryText) would align this component with the code style used across the TypeScript/Svelte codebase.

Useful? React with 👍 / 👎.

buildVideoAnnotationCountsFilter,
buildVideoFrameAnnotationCountsFilter
} from '$lib/utils/buildAnnotationCountsFilters';
import GridSearch from '$lib/components/GridSearch/GridSearch.svelte';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Import GridSearch via $lib/components barrel

The frontend guidelines recommend importing project-specific components from $lib/components; this direct path import bypasses the barrel even though GridSearch is exported there in the same commit. Using the barrel keeps imports consistent and easier to refactor.

Useful? React with 👍 / 👎.

toast.error('Error', { description: errorMessage });
};

async function uploadImage(file: File) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd expect this function in a hook. WDTY?

Copy link
Copy Markdown
Contributor

@LeonardoRosaa LeonardoRosaa left a comment

Choose a reason for hiding this comment

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

Can you write unit tests for this new component?

@ikondrat ikondrat closed this Apr 7, 2026
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