chore(codersdk): deprecate WorkspaceAppStatus.{NeedsUserAttention,Icon} (#17358)

https://github.com/coder/coder/pull/17163 introduced the
`workspace_app_statuses` table. Two of these fields
(`needs_user_attention`, `icon`) turned out to be surplus to
requirements.

- Removes columns `needs_user_attention` and `icon` from
`workspace_app_statuses`
- Marks the corresponding fields of `codersdk.WorkspaceAppStatus` as
deprecated.
This commit is contained in:
Cian Johnston
2025-04-15 10:47:42 +01:00
committed by GitHub
parent 95f03c561f
commit 979687c37f
21 changed files with 119 additions and 129 deletions
+4 -1
View File
@@ -10242,12 +10242,14 @@ const docTemplate = `{
"type": "string"
},
"icon": {
"description": "Deprecated: this field is unused and will be removed in a future version.",
"type": "string"
},
"message": {
"type": "string"
},
"needs_user_attention": {
"description": "Deprecated: this field is unused and will be removed in a future version.",
"type": "boolean"
},
"state": {
@@ -16925,7 +16927,7 @@ const docTemplate = `{
"format": "date-time"
},
"icon": {
"description": "Icon is an external URL to an icon that will be rendered in the UI.",
"description": "Deprecated: This field is unused and will be removed in a future version.\nIcon is an external URL to an icon that will be rendered in the UI.",
"type": "string"
},
"id": {
@@ -16936,6 +16938,7 @@ const docTemplate = `{
"type": "string"
},
"needs_user_attention": {
"description": "Deprecated: This field is unused and will be removed in a future version.\nNeedsUserAttention specifies whether the status needs user attention.",
"type": "boolean"
},
"state": {
+4 -1
View File
@@ -9079,12 +9079,14 @@
"type": "string"
},
"icon": {
"description": "Deprecated: this field is unused and will be removed in a future version.",
"type": "string"
},
"message": {
"type": "string"
},
"needs_user_attention": {
"description": "Deprecated: this field is unused and will be removed in a future version.",
"type": "boolean"
},
"state": {
@@ -15444,7 +15446,7 @@
"format": "date-time"
},
"icon": {
"description": "Icon is an external URL to an icon that will be rendered in the UI.",
"description": "Deprecated: This field is unused and will be removed in a future version.\nIcon is an external URL to an icon that will be rendered in the UI.",
"type": "string"
},
"id": {
@@ -15455,6 +15457,7 @@
"type": "string"
},
"needs_user_attention": {
"description": "Deprecated: This field is unused and will be removed in a future version.\nNeedsUserAttention specifies whether the status needs user attention.",
"type": "boolean"
},
"state": {
+8 -10
View File
@@ -537,16 +537,14 @@ func WorkspaceAppStatuses(statuses []database.WorkspaceAppStatus) []codersdk.Wor
func WorkspaceAppStatus(status database.WorkspaceAppStatus) codersdk.WorkspaceAppStatus {
return codersdk.WorkspaceAppStatus{
ID: status.ID,
CreatedAt: status.CreatedAt,
WorkspaceID: status.WorkspaceID,
AgentID: status.AgentID,
AppID: status.AppID,
NeedsUserAttention: status.NeedsUserAttention,
URI: status.Uri.String,
Icon: status.Icon.String,
Message: status.Message,
State: codersdk.WorkspaceAppStatusState(status.State),
ID: status.ID,
CreatedAt: status.CreatedAt,
WorkspaceID: status.WorkspaceID,
AgentID: status.AgentID,
AppID: status.AppID,
URI: status.Uri.String,
Message: status.Message,
State: codersdk.WorkspaceAppStatusState(status.State),
}
}
+8 -10
View File
@@ -9764,16 +9764,14 @@ func (q *FakeQuerier) InsertWorkspaceAppStatus(_ context.Context, arg database.I
defer q.mutex.Unlock()
status := database.WorkspaceAppStatus{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
WorkspaceID: arg.WorkspaceID,
AgentID: arg.AgentID,
AppID: arg.AppID,
NeedsUserAttention: arg.NeedsUserAttention,
State: arg.State,
Message: arg.Message,
Uri: arg.Uri,
Icon: arg.Icon,
ID: arg.ID,
CreatedAt: arg.CreatedAt,
WorkspaceID: arg.WorkspaceID,
AgentID: arg.AgentID,
AppID: arg.AppID,
State: arg.State,
Message: arg.Message,
Uri: arg.Uri,
}
q.workspaceAppStatuses = append(q.workspaceAppStatuses, status)
return status, nil
+1 -3
View File
@@ -1911,10 +1911,8 @@ CREATE TABLE workspace_app_statuses (
app_id uuid NOT NULL,
workspace_id uuid NOT NULL,
state workspace_app_status_state NOT NULL,
needs_user_attention boolean NOT NULL,
message text NOT NULL,
uri text,
icon text
uri text
);
CREATE TABLE workspace_apps (
@@ -0,0 +1,3 @@
ALTER TABLE ONLY workspace_app_statuses
ADD COLUMN IF NOT EXISTS needs_user_attention BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS icon TEXT;
@@ -0,0 +1,3 @@
ALTER TABLE ONLY workspace_app_statuses
DROP COLUMN IF EXISTS needs_user_attention,
DROP COLUMN IF EXISTS icon;
+8 -10
View File
@@ -3579,16 +3579,14 @@ type WorkspaceAppStat struct {
}
type WorkspaceAppStatus struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
AgentID uuid.UUID `db:"agent_id" json:"agent_id"`
AppID uuid.UUID `db:"app_id" json:"app_id"`
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
State WorkspaceAppStatusState `db:"state" json:"state"`
NeedsUserAttention bool `db:"needs_user_attention" json:"needs_user_attention"`
Message string `db:"message" json:"message"`
Uri sql.NullString `db:"uri" json:"uri"`
Icon sql.NullString `db:"icon" json:"icon"`
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
AgentID uuid.UUID `db:"agent_id" json:"agent_id"`
AppID uuid.UUID `db:"app_id" json:"app_id"`
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
State WorkspaceAppStatusState `db:"state" json:"state"`
Message string `db:"message" json:"message"`
Uri sql.NullString `db:"uri" json:"uri"`
}
// Joins in the username + avatar url of the initiated by user.
+14 -24
View File
@@ -15598,8 +15598,8 @@ func (q *sqlQuerier) UpsertWorkspaceAppAuditSession(ctx context.Context, arg Ups
const getLatestWorkspaceAppStatusesByWorkspaceIDs = `-- name: GetLatestWorkspaceAppStatusesByWorkspaceIDs :many
SELECT DISTINCT ON (workspace_id)
id, created_at, agent_id, app_id, workspace_id, state, needs_user_attention, message, uri, icon
FROM workspace_app_statuses
id, created_at, agent_id, app_id, workspace_id, state, message, uri
FROM workspace_app_statuses
WHERE workspace_id = ANY($1 :: uuid[])
ORDER BY workspace_id, created_at DESC
`
@@ -15620,10 +15620,8 @@ func (q *sqlQuerier) GetLatestWorkspaceAppStatusesByWorkspaceIDs(ctx context.Con
&i.AppID,
&i.WorkspaceID,
&i.State,
&i.NeedsUserAttention,
&i.Message,
&i.Uri,
&i.Icon,
); err != nil {
return nil, err
}
@@ -15674,7 +15672,7 @@ func (q *sqlQuerier) GetWorkspaceAppByAgentIDAndSlug(ctx context.Context, arg Ge
}
const getWorkspaceAppStatusesByAppIDs = `-- name: GetWorkspaceAppStatusesByAppIDs :many
SELECT id, created_at, agent_id, app_id, workspace_id, state, needs_user_attention, message, uri, icon FROM workspace_app_statuses WHERE app_id = ANY($1 :: uuid [ ])
SELECT id, created_at, agent_id, app_id, workspace_id, state, message, uri FROM workspace_app_statuses WHERE app_id = ANY($1 :: uuid [ ])
`
func (q *sqlQuerier) GetWorkspaceAppStatusesByAppIDs(ctx context.Context, ids []uuid.UUID) ([]WorkspaceAppStatus, error) {
@@ -15693,10 +15691,8 @@ func (q *sqlQuerier) GetWorkspaceAppStatusesByAppIDs(ctx context.Context, ids []
&i.AppID,
&i.WorkspaceID,
&i.State,
&i.NeedsUserAttention,
&i.Message,
&i.Uri,
&i.Icon,
); err != nil {
return nil, err
}
@@ -15942,22 +15938,20 @@ func (q *sqlQuerier) InsertWorkspaceApp(ctx context.Context, arg InsertWorkspace
}
const insertWorkspaceAppStatus = `-- name: InsertWorkspaceAppStatus :one
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, needs_user_attention, uri, icon)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
RETURNING id, created_at, agent_id, app_id, workspace_id, state, needs_user_attention, message, uri, icon
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, uri)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, created_at, agent_id, app_id, workspace_id, state, message, uri
`
type InsertWorkspaceAppStatusParams struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
AgentID uuid.UUID `db:"agent_id" json:"agent_id"`
AppID uuid.UUID `db:"app_id" json:"app_id"`
State WorkspaceAppStatusState `db:"state" json:"state"`
Message string `db:"message" json:"message"`
NeedsUserAttention bool `db:"needs_user_attention" json:"needs_user_attention"`
Uri sql.NullString `db:"uri" json:"uri"`
Icon sql.NullString `db:"icon" json:"icon"`
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
AgentID uuid.UUID `db:"agent_id" json:"agent_id"`
AppID uuid.UUID `db:"app_id" json:"app_id"`
State WorkspaceAppStatusState `db:"state" json:"state"`
Message string `db:"message" json:"message"`
Uri sql.NullString `db:"uri" json:"uri"`
}
func (q *sqlQuerier) InsertWorkspaceAppStatus(ctx context.Context, arg InsertWorkspaceAppStatusParams) (WorkspaceAppStatus, error) {
@@ -15969,9 +15963,7 @@ func (q *sqlQuerier) InsertWorkspaceAppStatus(ctx context.Context, arg InsertWor
arg.AppID,
arg.State,
arg.Message,
arg.NeedsUserAttention,
arg.Uri,
arg.Icon,
)
var i WorkspaceAppStatus
err := row.Scan(
@@ -15981,10 +15973,8 @@ func (q *sqlQuerier) InsertWorkspaceAppStatus(ctx context.Context, arg InsertWor
&i.AppID,
&i.WorkspaceID,
&i.State,
&i.NeedsUserAttention,
&i.Message,
&i.Uri,
&i.Icon,
)
return i, err
}
+3 -3
View File
@@ -44,8 +44,8 @@ WHERE
id = $1;
-- name: InsertWorkspaceAppStatus :one
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, needs_user_attention, uri, icon)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, uri)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING *;
-- name: GetWorkspaceAppStatusesByAppIDs :many
@@ -54,6 +54,6 @@ SELECT * FROM workspace_app_statuses WHERE app_id = ANY(@ids :: uuid [ ]);
-- name: GetLatestWorkspaceAppStatusesByWorkspaceIDs :many
SELECT DISTINCT ON (workspace_id)
*
FROM workspace_app_statuses
FROM workspace_app_statuses
WHERE workspace_id = ANY(@ids :: uuid[])
ORDER BY workspace_id, created_at DESC;
-5
View File
@@ -366,11 +366,6 @@ func (api *API) patchWorkspaceAgentAppStatus(rw http.ResponseWriter, r *http.Req
String: req.URI,
Valid: req.URI != "",
},
Icon: sql.NullString{
String: req.Icon,
Valid: req.Icon != "",
},
NeedsUserAttention: req.NeedsUserAttention,
})
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
+6 -1
View File
@@ -366,8 +366,10 @@ func TestWorkspaceAgentAppStatus(t *testing.T) {
AppSlug: "vscode",
Message: "testing",
URI: "https://example.com",
Icon: "https://example.com/icon.png",
State: codersdk.WorkspaceAppStatusStateComplete,
// Ensure deprecated fields are ignored.
Icon: "https://example.com/icon.png",
NeedsUserAttention: true,
})
require.NoError(t, err)
@@ -376,6 +378,9 @@ func TestWorkspaceAgentAppStatus(t *testing.T) {
agent, err := client.WorkspaceAgent(ctx, workspace.LatestBuild.Resources[0].Agents[0].ID)
require.NoError(t, err)
require.Len(t, agent.Apps[0].Statuses, 1)
// Deprecated fields should be ignored.
require.Empty(t, agent.Apps[0].Statuses[0].Icon)
require.False(t, agent.Apps[0].Statuses[0].NeedsUserAttention)
})
}