Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
## 2024-05-27 - Frontend: Memoizing React Markdown Props
**Learning:** `react-markdown` is a heavy component. Passing new object references for props like `components`, `rehypePlugins`, or `remarkPlugins` on every render (e.g., defined inline) forces the library to re-parse the Markdown AST, leading to significant performance penalties.
**Action:** Always wrap `components`, `rehypePlugins`, and `remarkPlugins` in `useMemo` to ensure referential stability, and extract helper functions outside the component scope where possible.

## 2025-02-20 - Backend: Peewee Query Immutability
**Learning:** Peewee query methods like `order_by`, `where`, etc. return a new query object and do not modify the existing one in-place. Failure to assign the result leads to ignored clauses (e.g., `query.order_by(...)` does nothing effectively if result is not used).
**Action:** Always assign the result of Peewee query modifications: `query = query.order_by(...)`.
14 changes: 2 additions & 12 deletions api/db/services/knowledgebase_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,8 @@ def get_all_kb_by_tenant_ids(cls, tenant_ids, user_id):
)
)
# sort by create_time asc
kbs.order_by(cls.model.create_time.asc())
# maybe cause slow query by deep paginate, optimize later.
offset, limit = 0, 50
res = []
while True:
kb_batch = kbs.offset(offset).limit(limit)
_temp = list(kb_batch.dicts())
if not _temp:
break
res.extend(_temp)
offset += limit
return res
kbs = kbs.order_by(cls.model.create_time.asc())
return list(kbs.dicts())

@classmethod
@DB.connection_context()
Expand Down