Skip to content

feat: add conversation branching (edit to fork) - #155

Open
dalekirkwood wants to merge 1 commit into
SimonSchubert:mainfrom
dalekirkwood:feature/conversation-edit
Open

feat: add conversation branching (edit to fork)#155
dalekirkwood wants to merge 1 commit into
SimonSchubert:mainfrom
dalekirkwood:feature/conversation-edit

Conversation

@dalekirkwood

Copy link
Copy Markdown

Why

Sometimes, I want to go back and edit a message, but it's also nice to have forks of conversations. This is a common feature from most AI Chats, so it feels a welcome addition to Kai.

What

  • Edit icon below user messages opens an edit dialog
  • Editing creates a branch — the original conversation path is preserved
  • Edited messages automatically trigger an AI response
  • Inline < X / Y > navigation between branches (below the branched message)
  • Multiple branch groups supported at different fork points in the same conversation
  • Branches are persisted to conversation JSON — survive app restart and conversation switching
  • Edit icon disabled during loading to prevent conflicts
  • Backward compatible — old conversations without branch data load normally

Files Changed

  • Conversation.kt — Added BranchData for branch persistence
  • DataRepository.kt — Added BranchDirection enum and interface methods
  • RemoteDataRepository.kt — Branch group management, serialization/deserialization
  • ChatUiState.kt — Added branchInfo to state
  • ChatViewModel.kteditMessage calls ask(null) for auto-response
  • ChatScreen.kt — Inline branch navigation below user messages
  • UserMessage.kt — Added edit icon button (same pattern as bot message icons)
  • EditMessageDialog.kt — New composable for editing messages
  • ic_edit.xml — New edit icon drawable
  • ChatActions.kt — Added navigateBranch and editMessage
  • FakeDataRepository.kt, ScreenshotTestData.kt — Test stubs

Tested

  • Desktop build passes (compileKotlinDesktop)
  • App launches without crashes
  • Backward compatible with existing conversations

@Mohammed-Lahboub

Copy link
Copy Markdown

This is a really great feature! Conversation branching makes the app much more powerful and flexible. Looking forward to trying it 👌

@dalekirkwood

Copy link
Copy Markdown
Author

Thanks @mohammed-lahboub15 - appreciate it.

I've also been working one NextCloud/OwnCloud sync, it still has a few things to resolve.

I'll need to test it thoroughly, and makes some changes to the import/export function but I think will be a worthwhile addition.

@Mohammed-Lahboub

Copy link
Copy Markdown

That sounds really exciting!

Nextcloud/OwnCloud sync would be a fantastic feature, especially for users who prefer self-hosted and privacy-focused solutions. It would make Kai even more powerful.

Looking forward to it — and thanks again for your great work!

@SimonSchubert

Copy link
Copy Markdown
Owner

The branching brings a certain complexity which I try to postpone for now

Tho I'm very interested in next cloud sync. Settings sync in general. Specifically sync implementations that rely on other services and don't require too many changes in Kai

@dalekirkwood

Copy link
Copy Markdown
Author

Understood @SimonSchubert . Would you consider a PR just for editing a message with no forking?

It would be much simpler and fit 95% of use cases.

@TimeJunkie

TimeJunkie commented Apr 13, 2026

Copy link
Copy Markdown

Ability to edit messages would be a nice feature. On that note also, when the dynamic ui is enabled, the retry generation button and ability to click those buttons with the last output disappears usually. It would be nice if those interaction buttons still appeared even when dynamic ui elements appeared (this is outside of the full "Start Interactive UI" feature but simple the "Dynamic UI" option in settings).

@Mohammed-Lahboub

Copy link
Copy Markdown

Great feedback!

I agree — keeping retry and interaction buttons visible even with Dynamic UI enabled would improve the user experience a lot.

It would be ideal to combine both: dynamic interfaces and persistent interaction controls.

@timerloggedout-spec

Copy link
Copy Markdown

This exact thing has 2 projects sitting in Kai right now; where I have to figure out how to export the contents of the interactions, as the prompt fails to be scrollable from the response. They have been sitting waiting for ~ a week+ for me to take the time to figure it out.

It provided buttons, drop down descriptions, and tabs for phases.

The response from whatever the default model (What is it btw?) is had a great suggestion (really what I'm after as an 'finished' utility); yet, needed to be nearly a different project after the current intent; for future incorporation with a more matured deployment environment.

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.

5 participants