-
Notifications
You must be signed in to change notification settings - Fork 690
fix(memos-local-openclaw): Viewer API search limit and minScore params not working #1376
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -770,6 +770,9 @@ export class ViewerServer { | |||||||||||||
| const q = url.searchParams.get("q") ?? ""; | ||||||||||||||
| if (!q.trim()) { this.jsonResponse(res, { results: [], query: q }); return; } | ||||||||||||||
|
|
||||||||||||||
| const limit = Math.min(100, Math.max(1, Number(url.searchParams.get("limit")) || 20)); | ||||||||||||||
| const minScore = Math.max(0.35, Math.min(1, Number(url.searchParams.get("minScore")) || 0.64)); | ||||||||||||||
|
Comment on lines
+773
to
+774
|
||||||||||||||
| const limit = Math.min(100, Math.max(1, Number(url.searchParams.get("limit")) || 20)); | |
| const minScore = Math.max(0.35, Math.min(1, Number(url.searchParams.get("minScore")) || 0.64)); | |
| const rawLimit = Number(url.searchParams.get("limit")); | |
| const limit = Math.min(100, Math.max(1, Number.isFinite(rawLimit) ? rawLimit : 20)); | |
| const rawMinScore = Number(url.searchParams.get("minScore")); | |
| const minScore = Math.max(0.35, Math.min(1, Number.isFinite(rawMinScore) ? rawMinScore : 0.64)); |
Copilot
AI
Mar 28, 2026
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.
merged always includes ftsResults (the second loop appends them unconditionally), so the merged.length > 0 ? merged : ftsResults.slice(...) branch is effectively redundant. Simplifying this to a single slice of merged would make the intent clearer and avoid implying there’s a distinct fallback path.
| const results = (merged.length > 0 ? merged : ftsResults.slice(0, limit)).slice(0, limit); | |
| const results = merged.slice(0, limit); |
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.
The query param parsing uses
Number(...) || default, which treats0as “missing”. That makeslimit=0default to 20 (instead of clamping to 1) andminScore=0default to 0.64 (instead of clamping to 0.35). Consider parsing withNumber.isFiniteand applying the default only when the param is absent/NaN, then clamp the resulting value.