263748af4a
Add canva/canda-compatible routes for lightweight project open/save and agent thread history: - POST /canva/project/queryProject, saveProject - POST /canva/agent/queryAgentLastThread, agentThreadList - GET /canda/chat-history, /canda/thread/status Canvas save now accepts a compressed SHAKKERDATA:// snapshot payload, preserves connections, and returns a SaveProject response; blank successful image nodes are backfilled from generated artifacts. Frontend designGateway adopts the new save/query flow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.10.1
|
|
|
|
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"img_infinite_canvas/internal/svc"
|
|
"img_infinite_canvas/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type CandaChatHistoryLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCandaChatHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CandaChatHistoryLogic {
|
|
return &CandaChatHistoryLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *CandaChatHistoryLogic) CandaChatHistory(req *types.CandaChatHistoryRequest) (resp *types.CandaChatHistoryResponse, err error) {
|
|
replay, err := l.svcCtx.DesignService.ReplayHistory(l.ctx, req.ProjectId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
items := make([]types.CandaChatHistoryItem, 0, len(replay.Messages))
|
|
for _, message := range replay.Messages {
|
|
threadID := message.ThreadID
|
|
if threadID == "" {
|
|
threadID = req.ThreadId
|
|
}
|
|
if req.ThreadId != "" && threadID != req.ThreadId {
|
|
continue
|
|
}
|
|
items = append(items, toCandaChatHistoryItem(message, req.ProjectId, threadID))
|
|
}
|
|
|
|
return &types.CandaChatHistoryResponse{
|
|
Code: 0,
|
|
Message: "Successfully got history view for " + req.ThreadId,
|
|
Data: items,
|
|
}, nil
|
|
}
|