-
Notifications
You must be signed in to change notification settings - Fork 2
[fix] 가구 매핑 수정 및 스낵바 동작 개선 #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maehwasoo
wants to merge
41
commits into
develop
Choose a base branch
from
fix/mapping-and-bottomsheet/#393
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,888
−296
Open
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
78e63e8
docs: OBJ365 기준으로 가구 매핑 주석 명확화
maehwasoo 2a902f1
fix: 의자 벤치 스툴의 소파 매핑 비활성화
maehwasoo 5bfc64b
refactor: 캐비닛 2차 분류 타입과 매핑 명확화
maehwasoo fcc3e36
fix: Couch 매핑에 1인 소파 코드 추가
maehwasoo 77c5271
feat: 생성 경로 워밍업 및 ONNX 모델 영속 캐시 추가
maehwasoo ef95e7b
chore: 2차 분류 라벨 디버그 로그 추가
maehwasoo 11e409a
fix: 찜 스낵바 중복 노출 방지 및 시트 닫힘 시 리셋
maehwasoo 77ac112
fix: 찜 스낵바 중복 노출을 쿨타임으로 방지
maehwasoo d130a72
feat: 감지 캐시 도입하여 핫스팟 추론 재사용
maehwasoo 7cf96ba
fix: 마이페이지 이미지 캐시 15분 및 포커스 재조회 중지
maehwasoo c04b9ec
chore: npm 캐시 디렉터리 무시 추가
maehwasoo b751c09
fix: 이미지 로드 상태 저장하여 스켈레톤 깜빡임 방지
maehwasoo 49ff528
fix: 마이페이지 프로필 전달로 결과 크레딧 동기화
maehwasoo d412917
fix: 마이페이지 히스토리로 결과 페이지 표시하도록 수정
maehwasoo 3091e9f
fix: 감지 캐시에 핫스팟과 카테고리 저장
maehwasoo acfd0ee
fix: 결과 감지 캐시 적용 및 마이페이지 뒤로가기 개선
maehwasoo 9ed3101
fix: 결과 캐시 구조 정비
maehwasoo 1b10c5b
fix: 바텀시트 hidden 상태 추가 및 동작 개선
maehwasoo ce86f39
fix: 카테고리 필터 로딩에 스켈레톤 적용
maehwasoo 5cae060
fix: 새로 만들기 시 바텀시트 복원 막고 replace로 이동
maehwasoo 3d499ec
fix: 렌더 메트릭 비교와 콜백 안정화로 중복 실행 방지
maehwasoo 9131734
refactor: 카테고리 프리패치 병렬화로 초기 응답 개선
maehwasoo 3551605
fix: 마이페이지 결과 매핑 및 로딩 흐름 수정
maehwasoo d603052
fix: 생성 결과 캐시 유지 시간 연장
maehwasoo 8c38cd3
fix: 감지 캐시 영속 타입 정정 및 마이페이지 쿼리 옵션 보강
maehwasoo 2967960
fix: 슬라이드 개수 로딩 시 스켈레톤 표시
maehwasoo ab8a123
feat: 마이페이지 감지 프리페치 추가로 첫 렌더 가속
maehwasoo 6d93311
fix: 그룹 기반 쿼리키로 큐레이션 바텀시트 안정화
maehwasoo 1b88c95
feat: 감지 프리페치 개선 및 큐와 우선순위 도입
maehwasoo 3f69166
fix: 쿼리 키 안정화 및 타입 정비로 캐시 오류 수정
maehwasoo 7cc3a08
fix: 캐시와 초기 데이터도 저장하도록 변경하고 gcTime 적용
maehwasoo 0604fba
fix: 캐시 저장을 onSuccess로 이전해 중복 갱신 방지
maehwasoo 6e97b94
fix: 캐시 오염과 불필요한 재요청 방지
maehwasoo 4a78f5a
fix: 검출시그니처로 초기데이터와 캐시 동기화
maehwasoo 1cb72be
fix: 이미지 생성 완료 시 마이페이지 목록 갱신
maehwasoo 161ac83
fix: 그룹/카테고리 null 판별로 쿼리 캐시 오류 수정
maehwasoo 10004ff
fix: 더보기 슬라이드에서 바텀시트 숨김 및 복원
maehwasoo ec60ce1
fix: 카테고리와 상품 쿼리 무효화 로직 수정
maehwasoo ab0fe38
docs: 큐레이션과 결과 및 마이페이지 JSDoc 추가
maehwasoo d781917
fix: nullish 비교로 그룹 초기화 누락 방지
maehwasoo 69c698d
fix: 감지 프리페치 동시 실행 제한
maehwasoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,4 +56,5 @@ node_modules/ | |
| AGENTS.md | ||
|
|
||
| .pnpm-store/ | ||
| .serena/ | ||
| .serena/ | ||
| .npm-cache/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,44 @@ | ||
| import { Outlet } from 'react-router-dom'; | ||
| import { useEffect } from 'react'; | ||
|
|
||
| import { Outlet, useLocation } from 'react-router-dom'; | ||
|
|
||
| import { ROUTES } from '@/routes/paths'; | ||
| import { useScrollToTop } from '@/shared/hooks/useScrollToTop'; | ||
|
|
||
| import { OBJ365_MODEL_PATH } from '@pages/generate/constants/detection'; | ||
| import { preloadONNXModel } from '@pages/generate/hooks/useOnnxModel'; | ||
|
|
||
| const GENERATE_WARMUP_PATHS = [ | ||
| ROUTES.GENERATE, | ||
| ROUTES.GENERATE_RESULT, | ||
| ROUTES.GENERATE_START, | ||
| ROUTES.IMAGE_SETUP, | ||
| ]; | ||
|
|
||
| function RootLayout() { | ||
| // 라우트/쿼리/해시/키 변화와 초기 마운트 시 스크롤 최상단으로 이동 | ||
| useScrollToTop(); | ||
| useGenerateWarmup(); | ||
| return ( | ||
| <div> | ||
| <Outlet /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function useGenerateWarmup() { | ||
| const location = useLocation(); | ||
|
|
||
| useEffect(() => { | ||
| const pathname = location.pathname; | ||
| const shouldWarmup = GENERATE_WARMUP_PATHS.some( | ||
| (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`) | ||
| ); | ||
|
|
||
| if (!shouldWarmup) return; | ||
|
|
||
| preloadONNXModel(OBJ365_MODEL_PATH).catch(() => undefined); | ||
| }, [location.pathname]); | ||
| } | ||
|
|
||
| export default RootLayout; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { useCallback, useEffect, useMemo } from 'react'; | ||
|
|
||
| import { | ||
| useDetectionCacheStore, | ||
| type DetectionCacheEntry, | ||
| } from '@pages/generate/stores/useDetectionCacheStore'; | ||
|
|
||
| import type { FurnitureCategoryCode } from '@pages/generate/constants/furnitureCategoryMapping'; | ||
| import type { FurnitureHotspot } from '@pages/generate/hooks/useFurnitureHotspots'; | ||
| import type { ProcessedDetections } from '@pages/generate/types/detection'; | ||
|
|
||
| export const DETECTION_CACHE_TTL = 30 * 60 * 1000; // 30분 | ||
|
|
||
| type SavePayload = { | ||
| processedDetections: ProcessedDetections; | ||
| hotspots: FurnitureHotspot[]; | ||
| detectedObjects?: FurnitureCategoryCode[]; | ||
| }; | ||
|
|
||
| type UseDetectionCacheOptions = { | ||
| initialEntry?: DetectionCacheEntry | null; | ||
| }; | ||
|
|
||
| export function useDetectionCache( | ||
| imageId: number | null, | ||
| imageUrl: string, | ||
| options?: UseDetectionCacheOptions | ||
| ) { | ||
| const initialEntry = options?.initialEntry ?? null; | ||
| const storeEntry = useDetectionCacheStore((state) => | ||
| imageId ? (state.images[imageId] ?? null) : null | ||
| ); | ||
| const setEntry = useDetectionCacheStore((state) => state.setEntry); | ||
| const removeEntry = useDetectionCacheStore((state) => state.removeEntry); | ||
|
|
||
| const isExpired = useMemo(() => { | ||
| if (!storeEntry) return false; | ||
| if (storeEntry.imageUrl !== imageUrl) return true; | ||
| return Date.now() - storeEntry.updatedAt > DETECTION_CACHE_TTL; | ||
| }, [storeEntry, imageUrl]); | ||
|
|
||
| useEffect(() => { | ||
| if (!imageId || !initialEntry) return; | ||
| const candidate = initialEntry; | ||
| if (candidate.imageUrl !== imageUrl) return; | ||
| if (!storeEntry || candidate.updatedAt > storeEntry.updatedAt) { | ||
| setEntry(imageId, candidate); | ||
| } | ||
| }, [imageId, imageUrl, initialEntry, setEntry, storeEntry]); | ||
|
|
||
| useEffect(() => { | ||
| if (!imageId || !isExpired) return; | ||
| removeEntry(imageId); | ||
| }, [imageId, isExpired, removeEntry]); | ||
|
|
||
| const effectiveEntry = isExpired ? null : storeEntry; | ||
|
|
||
| const prefetchedDetections = effectiveEntry?.processedDetections ?? null; | ||
|
|
||
| const saveEntry = useCallback( | ||
| ({ processedDetections, hotspots, detectedObjects }: SavePayload) => { | ||
| if (!imageId) return; | ||
| setEntry(imageId, { | ||
| imageUrl, | ||
| processedDetections, | ||
| hotspots, | ||
| detectedObjects, | ||
| }); | ||
| }, | ||
| [imageId, imageUrl, setEntry] | ||
| ); | ||
|
|
||
| const clearEntry = useCallback(() => { | ||
| if (!imageId) return; | ||
| removeEntry(imageId); | ||
| }, [imageId, removeEntry]); | ||
|
|
||
| return { | ||
| entry: effectiveEntry, | ||
| prefetchedDetections, | ||
| saveEntry, | ||
| clearEntry, | ||
| } as const; | ||
| } | ||
|
|
||
| export const primeDetectionCacheEntry = ( | ||
| imageId: number, | ||
| payload: DetectionCacheEntry | ||
| ) => { | ||
| if (!imageId) return; | ||
| useDetectionCacheStore.getState().setEntry(imageId, payload); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
커스텀 훅 파일 분리 고려
코딩 가이드라인에 따르면 커스텀 훅 파일명은
use*.ts형식이어야 해요.useGenerateWarmup훅을 별도 파일(src/shared/hooks/useGenerateWarmup.ts)로 분리하면 재사용성과 테스트 용이성이 향상될 수 있어요. 현재 구현도 동작에는 문제없지만, 프로젝트 컨벤션 일관성을 위해 분리를 권장해요.🤖 Prompt for AI Agents