Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/gorilla/websocket v1.4.2
github.com/jinzhu/copier v0.4.0
github.com/pkg/errors v0.9.1
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.33.0 // indirect
gorm.io/driver/sqlite v1.5.5
nhooyr.io/websocket v1.8.10
)
Expand All @@ -21,7 +21,6 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
golang.org/x/image v0.15.0
golang.org/x/sync v0.6.0
google.golang.org/grpc v1.62.1
gorm.io/gorm v1.25.10
)

Expand Down Expand Up @@ -57,5 +56,8 @@ require (
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.62.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace nhooyr.io/websocket => github.com/coder/websocket v1.8.10
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZX
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/coder/websocket v1.8.10 h1:K+NrQte1lq04N7V/E3avmuuuCGEaInbjTWukHZsN17g=
github.com/coder/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -132,6 +134,4 @@ gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
9 changes: 6 additions & 3 deletions internal/conversation_msg/message_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ func (c *Conversation) checkEndBlock(ctx context.Context, conversationID string,
// Perform an end-of-block check if the retrieved message count is less than requested
if len(*list) < count {
if isReverse {
currentMaxSeq := c.maxSeqRecorder.Get(conversationID)
maxSeq, _, _ := c.getMaxAndMinHaveSeqList(*list)
log.ZDebug(ctx, "validateAndFillEndBlockContinuity", "maxSeq", maxSeq, "conversationID", conversationID)
if maxSeq == c.maxSeqRecorder.Get(conversationID) { // todo Replace `1` with the minimum sequence value as defined by the user or system
log.ZDebug(ctx, "validateAndFillEndBlockContinuity", "maxSeq", maxSeq, "conversationID", conversationID, "currentMaxSeq", currentMaxSeq)
// Use >= to prevent the currentMaxSeq from being updated too slowly,
// which could lead to misjudgments and cause repeated message fetching."
if maxSeq >= currentMaxSeq { // todo Replace `1` with the minimum sequence value as defined by the user or system
messageListCallback.IsEnd = true
} else {
lastEndSeq, _ := c.messagePullReverseEndSeqMap.Load(conversationID)
log.ZDebug(ctx, "validateAndFillEndBlockContinuity", "lastEndSeq", lastEndSeq, "conversationID", conversationID)
// If `maxSeq` is zero and `lastEndSeq` is at the maximum server sequence, this batch is fully local
if maxSeq == 0 && lastEndSeq == c.maxSeqRecorder.Get(conversationID) { // All messages in this batch are local messages,
if maxSeq == 0 && lastEndSeq >= currentMaxSeq { // All messages in this batch are local messages,
// and the maximum seq of the last batch of valid messages has already reached the maximum pullable seq from the server.
messageListCallback.IsEnd = true
} else {
Expand Down