Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

chore(SearchBar):removed-logs

Aswin Asok9099b70eab11
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 2f8ddad426..96b20e7831 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -19,7 +19,6 @@ import {
import { EnteLogo, EnteLogoBox } from "ente-base/components/EnteLogo";
import type { ButtonishProps } from "ente-base/components/mui";
import { useIsSmallWidth } from "ente-base/components/utils/hooks";
-import log from "ente-base/log";
import {
hlsGenerationStatusSnapshot,
isHLSGenerationSupported,
@@ -196,7 +195,6 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
}, []);
const handleChange = (value: SearchOption | null) => {
- log.info(`[SearchBar] Option selected"`);
const type = value?.suggestion.type;
// Collection and people suggestions are handled differently - our
// caller will switch to the corresponding view, dismissing search.
@@ -236,7 +234,6 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
// If the input is cleared, also clear the selected value.
if (value === "") {
- log.info("[SearchBar] Input cleared, resetting selection");
setValue(null);
setInputValue("");
// Notify parent but don't exit search mode on mobile
@@ -248,7 +245,6 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
};
const resetSearch = () => {
- log.info("[SearchBar] Resetting search state");
// Dismiss the search menu if it is open.
selectRef.current?.blur();
@@ -271,13 +267,11 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
};
const handleFocus = () => {
- log.info("[SearchBar] Search input focused");
setIsFocused(true);
// A workaround to show the suggestions again for the current non-empty
// search string if the user focuses back on the input field after
// moving focus elsewhere.
if (inputValue) {
- log.info(`[SearchBar] Re-triggering search for existing input"`);
selectRef.current?.onInputChange(inputValue, {
action: "set-value",
prevInputValue: "",
@@ -286,7 +280,6 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
};
const handleBlur = () => {
- log.info("[SearchBar] Search input blurred");
setIsFocused(false);
};
@@ -316,21 +309,12 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
onFocus={handleFocus}
onBlur={handleBlur}
placeholder={t("search_hint")}
- loadingMessage={() => {
- log.info(`[SearchBar] loadingMessage: Loading results"`);
- return null;
- }}
+ loadingMessage={() => null}
noOptionsMessage={({ inputValue }) => {
if (inputValue) {
- log.info(
- `[SearchBar] noOptionsMessage: No results found"`,
- );
return t("no_results");
}
if (shouldShowEmptyState(inputValue)) {
- log.info(
- "[SearchBar] noOptionsMessage: Showing empty state",
- );
return (
<EmptyState
onSelectPeople={handleSelectPeople}
@@ -338,9 +322,6 @@ const SearchInput: React.FC<Omit<SearchBarProps, "onShowSearchInput">> = ({
/>
);
}
- log.info(
- "[SearchBar] noOptionsMessage: Returning null (no menu content)",
- );
return null;
}}
/>
@@ -366,31 +347,12 @@ const SearchInputWrapper = styled("div")`
`;
const loadOptions = pDebounce(async (input: string) => {
- log.info("[SearchBar] Loading search options");
- const startTime = performance.now();
-
- try {
- const [sidebarActions, photoOptions] = await Promise.all([
- sidebarSearchOptionsForString(input),
- searchOptionsForString(input),
- ]);
-
- const duration = performance.now() - startTime;
- log.info(
- `[SearchBar] Search options loaded in ${duration.toFixed(0)}ms: ` +
- `${photoOptions.length} photo options, ${sidebarActions.length} sidebar actions`,
- );
+ const [sidebarActions, photoOptions] = await Promise.all([
+ sidebarSearchOptionsForString(input),
+ searchOptionsForString(input),
+ ]);
- return [...photoOptions, ...sidebarActions];
- } catch (e) {
- const duration = performance.now() - startTime;
- log.error(
- `[SearchBar] Failed to load search options after ${duration.toFixed(0)}ms`,
- e,
- );
- // Re-throw so react-select can handle it, but now we have visibility
- throw e;
- }
+ return [...photoOptions, ...sidebarActions];
}, 250);
// const loadOptions = pDebounce(searchOptionsForString, 250);
@@ -549,21 +511,11 @@ const shouldShowEmptyState = (inputValue: string) => {
if (!isMLSupported && !isHLSGenerationSupported) {
// Neither of ML or HLS generation is supported on current client. This
// is the code path for web.
- log.info(
- "[SearchBar] shouldShowEmptyState: false (ML and HLS not supported)",
- );
return false;
}
const mlStatus = mlStatusSnapshot();
const vpStatus = hlsGenerationStatusSnapshot();
- log.info("[SearchBar] shouldShowEmptyState check", {
- isMLSupported,
- isHLSGenerationSupported,
- mlPhase: mlStatus?.phase ?? "undefined",
- vpEnabled: vpStatus?.enabled ?? false,
- vpStatus: vpStatus?.enabled ? vpStatus.status : "disabled",
- });
const isMLInactive =
!mlStatus || mlStatus.phase == "disabled" || mlStatus.phase == "done";
@@ -576,15 +528,11 @@ const shouldShowEmptyState = (inputValue: string) => {
const people = peopleStateSnapshot()?.visiblePeople;
const hasPeople = people && people.length > 0;
if (!hasPeople) {
- log.info(
- "[SearchBar] shouldShowEmptyState: false (ML inactive, no video processing, no people)",
- );
return false;
}
}
// Show it otherwise.
- log.info("[SearchBar] shouldShowEmptyState: true");
return true;
};
@@ -599,13 +547,6 @@ const EmptyState: React.FC<
const people = usePeopleStateSnapshot()?.visiblePeople;
const vpStatus = useHLSGenerationStatusSnapshot();
- log.info("[SearchBar] EmptyState render", {
- mlPhase: mlStatus?.phase ?? "undefined",
- peopleCount: people?.length ?? 0,
- vpEnabled: vpStatus?.enabled ?? false,
- vpStatus: vpStatus?.enabled ? vpStatus.status : "disabled",
- });
-
let label: string | undefined;
switch (mlStatus?.phase) {
case undefined:
@@ -614,24 +555,19 @@ const EmptyState: React.FC<
// If ML is not running, see if video processing is.
if (vpStatus?.enabled && vpStatus.status == "processing") {
label = t("processing_videos_status");
- log.info("[SearchBar] Status: Processing videos in progress");
}
break;
case "scheduled":
label = t("indexing_scheduled");
- log.info("[SearchBar] Status: Photo indexing scheduled");
break;
case "indexing":
label = t("indexing_photos");
- log.info("[SearchBar] Status: Indexing photos in progress");
break;
case "fetching":
label = t("indexing_fetching");
- log.info("[SearchBar] Status: Fetching data for indexing");
break;
case "clustering":
label = t("indexing_people");
- log.info("[SearchBar] Status: Clustering people/faces");
break;
}