Skip to content

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

Go

feat(views): Recent group in the assignee picker from server-side frequency (MUL-9704) (#11043)

Multica Eve43cfe54f3e45
diff --git a/packages/core/issues/mutations.ts b/packages/core/issues/mutations.ts
index 9331a3c955..d708f4484c 100644
--- a/packages/core/issues/mutations.ts
+++ b/packages/core/issues/mutations.ts
@@ -9,6 +9,7 @@ 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,
@@ -388,6 +389,8 @@ 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/workspace/queries.test.ts b/packages/core/workspace/queries.test.ts
index 63bbc258fd..b3e2212487 100644
--- a/packages/core/workspace/queries.test.ts
+++ b/packages/core/workspace/queries.test.ts
@@ -1,6 +1,12 @@
-import { describe, expect, it } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { setApiInstance } from "../api";
+import { createQueryClient } from "../query-client";
import type { Agent, Workspace } from "../types";
-import { agentListOptions, workspaceBySlugOptions } from "./queries";
+import {
+ agentListOptions,
+ assigneeFrequencyOptions,
+ workspaceBySlugOptions,
+} from "./queries";
function makeWorkspace(slug: string): Workspace {
return {
@@ -65,3 +71,29 @@ 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.ts
index 82a99a6695..8c0417e5ca 100644
--- a/packages/core/workspace/queries.ts
+++ b/packages/core/workspace/queries.ts
@@ -229,6 +229,12 @@ 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,
});
}
diff --git a/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx b/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx
new file mode 100644
index 0000000000..6c71b16c53
--- /dev/null
+++ b/packages/views/issues/components/pickers/assignee-picker.recent.test.tsx
@@ -0,0 +1,168 @@
+// The assignee picker's Recent group: the current user's top 3 assignees from
+// the server-side assignee-frequency counts.
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { 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 { AssigneePicker } from "./assignee-picker";
+
+const MEMBERS = [
+ { user_id: "user-1", name: "Ada Lovelace", role: "member" },
+ { user_id: "user-2", name: "Grace Hopper", role: "member" },
+];
+const AGENTS = [
+ { id: "agent-1", name: "Builder", archived_at: null, visibility: "workspace" },
+ { id: "agent-2", name: "Retired", archived_at: "2026-01-01T00:00:00Z", visibility: "workspace" },
+];
+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[] = [];
+
+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: [] };
+ },
+}));
+
+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"] }),
+ agentListOptions: () => ({ queryKey: ["agents"] }),
+ squadListOptions: () => ({ queryKey: ["squads"] }),
+ assigneeFrequencyOptions: () => ({ queryKey: ["frequency"] }),
+}));
+vi.mock("../../../common/actor-avatar", () => ({
+ ActorAvatar: () => <span data-testid="actor-avatar" />,
+}));
+
+function picker(onUpdate: () => void) {
+ return (
+ <I18nProvider locale="en" resources={{ en: { issues: enIssues } }}>
+ <AssigneePicker
+ assigneeType={null}
+ assigneeId={null}
+ onUpdate={onUpdate}
+ open
+ onOpenChange={() => {}}
+ />
+ </I18nProvider>
+ );
+}
+
+function renderPicker(onUpdate: () => void = () => {}) {
+ return render(picker(onUpdate));
+}
+
+/** Row names inside the Recent section, in display order. */
+async function recentRows(): Promise<string[]> {
+ const label = await screen.findByText("Recent");
+ const section = label.parentElement as HTMLElement;
+ return Array.from(section.querySelectorAll("[data-picker-item]")).map(
+ (el) => el.textContent ?? "",
+ );
+}
+
+describe("AssigneePicker Recent group", () => {
+ beforeEach(() => {
+ frequency = [];
+ });
+
+ it("is hidden without frequency data", 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 },
+ ];
+ renderPicker();
+
+ expect(await recentRows()).toEqual(["Platform", "Builder", "Ada Lovelace"]);
+ // Recent sits between the Unassigned row and Members.
+ const follows = (a: Node, b: Node) =>
+ Boolean(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING);
+ const unassignedRow = screen.getAllByText("Unassigned").at(-1)!;
+ const recentLabel = screen.getByText("Recent");
+ expect(follows(unassignedRow, recentLabel)).toBe(true);
+ expect(follows(recentLabel, screen.getByText("Members"))).toBe(true);
+ // The same actors still appear in their own groups.
+ 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 },
+ ];
+ renderPicker();
+
+ expect(await recentRows()).toEqual(["Grace Hopper"]);
+ });
+
+ it("assigns from a Recent row", async () => {
+ frequency = [{ assignee_type: "agent", assignee_id: "agent-1", frequency: 4 }];
+ const user = userEvent.setup();
+ const onUpdate = vi.fn();
+ renderPicker(onUpdate);
+
+ const section = (await screen.findByText("Recent")).parentElement as HTMLElement;
+ await user.click(within(section).getByText("Builder"));
+
+ expect(onUpdate).toHaveBeenCalledWith({ assignee_type: "agent", assignee_id: "agent-1" });
+ });
+
+ it("is hidden while searching so Enter picks the first match", async () => {
+ frequency = [{ assignee_type: "member", assignee_id: "user-1", frequency: 6 }];
+ const user = userEvent.setup();
+ const onUpdate = vi.fn();
+ renderPicker(onUpdate);
+
+ await screen.findByText("Recent");
+ await user.type(screen.getByPlaceholderText("Assign to..."), "grace");
+ expect(screen.queryByText("Recent")).toBeNull();
+
+ await user.keyboard("{Enter}");
+ expect(onUpdate).toHaveBeenCalledWith({ assignee_type: "member", assignee_id: "user-2" });
+ });
+
+ it("keeps the keyboard highlight on the same row when Recent loads late", async () => {
+ const user = userEvent.setup();
+ const onUpdate = vi.fn();
+ const { rerender } = renderPicker(onUpdate);
+
+ await screen.findByText("Members");
+ // Unassigned, then Ada Lovelace.
+ 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 }];
+ rerender(picker(onUpdate));
+ await screen.findByText("Recent");
+
+ await user.keyboard("{Enter}");
+ expect(onUpdate).toHaveBeenCalledWith({ assignee_type: "member", assignee_id: "user-1" });
+ });
+});
diff --git a/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsx b/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsx
new file mode 100644
index 0000000000..d987fbf500
--- /dev/null
+++ b/packages/views/issues/components/pickers/assignee-picker.reopen.test.tsx
@@ -0,0 +1,72 @@
+// 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.tsx
index 0a379385c4..52ad6b4a0b 100644
--- a/packages/views/issues/components/pickers/assignee-picker.tsx
+++ b/packages/views/issues/components/pickers/assignee-picker.tsx
@@ -2,7 +2,7 @@
import { useMemo, useState } from "react";
import { Lock, UserMinus } from "@multica/ui/icons";
-import type { Agent, IssueAssigneeType, UpdateIssueRequest } from "@multica/core/types";
+import type { Agent, IssueAssigneeType, MemberWithUser, Squad, UpdateIssueRequest } from "@multica/core/types";
import { useQuery } from "@tanstack/react-query";
import { useAuthStore } from "@multica/core/auth";
import { isAgentRuntimeBound } from "@multica/core/agents";
@@ -110,7 +110,7 @@ function AssigneePickerImpl({
const open = controlledOpen ?? internalOpen;
const setOpen = controlledOnOpenChange ?? setInternalOpen;
const [filter, setFilter] = useState("");
- const choices = useAssigneeChoices(filter);
+ const choices = useAssigneeChoices(filter, open);
const { getActorName } = useActorName();
const triggerLabel =
@@ -199,13 +199,18 @@ export function AssigneePickerPanel({
);
}
-function useAssigneeChoices(filter: string) {
+/** `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) {
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));
+ const { data: frequency = [] } = useQuery({
+ ...assigneeFrequencyOptions(wsId),
+ enabled: open,
+ });
const currentMember = members.find((m) => m.user_id === user?.id);
const memberRole = currentMember?.role;
@@ -231,6 +236,29 @@ function useAssigneeChoices(filter: string) {
const filteredSquads = squads
.filter((s) => !s.archived_at && (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 — member removed, agent/squad archived — 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 (member) recent.push({ type: "member", member });
+ } else if (entry.assignee_type === "agent") {
+ const agent = agents.find((a) => a.id === entry.assignee_id && !a.archived_at);
+ if (agent) recent.push({ type: "agent", agent });
+ } else if (entry.assignee_type === "squad") {
+ const squad = squads.find((s) => s.id === entry.assignee_id && !s.archived_at);
+ if (squad) recent.push({ type: "squad", squad });
+ }
+ }
+ }
const runnableAgentIds = new Set(
agents
.filter((agent) => !agent.archived_at && isAgentRuntimeBound(agent))
@@ -240,6 +268,7 @@ function useAssigneeChoices(filter: string) {
return {
userId: user?.id ?? null,
memberRole,
+ recent,
filteredMembers,
filteredAgents,
filteredSquads,
@@ -247,6 +276,11 @@ function useAssigneeChoices(filter: string) {
};
}
+type RecentAssignee =
+ | { type: "member"; member: MemberWithUser }
+ | { type: "agent"; agent: Agent }
+ | { type: "squad"; squad: Squad };
+
function AssigneeOptions({
choices,
filter,
@@ -263,12 +297,97 @@ function AssigneeOptions({
onPick: (updates: Partial<UpdateIssueRequest>) => void;
}) {
const { t } = useT("issues");
- const { userId, memberRole, filteredMembers, filteredAgents, filteredSquads, runnableAgentIds } =
+ const { userId, memberRole, recent, filteredMembers, filteredAgents, filteredSquads, runnableAgentIds } =
choices;
const isSelected = (type: string, id: string) =>
assigneeType === type && assigneeId === id;
+ // Shared by Recent and the per-type groups so disabled state, tooltips and
+ // the private lock render identically wherever an actor shows up.
+ const renderMember = (m: MemberWithUser) => (
+ <PickerItem
+ key={m.user_id}
+ selected={isSelected("member", m.user_id)}
+ onClick={() =>
+ onPick({
+ assignee_type: "member",
+ assignee_id: m.user_id,
+ })
+ }
+ >
+ <ActorAvatar actorType="member" actorId={m.user_id} size="sm" />
+ <span className="truncate">{m.name}</span>
+ </PickerItem>
+ );
+
+ const renderAgent = (a: Agent) => {
+ const decision = canAssignAgentToIssue(a, {
+ userId,
+ role:
+ memberRole === "owner" ||
+ memberRole === "admin" ||
+ memberRole === "member"
+ ? memberRole
+ : null,
+ });
+ const runtimeBound = isAgentRuntimeBound(a);
+ const allowed = decision.allowed && runtimeBound;
+ return (
+ <PickerItem
+ key={a.id}
+ selected={isSelected("agent", a.id)}
+ disabled={!allowed}
+ tooltip={
+ !decision.allowed
+ ? decision.message
+ : !runtimeBound
+ ? t(($) => $.pickers.assignee.agent_runtime_required)
+ : undefined
+ }
+ onClick={() => {
+ if (!allowed) return;
+ onPick({
+ assignee_type: "agent",
+ assignee_id: a.id,
+ });
+ }}
+ >
+ <ActorAvatar actorType="agent" actorId={a.id} size="sm" showStatusDot />
+ <span className={`truncate ${allowed ? "" : "text-muted-foreground"}`}>{a.name}</span>
+ {a.visibility === "private" && (
+ <Lock className="ml-auto h-3 w-3 text-muted-foreground" />
+ )}
+ </PickerItem>
+ );
+ };
+
+ const renderSquad = (s: Squad) => {
+ const runtimeBound = runnableAgentIds.has(s.leader_id);
+ return (
+ <PickerItem
+ key={s.id}
+ selected={isSelected("squad", s.id)}
+ disabled={!runtimeBound}
+ tooltip={
+ runtimeBound
+ ? undefined
+ : t(($) => $.pickers.assignee.squad_runtime_required)
+ }
+ onClick={() => {
+ if (!runtimeBound) return;
+ onPick({
+ assignee_type: "squad",
+ assignee_id: s.id,
+ });
+ }}
+ >
+ <ActorAvatar actorType="squad" actorId={s.id} size="sm" />
+ <span className="truncate">{s.name}</span>
+ </PickerItem>
+ );
+ };
+
return (
<>
{/* Unassigned — always the first row, search active or not. Every
@@ -283,70 +402,29 @@ function AssigneeOptions({
<span className="text-muted-foreground">{t(($) => $.pickers.assignee.trigger_unassigned)}</span>
</PickerItem>
- {/* Members */}
+ {/* Recent — empty (and hidden) while searching or without history. The
+ same actors still appear in their own groups below. */}
+ {recent.length > 0 && (
+ <PickerSection label={t(($) => $.pickers.assignee.recent_group)}>
+ {recent.map((r) =>
+ r.type === "member"
+ ? renderMember(r.member)
+ : r.type === "agent"
+ ? renderAgent(r.agent)
+ : renderSquad(r.squad),
+ )}
+ </PickerSection>
+ )}
+
{filteredMembers.length > 0 && (
<PickerSection label={t(($) => $.pickers.assignee.members_group)}>
- {filteredMembers.map((m) => (
- <PickerItem
- key={m.user_id}
- selected={isSelected("member", m.user_id)}
- onClick={() =>
- onPick({
- assignee_type: "member",
- assignee_id: m.user_id,
- })
- }
- >
- <ActorAvatar actorType="member" actorId={m.user_id} size="sm" />
- <span className="truncate">{m.name}</span>
- </PickerItem>
- ))}
+ {filteredMembers.map(renderMember)}
</PickerSection>
)}
- {/* Agents */}
{filteredAgents.length > 0 && (
<PickerSection label={t(($) => $.pickers.assignee.agents_group)}>
- {filteredAgents.map((a) => {
- const decision = canAssignAgentToIssue(a, {
- userId,
- role:
- memberRole === "owner" ||
- memberRole === "admin" ||
- memberRole === "member"
- ? memberRole
- : null,
- });
- const runtimeBound = isAgentRuntimeBound(a);
- const allowed = decision.allowed && runtimeBound;
- return (
- <PickerItem
- key={a.id}
- selected={isSelected("agent", a.id)}
- disabled={!allowed}
- tooltip={
- !decision.allowed
- ? decision.message
- : !runtimeBound
- ? t(($) => $.pickers.assignee.agent_runtime_required)
- : undefined
- }
- onClick={() => {
- if (!allowed) return;
- onPick({
- assignee_type: "agent",
- assignee_id: a.id,
- });
- }}
- >
- <ActorAvatar actorType="agent" actorId={a.id} size="sm" showStatusDot />
- <span className={`truncate ${allowed ? "" : "text-muted-foreground"}`}>{a.name}</span>
- {a.visibility === "private" && (
- <Lock className="ml-auto h-3 w-3 text-muted-foreground" />
- )}
- </PickerItem>
- );
- })}
+ {filteredAgents.map(renderAgent)}
</PickerSection>
)}
@@ -354,31 +432,7 @@ function AssigneeOptions({
its leader agent on the backend. */}
{filteredSquads.length > 0 && (
<PickerSection label={t(($) => $.pickers.assignee.squads_group)}>
- {filteredSquads.map((s) => {
- const runtimeBound = runnableAgentIds.has(s.leader_id);
- return (
- <PickerItem
- key={s.id}
- selected={isSelected("squad", s.id)}
- disabled={!runtimeBound}
- tooltip={
- runtimeBound
- ? undefined
- : t(($) => $.pickers.assignee.squad_runtime_required)
- }
- onClick={() => {
- if (!runtimeBound) return;
- onPick({
- assignee_type: "squad",
- assignee_id: s.id,
- });
- }}
- >
- <ActorAvatar actorType="squad" actorId={s.id} size="sm" />
- <span className="truncate">{s.name}</span>
- </PickerItem>
- );
- })}
+ {filteredSquads.map(renderSquad)}
</PickerSection>
)}
diff --git a/packages/views/issues/components/pickers/property-picker.tsx b/packages/views/issues/components/pickers/property-picker.tsx
index ea531b1955..364f33c564 100644
--- a/packages/views/issues/components/pickers/property-picker.tsx
+++ b/packages/views/issues/components/pickers/property-picker.tsx
@@ -156,7 +156,10 @@ export function PickerPanel({
const placeholder = searchPlaceholder ?? t(($) => $.filters.placeholder);
const filterAria = t(($) => $.pickers.filter_options_aria);
const [query, setQuery] = useState("");
- const [highlightedIndex, setHighlightedIndex] = useState(-1);
+ // The highlighted row itself, not its position: rows that load late (the
+ // assignee picker's Recent group) can insert above it, and Enter must still
+ // commit the row the user sees highlighted.
+ const [highlighted, setHighlighted] = useState<HTMLButtonElement | null>(null);
const listRef = useRef<HTMLDivElement>(null);
const getItems = useCallback(() => {
@@ -166,7 +169,7 @@ export function PickerPanel({
);
}, []);
- // Typing re-highlights the first *real* match. The index can't be computed
+ // Typing re-highlights the first *real* match. The row can't be resolved
// in the input's onChange handler — the filtered list hasn't rendered yet —
// so the keystroke raises a flag and this effect resolves it against the
// fresh DOM. Guarding on the flag keeps arrow keys free to walk back onto
@@ -175,22 +178,18 @@ export function PickerPanel({
useEffect(() => {
if (!pendingSearchHighlight.current) return;
pendingSearchHighlight.current = false;
- const items = getItems();
- // -1 when the query matches nothing (only the empty row is left), which
+ // None when the query matches nothing (only the empty row is left), which
// leaves Enter inert instead of clearing the field.
- setHighlightedIndex(items.findIndex((item) => !isEmptyItem(item)));
+ setHighlighted(getItems().find((item) => !isEmptyItem(item)) ?? null);
}, [children, getItems]);
- // Apply/remove highlight class via DOM when index changes
+ // Apply/remove highlight class via DOM. A highlighted row that left the list
+ // simply stops matching, so it is neither painted nor committed.
useEffect(() => {
- const items = getItems();
- for (const item of items) {
- item.classList.remove(HIGHLIGHT_CLASS);
+ for (const item of getItems()) {
+ item.classList.toggle(HIGHLIGHT_CLASS, item === highlighted);
}
- if (highlightedIndex >= 0 && highlightedIndex < items.length) {
- items[highlightedIndex]?.classList.add(HIGHLIGHT_CLASS);
- }
- }, [highlightedIndex, getItems, children]); // re-run when children change (filtered list updates)
+ }, [highlighted, getItems, children]); // re-run when children change (filtered list updates)
// Reset the search state on the open -> closed transition rather than inside
// an open-change handler. Every picker closes itself after a selection by
@@ -201,7 +200,7 @@ export function PickerPanel({
useEffect(() => {
if (wasOpen.current && !open) {
setQuery("");
- setHighlightedIndex(-1);
+ setHighlighted(null);
onSearchChange?.("");
}
wasOpen.current = open;
@@ -215,24 +214,19 @@ export function PickerPanel({
const items = getItems();
if (items.length === 0) return;
- if (e.key === "ArrowDown") {
- e.preventDefault();
- setHighlightedIndex((prev) => {
- const next = prev < items.length - 1 ? prev + 1 : 0;
- items[next]?.scrollIntoView({ block: "nearest" });
- return next;
- });
- } else if (e.key === "ArrowUp") {
+ const current = highlighted ? items.indexOf(highlighted) : -1;
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
e.preventDefault();
- setHighlightedIndex((prev) => {
- const next = prev > 0 ? prev - 1 : items.length - 1;
- items[next]?.scrollIntoView({ block: "nearest" });
- return next;
- });
+ const next =
+ e.key === "ArrowDown"
+ ? current < items.length - 1 ? current + 1 : 0
+ : current > 0 ? current - 1 : items.length - 1;
+ items[next]?.scrollIntoView({ block: "nearest" });
+ setHighlighted(items[next] ?? null);
} else if (e.key === "Enter") {
e.preventDefault();
- if (highlightedIndex >= 0 && highlightedIndex < items.length) {
- items[highlightedIndex]?.click();
+ if (current >= 0) {
+ items[current]?.click();
} else if (items.length === 1 && !isEmptyItem(items[0])) {
// Auto-select when only one result. The empty row is excluded: a
// query with no matches leaves it as the sole item, and Enter there
@@ -241,7 +235,7 @@ export function PickerPanel({
}
}
},
- [getItems, highlightedIndex],
+ [getItems, highlighted],
);
return (
diff --git a/packages/views/layout/route-data-prefetch.test.tsx b/packages/views/layout/route-data-prefetch.test.tsx
index 5d5ab1341a..0ea23c6df1 100644
--- a/packages/views/layout/route-data-prefetch.test.tsx
+++ b/packages/views/layout/route-data-prefetch.test.tsx
@@ -83,6 +83,7 @@ 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"]));
});
it("stays idle without a resolved workspace", () => {
diff --git a/packages/views/layout/route-data-prefetch.tsx b/packages/views/layout/route-data-prefetch.tsx
index 8097f0bcbc..c3400ac767 100644
--- a/packages/views/layout/route-data-prefetch.tsx
+++ b/packages/views/layout/route-data-prefetch.tsx
@@ -19,6 +19,7 @@ import { runtimeProfileListOptions } from "@multica/core/runtimes";
import { runtimeListOptions } from "@multica/core/runtimes/queries";
import {
agentListOptions,
+ assigneeFrequencyOptions,
memberListOptions,
skillListOptions,
squadListOptions,
@@ -127,6 +128,9 @@ 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/locales/en/issues.json b/packages/views/locales/en/issues.json
index 7183315639..134db259ab 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -1130,6 +1130,7 @@
"assignee": {
"trigger_unassigned": "Unassigned",
"search_placeholder": "Assign to...",
+ "recent_group": "Recent",
"members_group": "Members",
"agents_group": "Agents",
"squads_group": "Squads",
diff --git a/packages/views/locales/es/issues.json b/packages/views/locales/es/issues.json
index 39160172f5..b20387c366 100644
--- a/packages/views/locales/es/issues.json
+++ b/packages/views/locales/es/issues.json
@@ -1044,6 +1044,7 @@
"assignee": {
"trigger_unassigned": "Sin asignar",
"search_placeholder": "Asignar a...",
+ "recent_group": "Recientes",
"members_group": "Miembros",
"agents_group": "Agentes",
"squads_group": "Squads",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index a404c2828a..dcaf65a753 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -1130,6 +1130,7 @@
"assignee": {
"trigger_unassigned": "Non assigné",
"search_placeholder": "Assigner à...",
+ "recent_group": "Récents",
"members_group": "Membres",
"agents_group": "Agents",
"squads_group": "Squads",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index e8884d4b03..3f73c305eb 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -1075,6 +1075,7 @@
"assignee": {
"trigger_unassigned": "未割り当て",
"search_placeholder": "担当者を割り当て...",
+ "recent_group": "最近",
"members_group": "メンバー",
"agents_group": "エージェント",
"squads_group": "スクワッド",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 2360b0fda3..d4b09dd3ac 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -1075,6 +1075,7 @@
"assignee": {
"trigger_unassigned": "담당자 없음",
"search_placeholder": "담당자 지정...",
+ "recent_group": "최근",
"members_group": "멤버",
"agents_group": "에이전트",
"squads_group": "스쿼드",
diff --git a/packages/views/locales/ru/issues.json b/packages/views/locales/ru/issues.json
index 3737decc33..7e1eb11bab 100644
--- a/packages/views/locales/ru/issues.json
+++ b/packages/views/locales/ru/issues.json
@@ -1239,6 +1239,7 @@
"assignee": {
"trigger_unassigned": "Не назначено",
"search_placeholder": "Назначить на...",
+ "recent_group": "Недавние",
"members_group": "Участники",
"agents_group": "Агенты",
"squads_group": "Команды",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 2f6667c640..7b6924dac5 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -1075,6 +1075,7 @@
"assignee": {
"trigger_unassigned": "未分配",
"search_placeholder": "分配给...",
+ "recent_group": "最近",
"members_group": "成员",
"agents_group": "智能体",
"squads_group": "小队",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 1d88f3ee6d..0523a17e3c 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -1075,6 +1075,7 @@
"assignee": {
"trigger_unassigned": "未分配",
"search_placeholder": "分配給...",
+ "recent_group": "最近",
"members_group": "成員",
"agents_group": "AI 代理",
"squads_group": "小隊",