feat(web): add history fork for conversations#281
Open
zhengdaqi wants to merge 1 commit into
Open
Conversation
Let users branch a conversation from any prior user message into a new session that carries the history up to the fork point and pre-fills the forked prompt into the composer for editing and re-sending. - gateway: new fork_session RPC wired through protocol types, in-process and remote gateway clients, ws dispatch, and local gateway impl - server: forkSession truncates the source transcript at the fork turn, writes a new session jsonl with fork lineage metadata, copies aux dirs, and returns the prefill text + carried message count - session: persist parentSessionId/forkedFromTurnId so the sidebar can render the fork lineage tree - ui: hover Fork button on user messages, auto-navigate to the new session, prefill + focus the composer, scroll to bottom, distinctive fork titles, and a friendly empty state for branches with no carried history - tests: forkSession unit test + history-fork e2e spec Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fork_sessionRPC(protocol 类型 / InProcess + Remote 客户端 / ws dispatch / 本地网关实现)。forkSession在分叉 turn 处截断源 transcript,写入带分叉谱系 metadata 的新会话 jsonl,复制tool-results/file-history辅助目录,并返回预填文本与携带消息数。parentSessionId/forkedFromTurnId,侧栏据此渲染分叉谱系树。⑂ <分叉点消息>命名增强区分度;对无携带历史的分支提供友好空态。Changes
protocol/types.ts,protocol/frames.ts,client/InProcessGateway.ts,client/RemoteGateway.ts,server/GatewayWsConnection.ts,cli/createLocalGateway.ts,cli/pilotdeck.tsweb/server/forkSession.ts(新增),web/server/readSessionMessages.ts,web/client/protocol.ts,web/client/webMessage.tssession/transcript/TranscriptEntry.ts,session/storage/SessionList.tsui/server/routes/messages.js(POST /api/sessions/:id/fork),ui/server/projects.jsChatInterfaceV2.tsx,MessageRowV2.tsx,MessagesPaneV2.tsx,SidebarV2.tsx,useChatMessages.ts,types.ts,useSessionStore.ts,api.jstests/web/forkSession.test.ts,ui/e2e/history-fork.spec.mjsTest plan
tests/web/forkSession.test.ts通过newSessionId、prefillText、carriedMessageCount;新 transcript 携带完整历史、谱系 metadata 正确、标题为⑂ <消息>⑂的分叉条目、无 "Fork did not return a new session id" 报错Made with Cursor