Skip to content

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

Go

MUL-8498 feat(views): add Read state → Unread filter (#9842)

Jiayuan Zhange4a9bb5bcf10
diff --git a/packages/core/issue-statuses/archive.ts b/packages/core/issue-statuses/archive.ts
index f830ac9a64..f5d1509124 100644
--- a/packages/core/issue-statuses/archive.ts
+++ b/packages/core/issue-statuses/archive.ts
@@ -24,7 +24,7 @@ export function createIssueStatusListStore(key: string) {
creatorFilters: [], projectFilters: [], includeNoProject: false,
labelFilters: [], relationFilters: [], dueDateFilters: [], negatedFilters: [],
propertyFilters: {}, advancedFilter: null, dateFilter: null,
- agentRunningFilter: false, showSubIssues: true,
+ agentRunningFilter: false, unreadFilter: false, showSubIssues: true,
hiddenStatuses: [], listCollapsedStatuses: [],
}));
}
diff --git a/packages/core/issue-views/baseline.test.ts b/packages/core/issue-views/baseline.test.ts
index 7f3e6ce91f..414ccc8563 100644
--- a/packages/core/issue-views/baseline.test.ts
+++ b/packages/core/issue-views/baseline.test.ts
@@ -116,3 +116,16 @@ describe("baselineFromQuery agent running", () => {
expect(issueViewFilterCount({ agentRunningFilter: true, statusFilters: ["todo"] })).toBe(2);
});
});
+
+describe("baselineFromQuery unread", () => {
+ it("fixes the filter only when the view saved it as true", () => {
+ expect(baselineFromQuery({ unreadFilter: true }).unread).toBe(true);
+ expect(baselineFromQuery({ unreadFilter: true }).raw.unreadFilter).toBe(true);
+ expect(baselineFromQuery({ unreadFilter: "yes" }).unread).toBe(false);
+ expect(baselineFromQuery({}).raw.unreadFilter).toBe(false);
+ });
+
+ it("counts as one condition in the view summary", () => {
+ expect(issueViewFilterCount({ unreadFilter: true, statusFilters: ["todo"] })).toBe(2);
+ });
+});
diff --git a/packages/core/issue-views/baseline.ts b/packages/core/issue-views/baseline.ts
index 839150db6a..194fdf4f00 100644
--- a/packages/core/issue-views/baseline.ts
+++ b/packages/core/issue-views/baseline.ts
@@ -41,6 +41,7 @@ export interface IssueViewBaseline {
/** Dimensions the view saved as "is not". */
negated: Set<NegatableFilterDimension>;
agentRunning: boolean;
+ unread: boolean;
/** Property definition id → fixed member keys (`propertyFilterValueKey`). */
property: Map<string, Set<string>>;
/** Enum-sanitized snapshot, safe to hand straight to `resetFiltersTo`. */
@@ -125,6 +126,7 @@ export function baselineFromQuery(query: Record<string, unknown>): IssueViewBase
const includeNoAssignee = query.includeNoAssignee === true;
const includeNoProject = query.includeNoProject === true;
const agentRunningFilter = query.agentRunningFilter === true;
+ const unreadFilter = query.unreadFilter === true;
const propertyFilters: Record<string, PropertyFilterValue[]> = {};
const property = new Map<string, Set<string>>();
@@ -154,6 +156,7 @@ export function baselineFromQuery(query: Record<string, unknown>): IssueViewBase
dueDate: new Set(dueDateFilters),
negated: new Set(negatedFilters),
agentRunning: agentRunningFilter,
+ unread: unreadFilter,
property,
raw: {
statusFilters,
@@ -171,6 +174,7 @@ export function baselineFromQuery(query: Record<string, unknown>): IssueViewBase
propertyFilters,
advancedFilter,
agentRunningFilter,
+ unreadFilter,
},
};
}
@@ -190,6 +194,7 @@ export function issueViewFilterCount(query: Record<string, unknown>): number {
raw.relationFilters.length,
raw.dueDateFilters.length,
raw.agentRunningFilter,
+ raw.unreadFilter,
].filter(Boolean).length +
Object.keys(raw.propertyFilters).length +
countAdvancedConditions(raw.advancedFilter)
diff --git a/packages/core/issue-views/definition.test.ts b/packages/core/issue-views/definition.test.ts
index 8a57192029..bcfc8ea808 100644
--- a/packages/core/issue-views/definition.test.ts
+++ b/packages/core/issue-views/definition.test.ts
@@ -125,3 +125,30 @@ describe("agent running in a saved view", () => {
expect(isIssueViewModified(legacy, store.getState()).filters).toBe(false);
});
});
+
+describe("unread in a saved view", () => {
+ const view = { query: { unreadFilter: true }, display: {} };
+
+ it("saves the filter and opens with it on, unmodified", () => {
+ const store = liveStateFor(view);
+ expect(store.getState().unreadFilter).toBe(true);
+ expect(issueViewDefinitionFromState(store.getState()).query).toMatchObject({
+ unreadFilter: true,
+ });
+ expect(isIssueViewModified(view, store.getState()).filters).toBe(false);
+ });
+
+ it("reports turning it off as a modified filter", () => {
+ const store = liveStateFor(view);
+ store.getState().toggleUnreadFilter();
+ expect(isIssueViewModified(view, store.getState()).filters).toBe(true);
+ expect([...modifiedFilterDimensions(view, store.getState())]).toEqual(["unread"]);
+ });
+
+ it("treats a view saved before the filter existed as off", () => {
+ const legacy = { query: { statusFilters: ["todo"] }, display: {} };
+ const store = liveStateFor(legacy);
+ expect(store.getState().unreadFilter).toBe(false);
+ expect(isIssueViewModified(legacy, store.getState()).filters).toBe(false);
+ });
+});
diff --git a/packages/core/issue-views/definition.ts b/packages/core/issue-views/definition.ts
index ae1d25b4c3..9f43ed08fa 100644
--- a/packages/core/issue-views/definition.ts
+++ b/packages/core/issue-views/definition.ts
@@ -41,6 +41,7 @@ export function issueViewDefinitionFromState(state: IssueViewState): IssueViewDe
propertyFilters: state.propertyFilters,
advancedFilter: pruneAdvancedFilter(state.advancedFilter),
agentRunningFilter: state.agentRunningFilter,
+ unreadFilter: state.unreadFilter,
},
display: {
showSubIssues: state.showSubIssues,
@@ -152,6 +153,7 @@ export function modifiedFilterDimensions(
}
if (seed.advancedFilter !== live.advancedFilter) modified.add("advanced");
if (seed.agentRunningFilter !== live.agentRunningFilter) modified.add("agentRunning");
+ if (seed.unreadFilter !== live.unreadFilter) modified.add("unread");
return modified;
}
diff --git a/packages/core/issue-views/unread-view.ts b/packages/core/issue-views/unread-view.ts
new file mode 100644
index 0000000000..255cbb38b4
--- /dev/null
+++ b/packages/core/issue-views/unread-view.ts
@@ -0,0 +1,37 @@
+import type { IssueView } from "../api/schemas";
+import { baselineFromQuery, type IssueViewBaseline } from "./baseline";
+
+/**
+ * The built-in "Unread" view: All issues filtered on the viewer's unread
+ * marks. It is not stored on the server. The workspace issues page opens it
+ * through the same `?view=` id as a saved view, and this definition stands
+ * in for the saved one.
+ */
+export const UNREAD_VIEW_ID = "unread";
+
+export const UNREAD_VIEW: IssueView = {
+ id: UNREAD_VIEW_ID,
+ workspace_id: "",
+ owner_id: "",
+ name: "",
+ scope_type: "workspace",
+ scope_id: null,
+ scope_variant: null,
+ visibility: "private",
+ definition_version: 1,
+ query: { unreadFilter: true },
+ display: {},
+ revision: 1,
+ created_at: "",
+ updated_at: "",
+};
+
+/**
+ * Saved views can be edited, so their filters stay removable. This one has no
+ * editor: the unread condition is fixed, and clearing filters returns to it.
+ */
+export const UNREAD_VIEW_BASELINE: IssueViewBaseline = baselineFromQuery(UNREAD_VIEW.query);
+
+export function isUnreadView(view: Pick<IssueView, "id"> | null | undefined): boolean {
+ return view?.id === UNREAD_VIEW_ID;
+}
diff --git a/packages/core/issue-views/use-active-view.test.tsx b/packages/core/issue-views/use-active-view.test.tsx
new file mode 100644
index 0000000000..82a26e02e8
--- /dev/null
+++ b/packages/core/issue-views/use-active-view.test.tsx
@@ -0,0 +1,55 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { act, renderHook, waitFor } from "@testing-library/react";
+import { QueryClientProvider, type QueryClient } from "@tanstack/react-query";
+import type { ReactNode } from "react";
+import { setApiInstance } from "../api";
+import type { ApiClient } from "../api/client";
+import { createQueryClient } from "../query-client";
+import { issueViewContainerKey, useActiveIssueViewStore } from "./active-view-store";
+import { UNREAD_VIEW_ID } from "./unread-view";
+import { useActiveIssueView } from "./use-active-view";
+import type { IssueViewScope } from "./queries";
+
+const WORKSPACE: IssueViewScope = { scope_type: "workspace" };
+const PROJECT: IssueViewScope = { scope_type: "project", scope_id: "p1" };
+
+describe("useActiveIssueView and the built-in Unread view", () => {
+ let qc: QueryClient;
+
+ function render(scope: IssueViewScope) {
+ return renderHook(() => useActiveIssueView("ws-1", scope), {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ <QueryClientProvider client={qc}>{children}</QueryClientProvider>
+ ),
+ });
+ }
+
+ beforeEach(() => {
+ qc = createQueryClient();
+ setApiInstance({ listIssueViews: vi.fn(async () => []) } as unknown as ApiClient);
+ useActiveIssueViewStore.setState({ active: {} });
+ });
+
+ afterEach(() => {
+ qc.clear();
+ vi.restoreAllMocks();
+ });
+
+ it("opens on the workspace page without a saved view behind it", async () => {
+ act(() => useActiveIssueViewStore.getState().setActive(issueViewContainerKey("ws-1", WORKSPACE), UNREAD_VIEW_ID));
+ const { result } = render(WORKSPACE);
+ await waitFor(() => expect(result.current.viewsReady).toBe(true));
+ expect(result.current.activeView).toMatchObject({ id: UNREAD_VIEW_ID, query: { unreadFilter: true } });
+ expect(result.current.missing).toBe(false);
+ });
+
+ it("is not a view on other surfaces, so the id there reads as missing", async () => {
+ act(() => useActiveIssueViewStore.getState().setActive(issueViewContainerKey("ws-1", PROJECT), UNREAD_VIEW_ID));
+ const { result } = render(PROJECT);
+ await waitFor(() => expect(result.current.missing).toBe(true));
+ expect(result.current.activeView).toBeNull();
+ });
+});
diff --git a/packages/core/issue-views/use-active-view.ts b/packages/core/issue-views/use-active-view.ts
index 6267cc9dbb..0516365554 100644
--- a/packages/core/issue-views/use-active-view.ts
+++ b/packages/core/issue-views/use-active-view.ts
@@ -8,6 +8,7 @@ import {
issueViewContainerKey,
useActiveIssueViewStore,
} from "./active-view-store";
+import { UNREAD_VIEW, UNREAD_VIEW_ID } from "./unread-view";
const EMPTY_VIEWS: IssueView[] = [];
@@ -32,9 +33,10 @@ export function useActiveIssueView(
enabled: !!scope && !!wsId,
});
const views = listQuery.data ?? EMPTY_VIEWS;
- const activeView = activeViewId
- ? (views.find((v) => v.id === activeViewId) ?? null)
- : null;
+ const builtinView =
+ scope?.scope_type === "workspace" && activeViewId === UNREAD_VIEW_ID ? UNREAD_VIEW : null;
+ const activeView =
+ builtinView ?? (activeViewId ? (views.find((v) => v.id === activeViewId) ?? null) : null);
// "Missing" must never fire off a STALE list: right after a create the
// active id is set before the invalidated list lands, and treating that
// gap as "view deleted" bounces the surface back to the default tab.
diff --git a/packages/core/issues/sidebar-list.test.ts b/packages/core/issues/sidebar-list.test.ts
index 6b3698d20f..63387dc4b7 100644
--- a/packages/core/issues/sidebar-list.test.ts
+++ b/packages/core/issues/sidebar-list.test.ts
@@ -115,6 +115,13 @@ describe("viewSidebarRequest", () => {
}),
).toMatchObject({ advanced: { match: "any", children: [{ field: "priorities", values: ["urgent"] }] } });
expect(filters({ agentRunningFilter: true })).toMatchObject({ working_only: true });
+ expect(filters({ unreadFilter: true })).toMatchObject({ unread_issue_ids: [] });
+ expect(
+ viewSidebarRequest({ ...workspace, query: { unreadFilter: true } }, TODAY, ["b", "a"])?.table.filters,
+ ).toMatchObject({ unread_issue_ids: ["a", "b"] });
+ expect(
+ viewSidebarRequest({ ...workspace, query: {} }, TODAY, ["a"])?.table.filters,
+ ).not.toHaveProperty("unread_issue_ids");
// "Is not" with nothing selected is not a condition, and no due-date rule needs no day.
expect(filters({ negatedFilters: ["status"] })).toEqual({ include_sub_issues: true });
});
diff --git a/packages/core/issues/sidebar-list.ts b/packages/core/issues/sidebar-list.ts
index 4c5151b95a..4c98c5b541 100644
--- a/packages/core/issues/sidebar-list.ts
+++ b/packages/core/issues/sidebar-list.ts
@@ -142,12 +142,22 @@ function viewTableSort(display: Record<string, unknown>): IssueTableQuerySpec["s
return { field, direction: display.sortDirection === "desc" ? "desc" : "asc" };
}
+/** Whether listing the view needs the viewer's unread issues. */
+export function viewSidebarNeedsUnread(view: SidebarViewFields): boolean {
+ return baselineFromQuery(view.query).raw.unreadFilter;
+}
+
/**
* The request for an expanded saved view: its scope, filters and ordering,
* so the sidebar lists what opening the view shows. `null` when the view's
- * scope cannot be listed.
+ * scope cannot be listed. A view filtered to unread needs `unreadIssueIds`
+ * (see `viewSidebarNeedsUnread`); without them it lists nothing.
*/
-export function viewSidebarRequest(view: SidebarViewFields, today: string): SidebarTableRequest | null {
+export function viewSidebarRequest(
+ view: SidebarViewFields,
+ today: string,
+ unreadIssueIds: readonly string[] = [],
+): SidebarTableRequest | null {
const scope = viewTableScope(view);
if (!scope) return null;
const { raw } = baselineFromQuery(view.query);
@@ -183,6 +193,7 @@ export function viewSidebarRequest(view: SidebarViewFields, today: string): Side
...(advanced ? { advanced } : {}),
...(Object.keys(fields.propertyFilters).length > 0 ? { properties: fields.propertyFilters } : {}),
...(fields.agentRunningFilter ? { working_only: true } : {}),
+ ...(fields.unreadFilter ? { unread_issue_ids: [...unreadIssueIds].sort() } : {}),
include_sub_issues: display.showSubIssues !== false,
},
sort: viewTableSort(display),
diff --git a/packages/core/issues/stores/view-store.ts b/packages/core/issues/stores/view-store.ts
index 2572ad5e5c..1586ea5a56 100644
--- a/packages/core/issues/stores/view-store.ts
+++ b/packages/core/issues/stores/view-store.ts
@@ -160,6 +160,8 @@ export interface FilterSnapshot {
advancedFilter: AdvancedFilterGroup | null;
/** Only issues an agent is running on right now. */
agentRunningFilter: boolean;
+ /** Only issues with an agent result the viewer has not seen yet. */
+ unreadFilter: boolean;
}
/** Filter-bar chip dimensions. Date is excluded: `dateFilter` lives outside
@@ -345,6 +347,9 @@ export interface IssueViewState {
// agent task in `running` status. Saved into views and persisted like the
// other filters.
agentRunningFilter: boolean;
+ // When true, the list only shows the viewer's unread issues (the sidebar's
+ // unread dot). Saved into views; resolved per viewer.
+ unreadFilter: boolean;
sortBy: SortField;
sortDirection: SortDirection;
/** Last explicit direction per field, so switching fields is reversible. */
@@ -416,6 +421,7 @@ export interface IssueViewState {
* something simple mode cannot say (`simpleFromAdvancedFilter`). */
exitAdvancedFilter: () => void;
toggleAgentRunningFilter: () => void;
+ toggleUnreadFilter: () => void;
hideStatus: (status: IssueStatus) => void;
showStatus: (status: IssueStatus) => void;
clearFilters: () => void;
@@ -466,6 +472,7 @@ export const viewStoreSlice = (set: StoreApi<IssueViewState>["setState"]): Issue
advancedFilter: null,
dateFilter: null,
agentRunningFilter: false,
+ unreadFilter: false,
sortBy: "created_at",
sortDirection: "desc",
sortDirections: { created_at: "desc" },
@@ -625,6 +632,8 @@ export const viewStoreSlice = (set: StoreApi<IssueViewState>["setState"]): Issue
}),
toggleAgentRunningFilter: () =>
set((state) => ({ agentRunningFilter: !state.agentRunningFilter })),
+ toggleUnreadFilter: () =>
+ set((state) => ({ unreadFilter: !state.unreadFilter })),
hideStatus: (status) =>
set((state) =>
state.hiddenStatuses.includes(status)
@@ -653,6 +662,7 @@ export const viewStoreSlice = (set: StoreApi<IssueViewState>["setState"]): Issue
advancedFilter: null,
dateFilter: null,
agentRunningFilter: false,
+ unreadFilter: false,
}),
resetFiltersTo: (snapshot) => set({ ...snapshot }),
clearFilterDimension: (dimension) =>
@@ -814,6 +824,7 @@ export const viewStorePersistOptions = (name: string) => ({
propertyFilters: state.propertyFilters,
advancedFilter: state.advancedFilter,
agentRunningFilter: state.agentRunningFilter,
+ unreadFilter: state.unreadFilter,
sortBy: state.sortBy,
sortDirection: state.sortDirection,
sortDirections: state.sortDirections,
@@ -951,6 +962,9 @@ export function mergeViewStatePersisted<T extends IssueViewState>(
agentRunningFilter: p.agentRunningFilter === undefined
? current.agentRunningFilter
: p.agentRunningFilter === true,
+ unreadFilter: p.unreadFilter === undefined
+ ? current.unreadFilter
+ : p.unreadFilter === true,
negatedFilters: Array.isArray(p.negatedFilters)
? [...new Set(p.negatedFilters.filter((dimension): dimension is NegatableFilterDimension =>
(NEGATABLE_FILTER_DIMENSIONS as readonly unknown[]).includes(dimension),
diff --git a/packages/core/issues/unread.ts b/packages/core/issues/unread.ts
index e1794c8498..5c38113464 100644
--- a/packages/core/issues/unread.ts
+++ b/packages/core/issues/unread.ts
@@ -49,6 +49,20 @@ export function useIssueUnread(wsId: string, issueId: string): IssueUnread | nul
return data;
}
+const selectUnreadIssueIds = (items: IssueUnread[]) => items.map((item) => item.issue_id);
+
+/** The ids of the viewer's unread issues. `ids` stays `undefined` until the
+ * list loads (or while `enabled` is false); `isError` means it failed with
+ * nothing cached and no retry in flight. */
+export function useIssueUnreadIds(wsId: string, enabled = true) {
+ const { data, isError, isFetching, refetch } = useQuery({
+ ...issueUnreadOptions(wsId),
+ select: selectUnreadIssueIds,
+ enabled: enabled && !!wsId,
+ });
+ return { ids: data, isError: isError && !isFetching && data === undefined, refetch };
+}
+
function useSetIssueUnread(wsId: string, unread: boolean) {
const qc = useQueryClient();
const key = issueUnreadKeys.all(wsId);
diff --git a/packages/core/package.json b/packages/core/package.json
index e3da252a57..091bafff92 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -125,6 +125,7 @@
"./issue-views/preferences": "./issue-views/preferences.ts",
"./issue-views/sidebar-views": "./issue-views/sidebar-views.ts",
"./issue-views/view-target": "./issue-views/view-target.ts",
+ "./issue-views/unread-view": "./issue-views/unread-view.ts",
"./issue-views/definition": "./issue-views/definition.ts",
"./issue-views/rename-store": "./issue-views/rename-store.ts",
"./billing": "./billing/index.ts",
diff --git a/packages/core/types/api.ts b/packages/core/types/api.ts
index 03f74e1b69..5548882e10 100644
--- a/packages/core/types/api.ts
+++ b/packages/core/types/api.ts
@@ -382,6 +382,9 @@ export interface IssueTableFilters {
/** Match the running-task issue projection returned by
* `/api/working-agents`. An explicit empty list matches nothing. */
working_issue_ids?: string[];
+ /** Match the viewer's unread issues as the client holds them
+ * (`/api/issues/unread`). An explicit empty list matches nothing. */
+ unread_issue_ids?: string[];
include_sub_issues?: boolean;
}
diff --git a/packages/views/issue-views/unread-view-icon.tsx b/packages/views/issue-views/unread-view-icon.tsx
new file mode 100644
index 0000000000..7251da6d4f
--- /dev/null
+++ b/packages/views/issue-views/unread-view-icon.tsx
@@ -0,0 +1,8 @@
+/** The built-in Unread view's icon: the same dot the sidebar puts on an unread issue. */
+export function UnreadViewIcon() {
+ return (
+ <span className="flex size-4 shrink-0 items-center justify-center">
+ <span className="size-2 rounded-full bg-brand" />
+ </span>
+ );
+}
diff --git a/packages/views/issue-views/view-header.tsx b/packages/views/issue-views/view-header.tsx
index 077a2426ba..ba6c559ffc 100644
--- a/packages/views/issue-views/view-header.tsx
+++ b/packages/views/issue-views/view-header.tsx
@@ -53,6 +53,7 @@ import {
type BuiltinViewKey,
} from "@multica/core/issue-views/sidebar-views";
import { issueViewTarget } from "@multica/core/issue-views/view-target";
+import { isUnreadView } from "@multica/core/issue-views/unread-view";
import {
isIssueViewModified,
isIssueViewUndefined,
@@ -83,11 +84,13 @@ import { ActionShortcutKeycaps } from "../common/shortcut-keycaps";
import { ProjectIcon } from "../projects/components/project-icon";
import { IssueDisplayControls, IssueFilterMenu } from "../issues/components/issues-header";
import { ChipSpan, useFilterChips, type FilterChip } from "../issues/components/filter-chips-bar";
+import { useViewBaseline } from "../issues/surface/view-baseline-context";
import { WorkspaceAgentWorkingChip } from "../issues/components/workspace-agent-working-chip";
import type { IssueSurfaceController } from "../issues/surface/use-issue-surface-controller";
import { useT } from "../i18n";
import { useMyIssuesScope } from "../my-issues/use-my-issues-scope";
import { DeleteViewDialog } from "./delete-view-dialog";
+import { UnreadViewIcon } from "./unread-view-icon";
import { useIssueViewActions } from "./use-view-actions";
import { ViewNameInput } from "./view-name-input";
@@ -190,7 +193,15 @@ export function IssueViewHeader({
// does; its filter menu opens as soon as the view is named.
const needsSetup = !!activeView && canManage && isIssueViewUndefined(activeView);
const [setupFilterOpen, setSetupFilterOpen] = useState(false);
- const starId = activeView ? savedViewItemId(activeView.id) : builtinKey ? builtinViewItemId(builtinKey) : null;
+ const unreadView = isUnreadView(activeView);
+ const activeViewName = unreadView ? t(($) => $.views.builtin.unread) : activeView?.name;
+ const starId = unreadView
+ ? null
+ : activeView
+ ? savedViewItemId(activeView.id)
+ : builtinKey
+ ? builtinViewItemId(builtinKey)
+ : null;
const starred = starId ? actions.sidebar.isStarred(starId) : false;
const renaming =
!!activeView && renameTarget?.surface === "header" && renameTarget.viewId === activeView.id;
@@ -287,7 +298,8 @@ export function IssueViewHeader({
// "My issues" is already a relation to me; a second one there is noise.
const showRelation = base.kind !== "my";
- const { chips: allFilterChips } = useFilterChips(dateFilter, setDateFilter);
+ const viewBaseline = useViewBaseline() ?? undefined;
+ const { chips: allFilterChips } = useFilterChips(dateFilter, setDateFilter, viewBaseline);
const filterChips = showRelation
? allFilterChips
: allFilterChips.filter((chip) => chip.key !== "relation");
@@ -318,11 +330,12 @@ export function IssueViewHeader({
);
const filterMenuProps = {
+ viewBaseline,
leadingSections: scopeSection,
showRelation,
hiddenFields: base.kind === "project" ? PROJECT_HIDDEN_FIELDS : undefined,
modifiedKeys,
- summaryTitle: activeView?.name ?? baseName,
+ summaryTitle: activeViewName ?? baseName,
scopedIssues: controller.surfaceIssues,
facetCountsExact: controller.facetCountsExact,
tableFacetCounts: controller.tableFacetCounts,
@@ -337,9 +350,9 @@ export function IssueViewHeader({
const title = (
<>
<RefreshablePageIcon refreshing={controller.isRefreshing}>
- {activeView ? <Layers className="size-4" /> : baseIcon}
+ {unreadView ? <UnreadViewIcon /> : activeView ? <Layers className="size-4" /> : baseIcon}
</RefreshablePageIcon>
- <span className="min-w-0 truncate">{activeView ? activeView.name : baseName}</span>
+ <span className="min-w-0 truncate">{activeView ? activeViewName : baseName}</span>
</>
);
@@ -386,7 +399,9 @@ export function IssueViewHeader({
{t(($) => $.views.rename)}
</DropdownMenuItem>
)}
- <DropdownMenuItem onClick={() => actions.duplicate(activeView, "header")}>
+ <DropdownMenuItem
+ onClick={() => actions.duplicate({ ...activeView, name: activeViewName ?? "" }, "header")}
+ >
<Copy className="size-3.5" />
{t(($) => $.views.duplicate)}
</DropdownMenuItem>
@@ -422,7 +437,9 @@ export function IssueViewHeader({
)}
<DropdownMenuSeparator />
<DropdownMenuGroup>
- <StarItem starred={starred} onToggle={() => starId && (starred ? actions.sidebar.unstar(starId) : actions.sidebar.star(starId))} />
+ {starId && (
+ <StarItem starred={starred} onToggle={() => (starred ? actions.sidebar.unstar(starId) : actions.sidebar.star(starId))} />
+ )}
<DropdownMenuItem onClick={() => setActive(null)}>
<ArrowLeft className="size-3.5" />
{t(($) => $.views.back_to, { name: baseName })}
diff --git a/packages/views/issues/components/filter-chips-bar.tsx b/packages/views/issues/components/filter-chips-bar.tsx
index 0397b9b71e..ba6256addb 100644
--- a/packages/views/issues/components/filter-chips-bar.tsx
+++ b/packages/views/issues/components/filter-chips-bar.tsx
@@ -10,6 +10,7 @@ import {
CircleDashed,
CircleDot,
CircleUser,
+ Eye,
FolderKanban,
SignalHigh,
Tag,
@@ -232,6 +233,7 @@ export function useFilterChips(
const negatedFilters = useViewStore((s) => s.negatedFilters);
const propertyFilters = useViewStore((s) => s.propertyFilters);
const agentRunningFilter = useViewStore((s) => s.agentRunningFilter);
+ const unreadFilter = useViewStore((s) => s.unreadFilter);
const store = useViewStoreApi();
const negated = new Set(negatedFilters);
@@ -321,6 +323,7 @@ export function useFilterChips(
propertyFilters: s.propertyFilters,
advancedFilter: s.advancedFilter,
agentRunningFilter: s.agentRunningFilter,
+ unreadFilter: s.unreadFilter,
};
switch (dimension) {
case "status":
@@ -457,6 +460,18 @@ export function useFilterChips(
},
});
}
+ if (unreadFilter && !baseline?.unread) {
+ chips.push({
+ key: "unread",
+ icon: <Eye className={CHIP_ICON_CLASS} />,
+ label: t(($) => $.filters.section_read_state),
+ value: t(($) => $.filters.read_state_unread),
+ onRemove: () => {
+ const s = store.getState();
+ if (s.unreadFilter) s.toggleUnreadFilter();
+ },
+ });
+ }
const [onlyPriority] = deltaPriority;
if (deltaPriority.length > 0) {
chips.push({
diff --git a/packages/views/issues/components/issues-header.agent-running-filter.test.tsx b/packages/views/issues/components/issues-header.agent-running-filter.test.tsx
index b88401a787..dc3e2340ea 100644
--- a/packages/views/issues/components/issues-header.agent-running-filter.test.tsx
+++ b/packages/views/issues/components/issues-header.agent-running-filter.test.tsx
@@ -68,7 +68,7 @@ describe("IssueFilterMenu agent status", () => {
await screen.findByRole("menuitem", { name: /^Status/ });
const rows = screen.getAllByRole("menuitem").map((el) => el.textContent?.trim());
- expect(rows.slice(0, 3)).toEqual(["Status", "Agent status", "Priority"]);
+ expect(rows.slice(0, 4)).toEqual(["Status", "Agent status", "Read state", "Priority"]);
});
it("filters on Running from its submenu and reads as a sentence", async () => {
@@ -117,3 +117,46 @@ describe("IssueFilterMenu agent status", () => {
expect(store.getState().agentRunningFilter).toBe(true);
});
});
+
+const readStateRow = () => screen.getByRole("menuitem", { name: /^Read state/ });
+
+async function openReadState() {
+ fireEvent.click(screen.getByRole("button", { name: "Filter" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: /^Read state/ }));
+ return screen.findByRole("menuitemcheckbox", { name: "Unread" });
+}
+
+describe("IssueFilterMenu read state", () => {
+ it("filters on Unread from its submenu and reads as a sentence", async () => {
+ const store = renderFilterMenu();
+ const unread = await openReadState();
+
+ fireEvent.click(unread);
+ await waitFor(() => expect(store.getState().unreadFilter).toBe(true));
+ expect(unread).toHaveAttribute("aria-checked", "true");
+ expect(readStateRow().textContent).toBe("Read stateisUnread");
+
+ fireEvent.click(unread);
+ await waitFor(() => expect(store.getState().unreadFilter).toBe(false));
+ });
+
+ it("is listed under Active when on, and Reset turns it off", async () => {
+ const store = renderFilterMenu({ unreadFilter: true });
+ fireEvent.click(screen.getByRole("button", { name: "Filter" }));
+ await screen.findByText("Active");
+
+ expect(screen.getAllByRole("menuitem")[0]?.textContent).toBe("Read stateisUnread");
+ fireEvent.click(screen.getByRole("menuitem", { name: "Reset all filters" }));
+ await waitFor(() => expect(store.getState().unreadFilter).toBe(false));
+ });
+
+ it("is fixed inside a saved view that filters on it", async () => {
+ const baseline = baselineFromQuery({ unreadFilter: true });
+ const store = renderFilterMenu({ unreadFilter: true }, baseline);
+ const unread = await openReadState();
+
+ expect(unread).toHaveAttribute("aria-checked", "true");
+ expect(unread).toHaveAttribute("aria-disabled", "true");
+ expect(store.getState().unreadFilter).toBe(true);
+ });
+});
diff --git a/packages/views/issues/components/issues-header.status-filter.test.tsx b/packages/views/issues/components/issues-header.status-filter.test.tsx
index 15fd03500e..9b44759bbd 100644
--- a/packages/views/issues/components/issues-header.status-filter.test.tsx
+++ b/packages/views/issues/components/issues-header.status-filter.test.tsx
@@ -173,7 +173,7 @@ describe("IssueFilterMenu active dimensions", () => {
const rows = dimensionRows();
expect(rows[0]).toBe("PriorityisHigh");
- expect(rows.slice(1, 4)).toEqual(["Status", "Agent status", "Assignee"]);
+ expect(rows.slice(1, 5)).toEqual(["Status", "Agent status", "Read state", "Assignee"]);
});
it("keeps a dimension in place while the menu stays open", async () => {
diff --git a/packages/views/issues/components/issues-header.tsx b/packages/views/issues/components/issues-header.tsx
index 8b67bd91b6..5916cbe878 100644
--- a/packages/views/issues/components/issues-header.tsx
+++ b/packages/views/issues/components/issues-header.tsx
@@ -12,6 +12,7 @@ import {
CircleDot,
CircleUser,
Columns3,
+ Eye,
Filter,
FolderKanban,
FolderMinus,
@@ -166,6 +167,7 @@ function getActiveFilterCount(
advancedFilter?: AdvancedFilterGroup | null;
dateFilter?: IssueDateFilter | null;
agentRunningFilter?: boolean;
+ unreadFilter?: boolean;
},
// Inside a saved view only the user's additions on top of the view's own
// query count — the baseline is the view, not "active filtering".
@@ -213,6 +215,7 @@ function getActiveFilterCount(
}
if (state.dateFilter) count++;
if (state.agentRunningFilter && !baseline?.agentRunning) count++;
+ if (state.unreadFilter && !baseline?.unread) count++;
return count;
}
@@ -1051,6 +1054,7 @@ export function IssueFilterMenu({
const negatedFilters = useViewStore((s) => s.negatedFilters);
const propertyFilters = useViewStore((s) => s.propertyFilters);
const agentRunningFilter = useViewStore((s) => s.agentRunningFilter);
+ const unreadFilter = useViewStore((s) => s.unreadFilter);
const viewStoreApi = useViewStoreApi();
const act = viewStoreApi.getState();
const advancedMode = advancedFilter !== null;
@@ -1105,6 +1109,7 @@ export function IssueFilterMenu({
advancedFilter,
dateFilter: showDateFilter ? dateFilter : null,
agentRunningFilter,
+ unreadFilter,
},
viewBaseline,
) > 0;
@@ -1142,6 +1147,8 @@ export function IssueFilterMenu({
? t(($) => $.filters.section_date)
: key === "agentRunning"
? `${t(($) => $.filters.section_agent_status)} ${t(($) => $.filters.agent_status_running)}`
+ : key === "unread"
+ ? `${t(($) => $.filters.section_read_state)} ${t(($) => $.filters.read_state_unread)}`
: key.startsWith("property:")
? filterableProperties.find((p) => `property:${p.id}` === key)?.name ?? ""
: fieldLabels[key as NegatableFilterDimension] ?? "";
@@ -1228,6 +1235,32 @@ export function IssueFilterMenu({
</DropdownMenuSub>
)}
+ {/* Read state */}
+ {show("unread") && (
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <Eye className="size-3.5" />
+ <span className="flex-1">{t(($) => $.filters.section_read_state)}</span>
+ {triggerValue("unread")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent className="w-auto min-w-44">
+ <DropdownMenuCheckboxItem
+ checked={unreadFilter}
+ disabled={viewBaseline?.unread === true}
+ title={viewBaseline?.unread === true ? fixedTitle : undefined}
+ onCheckedChange={() => act.toggleUnreadFilter()}
+ className={FILTER_ITEM_CLASS}
+ >
+ <HoverCheck checked={unreadFilter} />
+ <span className="flex size-3.5 items-center justify-center">
+ <span className="size-1.5 rounded-full bg-brand" />
+ </span>
+ {t(($) => $.filters.read_state_unread)}
+ </DropdownMenuCheckboxItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ )}
+
{/* Priority */}
{show("priority") && (
<DropdownMenuSub
@@ -1555,6 +1588,7 @@ export function IssueFilterMenu({
const sectionKeys = [
...searchFields.filter((field) => field !== "relation" || showRelation),
"agentRunning",
+ "unread",
...(showDateFilter ? ["date"] : []),
...filterableProperties.map((p) => `property:${p.id}`),
];
@@ -1813,6 +1847,7 @@ export function IssueDisplayControls({
const advancedFilter = useViewStore((s) => s.advancedFilter);
const negatedFilters = useViewStore((s) => s.negatedFilters);
const agentRunningFilter = useViewStore((s) => s.agentRunningFilter);
+ const unreadFilter = useViewStore((s) => s.unreadFilter);
const cardPropertyIds = useViewStore((s) => s.cardPropertyIds);
const sortBy = useViewStore((s) => s.sortBy);
const sortDirection = useViewStore((s) => s.sortDirection);
@@ -1894,6 +1929,7 @@ export function IssueDisplayControls({
advancedFilter,
dateFilter: showDateFilter ? dateFilter : null,
agentRunningFilter,
+ unreadFilter,
},
viewBaseline,
);
diff --git a/packages/views/issues/components/swimlane-view.tsx b/packages/views/issues/components/swimlane-view.tsx
index 04fa4d4863..552530c805 100644
--- a/packages/views/issues/components/swimlane-view.tsx
+++ b/packages/views/issues/components/swimlane-view.tsx
@@ -671,6 +671,8 @@ function SwimLaneViewImpl({
// the same running-task issue ids returned by `/api/working-agents`.
agentRunningFilter: activeFiltersProp?.agentRunningFilter ?? false,
runningIssueIds: activeFiltersProp?.runningIssueIds,
+ unreadFilter: activeFiltersProp?.unreadFilter ?? false,
+ unreadIssueIds: activeFiltersProp?.unreadIssueIds,
creatorFilters: activeFiltersProp?.creatorFilters ?? [],
projectFilters: activeFiltersProp?.projectFilters ?? [],
includeNoProject: activeFiltersProp?.includeNoProject ?? false,
diff --git a/packages/views/issues/surface/issue-surface.test.tsx b/packages/views/issues/surface/issue-surface.test.tsx
index 9780ccde63..30de127bfe 100644
--- a/packages/views/issues/surface/issue-surface.test.tsx
+++ b/packages/views/issues/surface/issue-surface.test.tsx
@@ -29,6 +29,8 @@ import { IssueSurface, IssueSurfaceWithStore } from "./issue-surface";
import { createIssueStatusListStore } from "@multica/core/issue-statuses";
import { baselineFromQuery } from "@multica/core/issue-views/baseline";
import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";
+import { UNREAD_VIEW_ID } from "@multica/core/issue-views/unread-view";
+import { setCurrentWorkspace } from "@multica/core/platform";
import { statusTableMethodsFromLegacy } from "./status-table-test-api";
// Mutable so tests can simulate a workspace switch — the workspace layout
@@ -785,6 +787,8 @@ describe("IssueSurface — filtered empty state", () => {
getAgentTaskSnapshot: vi.fn(() => never<AgentTask[]>()),
getWorkspaceWorkingAgents: vi.fn(() => Promise.resolve([])),
getChildIssueProgress: vi.fn(() => never()),
+ listIssueUnread: vi.fn(() => Promise.resolve([])),
+ listIssueViews: vi.fn(() => Promise.resolve([])),
} as unknown as ApiClient);
pruneIssueSurfaceViewStates([]);
});
@@ -793,6 +797,7 @@ describe("IssueSurface — filtered empty state", () => {
cleanup();
qc.clear();
pruneIssueSurfaceViewStates([]);
+ useActiveIssueViewStore.getState().setActive("ws-1:workspace", null);
mockTranslate.mockImplementation(() => "translated");
vi.restoreAllMocks();
});
@@ -844,6 +849,61 @@ describe("IssueSurface — filtered empty state", () => {
await screen.findByText("detail.empty_issues_title");
expect(screen.queryByText("filtered_empty.title")).toBeNull();
});
+
+ function unreadViewSurface() {
+ useActiveIssueViewStore.getState().setActive("ws-1:workspace", UNREAD_VIEW_ID);
+ return (
+ <QueryClientProvider client={qc}>
+ <IssueSurface
+ scope={{ type: "workspace", actorKind: "all" }}
+ modes={["list"]}
+ renderHeader={() => null}
+ batchToolbar="never"
+ />
+ </QueryClientProvider>
+ );
+ }
+
+ it("keeps the built-in Unread view's condition when its filters are cleared", async () => {
+ const store = getIssueSurfaceViewStore(`view:${UNREAD_VIEW_ID}`);
+ act(() => store.setState({ unreadFilter: true, agentRunningFilter: true }));
+
+ render(unreadViewSurface());
+
+ fireEvent.click(await screen.findByRole("button", { name: "filtered_empty.clear_button" }));
+ expect(store.getState().agentRunningFilter).toBe(false);
+ expect(store.getState().unreadFilter).toBe(true);
+ await screen.findByText("filtered_empty.unread_title");
+ expect(screen.queryByRole("button", { name: "filtered_empty.clear_button" })).toBeNull();
+ });
+
+ it("keeps the built-in Unread view's condition when a workspace switch reloads its state", async () => {
+ setCurrentWorkspace("acme", "ws-1");
+ const store = getIssueSurfaceViewStore(`view:${UNREAD_VIEW_ID}`);
+ render(unreadViewSurface());
+ await screen.findByText("filtered_empty.unread_title");
+
+ // The next workspace has no saved state for this view, so the reload
+ // resets the store to defaults, unread off.
+ await act(async () => {
+ setCurrentWorkspace("beta", "ws-1");
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ });
+
+ expect(store.getState().unreadFilter).toBe(true);
+ expect(screen.getByText("filtered_empty.unread_title")).toBeInTheDocument();
+ setCurrentWorkspace(null, null);
+ });
+
+ it("restores the built-in Unread view's condition from state saved without it", async () => {
+ const store = getIssueSurfaceViewStore(`view:${UNREAD_VIEW_ID}`);
+ act(() => store.setState({ unreadFilter: false }));
+
+ render(unreadViewSurface());
+
+ await screen.findByText("filtered_empty.unread_title");
+ expect(store.getState().unreadFilter).toBe(true);
+ });
});
/**
diff --git a/packages/views/issues/surface/issue-surface.tsx b/packages/views/issues/surface/issue-surface.tsx
index 42537a509d..1d0e3af7a8 100644
--- a/packages/views/issues/surface/issue-surface.tsx
+++ b/packages/views/issues/surface/issue-surface.tsx
@@ -21,6 +21,12 @@ import {
seedIssueSurfaceViewState,
} from "@multica/core/issues/stores/surface-view-store";
import { useActiveIssueView } from "@multica/core/issue-views/use-active-view";
+import { UNREAD_VIEW_BASELINE, isUnreadView } from "@multica/core/issue-views/unread-view";
+import {
+ issueViewDefinitionFromState,
+ issueViewSeedDefinition,
+ sameFilterMeaning,
+} from "@multica/core/issue-views/definition";
import { ViewBaselineProvider, useViewBaseline } from "./view-baseline-context";
import type { IssueViewScope } from "@multica/core/issue-views/queries";
import {
@@ -125,6 +131,7 @@ export function IssueSurface({
: activeView && scope.type === "my"
? { ...scope, relation: myRelationForViewVariant(activeView.scope_variant) }
: scope;
+ const viewBaseline = isUnreadView(activeView) ? UNREAD_VIEW_BASELINE : null;
const store = useMemo(() => {
// First-open seeding happens HERE, at store-creation time for this key:
// no React component has subscribed to the new key's store yet, so the
@@ -133,9 +140,19 @@ export function IssueSurface({
if (seedDefinition) {
seedIssueSurfaceViewState(resolvedSurfaceKey, seedDefinition);
}
- return getIssueSurfaceViewStore(resolvedSurfaceKey);
+ const viewStore = getIssueSurfaceViewStore(resolvedSurfaceKey);
+ if (viewBaseline?.unread) keepUnreadFilter(viewStore);
+ return viewStore;
// eslint-disable-next-line react-hooks/exhaustive-deps -- seed identity follows the key
}, [resolvedSurfaceKey]);
+ // Seeding happens once per key, but the stored state can be replaced later:
+ // a workspace switch reloads it from that workspace's preferences, which may
+ // never have held the condition. Re-apply it whenever it goes missing.
+ useEffect(() => {
+ if (!viewBaseline?.unread) return;
+ keepUnreadFilter(store);
+ return store.subscribe(() => keepUnreadFilter(store));
+ }, [store, viewBaseline]);
// Every change of this key tears down and remounts the ENTIRE surface
// (providers, DnD, all columns/cards) — by design for data-window changes,
@@ -151,35 +168,41 @@ export function IssueSurface({
return (
<ViewStoreProvider store={store}>
- {/* Remount on data-window change: the list queries keep the previous
- key's data as a placeholder (keepPreviousData) so sort/filter
- changes within ONE surface never flash a skeleton — but reusing the
- mounted observer across windows made project A's cards impersonate
- project B (with isLoading=false, so no skeleton either) until B's
- fetch landed. A window-keyed remount gives the new window a fresh
- observer: cold window → skeleton, warm window → instant cache hit.
- The window identity is wsId + scope — wsId is required because the
- workspace layout does not remount on workspace switch and two
- workspaces share the same scope key (e.g. "workspace:all"). Keyed
- by data identity, not surfaceKey (view-preference identity). */}
- <IssueSurfaceContent
- key={contentKey}
- scope={effectiveScope}
- modes={modes}
- createDefaults={createDefaults}
- search={search}
- renderHeader={renderHeader}
- renderEmpty={renderEmpty}
- renderLoading={renderLoading}
- clientFilter={clientFilter}
- showClientEmpty={showClientEmpty}
- batchToolbar={batchToolbar}
- contentClassName={contentClassName}
- />
+ <ViewBaselineProvider baseline={viewBaseline}>
+ {/* Remount on data-window change: the list queries keep the previous
+ key's data as a placeholder (keepPreviousData) so sort/filter
+ changes within ONE surface never flash a skeleton — but reusing the
+ mounted observer across windows made project A's cards impersonate
+ project B (with isLoading=false, so no skeleton either) until B's
+ fetch landed. A window-keyed remount gives the new window a fresh
+ observer: cold window → skeleton, warm window → instant cache hit.
+ The window identity is wsId + scope — wsId is required because the
+ workspace layout does not remount on workspace switch and two
+ workspaces share the same scope key (e.g. "workspace:all"). Keyed
+ by data identity, not surfaceKey (view-preference identity). */}
+ <IssueSurfaceContent
+ key={contentKey}
+ scope={effectiveScope}
+ modes={modes}
+ createDefaults={createDefaults}
+ search={search}
+ renderHeader={renderHeader}
+ renderEmpty={renderEmpty}
+ renderLoading={renderLoading}
+ clientFilter={clientFilter}
+ showClientEmpty={showClientEmpty}
+ batchToolbar={batchToolbar}
+ contentClassName={contentClassName}
+ />
+ </ViewBaselineProvider>
</ViewStoreProvider>
);
}
+function keepUnreadFilter(store: StoreApi<IssueViewState>) {
+ if (!store.getState().unreadFilter) store.setState({ unreadFilter: true });
+}
+
function IssueSurfaceContent({
scope,
modes,
@@ -271,6 +294,8 @@ function IssueSurfaceContent({
<FilterDependencyErrorState kind="status" onRetry={controller.retryStatusCatalog} />
) : controller.isWorkingFilterError ? (
<FilterDependencyErrorState kind="working" onRetry={controller.retryWorkingFilter} />
+ ) : controller.isUnreadFilterError ? (
+ <FilterDependencyErrorState kind="unread" onRetry={controller.retryUnreadFilter} />
) : controller.isLoading ? (
renderLoading ? (
renderLoading(renderContext)
@@ -397,7 +422,7 @@ function FilterDependencyErrorState({
kind,
onRetry,
}: {
- kind: "status" | "working";
+ kind: "status" | "working" | "unread";
onRetry: () => void;
}) {
const { t } = useT("issues");
@@ -409,7 +434,9 @@ function FilterDependencyErrorState({
title={
kind === "working"
? t(($) => $.working_filter_error.title)
- : t(($) => $.status_catalog_error.title)
+ : kind === "unread"
+ ? t(($) => $.unread_filter_error.title)
+ : t(($) => $.status_catalog_error.title)
}
description={kind === "status" ? t(($) => $.status_catalog_error.hint) : undefined}
actions={
@@ -431,16 +458,30 @@ function FilteredEmptyState() {
const handleClear = baseline
? () => resetFiltersTo(baseline.raw)
: clearFilters;
+ const baselineQuery = useMemo(
+ () => (baseline ? issueViewSeedDefinition({ query: { ...baseline.raw }, display: {} }).query : null),
+ [baseline],
+ );
+ // Only the view's own conditions are on, so there is nothing to clear.
+ const atBaseline = useViewStore(
+ (s) => !!baselineQuery && sameFilterMeaning(baselineQuery, issueViewDefinitionFromState(s).query),
+ );
return (
<CollectionPageState
size="compact"
icon={FilterX}
- title={t(($) => $.filtered_empty.title)}
+ title={
+ atBaseline && baseline?.unread
+ ? t(($) => $.filtered_empty.unread_title)
+ : t(($) => $.filtered_empty.title)
+ }
actions={
- <Button variant="outline" size="sm" onClick={handleClear}>
- {t(($) => $.filtered_empty.clear_button)}
- </Button>
+ atBaseline ? undefined : (
+ <Button variant="outline" size="sm" onClick={handleClear}>
+ {t(($) => $.filtered_empty.clear_button)}
+ </Button>
+ )
}
/>
);
diff --git a/packages/views/issues/surface/use-issue-surface-controller.test.tsx b/packages/views/issues/surface/use-issue-surface-controller.test.tsx
index 5c4dcaf4f6..cc4ef5bd1f 100644
--- a/packages/views/issues/surface/use-issue-surface-controller.test.tsx
+++ b/packages/views/issues/surface/use-issue-surface-controller.test.tsx
@@ -8,6 +8,7 @@ import type { ReactNode } from "react";
import { setApiInstance } from "@multica/core/api";
import type { ApiClient } from "@multica/core/api/client";
import { workspaceWorkingAgentsKeys } from "@multica/core/agents/queries";
+import { issueUnreadKeys } from "@multica/core/issues/unread";
import {
getIssueSurfaceViewStore,
pruneIssueSurfaceViewStates,
@@ -159,6 +160,7 @@ describe("useIssueSurfaceController", () => {
typeof vi.fn<() => Promise<WorkspaceWorkingAgent[]>>
>;
let listIssueTableRows: ReturnType<typeof vi.fn>;
+ let listIssueUnread: ReturnType<typeof vi.fn>;
let listIssueTableFacets: ReturnType<typeof vi.fn>;
// Every row the current fixture holds, kept outside the mocked list endpoint
// so the working-agents facet stand-in can read it without registering a
@@ -184,6 +186,7 @@ describe("useIssueSurfaceController", () => {
});
listIssueTableRows = vi.fn(tableMethods.listIssueTableRows);
listIssueTableFacets = vi.fn(tableMethods.listIssueTableFacets);
+ listIssueUnread = vi.fn(() => Promise.resolve([]));
setApiInstance({
// The board pages by category, so every surface stub answers the catalog
// read. Empty is the real shape for a workspace with no custom statuses:
@@ -197,6 +200,7 @@ describe("useIssueSurfaceController", () => {
listProjects: vi.fn(() => never()),
getAgentTaskSnapshot,
getWorkspaceWorkingAgents,
+ listIssueUnread,
getChildIssueProgress: vi.fn(() => never()),
} as unknown as ApiClient);
pruneIssueSurfaceViewStates([]);
@@ -1764,6 +1768,63 @@ describe("useIssueSurfaceController", () => {
expect(result.current.isWorkingFilterError).toBe(false);
});
+ const unreadMark = (issueId: string) => ({
+ issue_id: issueId,
+ outcome: "manual",
+ agent_id: null,
+ created_at: "2026-01-01T00:00:00Z",
+ });
+
+ it("offers a retry when the unread filter cannot load the unread list", async () => {
+ mockListByStatus({ todo: [makeIssue({ id: "todo-1", status: "todo" })] });
+ listIssueUnread.mockRejectedValueOnce(new Error("offline"));
+ const store = getIssueSurfaceViewStore("project:p1");
+ store.getState().toggleUnreadFilter();
+ const { result } = renderHook(
+ () => useIssueSurfaceController({ scope: { type: "project", projectId: "p1" }, modes: ["list"] }),
+ { wrapper: makeWrapper(qc) },
+ );
+ await waitFor(() => expect(result.current.isUnreadFilterError).toBe(true));
+ expect(result.current.isLoading).toBe(false);
+ expect(result.current.isEmpty).toBe(false);
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toBeUndefined();
+ expect(listIssueTableRows).not.toHaveBeenCalled();
+ listIssueUnread.mockResolvedValue([unreadMark("todo-1")]);
+ act(() => result.current.retryUnreadFilter());
+ await waitFor(() => expect(result.current.issues.map((issue) => issue.id)).toEqual(["todo-1"]));
+ expect(result.current.isUnreadFilterError).toBe(false);
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toEqual(["todo-1"]);
+ });
+
+ it("keeps issues read under the unread filter until the filter turns off", async () => {
+ mockListByStatus({ todo: [makeIssue({ id: "todo-1", status: "todo" })] });
+ listIssueUnread.mockResolvedValue([unreadMark("b"), unreadMark("a")]);
+ const store = getIssueSurfaceViewStore("project:p1");
+ const { result } = renderHook(
+ () => useIssueSurfaceController({ scope: { type: "project", projectId: "p1" }, modes: ["list"] }),
+ { wrapper: makeWrapper(qc) },
+ );
+ act(() => store.getState().toggleUnreadFilter());
+ await waitFor(() => expect(result.current.tableQuerySpec.filters.unread_issue_ids).toEqual(["a", "b"]));
+
+ await act(async () => {
+ qc.setQueryData(issueUnreadKeys.all("ws-1"), [unreadMark("b")]);
+ // Query observers notify on a timer; let the read reach the hook.
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ });
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toEqual(["a", "b"]);
+
+ act(() => qc.setQueryData(issueUnreadKeys.all("ws-1"), [unreadMark("b"), unreadMark("c")]));
+ await waitFor(() =>
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toEqual(["a", "b", "c"]),
+ );
+
+ act(() => store.getState().toggleUnreadFilter());
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toBeUndefined();
+ act(() => store.getState().toggleUnreadFilter());
+ expect(result.current.tableQuerySpec.filters.unread_issue_ids).toEqual(["b", "c"]);
+ });
+
it("keeps swimlane chrome bounded while descriptors retain hidden-status counts", async () => {
mockListByStatus({
todo: [makeIssue({ id: "todo-1", status: "todo" })],
diff --git a/packages/views/issues/surface/use-issue-surface-controller.ts b/packages/views/issues/surface/use-issue-surface-controller.ts
index 28a0987677..b000a315f2 100644
--- a/packages/views/issues/surface/use-issue-surface-controller.ts
+++ b/packages/views/issues/surface/use-issue-surface-controller.ts
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useEffect, useMemo, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { hashKey, keepPreviousData, useQuery } from "@tanstack/react-query";
import { api } from "@multica/core/api";
import type {
@@ -20,6 +20,7 @@ import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { useColumnWorkflow, workflowColumns } from "../utils/workflow-columns";
import { statusFilterColumns, visibleStatusKeys } from "@multica/core/issues";
import { dateOnlyToLocalDate, todayDateOnly } from "@multica/core/issues/date";
+import { useIssueUnreadIds } from "@multica/core/issues/unread";
import {
advancedFilterToTableQuery,
advancedFilterUsesField,
@@ -151,6 +152,8 @@ export interface IssueSurfaceController {
/** First-load failure while the working filter needs issue membership. */
isWorkingFilterError: boolean;
retryWorkingFilter: () => void;
+ isUnreadFilterError: boolean;
+ retryUnreadFilter: () => void;
openCreateIssue: (defaults?: IssueCreateDefaults) => void;
moveIssue: (
issueId: string,
@@ -259,6 +262,7 @@ export function useIssueSurfaceController({
const negatedFilters = useViewStore(useShallow(effectiveNegatedFilters));
const propertyFilters = useViewStore((s) => s.propertyFilters);
const agentRunningFilter = useViewStore((s) => s.agentRunningFilter);
+ const unreadFilter = useViewStore((s) => s.unreadFilter);
const showSubIssues = useViewStore((s) => s.showSubIssues);
const ganttShowCompleted = useViewStore((s) => s.ganttShowCompleted);
const cardProperties = useViewStore((s) => s.cardProperties);
@@ -498,7 +502,8 @@ export function useIssueSurfaceController({
advancedFilter !== null ||
Object.keys(effectivePropertyFilters).length > 0 ||
dateFilter != null ||
- agentRunningFilter === true;
+ agentRunningFilter === true ||
+ unreadFilter === true;
const workingAgentMineRelation =
scope.type === "my"
@@ -527,6 +532,25 @@ export function useIssueSurfaceController({
return issueIDs;
}, [workspaceWorkingAgents]);
+ // The unread filter matches the viewer's unread list. An issue read while
+ // the filter is on stays in the set, so it keeps its place on screen (and
+ // the query keeps its identity) until the filter turns off or the surface
+ // unmounts; a newly unread issue grows the set and refetches.
+ const unreadProjection = useIssueUnreadIds(wsId, unreadFilter);
+ const unreadIssueList = unreadProjection.ids;
+ const unreadFilterUnresolved = unreadFilter && unreadIssueList === undefined;
+ const unreadFilterError = unreadFilterUnresolved && unreadProjection.isError;
+ const keptUnreadRef = useRef<Set<string>>(new Set());
+ const unreadIssueIDs = useMemo<ReadonlySet<string>>(() => {
+ if (!unreadFilter) {
+ keptUnreadRef.current = new Set();
+ return keptUnreadRef.current;
+ }
+ for (const issueID of unreadIssueList ?? EMPTY_LIST) keptUnreadRef.current.add(issueID);
+ return new Set(keptUnreadRef.current);
+ }, [unreadFilter, unreadIssueList]);
+ const membershipUnresolved = workingFilterUnresolved || unreadFilterUnresolved;
+
const derivedTableQuerySpec = useMemo<IssueTableQuerySpec>(() => {
let queryScope: IssueTableQuerySpec["scope"];
switch (scope.type) {
@@ -612,6 +636,9 @@ export function useIssueSurfaceController({
...(agentRunningFilter && !workingFilterUnresolved
? { working_issue_ids: [...workingIssueIDs] }
: {}),
+ ...(unreadFilter && !unreadFilterUnresolved
+ ? { unread_issue_ids: [...unreadIssueIDs].sort() }
+ : {}),
include_sub_issues: showSubIssues,
},
...(debouncedActiveSearch ? { search: debouncedActiveSearch } : {}),
@@ -641,6 +668,9 @@ export function useIssueSurfaceController({
sort.sort_direction,
statusFilters,
today,
+ unreadFilter,
+ unreadFilterUnresolved,
+ unreadIssueIDs,
viewIncludeNoProject,
viewProjectFilters,
workingFilterUnresolved,
@@ -689,7 +719,7 @@ export function useIssueSurfaceController({
// every custom-property facet made a Table mount issue up to 47 SQL
// statements and repeatedly scan the issue table after invalidation.
enabled:
- !workingFilterUnresolved && (
+ !membershipUnresolved && (
usesServerStatusSurface ||
((usesTable || usesServerGroupSurface) && activeTableFacet !== null)
),
@@ -754,7 +784,7 @@ export function useIssueSurfaceController({
facets: tableFacetsQuery.data,
facetsPending: tableFacetsQuery.isPending,
facetsFetching: tableFacetsQuery.isFetching,
- enabled: usesServerStatusSurface && !statusFilterUnresolved && !workingFilterUnresolved,
+ enabled: usesServerStatusSurface && !statusFilterUnresolved && !membershipUnresolved,
});
const serverGroupSpec = useMemo<IssueTableGroupsRequest["group"]>(() => {
if (effectiveViewMode === "swimlane") {
@@ -800,7 +830,7 @@ export function useIssueSurfaceController({
observeEmptyBranches:
effectiveViewMode === "swimlane" ||
(effectiveViewMode === "board" && activeGroupingProperty !== null),
- enabled: usesServerGroupSurface && !statusFilterUnresolved && !workingFilterUnresolved,
+ enabled: usesServerGroupSurface && !statusFilterUnresolved && !membershipUnresolved,
});
// Selection is only meaningful within the current membership window: batch
@@ -830,6 +860,7 @@ export function useIssueSurfaceController({
negatedFilters,
effectivePropertyFilters,
agentRunningFilter,
+ unreadFilter,
showSubIssues,
dateParams,
debouncedActiveSearch,
@@ -837,6 +868,7 @@ export function useIssueSurfaceController({
[
advancedTableFilter,
agentRunningFilter,
+ unreadFilter,
assigneeFilters,
creatorFilters,
dateParams,
@@ -878,6 +910,7 @@ export function useIssueSurfaceController({
assigneeFilters,
includeNoAssignee,
agentRunningFilter,
+ unreadFilter,
creatorFilters,
projectFilters: viewProjectFilters,
includeNoProject: viewIncludeNoProject,
@@ -891,6 +924,7 @@ export function useIssueSurfaceController({
negatedFilters,
propertyFilters: effectivePropertyFilters,
workingIssueIDs,
+ unreadIssueIDs,
showSubIssues,
loadProjects:
// The client-side project-status predicate (Gantt / swimlane extras)
@@ -993,7 +1027,8 @@ export function useIssueSurfaceController({
viewMode: effectiveViewMode,
allowGantt: allowedModes.has("gantt") && !!projectId,
...surfaceData,
- isLoading: data.isLoading || workingFilterPending,
+ isLoading:
+ data.isLoading || workingFilterPending || (unreadFilterUnresolved && !unreadFilterError),
workingAgents,
hasActiveFilters,
statusPagination: usesServerStatusSurface
@@ -1007,7 +1042,7 @@ export function useIssueSurfaceController({
// debounced value as well to avoid a brief empty-screen flash while a
// cleared query is waiting to re-fetch the unsearched window.
isEmpty:
- !workingFilterUnresolved &&
+ !membershipUnresolved &&
data.isEmpty &&
!data.isRefreshing &&
!(usesTable && (tableSearch.trim() || debouncedActiveSearch)),
@@ -1022,6 +1057,10 @@ export function useIssueSurfaceController({
retryWorkingFilter: () => {
void workingAgentsProjection.refetch();
},
+ isUnreadFilterError: unreadFilterError,
+ retryUnreadFilter: () => {
+ void unreadProjection.refetch();
+ },
sort,
actions,
selection,
diff --git a/packages/views/issues/surface/use-issue-surface-data.ts b/packages/views/issues/surface/use-issue-surface-data.ts
index 3b2b5caff4..38c7f95370 100644
--- a/packages/views/issues/surface/use-issue-surface-data.ts
+++ b/packages/views/issues/surface/use-issue-surface-data.ts
@@ -122,6 +122,7 @@ export function useIssueSurfaceData({
assigneeFilters,
includeNoAssignee,
agentRunningFilter,
+ unreadFilter,
creatorFilters,
projectFilters,
includeNoProject,
@@ -135,6 +136,7 @@ export function useIssueSurfaceData({
negatedFilters,
propertyFilters,
workingIssueIDs,
+ unreadIssueIDs,
showSubIssues,
loadProjects,
}: {
@@ -158,6 +160,7 @@ export function useIssueSurfaceData({
assigneeFilters: IssueFilterState["assigneeFilters"];
includeNoAssignee: boolean;
agentRunningFilter: boolean;
+ unreadFilter: boolean;
creatorFilters: IssueFilterState["creatorFilters"];
projectFilters: string[];
includeNoProject: boolean;
@@ -175,6 +178,8 @@ export function useIssueSurfaceData({
propertyFilters: Record<string, PropertyFilterValue[]>;
/** Distinct running-task issue ids projected by `/api/working-agents`. */
workingIssueIDs: ReadonlySet<string>;
+ /** The viewer's unread issue ids, plus those kept on screen after reading. */
+ unreadIssueIDs: ReadonlySet<string>;
showSubIssues: boolean;
loadProjects: boolean;
}): IssueSurfaceData {
@@ -224,8 +229,14 @@ export function useIssueSurfaceData({
const projectCatalogError = usesClientProjectStatusFilter && projectsError;
const workingFilterContext = useMemo(
- () => ({ runningIssueIds: workingIssueIDs, projectStatusById, relation: relationContext, today }),
- [projectStatusById, relationContext, today, workingIssueIDs],
+ () => ({
+ runningIssueIds: workingIssueIDs,
+ unreadIssueIds: unreadIssueIDs,
+ projectStatusById,
+ relation: relationContext,
+ today,
+ }),
+ [projectStatusById, relationContext, today, unreadIssueIDs, workingIssueIDs],
);
const bucketedIssues = serverStatusBranches.enabled
? serverStatusBranches.issues
@@ -261,12 +272,14 @@ export function useIssueSurfaceData({
negatedFilters,
propertyFilters,
workingOnly: agentRunningFilter,
+ unreadOnly: unreadFilter,
showSubIssues,
}),
[
advancedFilter,
assigneeFilters,
agentRunningFilter,
+ unreadFilter,
creatorFilters,
dueDateFilters,
includeNoAssignee,
@@ -447,6 +460,8 @@ export function useIssueSurfaceData({
includeNoAssignee,
agentRunningFilter,
runningIssueIds: workingIssueIDs,
+ unreadFilter,
+ unreadIssueIds: unreadIssueIDs,
creatorFilters,
projectFilters,
includeNoProject,
@@ -481,6 +496,8 @@ export function useIssueSurfaceData({
relationFilters,
showSubIssues,
today,
+ unreadFilter,
+ unreadIssueIDs,
workingIssueIDs,
],
);
diff --git a/packages/views/issues/utils/filter.test.ts b/packages/views/issues/utils/filter.test.ts
index 10f623d360..eb2c5a79d0 100644
--- a/packages/views/issues/utils/filter.test.ts
+++ b/packages/views/issues/utils/filter.test.ts
@@ -334,6 +334,33 @@ describe("filterIssues", () => {
expect(result.map((i) => i.id)).toEqual(["1"]);
});
+ // --- Unread filter ---
+ it("keeps only unread issues when unreadFilter is on", () => {
+ const result = filterIssues(issues, {
+ ...NO_FILTER,
+ unreadFilter: true,
+ unreadIssueIds: new Set(["1", "3"]),
+ });
+ expect(result.map((i) => i.id)).toEqual(["1", "3"]);
+ });
+
+ it("hides everything when unreadFilter is on and nothing is unread", () => {
+ const result = filterIssues(issues, {
+ ...NO_FILTER,
+ unreadFilter: true,
+ unreadIssueIds: new Set(),
+ });
+ expect(result).toHaveLength(0);
+ });
+
+ it("ignores unreadIssueIds when unreadFilter is off", () => {
+ const result = filterIssues(issues, {
+ ...NO_FILTER,
+ unreadIssueIds: new Set(["1"]),
+ });
+ expect(result).toHaveLength(4);
+ });
+
it("applies workingOnly from activity context without treating queued issues as working", () => {
const result = applyIssueFilters(
issues,
diff --git a/packages/views/issues/utils/filter.ts b/packages/views/issues/utils/filter.ts
index 33fd1069bb..8f7ebc9ef5 100644
--- a/packages/views/issues/utils/filter.ts
+++ b/packages/views/issues/utils/filter.ts
@@ -54,6 +54,11 @@ export interface IssueFilters {
// `/api/working-agents` projection so filter.ts stays free of fetching.
agentRunningFilter?: boolean;
runningIssueIds?: ReadonlySet<string>;
+ // When `unreadFilter` is true, only keep issues whose id is in
+ // `unreadIssueIds` — the viewer's unread list, plus any the surface keeps on
+ // screen after they were read.
+ unreadFilter?: boolean;
+ unreadIssueIds?: ReadonlySet<string>;
// "Show sub-issues" display toggle. When explicitly `false`, hide issues
// that have a parent so only top-level issues remain. Undefined / true keeps
// the default behaviour of showing everything, so existing callers that omit
@@ -82,6 +87,8 @@ export interface IssueFilterState {
negatedFilters?: readonly NegatableFilterDimension[];
propertyFilters?: Record<string, PropertyFilterValue[]>;
workingOnly: boolean;
+ /** Only issues in `IssueFilterContext.unreadIssueIds`. */
+ unreadOnly?: boolean;
/** See IssueFilters.showSubIssues — only an explicit `false` hides. */
showSubIssues?: boolean;
}
@@ -89,6 +96,9 @@ export interface IssueFilterState {
export interface IssueFilterContext {
activityByIssueId?: ReadonlyMap<string, IssueActivityState>;
runningIssueIds?: ReadonlySet<string>;
+ /** See IssueFilters.unreadIssueIds. A missing set with `unreadOnly` on
+ * matches nothing. */
+ unreadIssueIds?: ReadonlySet<string>;
/** Project id → its lifecycle status, from the workspace project list.
* Absent on surfaces that never load it, which makes the project-status
* filter a no-op there rather than blanking the surface. */
@@ -257,6 +267,7 @@ export function applyIssueFilters(
// filter is on but the set is missing/empty, hide everything — the
// user opted into "only running" and there is nothing running.
const applyWorkingOnly = workingOnly === true;
+ const applyUnreadOnly = filters.unreadOnly === true;
const hideSubIssues = filters.showSubIssues === false;
const relationFilters = filters.relationFilters ?? [];
@@ -275,6 +286,8 @@ export function applyIssueFilters(
return issues.filter((issue) => {
if (applyWorkingOnly && !issueIsWorking(issue.id, context))
return false;
+ if (applyUnreadOnly && context.unreadIssueIds?.has(issue.id) !== true)
+ return false;
if (hideSubIssues && issue.parent_issue_id) return false;
@@ -482,10 +495,12 @@ export function filterIssues(issues: Issue[], filters: IssueFilters): Issue[] {
negatedFilters: filters.negatedFilters,
propertyFilters: filters.propertyFilters,
workingOnly: filters.agentRunningFilter === true,
+ unreadOnly: filters.unreadFilter === true,
showSubIssues: filters.showSubIssues,
},
{
runningIssueIds: filters.runningIssueIds,
+ unreadIssueIds: filters.unreadIssueIds,
projectStatusById: filters.projectStatusById,
relation: filters.relationContext,
today: filters.today,
@@ -507,15 +522,18 @@ export function filterAssigneeGroups(
showSubIssues?: boolean;
agentRunningFilter?: boolean;
runningIssueIds?: ReadonlySet<string>;
+ unreadFilter?: boolean;
+ unreadIssueIds?: ReadonlySet<string>;
propertyFilters?: Record<string, PropertyFilterValue[]>;
},
): IssueAssigneeGroup[] | undefined {
const applyRunning = filters.agentRunningFilter === true;
+ const applyUnread = filters.unreadFilter === true;
const hideSubIssues = filters.showSubIssues === false;
const hasPropertyFilters = Object.values(filters.propertyFilters ?? {}).some(
(selected) => selected.length > 0,
);
- if (!groups || (!applyRunning && !hideSubIssues && !hasPropertyFilters)) return groups;
+ if (!groups || (!applyRunning && !applyUnread && !hideSubIssues && !hasPropertyFilters)) return groups;
const { runningIssueIds } = filters;
return groups
@@ -523,6 +541,8 @@ export function filterAssigneeGroups(
const issues = group.issues.filter((issue) => {
if (applyRunning && !(runningIssueIds?.has(issue.id) ?? false))
return false;
+ if (applyUnread && !(filters.unreadIssueIds?.has(issue.id) ?? false))
+ return false;
if (hideSubIssues && issue.parent_issue_id) return false;
if (hasPropertyFilters && !issueMatchesPropertyFilters(issue, filters.propertyFilters))
return false;
diff --git a/packages/views/layout/panels/sidebar-tree.tsx b/packages/views/layout/panels/sidebar-tree.tsx
index 4827bce8d6..84a17db808 100644
--- a/packages/views/layout/panels/sidebar-tree.tsx
+++ b/packages/views/layout/panels/sidebar-tree.tsx
@@ -193,13 +193,16 @@ export function useKeptActiveItem<T extends { id: string }>(
/**
* The issues under an expanded row: the first page, then "Load more" in
* steps. `params: null` means the row's settings can match nothing;
- * `undefined` that they are still resolving.
+ * `undefined` that they are still resolving, or — with `paramsError` — that
+ * they could not resolve, which `onRetry` tries again.
*/
export function SidebarIssueList({
id,
wsId,
source,
params,
+ paramsError = false,
+ onRetry,
activeIssueId,
onCollapse,
}: {
@@ -207,6 +210,8 @@ export function SidebarIssueList({
wsId: string;
source: string;
params: SidebarIssuesRequest | null | undefined;
+ paramsError?: boolean;
+ onRetry?: () => void;
activeIssueId: string | null;
onCollapse: () => void;
}) {
@@ -240,7 +245,21 @@ export function SidebarIssueList({
return (
<ul id={id} className="mb-2 ml-5 border-l border-surface-border pl-1.5">
- {params === undefined || (params && query.isPending) ? (
+ {params === undefined && paramsError ? (
+ <li className="flex h-[26px] items-center gap-2 px-2 text-caption text-faint-foreground">
+ <span className="min-w-0 truncate">{t(($) => $.panels.work.project_issues_error)}</span>
+ {onRetry && (
+ <button
+ type="button"
+ className="shrink-0 text-muted-foreground hover:text-foreground"
+ onKeyDown={onKeyDown}
+ onClick={onRetry}
+ >
+ {t(($) => $.panels.work.project_issues_retry)}
+ </button>
+ )}
+ </li>
+ ) : params === undefined || (params && query.isPending) ? (
<li className="flex h-[26px] items-center gap-2 px-2">
<div className="size-3 shrink-0 rounded-full bg-muted" />
<div className="h-3 w-24 rounded-xs bg-muted" />
diff --git a/packages/views/layout/panels/views-section.tsx b/packages/views/layout/panels/views-section.tsx
index 3298857d89..011cad8699 100644
--- a/packages/views/layout/panels/views-section.tsx
+++ b/packages/views/layout/panels/views-section.tsx
@@ -24,11 +24,13 @@ import {
SIDEBAR_FIRST_PAGE,
builtinSidebarRequest,
builtinSidebarSource,
+ viewSidebarNeedsUnread,
viewSidebarRequest,
viewSidebarSource,
type SidebarIssuesRequest,
} from "@multica/core/issues/sidebar-list";
import { todayDateOnly } from "@multica/core/issues/date";
+import { useIssueUnreadIds } from "@multica/core/issues/unread";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { useSidebarProjectPrefs } from "@multica/core/issues/sidebar-project-prefs";
import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
@@ -46,9 +48,11 @@ import { issueViewSeedDefinition } from "@multica/core/issue-views/definition";
import { useIssueViewRenameStore } from "@multica/core/issue-views/rename-store";
import { builtinViewItemId, type BuiltinViewKey, type SidebarViewItem } from "@multica/core/issue-views/sidebar-views";
import { issueViewTarget } from "@multica/core/issue-views/view-target";
+import { UNREAD_VIEW, UNREAD_VIEW_ID } from "@multica/core/issue-views/unread-view";
import { useIssueViewActions, type IssueViewActions } from "../../issue-views/use-view-actions";
import { DeleteViewDialog } from "../../issue-views/delete-view-dialog";
import { ViewNameInput } from "../../issue-views/view-name-input";
+import { UnreadViewIcon } from "../../issue-views/unread-view-icon";
import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";
import { useNavigation } from "../../navigation";
import { useT } from "../../i18n";
@@ -94,6 +98,19 @@ export function ViewsSection({
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
const collapsed = useSidebarTreeStore((s) => s.viewsCollapsed);
const setCollapsed = useSidebarTreeStore((s) => s.setViewsCollapsed);
+ // The Unread view is not part of the starred order: it follows All issues,
+ // or closes the list when All issues is not starred.
+ const allIssuesIndex = items.findIndex((item) => item.id === builtinViewItemId("all_issues"));
+ const unreadAfter = allIssuesIndex === -1 ? items.length - 1 : allIssuesIndex;
+ const unreadRow = (
+ <UnreadViewRow
+ key={UNREAD_VIEW_ID}
+ wsId={wsId}
+ pathname={pathname}
+ plainRowsLit={plainRowsLit}
+ activeIssueId={activeIssueId}
+ />
+ );
const onDragEnd = useCallback(
({ active, over }: DragEndEvent) => {
@@ -136,7 +153,8 @@ export function ViewsSection({
<DndContext sensors={sensors} collisionDetection={closestCenter} modifiers={DRAG_MODIFIERS} onDragEnd={onDragEnd}>
<SortableContext items={items.map((item) => item.id)} strategy={verticalListSortingStrategy}>
<PanelList>
- {items.map((item) => (
+ {unreadAfter === -1 && unreadRow}
+ {items.map((item, index) => [
<SortableViewRow key={item.id} id={item.id}>
{(drag) =>
item.kind === "builtin" ? (
@@ -163,8 +181,9 @@ export function ViewsSection({
/>
)
}
- </SortableViewRow>
- ))}
+ </SortableViewRow>,
+ index === unreadAfter && unreadRow,
+ ])}
</PanelList>
</SortableContext>
</DndContext>
@@ -379,6 +398,76 @@ function BuiltinViewRow({
);
}
+/**
+ * The built-in Unread view. It shows only while the viewer has unread
+ * issues, and stays while its page is open so reading the last one does not
+ * pull the row out from under the reader.
+ */
+function UnreadViewRow({
+ wsId,
+ pathname,
+ plainRowsLit,
+ activeIssueId,
+}: {
+ wsId: string;
+ pathname: string;
+ plainRowsLit: boolean;
+ activeIssueId: string | null;
+}) {
+ const { t } = useT("layout");
+ const p = useWorkspacePaths();
+ const listId = useId();
+ const linkRef = useRef<HTMLAnchorElement>(null);
+ const target = issueViewTarget(wsId, UNREAD_VIEW, p);
+ const open = useActiveIssueViewStore(
+ (s) => pathname === target.path && s.active[target.containerKey] === UNREAD_VIEW_ID,
+ );
+ const setActive = useActiveIssueViewStore((s) => s.setActive);
+ const source = viewSidebarSource(UNREAD_VIEW_ID);
+ const expanded = useSidebarTreeStore((s) => s.expanded.includes(source));
+ const setExpanded = useSidebarTreeStore((s) => s.setExpanded);
+ const unread = useIssueUnreadIds(wsId);
+ const count = unread.ids?.length ?? 0;
+ const request = unread.ids ? viewSidebarRequest(UNREAD_VIEW, todayDateOnly(), unread.ids) : undefined;
+ const prefetch = usePrefetch(wsId, source, request);
+
+ if (count === 0 && !open) return null;
+ const label = t(($) => $.panels.work.unread);
+ return (
+ <li>
+ <TreeRow
+ ref={linkRef}
+ href={target.href}
+ label={label}
+ icon={<UnreadViewIcon />}
+ active={plainRowsLit && open}
+ expanded={expanded}
+ onExpandedChange={(next) => setExpanded(source, next)}
+ listId={listId}
+ toggleLabel={t(($) => $.panels.work.project_issues, { name: label })}
+ onPrefetch={prefetch}
+ onNavigateInPlace={() => setActive(target.containerKey, UNREAD_VIEW_ID)}
+ trailing={<PanelCount value={count} className="font-medium text-brand" />}
+ />
+ {expanded && (
+ <SidebarIssueList
+ id={listId}
+ wsId={wsId}
+ source={source}
+ params={request}
+ paramsError={unread.isError}
+ onRetry={() => void unread.refetch()}
+ activeIssueId={activeIssueId}
+ onCollapse={() => {
+ setExpanded(source, false);
+ linkRef.current?.focus();
+ }}
+ />
+ )}
+ </li>
+ );
+}
+
function SavedViewRow({
wsId,
item,
@@ -417,7 +506,10 @@ function SavedViewRow({
const source = viewSidebarSource(view.id);
const expanded = useSidebarTreeStore((s) => s.expanded.includes(source));
const setExpanded = useSidebarTreeStore((s) => s.setExpanded);
- const request = viewSidebarRequest(view, todayDateOnly());
+ const needsUnread = viewSidebarNeedsUnread(view);
+ const unread = useIssueUnreadIds(wsId, needsUnread);
+ const request =
+ needsUnread && !unread.ids ? undefined : viewSidebarRequest(view, todayDateOnly(), unread.ids);
const prefetch = usePrefetch(wsId, source, request);
const canManage = actions.canManage(view);
@@ -497,6 +589,8 @@ function SavedViewRow({
wsId={wsId}
source={source}
params={request}
+ paramsError={needsUnread && unread.isError}
+ onRetry={() => void unread.refetch()}
activeIssueId={activeIssueId}
onCollapse={() => {
setExpanded(source, false);
diff --git a/packages/views/layout/panels/views-section.unread.test.tsx b/packages/views/layout/panels/views-section.unread.test.tsx
new file mode 100644
index 0000000000..d105d29f6f
--- /dev/null
+++ b/packages/views/layout/panels/views-section.unread.test.tsx
@@ -0,0 +1,186 @@
+import type { ReactNode } from "react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { fireEvent, screen, waitFor } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { setApiInstance } from "@multica/core/api";
+import type { ApiClient } from "@multica/core/api/client";
+import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
+import { viewSidebarSource } from "@multica/core/issues/sidebar-list";
+import { issueViewContainerKey, useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";
+import { UNREAD_VIEW_ID } from "@multica/core/issue-views/unread-view";
+import { renderWithI18n } from "../../test/i18n";
+import { NavigationProvider, type NavigationAdapter } from "../../navigation";
+import { ViewsSection } from "./views-section";
+
+const actions = vi.hoisted(() => ({
+ sidebar: { items: [] as unknown[], reorder: vi.fn(), unstar: vi.fn() },
+ create: vi.fn(),
+ remove: vi.fn(),
+ canManage: () => true,
+}));
+
+vi.mock("../../issue-views/use-view-actions", () => ({ useIssueViewActions: () => actions }));
+vi.mock("../../issue-views/delete-view-dialog", () => ({ DeleteViewDialog: () => null }));
+vi.mock("@dnd-kit/core", () => ({
+ DndContext: ({ children }: { children: ReactNode }) => <>{children}</>,
+ PointerSensor: vi.fn(),
+ closestCenter: vi.fn(),
+ useSensor: vi.fn(),
+ useSensors: vi.fn(),
+}));
+vi.mock("@dnd-kit/sortable", () => ({
+ SortableContext: ({ children }: { children: ReactNode }) => <>{children}</>,
+ useSortable: () => ({ listeners: {}, setNodeRef: vi.fn(), setActivatorNodeRef: vi.fn() }),
+ verticalListSortingStrategy: vi.fn(),
+ arrayMove: vi.fn(),
+}));
+vi.mock("@multica/ui/components/common/tooltip-hint", () => ({
+ TooltipHint: ({ children }: { children: ReactNode }) => <>{children}</>,
+}));
+vi.mock("@multica/core/paths", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@multica/core/paths")>();
+ return { ...actual, useWorkspacePaths: () => actual.paths.workspace("acme") };
+});
+vi.mock("@multica/core/hooks", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@multica/core/hooks")>()),
+ useWorkspaceId: () => "ws-1",
+}));
+vi.mock("@multica/core/issue-statuses/hooks", async () => {
+ const { buildIssueStatusCatalog } = await import("@multica/core/issue-statuses/queries");
+ return { useIssueStatuses: () => buildIssueStatusCatalog([]) };
+});
+
+const adapter: NavigationAdapter = {
+ push: vi.fn(),
+ replace: vi.fn(),
+ back: vi.fn(),
+ pathname: "/acme/issues",
+ searchParams: new URLSearchParams(),
+ hash: "",
+ getShareableUrl: (path) => path,
+};
+
+const UNREAD_VIEW = {
+ id: "v1",
+ name: "Mine unread",
+ scope_type: "workspace",
+ scope_id: null,
+ scope_variant: null,
+ query: { unreadFilter: true },
+ display: {},
+};
+
+let listIssueUnread: ReturnType<typeof vi.fn>;
+let listIssueTableRows: ReturnType<typeof vi.fn>;
+
+function renderSection() {
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ return renderWithI18n(
+ <QueryClientProvider client={qc}>
+ <NavigationProvider value={adapter}>
+ <ViewsSection
+ wsId="ws-1"
+ pathname="/acme/issues"
+ plainRowsLit
+ issueLitInTree={false}
+ activeIssueId={null}
+ />
+ </NavigationProvider>
+ </QueryClientProvider>,
+ );
+}
+
+beforeEach(() => {
+ listIssueUnread = vi.fn();
+ listIssueTableRows = vi.fn(async () => ({
+ rows: [],
+ total: 0,
+ next_cursor: null,
+ query_fingerprint: "fp",
+ group_key: null,
+ parent_id: null,
+ }));
+ setApiInstance({
+ listIssueUnread,
+ listIssueTableRows,
+ listIssueViews: vi.fn(async () => []),
+ getIssueViewPreference: vi.fn(() => new Promise(() => {})),
+ } as unknown as ApiClient);
+ useActiveIssueViewStore.setState({ active: {} });
+ actions.sidebar.items = [{ id: "view:v1", kind: "view", view: UNREAD_VIEW }];
+ useSidebarTreeStore.setState({ viewsCollapsed: false, expanded: [viewSidebarSource("v1")] });
+});
+
+describe("ViewsSection saved view with the unread filter", () => {
+ it("offers a retry when the unread list fails, then lists the view's issues", async () => {
+ listIssueUnread.mockRejectedValueOnce(new Error("offline"));
+ renderSection();
+
+ const retry = await screen.findByRole("button", { name: "Retry" });
+ expect(screen.getByText("Couldn't load issues")).toBeInTheDocument();
+ expect(listIssueTableRows).not.toHaveBeenCalled();
+
+ listIssueUnread.mockResolvedValue([
+ { issue_id: "issue-1", outcome: "manual", agent_id: null, created_at: "2026-01-01T00:00:00Z" },
+ ]);
+ fireEvent.click(retry);
+
+ await screen.findByText("No issues");
+ expect(screen.queryByRole("button", { name: "Retry" })).toBeNull();
+ await waitFor(() =>
+ expect(listIssueTableRows).toHaveBeenCalledWith(
+ expect.objectContaining({
+ query: expect.objectContaining({
+ filters: expect.objectContaining({ unread_issue_ids: ["issue-1"] }),
+ }),
+ }),
+ ),
+ );
+ });
+});
+
+const mark = (issueId: string) => ({
+ issue_id: issueId,
+ outcome: "completed",
+ agent_id: null,
+ created_at: "2026-01-01T00:00:00Z",
+});
+
+describe("ViewsSection built-in Unread view", () => {
+ beforeEach(() => {
+ actions.sidebar.items = [
+ { id: "builtin:all_issues", kind: "builtin", key: "all_issues" },
+ { id: "view:v1", kind: "view", view: UNREAD_VIEW },
+ ];
+ useSidebarTreeStore.setState({ viewsCollapsed: false, expanded: [] });
+ });
+
+ it("is hidden while nothing is unread", async () => {
+ listIssueUnread.mockResolvedValue([]);
+ renderSection();
+ await waitFor(() => expect(listIssueUnread).toHaveBeenCalled());
+ await screen.findByRole("link", { name: "All issues" });
+ expect(screen.queryByRole("link", { name: /^Unread/ })).toBeNull();
+ });
+
+ it("appears right after All issues with the unread count", async () => {
+ listIssueUnread.mockResolvedValue([mark("a"), mark("b")]);
+ renderSection();
+ const link = await screen.findByRole("link", { name: /^Unread/ });
+ expect(link).toHaveAttribute("href", "/acme/issues?view=unread");
+ expect(link.closest("li")).toHaveTextContent("Unread2");
+ const names = screen.getAllByRole("link").map((l) => l.textContent);
+ expect(names.slice(0, 3)).toEqual(["All issues", "Unread", "Mine unread"]);
+ });
+
+ it("stays while its page is open, even once everything is read", async () => {
+ listIssueUnread.mockResolvedValue([]);
+ useActiveIssueViewStore
+ .getState()
+ .setActive(issueViewContainerKey("ws-1", { scope_type: "workspace" }), UNREAD_VIEW_ID);
+ renderSection();
+ const link = await screen.findByRole("link", { name: /^Unread/ });
+ expect(link).toHaveAttribute("aria-current", "page");
+ expect(screen.getByRole("link", { name: /^All issues/ })).not.toHaveAttribute("aria-current");
+ });
+});
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index dac3750e94..aaaf0ea631 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -39,6 +39,9 @@
"working_filter_error": {
"title": "Couldn't load issues with working agents"
},
+ "unread_filter_error": {
+ "title": "Couldn't load your unread issues"
+ },
"status_catalog_error": {
"title": "Couldn't load the status list",
"hint": "Issues can't be shown until statuses load.",
@@ -183,6 +186,8 @@
"relation_my_agents": "Assigned to my agents",
"section_agent_status": "Agent status",
"agent_status_running": "Running",
+ "section_read_state": "Read state",
+ "read_state_unread": "Unread",
"operator_label": "Match",
"operator_is": "is",
"operator_is_not": "is not",
@@ -783,6 +788,7 @@
},
"filtered_empty": {
"title": "No issues match these filters",
+ "unread_title": "No unread issues",
"clear_button": "Clear filters"
},
"agent_live": {
@@ -1790,7 +1796,8 @@
"builtin": {
"my_issues": "My Issues",
"my_agents": "My agents' work",
- "all_issues": "All issues"
+ "all_issues": "All issues",
+ "unread": "Unread"
},
"untitled": "Untitled view",
"copy_name": "{{name}} (copy)",
diff --git a/packages/views/locales/en/layout.json b/packages/views/locales/en/layout.json
index d349d889a3..79d30a7dd2 100644
--- a/packages/views/locales/en/layout.json
+++ b/packages/views/locales/en/layout.json
@@ -110,6 +110,7 @@
"work": {
"my_agents": "My agents' work",
"all_issues": "All issues",
+ "unread": "Unread",
"views": "Views",
"new_project": "New project",
"new_issue_in_project": "New issue in {{name}}",
@@ -118,6 +119,7 @@
"project_issues": "Issues in {{name}}",
"project_issues_empty": "No issues",
"project_issues_error": "Couldn't load issues",
+ "project_issues_retry": "Retry",
"project_issues_settings": "Issues in projects",
"settings_status": "Status",
"settings_assignee": "Assignee",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index d8d7538e6b..b9e2f3dfda 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -39,6 +39,9 @@
"working_filter_error": {
"title": "Impossible de charger les tâches en cours de traitement par les agents"
},
+ "unread_filter_error": {
+ "title": "Impossible de charger vos tâches non lues"
+ },
"status_catalog_error": {
"title": "Impossible de charger la liste des états",
"hint": "Les tâches ne peuvent pas s’afficher tant que les statuts ne sont pas chargés.",
@@ -183,6 +186,8 @@
"relation_my_agents": "Assignés à mes agents",
"section_agent_status": "Statut de l'agent",
"agent_status_running": "En cours d'exécution",
+ "section_read_state": "État de lecture",
+ "read_state_unread": "Non lu",
"operator_label": "Condition",
"operator_is": "est",
"operator_is_not": "n'est pas",
@@ -783,6 +788,7 @@
},
"filtered_empty": {
"title": "Aucune tâche ne correspond à ces filtres",
+ "unread_title": "Aucune tâche non lue",
"clear_button": "Effacer les filtres"
},
"agent_live": {
@@ -1790,7 +1796,8 @@
"builtin": {
"my_issues": "Mes tâches",
"my_agents": "Travail de mes agents",
- "all_issues": "Toutes les tâches"
+ "all_issues": "Toutes les tâches",
+ "unread": "Non lues"
},
"untitled": "Vue sans titre",
"copy_name": "{{name}} (copie)",
diff --git a/packages/views/locales/fr/layout.json b/packages/views/locales/fr/layout.json
index ee62af08f4..e5d7a23edb 100644
--- a/packages/views/locales/fr/layout.json
+++ b/packages/views/locales/fr/layout.json
@@ -110,6 +110,7 @@
"work": {
"my_agents": "Travail de mes agents",
"all_issues": "Toutes les tâches",
+ "unread": "Non lues",
"views": "Vues",
"new_project": "Nouveau projet",
"new_issue_in_project": "Nouvelle tâche dans {{name}}",
@@ -118,6 +119,7 @@
"project_issues": "Tâches de {{name}}",
"project_issues_empty": "Aucune tâche",
"project_issues_error": "Impossible de charger les tâches",
+ "project_issues_retry": "Réessayer",
"project_issues_settings": "Tâches des projets",
"settings_status": "Statut",
"settings_assignee": "Responsable",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index b535527183..23ea4071bd 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -38,6 +38,9 @@
"working_filter_error": {
"title": "エージェントが作業中のタスクを読み込めませんでした"
},
+ "unread_filter_error": {
+ "title": "未読のタスクを読み込めませんでした"
+ },
"status_catalog_error": {
"title": "ステータス一覧を読み込めませんでした",
"hint": "ステータスを読み込むまでタスクを表示できません。",
@@ -181,6 +184,8 @@
"relation_my_agents": "自分のエージェントが担当",
"section_agent_status": "エージェントの状態",
"agent_status_running": "実行中",
+ "section_read_state": "既読状態",
+ "read_state_unread": "未読",
"operator_label": "条件",
"operator_is": "一致",
"operator_is_not": "除外",
@@ -754,6 +759,7 @@
},
"filtered_empty": {
"title": "フィルター条件に一致するタスクがありません",
+ "unread_title": "未読のタスクはありません",
"clear_button": "フィルターを解除"
},
"agent_live": {
@@ -1722,7 +1728,8 @@
"builtin": {
"my_issues": "マイタスク",
"my_agents": "マイエージェントの作業",
- "all_issues": "すべてのタスク"
+ "all_issues": "すべてのタスク",
+ "unread": "未読"
},
"untitled": "無題のビュー",
"copy_name": "{{name}}(コピー)",
diff --git a/packages/views/locales/ja/layout.json b/packages/views/locales/ja/layout.json
index 2a3ebedec2..4dd12a2751 100644
--- a/packages/views/locales/ja/layout.json
+++ b/packages/views/locales/ja/layout.json
@@ -109,6 +109,7 @@
"work": {
"my_agents": "マイエージェントの作業",
"all_issues": "すべてのタスク",
+ "unread": "未読",
"views": "ビュー",
"new_project": "新規プロジェクト",
"new_issue_in_project": "{{name}} に新規タスク",
@@ -116,6 +117,7 @@
"project_issues": "{{name}} のタスク",
"project_issues_empty": "タスクはありません",
"project_issues_error": "タスクを読み込めませんでした",
+ "project_issues_retry": "再試行",
"project_issues_settings": "プロジェクトのタスク",
"settings_status": "ステータス",
"settings_assignee": "担当者",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index e2d509236f..471c100ff1 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -38,6 +38,9 @@
"working_filter_error": {
"title": "에이전트가 작업 중인 태스크를 불러오지 못했습니다"
},
+ "unread_filter_error": {
+ "title": "읽지 않은 태스크를 불러오지 못했습니다"
+ },
"status_catalog_error": {
"title": "상태 목록을 불러오지 못했습니다",
"hint": "상태를 불러와야 태스크를 표시할 수 있습니다.",
@@ -181,6 +184,8 @@
"relation_my_agents": "내 에이전트가 담당",
"section_agent_status": "에이전트 상태",
"agent_status_running": "실행 중",
+ "section_read_state": "읽음 상태",
+ "read_state_unread": "읽지 않음",
"operator_label": "조건",
"operator_is": "일치",
"operator_is_not": "제외",
@@ -754,6 +759,7 @@
},
"filtered_empty": {
"title": "필터 조건에 맞는 태스크가 없습니다",
+ "unread_title": "읽지 않은 태스크가 없습니다",
"clear_button": "필터 해제"
},
"agent_live": {
@@ -1722,7 +1728,8 @@
"builtin": {
"my_issues": "내 태스크",
"my_agents": "내 에이전트의 작업",
- "all_issues": "전체 태스크"
+ "all_issues": "전체 태스크",
+ "unread": "읽지 않음"
},
"untitled": "제목 없는 뷰",
"copy_name": "{{name}} (사본)",
diff --git a/packages/views/locales/ko/layout.json b/packages/views/locales/ko/layout.json
index dc4b460092..5bbadfd9be 100644
--- a/packages/views/locales/ko/layout.json
+++ b/packages/views/locales/ko/layout.json
@@ -109,6 +109,7 @@
"work": {
"my_agents": "내 에이전트의 작업",
"all_issues": "전체 태스크",
+ "unread": "읽지 않음",
"views": "뷰",
"new_project": "새 프로젝트",
"new_issue_in_project": "{{name}}에 새 태스크",
@@ -116,6 +117,7 @@
"project_issues": "{{name}}의 태스크",
"project_issues_empty": "태스크가 없습니다",
"project_issues_error": "태스크를 불러오지 못했습니다",
+ "project_issues_retry": "다시 시도",
"project_issues_settings": "프로젝트 태스크",
"settings_status": "상태",
"settings_assignee": "담당자",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 5bf52622c8..d353524b15 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -38,6 +38,9 @@
"working_filter_error": {
"title": "无法加载智能体正在处理的任务"
},
+ "unread_filter_error": {
+ "title": "无法加载未读任务"
+ },
"status_catalog_error": {
"title": "状态列表加载失败",
"hint": "加载状态后才能显示任务。",
@@ -181,6 +184,8 @@
"relation_my_agents": "分配给我的智能体的",
"section_agent_status": "智能体状态",
"agent_status_running": "运行中",
+ "section_read_state": "阅读状态",
+ "read_state_unread": "未读",
"operator_label": "关系",
"operator_is": "是",
"operator_is_not": "不是",
@@ -754,6 +759,7 @@
},
"filtered_empty": {
"title": "没有符合筛选条件的任务",
+ "unread_title": "没有未读任务",
"clear_button": "清除筛选"
},
"agent_live": {
@@ -1722,7 +1728,8 @@
"builtin": {
"my_issues": "我的任务",
"my_agents": "我的智能体在做",
- "all_issues": "全部任务"
+ "all_issues": "全部任务",
+ "unread": "未读"
},
"untitled": "未命名视图",
"copy_name": "{{name}}(副本)",
diff --git a/packages/views/locales/zh-Hans/layout.json b/packages/views/locales/zh-Hans/layout.json
index 461f397536..138ca56243 100644
--- a/packages/views/locales/zh-Hans/layout.json
+++ b/packages/views/locales/zh-Hans/layout.json
@@ -109,6 +109,7 @@
"work": {
"my_agents": "我的智能体在做",
"all_issues": "全部任务",
+ "unread": "未读",
"views": "视图",
"new_project": "新建项目",
"new_issue_in_project": "在 {{name}} 中新建任务",
@@ -116,6 +117,7 @@
"project_issues": "{{name}} 的任务",
"project_issues_empty": "没有任务",
"project_issues_error": "无法加载任务",
+ "project_issues_retry": "重试",
"project_issues_settings": "项目中的任务",
"settings_status": "状态",
"settings_assignee": "负责人",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 6903a3169d..34e7cae1dd 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -38,6 +38,9 @@
"working_filter_error": {
"title": "無法載入 AI 代理正在處理的任務"
},
+ "unread_filter_error": {
+ "title": "無法載入未讀任務"
+ },
"status_catalog_error": {
"title": "狀態列表載入失敗",
"hint": "載入狀態後才能顯示任務。",
@@ -181,6 +184,8 @@
"relation_my_agents": "分配給我的 AI 代理的",
"section_agent_status": "AI 代理狀態",
"agent_status_running": "執行中",
+ "section_read_state": "閱讀狀態",
+ "read_state_unread": "未讀",
"operator_label": "關係",
"operator_is": "是",
"operator_is_not": "不是",
@@ -754,6 +759,7 @@
},
"filtered_empty": {
"title": "沒有符合篩選條件的任務",
+ "unread_title": "沒有未讀任務",
"clear_button": "清除篩選"
},
"agent_live": {
@@ -1722,7 +1728,8 @@
"builtin": {
"my_issues": "我的任務",
"my_agents": "我的 AI 代理在做",
- "all_issues": "全部任務"
+ "all_issues": "全部任務",
+ "unread": "未讀"
},
"untitled": "未命名檢視",
"copy_name": "{{name}}(副本)",
diff --git a/packages/views/locales/zh-Hant/layout.json b/packages/views/locales/zh-Hant/layout.json
index 12aca09026..4b8a9fa6d3 100644
--- a/packages/views/locales/zh-Hant/layout.json
+++ b/packages/views/locales/zh-Hant/layout.json
@@ -109,6 +109,7 @@
"work": {
"my_agents": "我的 AI 代理在做",
"all_issues": "全部任務",
+ "unread": "未讀",
"views": "檢視",
"new_project": "新建專案",
"new_issue_in_project": "在 {{name}} 中新建任務",
@@ -116,6 +117,7 @@
"project_issues": "{{name}} 的任務",
"project_issues_empty": "沒有任務",
"project_issues_error": "無法載入任務",
+ "project_issues_retry": "重試",
"project_issues_settings": "專案中的任務",
"settings_status": "狀態",
"settings_assignee": "負責人",
diff --git a/server/internal/handler/issue_table_query.go b/server/internal/handler/issue_table_query.go
index 3b667ea59e..d80c541b96 100644
--- a/server/internal/handler/issue_table_query.go
+++ b/server/internal/handler/issue_table_query.go
@@ -109,11 +109,15 @@ type issueTableFiltersRequest struct {
Advanced *issueTableFilterNode `json:"advanced,omitempty"`
// Members are raw JSON so operator objects ({op, value}) and plain
// strings both survive the round-trip into parsePropertiesFilterParam.
- Properties map[string][]json.RawMessage `json:"properties,omitempty"`
- Date *issueTableDateFilterRequest `json:"date,omitempty"`
- WorkingOnly bool `json:"working_only,omitempty"`
- WorkingIssueIDs []string `json:"working_issue_ids,omitempty"`
- IncludeSubIssues *bool `json:"include_sub_issues,omitempty"`
+ Properties map[string][]json.RawMessage `json:"properties,omitempty"`
+ Date *issueTableDateFilterRequest `json:"date,omitempty"`
+ WorkingOnly bool `json:"working_only,omitempty"`
+ WorkingIssueIDs []string `json:"working_issue_ids,omitempty"`
+ // UnreadIssueIDs is the viewer's unread issues as the client holds them
+ // (`/api/issues/unread`, plus any it keeps on screen after reading). An
+ // explicit empty list matches nothing.
+ UnreadIssueIDs []string `json:"unread_issue_ids,omitempty"`
+ IncludeSubIssues *bool `json:"include_sub_issues,omitempty"`
}
type issueTableSortRequest struct {
@@ -270,6 +274,8 @@ func canonicalIssueTableFingerprint(workspaceID string, spec issueTableQuerySpec
spec.Filters.Assignees != nil && len(spec.Filters.Assignees) == 0
explicitEmptyWorkingIssues :=
spec.Filters.WorkingIssueIDs != nil && len(spec.Filters.WorkingIssueIDs) == 0
+ explicitEmptyUnreadIssues :=
+ spec.Filters.UnreadIssueIDs != nil && len(spec.Filters.UnreadIssueIDs) == 0
normalized := spec
normalized.Search = strings.TrimSpace(normalized.Search)
normalized.Scope.AssigneeTypes = sortedUniqueStrings(normalized.Scope.AssigneeTypes)
@@ -284,6 +290,7 @@ func canonicalIssueTableFingerprint(workspaceID string, spec issueTableQuerySpec
normalized.Filters.Advanced = canonicalIssueTableFilterNode(normalized.Filters.Advanced)
normalized.Filters.Assignees = sortedUniqueActors(normalized.Filters.Assignees)
normalized.Filters.WorkingIssueIDs = sortedUniqueStrings(normalized.Filters.WorkingIssueIDs)
+ normalized.Filters.UnreadIssueIDs = sortedUniqueStrings(normalized.Filters.UnreadIssueIDs)
normalized.Filters.Creators = sortedUniqueActors(normalized.Filters.Creators)
for key, values := range normalized.Filters.Properties {
normalized.Filters.Properties[key] = sortedUniqueRawJSON(values)
@@ -293,11 +300,13 @@ func canonicalIssueTableFingerprint(workspaceID string, spec issueTableQuerySpec
Query issueTableQuerySpec `json:"query"`
ExplicitEmptyAssignees bool `json:"explicit_empty_assignees,omitempty"`
ExplicitEmptyWorkingIssues bool `json:"explicit_empty_working_issues,omitempty"`
+ ExplicitEmptyUnreadIssues bool `json:"explicit_empty_unread_issues,omitempty"`
}{
WorkspaceID: workspaceID,
Query: normalized,
ExplicitEmptyAssignees: explicitEmptyAssignees,
ExplicitEmptyWorkingIssues: explicitEmptyWorkingIssues,
+ ExplicitEmptyUnreadIssues: explicitEmptyUnreadIssues,
})
if err != nil {
return "", err
@@ -832,6 +841,20 @@ func (h *Handler) compileIssueTableQuery(w http.ResponseWriter, r *http.Request,
))
}
}
+ unreadIssueIDs, ok := parseIssueTableUUIDList(w, spec.Filters.UnreadIssueIDs, "filters.unread_issue_ids")
+ if !ok {
+ return issueTableSQL{}, false
+ }
+ if spec.Filters.UnreadIssueIDs != nil {
+ if len(unreadIssueIDs) == 0 {
+ where = append(where, "FALSE")
+ } else {
+ where = append(where, fmt.Sprintf(
+ "i.id = ANY(%s::uuid[])",
+ addArg(unreadIssueIDs),
+ ))
+ }
+ }
if spec.Filters.IncludeSubIssues != nil && !*spec.Filters.IncludeSubIssues {
where = append(where, "i.parent_issue_id IS NULL")
}
diff --git a/server/internal/handler/issue_table_query_test.go b/server/internal/handler/issue_table_query_test.go
index 300a77a7c7..78db825ba3 100644
--- a/server/internal/handler/issue_table_query_test.go
+++ b/server/internal/handler/issue_table_query_test.go
@@ -273,6 +273,79 @@ func TestIssueTableWorkingIssueIDsAreExplicitAndAssigneeIndependent(t *testing.T
}
}
+func TestIssueTableUnreadIssueIDsAreExplicit(t *testing.T) {
+ if testHandler == nil {
+ t.Skip("database not available")
+ }
+
+ base := issueTableQuerySpec{
+ Scope: issueTableScope{Kind: "workspace"},
+ Sort: issueTableSortRequest{Field: "position", Direction: "asc"},
+ }
+ withEmpty := base
+ withEmpty.Filters.UnreadIssueIDs = []string{}
+ withEmptyWorking := base
+ withEmptyWorking.Filters.WorkingIssueIDs = []string{}
+
+ unfilteredFingerprint, err := canonicalIssueTableFingerprint(testWorkspaceID, base)
+ if err != nil {
+ t.Fatal(err)
+ }
+ emptyFingerprint, err := canonicalIssueTableFingerprint(testWorkspaceID, withEmpty)
+ if err != nil {
+ t.Fatal(err)
+ }
+ emptyWorkingFingerprint, err := canonicalIssueTableFingerprint(testWorkspaceID, withEmptyWorking)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if unfilteredFingerprint == emptyFingerprint {
+ t.Fatal("explicit empty unread_issue_ids must not share the unfiltered cursor fingerprint")
+ }
+ if emptyWorkingFingerprint == emptyFingerprint {
+ t.Fatal("explicit empty unread_issue_ids must not share the empty working_issue_ids fingerprint")
+ }
+
+ w := httptest.NewRecorder()
+ compiled, ok := testHandler.compileIssueTableQuery(
+ w,
+ newRequest(http.MethodPost, "/api/issues/table/rows", nil),
+ withEmpty,
+ )
+ if !ok {
+ t.Fatalf("compile empty filter: %d %s", w.Code, w.Body.String())
+ }
+ if !strings.Contains(compiled.where, "FALSE") {
+ t.Fatalf("explicit empty unread_issue_ids predicate = %q, want FALSE", compiled.where)
+ }
+
+ withIssue := base
+ withIssue.Filters.UnreadIssueIDs = []string{"00000000-0000-4000-8000-000000000001"}
+ w = httptest.NewRecorder()
+ compiled, ok = testHandler.compileIssueTableQuery(
+ w,
+ newRequest(http.MethodPost, "/api/issues/table/rows", nil),
+ withIssue,
+ )
+ if !ok {
+ t.Fatalf("compile issue filter: %d %s", w.Code, w.Body.String())
+ }
+ if !strings.Contains(compiled.where, "i.id = ANY(") {
+ t.Errorf("unread-issue predicate = %q, want issue-id membership", compiled.where)
+ }
+
+ invalid := base
+ invalid.Filters.UnreadIssueIDs = []string{"not-a-uuid"}
+ w = httptest.NewRecorder()
+ if _, ok := testHandler.compileIssueTableQuery(
+ w,
+ newRequest(http.MethodPost, "/api/issues/table/rows", nil),
+ invalid,
+ ); ok || w.Code != http.StatusBadRequest {
+ t.Fatalf("invalid unread_issue_ids: ok=%v code=%d, want 400", ok, w.Code)
+ }
+}
+
func TestIssueTableWorkingIssueProjectionMatchesTaskIssuesNotAssignees(t *testing.T) {
if testHandler == nil {
t.Skip("database not available")