Skip to content

fix: guard Android Chat folder selection dialog against dismissal while async folder assignment is in flight - #902

Merged
TheRealAshik merged 1 commit into
23-11-2026from
fix/chat-folder-assignment-dismiss-23-11-2026
Nov 23, 2026
Merged

TheRealAshik merged 1 commit into
23-11-2026from
fix/chat-folder-assignment-dismiss-23-11-2026

Conversation

@TheRealAshik

@TheRealAshik TheRealAshik commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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: Added FolderAssignmentSaveStatus sealed class (Idle, Saving, Success, Failure) and _folderAssignmentSaveStatus StateFlow; assignCurrentChatToFolder now sets Saving before the async operation and Success/Failure based on persistChatFolders result.
  • ChatScreen.kt: Collects folderAssignmentSaveStatus; added LaunchedEffect to dismiss the folder selection sheet only on Success (or show snackbar on Failure); onFolderSelected no longer dismisses the sheet immediately.

Verification

  • Code review: change addresses the root cause (dialog dismissed before async folder assignment completes)
  • Surrounding implementation remains consistent with existing patterns (e.g., createFolderSaveStatus used for create-folder dialog)
  • Only relevant files modified: ChatViewModel.kt, ChatScreen.kt
  • No secrets or credentials introduced
  • Dark/light theme and accessibility preserved

User 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

  • The folder selection dialog remains open while the async folder assignment is in flight
  • The dialog only dismisses after the folder assignment completes successfully
  • If the assignment fails, the dialog stays open and the user receives error feedback

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
synapsesocial Ready Ready Preview Nov 23, 2026 1:14pm UTC

fun assignCurrentChatToFolder(folderId: String) {
val chatId = currentChatId ?: return
viewModelScope.launch {
_folderAssignmentSaveStatus.value = FolderAssignmentSaveStatus.Saving

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 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

@kilo-code-bot

kilo-code-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Roast 🔥

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 1
💡 suggestion 0
🤏 nitpick 1
Issue Details (click to expand)
File Line Roast
app/src/main/kotlin/com/synapse/social/studioasinc/feature/inbox/inbox/ChatViewModel.kt 1333 assignCurrentChatToFolder launches a coroutine on every tap without checking if one is already in flight — rapid taps cause overlapping assignments racing on Saving/Success/Failure. deleteCurrentChat already guards this way in the same file and was ignored here.
app/src/main/kotlin/com/synapse/social/studioasinc/feature/inbox/inbox/screens/ChatScreen.kt 1255 Failure snackbar reuses R.string.chat_folder_save_failed ("save failed") for a folder assignment failure — tells the user a save failed when really an assignment failed.

🏆 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 assignCurrentChatToFolder — a race condition waiting for an impatient user to double-tap.

📊 Overall: Like a first pancake — the shape is right but the edges need trimming.

Files Reviewed (2 files)
  • app/src/main/kotlin/com/synapse/social/studioasinc/feature/inbox/inbox/ChatViewModel.kt - 1 issue
  • app/src/main/kotlin/com/synapse/social/studioasinc/feature/inbox/inbox/screens/ChatScreen.kt - 1 issue

Fix these issues in Kilo Cloud


Reviewed by free · Input: 173K · Output: 37.4K · Cached: 1M

Review guidance: REVIEW.md from base branch 23-11-2026

@TheRealAshik
TheRealAshik merged commit d4d7712 into 23-11-2026 Nov 23, 2026
6 checks passed
@TheRealAshik
TheRealAshik deleted the fix/chat-folder-assignment-dismiss-23-11-2026 branch November 23, 2026 13:37

This branch was successfully deployed

1 active deployment
Preview — 00fc8bfc Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant