mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: show shared chats in agents sidebar (#26056)
This commit is contained in:
@@ -1763,6 +1763,7 @@ func Chat(c database.Chat, diffStatus *database.ChatDiffStatus, files []database
|
||||
Title: c.Title,
|
||||
Status: codersdk.ChatStatus(c.Status),
|
||||
Archived: c.Archived,
|
||||
Shared: len(c.UserACL) > 0 || len(c.GroupACL) > 0,
|
||||
PinOrder: c.PinOrder,
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
|
||||
@@ -947,6 +947,7 @@ func TestChat_AllFieldsPopulated(t *testing.T) {
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
Archived: true,
|
||||
UserACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
|
||||
PinOrder: 1,
|
||||
PlanMode: database.NullChatPlanMode{ChatPlanMode: database.ChatPlanModePlan, Valid: true},
|
||||
MCPServerIDs: []uuid.UUID{uuid.New()},
|
||||
@@ -1005,6 +1006,58 @@ func TestChat_AllFieldsPopulated(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestChat_Shared(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
userACL database.ChatACL
|
||||
groupACL database.ChatACL
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "not shared",
|
||||
},
|
||||
{
|
||||
name: "user ACL",
|
||||
userACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "group ACL",
|
||||
groupACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "user and group ACLs",
|
||||
userACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
|
||||
groupACL: database.ChatACL{uuid.NewString(): database.ChatACLEntry{}},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
chat := database.Chat{
|
||||
ID: uuid.New(),
|
||||
OwnerID: uuid.New(),
|
||||
LastModelConfigID: uuid.New(),
|
||||
Title: tc.name,
|
||||
Status: database.ChatStatusWaiting,
|
||||
CreatedAt: dbtime.Now(),
|
||||
UpdatedAt: dbtime.Now(),
|
||||
UserACL: tc.userACL,
|
||||
GroupACL: tc.groupACL,
|
||||
}
|
||||
|
||||
got := db2sdk.Chat(chat, nil, nil)
|
||||
require.Equal(t, tc.expected, got.Shared)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChat_FileMetadataConversion(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user