Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideRefactors and extends the database schema and shared types to support richer threading/agent metadata, compressed message groups, memory/onboarding fields on users, and new indexes, with a matching migration and minor tooling/script updates. ER diagram for updated database schema (threads, users, agents, memories, AI infra)erDiagram
users {
text id
text email
varchar[] interests
jsonb onboarding
}
user_settings {
text id
text user_id
jsonb system_agent
jsonb default_agent
jsonb market
jsonb memory
jsonb tool
jsonb image
}
agents {
text id
text user_id
jsonb plugins
boolean pinned
}
chat_groups {
text id
text user_id
}
threads {
text id
text topic_id
text parent_thread_id
text client_id
text user_id
text agent_id
text group_id
jsonb metadata
text type
text status
}
message_groups {
text id
text topic_id
text user_id
text client_id
text title
text description
text type
text content
jsonb editor_data
}
messages {
text id
text group_id
text user_id
text role
text content
jsonb editor_data
text summary
}
message_plugins {
text id
text message_id
text tool_call_id
text user_id
text client_id
}
user_memories_contexts {
text id
text user_id
jsonb user_memory_ids
jsonb metadata
text[] tags
jsonb associated_objects
jsonb associated_subjects
text title
text description
vector description_vector
}
ai_providers {
text id
text user_id
text provider
}
ai_models {
text id
text provider_id
text user_id
text model
}
%% Relationships
users ||--o{ user_settings : has
users ||--o{ agents : owns
users ||--o{ chat_groups : owns
users ||--o{ threads : owns
users ||--o{ message_groups : owns
users ||--o{ messages : owns
users ||--o{ message_plugins : owns
users ||--o{ user_memories_contexts : owns
users ||--o{ ai_providers : configures
users ||--o{ ai_models : configures
agents ||--o{ threads : assigned_to
chat_groups ||--o{ threads : grouped_in
message_groups ||--o{ messages : contains
messages ||--o{ message_plugins : uses
ai_providers ||--o{ ai_models : offers
threads ||--o{ threads : parent_of
user_memories_contexts ||--o{ user_memories_contexts : related_to
Class diagram for updated types and metadata (ThreadMetadata, UserOnboarding, and related models)classDiagram
class ThreadMetadata {
+string completedAt
+number duration
+string error
+string operationId
+string startedAt
+number totalCost
+number totalMessages
+number totalTokens
+number totalToolCalls
}
class UserOnboarding {
+number currentStep
+string finishedAt
+number version
}
class AgentRow {
+string id
+string userId
+string[] plugins
+boolean pinned
}
class UserRow {
+string id
+string email
+string firstName
+string lastName
+string fullName
+string[] interests
+UserOnboarding onboarding
}
class UserSettingsRow {
+string id
+string userId
+any systemAgent
+any defaultAgent
+any market
+any memory
+any tool
+any image
}
class MessageGroupRow {
+string id
+string topicId
+string userId
+string clientId
+string title
+string description
+string type
+string content
+any editorData
}
class MessageRow {
+string id
+string groupId
+string userId
+string role
+string content
+any editorData
+string summary
}
class UserMemoriesContextRow {
+string id
+string userId
+string[] userMemoryIds
+Record~string, unknown~ metadata
+string[] tags
+AssociatedObject[] associatedObjects
+AssociatedObject[] associatedSubjects
+string title
+string description
}
class AssociatedObject {
+Record~string, unknown~ extra
+string name
+string type
}
class ThreadRow {
+string id
+string topicId
+string parentThreadId
+string clientId
+string userId
+string agentId
+string groupId
+ThreadMetadata metadata
+string type
+string status
}
UserRow "1" --> "1" UserOnboarding : has
ThreadRow "1" --> "1" ThreadMetadata : has
UserRow "1" --> "*" AgentRow : owns
UserRow "1" --> "1" UserSettingsRow : owns
UserRow "1" --> "*" MessageGroupRow : owns
MessageGroupRow "1" --> "*" MessageRow : contains
UserRow "1" --> "*" UserMemoriesContextRow : owns
UserMemoriesContextRow "*" --> "*" AssociatedObject : references
AgentRow "1" --> "*" ThreadRow : assigned_to
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
⏳ Processing in progress |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #10860 +/- ##
========================================
Coverage 80.31% 80.31%
========================================
Files 980 980
Lines 66983 66983
Branches 9153 8780 -373
========================================
Hits 53800 53800
Misses 13183 13183
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The
agents.pluginscolumn no longer has a default while the Drizzle type is stillstring[]; consider either keeping a non-null default or updating the type/usage to safely handlenullto avoid runtime assumptions of an array. - The new
users.onboardingjsonb column is nullable in the schema but theUserOnboardingtype requires aversionfield; make sure call sites either treat the column as optional/nullable or initialize a default shape to prevent undefinedversionvalues at runtime.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `agents.plugins` column no longer has a default while the Drizzle type is still `string[]`; consider either keeping a non-null default or updating the type/usage to safely handle `null` to avoid runtime assumptions of an array.
- The new `users.onboarding` jsonb column is nullable in the schema but the `UserOnboarding` type requires a `version` field; make sure call sites either treat the column as optional/nullable or initialize a default shape to prevent undefined `version` values at runtime.
## Individual Comments
### Comment 1
<location> `packages/database/src/schemas/agent.ts:40` </location>
<code_context>
backgroundColor: text('background_color'),
marketIdentifier: text('market_identifier'),
- plugins: jsonb('plugins').$type<string[]>().default([]),
+ plugins: jsonb('plugins').$type<string[]>(),
clientId: text('client_id'),
</code_context>
<issue_to_address>
**issue (bug_risk):** Dropping the `plugins` default may introduce `null` where code expects an array.
Without the `[]` default (and with `ALTER TABLE "agents" ALTER COLUMN "plugins" DROP DEFAULT;`), `plugins` can now be `NULL` for both existing and new rows. Any code that assumes this is always an array (e.g., iterating/spreading without a null check) may now throw at runtime. Consider keeping the default, adding a non-null constraint with a default, or updating all call sites to handle `null` explicitly.
</issue_to_address>
### Comment 2
<location> `packages/types/src/user/onboarding.ts:14` </location>
<code_context>
+export interface UserOnboarding {
+ /** Current step number (1-based), for resuming onboarding */
+ currentStep?: number;
+ /** Timestamp when onboarding was completed (ISO 8601) */
+ finishedAt?: string;
+ /** Onboarding flow version for future upgrades */
+ version: number;
</code_context>
<issue_to_address>
**suggestion:** The schema doesn’t enforce the documented ISO 8601 format for `finishedAt`.
Docs promise an ISO 8601 timestamp, but the schema only uses a plain `string`. To align them, consider `z.string().datetime()` (if supported) or a custom refinement to validate ISO 8601; otherwise the documented contract and actual validation will diverge.
```suggestion
finishedAt: z.string().datetime().optional(),
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| export const UserOnboardingSchema = z.object({ | ||
| currentStep: z.number().optional(), | ||
| finishedAt: z.string().optional(), |
There was a problem hiding this comment.
suggestion: The schema doesn’t enforce the documented ISO 8601 format for finishedAt.
Docs promise an ISO 8601 timestamp, but the schema only uses a plain string. To align them, consider z.string().datetime() (if supported) or a custom refinement to validate ISO 8601; otherwise the documented contract and actual validation will diverge.
| finishedAt: z.string().optional(), | |
| finishedAt: z.string().datetime().optional(), |
|
❤️ Great PR @arvinxx ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
## [Version 2.0.0-next.174](v2.0.0-next.173...v2.0.0-next.174) <sup>Released on **2025-12-20**</sup> #### ♻ Code Refactoring - **misc**: Refactor database schema. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor database schema, closes [#10860](#10860) ([5c489bc](5c489bc)) </details> <div align="right"> [](#readme-top) </div>
|
🎉 This PR is included in version 2.0.0-next.174 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [Version 1.146.0](v1.145.1...v1.146.0) <sup>Released on **2025-12-29**</sup> #### ♻ Code Refactoring - **misc**: Refactor database schema. #### ✨ Features - **ci**: Add bundle analyzer workflow. - **misc**: Mobile native better auth support. #### 🐛 Bug Fixes - **ci**: Always continue build to upload bundle analyzer report, skip backend routes in bundle analyzer build. - **scripts**: Fix syntax error in prebuild.mts. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Refactor database schema, closes [lobehub#10860](https://github.com/jaworldwideorg/OneJA-Bot/issues/10860) ([5c489bc](5c489bc)) #### What's improved * **ci**: Add bundle analyzer workflow, closes [lobehub#10932](https://github.com/jaworldwideorg/OneJA-Bot/issues/10932) ([c470cfb](c470cfb)) * **misc**: Mobile native better auth support, closes [lobehub#10871](https://github.com/jaworldwideorg/OneJA-Bot/issues/10871) ([8c42a93](8c42a93)) #### What's fixed * **ci**: Always continue build to upload bundle analyzer report, closes [lobehub#10946](https://github.com/jaworldwideorg/OneJA-Bot/issues/10946) ([8d37811](8d37811)) * **ci**: Skip backend routes in bundle analyzer build, closes [lobehub#10944](https://github.com/jaworldwideorg/OneJA-Bot/issues/10944) ([0276b87](0276b87)) * **scripts**: Fix syntax error in prebuild.mts, closes [lobehub#10952](https://github.com/jaworldwideorg/OneJA-Bot/issues/10952) ([3d46c13](3d46c13)) </details> <div align="right"> [](#readme-top) </div>
💻 Change Type
🔗 Related Issue
🔀 Description of Change
🧪 How to Test
📸 Screenshots / Videos
📝 Additional Information
Summary by Sourcery
Update database and type schemas to support richer threading, messaging, agent, and user personalization metadata, along with corresponding migrations and tooling adjustments.
New Features:
Enhancements:
Build: