-
Notifications
You must be signed in to change notification settings - Fork 38
feat(trails): trail search micro frontend acquisition surface #2389
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
Changes from all commits
2a6c4a3
2419785
41a02cc
dfe3f57
ff7a1df
f2c147f
8825db0
1a3c900
74e5114
29294c6
57bbf09
c6256d7
e49810b
ba32482
347d82e
8a55893
17ad75c
fefc42d
b0d4b22
ce503a3
5d75348
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,14 +67,11 @@ function CatalogItemsScreen() { | |||||||||||||
| isLoading: isVectorLoading, | ||||||||||||||
| error: vectorError, | ||||||||||||||
| } = useVectorSearch({ query: trimmedQuery, limit: 10 }); | ||||||||||||||
| // safe-cast: treaty response shape matches CatalogItem[] as validated by the API schema | ||||||||||||||
| const searchResults: CatalogItem[] = (vectorResult?.items ?? []) as unknown as CatalogItem[]; | ||||||||||||||
| const searchResults = vectorResult?.items ?? []; | ||||||||||||||
|
|
||||||||||||||
| const paginatedItems: CatalogItem[] = | ||||||||||||||
| // safe-cast: treaty response shape matches CatalogItem[] as validated by the API schema | ||||||||||||||
| ((paginatedData?.pages.flatMap((page) => page.items) ?? []) as CatalogItem[]).filter((item) => | ||||||||||||||
| Boolean(item?.id), | ||||||||||||||
| ); | ||||||||||||||
| const paginatedItems = (paginatedData?.pages.flatMap((page) => page.items) ?? []).filter((item) => | ||||||||||||||
| Boolean(item?.id), | ||||||||||||||
| ); | ||||||||||||||
|
Comment on lines
+72
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use explicit null checks for
Suggested fix- const paginatedItems = (paginatedData?.pages.flatMap((page) => page.items) ?? []).filter((item) =>
- Boolean(item?.id),
- );
+ const paginatedItems = (paginatedData?.pages.flatMap((page) => page.items) ?? []).filter(
+ (item): item is CatalogItem => item?.id != null,
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| const totalItems = paginatedData?.pages[0]?.totalCount ?? 0; | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
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.
UserSchema.parseafter token writes leaves session in an inconsistent state on schema mismatch.The execution order in all four flows is:
If
data.userdoesn't satisfyUserSchema(missing required field, renamed key, unexpected null, etc.),parsethrows aZodErrorthat is caught and re-thrown. The result is:userStoreis not updated — no user in the reactive store.redirectnever executes — the user stays on the login screen.On the next cold start the app has valid tokens but no user record — an inconsistent session that's hard to recover from without an explicit logout.
Use
safeParseand handle failure explicitly before any storage writes, or move the parse before the token writes:🛡️ Proposed fix — validate before committing tokens
Apply the same pattern at lines 101–103 (
signInWithGoogle), 148–150 (signInWithApple), and 255–257 (verifyEmail).Also applies to: 101-103, 148-150, 255-257
🤖 Prompt for AI Agents