Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

The UpdatedAt field on conversation branches was not being updated when messages were appended, causing GetActiveBranch() to return stale results since it selects the branch with the most recent UpdatedAt timestamp.

Changes

  • Added activeBranch.UpdatedAt = bson.NewDateTimeFromTime(time.Now()) before UpdateConversationV2() in both locations where messages are appended:
    • appendConversationMessage() - single user message append
    • CreateConversationMessageStream() - bulk message append
// Before
activeBranch.InappChatHistory = append(activeBranch.InappChatHistory, bsonMsg)
activeBranch.OpenaiChatHistoryCompletion = append(activeBranch.OpenaiChatHistoryCompletion, userOaiMsg)
if err := s.chatServiceV2.UpdateConversationV2(conversation); err != nil {
    return nil, nil, err
}

// After
activeBranch.InappChatHistory = append(activeBranch.InappChatHistory, bsonMsg)
activeBranch.OpenaiChatHistoryCompletion = append(activeBranch.OpenaiChatHistoryCompletion, userOaiMsg)
activeBranch.UpdatedAt = bson.NewDateTimeFromTime(time.Now())
if err := s.chatServiceV2.UpdateConversationV2(conversation); err != nil {
    return nil, nil, err
}

This matches the pattern already used in CreateNewBranch() which sets UpdatedAt when creating branches.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Note

Ensures branch recency is correctly tracked so GetActiveBranch() reflects the latest message activity.

  • Set activeBranch.UpdatedAt = bson.NewDateTimeFromTime(time.Now()) before UpdateConversationV2() in appendConversationMessage() and CreateConversationMessageStream()
  • Added time import to support timestamp update

Written by Cursor Bugbot for commit 9423154. This will update automatically on new commits. Configure here.

Copilot AI changed the title [WIP] Address feedback from review on gpt5.2 conversation Fix UpdatedAt timestamp not updating when appending messages to branches Jan 8, 2026
Copilot AI requested a review from Junyi-99 January 8, 2026 07:52
@Junyi-99 Junyi-99 changed the title Fix UpdatedAt timestamp not updating when appending messages to branches fix: UpdatedAt timestamp not updating when appending messages to branches Jan 9, 2026
@Junyi-99 Junyi-99 marked this pull request as ready for review January 9, 2026 09:02
@Junyi-99 Junyi-99 merged commit 98580ce into feat/gpt-5.2 Jan 9, 2026
1 of 4 checks passed
@Junyi-99 Junyi-99 deleted the copilot/sub-pr-79 branch January 9, 2026 09:02
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.

2 participants