feat: implement Fork thread branching, Archive, Branch, Resend, and English menu labels#270
Open
Copilot wants to merge 3 commits into
Open
feat: implement Fork thread branching, Archive, Branch, Resend, and English menu labels#270Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Copilot created this pull request from a session on behalf of
crazygo
June 3, 2026 06:45
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the assistant message “⋯” action menu in ChatScreen by wiring the previously-missing callbacks into MessageList, ensuring the menu can open and handle user taps (currently via placeholder snackbars).
Changes:
- Add
_handleArchiveRound,_handleArchiveReply, and_handleMoveToThreadhandlers inChatScreen. - Pass the new handlers to
MessageListso_showAssistantMessageActionMenuno longer early-returns due to all-null callbacks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } | ||
|
|
||
| void _handleArchiveRound(ChatMessage message) { |
| .showSnackBar(const SnackBar(content: Text('Coming soon'))); | ||
| } | ||
|
|
||
| void _handleArchiveReply(ChatMessage message) { |
| .showSnackBar(const SnackBar(content: Text('Coming soon'))); | ||
| } | ||
|
|
||
| void _handleMoveToThread(ChatMessage message) { |
- Add migration 023: chat_thread_forks table for DB-level branching - Backend: forkThread() service, listSessionMessagesForModel fork context assembly - Backend: POST /fork endpoint - Flutter: ChatForkResult + forkThread() API client method - Flutter: MessageList - rename onMoveToThread→onFork, add onBranch/onResend, translate all labels to English - Flutter: chat_screen.dart - implement _handleArchiveRound, _handleArchiveReply, _handleFork, _handleBranch, _handleResend - Flutter: clear _archivedMessageIds at all _messages.clear() call sites - Test: update message_list_test.dart for renamed onFork callback and Fork label
Copilot
AI
changed the title
fix: wire assistant message action menu in ChatScreen
feat: implement Fork thread branching, Archive, Branch, Resend, and English menu labels
Jun 3, 2026
| if (msgResult.rows.length === 0) { | ||
| throw new Error(`Fork message not found: ${forkMessageId}`); | ||
| } | ||
| const forkWriteSeq = Number(msgResult.rows[0].write_seq); |
Comment on lines
+369
to
+373
| // Check if this session is a fork; if so, prepend parent context first. | ||
| const fork = await getThreadFork(userId, sessionId); | ||
|
|
||
| // Fetch own messages (newest-first so we can apply the char budget). | ||
| const ownResult = await pool.query<ChatMessageRow>( |
Comment on lines
+1846
to
+1854
| const body = req.body ?? {}; | ||
| const parentSessionId = parseSessionId(body.parentSessionId); | ||
| const forkMessageId = parseSessionId(body.forkMessageId); | ||
| const newThreadId = parseSessionId(body.newThreadId); | ||
|
|
||
| if (!parentSessionId || !forkMessageId || !newThreadId) { | ||
| res.status(400).json({ | ||
| error: "parentSessionId, forkMessageId, and newThreadId are required", | ||
| }); |
Comment on lines
+21
to
+22
| CREATE INDEX IF NOT EXISTS idx_chat_thread_forks_forked_session | ||
| ON chat_thread_forks(user_id, forked_session_id); |
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.
Several chat context menu items were stubbed with "coming soon" and labels were in Chinese. Fork needed proper DB-level tree branching — not text copying — so that forked threads inherit parent context structurally at query time.
DB
chat_thread_forks(user_id, forked_session_id, parent_session_id, fork_message_id, fork_write_seq)— UNIQUE on(user_id, forked_session_id)Backend
forkThread(): creates a new session and inserts a fork record pinning the branch point bywrite_seqlistSessionMessagesForModel: when assembling LLM context for a forked session, walks the fork chain and prepends ancestor messages up tofork_write_seq— no content duplication, purely relationalPOST /fork: acceptssessionId,messageId,channelId; returnsforkedSessionIdFlutter
forkThread()API client +ChatForkResultinchat_history_api_service.dartMessageList:onMoveToThread→onFork; addsonBranch/onResendcallbacks; all labels translated to English;(coming soon)removedchat_screen.dart— five handlers now implemented:_handleArchiveRound— archives AI reply + its preceding user message (single-pass reverse scan)_handleArchiveReply— archives AI reply only_handleFork— callsPOST /fork, navigates to new thread with inherited context_handleBranch— same as Fork but triggered from a user message_handleResend— re-sends message text in current thread_archivedMessageIds.clear()added at all 7_messages.clear()call sites so archive state resets on scope change