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:
+52
-27
@@ -106,30 +106,32 @@ const (
|
||||
|
||||
// Chat represents a chat session with an AI agent.
|
||||
type Chat struct {
|
||||
ID uuid.UUID `json:"id" format:"uuid"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
|
||||
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
|
||||
OwnerUsername string `json:"owner_username,omitempty"`
|
||||
OwnerName string `json:"owner_name,omitempty"`
|
||||
WorkspaceID *uuid.UUID `json:"workspace_id,omitempty" format:"uuid"`
|
||||
BuildID *uuid.UUID `json:"build_id,omitempty" format:"uuid"`
|
||||
AgentID *uuid.UUID `json:"agent_id,omitempty" format:"uuid"`
|
||||
ParentChatID *uuid.UUID `json:"parent_chat_id,omitempty" format:"uuid"`
|
||||
RootChatID *uuid.UUID `json:"root_chat_id,omitempty" format:"uuid"`
|
||||
LastModelConfigID uuid.UUID `json:"last_model_config_id" format:"uuid"`
|
||||
Title string `json:"title"`
|
||||
Status ChatStatus `json:"status"`
|
||||
PlanMode ChatPlanMode `json:"plan_mode,omitempty"`
|
||||
LastError *ChatError `json:"last_error,omitempty"`
|
||||
LastTurnSummary *string `json:"last_turn_summary"`
|
||||
DiffStatus *ChatDiffStatus `json:"diff_status,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at" format:"date-time"`
|
||||
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
|
||||
Archived bool `json:"archived"`
|
||||
PinOrder int32 `json:"pin_order"`
|
||||
MCPServerIDs []uuid.UUID `json:"mcp_server_ids" format:"uuid"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Files []ChatFileMetadata `json:"files,omitempty"`
|
||||
ID uuid.UUID `json:"id" format:"uuid"`
|
||||
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
|
||||
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
|
||||
OwnerUsername string `json:"owner_username,omitempty"`
|
||||
OwnerName string `json:"owner_name,omitempty"`
|
||||
WorkspaceID *uuid.UUID `json:"workspace_id,omitempty" format:"uuid"`
|
||||
BuildID *uuid.UUID `json:"build_id,omitempty" format:"uuid"`
|
||||
AgentID *uuid.UUID `json:"agent_id,omitempty" format:"uuid"`
|
||||
ParentChatID *uuid.UUID `json:"parent_chat_id,omitempty" format:"uuid"`
|
||||
RootChatID *uuid.UUID `json:"root_chat_id,omitempty" format:"uuid"`
|
||||
LastModelConfigID uuid.UUID `json:"last_model_config_id" format:"uuid"`
|
||||
Title string `json:"title"`
|
||||
Status ChatStatus `json:"status"`
|
||||
PlanMode ChatPlanMode `json:"plan_mode,omitempty"`
|
||||
LastError *ChatError `json:"last_error,omitempty"`
|
||||
LastTurnSummary *string `json:"last_turn_summary"`
|
||||
DiffStatus *ChatDiffStatus `json:"diff_status,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at" format:"date-time"`
|
||||
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
|
||||
Archived bool `json:"archived"`
|
||||
// Shared is true when this chat's root chat has explicit user or group ACL entries.
|
||||
Shared bool `json:"shared"`
|
||||
PinOrder int32 `json:"pin_order"`
|
||||
MCPServerIDs []uuid.UUID `json:"mcp_server_ids" format:"uuid"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Files []ChatFileMetadata `json:"files,omitempty"`
|
||||
// HasUnread is true when assistant messages exist beyond
|
||||
// the owner's read cursor, which updates on stream
|
||||
// connect and disconnect.
|
||||
@@ -2037,9 +2039,25 @@ type UpdateChatACL struct {
|
||||
GroupRoles map[string]ChatRole `json:"group_roles,omitempty"`
|
||||
}
|
||||
|
||||
// ChatListSource controls which chats ListChats returns by ownership.
|
||||
type ChatListSource string
|
||||
|
||||
const (
|
||||
// ChatListSourceCreatedByMe returns chats owned by the caller.
|
||||
ChatListSourceCreatedByMe ChatListSource = "created_by_me"
|
||||
// ChatListSourceSharedWithMe returns chats shared with the caller.
|
||||
ChatListSourceSharedWithMe ChatListSource = "shared_with_me"
|
||||
// ChatListSourceAll returns both owned and shared chats.
|
||||
ChatListSourceAll ChatListSource = "all"
|
||||
)
|
||||
|
||||
// ListChatsOptions are optional parameters for ListChats.
|
||||
type ListChatsOptions struct {
|
||||
Query string
|
||||
// Query supports raw chat search terms. If Query includes a source: term,
|
||||
// Source must be empty.
|
||||
Query string
|
||||
// Source adds a source: term to Query.
|
||||
Source ChatListSource
|
||||
Labels map[string]string
|
||||
Pagination
|
||||
}
|
||||
@@ -2049,10 +2067,17 @@ func (c *ExperimentalClient) ListChats(ctx context.Context, opts *ListChatsOptio
|
||||
var reqOpts []RequestOption
|
||||
if opts != nil {
|
||||
reqOpts = append(reqOpts, opts.Pagination.asRequestOption())
|
||||
if opts.Query != "" {
|
||||
query := opts.Query
|
||||
if opts.Source != "" {
|
||||
if query != "" {
|
||||
query += " "
|
||||
}
|
||||
query += "source:" + string(opts.Source)
|
||||
}
|
||||
if query != "" {
|
||||
reqOpts = append(reqOpts, func(r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
q.Set("q", opts.Query)
|
||||
q.Set("q", query)
|
||||
r.URL.RawQuery = q.Encode()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user