Repository navigation
fix: guard Android Chat folder selection dialog against dismissal while async folder assignment is in flight - #902
Conversation
…le folder assignment is in flight
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| fun assignCurrentChatToFolder(folderId: String) { | ||
| val chatId = currentChatId ?: return | ||
| viewModelScope.launch { | ||
| _folderAssignmentSaveStatus.value = FolderAssignmentSaveStatus.Saving |
There was a problem hiding this comment.
🔥 The Roast: assignCurrentChatToFolder launches a coroutine on every tap without checking if one is already in flight. Tap fast enough and you'll have overlapping assignments racing to set Saving/Success/Failure — like two people trying to mail the same letter at once. Meanwhile deleteCurrentChat (line 1417) already guards with if (_isDeletingChat.value) return, so this pattern exists in the same file and was ignored here.
🩹 The Fix: Add a guard at the top of the viewModelScope.launch block (or before it) to return early if _folderAssignmentSaveStatus.value == FolderAssignmentSaveStatus.Saving.
📏 Severity: warning
| is ChatViewModel.FolderAssignmentSaveStatus.Failure -> { | ||
| // Keep sheet open; error is surfaced via snackbar below | ||
| snackbarHostState.showSnackbar( | ||
| message = context.getString(R.string.chat_folder_save_failed) |
There was a problem hiding this comment.
🔥 The Roast: The Failure snackbar reuses R.string.chat_folder_save_failed — a string that says "save failed" — for a folder assignment failure. The user is being told a save failed when really an assignment failed. It's accurate enough to not be wrong, but inaccurate enough to make the user wonder what exactly failed.
🩹 The Fix: Use a distinct string like R.string.chat_folder_assignment_failed (or generalize the existing one to chat_folder_operation_failed).
📏 Severity: nitpick
Code Review Roast 🔥Verdict: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)
🏆 Best part: Oh wait, the core fix is actually clean. The LaunchedEffect pattern correctly keeps the sheet open during Saving and dismisses only on Success, mirroring the existing create-folder flow. I need to sit down. 💀 Worst part: The missing concurrency guard in 📊 Overall: Like a first pancake — the shape is right but the edges need trimming. Files Reviewed (2 files)
Fix these issues in Kilo Cloud Reviewed by free · Input: 173K · Output: 37.4K · Cached: 1M Review guidance: REVIEW.md from base branch |
Summary
The Chat folder selection dialog dismisses immediately when a folder is selected, before the async folder assignment completes. If the assignment fails, the user has no feedback.
Related Issue
#900
Changes
ChatViewModel.kt: AddedFolderAssignmentSaveStatussealed class (Idle, Saving, Success, Failure) and_folderAssignmentSaveStatusStateFlow;assignCurrentChatToFoldernow setsSavingbefore the async operation andSuccess/Failurebased onpersistChatFoldersresult.ChatScreen.kt: CollectsfolderAssignmentSaveStatus; addedLaunchedEffectto dismiss the folder selection sheet only onSuccess(or show snackbar onFailure);onFolderSelectedno longer dismisses the sheet immediately.Verification
createFolderSaveStatusused for create-folder dialog)ChatViewModel.kt,ChatScreen.ktUser Impact
Users assigning a chat to a folder will see the dialog remain open while the assignment is in flight, and will receive error feedback if the assignment fails instead of a silent failure.
Acceptance Criteria
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.