mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add chat debug retention purge (#24943)
> Mux is acting on Mike's behalf. Adds configurable retention for chat debug data, including the purge query, updated_at index, site config, experimental API, SDK types, frontend lifecycle setting, and docs. The purge deletes debug runs older than the configured retention window and relies on existing cascades to delete steps. The default retention is 30 days, and setting the value to 0 disables the purge.
This commit is contained in:
@@ -945,6 +945,11 @@ const DefaultChatWorkspaceTTL = 0
|
||||
// auto-archival.
|
||||
const DefaultChatAutoArchiveDays int32 = 0
|
||||
|
||||
// DefaultChatDebugRetentionDays is the default chat debug run retention
|
||||
// window, in days, applied when no site config row exists. Set the
|
||||
// config value to zero to disable the purge.
|
||||
const DefaultChatDebugRetentionDays int32 = 30
|
||||
|
||||
// ChatWorkspaceTTLResponse is the response for getting the chat
|
||||
// workspace TTL setting.
|
||||
type ChatWorkspaceTTLResponse struct {
|
||||
@@ -972,6 +977,18 @@ type UpdateChatRetentionDaysRequest struct {
|
||||
RetentionDays int32 `json:"retention_days"`
|
||||
}
|
||||
|
||||
// ChatDebugRetentionDaysResponse contains the current chat debug run
|
||||
// retention setting.
|
||||
type ChatDebugRetentionDaysResponse struct {
|
||||
DebugRetentionDays int32 `json:"debug_retention_days"`
|
||||
}
|
||||
|
||||
// UpdateChatDebugRetentionDaysRequest is a request to update the chat
|
||||
// debug run retention period.
|
||||
type UpdateChatDebugRetentionDaysRequest struct {
|
||||
DebugRetentionDays int32 `json:"debug_retention_days"`
|
||||
}
|
||||
|
||||
// ChatAutoArchiveDaysResponse contains the current chat auto-archive setting.
|
||||
type ChatAutoArchiveDaysResponse struct {
|
||||
AutoArchiveDays int32 `json:"auto_archive_days"`
|
||||
@@ -2462,6 +2479,34 @@ func (c *ExperimentalClient) UpdateChatRetentionDays(ctx context.Context, req Up
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetChatDebugRetentionDays returns the configured chat debug run
|
||||
// retention period.
|
||||
func (c *ExperimentalClient) GetChatDebugRetentionDays(ctx context.Context) (ChatDebugRetentionDaysResponse, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/experimental/chats/config/debug-retention-days", nil)
|
||||
if err != nil {
|
||||
return ChatDebugRetentionDaysResponse{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return ChatDebugRetentionDaysResponse{}, ReadBodyAsError(res)
|
||||
}
|
||||
var resp ChatDebugRetentionDaysResponse
|
||||
return resp, json.NewDecoder(res.Body).Decode(&resp)
|
||||
}
|
||||
|
||||
// UpdateChatDebugRetentionDays updates the chat debug run retention period.
|
||||
func (c *ExperimentalClient) UpdateChatDebugRetentionDays(ctx context.Context, req UpdateChatDebugRetentionDaysRequest) error {
|
||||
res, err := c.Request(ctx, http.MethodPut, "/api/experimental/chats/config/debug-retention-days", req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
return ReadBodyAsError(res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetChatAutoArchiveDays returns the configured chat auto-archive period.
|
||||
func (c *ExperimentalClient) GetChatAutoArchiveDays(ctx context.Context) (ChatAutoArchiveDaysResponse, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/experimental/chats/config/auto-archive-days", nil)
|
||||
|
||||
Reference in New Issue
Block a user