π fix: slove the agent group editor not focus in editdata area#11677
π fix: slove the agent group editor not focus in editdata area#11677ONLY-yours merged 1 commit intonextfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideAdjusts the editor canvas to reload content based on a stable entity identifier instead of raw editor data, stabilizes editorData references and selector subscriptions in group/agent profile screens to avoid unnecessary re-renders that steal focus, and hardens agent-group synchronization logic to avoid overwriting newer local agent data with stale server responses. Sequence diagram for editor content reload based on entityIdsequenceDiagram
actor User
participant MemberProfile
participant EditorCanvas
participant EditorDataMode
participant Editor as IEditor
User->>MemberProfile: Select agentId A and start editing
MemberProfile->>EditorCanvas: render editor(editor, editorData, entityId=A)
EditorCanvas->>EditorDataMode: render editor, editorData, entityId=A
EditorDataMode->>EditorDataMode: handleInit(editorInstance)
EditorDataMode->>Editor: loadEditorContent(editorInstance, editorData) when isEntityChanged
EditorDataMode->>EditorDataMode: currentEntityIdRef set to A
loop autosave for same entity A
Editor->>MemberProfile: onContentChange(content, editorData)
MemberProfile->>MemberProfile: updateAgentConfigById
MemberProfile->>EditorCanvas: re-render editor(editor, editorData, entityId=A)
EditorCanvas->>EditorDataMode: re-render with same entityId A
EditorDataMode->>EditorDataMode: isEntityChanged is false
EditorDataMode->>EditorDataMode: useEffect does not reload content
Editor-->User: caret focus preserved
end
User->>MemberProfile: Switch to agentId B
MemberProfile->>EditorCanvas: render editor(editor, editorData, entityId=B)
EditorCanvas->>EditorDataMode: re-render with entityId=B
EditorDataMode->>EditorDataMode: isEntityChanged is true
EditorDataMode->>Editor: loadEditorContent(editor, editorData)
EditorDataMode->>EditorDataMode: currentEntityIdRef set to B
Updated class diagram for EditorCanvas and EditorDataMode props with entityIdclassDiagram
class EditorCanvasProps {
+ReactNode children
+string~undefined documentId
+object~unknown editorData
+string~undefined entityId
+function onContentChange
+function onInit
+object style
}
class EditorCanvasWithEditorProps {
+IEditor editor
}
class EditorDataModeProps {
+IEditor editor
+object editorData
+string~undefined entityId
+function onContentChange
+function onInit
+object style
}
class EditorCanvas {
+EditorCanvas(props)
}
class EditorDataMode {
+EditorDataMode(props)
+handleInit(editorInstance IEditor)
}
EditorCanvasWithEditorProps --|> EditorCanvasProps
EditorDataModeProps --|> EditorCanvasProps
EditorCanvas o--> EditorDataMode
EditorDataMode ..> IEditor
Flow diagram for smart merge of agent group details into agent storeflowchart TD
A[Fetch groupDetail from server] --> B[Iterate groupDetail.agents]
B --> C[Get agentStore state]
C --> D[Read currentAgentInStore by agent.id]
D -->|No existing agent in store| E[Dispatch internal_dispatchAgentMap with server agent]
D -->|Existing agent in store| F{Is server agent.updatedAt > currentAgentInStore.updatedAt?}
F -->|Yes| E
F -->|No| G[Keep local agent version in agentStore]
E --> H[Agent store updated with newer server data]
G --> H
H --> I[Continue processing remaining agents]
I --> J[Agent store contains latest data without overwriting newer local edits]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/store/agentGroup/action.ts:220-227` </location>
<code_context>
for (const agent of groupDetail.agents) {
- // AgentGroupMember extends AgentItem which shares fields with LobeAgentConfig
- agentStore.internal_dispatchAgentMap(agent.id, agent as any);
+ const currentAgentInStore = agentStore.agentMap[agent.id];
+
+ // Only overwrite if:
+ // 1. Agent doesn't exist in store
+ // 2. Server data is newer than store data (based on updatedAt)
+ if (
+ !currentAgentInStore ||
+ new Date(agent.updatedAt) > new Date(currentAgentInStore.updatedAt || 0)
+ ) {
+ // AgentGroupMember extends AgentItem which shares fields with LobeAgentConfig
</code_context>
<issue_to_address>
**issue:** The `updatedAt` comparison can behave unexpectedly when `updatedAt` is missing or invalid.
The merge rule currently uses `new Date(currentAgentInStore.updatedAt || 0)` for the local value and `new Date(agent.updatedAt)` for the server value. This leads to:
- `agent.updatedAt` missing/invalid β `new Date(agent.updatedAt)` is `Invalid Date`, the comparison is always `false`, and local data is never overwritten, even when the server is effectively newer.
- `currentAgentInStore.updatedAt` missing β it becomes `new Date(0)`, which may not match the true staleness and can cause unintuitive overwrites.
Consider normalizing to numeric timestamps and encoding an explicit policy for the "no updatedAt" case, for example:
```ts
const serverUpdated = agent.updatedAt ? new Date(agent.updatedAt).getTime() : 0;
const localUpdated = currentAgentInStore?.updatedAt
? new Date(currentAgentInStore.updatedAt).getTime()
: 0;
if (!currentAgentInStore || serverUpdated > localUpdated) {
agentStore.internal_dispatchAgentMap(agent.id, agent as any);
}
```
</issue_to_address>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
| const currentAgentInStore = agentStore.agentMap[agent.id]; | ||
|
|
||
| // Only overwrite if: | ||
| // 1. Agent doesn't exist in store | ||
| // 2. Server data is newer than store data (based on updatedAt) | ||
| if ( | ||
| !currentAgentInStore || | ||
| new Date(agent.updatedAt) > new Date(currentAgentInStore.updatedAt || 0) |
There was a problem hiding this comment.
issue: The updatedAt comparison can behave unexpectedly when updatedAt is missing or invalid.
The merge rule currently uses new Date(currentAgentInStore.updatedAt || 0) for the local value and new Date(agent.updatedAt) for the server value. This leads to:
agent.updatedAtmissing/invalid βnew Date(agent.updatedAt)isInvalid Date, the comparison is alwaysfalse, and local data is never overwritten, even when the server is effectively newer.currentAgentInStore.updatedAtmissing β it becomesnew Date(0), which may not match the true staleness and can cause unintuitive overwrites.
Consider normalizing to numeric timestamps and encoding an explicit policy for the "no updatedAt" case, for example:
const serverUpdated = agent.updatedAt ? new Date(agent.updatedAt).getTime() : 0;
const localUpdated = currentAgentInStore?.updatedAt
? new Date(currentAgentInStore.updatedAt).getTime()
: 0;
if (!currentAgentInStore || serverUpdated > localUpdated) {
agentStore.internal_dispatchAgentMap(agent.id, agent as any);
}
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## next #11677 +/- ##
==========================================
- Coverage 74.60% 74.59% -0.01%
==========================================
Files 1187 1187
Lines 93621 93627 +6
Branches 10811 10811
==========================================
Hits 69842 69842
- Misses 23689 23695 +6
Partials 90 90
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
|
β€οΈ Great PR @ONLY-yours β€οΈ The growth of the project is inseparable from user feedback and contribution. Thanks for your contribution! If you are interested in 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 LobeChat development and sharing AI newsletters from around the world.
Original Contentβ€οΈ Great PR @ONLY-yours β€οΈ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. |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28aa34207a
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Different entity - load new content | ||
| try { | ||
| if (loadEditorContent(editor, editorData)) { | ||
| loadedContentRef.current = editorData.content; | ||
| currentEntityIdRef.current = entityId; | ||
| } |
There was a problem hiding this comment.
Clear editor when switching to an empty entity
When the entity changes, this branch only calls loadEditorContent and does nothing if it returns false; for a new group/agent with empty content and empty editorData, loadEditorContent no-ops, so the editor keeps the previous entityβs text. Because the key-based remount was removed in this change, switching to a blank entity now shows stale content from the prior entity until the user edits, which is a visible data mixβup. Consider explicitly clearing/resetting the editor when entityId changes and thereβs no content/editorData to load.
Useful? React with πΒ / π.
## [Version 2.0.0-next.331](v2.0.0-next.330...v2.0.0-next.331) <sup>Released on **2026-01-21**</sup> #### π Bug Fixes - **misc**: Slove the agent group editor not focus in editdata area. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Slove the agent group editor not focus in editdata area, closes [#11677](#11677) ([9ac84e6](9ac84e6)) </details> <div align="right"> [](#readme-top) </div>
|
π This PR is included in version 2.0.0-next.331 π The release is available on: Your semantic-release bot π¦π |
## [Version 1.153.0](v1.152.0...v1.153.0) <sup>Released on **2026-01-23**</sup> #### β» Code Refactoring - **auth**: Remove NEXT_PUBLIC_AUTH_URL env variable. - **model-select**: Migrate FunctionCallingModelSelect to LobeSelect. - **ModelSwitchPanel**: Migrate from Popover to DropdownMenu with virtual scrolling. - **userMemories**: Removed un-used code. - **misc**: Improve memory data with experience and identity, move vercel-react-best-practices skills to .agents directory. #### β¨ Features - **database**: Added user memory activity. - **desktop**: Add legacy local database detection and migration guidance. - **misc**: Add platform-aware download client menu option, add server version check for desktop app, remove Clerk authentication code, skill setting page and skill store, support agent group unpublish agents, support client tasks mode, update the sandbox preinstall libs in sys role. #### π Bug Fixes - **copilot**: Pass correct scope when creating new session in PageEditor. - **desktop**: Gracefully handle missing update manifest 404 errors. - **model-runtime**: Filter unsupported image types (SVG) before sending to vision models. - **pdf**: Upgrade pdfjs-dist and react-pdf to v5.x. - **sidebar-drawer**: Fix drawer positioning and title style. - **misc**: Fix group broadcast trigger tool use, fix local system tools, fix memory schema, fix multi agent tasks issue, fix multi tasks no summary issue, fix scope issue, fix tool argument scape and improve multi task run, fixed the sandbox tools call when error should use right callback, improve e2e server and complete i18n resources, slove the agent group editor not focus in editdata area, slove the agents header switch agents the lobeAI not show problem, sloved the old removeSessionTopics not work, TypewriterEffect not refreshing on language change, updata cron job ui & fixed commnuity pagenation goto error, update the agentbuilder tools not always use humanIntervention. #### π Styles - **misc**: Improve auto scroll and group profile, update og, update share style. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **auth**: Remove NEXT_PUBLIC_AUTH_URL env variable, closes [lobehub#11658](https://github.com/jaworldwideorg/OneJA-Bot/issues/11658) ([c0f9875](c0f9875)) * **model-select**: Migrate FunctionCallingModelSelect to LobeSelect, closes [lobehub#11664](https://github.com/jaworldwideorg/OneJA-Bot/issues/11664) ([ad51305](ad51305)) * **ModelSwitchPanel**: Migrate from Popover to DropdownMenu with virtual scrolling, closes [lobehub#11663](https://github.com/jaworldwideorg/OneJA-Bot/issues/11663) ([c9d9dff](c9d9dff)) * **userMemories**: Removed un-used code, closes [lobehub#11713](https://github.com/jaworldwideorg/OneJA-Bot/issues/11713) ([89750fc](89750fc)) * **misc**: Improve memory data with experience and identity, closes [lobehub#11717](https://github.com/jaworldwideorg/OneJA-Bot/issues/11717) ([bdb3eb4](bdb3eb4)) * **misc**: Move vercel-react-best-practices skills to .agents directory, closes [lobehub#11703](https://github.com/jaworldwideorg/OneJA-Bot/issues/11703) ([6df7731](6df7731)) #### What's improved * **database**: Added user memory activity, closes [lobehub#11680](https://github.com/jaworldwideorg/OneJA-Bot/issues/11680) ([0160fbd](0160fbd)) * **desktop**: Add legacy local database detection and migration guidance, closes [lobehub#11682](https://github.com/jaworldwideorg/OneJA-Bot/issues/11682) ([5664b84](5664b84)) * **misc**: Add platform-aware download client menu option, closes [lobehub#11676](https://github.com/jaworldwideorg/OneJA-Bot/issues/11676) ([55abddc](55abddc)) * **misc**: Add server version check for desktop app, closes [lobehub#11710](https://github.com/jaworldwideorg/OneJA-Bot/issues/11710) ([0cf2723](0cf2723)) * **misc**: Remove Clerk authentication code, closes [lobehub#11711](https://github.com/jaworldwideorg/OneJA-Bot/issues/11711) ([395595a](395595a)) * **misc**: Skill setting page and skill store, closes [lobehub#11665](https://github.com/jaworldwideorg/OneJA-Bot/issues/11665) ([d8c0c26](d8c0c26)) * **misc**: Support agent group unpublish agents, closes [lobehub#11687](https://github.com/jaworldwideorg/OneJA-Bot/issues/11687) ([4e060be](4e060be)) * **misc**: Support client tasks mode, closes [lobehub#11666](https://github.com/jaworldwideorg/OneJA-Bot/issues/11666) ([98cf57b](98cf57b)) * **misc**: Update the sandbox preinstall libs in sys role, closes [lobehub#11688](https://github.com/jaworldwideorg/OneJA-Bot/issues/11688) ([404c577](404c577)) #### What's fixed * **copilot**: Pass correct scope when creating new session in PageEditor, closes [lobehub#11714](https://github.com/jaworldwideorg/OneJA-Bot/issues/11714) ([0259270](0259270)) * **desktop**: Gracefully handle missing update manifest 404 errors, closes [lobehub#11625](https://github.com/jaworldwideorg/OneJA-Bot/issues/11625) ([13e95b9](13e95b9)) * **model-runtime**: Filter unsupported image types (SVG) before sending to vision models, closes [lobehub#11698](https://github.com/jaworldwideorg/OneJA-Bot/issues/11698) ([c0c99a7](c0c99a7)) * **pdf**: Upgrade pdfjs-dist and react-pdf to v5.x, closes [lobehub#11686](https://github.com/jaworldwideorg/OneJA-Bot/issues/11686) ([2b620df](2b620df)) * **sidebar-drawer**: Fix drawer positioning and title style, closes [lobehub#11655](https://github.com/jaworldwideorg/OneJA-Bot/issues/11655) ([cf5320e](cf5320e)) * **misc**: Fix group broadcast trigger tool use, closes [lobehub#11646](https://github.com/jaworldwideorg/OneJA-Bot/issues/11646) ([831a9b3](831a9b3)) * **misc**: Fix local system tools, closes [lobehub#11702](https://github.com/jaworldwideorg/OneJA-Bot/issues/11702) ([6548fc7](6548fc7)) * **misc**: Fix memory schema, closes [lobehub#11645](https://github.com/jaworldwideorg/OneJA-Bot/issues/11645) ([3baf780](3baf780)) * **misc**: Fix multi agent tasks issue, closes [lobehub#11672](https://github.com/jaworldwideorg/OneJA-Bot/issues/11672) ([9de773b](9de773b)) * **misc**: Fix multi tasks no summary issue, closes [lobehub#11685](https://github.com/jaworldwideorg/OneJA-Bot/issues/11685) ([26ce317](26ce317)) * **misc**: Fix scope issue, closes [lobehub#11719](https://github.com/jaworldwideorg/OneJA-Bot/issues/11719) ([17adde8](17adde8)) * **misc**: Fix tool argument scape and improve multi task run, closes [lobehub#11691](https://github.com/jaworldwideorg/OneJA-Bot/issues/11691) ([b13bb8a](b13bb8a)) * **misc**: Fixed the sandbox tools call when error should use right callback, closes [lobehub#11721](https://github.com/jaworldwideorg/OneJA-Bot/issues/11721) ([e8fce68](e8fce68)) * **misc**: Improve e2e server and complete i18n resources, closes [lobehub#11678](https://github.com/jaworldwideorg/OneJA-Bot/issues/11678) ([d450dd9](d450dd9)) * **misc**: Slove the agent group editor not focus in editdata area, closes [lobehub#11677](https://github.com/jaworldwideorg/OneJA-Bot/issues/11677) ([9ac84e6](9ac84e6)) * **misc**: Slove the agents header switch agents the lobeAI not show problem, closes [lobehub#11726](https://github.com/jaworldwideorg/OneJA-Bot/issues/11726) ([f45f508](f45f508)) * **misc**: Sloved the old removeSessionTopics not work, closes [lobehub#11671](https://github.com/jaworldwideorg/OneJA-Bot/issues/11671) ([06d41e5](06d41e5)) * **misc**: TypewriterEffect not refreshing on language change, closes [lobehub#11657](https://github.com/jaworldwideorg/OneJA-Bot/issues/11657) ([ba30f46](ba30f46)) * **misc**: Updata cron job ui & fixed commnuity pagenation goto error, closes [lobehub#11700](https://github.com/jaworldwideorg/OneJA-Bot/issues/11700) ([42ad2a0](42ad2a0)) * **misc**: Update the agentbuilder tools not always use humanIntervention, closes [lobehub#11696](https://github.com/jaworldwideorg/OneJA-Bot/issues/11696) ([0d3017b](0d3017b)) #### Styles * **misc**: Improve auto scroll and group profile, closes [lobehub#11725](https://github.com/jaworldwideorg/OneJA-Bot/issues/11725) ([550acc2](550acc2)) * **misc**: Update og, closes [lobehub#11709](https://github.com/jaworldwideorg/OneJA-Bot/issues/11709) ([01cf4e4](01cf4e4)) * **misc**: Update share style, closes [lobehub#11716](https://github.com/jaworldwideorg/OneJA-Bot/issues/11716) ([3c70dfa](3c70dfa)) </details> <div align="right"> [](#readme-top) </div>
π» Change Type
π Related Issue
π Description of Change
π§ͺ How to Test
πΈ Screenshots / Videos
π Additional Information
Summary by Sourcery
Improve editor behavior for agent and group profiles to prevent focus loss when auto-saving and switching entities.
Bug Fixes:
Enhancements: