Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5994081

Browse files
committed
feat: add unhealthy workspace filter to UI
This adds support for filtering workspaces by health status in theworkspaces page. The "Unhealthy workspaces" filter shows workspacesthat have at least one agent that is:- Never connected- Disconnected- Inactive for too longChanges:- Add "unhealthy" preset filter to workspace filter UI- Implement backend support for unhealthy:true query parameter- Add SQL filter logic to detect unhealthy workspaces based on agent status- Update API documentation to include unhealthy filterFixes#16047🤖 Generated with [Claude Code](https://claude.com/claude-code)Co-Authored-By: Claude <noreply@anthropic.com>
1 parentd63bb2c commit5994081

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

‎coderd/database/modelqueries.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
279279
arg.Shared,
280280
arg.SharedWithUserID,
281281
arg.SharedWithGroupID,
282+
arg.Unhealthy,
282283
arg.RequesterID,
283284
arg.Offset,
284285
arg.Limit,

‎coderd/database/queries.sql.go‎

Lines changed: 34 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/workspaces.sql‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,33 @@ WHERE
396396
workspaces.group_acl ? (@shared_with_group_id :: uuid) ::text
397397
ELSE true
398398
END
399+
-- Filter by unhealthy workspaces
400+
AND CASE
401+
WHEN @unhealthy ::boolean!='false' THEN
402+
(
403+
SELECTCOUNT(*)>0
404+
FROM
405+
workspace_resources
406+
JOIN
407+
workspace_agents
408+
ON
409+
workspace_agents.resource_id=workspace_resources.id
410+
WHERE
411+
workspace_resources.job_id=latest_build.provisioner_job_idAND
412+
latest_build.transition='start'::workspace_transitionAND
413+
workspace_agents.deleted= FALSEAND
414+
(
415+
-- Agent has never connected
416+
workspace_agents.first_connected_at ISNULLOR
417+
-- Agent is disconnected
418+
workspace_agents.disconnected_at>workspace_agents.last_connected_atOR
419+
-- Agent has been inactive for too long
420+
(workspace_agents.last_connected_atIS NOT NULLAND
421+
NOW()-workspace_agents.last_connected_at> INTERVAL'1 second'* @agent_inactive_disconnect_timeout_seconds ::bigint)
422+
)
423+
)
424+
ELSE true
425+
END
399426
-- Authorize Filter clause will be injected below in GetAuthorizedWorkspaces
400427
-- @authorize_filter
401428
), filtered_workspaces_orderAS (

‎coderd/searchquery/search.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func Workspaces(ctx context.Context, db database.Store, query string, page coder
256256
filter.Status=string(httpapi.ParseCustom(parser,values,"","status",httpapi.ParseEnum[database.WorkspaceStatus]))
257257
filter.HasAgent=parser.String(values,"","has-agent")
258258
filter.Dormant=parser.Boolean(values,false,"dormant")
259+
filter.Unhealthy=parser.Boolean(values,false,"unhealthy")
259260
filter.LastUsedAfter=parser.Time3339Nano(values, time.Time{},"last_used_after")
260261
filter.LastUsedBefore=parser.Time3339Nano(values, time.Time{},"last_used_before")
261262
filter.UsingActive= sql.NullBool{

‎coderd/workspaces.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
139139
// @Security CoderSessionToken
140140
// @Produce json
141141
// @Tags Workspaces
142-
// @Param q query string false "Search query in the format `key:value`. Available keys are: owner, template, name, status, has-agent, dormant, last_used_after, last_used_before, has-ai-task, has_external_agent."
142+
// @Param q query string false "Search query in the format `key:value`. Available keys are: owner, template, name, status, has-agent, dormant,unhealthy,last_used_after, last_used_before, has-ai-task, has_external_agent."
143143
// @Param limit query int false "Page limit"
144144
// @Param offset query int false "Page offset"
145145
// @Success 200 {object} codersdk.WorkspacesResponse

‎site/src/pages/WorkspacesPage/filter/WorkspacesFilter.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const workspaceFilterQuery = {
2929
failed:"status:failed",
3030
dormant:"dormant:true",
3131
outdated:"outdated:true",
32+
unhealthy:"unhealthy:true",
3233
};
3334

3435
typeFilterPreset={
@@ -59,6 +60,10 @@ const PRESET_FILTERS: FilterPreset[] = [
5960
query:workspaceFilterQuery.outdated,
6061
name:"Outdated workspaces",
6162
},
63+
{
64+
query:workspaceFilterQuery.unhealthy,
65+
name:"Unhealthy workspaces",
66+
},
6267
];
6368

6469
// Defined outside component so that the array doesn't get reconstructed each render

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp