Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): move issue refresh feedback into page title icons (#8430)
Jiayuan Zhanga3318b68deb5
diff --git a/packages/views/issues/components/issues-header.tsx b/packages/views/issues/components/issues-header.tsxindex a6fdcf6fab..b7af5db7b9 100644--- a/packages/views/issues/components/issues-header.tsx+++ b/packages/views/issues/components/issues-header.tsx@@ -1146,7 +1146,7 @@ export function IssuesHeader({allowGantt = false,dateFilter = null,onDateFilterChange,- isRefreshing = false,+ isRefreshing,facetCountsExact = true,tableFacetCounts,onTableFacetChange,@@ -1159,6 +1159,7 @@ export function IssuesHeader({allowGantt?: boolean;dateFilter?: IssueDateFilter | null;onDateFilterChange?: (filter: IssueDateFilter | null) => void;+ /** Omit when the page title already displays refresh feedback. */isRefreshing?: boolean;/** See IssueDisplayControls.facetCountsExact. */facetCountsExact?: boolean;@@ -1342,7 +1343,7 @@ export function IssuesHeader({onTableFacetChange={onTableFacetChange}viewBaseline={viewBaseline}/>- <ViewRefreshIndicator active={isRefreshing} />+ {isRefreshing !== undefined && <ViewRefreshIndicator active={isRefreshing} />}</div></div></div>diff --git a/packages/views/issues/components/issues-page.tsx b/packages/views/issues/components/issues-page.tsxindex 1ee80e4ecf..248188551a 100644--- a/packages/views/issues/components/issues-page.tsx+++ b/packages/views/issues/components/issues-page.tsx@@ -10,6 +10,7 @@ import type {import { useIssuesScope } from "@multica/core/issues/stores/issues-scope-store";import { useViewStore } from "@multica/core/issues/stores/view-store-context";import { PageHeader } from "../../layout/page-header";+import { RefreshablePageIcon } from "../../layout/refreshable-page-icon";import { useT } from "../../i18n";import { IssueSurface } from "../surface/issue-surface";import { IssuesHeader } from "./issues-header";@@ -29,20 +30,28 @@ function IssuesSurfaceHeader({tableFacetCounts?: IssueTableFacetsResponse;onTableFacetChange: (facet: IssueTableFacetSpec | null) => void;}) {+ const { t } = useT("issues");const dateFilter = useViewStore((s) => s.dateFilter);const setDateFilter = useViewStore((s) => s.setDateFilter);return (- <IssuesHeader- scopedIssues={issues}- workingAgents={workingAgents}- dateFilter={dateFilter}- onDateFilterChange={setDateFilter}- isRefreshing={isRefreshing}- facetCountsExact={facetCountsExact}- tableFacetCounts={tableFacetCounts}- onTableFacetChange={onTableFacetChange}- />+ <>+ <PageHeader>+ <RefreshablePageIcon refreshing={isRefreshing}>+ <ListTodo className="size-4" />+ </RefreshablePageIcon>+ <h1 className="text-body font-medium">{t(($) => $.page.breadcrumb_title)}</h1>+ </PageHeader>+ <IssuesHeader+ scopedIssues={issues}+ workingAgents={workingAgents}+ dateFilter={dateFilter}+ onDateFilterChange={setDateFilter}+ facetCountsExact={facetCountsExact}+ tableFacetCounts={tableFacetCounts}+ onTableFacetChange={onTableFacetChange}+ />+ </>);}@@ -52,11 +61,6 @@ export function IssuesPage() {return (<div className="flex flex-1 min-h-0 flex-col">- <PageHeader>- <ListTodo className="h-4 w-4 text-muted-foreground" />- <h1 className="text-body font-medium">{t(($) => $.page.breadcrumb_title)}</h1>- </PageHeader>-<IssueSurfacescope={{ type: "workspace", actorKind: scope }}modes={["board", "list", "table", "swimlane"]}diff --git a/packages/views/layout/issue-page-refresh.test.tsx b/packages/views/layout/issue-page-refresh.test.tsxnew file mode 100644index 0000000000..5a03ef8ec0--- /dev/null+++ b/packages/views/layout/issue-page-refresh.test.tsx@@ -0,0 +1,70 @@+import { act, cleanup, screen, within } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../test/i18n";+import { IssuesPage } from "../issues/components/issues-page";+import { MyIssuesPage } from "../my-issues/components/my-issues-page";++const state = vi.hoisted(() => ({ refreshing: false, user: { id: "user-1" } as { id: string } | null }));+vi.mock("@multica/core/auth", () => ({+ useAuthStore: (select: (s: typeof state) => unknown) => select(state),+}));+vi.mock("@multica/core/issues/stores/issues-scope-store", () => ({+ useIssuesScope: () => "all",+}));+vi.mock("@multica/core/issues/stores/view-store-context", () => ({+ useViewStore: (select: (s: object) => unknown) => select({ dateFilter: null, setDateFilter: vi.fn() }),+}));+vi.mock("@multica/core/issues/stores/my-issues-view-store", () => {+ const scopeState = { scope: "all", setScope: vi.fn() };+ return {+ myIssuesRelationFromScope: () => "all",+ myIssuesViewStore: { getState: () => scopeState, getInitialState: () => scopeState, subscribe: () => () => {} },+ };+});+vi.mock("../issues/surface/issue-surface", () => ({+ IssueSurface: ({ renderHeader }: { renderHeader: (context: object) => React.ReactNode }) => (+ <>{renderHeader({ controller: { isRefreshing: state.refreshing, surfaceIssues: [] } })}</>+ ),+}));+vi.mock("../issues/components/issues-header", () => ({+ IssuesHeader: () => <div>Issue controls</div>,+}));+vi.mock("../my-issues/components/my-issues-header", () => ({+ MyIssuesHeader: () => <div>My issue controls</div>,+}));++describe("issue page refresh feedback", () => {+ beforeEach(() => {+ state.refreshing = false;+ state.user = { id: "user-1" };+ vi.useFakeTimers();+ });+ afterEach(() => {+ cleanup();+ vi.useRealTimers();+ });++ it.each([IssuesPage, MyIssuesPage])("routes surface refresh state into the page title (%#)", (Page) => {+ const { rerender } = renderWithI18n(<Page />);+ const header = screen.getByRole("banner");+ expect(within(header).getByRole("heading")).toBeInTheDocument();+ expect(within(header).queryByRole("status")).not.toBeInTheDocument();++ state.refreshing = true;+ rerender(<Page />);+ act(() => vi.advanceTimersByTime(300));+ expect(within(header).getByRole("status")).toBeInTheDocument();++ state.refreshing = false;+ rerender(<Page />);+ expect(within(header).queryByRole("status")).not.toBeInTheDocument();+ expect(screen.getAllByRole("banner")).toHaveLength(1);+ });++ it("keeps the My Issues title visible before the user is available", () => {+ state.user = null;+ renderWithI18n(<MyIssuesPage />);+ expect(within(screen.getByRole("banner")).getByRole("heading")).toBeInTheDocument();+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ });+});diff --git a/packages/views/layout/refreshable-page-icon.test.tsx b/packages/views/layout/refreshable-page-icon.test.tsxnew file mode 100644index 0000000000..c89023a402--- /dev/null+++ b/packages/views/layout/refreshable-page-icon.test.tsx@@ -0,0 +1,50 @@+import { act, cleanup, screen } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../test/i18n";+import { RefreshablePageIcon } from "./refreshable-page-icon";++describe("RefreshablePageIcon", () => {+ beforeEach(() => vi.useFakeTimers());+ afterEach(() => {+ cleanup();+ vi.useRealTimers();+ });++ const icon = (refreshing: boolean) => (+ <RefreshablePageIcon refreshing={refreshing}>+ <svg aria-label="Issues icon" />+ </RefreshablePageIcon>+ );++ it("keeps the title icon until 300ms, then restores it immediately on completion", () => {+ const { rerender } = renderWithI18n(icon(false));+ const slot = screen.getByLabelText("Issues icon").parentElement;+ rerender(icon(true));+ act(() => vi.advanceTimersByTime(299));+ expect(screen.getByLabelText("Issues icon")).toBeInTheDocument();+ expect(screen.queryByRole("status")).not.toBeInTheDocument();++ act(() => vi.advanceTimersByTime(1));+ expect(screen.queryByLabelText("Issues icon")).not.toBeInTheDocument();+ expect(screen.getByRole("status").parentElement).toBe(slot);+ expect(slot).toHaveClass("size-4", "shrink-0");+ expect(screen.getByRole("status")).toHaveClass("motion-reduce:animate-none");++ rerender(icon(false));+ expect(screen.getByLabelText("Issues icon")).toBeInTheDocument();+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ });++ it("cancels fast refreshes and starts a fresh delay for the next request", () => {+ const { rerender } = renderWithI18n(icon(true));+ act(() => vi.advanceTimersByTime(200));+ rerender(icon(false));+ act(() => vi.advanceTimersByTime(500));+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ rerender(icon(true));+ act(() => vi.advanceTimersByTime(299));+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ act(() => vi.advanceTimersByTime(1));+ expect(screen.getByRole("status")).toBeInTheDocument();+ });+});diff --git a/packages/views/layout/refreshable-page-icon.tsx b/packages/views/layout/refreshable-page-icon.tsxnew file mode 100644index 0000000000..224886375f--- /dev/null+++ b/packages/views/layout/refreshable-page-icon.tsx@@ -0,0 +1,34 @@+"use client";++import { useEffect, useState, type ReactNode } from "react";+import { Spinner } from "@multica/ui/components/ui/spinner";+import { useT } from "../i18n";++/** Replace the title icon without changing its footprint or flashing on fast requests. */+export function RefreshablePageIcon({+ refreshing,+ children,+}: {+ refreshing: boolean;+ children: ReactNode;+}) {+ return (+ <span className="flex size-4 shrink-0 items-center justify-center text-muted-foreground">+ {refreshing ? <PendingIcon>{children}</PendingIcon> : children}+ </span>+ );+}++// Mount a fresh delay for each refresh; completion also cancels a pending timer.+function PendingIcon({ children }: { children: ReactNode }) {+ const { t } = useT("common");+ const [visible, setVisible] = useState(false);+ useEffect(() => {+ const timer = setTimeout(() => setVisible(true), 300);+ return () => clearTimeout(timer);+ }, []);++ return visible ? (+ <Spinner aria-label={t(($) => $.loading)} className="size-4 motion-reduce:animate-none" />+ ) : children;+}diff --git a/packages/views/my-issues/components/my-issues-header.tsx b/packages/views/my-issues/components/my-issues-header.tsxindex 9d91f6fb6b..b2f314622b 100644--- a/packages/views/my-issues/components/my-issues-header.tsx+++ b/packages/views/my-issues/components/my-issues-header.tsx@@ -22,7 +22,6 @@ import { useT } from "../../i18n";import { WorkspaceAgentWorkingChip } from "../../issues/components/workspace-agent-working-chip";import {IssueDisplayControls,- ViewRefreshIndicator,} from "../../issues/components/issues-header";import { cn } from "@multica/ui/lib/utils";import { PAGE_GUTTER } from "../../layout/page-header";@@ -48,7 +47,6 @@ export function MyIssuesHeader({workingAgents,scope,onScopeChange,- isRefreshing = false,facetCountsExact = true,tableFacetCounts,onTableFacetChange,@@ -60,7 +58,6 @@ export function MyIssuesHeader({workingAgents: WorkingAgentSummary[] | undefined;scope: MyIssuesScope;onScopeChange: (scope: MyIssuesScope) => void;- isRefreshing?: boolean;/** See IssueDisplayControls.facetCountsExact. */facetCountsExact?: boolean;tableFacetCounts?: IssueTableFacetsResponse;@@ -176,7 +173,6 @@ export function MyIssuesHeader({onTableFacetChange={onTableFacetChange}viewBaseline={viewBaseline}/>- <ViewRefreshIndicator active={isRefreshing} /></div></div></div>diff --git a/packages/views/my-issues/components/my-issues-page.tsx b/packages/views/my-issues/components/my-issues-page.tsxindex 337cae4df6..93df3f5b63 100644--- a/packages/views/my-issues/components/my-issues-page.tsx+++ b/packages/views/my-issues/components/my-issues-page.tsx@@ -8,6 +8,7 @@ import {myIssuesViewStore,} from "@multica/core/issues/stores/my-issues-view-store";import { PageHeader } from "../../layout/page-header";+import { RefreshablePageIcon } from "../../layout/refreshable-page-icon";import { IssueSurface } from "../../issues/surface/issue-surface";import { useT } from "../../i18n";import { MyIssuesHeader } from "./my-issues-header";@@ -18,13 +19,17 @@ export function MyIssuesPage() {const scope = useStore(myIssuesViewStore, (s) => s.scope);const setScope = useStore(myIssuesViewStore, (s) => s.setScope);+ const renderTitle = (refreshing = false) => (+ <PageHeader>+ <RefreshablePageIcon refreshing={refreshing}>+ <ListTodo className="size-4" />+ </RefreshablePageIcon>+ <h1 className="text-body font-medium">{t(($) => $.page.breadcrumb)}</h1>+ </PageHeader>+ );+return (<div className="flex flex-1 min-h-0 flex-col">- <PageHeader>- <ListTodo className="h-4 w-4 text-muted-foreground" />- <h1 className="text-body font-medium">{t(($) => $.page.breadcrumb)}</h1>- </PageHeader>-{user ? (<IssueSurfacescope={{@@ -35,16 +40,18 @@ export function MyIssuesPage() {modes={["board", "list", "table", "swimlane"]}batchToolbar="list"renderHeader={({ controller }) => (- <MyIssuesHeader- allIssues={controller.surfaceIssues}- workingAgents={controller.workingAgents}- scope={scope}- onScopeChange={setScope}- isRefreshing={controller.isRefreshing}- facetCountsExact={controller.facetCountsExact}- tableFacetCounts={controller.tableFacetCounts}- onTableFacetChange={controller.setActiveTableFacet}- />+ <>+ {renderTitle(controller.isRefreshing)}+ <MyIssuesHeader+ allIssues={controller.surfaceIssues}+ workingAgents={controller.workingAgents}+ scope={scope}+ onScopeChange={setScope}+ facetCountsExact={controller.facetCountsExact}+ tableFacetCounts={controller.tableFacetCounts}+ onTableFacetChange={controller.setActiveTableFacet}+ />+ </>)}renderEmpty={() => (<div className="flex flex-1 min-h-0 flex-col items-center justify-center gap-2 text-muted-foreground">@@ -54,7 +61,7 @@ export function MyIssuesPage() {</div>)}/>- ) : null}+ ) : renderTitle()}</div>);}