Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix: preserve idle filters when listing saved views (#11167)

沙雕的小鱼儿 boyfeiyu7683346805f5
diff --git a/server/internal/handler/issue_view_issues.go b/server/internal/handler/issue_view_issues.go
index bfde1366a7..20c9e659b9 100644
--- a/server/internal/handler/issue_view_issues.go
+++ b/server/internal/handler/issue_view_issues.go
@@ -442,6 +442,7 @@ func issueViewTableQuery(view db.IssueView, today string, activeProperties map[s
Negate: negate,
WorkingOnly: issueViewBool(query["agentRunningFilter"]),
}
+ filters.IdleOnly = !filters.WorkingOnly && issueViewBool(query["agentIdleFilter"])
// An explicitly empty assignee list means "match none" to the table query.
if len(assignees) > 0 {
filters.Assignees = assignees
diff --git a/server/internal/handler/issue_view_issues_test.go b/server/internal/handler/issue_view_issues_test.go
index 6f891db64f..ec77494318 100644
--- a/server/internal/handler/issue_view_issues_test.go
+++ b/server/internal/handler/issue_view_issues_test.go
@@ -105,6 +105,14 @@ func TestIssueViewTableQueryKeepsEveryViewCondition(t *testing.T) {
}}, `{"properties": {"p1": ["opt", {"op": "gte", "value": "3"}]}, "include_sub_issues": true}`},
{"agent running", map[string]any{"agentRunningFilter": true},
`{"working_only": true, "include_sub_issues": true}`},
+ {"agent idle off", map[string]any{"agentIdleFilter": false},
+ `{"include_sub_issues": true}`},
+ {"agent idle", map[string]any{"agentIdleFilter": true, "agentRunningFilter": false},
+ `{"idle_only": true, "include_sub_issues": true}`},
+ {"agent running with idle off", map[string]any{"agentRunningFilter": true, "agentIdleFilter": false},
+ `{"working_only": true, "include_sub_issues": true}`},
+ {"agent running takes precedence over idle", map[string]any{"agentRunningFilter": true, "agentIdleFilter": true},
+ `{"working_only": true, "include_sub_issues": true}`},
{"advanced tree", map[string]any{"advancedFilter": map[string]any{
"type": "group", "id": "root", "match": "any",
"children": []any{
@@ -389,3 +397,65 @@ func TestListIssueViewIssuesHidesOtherMembersPrivateViews(t *testing.T) {
listIssueViewIssuesForTest(t, other, view.ID, "").Want(http.StatusNotFound)
listIssueViewIssuesForTest(t, testUserID, view.ID, "limit=1").Want(http.StatusOK)
}
+
+func TestListIssueViewIssuesActivityFilters(t *testing.T) {
+ project := dbfx.Project(t, "saved view activity")
+ agent := dbfx.Agent(t, "saved view activity", testRuntimeID)
+ for _, row := range []struct{ title, status string }{
+ {"a untouched", ""},
+ {"b completed", "completed"},
+ {"c running", "running"},
+ {"d queued", "queued"},
+ } {
+ issue := dbfx.Issue(t, row.title, testutil.Cols{"project_id": project, "priority": "urgent"})
+ if row.status != "" {
+ dbfx.Task(t, agent, testutil.Cols{"runtime_id": testRuntimeID, "issue_id": issue, "status": row.status})
+ }
+ }
+ dbfx.Issue(t, "outside priority", testutil.Cols{"project_id": project, "priority": "low"})
+ otherProject := dbfx.Project(t, "outside saved view activity")
+ dbfx.Issue(t, "outside project", testutil.Cols{"project_id": otherProject, "priority": "urgent"})
+
+ all := []string{"a untouched", "b completed", "c running", "d queued"}
+ for _, scope := range []string{"workspace", "project"} {
+ t.Run(scope, func(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ query map[string]any
+ want []string
+ }{
+ {"omitted", map[string]any{}, all},
+ {"off", map[string]any{"agentIdleFilter": false, "agentRunningFilter": false}, all},
+ {"idle", map[string]any{"agentIdleFilter": true, "agentRunningFilter": false}, []string{"a untouched", "b completed"}},
+ {"running", map[string]any{"agentIdleFilter": false, "agentRunningFilter": true}, []string{"c running"}},
+ {"running takes precedence", map[string]any{"agentIdleFilter": true, "agentRunningFilter": true}, []string{"c running"}},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ query := map[string]any{"priorityFilters": []string{"urgent"}, "projectFilters": []string{project}}
+ for key, value := range tc.query {
+ query[key] = value
+ }
+ input := map[string]any{
+ "name": t.Name(), "scope_type": scope, "query": query,
+ "display": map[string]any{"sortBy": "title", "sortDirection": "asc"},
+ }
+ if scope == "project" {
+ input["scope_id"] = project
+ }
+ view, code, body := createIssueViewForTest(t, input)
+ if code != http.StatusCreated {
+ t.Fatalf("create view: %d %s", code, body)
+ }
+ var response issueViewIssuesResponse
+ listIssueViewIssuesForTest(t, testUserID, view.ID, "").Want(http.StatusOK).JSON(&response)
+ if got := issueViewIssueTitles(response); !reflect.DeepEqual(got, tc.want) {
+ t.Fatalf("saved view issues = %v, want %v", got, tc.want)
+ }
+ if response.Total == nil || *response.Total != int64(len(tc.want)) || response.HasMore {
+ t.Fatalf("page metadata: total=%v has_more=%v, want %d issues", response.Total, response.HasMore, len(tc.want))
+ }
+ })
+ }
+ })
+ }
+}