Refactor AI assistant dialogue and inspection process#59
Refactor AI assistant dialogue and inspection process#59cmjang merged 6 commits intoOpenLegged:devfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the AI assistant by splitting the monolithic AI modal into specialized Inspection and Conversation components, adding support for Markdown rendering via react-markdown and remark-gfm. Key updates include enhancing the robot and selection stores to preserve inspection context and improve camera focusing. Review feedback identifies redundant token usage from passing conversation history in both the system prompt and message array, and notes that Node.js-specific .unref() calls on timers will fail in a browser environment.
| const systemPrompt = getConversationSystemPrompt(lang, { | ||
| mode, | ||
| context, | ||
| history: serializeConversationHistory(history), | ||
| }) |
There was a problem hiding this comment.
The conversation history is being passed redundantly to the AI model. It is currently serialized into the system prompt via getConversationSystemPrompt and also provided as a sequence of messages in the messages array. This redundancy increases token consumption and can occasionally lead to conflicting instructions if the model prioritizes one source over the other. It is recommended to remove the history from the system prompt and rely solely on the messages array for context.
| if (pendingRefocusTimeout !== null) { | ||
| clearTimeout(pendingRefocusTimeout); | ||
| pendingRefocusTimeout = null; | ||
| } |
| set({ focusTarget: id }); | ||
| scheduleFocusReset(); | ||
| }, 0); | ||
| pendingRefocusTimeout.unref?.(); |
There was a problem hiding this comment.
No description provided.