Add Recursive Message Deletion Feature (Delete Thread) #142
Labels
No labels
Epic 5
MCP
P1
PR-0
PR-1
api
api-layer
architecture
area:backend
area:frontend
arrow
authentication
backend
bug
chat
client
clipboard
common-module
compose
cross-cutting
cross-cutting-requirement
data-layer
data-models
database
desktop-client
documentation
duplicate
enhancement
epic
epic-1
epic-2
epic-3
epic-4
epic-5
epic-6
epic-7
epic-llm-config
error-handling
feature
frontend
good first issue
help wanted
implementation
infrastructure
installer
invalid
kotlin
ktor
llm
medium-priority
message
multiplatform
needs-review
needs-triage
packaging
performance
phase-1
phase-2
phase-3
phase-4
phase-5
phase3
phase:3
priority: high
question
refactor
refactoring
resource-sharing
security
server
server-module
services
session
session-management
settings
setup
shutdown
state
storage
streaming
sub-issue
tests
tooling
type:task
ui
ui/ux
user-accounts
user-management
ux
viewmodel
websocket
windows
windows-integration
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Torvian.eu/chatbot#142
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add support for recursive message deletion ("Delete Thread") alongside existing single message deletion. Use Ktor Resources with declarative query parameters for compile-time validation and wire the feature through UI, API, and repository layers.
Motivation
Users need a safe and discoverable way to delete entire message threads (a message and all its replies). This feature adds a "Delete Thread" action, stronger confirmation, and backend support while keeping existing single-message deletion intact.
Proposed Implementation Steps
MessageResource.ByIdinMessageResource.ktto includemode: DeleteMode = DeleteMode.SINGLEas a declarative query parameter (Ktor Resources) so the mode is validated at compile time instead of manually parsing query params.configureMessageRoutes.ktto read the typedmodeparameter fromMessageResource.ByIdand call eithermessageService.deleteMessage(sessionId, messageId)ormessageService.deleteMessageRecursively(sessionId, messageId)depending on the mode value.MessageActions(MessageActions.kt) to include a newonDeleteThread: (ChatMessage) -> Unitcallback alongside existingonDeleteMessage.MessageActionRow.ktto add a "More" dropdown/popup menu containing the new "Delete Thread" action using the "Delete Sweep" icon (or similar) and the theme's error color. Position this after the existing Delete button in the hover actions so users can choose single-delete quickly and access thread-delete from the menu.deleteMessageRecursively(sessionId: Long, messageId: Long)to the client API interface (ChatApi) and implement it inKtorChatApiClient.ktby passingmode=DeleteMode.RECURSIVEin the Ktor resources call.deleteMessageRecursively(sessionId: Long, messageId: Long)toSessionRepositoryand implement inDefaultSessionRepositoryto call the new API client method.DeleteMessageUseCase(DeleteMessageUseCase.kt) to acceptrecursive: Boolean = falseand call the appropriate repository method based on this flag.requestDeleteMessageRecursively(message: ChatMessage)inChatViewModelthat triggers the recursive delete flow (show confirmation dialog and invoke use case when confirmed).ChatScreenactions andChatAreacompose wiring pass throughonDeleteThreadto the ViewModel method.ChatAreaDialogState.DeleteMessageRecursivelytoChatAreaDialogState.ktwith a stronger confirmation copy, e.g., "This will delete the message and all replies in this thread. This action cannot be undone."DeleteModeparsing and default value behavior (if applicable)configureMessageRoutesbehavior for both modes (unit test route handler or integration test)KtorChatApiClientrequest formation for RECURSIVE modeDefaultSessionRepositorymapping to clientDeleteMessageUseCasebranching for recursive=true/falseChatViewModelmethods to ensure correct use case invocationAcceptance criteria
modequery parameter is used for message deletion APIs.messageService.deleteMessageRecursively(...)on the server.Notes and considerations
Labels
If helpful, I can also open follow-up PRs with the changes described once this issue is accepted.