Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(issues): rank the assignee picker from local manual picks (MUL-9723) (#11066)
Multica Eve58b5c66a9b94
diff --git a/packages/core/api/client.ts b/packages/core/api/client.tsindex b217ebb263..012ae1c249 100644--- a/packages/core/api/client.ts+++ b/packages/core/api/client.ts@@ -125,7 +125,6 @@ import type {CreateRuntimeLocalSkillImportRequest,RuntimeLocalSkillImportRequest,TimelineEntry,- AssigneeFrequencyEntry,TaskMessagePayload,TaskContextReceiptResponse,RuntimeRateLimitsResponse,@@ -2157,10 +2156,6 @@ export class ApiClient {});}- async getAssigneeFrequency(): Promise<AssigneeFrequencyEntry[]> {- return this.fetch("/api/assignee-frequency");- }-async updateComment(commentId: string, content: string, attachmentIds?: string[], suppressAgentIds?: string[], contentBase?: string, expectedRevision?: number): Promise<Comment> {return this.fetch(`/api/comments/${commentId}`, {method: "PUT",diff --git a/packages/core/issues/mutations.ts b/packages/core/issues/mutations.tsindex d708f4484c..9331a3c955 100644--- a/packages/core/issues/mutations.ts+++ b/packages/core/issues/mutations.ts@@ -9,7 +9,6 @@ import {import { api } from "../api";import { issueKeys } from "./queries";import { projectKeys } from "../projects/queries";-import { workspaceKeys } from "../workspace/queries";import { inboxKeys, type ArchivedInboxCache } from "../inbox/queries";import {cancelInboxLists,@@ -389,8 +388,6 @@ export function useUpdateIssue() {Object.prototype.hasOwnProperty.call(vars, "project_id"),});qc.invalidateQueries({ queryKey: issueKeys.tableAll(wsId) });- // Refresh the assignee picker's Recent group after a reassignment.- if (!err && vars.assignee_id) qc.invalidateQueries({ queryKey: workspaceKeys.assigneeFrequency(wsId) });if (ctx) {invalidateStaleListKeys(qc, ctx.change.staleKeys);}diff --git a/packages/core/issues/stores/assignee-picks-store.test.ts b/packages/core/issues/stores/assignee-picks-store.test.tsnew file mode 100644index 0000000000..94a1039482--- /dev/null+++ b/packages/core/issues/stores/assignee-picks-store.test.ts@@ -0,0 +1,96 @@+// @vitest-environment jsdom+import { beforeEach, describe, expect, it } from "vitest";+import {+ rankAssigneePicks,+ selectAssigneePicks,+ useAssigneePicksStore,+ type AssigneePick,+} from "./assignee-picks-store";++const STORAGE_KEY = "multica_assignee_picks";+const picks = (userId: string, wsId: string) =>+ selectAssigneePicks(userId, wsId)(useAssigneePicksStore.getState());++beforeEach(() => {+ localStorage.clear();+ useAssigneePicksStore.setState({ byScope: {} });+});++describe("useAssigneePicksStore.recordPick", () => {+ it("appends every pick, repeats included", () => {+ const { recordPick } = useAssigneePicksStore.getState();+ recordPick("u1", "ws1", { type: "member", id: "m1" });+ recordPick("u1", "ws1", { type: "agent", id: "a1" });+ recordPick("u1", "ws1", { type: "member", id: "m1" });++ expect(picks("u1", "ws1")).toEqual([+ { type: "member", id: "m1" },+ { type: "agent", id: "a1" },+ { type: "member", id: "m1" },+ ]);+ });++ it("drops the oldest pick when the 101st arrives", () => {+ const { recordPick } = useAssigneePicksStore.getState();+ recordPick("u1", "ws1", { type: "squad", id: "oldest" });+ for (let i = 0; i < 100; i++) recordPick("u1", "ws1", { type: "agent", id: "a1" });++ const queue = picks("u1", "ws1");+ expect(queue).toHaveLength(100);+ expect(rankAssigneePicks(queue)).toEqual([{ type: "agent", id: "a1", count: 100 }]);+ const persisted = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "{}");+ expect(persisted.state.byScope["u1:ws1"]).toHaveLength(100);+ });++ it("keeps each account and workspace separate", () => {+ const { recordPick } = useAssigneePicksStore.getState();+ recordPick("u1", "ws1", { type: "member", id: "m1" });+ recordPick("u1", "ws2", { type: "member", id: "m2" });+ recordPick("u2", "ws1", { type: "member", id: "m3" });++ expect(picks("u1", "ws1").map((p) => p.id)).toEqual(["m1"]);+ expect(picks("u1", "ws2").map((p) => p.id)).toEqual(["m2"]);+ expect(picks("u2", "ws1").map((p) => p.id)).toEqual(["m3"]);+ });++ it("survives a reload from storage", async () => {+ useAssigneePicksStore.getState().recordPick("u1", "ws1", { type: "agent", id: "a1" });+ const saved = localStorage.getItem(STORAGE_KEY)!;+ // A fresh page: empty memory, the saved queue still on disk.+ useAssigneePicksStore.setState({ byScope: {} });+ localStorage.setItem(STORAGE_KEY, saved);++ await useAssigneePicksStore.persist.rehydrate();++ expect(picks("u1", "ws1")).toEqual([{ type: "agent", id: "a1" }]);+ });++ it("evicts the least recently used scope past 20", () => {+ const { recordPick } = useAssigneePicksStore.getState();+ for (let i = 0; i < 20; i++) recordPick("u1", `ws${i}`, { type: "member", id: "m1" });+ recordPick("u1", "ws0", { type: "member", id: "m1" });+ recordPick("u1", "ws-new", { type: "member", id: "m1" });++ const scopes = Object.keys(useAssigneePicksStore.getState().byScope);+ expect(scopes).toHaveLength(20);+ expect(scopes).toContain("u1:ws0");+ expect(scopes).not.toContain("u1:ws1");+ });+});++describe("rankAssigneePicks", () => {+ it("orders by count, breaking ties by the most recent pick", () => {+ const queue: AssigneePick[] = [+ { type: "member", id: "m1" },+ { type: "agent", id: "a1" },+ { type: "squad", id: "s1" },+ { type: "agent", id: "a1" },+ { type: "member", id: "m1" },+ ];+ expect(rankAssigneePicks(queue)).toEqual([+ { type: "member", id: "m1", count: 2 },+ { type: "agent", id: "a1", count: 2 },+ { type: "squad", id: "s1", count: 1 },+ ]);+ });+});diff --git a/packages/core/issues/stores/assignee-picks-store.ts b/packages/core/issues/stores/assignee-picks-store.tsnew file mode 100644index 0000000000..c34f7c8779--- /dev/null+++ b/packages/core/issues/stores/assignee-picks-store.ts@@ -0,0 +1,84 @@+"use client";++import { create } from "zustand";+import { createJSONStorage, persist } from "zustand/middleware";+import { defaultStorage } from "../../platform/storage";+import type { IssueAssigneeType } from "../../types";++const MAX_PICKS = 100;+const MAX_SCOPES = 20;+const EMPTY: AssigneePick[] = [];++/** One manual choice in the assignee picker. Counts are derived from the queue. */+export interface AssigneePick {+ type: IssueAssigneeType;+ id: string;+}++interface AssigneePicksState {+ /** FIFO queue (oldest first) per `${userId}:${wsId}`, capped at MAX_PICKS. */+ byScope: Record<string, AssigneePick[]>;+ recordPick: (userId: string, wsId: string, pick: AssigneePick) => void;+}++const scopeKey = (userId: string, wsId: string) => `${userId}:${wsId}`;++// Scoped by user + workspace id so another account or workspace on this device+// never borrows the ranking. Not cleared on logout, like the other recents.+export const useAssigneePicksStore = create<AssigneePicksState>()(+ persist(+ (set) => ({+ byScope: {},+ recordPick: (userId, wsId, pick) =>+ set((state) => {+ const key = scopeKey(userId, wsId);+ const queue = [...(state.byScope[key] ?? EMPTY), { type: pick.type, id: pick.id }].slice(-MAX_PICKS);+ // Re-inserting the key moves it to the end, so key order is+ // least-recently-used first and the oldest scope is evicted.+ const { [key]: _, ...rest } = state.byScope;+ const byScope: Record<string, AssigneePick[]> = { ...rest, [key]: queue };+ const keys = Object.keys(byScope);+ for (const stale of keys.slice(0, Math.max(0, keys.length - MAX_SCOPES))) {+ delete byScope[stale];+ }+ return { byScope };+ }),+ }),+ {+ name: "multica_assignee_picks",+ storage: createJSONStorage(() => defaultStorage),+ partialize: (state) => ({ byScope: state.byScope }),+ version: 1,+ },+ ),+);++export function selectAssigneePicks(userId: string | null | undefined, wsId: string | null | undefined) {+ return (state: AssigneePicksState) =>+ userId && wsId ? (state.byScope[scopeKey(userId, wsId)] ?? EMPTY) : EMPTY;+}++export interface RankedAssignee extends AssigneePick {+ count: number;+}++/**+ * Pick counts, highest first. Ties go to the more recently picked actor —+ * the queue already records the order, so nothing extra is stored.+ */+export function rankAssigneePicks(picks: readonly AssigneePick[]): RankedAssignee[] {+ const byKey = new Map<string, RankedAssignee & { last: number }>();+ picks.forEach((pick, index) => {+ const key = `${pick.type}:${pick.id}`;+ const entry = byKey.get(key);+ if (entry) {+ entry.count += 1;+ entry.last = index;+ } else {+ byKey.set(key, { type: pick.type, id: pick.id, count: 1, last: index });+ }+ });+ return [...byKey.values()]+ .sort((a, b) => b.count - a.count || b.last - a.last)+ .map(({ type, id, count }) => ({ type, id, count }));+}diff --git a/packages/core/issues/stores/draft-store.ts b/packages/core/issues/stores/draft-store.tsindex 87662e1e12..14873d85ba 100644--- a/packages/core/issues/stores/draft-store.ts+++ b/packages/core/issues/stores/draft-store.ts@@ -51,6 +51,10 @@ export interface IssueCreateManual {startDate: string | null;assigneeType?: IssueAssigneeType;assigneeId?: string;+ /** The assignee last picked by hand in this draft, not yet counted toward+ * the picker's local ranking. A create submitting this same assignee+ * counts it once; a prefilled assignee never matches it. */+ assigneePick?: { type: IssueAssigneeType; id: string };/** Label IDs chosen in the create dialog. Attached to the issue right after* it is created (the create endpoint takes no labels), so they are kept as* a plain id list rather than full Label objects. */diff --git a/packages/core/issues/stores/index.ts b/packages/core/issues/stores/index.tsindex 4135d07b46..8745d03b9a 100644--- a/packages/core/issues/stores/index.ts+++ b/packages/core/issues/stores/index.ts@@ -85,3 +85,10 @@ export {type SubIssueRowProperties,type SubIssueRowPropertyKey,} from "./sub-issue-display-store";+export {+ useAssigneePicksStore,+ selectAssigneePicks,+ rankAssigneePicks,+ type AssigneePick,+ type RankedAssignee,+} from "./assignee-picks-store";diff --git a/packages/core/types/activity.ts b/packages/core/types/activity.tsindex 2e66480eac..1cb9ffca19 100644--- a/packages/core/types/activity.ts+++ b/packages/core/types/activity.ts@@ -1,12 +1,6 @@import type { CommentAuthorType, CommentSupplementReceipt, Reaction } from "./comment";import type { Attachment } from "./attachment";-export interface AssigneeFrequencyEntry {- assignee_type: string;- assignee_id: string;- frequency: number;-}-export interface TimelineEntry {type: "activity" | "comment";id: string;diff --git a/packages/core/types/index.ts b/packages/core/types/index.tsindex e30a56161f..b70cde9309 100644--- a/packages/core/types/index.ts+++ b/packages/core/types/index.ts@@ -169,7 +169,6 @@ export {} from "./quick-action";export type {TimelineEntry,- AssigneeFrequencyEntry,} from "./activity";export type { IssueSubscriber, IssueSubscriberDelivery } from "./subscriber";export type * from "./events";diff --git a/packages/core/workspace/queries.test.ts b/packages/core/workspace/queries.test.tsindex b3e2212487..81681d656e 100644--- a/packages/core/workspace/queries.test.ts+++ b/packages/core/workspace/queries.test.ts@@ -1,10 +1,7 @@-import { afterEach, describe, expect, it, vi } from "vitest";-import { setApiInstance } from "../api";-import { createQueryClient } from "../query-client";+import { describe, expect, it } from "vitest";import type { Agent, Workspace } from "../types";import {agentListOptions,- assigneeFrequencyOptions,workspaceBySlugOptions,} from "./queries";@@ -71,29 +68,3 @@ describe("agentListOptions", () => {expect(queryState([])).toBe(false);});});--describe("assigneeFrequencyOptions", () => {- afterEach(() => {- vi.useRealTimers();- });-- // Issue create counts toward the frequencies but does not invalidate them,- // so an empty result cached on idle must not stick for the whole session.- it("refetches a cached result on a later read", async () => {- vi.useFakeTimers();- const getAssigneeFrequency = vi- .fn()- .mockResolvedValueOnce([])- .mockResolvedValueOnce([- { assignee_type: "agent", assignee_id: "agent-1", frequency: 1 },- ]);- setApiInstance({ getAssigneeFrequency } as never);- const qc = createQueryClient();-- expect(await qc.fetchQuery(assigneeFrequencyOptions("ws-1"))).toEqual([]);- vi.advanceTimersByTime(61_000);-- expect(await qc.fetchQuery(assigneeFrequencyOptions("ws-1"))).toHaveLength(1);- expect(getAssigneeFrequency).toHaveBeenCalledTimes(2);- });-});diff --git a/packages/core/workspace/queries.ts b/packages/core/workspace/queries.tsindex 8c0417e5ca..43db20abc0 100644--- a/packages/core/workspace/queries.ts+++ b/packages/core/workspace/queries.ts@@ -21,7 +21,6 @@ export const workspaceKeys = {squadMemberStatus: (wsId: string, squadId: string) =>["workspaces", wsId, "squads", squadId, "members-status"] as const,skills: (wsId: string) => ["workspaces", wsId, "skills"] as const,- assigneeFrequency: (wsId: string) => ["workspaces", wsId, "assignee-frequency"] as const,mcpServers: (wsId: string) => ["workspaces", wsId, "mcp-servers"] as const,};@@ -225,19 +224,6 @@ export function myInvitationListOptions() {});}-export function assigneeFrequencyOptions(wsId: string) {- return queryOptions({- queryKey: workspaceKeys.assigneeFrequency(wsId),- queryFn: () => api.getAssigneeFrequency(),- // Warmed on idle and read by every picker open; keep it past the default- // gcTime so the Recent group never waits on a refetch. Counts also change- // through paths that don't invalidate it (issue create, other clients), so- // a picker opened after a minute revalidates while the cached copy renders.- gcTime: Infinity,- staleTime: 60 * 1000,- });-}-/*** The workspace's MCP server library. Fetched for plain members too — the* payload is names and transports only, and an agent owner needs to see whatdiff --git a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsxindex 1b2eb3f145..ce4139b991 100644--- a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx+++ b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx@@ -6,6 +6,7 @@ import type { AgentTask, Issue, QuickAction } from "@multica/core/types";import { I18nProvider } from "@multica/core/i18n/react";import enCommon from "../../../locales/en/common.json";import enIssues from "../../../locales/en/issues.json";+import { useAssigneePicksStore } from "@multica/core/issues/stores/assignee-picks-store";const TEST_RESOURCES = { en: { common: enCommon, issues: enIssues } };@@ -58,10 +59,6 @@ vi.mock("@multica/core/workspace/queries", () => ({queryKey: ["workspaces", "ws-1", "squads"],queryFn: () => Promise.resolve([]),}),- assigneeFrequencyOptions: () => ({- queryKey: ["workspaces", "ws-1", "assignee-frequency"],- queryFn: () => Promise.resolve([]),- }),}));const { ACTOR_NAMES } = vi.hoisted(() => ({@@ -212,6 +209,8 @@ function wrap(ui: React.ReactNode) {}beforeEach(() => {+ // Picks persist in a real store; keep one test's picks out of the next's Recent.+ useAssigneePicksStore.setState({ byScope: {} });platform.desktop = false;deletionPolicy.allowed = true;mockOpenModal.mockReset();diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex d696632685..e87c06ca28 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -109,10 +109,6 @@ vi.mock("@multica/core/workspace/queries", () => ({queryKey: ["workspaces", "ws-1", "squads"],queryFn: () => Promise.resolve([]),}),- assigneeFrequencyOptions: () => ({- queryKey: ["workspaces", "ws-1", "assignee-frequency"],- queryFn: () => Promise.resolve([]),- }),workspaceListOptions: () => ({queryKey: ["workspaces"],queryFn: () => Promise.resolve([{ id: "ws-1", name: "Test WS", slug: "test" }]),diff --git a/packages/views/issues/components/issue-load-failure.test.tsx b/packages/views/issues/components/issue-load-failure.test.tsxindex 76c13b9dd2..b47f32279e 100644--- a/packages/views/issues/components/issue-load-failure.test.tsx+++ b/packages/views/issues/components/issue-load-failure.test.tsx@@ -57,7 +57,7 @@ beforeEach(() => {if (["SYN-1", uuid, "OTHER-2"].some((id) => pathname === `/api/issues/${id}`)) {return primary(url);}- const body = /\/(members|agents|squads|assignee-frequency)$/.test(pathname)+ const body = /\/(members|agents|squads)$/.test(pathname)? []: { issues: [], total: 0, members: [], agents: [], comments: [], tasks: [], entries: [], has_more: false };return Promise.resolve(response(200, body));diff --git a/packages/views/issues/components/pickers/assignee-picker.hidden.test.tsx b/packages/views/issues/components/pickers/assignee-picker.hidden.test.tsxindex 628bfb942f..db28deaed7 100644--- a/packages/views/issues/components/pickers/assignee-picker.hidden.test.tsx+++ b/packages/views/issues/components/pickers/assignee-picker.hidden.test.tsx@@ -4,6 +4,7 @@ import { describe, expect, it, vi } from "vitest";import { render, screen } from "@testing-library/react";import { I18nProvider } from "@multica/core/i18n/react";import enIssues from "../../../locales/en/issues.json";+import { useAssigneePicksStore } from "@multica/core/issues/stores/assignee-picks-store";import { AssigneePicker } from "./assignee-picker";const MEMBERS = [{ user_id: "user-1", name: "Ada Lovelace", role: "member" }];@@ -25,10 +26,10 @@ const SQUADS = [// rejects the pick, so it's hidden too.{ id: "squad-private", name: "Private Squad", archived_at: null, leader_id: "agent-theirs" },];-const FREQUENCY = [- { assignee_type: "agent", assignee_id: "agent-theirs", frequency: 9 },- { assignee_type: "squad", assignee_id: "squad-stuck", frequency: 8 },- { assignee_type: "agent", assignee_id: "agent-shared", frequency: 1 },+const PICKS = [+ ...Array.from({ length: 9 }, () => ({ type: "agent" as const, id: "agent-theirs" })),+ ...Array.from({ length: 8 }, () => ({ type: "squad" as const, id: "squad-stuck" })),+ { type: "agent" as const, id: "agent-shared" },];vi.mock("@tanstack/react-query", () => ({@@ -36,7 +37,6 @@ vi.mock("@tanstack/react-query", () => ({if (queryKey[0] === "members") return { data: MEMBERS };if (queryKey[0] === "agents") return { data: AGENTS };if (queryKey[0] === "squads") return { data: SQUADS };- if (queryKey[0] === "frequency") return { data: FREQUENCY };return { data: [] };},}));@@ -64,7 +64,6 @@ vi.mock("@multica/core/workspace/queries", () => ({memberListOptions: () => ({ queryKey: ["members"] }),agentListOptions: () => ({ queryKey: ["agents"] }),squadListOptions: () => ({ queryKey: ["squads"] }),- assigneeFrequencyOptions: () => ({ queryKey: ["frequency"] }),}));vi.mock("../../../common/actor-avatar", () => ({ActorAvatar: () => <span data-testid="actor-avatar" />,@@ -79,6 +78,7 @@ function rowsIn(label: string): string[] {describe("AssigneePicker unpickable actors", () => {it("hides agents and squads the user cannot assign, including from Recent", async () => {+ useAssigneePicksStore.setState({ byScope: { "user-1:workspace-1": PICKS } });render(<I18nProvider locale="en" resources={{ en: { issues: enIssues } }}><AssigneePickerdiff --git a/packages/views/issues/components/pickers/assignee-picker.keyboard.test.tsx b/packages/views/issues/components/pickers/assignee-picker.keyboard.test.tsxindex 6484860757..e8feffee4b 100644--- a/packages/views/issues/components/pickers/assignee-picker.keyboard.test.tsx+++ b/packages/views/issues/components/pickers/assignee-picker.keyboard.test.tsx@@ -40,7 +40,6 @@ vi.mock("@multica/core/workspace/queries", () => ({memberListOptions: () => ({ queryKey: ["members"] }),agentListOptions: () => ({ queryKey: ["agents"] }),squadListOptions: () => ({ queryKey: ["squads"] }),- assigneeFrequencyOptions: () => ({ queryKey: ["frequency"] }),}));vi.mock("../../../common/actor-avatar", () => ({ActorAvatar: () => <span data-testid="actor-avatar" />,diff --git a/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx b/packages/views/issues/components/pickers/assignee-picker.recent.test.tsxindex 6c71b16c53..4ed46af9a9 100644--- a/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx+++ b/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx@@ -1,10 +1,14 @@-// The assignee picker's Recent group: the current user's top 3 assignees from-// the server-side assignee-frequency counts.+// The assignee picker's Recent group and per-group order: ranked from this+// user's local pick queue (core's assignee-picks-store), fed by manual picks.import { beforeEach, describe, expect, it, vi } from "vitest";-import { render, screen, within } from "@testing-library/react";+import { act, render, screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { I18nProvider } from "@multica/core/i18n/react";import enIssues from "../../../locales/en/issues.json";+import {+ useAssigneePicksStore,+ type AssigneePick,+} from "@multica/core/issues/stores/assignee-picks-store";import { AssigneePicker } from "./assignee-picker";const MEMBERS = [@@ -17,15 +21,21 @@ const AGENTS = [];const SQUADS = [{ id: "squad-1", name: "Platform", archived_at: null, leader_id: "agent-1" }];-type FrequencyEntry = { assignee_type: string; assignee_id: string; frequency: number };-let frequency: FrequencyEntry[] = [];+const SCOPE = "user-1:workspace-1";++/** Seed the queue: each `[pick, n]` is appended n times, in order. */+function seed(...entries: [AssigneePick, number][]) {+ const queue = entries.flatMap(([pick, n]) => Array.from({ length: n }, () => pick));+ useAssigneePicksStore.setState({ byScope: { [SCOPE]: queue } });+}++const queue = () => useAssigneePicksStore.getState().byScope[SCOPE] ?? [];vi.mock("@tanstack/react-query", () => ({useQuery: ({ queryKey }: { queryKey: string[] }) => {if (queryKey[0] === "members") return { data: MEMBERS };if (queryKey[0] === "agents") return { data: AGENTS };if (queryKey[0] === "squads") return { data: SQUADS };- if (queryKey[0] === "frequency") return { data: frequency };return { data: [] };},}));@@ -43,13 +53,14 @@ vi.mock("@multica/core/workspace/queries", () => ({memberListOptions: () => ({ queryKey: ["members"] }),agentListOptions: () => ({ queryKey: ["agents"] }),squadListOptions: () => ({ queryKey: ["squads"] }),- assigneeFrequencyOptions: () => ({ queryKey: ["frequency"] }),}));vi.mock("../../../common/actor-avatar", () => ({ActorAvatar: () => <span data-testid="actor-avatar" />,}));-function picker(onUpdate: () => void) {+type PickerProps = Partial<React.ComponentProps<typeof AssigneePicker>>;++function picker(onUpdate: () => void, props: PickerProps = {}) {return (<I18nProvider locale="en" resources={{ en: { issues: enIssues } }}><AssigneePicker@@ -58,13 +69,22 @@ function picker(onUpdate: () => void) {onUpdate={onUpdate}openonOpenChange={() => {}}+ {...props}/></I18nProvider>);}-function renderPicker(onUpdate: () => void = () => {}) {- return render(picker(onUpdate));+function renderPicker(onUpdate: () => void = () => {}, props: PickerProps = {}) {+ return render(picker(onUpdate, props));+}++/** Row names inside a labelled section, in display order. */+function sectionRows(label: string): string[] {+ const section = screen.getByText(label).parentElement as HTMLElement;+ return Array.from(section.querySelectorAll("[data-picker-item]")).map(+ (el) => el.textContent ?? "",+ );}/** Row names inside the Recent section, in display order. */@@ -78,22 +98,22 @@ async function recentRows(): Promise<string[]> {describe("AssigneePicker Recent group", () => {beforeEach(() => {- frequency = [];+ useAssigneePicksStore.setState({ byScope: {} });});- it("is hidden without frequency data", async () => {+ it("is hidden without local picks", async () => {renderPicker();await screen.findByText("Members");expect(screen.queryByText("Recent")).toBeNull();});it("shows the top 3 by count, highest first, between Unassigned and Members", async () => {- frequency = [- { assignee_type: "member", assignee_id: "user-1", frequency: 2 },- { assignee_type: "squad", assignee_id: "squad-1", frequency: 9 },- { assignee_type: "member", assignee_id: "user-2", frequency: 1 },- { assignee_type: "agent", assignee_id: "agent-1", frequency: 5 },- ];+ seed(+ [{ type: "member", id: "user-1" }, 2],+ [{ type: "squad", id: "squad-1" }, 9],+ [{ type: "member", id: "user-2" }, 1],+ [{ type: "agent", id: "agent-1" }, 5],+ );renderPicker();expect(await recentRows()).toEqual(["Platform", "Builder", "Ada Lovelace"]);@@ -108,21 +128,42 @@ describe("AssigneePicker Recent group", () => {expect(screen.getAllByText("Platform")).toHaveLength(2);});- it("skips archived and removed actors and zero counts, letting the next one move up", async () => {- frequency = [- { assignee_type: "agent", assignee_id: "agent-2", frequency: 10 }, // archived- { assignee_type: "member", assignee_id: "user-gone", frequency: 8 }, // removed- { assignee_type: "squad", assignee_id: "squad-gone", frequency: 7 }, // deleted- { assignee_type: "member", assignee_id: "user-2", frequency: 3 },- { assignee_type: "member", assignee_id: "user-1", frequency: 0 },- ];+ it("skips archived and removed actors, letting the next one move up", async () => {+ seed(+ [{ type: "agent", id: "agent-2" }, 10], // archived+ [{ type: "member", id: "user-gone" }, 8], // removed+ [{ type: "squad", id: "squad-gone" }, 7], // deleted+ [{ type: "member", id: "user-2" }, 3],+ );renderPicker();expect(await recentRows()).toEqual(["Grace Hopper"]);});+ it("orders each group by its own counts, default order on ties", async () => {+ seed([{ type: "member", id: "user-2" }, 2]);+ renderPicker();++ await screen.findByText("Members");+ expect(sectionRows("Members")).toEqual(["Grace Hopper", "Ada Lovelace"]);+ });++ it("ignores another account's or workspace's picks", async () => {+ useAssigneePicksStore.setState({+ byScope: {+ "user-2:workspace-1": [{ type: "member", id: "user-2" }],+ "user-1:workspace-2": [{ type: "member", id: "user-2" }],+ },+ });+ renderPicker();++ await screen.findByText("Members");+ expect(screen.queryByText("Recent")).toBeNull();+ expect(sectionRows("Members")).toEqual(["Ada Lovelace", "Grace Hopper"]);+ });+it("assigns from a Recent row", async () => {- frequency = [{ assignee_type: "agent", assignee_id: "agent-1", frequency: 4 }];+ seed([{ type: "agent", id: "agent-1" }, 4]);const user = userEvent.setup();const onUpdate = vi.fn();renderPicker(onUpdate);@@ -134,7 +175,7 @@ describe("AssigneePicker Recent group", () => {});it("is hidden while searching so Enter picks the first match", async () => {- frequency = [{ assignee_type: "member", assignee_id: "user-1", frequency: 6 }];+ seed([{ type: "member", id: "user-1" }, 6]);const user = userEvent.setup();const onUpdate = vi.fn();renderPicker(onUpdate);@@ -157,8 +198,8 @@ describe("AssigneePicker Recent group", () => {await user.click(screen.getByPlaceholderText("Assign to..."));await user.keyboard("{ArrowDown}{ArrowDown}");- // The frequency response arrives and Recent is inserted above Members.- frequency = [{ assignee_type: "agent", assignee_id: "agent-1", frequency: 4 }];+ // A pick from another picker lands and Recent is inserted above Members.+ act(() => seed([{ type: "agent", id: "agent-1" }, 4]));rerender(picker(onUpdate));await screen.findByText("Recent");@@ -166,3 +207,53 @@ describe("AssigneePicker Recent group", () => {expect(onUpdate).toHaveBeenCalledWith({ assignee_type: "member", assignee_id: "user-1" });});});++describe("AssigneePicker pick recording", () => {+ beforeEach(() => {+ useAssigneePicksStore.setState({ byScope: {} });+ });++ it("records one pick per click, and repeats add up", async () => {+ const user = userEvent.setup();+ renderPicker();++ await user.click(await screen.findByText("Builder"));+ // Now listed twice: in Recent and under Agents.+ await user.click(screen.getAllByText("Builder").at(-1)!);+ expect(queue()).toEqual([+ { type: "agent", id: "agent-1" },+ { type: "agent", id: "agent-1" },+ ]);+ });++ it("records a batch pick across mixed assignees once", async () => {+ const user = userEvent.setup();+ const onUpdate = vi.fn();+ renderPicker(onUpdate, { mixed: true });++ await user.click(await screen.findByText("Platform"));+ expect(onUpdate).toHaveBeenCalledTimes(1);+ expect(queue()).toEqual([{ type: "squad", id: "squad-1" }]);+ });++ it("does not record re-picking the current assignee or clearing it", async () => {+ const user = userEvent.setup();+ const onUpdate = vi.fn();+ renderPicker(onUpdate, { assigneeType: "member", assigneeId: "user-2" });++ await user.click(await screen.findByText("Grace Hopper"));+ await user.click(screen.getAllByText("Unassigned").at(-1)!);+ expect(onUpdate).toHaveBeenCalledTimes(2);+ expect(queue()).toEqual([]);+ });++ it("leaves recording to the host when recordPicks is off", async () => {+ const user = userEvent.setup();+ const onUpdate = vi.fn();+ renderPicker(onUpdate, { recordPicks: false });++ await user.click(await screen.findByText("Builder"));+ expect(onUpdate).toHaveBeenCalledWith({ assignee_type: "agent", assignee_id: "agent-1" });+ expect(queue()).toEqual([]);+ });+});diff --git a/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsx b/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsxdeleted file mode 100644index d987fbf500..0000000000--- a/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsx+++ /dev/null@@ -1,72 +0,0 @@-// The Recent group's frequency counts revalidate when a picker that stays-// mounted (issue detail sidebar) is closed and opened again. Uses a real-// QueryClient: the regression lives in when the query refetches.-import { describe, expect, it, vi } from "vitest";-import { render, screen } from "@testing-library/react";-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { I18nProvider } from "@multica/core/i18n/react";-import enIssues from "../../../locales/en/issues.json";-import { AssigneePicker } from "./assignee-picker";--const getFrequency = vi.fn();--vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "workspace-1" }));-vi.mock("@multica/core/auth", () => ({ useAuthStore: () => ({ id: "user-1" }) }));-vi.mock("@multica/core/agents", () => ({ isAgentRuntimeBound: () => true }));-vi.mock("@multica/core/permissions", () => ({- canAssignAgentToIssue: () => ({ allowed: true }),-}));-vi.mock("@multica/core/workspace/hooks", () => ({- useActorName: () => ({ getActorName: () => "Ada Lovelace" }),-}));-vi.mock("@multica/core/workspace/queries", () => ({- memberListOptions: () => ({- queryKey: ["members"],- queryFn: () => [{ user_id: "user-1", name: "Ada Lovelace", role: "member" }],- }),- agentListOptions: () => ({ queryKey: ["agents"], queryFn: () => [] }),- squadListOptions: () => ({ queryKey: ["squads"], queryFn: () => [] }),- // Already stale, standing in for the real 60s staleTime having elapsed- // (covered in core's queries.test.ts).- assigneeFrequencyOptions: () => ({- queryKey: ["frequency"],- queryFn: () => getFrequency(),- staleTime: 0,- }),-}));-vi.mock("../../../common/actor-avatar", () => ({- ActorAvatar: () => <span data-testid="actor-avatar" />,-}));--describe("AssigneePicker frequency refresh", () => {- it("refetches stale counts when the same picker opens again", async () => {- const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });- const picker = (open: boolean) => (- <QueryClientProvider client={qc}>- <I18nProvider locale="en" resources={{ en: { issues: enIssues } }}>- <AssigneePicker- assigneeType={null}- assigneeId={null}- onUpdate={() => {}}- open={open}- onOpenChange={() => {}}- />- </I18nProvider>- </QueryClientProvider>- );- // Warmed empty, then an assignment elsewhere counts toward the user.- getFrequency- .mockResolvedValueOnce([])- .mockResolvedValue([{ assignee_type: "member", assignee_id: "user-1", frequency: 1 }]);-- const { rerender } = render(picker(true));- await screen.findByText("Members");- expect(screen.queryByText("Recent")).toBeNull();-- rerender(picker(false));- rerender(picker(true));-- expect(await screen.findByText("Recent")).toBeTruthy();- expect(getFrequency).toHaveBeenCalledTimes(2);- });-});diff --git a/packages/views/issues/components/pickers/assignee-picker.tsx b/packages/views/issues/components/pickers/assignee-picker.tsxindex 42ca4614ea..d58c059b4d 100644--- a/packages/views/issues/components/pickers/assignee-picker.tsx+++ b/packages/views/issues/components/pickers/assignee-picker.tsx@@ -9,7 +9,8 @@ import { isAgentRuntimeBound } from "@multica/core/agents";import { canAssignAgentToIssue } from "@multica/core/permissions";import { useActorName } from "@multica/core/workspace/hooks";import { useWorkspaceId } from "@multica/core/hooks";-import { memberListOptions, agentListOptions, squadListOptions, assigneeFrequencyOptions } from "@multica/core/workspace/queries";+import { memberListOptions, agentListOptions, squadListOptions } from "@multica/core/workspace/queries";+import { useAssigneePicksStore, selectAssigneePicks, rankAssigneePicks } from "@multica/core/issues/stores/assignee-picks-store";import { ActorAvatar } from "../../../common/actor-avatar";import { DeferredPopup } from "../../../common/deferred-popup";import {@@ -59,10 +60,15 @@ interface AssigneePickerProps {open?: boolean;onOpenChange?: (v: boolean) => void;align?: "start" | "center" | "end";+ /**+ * Whether a pick feeds the local ranking right away. The create-issue+ * dialog turns this off and records only the assignee it submits.+ */+ recordPicks?: boolean;}/**- * Mounting the real picker subscribes to members/agents/squads/frequency+ * Mounting the real picker subscribes to members/agents/squads* queries — multiplied per board card / list row that cost froze tab* switches. Uncontrolled callers that bring their own trigger content get a* deferred lookalike trigger instead; the picker mounts on first interaction.@@ -104,13 +110,14 @@ function AssigneePickerImpl({open: controlledOpen,onOpenChange: controlledOnOpenChange,align,+ recordPicks = true,}: AssigneePickerProps) {const { t } = useT("issues");const [internalOpen, setInternalOpen] = useState(false);const open = controlledOpen ?? internalOpen;const setOpen = controlledOnOpenChange ?? setInternalOpen;const [filter, setFilter] = useState("");- const choices = useAssigneeChoices(filter, open);+ const choices = useAssigneeChoices(filter);const { getActorName } = useActorName();const triggerLabel =@@ -149,6 +156,7 @@ function AssigneePickerImpl({assigneeType={assigneeType}assigneeId={assigneeId}mixed={mixed}+ recordPicks={recordPicks}onPick={(updates) => {onUpdate(updates);setOpen(false);@@ -199,30 +207,37 @@ export function AssigneePickerPanel({);}-/** `open` gates the frequency query so a picker that stays mounted while- * closed revalidates stale counts each time it opens, not only on mount. */-function useAssigneeChoices(filter: string, open = true) {+/**+ * Records a manual pick in this device's per-user, per-workspace queue that+ * ranks the picker. Exported for the create-issue dialog, which records only+ * the assignee it finally submits.+ */+export function useRecordAssigneePick() {+ const user = useAuthStore((s) => s.user);+ const wsId = useWorkspaceId();+ const recordPick = useAssigneePicksStore((s) => s.recordPick);+ return (type: IssueAssigneeType, id: string) => {+ if (user?.id && wsId) recordPick(user.id, wsId, { type, id });+ };+}++function useAssigneeChoices(filter: string) {const user = useAuthStore((s) => s.user);const wsId = useWorkspaceId();const { data: members = [] } = useQuery(memberListOptions(wsId));const { data: agents = [] } = useQuery(agentListOptions(wsId));const { data: squads = [] } = useQuery(squadListOptions(wsId));- const { data: frequency = [] } = useQuery({- ...assigneeFrequencyOptions(wsId),- enabled: open,- });+ const picks = useAssigneePicksStore(selectAssigneePicks(user?.id, wsId));+ const ranked = useMemo(() => rankAssigneePicks(picks), [picks]);const currentMember = members.find((m) => m.user_id === user?.id);const memberRole = currentMember?.role;- // Build a lookup map from frequency data for sorting.const freqMap = useMemo(() => {const map = new Map<string, number>();- for (const entry of frequency) {- map.set(`${entry.assignee_type}:${entry.assignee_id}`, entry.frequency);- }+ for (const entry of ranked) map.set(`${entry.type}:${entry.id}`, entry.count);return map;- }, [frequency]);+ }, [ranked]);const getFreq = (type: string, id: string) => freqMap.get(`${type}:${id}`) ?? 0;@@ -255,26 +270,23 @@ function useAssigneeChoices(filter: string, open = true) {const filteredSquads = assignableSquads.filter((s) => s.name.toLowerCase().includes(query) || matchesPinyin(s.name, query)).sort((a, b) => getFreq("squad", b.id) - getFreq("squad", a.id));- // Recent: the current user's top 3 assignees by how often they set them- // (server-side counts, scoped to this user + workspace). Entries whose actor- // is gone or no longer pickable — member removed, agent/squad archived or- // hidden above — are skipped so the next one moves up. Hidden while- // searching so Enter still picks the first match.+ // Recent: the top 3 actors this user picked most often on this device in+ // this workspace. Entries whose actor is gone or no longer pickable —+ // member removed, agent/squad archived or hidden above — are skipped so the+ // next one moves up. Hidden while searching so Enter still picks the first+ // match.const recent: RecentAssignee[] = [];if (!query) {- const ranked = frequency- .filter((e) => e.frequency > 0)- .sort((a, b) => b.frequency - a.frequency);for (const entry of ranked) {if (recent.length >= 3) break;- if (entry.assignee_type === "member") {- const member = members.find((m) => m.user_id === entry.assignee_id);+ if (entry.type === "member") {+ const member = members.find((m) => m.user_id === entry.id);if (member) recent.push({ type: "member", member });- } else if (entry.assignee_type === "agent") {- const agent = assignableAgents.find((a) => a.id === entry.assignee_id);+ } else if (entry.type === "agent") {+ const agent = assignableAgents.find((a) => a.id === entry.id);if (agent) recent.push({ type: "agent", agent });- } else if (entry.assignee_type === "squad") {- const squad = assignableSquads.find((s) => s.id === entry.assignee_id);+ } else if (entry.type === "squad") {+ const squad = assignableSquads.find((s) => s.id === entry.id);if (squad) recent.push({ type: "squad", squad });}}@@ -299,6 +311,7 @@ function AssigneeOptions({assigneeType,assigneeId,mixed = false,+ recordPicks = true,onPick,}: {choices: ReturnType<typeof useAssigneeChoices>;@@ -306,26 +319,30 @@ function AssigneeOptions({assigneeType: IssueAssigneeType | null;assigneeId: string | null;mixed?: boolean;+ recordPicks?: boolean;onPick: (updates: Partial<UpdateIssueRequest>) => void;}) {const { t } = useT("issues");const { recent, filteredMembers, filteredAgents, filteredSquads } = choices;+ const recordPick = useRecordAssigneePick();const isSelected = (type: string, id: string) =>assigneeType === type && assigneeId === id;+ // One click is one pick, single issue or batch. Re-picking the current+ // assignee changes nothing, so it does not count.+ const pickActor = (type: IssueAssigneeType, id: string) => {+ if (recordPicks && !isSelected(type, id)) recordPick(type, id);+ onPick({ assignee_type: type, assignee_id: id });+ };+// Shared by Recent and the per-type groups so selection and the private// lock render identically wherever an actor shows up.const renderMember = (m: MemberWithUser) => (<PickerItemkey={m.user_id}selected={isSelected("member", m.user_id)}- onClick={() =>- onPick({- assignee_type: "member",- assignee_id: m.user_id,- })- }+ onClick={() => pickActor("member", m.user_id)}><ActorAvatar actorType="member" actorId={m.user_id} size="sm" /><span className="truncate">{m.name}</span>@@ -336,12 +353,7 @@ function AssigneeOptions({<PickerItemkey={a.id}selected={isSelected("agent", a.id)}- onClick={() =>- onPick({- assignee_type: "agent",- assignee_id: a.id,- })- }+ onClick={() => pickActor("agent", a.id)}><ActorAvatar actorType="agent" actorId={a.id} size="sm" showStatusDot /><span className="truncate">{a.name}</span>@@ -355,12 +367,7 @@ function AssigneeOptions({<PickerItemkey={s.id}selected={isSelected("squad", s.id)}- onClick={() =>- onPick({- assignee_type: "squad",- assignee_id: s.id,- })- }+ onClick={() => pickActor("squad", s.id)}><ActorAvatar actorType="squad" actorId={s.id} size="sm" /><span className="truncate">{s.name}</span>diff --git a/packages/views/issues/components/table-view-editing.test.tsx b/packages/views/issues/components/table-view-editing.test.tsxindex 17d9312421..de92d66333 100644--- a/packages/views/issues/components/table-view-editing.test.tsx+++ b/packages/views/issues/components/table-view-editing.test.tsx@@ -301,7 +301,6 @@ describe("TableView cell editors under data refresh", () => {listMembers: async () => [],listAgents: async () => [],listSquads: async () => [],- getAssigneeFrequency: async () => [],listIssueStatuses: async () => ({ statuses: [] }),listIssueTableRows: async () => ({query_fingerprint: "test",diff --git a/packages/views/issues/components/table-view-project-grouping.test.tsx b/packages/views/issues/components/table-view-project-grouping.test.tsxindex 4676dfe3ab..11dec650bc 100644--- a/packages/views/issues/components/table-view-project-grouping.test.tsx+++ b/packages/views/issues/components/table-view-project-grouping.test.tsx@@ -187,7 +187,6 @@ describe("Table grouped by project", () => {listMembers: async () => [],listAgents: async () => [],listSquads: async () => [],- getAssigneeFrequency: async () => [],listIssueStatuses: async () => ({ statuses: [] }),listProjects: async () => ({projects: [diff --git a/packages/views/issues/components/table-view-virtualized-hierarchy.test.tsx b/packages/views/issues/components/table-view-virtualized-hierarchy.test.tsxindex 067e059f0b..92df02caa8 100644--- a/packages/views/issues/components/table-view-virtualized-hierarchy.test.tsx+++ b/packages/views/issues/components/table-view-virtualized-hierarchy.test.tsx@@ -293,7 +293,6 @@ describe("Table view on the production virtualized hierarchy path", () => {listMembers: async () => [],listAgents: async () => [],listSquads: async () => [],- getAssigneeFrequency: async () => [],listIssueTableRows: async (request: IssueTableRowsRequest) => {const parent = request.parent_id ?? "root";rowRequests.push(parent);diff --git a/packages/views/layout/route-data-prefetch.test.tsx b/packages/views/layout/route-data-prefetch.test.tsxindex 0ea23c6df1..8cc05fd786 100644--- a/packages/views/layout/route-data-prefetch.test.tsx+++ b/packages/views/layout/route-data-prefetch.test.tsx@@ -83,7 +83,8 @@ describe("RouteDataPrefetch", () => {const warmed = keys();expect(warmed.length).toBeGreaterThan(0);expect(new Set(warmed).size).toBeGreaterThanOrEqual(5);- expect(warmed).toContain(JSON.stringify(["workspaces", "ws-1", "assignee-frequency"]));+ // The assignee picker ranks from local picks; nothing warms server counts.+ expect(warmed.some((key) => key.includes("assignee-frequency"))).toBe(false);});it("stays idle without a resolved workspace", () => {diff --git a/packages/views/layout/route-data-prefetch.tsx b/packages/views/layout/route-data-prefetch.tsxindex c3400ac767..8097f0bcbc 100644--- a/packages/views/layout/route-data-prefetch.tsx+++ b/packages/views/layout/route-data-prefetch.tsx@@ -19,7 +19,6 @@ import { runtimeProfileListOptions } from "@multica/core/runtimes";import { runtimeListOptions } from "@multica/core/runtimes/queries";import {agentListOptions,- assigneeFrequencyOptions,memberListOptions,skillListOptions,squadListOptions,@@ -128,9 +127,6 @@ export function RouteDataPrefetch({if (!wsId) return;const warm = () => {for (const key of guest ? GUEST_ROUTES : WARM_ON_IDLE) ROUTES[key](qc, wsId, userId);- // The assignee picker's Recent group, so it renders on the picker's- // first open instead of popping in after a fetch.- if (!guest) void qc.prefetchQuery(assigneeFrequencyOptions(wsId));};if (typeof window.requestIdleCallback === "function") {const id = window.requestIdleCallback(warm, { timeout: 3000 });diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsxindex a1cd92b930..b000d7b705 100644--- a/packages/views/modals/create-issue.test.tsx+++ b/packages/views/modals/create-issue.test.tsx@@ -34,6 +34,8 @@ function I18nWrapper({ children }: { children: ReactNode }) {const mockParentIssue = vi.hoisted(() => ({ value: null as Issue | null }));const mockPush = vi.hoisted(() => vi.fn());const mockCreateIssue = vi.hoisted(() => vi.fn());+const mockRecordAssigneePick = vi.hoisted(() => vi.fn());+const assigneePickerProps = vi.hoisted(() => ({ recordPicks: undefined as boolean | undefined }));type VoiceOptions = { insert: (text: string) => boolean; submit?: () => void };const voiceOptions = vi.hoisted(() => ({ last: null as VoiceOptions | null }));@@ -146,6 +148,7 @@ const emptyIssueDraft = () => ({startDate: null as string | null,assigneeType: undefined as "agent" | "squad" | "member" | undefined,assigneeId: undefined as string | undefined,+ assigneePick: undefined as { type: "agent" | "squad" | "member"; id: string } | undefined,labelIds: [] as string[],propertyValues: {} as Record<string, string | number | boolean | string[]>,},@@ -482,7 +485,19 @@ vi.mock("../issues/components", () => ({<div data-testid="priority-picker" onClick={() => onUpdate({ priority: "high" })} />),StagePicker: () => <div data-testid="stage-picker" />,- AssigneePicker: () => <div data-testid="assignee-picker" />,+ // Surface onUpdate so tests can drive manual picks.+ AssigneePicker: ({ onUpdate, recordPicks }: {+ onUpdate: (u: { assignee_type: string; assignee_id: string }) => void;+ recordPicks?: boolean;+ }) => {+ assigneePickerProps.recordPicks = recordPicks;+ return (+ <div data-testid="assignee-picker">+ <button type="button" onClick={() => onUpdate({ assignee_type: "member", assignee_id: "alice" })}>pick alice</button>+ <button type="button" onClick={() => onUpdate({ assignee_type: "agent", assignee_id: "bot" })}>pick bot</button>+ </div>+ );+ },// Surface open/onOpenChange so tests can assert progressive-disclosure// behavior (mounted only when the user has opted in or has a value).StartDatePicker: ({ open, onOpenChange }: { open?: boolean; onOpenChange?: (v: boolean) => void }) => (@@ -512,6 +527,10 @@ vi.mock("../issues/components", () => ({),}));+vi.mock("../issues/components/pickers/assignee-picker", () => ({+ useRecordAssigneePick: () => mockRecordAssigneePick,+}));+vi.mock("../issues/components/pickers/custom-property-picker", () => ({CustomPropertyValueInput: ({ property, onChange, open }: any) => (<button@@ -884,6 +903,132 @@ describe("CreateIssueModal", () => {expect(mockToastDismiss).toHaveBeenCalledWith("toast-1");});+ it("records only the assignee picked by hand and finally submitted", async () => {+ const user = userEvent.setup();+ renderModal(<CreateIssueModal onClose={vi.fn()} />);++ // The picker leaves recording to the dialog.+ expect(assigneePickerProps.recordPicks).toBe(false);+ await user.click(screen.getByRole("button", { name: "pick alice" }));+ await user.click(screen.getByRole("button", { name: "pick bot" }));+ expect(mockRecordAssigneePick).not.toHaveBeenCalled();++ await user.type(screen.getByPlaceholderText("Issue title"), "Assigned issue");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));++ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledWith("agent", "bot"));+ expect(mockRecordAssigneePick).toHaveBeenCalledTimes(1);+ expect(mockRecordAssigneePick).toHaveBeenCalledWith("agent", "bot");+ });++ it("does not record a remembered default assignee", async () => {+ const user = userEvent.setup();+ mockDraftStore.draft.manual.assigneeType = "member";+ mockDraftStore.draft.manual.assigneeId = "alice";+ renderModal(<CreateIssueModal onClose={vi.fn()} />);++ await user.type(screen.getByPlaceholderText("Issue title"), "Default assignee");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));++ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledWith("member", "alice"));+ expect(mockRecordAssigneePick).not.toHaveBeenCalled();+ });++ it("does not record re-picking the prefilled assignee", async () => {+ const user = userEvent.setup();+ mockDraftStore.draft.manual.assigneeType = "member";+ mockDraftStore.draft.manual.assigneeId = "alice";+ renderModal(<CreateIssueModal onClose={vi.fn()} />);++ await user.click(screen.getByRole("button", { name: "pick alice" }));+ await user.type(screen.getByPlaceholderText("Issue title"), "Same assignee");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));++ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledWith("member", "alice"));+ expect(mockRecordAssigneePick).not.toHaveBeenCalled();+ });++ it("records a pick made while an earlier create was in flight with that later create", async () => {+ const user = userEvent.setup();+ mockDraftStore.draft.manual.assigneeType = "member";+ mockDraftStore.draft.manual.assigneeId = "alice";+ let resolveCreate!: (v: unknown) => void;+ mockCreateIssue.mockImplementationOnce(+ () => new Promise((resolve) => { resolveCreate = resolve; }),+ );+ renderModal(<CreateIssueModal onClose={vi.fn()} />);++ await user.type(screen.getByPlaceholderText("Issue title"), "First");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ await waitFor(() => expect(mockCreateIssue).toHaveBeenCalledTimes(1));+ await user.click(screen.getByRole("button", { name: "pick bot" }));+ await act(async () => {+ resolveCreate({ id: "issue-1", identifier: "TES-1", title: "First", status: "todo", labels: [] });+ });+ // The first create submitted the prefilled assignee.+ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledTimes(1));+ expect(mockRecordAssigneePick).not.toHaveBeenCalled();++ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ await waitFor(() => expect(mockRecordAssigneePick).toHaveBeenCalledTimes(1));+ expect(mockRecordAssigneePick).toHaveBeenCalledWith("agent", "bot");+ });++ it("counts a hand pick once when the kept draft is submitted again", async () => {+ const user = userEvent.setup();+ let resolveCreate!: (v: unknown) => void;+ mockCreateIssue.mockImplementationOnce(+ () => new Promise((resolve) => { resolveCreate = resolve; }),+ );+ renderModal(<CreateIssueModal onClose={vi.fn()} />);++ await user.click(screen.getByRole("button", { name: "pick bot" }));+ await user.type(screen.getByPlaceholderText("Issue title"), "First");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ await waitFor(() => expect(mockCreateIssue).toHaveBeenCalledTimes(1));+ // Editing the title mid-flight keeps the draft open after success.+ await user.type(screen.getByPlaceholderText("Issue title"), " again");+ await act(async () => {+ resolveCreate({ id: "issue-1", identifier: "TES-1", title: "First", status: "todo", labels: [] });+ });+ await waitFor(() => expect(mockRecordAssigneePick).toHaveBeenCalledTimes(1));++ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ await waitFor(() => expect(mockCreateIssue).toHaveBeenCalledTimes(2));+ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledTimes(2));+ expect(mockRecordAssigneePick).toHaveBeenCalledTimes(1);+ });++ it("does not credit an earlier hand pick to a prefilled assignee", async () => {+ const user = userEvent.setup();+ mockDraftStore.draft.manual.assigneeType = "member";+ mockDraftStore.draft.manual.assigneeId = "alice";+ mockDraftStore.draft.manual.assigneePick = { type: "member", id: "alice" };+ renderModal(<CreateIssueModal onClose={vi.fn()} data={{ assignee_type: "agent", assignee_id: "bot" }} />);++ // Re-picking the prefilled assignee writes it into the draft.+ await user.click(screen.getByRole("button", { name: "pick bot" }));+ await user.type(screen.getByPlaceholderText("Issue title"), "Prefilled");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));++ await waitFor(() => expect(mockSetLastAssignee).toHaveBeenCalledWith("agent", "bot"));+ expect(mockRecordAssigneePick).not.toHaveBeenCalled();+ });++ it("records a hand-picked assignee kept in a reopened draft", async () => {+ const user = userEvent.setup();+ const first = renderModal(<CreateIssueModal onClose={vi.fn()} />);+ await user.click(screen.getByRole("button", { name: "pick bot" }));+ first.unmount();++ renderModal(<CreateIssueModal onClose={vi.fn()} />);+ await user.type(screen.getByPlaceholderText("Issue title"), "Reopened");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));++ await waitFor(() => expect(mockRecordAssigneePick).toHaveBeenCalledTimes(1));+ expect(mockRecordAssigneePick).toHaveBeenCalledWith("agent", "bot");+ });+it("starts a fresh create from todo without a remembered stage", async () => {const user = userEvent.setup();const first = renderModal(<CreateIssueModal onClose={vi.fn()} data={{diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsxindex fc038dbd5d..c4260be48e 100644--- a/packages/views/modals/create-issue.tsx+++ b/packages/views/modals/create-issue.tsx@@ -57,6 +57,7 @@ import { useIssueCreateUploads } from "./use-issue-create-uploads";import { useShortcut } from "@multica/core/shortcuts";import { ShortcutKeycaps } from "../common/shortcut-keycaps";import { StatusIcon, StatusPicker, PriorityIcon, PriorityPicker, StagePicker, AssigneePicker, StartDatePicker, DueDatePicker, LabelPicker } from "../issues/components";+import { useRecordAssigneePick } from "../issues/components/pickers/assignee-picker";import { maxSiblingStage } from "../issues/components/pickers/stage-picker";import { ProjectPicker } from "../projects/components/project-picker";import { useIssueTriggerPreview } from "../issues/hooks/use-issue-trigger-preview";@@ -302,6 +303,9 @@ export function ManualCreatePanel({return draft.manual.assigneeId;});const [assigneeCleared, setAssigneeCleared] = useState(data?.manual_assignee_cleared === true);+ const recordAssigneePick = useRecordAssigneePick();+ // The draft's pending hand pick that the request in flight submits.+ const submittedPickRef = useRef<IssueCreateDraft["manual"]["assigneePick"]>(undefined);const [startDate, setStartDate] = useState<string | null>(draft.manual.startDate);const [dueDate, setDueDate] = useState<string | null>((data?.due_date as string | undefined) ?? draft.shared.dueDate,@@ -417,9 +421,15 @@ export function ManualCreatePanel({const updateStatus = (v: IssueStatus) => { setStatus(v); setManual({ status: v }); };const updatePriority = (v: IssuePriority) => { setPriority(v); setShared({ priority: v }); };const updateAssignee = (type?: IssueAssigneeType, id?: string) => {+ // Re-picking the current assignee is not a new pick; clearing drops it.+ const changed = type !== assigneeType || id !== assigneeId;setAssigneeType(type); setAssigneeId(id);setAssigneeCleared(!id);- setManual({ assigneeType: type, assigneeId: id });+ setManual({+ assigneeType: type,+ assigneeId: id,+ ...(changed ? { assigneePick: type && id ? { type, id } : undefined } : {}),+ });};const updateProject = (id?: string) => { setProjectId(id); setShared({ projectId: id }); };const updateParent = (id?: string) => {@@ -547,6 +557,13 @@ export function ManualCreatePanel({const pendingDesc = descEditorRef.current?.flushPendingUpdate?.();if (pendingDesc != null) setManual({ description: pendingDesc });submittedDraftRef.current = useIssueDraftStore.getState().draft;+ // Only a hand pick of the submitted assignee feeds the picker's+ // ranking; a prefilled or remembered assignee never matches one.+ const pendingPick = submittedDraftRef.current.manual.assigneePick;+ submittedPickRef.current =+ pendingPick?.type === assigneeType && pendingPick?.id === assigneeId+ ? pendingPick+ : undefined;try {const description = descEditorRef.current?.getMarkdown()?.trim() || undefined;const activeAttachmentIds = draftAttachments@@ -823,6 +840,9 @@ export function ManualCreatePanel({}},onAccepted: () => {+ const pick = submittedPickRef.current;+ if (pick) recordAssigneePick(pick.type, pick.id);+ submittedPickRef.current = undefined;// Only the assignee persists across independent create sessions.setLastAssignee(assigneeType, assigneeId);setLastMode("manual");@@ -837,6 +857,11 @@ export function ManualCreatePanel({const untouched =useIssueDraftStore.getState().draft === submittedDraftRef.current;if (untouched) clearDraft();+ // A kept draft must not count the same pick again on its next create;+ // a newer pick made during the request stays.+ else if (pick && useIssueDraftStore.getState().draft.manual.assigneePick === pick) {+ setManual({ assigneePick: undefined });+ }if (!mountedRef.current || !untouched) return;if (keepOpen) {resetForNextIssue();@@ -1146,6 +1171,7 @@ export function ManualCreatePanel({u.assignee_type ?? undefined,u.assignee_id ?? undefined,)}+ recordPicks={false}triggerRender={<PillButton />}tooltip={tIssues(($) => $.detail.prop_assignee)}align="start"