Skip to content

Commit fd27916

Browse files
committed
Fix Rename Chat single-line input and surface persistence failures
1 parent ade9ce5 commit fd27916

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/history/ChatHistoryRepository.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ class RealChatHistoryRepository @Inject constructor(
6161
}
6262

6363
override suspend fun renameChat(chatId: String, newTitle: String) {
64-
withContext(dispatchers.io()) { chatStore.renameChat(chatId, newTitle) }
64+
withContext(dispatchers.io()) {
65+
check(chatStore.renameChat(chatId, newTitle)) { "Chat $chatId not found or unreadable" }
66+
}
6567
}
6668

6769
private fun toChatHistoryItem(chat: DuckAiChat): ChatHistoryItem = ChatHistoryItem(

duckchat/duckchat-impl/src/main/res/layout/fragment_rename_chat.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@
4444
android:layout_height="wrap_content"
4545
android:layout_margin="@dimen/keyline_4"
4646
android:hint="@string/duck_ai_chat_history_rename_chat_title_hint"
47-
android:inputType="text|textCapWords"
47+
app:capitalizeKeyboard="true"
4848
app:layout_constraintEnd_toEndOf="parent"
4949
app:layout_constraintStart_toStartOf="parent"
50-
app:layout_constraintTop_toBottomOf="@id/appBarLayout" />
50+
app:layout_constraintTop_toBottomOf="@id/appBarLayout"
51+
app:type="single_line" />
5152

5253
</androidx.constraintlayout.widget.ConstraintLayout>

duckchat/duckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/history/ChatHistoryRepositoryTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,22 @@ class ChatHistoryRepositoryTest {
165165
verify(chatStore).deleteAllChats()
166166
}
167167

168+
@Test
169+
fun `renameChat delegates to store on success`() = runTest {
170+
whenever(chatStore.renameChat("abc", "New")).thenReturn(true)
171+
172+
repository.renameChat("abc", "New")
173+
174+
verify(chatStore).renameChat("abc", "New")
175+
}
176+
177+
@Test(expected = IllegalStateException::class)
178+
fun `renameChat throws when store reports the chat could not be updated`() = runTest {
179+
whenever(chatStore.renameChat("missing", "New")).thenReturn(false)
180+
181+
repository.renameChat("missing", "New")
182+
}
183+
168184
private fun chat(
169185
chatId: String,
170186
title: String = "Title",

0 commit comments

Comments
 (0)