| 1855 | } |
| 1856 | |
| 1857 | void LLMChatUI::writeToLastChat( const std::string& text ) { |
| 1858 | runOnMainThread( [this, text] { |
| 1859 | removeWaitingBubble(); |
| 1860 | |
| 1861 | UIWidget* chatAdded = nullptr; |
| 1862 | if ( mChatsList->getChildCount() > 0 ) { |
| 1863 | auto* lastChild = mChatsList->getLastChild()->asType<UIWidget>(); |
| 1864 | if ( lastChild->hasClass( "llm_conversation" ) && !lastChild->hasClass( "llm_plan" ) && |
| 1865 | !lastChild->hasClass( "llm_tool_call" ) && |
| 1866 | !lastChild->hasClass( "llm_thought" ) ) { |
| 1867 | auto* roleDDL = lastChild->findByClass<UIDropDownList>( "role_ui" ); |
| 1868 | if ( roleDDL && roleDDL->getListBox()->getItemSelectedIndex() == 1 ) { |
| 1869 | chatAdded = lastChild; |
| 1870 | } |
| 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | if ( nullptr == chatAdded ) { |
| 1875 | chatAdded = addChatUI( LLMChat::Role::Assistant ); |
| 1876 | } |
| 1877 | |
| 1878 | auto* editor = chatAdded->findByClass<UICodeEditor>( "data_ui" ); |
| 1879 | if ( !editor ) |
| 1880 | return; |
| 1881 | |
| 1882 | auto* thinking = editor->findByClass<UIImage>( "thinking" ); |
| 1883 | if ( thinking ) { |
| 1884 | auto thinkingID = String::hash( String::format( "thinking-%p", thinking ) ); |
| 1885 | thinking->removeActionsByTag( thinkingID ); |
| 1886 | thinking->setVisible( false ); |
| 1887 | } |
| 1888 | |
| 1889 | editor->getDocument().textInput( String::fromUtf8( text ) ); |
| 1890 | editor->setCursorVisible( false ); |
| 1891 | resizeToFit( editor ); |
| 1892 | mChatScrollView->getVerticalScrollBar()->setValue( 1.0f ); |
| 1893 | } ); |
| 1894 | } |
| 1895 | |
| 1896 | void LLMChatUI::updateAgentModeUI() { |
| 1897 | mModelBtn->setVisible( !mIsAgentMode ); |
nothing calls this directly
no test coverage detected