Repository navigation
feat: branch a conversation from any message - #1624
Conversation
Adds a "Branch from here" action on chat messages that forks the conversation on the local agent-server. On a user message it acts as "edit message": the fork excludes the message (branching at its parent, fetched from the single-event endpoint because the events search API omits parent_id) and its text is restored into the composer to edit. The fork is given a distinct "<source> (branch)" title so it reads apart from its source.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Addresses review findings on the branch-from-message feature: (1) an image-only user message parses to empty text — branch it inclusively instead of excluding it into an empty composer (was dropping the image); (2) only use the current conversation's title for the "(branch)" marker when its id matches (the shared singleton can hold a previously-viewed conversation); (3) add an in-flight ref guard so a rapid double-click can't fire two forks before isPending flips.
Self-review: bug huntRan an independent review of the implementation. Fixed the contained issues in
Known follow-ups (not in this PR — they touch shared mechanisms and deserve a focused change)
|
Two review follow-ups on the branch-from-message feature. (M4) The fork's HEAD (leaf_event_id) confirms the backend honored from_event_id; on older agent-servers (<1.31.0) that ignore it and copy the whole conversation, we now report the message as NOT excluded so we don't prefill and duplicate it. (H1) messageToSend (the composer prefill store value) is now cleared once the composer applies it, via a new onValueApplied one-shot signal on useAutoResize, so an abandoned branch prefill can't replay into a different conversation's composer and clobber its draft. useLaunchSkillInChat uses the same apply path and is unaffected (it needs a single application).
Update: the two follow-ups are now fixed in this PRBoth landed after verifying the approaches (commit
All 3 branch commits are green on the local pre-commit hook (eslint, staged typecheck, translation completeness) and the branch tests ( |
…igate useNavigate() throws when a message is rendered outside a Router (broke duplicate-streamed-message.test.tsx, which renders <Messages> bare). The repo's useNavigation() context is Router-independent and provided by renderWithProviders — matching useLaunchSkillInChat.
enyst
left a comment
There was a problem hiding this comment.
Thank you! Love this! It’s going to help people to have more flexibility when it matters, for as long as it still matters to reuse some context for another task ❤️
✅ Mock-LLM E2E Tests60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
✅ Mock-LLM Docker E2E Test Results60/60 passed Commit: Details
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
|
🚀 Released in v1.2.0. |
HUMAN:
As the title say: branch a conversation from any message
AGENT:
Verified end-to-end against the real local stack (frontend + local agent-server
1.32.0), not just unit tests — evidence in How to Test and Video/Screenshots below.Why
There was no way to branch a conversation to explore an alternative path, or to revise an earlier prompt, without losing the original thread. This adds a per-message Branch from here action so you can fork a conversation locally — and, on your own messages, edit-and-resend from that point in a fresh, independent conversation.
Summary
POST /api/conversations/{id}/fork.GET /events/{id}) because the events search API omitsparent_id, and the client event store holds un-persisted streaming events that the backend rejects as fork points."<source> (branch)"title so it doesn't read identically to its source in the sidebar.Issue Number
N/A
How to Test
npm installnpm run dev(serves http://localhost:8000).… (branch)conversation that does not contain that message; its text is in the composer, editable. Edit and send → the thread continues from that point.Video/Screenshots
Screen.Recording.2026-07-08.at.16.29.38.mov
Type
Notes
from_event_idon/fork).from_event_idis sent via a typed cast becauseForkConversationRequestin@openhands/typescript-client(through 1.32.0) doesn't yet include the field — adding it upstream would let us drop the cast.__tests__/components/features/chat/user-assistant-event-message.test.tsxmocks the service and drives the real hook (per the repo test convention).🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.33.0-pythonopenhands-automation==1.1.42b8585cfc0866b52a54bb66f8d350973737a4beePull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-2b8585cRun
All tags pushed for this build
About Multi-Architecture Support
sha-2b8585c) is a multi-arch manifest supporting both amd64 and arm64sha-2b8585c-amd64) are also available if needed