@@ -84,6 +84,7 @@ type websocketConnection struct {
8484}
8585
8686const recentActiveChatRetention = 5 * time .Second
87+ const maxHistoryListLimit = 200
8788
8889func NewWebSocketServer (cfg * config.Config , sm * session.Manager ) http.Handler {
8990 server := & websocket.Server {
@@ -486,23 +487,35 @@ func (c *websocketConnection) handleFsListDirs(req websocketRequest) {
486487
487488func (c * websocketConnection ) handleHistoryList (req websocketRequest ) {
488489 type payload struct {
489- Limit int `json:"limit "`
490- Offset int `json:"offset "`
490+ Page int `json:"page "`
491+ PageSize int `json:"page_size "`
491492 }
492493
493494 var body payload
494495 if err := decodeWebSocketPayload (req .Payload , & body ); err != nil {
495496 _ = c .writeError (req .ID , "invalid history.list payload" )
496497 return
497498 }
499+ page := body .Page
500+ if page <= 0 {
501+ _ = c .writeError (req .ID , "history.list page must be greater than 0" )
502+ return
503+ }
504+ pageSize := body .PageSize
505+ if pageSize <= 0 {
506+ _ = c .writeError (req .ID , "history.list page_size must be greater than 0" )
507+ return
508+ } else if pageSize > maxHistoryListLimit {
509+ pageSize = maxHistoryListLimit
510+ }
498511
499512 response , err := c .awaitAgentResponse (req .ID , & gatewayv1.GatewayEnvelope {
500513 RequestId : req .ID ,
501514 Timestamp : time .Now ().Unix (),
502515 Payload : & gatewayv1.GatewayEnvelope_HistoryList {
503516 HistoryList : & gatewayv1.HistoryListRequest {
504- Limit : int32 (body . Limit ),
505- Offset : int32 (body . Offset ),
517+ Page : int32 (page ),
518+ PageSize : int32 (pageSize ),
506519 },
507520 },
508521 })
@@ -528,7 +541,7 @@ func (c *websocketConnection) handleHistoryList(req websocketRequest) {
528541
529542 _ = c .writeResponse (req .ID , map [string ]any {
530543 "conversations" : conversations ,
531- "total " : resp .GetTotal (),
544+ "total_count " : resp .GetTotalCount (),
532545 "running_conversation_ids" : c .sm .ActiveChatRunConversationIDs (),
533546 })
534547}
0 commit comments