Feature: Insert Message Above/Below in Conversation (InsertMessage) #144
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#144
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 a feature that allows inserting a new user or assistant message above or below an existing message in a conversation thread. Users pick "Insert" from a message's More Actions menu, configure insertion options (position, role, optional content) via a dialog, and confirm to insert a new message into the conversation tree in the appropriate place.
Why
This improves editing/fine-tuning conversations by letting users introduce new messages at a specific point in a thread without manually copying content or moving messages.
Acceptance criteria
Implementation tasks (suggested order)
Frontend (app module)
Add InsertMessage dialog state to
ChatAreaDialogStatewith fields:Create Insert Message dialog UI in
Dialogs.kt:Add "Insert" menu item to
MoreActionsMenuinMessageActionRow.ktthat triggers anonRequestInsertMessage(targetMessage)action.Add
onRequestInsertMessagetoMessageActionsandChatAreaActionsinterfaces and wire through toChatViewModelso the view model can show the dialog with the target message preselected.Implement
requestInsertMessageandconfirmInsertMessageflows inChatViewModel:requestInsertMessageshows theInsertMessagedialog with the selected target message.confirmInsertMessagecalls theMessageRepository.insertMessagewithmodelIdandsettingsIdfrom the current session, then updates the session's message tree/leaf with the new message ID.Common (shared module)
Create
InsertMessageRequestmodel incommon/src/commonMain/kotlin/eu/torvian/chatbot/common/models/api/core/with fields:targetMessageId: Stringposition: Positionenum (ABOVE | BELOW)role: Roleenum (USER | ASSISTANT)content: String?modelId: StringsettingsId: StringAdd serialization annotations consistent with existing API models.
Client API / Repository
Add
insertMessagemethod toMessageApiClientthat POSTsInsertMessageRequestto server endpoint/api/v1/messages/insertand returns the createdChatMessage.Add
insertMessagemethod toMessageRepositorythat calls the API client, wraps results in ArrowEitherreturningRepositoryErrororChatMessage.Server (server module)
Add POST
/api/v1/messages/insertroute in message routes that:MessageService.insertMessage(request).Extend
MessageServicewithinsertMessage(request: InsertMessageRequest): ChatMessagethat:parentMessageId: for ABOVE => target.parentMessageId; for BELOW => target.id.parentMessageId.Add
insertMessagetoMessageDaowith SQL/Exposed logic to create the message and update sibling orderings and session leaf in a single transaction.Testing
MessageService.insertMessagecovering ABOVE and BELOW cases, edge cases (target is root, target has no parent, inserting into empty thread), and session leaf update behavior.Notes / assumptions
Eitherfor repository error handling and return logical errors per project guidelines.Suggested labels: enhancement, backend, frontend
If you'd like, I can also open a PR scaffolding the
InsertMessageRequestmodel and the client API method, or implement the frontend dialog first. Which subtask do you want me to take on next?