Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8427 feat(sidebar): add a Me and my agents assignee option to the project issue settings (#9750)
Jiayuan Zhangca7cdb9d5dc1
diff --git a/packages/core/api/schemas.test.ts b/packages/core/api/schemas.test.tsindex c57de7d3e6..1a91144c94 100644--- a/packages/core/api/schemas.test.ts+++ b/packages/core/api/schemas.test.ts@@ -68,6 +68,7 @@ import {EMPTY_PLUGIN_PREVIEW,} from "./schemas";import { IssueViewSchema, IssueViewListSchema, SidebarProjectPrefsDocSchema } from "./schemas";+import type { SidebarIssueAssignee } from "../issues/stores/sidebar-tree-store";import {ListIssueStatusesResponseSchema,IssueStatusEntrySchema,@@ -1977,6 +1978,13 @@ describe("SidebarProjectPrefsDocSchema", () => {expect(SidebarProjectPrefsDocSchema.parse(doc)).toEqual(doc);});+ it.each(["anyone", "me", "my_agents", "me_and_my_agents"] satisfies SidebarIssueAssignee[])(+ "keeps the %s assignee setting",+ (assignee) => {+ expect(SidebarProjectPrefsDocSchema.parse({ issues: { assignee } }).issues.assignee).toBe(assignee);+ },+ );+it("drops settings saved by another client version instead of failing the document", () => {const parsed = SidebarProjectPrefsDocSchema.parse({projects: { ordering: "future-order", statuses: "planned", onlyMine: "no", showCount: true },diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.tsindex 1d5f357beb..3c64bf001f 100644--- a/packages/core/api/schemas.ts+++ b/packages/core/api/schemas.ts@@ -736,7 +736,7 @@ export const SidebarProjectPrefsDocSchema = z.object({sortBy: z.enum(["updated_at", "created_at", "priority", "status", "title", "due_date"]).optional().catch(undefined),sortDirection: z.enum(["asc", "desc"]).optional().catch(undefined),hiddenStatuses: z.array(z.string()).nullable().optional().catch(undefined),- assignee: z.enum(["anyone", "me", "my_agents"]).optional().catch(undefined),+ assignee: z.enum(["anyone", "me", "my_agents", "me_and_my_agents"]).optional().catch(undefined),showSubIssues: z.boolean().optional().catch(undefined),}).catch({}),order: z.array(z.unknown()).catch([]).transform((ids) => ids.filter((id): id is string => typeof id === "string")),diff --git a/packages/core/issues/sidebar-list.test.ts b/packages/core/issues/sidebar-list.test.tsindex 455e49c5dd..6b3698d20f 100644--- a/packages/core/issues/sidebar-list.test.ts+++ b/packages/core/issues/sidebar-list.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from "vitest";import type { Project } from "../types";import {- projectSidebarParams,+ projectSidebarRequest,shownSidebarStatuses,builtinSidebarRequest,sidebarProjects,@@ -23,9 +23,9 @@ const STATUSES = [{ key: "cancelled", category: "closed" },] as const;-describe("projectSidebarParams", () => {+describe("projectSidebarRequest", () => {it("leaves out finished statuses and sorts by update time by default", () => {- expect(projectSidebarParams("p1", DEFAULT_SIDEBAR_ISSUE_SETTINGS, STATUSES, "u1")).toEqual({+ expect(projectSidebarRequest("p1", DEFAULT_SIDEBAR_ISSUE_SETTINGS, STATUSES, "u1")).toEqual({project_id: "p1",statuses: ["backlog", "todo", "in_progress", "merged"],sort_by: "updated_at",@@ -40,7 +40,7 @@ describe("projectSidebarParams", () => {assignee: "my_agents",showSubIssues: false,};- expect(projectSidebarParams("p1", settings, STATUSES, "u1")).toEqual({+ expect(projectSidebarRequest("p1", settings, STATUSES, "u1")).toEqual({project_id: "p1",involves_user_id: "u1",top_level_only: true,@@ -49,10 +49,26 @@ describe("projectSidebarParams", () => {});});+ it("lists me and my agents through the table query, which can OR the two", () => {+ const settings: SidebarIssueSettings = { ...DEFAULT_SIDEBAR_ISSUE_SETTINGS, assignee: "me_and_my_agents" };+ expect(projectSidebarRequest("p1", settings, STATUSES, "u1")).toEqual({+ table: {+ scope: { kind: "project", project_id: "p1" },+ filters: {+ statuses: ["backlog", "todo", "in_progress", "merged"],+ relations: ["assigned", "my_agents"],+ include_sub_issues: true,+ },+ sort: { field: "updated_at", direction: "desc" },+ },+ });+ expect(projectSidebarRequest("p1", settings, STATUSES, undefined)).toBeNull();+ });+it("lists nothing when every status is hidden", () => {const settings = { ...DEFAULT_SIDEBAR_ISSUE_SETTINGS, hiddenStatuses: STATUSES.map((s) => s.key) };expect(shownSidebarStatuses(settings, STATUSES)).toEqual([]);- expect(projectSidebarParams("p1", settings, STATUSES, "u1")).toBeNull();+ expect(projectSidebarRequest("p1", settings, STATUSES, "u1")).toBeNull();});});@@ -155,6 +171,11 @@ describe("builtinSidebarRequest", () => {relations: ["my_agents"],include_sub_issues: true,});+ const both = { ...mine, assignee: "me_and_my_agents" as const };+ expect(builtinSidebarRequest("all_issues", "assigned", both, STATUSES)?.table.filters).toEqual({+ relations: ["assigned", "my_agents"],+ include_sub_issues: true,+ });const none = { ...DEFAULT_SIDEBAR_ISSUE_SETTINGS, hiddenStatuses: STATUSES.map((s) => s.key) };expect(builtinSidebarRequest("all_issues", "assigned", none, STATUSES)).toBeNull();});diff --git a/packages/core/issues/sidebar-list.ts b/packages/core/issues/sidebar-list.tsindex cc98ccd69d..4c5151b95a 100644--- a/packages/core/issues/sidebar-list.ts+++ b/packages/core/issues/sidebar-list.ts@@ -14,7 +14,7 @@ import { assigneeTypesForActorKind } from "./surface/scope";import { effectiveNegatedFilters } from "./stores/view-store";import { FILTER_DIMENSION_TABLE_FIELD, advancedFilterToTableQuery, advancedFilterUsesField } from "./stores/filter-tree";import type { MyIssuesRelation } from "./stores/my-issues-view-store";-import type { SidebarIssueSettings, SidebarProjectSettings } from "./stores/sidebar-tree-store";+import type { SidebarIssueAssignee, SidebarIssueSettings, SidebarProjectSettings } from "./stores/sidebar-tree-store";/** Rows an expanded sidebar list shows before "Load more". */export const SIDEBAR_FIRST_PAGE = 5;@@ -43,19 +43,43 @@ export function shownSidebarStatuses(return statuses.filter((s) => !hidden.has(s.key)).map((s) => s.key);}-/** List params for an expanded project, or `null` when the settings leave nothing to list. */-export function projectSidebarParams(+/** The viewer relations each assignee setting lists through the table query, OR'd together. */+const ASSIGNEE_RELATIONS: Record<SidebarIssueAssignee, IssueTableRelation[]> = {+ anyone: [],+ me: ["assigned"],+ my_agents: ["my_agents"],+ me_and_my_agents: ["assigned", "my_agents"],+};++/** The request for an expanded project, or `null` when the settings leave nothing to list. */+export function projectSidebarRequest(projectId: string,settings: SidebarIssueSettings,statuses: readonly StatusRef[],userId: string | undefined,-): ListIssuesParams | null {+): SidebarIssuesRequest | null {const shown = shownSidebarStatuses(settings, statuses);if (shown.length === 0) return null;if (settings.assignee !== "anyone" && !userId) return null;+ const statusFilter = shown.length < statuses.length ? { statuses: shown } : {};+ // The list endpoint cannot OR the user with their agents: `involves_user_id`+ // never matches issues assigned to the user directly.+ if (settings.assignee === "me_and_my_agents") {+ return {+ table: {+ scope: { kind: "project", project_id: projectId },+ filters: {+ ...statusFilter,+ relations: ASSIGNEE_RELATIONS.me_and_my_agents,+ include_sub_issues: settings.showSubIssues,+ },+ sort: { field: settings.sortBy, direction: settings.sortDirection },+ },+ };+ }return {project_id: projectId,- ...(shown.length < statuses.length ? { statuses: shown } : {}),+ ...statusFilter,...(settings.assignee === "me" ? { assignee_id: userId } : {}),...(settings.assignee === "my_agents" ? { involves_user_id: userId } : {}),...(settings.showSubIssues ? {} : { top_level_only: true }),@@ -180,8 +204,7 @@ export function builtinSidebarRequest(const shown = shownSidebarStatuses(settings, statuses);if (shown.length === 0) return null;const relation = builtin === "my_agents" ? "involved" : myRelation === "all" ? "any" : myRelation;- const relations: IssueTableRelation[] =- settings.assignee === "me" ? ["assigned"] : settings.assignee === "my_agents" ? ["my_agents"] : [];+ const relations = ASSIGNEE_RELATIONS[settings.assignee] ?? [];return {table: {scope: builtin === "all_issues" ? { kind: "workspace" } : { kind: "my", relation },diff --git a/packages/core/issues/stores/sidebar-tree-store.ts b/packages/core/issues/stores/sidebar-tree-store.tsindex 4840d109ea..11cdcd1388 100644--- a/packages/core/issues/stores/sidebar-tree-store.ts+++ b/packages/core/issues/stores/sidebar-tree-store.ts@@ -7,7 +7,7 @@ import { defaultStorage } from "../../platform/storage";import type { ProjectStatus } from "../../types";export type SidebarIssueSort = "updated_at" | "created_at" | "priority" | "status" | "title" | "due_date";-export type SidebarIssueAssignee = "anyone" | "me" | "my_agents";+export type SidebarIssueAssignee = "anyone" | "me" | "my_agents" | "me_and_my_agents";/** How expanded projects list their issues in the sidebar. */export interface SidebarIssueSettings {diff --git a/packages/views/chat/components/chat-window-messages.test.tsx b/packages/views/chat/components/chat-window-messages.test.tsxindex 743f9d16a2..fc5a82b2e0 100644--- a/packages/views/chat/components/chat-window-messages.test.tsx+++ b/packages/views/chat/components/chat-window-messages.test.tsx@@ -143,8 +143,11 @@ describe("floating chat message lifetime", () => {setOpen(false);expect(screen.getByTestId("messages")).toHaveAttribute("data-active", "false");- await waitFor(() => expect(screen.queryByTestId("messages")).not.toBeInTheDocument());- expect(observers()).toBe(0);+ // The observer leaves in the unmount's passive cleanup, which can trail the DOM removal.+ await waitFor(() => {+ expect(screen.queryByTestId("messages")).not.toBeInTheDocument();+ expect(observers()).toBe(0);+ });act(() => qc.setQueryData(key, pages([message("arrived while closed")])));setOpen(true);diff --git a/packages/views/layout/panels/sidebar-settings.test.tsx b/packages/views/layout/panels/sidebar-settings.test.tsxindex 067736b8dd..f69c5d9152 100644--- a/packages/views/layout/panels/sidebar-settings.test.tsx+++ b/packages/views/layout/panels/sidebar-settings.test.tsx@@ -1,5 +1,6 @@import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { fireEvent, screen, waitFor } from "@testing-library/react";+import { act, fireEvent, screen, waitFor } from "@testing-library/react";+import userEvent from "@testing-library/user-event";import { beforeEach, describe, expect, it, vi } from "vitest";import type { IssueViewPreference } from "@multica/core/api/schemas";import { issueViewPreferenceOptions } from "@multica/core/issue-views/preferences";@@ -99,6 +100,23 @@ describe("ProjectsSectionSettings", () => {expect(lastSaved().issues.hiddenStatuses).toEqual(expect.arrayContaining(["todo", "done"]));});+ it("saves me and my agents and keeps it once the saved document is read back", async () => {+ const user = userEvent.setup();+ openSettings();++ const assignee = screen.getByRole("combobox", { name: "Assignee" });+ expect(assignee).toHaveTextContent("Anyone");+ await user.click(assignee);+ await user.click(await screen.findByRole("option", { name: "Me and my agents" }));++ await waitFor(() => expect(server.putIssueViewPreference).toHaveBeenCalled());+ expect(lastSaved().issues.assignee).toBe("me_and_my_agents");+ await waitFor(() => expect(server.doc.prefs.issues).toMatchObject({ assignee: "me_and_my_agents" }));+ await act(() => qc.refetchQueries());+ expect(server.getIssueViewPreference).toHaveBeenCalled();+ expect(assignee).toHaveTextContent("Me and my agents");+ });+it("toggles a project status and resets everything at once", async () => {openSettings();diff --git a/packages/views/layout/panels/sidebar-settings.tsx b/packages/views/layout/panels/sidebar-settings.tsxindex 219f632a6c..526c463d9e 100644--- a/packages/views/layout/panels/sidebar-settings.tsx+++ b/packages/views/layout/panels/sidebar-settings.tsx@@ -86,9 +86,11 @@ function SortSelect<T extends string>({}}><SelectTrigger size="sm" className={className} aria-label={label}>- <SelectValue>{options.find((o) => o.value === value)?.label}</SelectValue>+ <SelectValue>+ <span className="truncate">{options.find((o) => o.value === value)?.label}</span>+ </SelectValue></SelectTrigger>- <SelectContent align="end">+ <SelectContent align="end" className="w-auto min-w-(--anchor-width)"><SelectGroup>{options.map((o) => (<SelectItem key={o.value} value={o.value}>@@ -184,6 +186,7 @@ function ProjectIssuesGroup({{ value: "anyone", label: t(($) => $.panels.work.assignee_anyone) },{ value: "me", label: t(($) => $.panels.work.assignee_me) },{ value: "my_agents", label: t(($) => $.panels.work.assignee_my_agents) },+ { value: "me_and_my_agents", label: t(($) => $.panels.work.assignee_me_and_my_agents) },];return (@@ -231,7 +234,7 @@ function ProjectIssuesGroup({value={settings.assignee}options={assigneeOptions}onChange={(assignee) => update({ assignee })}- className="w-36"+ className="w-44"/></Field><SwitchFielddiff --git a/packages/views/layout/panels/work-tree.tsx b/packages/views/layout/panels/work-tree.tsxindex b62db631d9..7590e9652a 100644--- a/packages/views/layout/panels/work-tree.tsx+++ b/packages/views/layout/panels/work-tree.tsx@@ -13,8 +13,9 @@ import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import { issueKeys, sidebarIssuesOptions } from "@multica/core/issues/queries";import {SIDEBAR_FIRST_PAGE,- projectSidebarParams,+ projectSidebarRequest,projectSidebarSource,+ type SidebarIssuesRequest,} from "@multica/core/issues/sidebar-list";import { useSidebarProjectPrefs, useUpdateSidebarProjectPrefs } from "@multica/core/issues/sidebar-project-prefs";import { openCreateIssueWithPreference } from "@multica/core/issues/stores/create-mode-store";@@ -22,7 +23,7 @@ import { useSidebarKeptStore } from "@multica/core/issues/stores/sidebar-kept-stimport { useSidebarTreeStore, type SidebarIssueSettings } from "@multica/core/issues/stores/sidebar-tree-store";import { useModalStore } from "@multica/core/modals";import { useWorkspacePaths } from "@multica/core/paths";-import type { Issue, ListIssuesParams, ListIssuesResponse, Project } from "@multica/core/types";+import type { Issue, ListIssuesResponse, Project } from "@multica/core/types";import { useT } from "../../i18n";import { PanelCount, PanelLink, PanelList, PanelSection, isPathWithin } from "../panel-nav";import { ProjectsSectionSettings } from "./sidebar-settings";@@ -36,10 +37,10 @@ function useExpanded(key: string) {return [expanded, (next: boolean) => setExpanded(key, next)] as const;}-function usePrefetch(wsId: string, source: string, params: ListIssuesParams | null | undefined) {+function usePrefetch(wsId: string, source: string, request: SidebarIssuesRequest | null | undefined) {const qc = useQueryClient();return () => {- if (params) void qc.prefetchQuery(sidebarIssuesOptions(wsId, source, params, SIDEBAR_FIRST_PAGE));+ if (request) void qc.prefetchQuery(sidebarIssuesOptions(wsId, source, request, SIDEBAR_FIRST_PAGE));};}@@ -201,7 +202,7 @@ function ProjectTreeItem({const [expanded, setExpanded] = useExpanded(source);const statusCatalog = useIssueStatuses(wsId);const params = statusCatalog.isLoaded- ? projectSidebarParams(project.id, issueSettings, statusCatalog.statuses, userId)+ ? projectSidebarRequest(project.id, issueSettings, statusCatalog.statuses, userId): undefined;const prefetch = usePrefetch(wsId, source, params);diff --git a/packages/views/locales/en/layout.json b/packages/views/locales/en/layout.jsonindex 83caf56036..e5c3921ee2 100644--- a/packages/views/locales/en/layout.json+++ b/packages/views/locales/en/layout.json@@ -101,6 +101,7 @@"assignee_anyone": "Anyone","assignee_me": "Me","assignee_my_agents": "My agents",+ "assignee_me_and_my_agents": "Me and my agents","reset": "Reset","load_more": "Load more","show_less": "Show less",diff --git a/packages/views/locales/fr/layout.json b/packages/views/locales/fr/layout.jsonindex 6a0f5ae0c4..a7bb85896a 100644--- a/packages/views/locales/fr/layout.json+++ b/packages/views/locales/fr/layout.json@@ -101,6 +101,7 @@"assignee_anyone": "Tout le monde","assignee_me": "Moi","assignee_my_agents": "Mes agents",+ "assignee_me_and_my_agents": "Moi et mes agents","reset": "Réinitialiser","load_more": "Afficher plus","show_less": "Afficher moins",diff --git a/packages/views/locales/ja/layout.json b/packages/views/locales/ja/layout.jsonindex d36d88d9f6..9480311225 100644--- a/packages/views/locales/ja/layout.json+++ b/packages/views/locales/ja/layout.json@@ -100,6 +100,7 @@"assignee_anyone": "全員","assignee_me": "自分","assignee_my_agents": "自分のエージェント",+ "assignee_me_and_my_agents": "自分と自分のエージェント","reset": "リセット","load_more": "さらに表示","show_less": "表示を減らす",diff --git a/packages/views/locales/ko/layout.json b/packages/views/locales/ko/layout.jsonindex 27fc957a70..ea1dd8b3fa 100644--- a/packages/views/locales/ko/layout.json+++ b/packages/views/locales/ko/layout.json@@ -100,6 +100,7 @@"assignee_anyone": "모두","assignee_me": "나","assignee_my_agents": "내 에이전트",+ "assignee_me_and_my_agents": "나와 내 에이전트","reset": "초기화","load_more": "더 보기","show_less": "간단히 보기",diff --git a/packages/views/locales/zh-Hans/layout.json b/packages/views/locales/zh-Hans/layout.jsonindex 5b2fece980..3305d39068 100644--- a/packages/views/locales/zh-Hans/layout.json+++ b/packages/views/locales/zh-Hans/layout.json@@ -100,6 +100,7 @@"assignee_anyone": "所有人","assignee_me": "我","assignee_my_agents": "我的智能体",+ "assignee_me_and_my_agents": "我和我的智能体","reset": "重置","load_more": "加载更多","show_less": "收起",diff --git a/packages/views/locales/zh-Hant/layout.json b/packages/views/locales/zh-Hant/layout.jsonindex 02ec3395ac..7e35d23332 100644--- a/packages/views/locales/zh-Hant/layout.json+++ b/packages/views/locales/zh-Hant/layout.json@@ -100,6 +100,7 @@"assignee_anyone": "所有人","assignee_me": "我","assignee_my_agents": "我的智慧體",+ "assignee_me_and_my_agents": "我和我的智慧體","reset": "重設","load_more": "載入更多","show_less": "收合",