Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8766 fix(sidebar): stop opening an issue's project on every issue page (#10123)
Jiayuan Zhang07764420104f
diff --git a/packages/core/issues/stores/sidebar-tree-store.ts b/packages/core/issues/stores/sidebar-tree-store.tsindex 4777c5d87c..7be0f6f564 100644--- a/packages/core/issues/stores/sidebar-tree-store.ts+++ b/packages/core/issues/stores/sidebar-tree-store.ts@@ -45,6 +45,12 @@ export const DEFAULT_SIDEBAR_PROJECT_SETTINGS: SidebarProjectSettings = {};+export interface SidebarLocateRequest {+ issueId: string;+ /** The project row's sidebar source, `project:{id}`. */+ source: string;+}+/*** This device's sidebar layout. The Projects section's settings and order are* per user on the server (see `sidebar-project-prefs`); what is left here is@@ -65,7 +71,13 @@ interface SidebarTreeState {pinnedCollapsed: boolean;workingCollapsed: boolean;needsAttentionCollapsed: boolean;+ /**+ * An issue the user asked to show in its project's row, until the Work+ * panel has opened that row and scrolled to it. Not persisted.+ */+ locate: SidebarLocateRequest | null;setExpanded: (key: string, expanded: boolean) => void;+ requestLocate: (request: SidebarLocateRequest | null) => void;setProjectsCollapsed: (collapsed: boolean) => void;setViewsCollapsed: (collapsed: boolean) => void;setPinnedCollapsed: (collapsed: boolean) => void;@@ -102,6 +114,8 @@ export const useSidebarTreeStore = create<SidebarTreeState>()(persist((set) => ({...INITIAL,+ locate: null,+ requestLocate: (locate) => set({ locate }),setExpanded: (key, expanded) =>set((s) => {if (s.expanded.includes(key) === expanded) return s;diff --git a/packages/views/issues/actions/issue-actions-dropdown.tsx b/packages/views/issues/actions/issue-actions-dropdown.tsxindex 9d42f00672..77603451dd 100644--- a/packages/views/issues/actions/issue-actions-dropdown.tsx+++ b/packages/views/issues/actions/issue-actions-dropdown.tsx@@ -23,6 +23,8 @@ interface IssueActionsDropdownProps {onDeletedFallbackPath?: string;/** The reader's archived inbox notification for this issue; adds "Restore to inbox". */archivedInboxItemId?: string;+ /** Adds "Show in sidebar". */+ onShowInSidebar?: () => void;}export function IssueActionsDropdown({@@ -31,6 +33,7 @@ export function IssueActionsDropdown({align = "end",onDeletedFallbackPath,archivedInboxItemId,+ onShowInSidebar,}: IssueActionsDropdownProps) {const actions = useIssueActions(issue);const [open, setOpen] = useState(false);@@ -46,6 +49,7 @@ export function IssueActionsDropdown({onClose={() => setOpen(false)}onDeletedFallbackPath={onDeletedFallbackPath}archivedInboxItemId={archivedInboxItemId}+ onShowInSidebar={onShowInSidebar}/></DropdownMenuContent></DropdownMenu>diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsxindex be3e746195..5b44482a65 100644--- a/packages/views/issues/actions/issue-actions-menu-items.tsx+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx@@ -15,6 +15,7 @@ import {FolderOpen,Hash,Link2,+ LocateFixed,Network,Pin,PinOff,@@ -120,6 +121,8 @@ interface IssueActionsMenuItemsProps {variant?: "full" | "sidebar";/** Sidebar variant: asks the parent to confirm stopping a running task. */onStopRun?: (task: AgentTask) => void;+ /** Adds "Show in sidebar", for the page the issue is open on. */+ onShowInSidebar?: () => void;}export function IssueActionsMenuItems({@@ -131,6 +134,7 @@ export function IssueActionsMenuItems({archivedInboxItemId,variant = "full",onStopRun,+ onShowInSidebar,}: IssueActionsMenuItemsProps) {const { t } = useT("issues");const wsId = useWorkspaceId();@@ -421,6 +425,12 @@ export function IssueActionsMenuItems({)}{isPinned ? t(($) => $.actions.unpin_from_sidebar) : t(($) => $.actions.pin_to_sidebar)}</P.Item>+ {onShowInSidebar && (+ <P.Item onClick={onShowInSidebar}>+ <LocateFixed className="h-3.5 w-3.5" />+ {t(($) => $.actions.locate_in_sidebar)}+ </P.Item>+ )}{archivedInboxItemId && <InboxRestoreMenuItem itemId={archivedInboxItemId} Item={P.Item} />}{sidebar &&(unread ? (diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 9adbf6e64e..112dad7811 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -183,6 +183,7 @@ import { cn } from "@multica/ui/lib/utils";import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";import { CollectionPageState } from "../../layout/collection-page";import { PAGE_GUTTER } from "../../layout/page-header";+import { useShowInSidebar } from "../../layout/panels/show-in-sidebar";import { ProgressRing } from "./progress-ring";import { matchesPinyin } from "../../editor/extensions/pinyin-match";@@ -2637,6 +2638,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr// Called before the `if (!issue)` early return so hook order stays stable.const actions = useIssueActions(issue);const handleUpdateField = actions.updateField;+ const showInSidebar = useShowInSidebar(issue);// The inbox passes `onDone` and owns archive and restore there.const archivedInboxItemId = useArchivedInboxItemId(id, !onDone);@@ -3383,6 +3385,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr// to the list we came from, falling back to all issues.onDeletedFallbackPath={onDelete ? undefined : paths.issues()}archivedInboxItemId={archivedInboxItemId}+ onShowInSidebar={isPeek ? undefined : (showInSidebar ?? undefined)}trigger={<IconButtonlabel={tCommon(($) => $.more_actions)}diff --git a/packages/views/layout/panels/show-in-sidebar.test.tsx b/packages/views/layout/panels/show-in-sidebar.test.tsxnew file mode 100644index 0000000000..519501dc74--- /dev/null+++ b/packages/views/layout/panels/show-in-sidebar.test.tsx@@ -0,0 +1,105 @@+import type { ReactNode } from "react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { renderHook } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { EMPTY_ISSUE_VIEW_PREFERENCE } from "@multica/core/api/schemas";+import { issueViewPreferenceOptions } from "@multica/core/issue-views/preferences";+import { SIDEBAR_PROJECTS_SCOPE } from "@multica/core/issues/sidebar-project-prefs";+import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";+import { projectListOptions } from "@multica/core/projects/queries";+import type { Project } from "@multica/core/types";+import { NavigationProvider, type NavigationAdapter } from "../../navigation";+import { useShowInSidebar } from "./show-in-sidebar";++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/auth", async (importOriginal) => {+ const state = { user: { id: "u1" } };+ return {+ ...(await importOriginal<typeof import("@multica/core/auth")>()),+ useAuthStore: Object.assign((selector: (s: typeof state) => unknown) => selector(state), {+ getState: () => state,+ }),+ };+});++const layout = vi.hoisted(() => ({+ shell: null as { navCollapsed: boolean; toggleNav: () => void } | null,+ sidebar: null as { isCompact: boolean; setOpenMobile: (open: boolean) => void } | null,+}));+vi.mock("../app-shell-context", () => ({ useAppShell: () => layout.shell }));+vi.mock("@multica/ui/components/ui/sidebar", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@multica/ui/components/ui/sidebar")>()),+ useSidebarSafe: () => layout.sidebar,+}));++const PROJECT = { id: "p-1", title: "Launch", status: "in_progress", lead_type: null, lead_id: null } as unknown as Project;+const DONE_PROJECT = { ...PROJECT, id: "p-2", status: "completed" } as Project;+const ISSUE_ID = "0a3f0a8e-6a52-4c1e-9f5e-1b2c3d4e5f60";++function render(pathname: string, projectId: string | null) {+ const qc = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity, retry: false } } });+ qc.setQueryData(projectListOptions("ws-1").queryKey, { projects: [PROJECT, DONE_PROJECT], total: 2 });+ qc.setQueryData(issueViewPreferenceOptions("ws-1", SIDEBAR_PROJECTS_SCOPE).queryKey, EMPTY_ISSUE_VIEW_PREFERENCE);+ const adapter: NavigationAdapter = {+ push: vi.fn(),+ replace: vi.fn(),+ back: vi.fn(),+ pathname,+ searchParams: new URLSearchParams(),+ hash: "",+ getShareableUrl: (path) => path,+ };+ const wrapper = ({ children }: { children: ReactNode }) => (+ <QueryClientProvider client={qc}>+ <NavigationProvider value={adapter}>{children}</NavigationProvider>+ </QueryClientProvider>+ );+ return renderHook(() => useShowInSidebar({ id: ISSUE_ID, project_id: projectId }), { wrapper }).result;+}++beforeEach(() => {+ useSidebarTreeStore.setState({ locate: null });+ layout.shell = null;+ layout.sidebar = null;+});++describe("useShowInSidebar", () => {+ it("asks the Work panel to show the issue under its project", () => {+ const result = render(`/acme/issues/${ISSUE_ID}`, PROJECT.id);+ result.current?.();+ expect(useSidebarTreeStore.getState().locate).toEqual({ issueId: ISSUE_ID, source: `project:${PROJECT.id}` });+ });++ it("opens a collapsed space panel", () => {+ layout.shell = { navCollapsed: true, toggleNav: vi.fn() };+ layout.sidebar = { isCompact: false, setOpenMobile: vi.fn() };+ render(`/acme/issues/${ISSUE_ID}`, PROJECT.id).current?.();+ expect(layout.shell.toggleNav).toHaveBeenCalledOnce();+ expect(layout.sidebar.setOpenMobile).not.toHaveBeenCalled();+ });++ it("opens the nav sheet in the compact layout", () => {+ layout.shell = { navCollapsed: false, toggleNav: vi.fn() };+ layout.sidebar = { isCompact: true, setOpenMobile: vi.fn() };+ render(`/acme/issues/${ISSUE_ID}`, PROJECT.id).current?.();+ expect(layout.sidebar.setOpenMobile).toHaveBeenCalledWith(true);+ expect(layout.shell.toggleNav).not.toHaveBeenCalled();+ expect(useSidebarTreeStore.getState().locate?.issueId).toBe(ISSUE_ID);+ });++ it("is not offered off an issue route, where the panel does not mark the issue", () => {+ expect(render("/acme/inbox", PROJECT.id).current).toBeNull();+ });++ it("is not offered for an issue without a project, or one the sidebar leaves out", () => {+ expect(render(`/acme/issues/${ISSUE_ID}`, null).current).toBeNull();+ expect(render(`/acme/issues/${ISSUE_ID}`, DONE_PROJECT.id).current).toBeNull();+ });+});diff --git a/packages/views/layout/panels/show-in-sidebar.ts b/packages/views/layout/panels/show-in-sidebar.tsnew file mode 100644index 0000000000..a4f14ada3e--- /dev/null+++ b/packages/views/layout/panels/show-in-sidebar.ts@@ -0,0 +1,42 @@+"use client";++import { useQuery } from "@tanstack/react-query";+import { useAuthStore } from "@multica/core/auth";+import { useWorkspaceId } from "@multica/core/hooks";+import { projectSidebarSource, sidebarProjects } from "@multica/core/issues/sidebar-list";+import { useSidebarProjectPrefs } from "@multica/core/issues/sidebar-project-prefs";+import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";+import { useWorkspacePaths } from "@multica/core/paths";+import { projectListOptions } from "@multica/core/projects/queries";+import type { Issue } from "@multica/core/types";+import { useSidebarSafe } from "@multica/ui/components/ui/sidebar";+import { useNavigation } from "../../navigation";+import { useAppShell } from "../app-shell-context";++/**+ * Opens the issue's project row in the Work panel and scrolls to the issue,+ * or `null` off an issue route (the panel only marks the route's issue) or+ * when the panel does not list its project.+ */+export function useShowInSidebar(issue: Pick<Issue, "id" | "project_id"> | null | undefined): (() => void) | null {+ const wsId = useWorkspaceId();+ const userId = useAuthStore((s) => s.user?.id);+ const shell = useAppShell();+ const sidebar = useSidebarSafe();+ const paths = useWorkspacePaths();+ const { pathname } = useNavigation();+ const { data: projects } = useQuery({ ...projectListOptions(wsId), enabled: !!issue?.project_id });+ const { projectSettings, projectOrder } = useSidebarProjectPrefs(wsId);+ const projectId = issue?.project_id;+ if (!issue || !projectId || !projects || !pathname.startsWith(paths.issues() + "/")) return null;+ const listed = sidebarProjects(projects, projectSettings, projectOrder, userId).some(+ (project) => project.id === projectId,+ );+ if (!listed) return null;+ return () => {+ // `navCollapsed` is always false in the compact layout, where the nav is a sheet.+ if (sidebar?.isCompact) sidebar.setOpenMobile(true);+ else if (shell?.navCollapsed) shell.toggleNav();+ useSidebarTreeStore.getState().requestLocate({ issueId: issue.id, source: projectSidebarSource(projectId) });+ };+}diff --git a/packages/views/layout/panels/sidebar-tree.tsx b/packages/views/layout/panels/sidebar-tree.tsxindex cf73d43448..8fd3450163 100644--- a/packages/views/layout/panels/sidebar-tree.tsx+++ b/packages/views/layout/panels/sidebar-tree.tsx@@ -1,6 +1,6 @@"use client";-import { forwardRef, memo, useCallback, useLayoutEffect, useState } from "react";+import { forwardRef, memo, useCallback, useLayoutEffect, useRef, useState } from "react";import { keepPreviousData, useQuery } from "@tanstack/react-query";import { ChevronDown, ChevronRight, ChevronUp } from "@multica/ui/icons";import { cn } from "@multica/ui/lib/utils";@@ -13,6 +13,7 @@ import { issueStatusCategory } from "@multica/core/issues";import { issueDetailOptions, sidebarIssuesOptions } from "@multica/core/issues/queries";import { SIDEBAR_FIRST_PAGE, SIDEBAR_PAGE_STEP, type SidebarIssuesRequest } from "@multica/core/issues/sidebar-list";import { useSidebarKeptStore } from "@multica/core/issues/stores/sidebar-kept-store";+import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";import { issueUnreadTarget, useIssueUnread } from "@multica/core/issues/unread";import { useWorkspacePaths } from "@multica/core/paths";import { useActorName } from "@multica/core/workspace/hooks";@@ -42,6 +43,8 @@ interface TreeRowProps extends React.ComponentProps<"div"> {label: string;icon: React.ReactNode;active: boolean;+ /** The open issue sits under this collapsed row, which no list shows. */+ located?: boolean;/** Omit the expand props for a row that only opens its page. */expanded?: boolean;onExpandedChange?: (expanded: boolean) => void;@@ -67,6 +70,7 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function Treelabel,icon,active,+ located = false,expanded,onExpandedChange,listId,@@ -96,11 +100,15 @@ export const TreeRow = forwardRef<HTMLAnchorElement, TreeRowProps>(function Tree<div{...rowProps}ref={rowRef}+ data-located={located && !active ? "" : undefined}className={cn(PANEL_ROW_CLASS,panelRowStateClass(active),"group/row relative",expanded && !active && "text-foreground",+ // A step below the selected row: no fill, so it marks the place+ // without competing with a lit row.+ "data-located:font-medium data-located:text-foreground data-located:[&_svg_.icon-body]:fill-current data-located:[&_svg_.icon-body]:[fill-opacity:0.2]",className,)}>@@ -197,7 +205,9 @@ 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, or — with `paramsError` — that- * they could not resolve, which `onRetry` tries again.+ * they could not resolve, which `onRetry` tries again. `activeIssueId` is the+ * row that lights; the open issue `openIssueId` names is listed last when+ * `ownsOpen` claims it and no loaded page has it, lit or not.*/export function SidebarIssueList({id,@@ -207,6 +217,8 @@ export function SidebarIssueList({paramsError = false,onRetry,activeIssueId,+ openIssueId = activeIssueId,+ ownsOpen,onCollapse,}: {id: string;@@ -216,6 +228,8 @@ export function SidebarIssueList({paramsError?: boolean;onRetry?: () => void;activeIssueId: string | null;+ openIssueId?: string | null;+ ownsOpen?: (issue: Issue) => boolean;onCollapse: () => void;}) {const { t } = useT("layout");@@ -232,11 +246,22 @@ export function SidebarIssueList({const total = params ? (query.data?.total ?? 0) : 0;// The list no longer carries a kept issue; the detail cache follows its// edits, and dropping it on delete ends the keep.- const { data: activeIssue } = useQuery({- ...issueDetailOptions(wsId, activeIssueId ?? ""),+ const openId = activeIssueId ?? openIssueId;+ const { data: openIssue } = useQuery({+ ...issueDetailOptions(wsId, openId ?? ""),enabled: false,});- const issues = useKeptActiveItem(source, listed, activeIssueId, activeIssue);+ const kept = useKeptActiveItem(source, listed, activeIssueId, openIssue);+ const issues =+ openIssue &&+ openIssue.id === openId &&+ ownsOpen?.(openIssue) &&+ !kept.some((issue) => issue.id === openIssue.id)+ ? [...kept, openIssue]+ : kept;+ const locating = useSidebarTreeStore(+ (s) => !!activeIssueId && s.locate?.source === source && s.locate.issueId === activeIssueId,+ );const onKeyDown = (event: React.KeyboardEvent) => {if (event.key !== "ArrowLeft") return;@@ -247,7 +272,7 @@ export function SidebarIssueList({const tailClass = cn(TREE_CHILD_ROW_CLASS, panelRowStateClass(false), "gap-1.5 min-h-6 text-caption text-faint-foreground");return (- <ul id={id} className="mb-2 ml-5 border-l border-surface-border pl-1.5">+ <ul id={id} data-sidebar-list={source} className="mb-2 ml-5 border-l border-surface-border pl-1.5">{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>@@ -282,6 +307,7 @@ export function SidebarIssueList({issue={issue}href={p.issueDetail(issue.id)}active={issue.id === activeIssueId}+ locating={locating && issue.id === activeIssueId}statusColor={statusCatalog.colorOf(issue.status)}statusIcon={statusCatalog.iconOf(issue.status)}statusLabel={statusLabel(issue.status)}@@ -470,6 +496,7 @@ const SidebarIssueRow = memo(function SidebarIssueRow({issue,href,active,+ locating,statusColor,statusIcon,statusLabel,@@ -479,6 +506,8 @@ const SidebarIssueRow = memo(function SidebarIssueRow({issue: Issue;href: string;active: boolean;+ /** "Show in sidebar" asked for this row: scroll to it once. */+ locating: boolean;statusColor: string | null;statusIcon: string | null;statusLabel: string;@@ -486,10 +515,19 @@ const SidebarIssueRow = memo(function SidebarIssueRow({}) {const agents = useIssueAgentState(wsId, issue.id);const unread = useIssueUnread(wsId, issue.id);+ const rowRef = useRef<HTMLDivElement>(null);+ useLayoutEffect(() => {+ if (!locating) return;+ rowRef.current?.scrollIntoView?.({ block: "nearest" });+ useSidebarTreeStore.getState().requestLocate(null);+ }, [locating]);return (<IssueActionsContextMenu issue={issue}>- <div className={cn(TREE_CHILD_ROW_CLASS, panelRowStateClass(active), issueRowMenuOpenClass(active), "relative")}>+ <div+ ref={rowRef}+ className={cn(TREE_CHILD_ROW_CLASS, panelRowStateClass(active), issueRowMenuOpenClass(active), "relative")}+ ><SidebarIssueStatusissue={issue}color={statusColor}diff --git a/packages/views/layout/panels/views-section.test.tsx b/packages/views/layout/panels/views-section.test.tsxindex 2d2634ed5c..bc954d5605 100644--- a/packages/views/layout/panels/views-section.test.tsx+++ b/packages/views/layout/panels/views-section.test.tsx@@ -6,6 +6,7 @@ import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-simport { renderWithI18n } from "../../test/i18n";import { NavigationProvider, type NavigationAdapter } from "../../navigation";import { ViewsSection } from "./views-section";+import type { IssueViewActions } from "../../issue-views/use-view-actions";const actions = vi.hoisted(() => ({sidebar: { items: [] as unknown[], reorder: vi.fn(), unstar: vi.fn() },@@ -70,8 +71,10 @@ function renderSection(adapter = makeAdapter()) {wsId="ws-1"pathname="/acme/issues"plainRowsLit- issueLitInTree={false}+ issueInAllIssues={false}activeIssueId={null}+ litSource={null}+ actions={actions as unknown as IssueViewActions}/></NavigationProvider>,);diff --git a/packages/views/layout/panels/views-section.tsx b/packages/views/layout/panels/views-section.tsxindex 2a543f20a0..69e2ac2f0a 100644--- a/packages/views/layout/panels/views-section.tsx+++ b/packages/views/layout/panels/views-section.tsx@@ -55,7 +55,7 @@ import {} 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 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";@@ -79,9 +79,18 @@ interface ViewsSectionProps {wsId: string;pathname: string;plainRowsLit: boolean;- /** An expanded tree row lists the current issue, so "All issues" stays unlit. */- issueLitInTree: boolean;+ /** No other row marks the open issue and it has no project, so "All issues" lights for it. */+ issueInAllIssues: boolean;activeIssueId: string | null;+ /** The one list that lights the open issue. */+ litSource: string | null;+ actions: IssueViewActions;+}++/** The sidebar source of a starred view's issue list. */+export function sidebarViewItemSource(item: SidebarViewItem): string {+ if (item.kind === "view") return viewSidebarSource(item.view.id);+ return item.key === "unread" ? viewSidebarSource(UNREAD_VIEW_ID) : builtinSidebarSource(item.key);}/**@@ -92,12 +101,13 @@ export function ViewsSection({wsId,pathname,plainRowsLit,- issueLitInTree,+ issueInAllIssues,activeIssueId,+ litSource,+ actions,}: ViewsSectionProps) {const { t } = useT("layout");const p = useWorkspacePaths();- const actions = useIssueViewActions();const { items, reorder } = actions.sidebar;const { data: allViews = EMPTY_VIEWS } = useQuery(issueViewEverywhereOptions(wsId));const [deleteTarget, setDeleteTarget] = useState<IssueView | null>(null);@@ -155,7 +165,7 @@ export function ViewsSection({item={item}pathname={pathname}plainRowsLit={plainRowsLit}- activeIssueId={activeIssueId}+ activeIssueId={litSource === sidebarViewItemSource(item) ? activeIssueId : null}actions={actions}onDelete={setDeleteTarget}drag={drag}@@ -165,7 +175,7 @@ export function ViewsSection({wsId={wsId}pathname={pathname}plainRowsLit={plainRowsLit}- activeIssueId={activeIssueId}+ activeIssueId={litSource === sidebarViewItemSource(item) ? activeIssueId : null}actions={actions}drag={drag}/>@@ -175,8 +185,8 @@ export function ViewsSection({builtin={item.key}pathname={pathname}plainRowsLit={plainRowsLit}- issueLitInTree={issueLitInTree}- activeIssueId={activeIssueId}+ issueInAllIssues={issueInAllIssues}+ activeIssueId={litSource === sidebarViewItemSource(item) ? activeIssueId : null}actions={actions}drag={drag}/>@@ -295,7 +305,7 @@ function BuiltinViewRow({builtin,pathname,plainRowsLit,- issueLitInTree,+ issueInAllIssues,activeIssueId,actions,drag,@@ -304,7 +314,7 @@ function BuiltinViewRow({builtin: ScopeBuiltinViewKey;pathname: string;plainRowsLit: boolean;- issueLitInTree: boolean;+ issueInAllIssues: boolean;activeIssueId: string | null;actions: IssueViewActions;drag: DragBindings;@@ -335,7 +345,7 @@ function BuiltinViewRow({(builtin === "all_issues"? pathname === p.issues()? activeWorkspaceView === null- : !issueLitInTree && isPathWithin(pathname, p.issues())+ : issueInAllIssues && isPathWithin(pathname, p.issues()): onMyIssues && activeMyView === null && (builtin === "my_agents") === isMyAgentsSearch(searchParams));const source = builtinSidebarSource(builtin);diff --git a/packages/views/layout/panels/views-section.unread.test.tsx b/packages/views/layout/panels/views-section.unread.test.tsxindex fdac1717c8..f7a11414d7 100644--- a/packages/views/layout/panels/views-section.unread.test.tsx+++ b/packages/views/layout/panels/views-section.unread.test.tsx@@ -12,6 +12,7 @@ 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";+import type { IssueViewActions } from "../../issue-views/use-view-actions";const actions = vi.hoisted(() => ({sidebar: { items: [] as unknown[], reorder: vi.fn(), unstar: vi.fn() },@@ -80,8 +81,10 @@ function renderSection({ activeIssueId = null }: { activeIssueId?: string | nullwsId="ws-1"pathname={issueId ? `/acme/issues/${issueId}` : "/acme/issues"}plainRowsLit- issueLitInTree={false}+ issueInAllIssues={false}activeIssueId={issueId}+ litSource={viewSidebarSource(UNREAD_VIEW_ID)}+ actions={actions as unknown as IssueViewActions}/></NavigationProvider></QueryClientProvider>diff --git a/packages/views/layout/panels/work-panel.test.tsx b/packages/views/layout/panels/work-panel.test.tsxindex c0c9f274ba..c1af17cf33 100644--- a/packages/views/layout/panels/work-panel.test.tsx+++ b/packages/views/layout/panels/work-panel.test.tsx@@ -20,7 +20,7 @@ import { renderWithI18n } from "../../test/i18n";import { NavigationProvider, type NavigationAdapter } from "../../navigation";import { KeptRowsRelease, WorkPanel } from "./work-panel";-const apiMock = vi.hoisted(() => ({ listIssueTableRows: vi.fn(), getIssue: vi.fn() }));+const apiMock = vi.hoisted(() => ({ listIssueTableRows: vi.fn(), listIssues: vi.fn(), getIssue: vi.fn() }));const actions = vi.hoisted(() => ({sidebar: {items: [@@ -221,6 +221,7 @@ beforeEach(() => {total: 2,next_cursor: null,} as unknown as IssueTableRowsResponse);+ apiMock.listIssues.mockResolvedValue({ issues: [ISSUE, OTHER], total: 2 });// The issue page never finishes loading, so the panel cannot lean on it.apiMock.getIssue.mockReturnValue(new Promise<Issue>(() => {}));});@@ -249,7 +250,13 @@ describe("WorkPanel issue highlight", () => {});it("leaves All issues lit for an issue no expanded row lists", async () => {- renderPanel("/acme/issues/9c8d7e6f-5a4b-4c3d-8e2f-1a0b9c8d7e6f");+ const qc = renderPanel("/acme/issues/9c8d7e6f-5a4b-4c3d-8e2f-1a0b9c8d7e6f");+ act(() => {+ qc.setQueryData(issueDetailOptions("ws-1", "9c8d7e6f-5a4b-4c3d-8e2f-1a0b9c8d7e6f").queryKey, {+ ...OTHER,+ id: "9c8d7e6f-5a4b-4c3d-8e2f-1a0b9c8d7e6f",+ });+ });await screen.findByRole("link", { name: ISSUE.title });expect(allIssues()).toHaveAttribute("aria-current", "page");@@ -343,6 +350,149 @@ describe("WorkPanel issue highlight", () => {});});+describe("WorkPanel and the open issue's project", () => {+ const PROJECT_SOURCE = `project:${PROJECT.id}`;+ const IN_PROJECT = { ...ISSUE, project_id: PROJECT.id } as Issue;+ const projectLocated = () => !!screen.getByRole("link", { name: PROJECT.title }).closest("[data-located]");+ const litIssueRows = () =>+ screen.queryAllByRole("link", { name: ISSUE.title }).filter((link) => link.getAttribute("aria-current") === "page");+ const openInProject = (qc: QueryClient) =>+ act(() => {+ qc.setQueryData(issueDetailOptions("ws-1", ISSUE.id).queryKey, IN_PROJECT);+ });+ // Query observers hear of cache writes on a timer.+ const settle = () => act(() => new Promise((resolve) => setTimeout(resolve, 10)));++ beforeEach(() => {+ useSidebarTreeStore.setState({ locate: null });+ });++ it("leaves the project closed when its issue is clicked in a view", async () => {+ const qc = renderPanel("/acme/my-issues", [], [PROJECT]);+ await openInProject(qc);+ fireEvent.click(await screen.findByRole("link", { name: ISSUE.title }));++ expect(useSidebarTreeStore.getState().expanded).not.toContain(PROJECT_SOURCE);+ expect(litIssueRows()).toHaveLength(1);+ expect(projectLocated()).toBe(false);+ });++ it("lights the issue only in the list it was clicked in", async () => {+ useSidebarTreeStore.setState({ expanded: ["builtin:my_issues", PROJECT_SOURCE] });+ const qc = renderPanel("/acme/my-issues", [], [PROJECT]);+ await openInProject(qc);+ await waitFor(() => expect(screen.getAllByRole("link", { name: ISSUE.title })).toHaveLength(2));+ const inMyIssues = document.querySelector('[data-sidebar-list="builtin:my_issues"]') as HTMLElement;+ fireEvent.click(within(inMyIssues).getByRole("link", { name: ISSUE.title }));++ expect(litIssueRows()).toEqual([within(inMyIssues).getByRole("link", { name: ISSUE.title })]);+ });++ it("marks the closed project of an issue no list shows, instead of All issues", async () => {+ useSidebarTreeStore.setState({ expanded: [] });+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [PROJECT]);+ await openInProject(qc);++ await waitFor(() => expect(projectLocated()).toBe(true));+ expect(allIssues()).not.toHaveAttribute("aria-current");+ expect(useSidebarTreeStore.getState().expanded).toEqual([]);+ });++ it("lights All issues for an issue without a project that no list shows", async () => {+ useSidebarTreeStore.setState({ expanded: [] });+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [PROJECT]);+ act(() => {+ qc.setQueryData(issueDetailOptions("ws-1", ISSUE.id).queryKey, ISSUE);+ });++ await waitFor(() => expect(allIssues()).toHaveAttribute("aria-current", "page"));+ });++ it("does not light All issues for an issue under the collapsed Projects section", async () => {+ useSidebarTreeStore.setState({ expanded: [], projectsCollapsed: true });+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [PROJECT]);+ await openInProject(qc);+ await settle();++ expect(allIssues()).not.toHaveAttribute("aria-current");+ expect(document.querySelector("[data-located]")).toBeNull();+ });++ it("does not light All issues for an issue in a project the sidebar filters out", async () => {+ useSidebarTreeStore.setState({ expanded: [] });+ const done = { ...PROJECT, status: "completed" } as Project;+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [done]);+ await openInProject(qc);+ await settle();++ expect(screen.queryByRole("link", { name: PROJECT.title })).toBeNull();+ expect(allIssues()).not.toHaveAttribute("aria-current");+ });++ it("lists an issue lit in a view under its project once the project is expanded", async () => {+ // The open issue is on the project's second page.+ apiMock.listIssues.mockImplementation(async ({ offset }: { offset: number }) => ({+ issues: offset ? [] : [OTHER],+ total: 2,+ }));+ const qc = renderPanel("/acme/my-issues", [], [PROJECT]);+ await openInProject(qc);+ const inMyIssues = await waitFor(() => {+ const element = document.querySelector('[data-sidebar-list="builtin:my_issues"]') as HTMLElement;+ expect(within(element).getByRole("link", { name: ISSUE.title })).toBeInTheDocument();+ return element;+ });+ fireEvent.click(within(inMyIssues).getByRole("link", { name: ISSUE.title }));++ act(() => {+ useSidebarTreeStore.getState().setExpanded(PROJECT_SOURCE, true);+ });+ const list = await waitFor(() => {+ const element = document.querySelector(`[data-sidebar-list="${PROJECT_SOURCE}"]`) as HTMLElement;+ expect(within(element).getAllByRole("link").map((link) => link.textContent)).toEqual([OTHER.title, ISSUE.title]);+ return element;+ });+ expect(within(list).getByRole("link", { name: ISSUE.title })).not.toHaveAttribute("aria-current");+ expect(litIssueRows()).toEqual([within(inMyIssues).getByRole("link", { name: ISSUE.title })]);+ });++ it("lists the open issue last under its expanded project when no page has it", async () => {+ useSidebarTreeStore.setState({ expanded: [PROJECT_SOURCE] });+ apiMock.listIssues.mockResolvedValue({ issues: [OTHER], total: 1 });+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [PROJECT]);+ await openInProject(qc);++ const list = await waitFor(() => {+ const element = document.querySelector(`[data-sidebar-list="${PROJECT_SOURCE}"]`) as HTMLElement;+ expect(within(element).getByRole("link", { name: OTHER.title })).toBeInTheDocument();+ return element;+ });+ const links = within(list).getAllByRole("link");+ expect(links.map((link) => link.textContent)).toEqual([OTHER.title, ISSUE.title]);+ expect(links[1]).toHaveAttribute("aria-current", "page");+ expect(allIssues()).not.toHaveAttribute("aria-current");+ });++ it("opens the project and lights the issue there when asked to show it", async () => {+ const qc = renderPanel(`/acme/issues/${ISSUE.id}`, [], [PROJECT]);+ await openInProject(qc);+ await screen.findByRole("link", { name: ISSUE.title });++ act(() => {+ useSidebarTreeStore.getState().requestLocate({ issueId: ISSUE.id, source: PROJECT_SOURCE });+ });++ expect(useSidebarTreeStore.getState().expanded).toContain(PROJECT_SOURCE);+ const list = await waitFor(() => {+ const element = document.querySelector(`[data-sidebar-list="${PROJECT_SOURCE}"]`) as HTMLElement;+ expect(within(element).getByRole("link", { name: ISSUE.title })).toHaveAttribute("aria-current", "page");+ return element;+ });+ expect(litIssueRows()).toEqual([within(list).getByRole("link", { name: ISSUE.title })]);+ await waitFor(() => expect(useSidebarTreeStore.getState().locate).toBeNull());+ });+});+describe("WorkPanel starred Unread view after its last issue is read", () => {const unreadRow = (scope: Pick<typeof screen, "queryByRole"> = screen) =>scope.queryByRole("link", { name: /^Unread/ });diff --git a/packages/views/layout/panels/work-panel.tsx b/packages/views/layout/panels/work-panel.tsxindex 2f09e16a34..229d54e841 100644--- a/packages/views/layout/panels/work-panel.tsx+++ b/packages/views/layout/panels/work-panel.tsx@@ -14,16 +14,19 @@ import { projectListOptions } from "@multica/core/projects/queries";import type { Project } from "@multica/core/types";import { useNavigation } from "../../navigation";import { IssueContextMenuProvider } from "../../issues/actions";+import { useIssueViewActions } from "../../issue-views/use-view-actions";import { useT } from "../../i18n";import { PanelBody, PanelHeader, isPathWithin } from "../panel-nav";import { PinnedSection, usePanelPins } from "./pinned-section";import { useKeptActiveItem } from "./sidebar-tree";-import { ProjectsSection, useIssueIdInTree } from "./work-tree";-import { ViewsSection } from "./views-section";+import { ProjectsSection, useIssueInTree } from "./work-tree";+import { ViewsSection, sidebarViewItemSource } from "./views-section";const EMPTY_PROJECTS: Project[] = [];/** The Projects section's key in the kept-rows store, apart from every sidebar source. */const PROJECTS_LIST = "projects";+/** Pinned rows' place in the clicked-issue record, apart from every sidebar source. */+const PINS_LIST = "pins";/*** The `{id}` of a `{base}/{id}` route — for `/issues/{id}`, a UUID or an@@ -66,6 +69,7 @@ export function WorkPanel() {const { pathname } = useNavigation();const wsId = useCurrentWorkspace()?.id;const userId = useAuthStore((s) => s.user?.id);+ const viewActions = useIssueViewActions();const { data: projects = EMPTY_PROJECTS } = useQuery({...projectListOptions(wsId ?? ""),@@ -77,39 +81,36 @@ export function WorkPanel() {...issueDetailOptions(wsId ?? "", issueSegment ?? ""),enabled: false,});- // A tree row takes the highlight from "All issues" while it lists the issue.- const treeIssueId = useIssueIdInTree(wsId ?? "", issueSegment);+ const inTree = useIssueInTree(wsId ?? "", issueSegment);// The tree and a UUID route name the issue before the page has loaded it;// waiting for the load would light "All issues" first.const currentIssueId = issueSegment- ? (currentIssue?.id ?? treeIssueId ?? (isIssueUuid(issueSegment) ? issueSegment : null))+ ? (currentIssue?.id ?? inTree.issueId ?? (isIssueUuid(issueSegment) ? issueSegment : null)): null;- // An issue can sit in Pinned and in the tree at once. The row that was- // clicked keeps the highlight; arriving any other way (search, a link, a- // shortcut) lights the pin.- const [clickedIssue, setClickedIssue] = useState<{ segment: string; fromPins: boolean } | null>(null);- const treeClaimsIssue =- !!clickedIssue &&- !clickedIssue.fromPins &&- !!currentIssueId &&- (clickedIssue.segment === currentIssueId || clickedIssue.segment === currentIssue?.identifier);+ // An issue can sit in Pinned and in several lists at once, but lights in+ // one place: the list it was clicked in. Arriving any other way (search, a+ // link, a shortcut) lights the pin, else the first list that shows it.+ const [clickedIssue, setClickedIssue] = useState<{ segment: string; list: string | null } | null>(null);+ const clickedList =+ clickedIssue &&+ currentIssueId &&+ (clickedIssue.segment === currentIssueId || clickedIssue.segment === currentIssue?.identifier)+ ? clickedIssue.list+ : undefined;+ const treeClaimsIssue = clickedList !== undefined && clickedList !== PINS_LIST;const pins = usePanelPins(wsId, userId, pathname, treeClaimsIssue ? null : currentIssueId);+ const requestLocate = useSidebarTreeStore((s) => s.requestLocate);const rememberClickedIssue = (event: React.MouseEvent) => {const link = (event.target as HTMLElement).closest("a[href]");if (!link) return;+ requestLocate(null);const path = new URL(link.getAttribute("href") ?? "", window.location.href).pathname;const segment = routeSegment(path, p.issues());- setClickedIssue(segment ? { segment, fromPins: !!link.closest("[data-pinned-section]") } : null);+ const list = link.closest("[data-pinned-section]")+ ? PINS_LIST+ : (link.closest("[data-sidebar-list]")?.getAttribute("data-sidebar-list") ?? null);+ setClickedIssue(segment ? { segment, list } : null);};- // A lit pin already marks the issue; opening its project would only push- // the rest of the panel down.- const revealProjectId =- issueSegment && !pins.isActivePinnedRoute ? (currentIssue?.project_id ?? null) : null;-- const setExpanded = useSidebarTreeStore((s) => s.setExpanded);- useEffect(() => {- if (revealProjectId) setExpanded(projectSidebarSource(revealProjectId), true);- }, [revealProjectId, setExpanded]);const { projectSettings, projectOrder } = useSidebarProjectPrefs(wsId ?? "");const filteredProjects = useMemo(@@ -117,14 +118,48 @@ export function WorkPanel() {[projects, projectSettings, projectOrder, userId],);const openProject = projects.find((project) => isPathWithin(pathname, p.projectDetail(project.id)));- const keptProjects = useKeptActiveItem(PROJECTS_LIST, filteredProjects, openProject?.id ?? null, openProject);- const shownProjects = useMemo(() => {- const revealed = projects.find((project) => project.id === revealProjectId);- return revealed && !keptProjects.includes(revealed) ? [...keptProjects, revealed] : [...keptProjects];- }, [projects, keptProjects, revealProjectId]);- const issueLitInTree = treeIssueId !== null;+ const shownProjects = useKeptActiveItem(PROJECTS_LIST, filteredProjects, openProject?.id ?? null, openProject);const plainRowsLit = !pins.isActivePinnedRoute;+ // Opening an issue never opens its project: the tree changes only when the+ // user toggles a row or asks to show the issue there.+ const projectsCollapsed = useSidebarTreeStore((s) => s.projectsCollapsed);+ const issueProjectId = currentIssue?.project_id ?? null;+ const issueProject =+ !projectsCollapsed && issueProjectId ? shownProjects.find((project) => project.id === issueProjectId) : undefined;+ const issueProjectSource = issueProject ? projectSidebarSource(issueProject.id) : null;+ // An expanded project always lists its open issue (`ownsOpen`).+ const issueProjectExpanded = useSidebarTreeStore(+ (s) => !!issueProjectSource && s.expanded.includes(issueProjectSource),+ );+ const listing = issueProjectExpanded ? [...inTree.sources, issueProjectSource!] : inTree.sources;+ const listOrder = [+ ...viewActions.sidebar.items.map(sidebarViewItemSource),+ ...shownProjects.map((project) => projectSidebarSource(project.id)),+ ];+ const litSource =+ !plainRowsLit || !currentIssueId+ ? null+ : clickedList && listing.includes(clickedList)+ ? clickedList+ : issueProjectExpanded+ ? issueProjectSource+ : (listOrder.find((source) => listing.includes(source)) ?? null);+ const locatedProjectId = plainRowsLit && !litSource && issueProject ? issueProject.id : null;+ // An issue in a project the panel hides, or under the collapsed Projects+ // section, stays unmarked rather than lighting a list that may not show it.+ const issueInAllIssues = plainRowsLit && !!currentIssue && !currentIssue.project_id && litSource === null;++ const locate = useSidebarTreeStore((s) => s.locate);+ const setExpanded = useSidebarTreeStore((s) => s.setExpanded);+ const setProjectsCollapsed = useSidebarTreeStore((s) => s.setProjectsCollapsed);+ useEffect(() => {+ if (!locate || locate.issueId !== currentIssueId) return;+ setProjectsCollapsed(false);+ setExpanded(locate.source, true);+ setClickedIssue({ segment: locate.issueId, list: locate.source });+ }, [locate, currentIssueId, setExpanded, setProjectsCollapsed]);+return (<><PanelHeader title={t(($) => $.spaces.work)} />@@ -137,8 +172,10 @@ export function WorkPanel() {wsId={wsId}pathname={pathname}plainRowsLit={plainRowsLit}- issueLitInTree={issueLitInTree}- activeIssueId={plainRowsLit ? currentIssueId : null}+ issueInAllIssues={issueInAllIssues}+ activeIssueId={currentIssueId}+ litSource={litSource}+ actions={viewActions}/>)}@@ -156,7 +193,9 @@ export function WorkPanel() {projects={shownProjects}totalProjects={projects.length}plainRowsLit={plainRowsLit}- activeIssueId={plainRowsLit ? currentIssueId : null}+ activeIssueId={currentIssueId}+ litSource={litSource}+ locatedProjectId={locatedProjectId}/>)}</PanelBody>diff --git a/packages/views/layout/panels/work-tree.catalog.test.tsx b/packages/views/layout/panels/work-tree.catalog.test.tsxindex 86e737c458..94188fab46 100644--- a/packages/views/layout/panels/work-tree.catalog.test.tsx+++ b/packages/views/layout/panels/work-tree.catalog.test.tsx@@ -70,6 +70,8 @@ function renderSection() {totalProjects={1}plainRowsLitactiveIssueId={null}+ litSource={null}+ locatedProjectId={null}/></NavigationProvider></QueryClientProvider>,diff --git a/packages/views/layout/panels/work-tree.test.tsx b/packages/views/layout/panels/work-tree.test.tsxindex 88835e3315..82f0b2d657 100644--- a/packages/views/layout/panels/work-tree.test.tsx+++ b/packages/views/layout/panels/work-tree.test.tsx@@ -101,6 +101,8 @@ function renderSection() {totalProjects={4}plainRowsLitactiveIssueId={null}+ litSource={null}+ locatedProjectId={null}/></QueryClientProvider>,);diff --git a/packages/views/layout/panels/work-tree.tsx b/packages/views/layout/panels/work-tree.tsxindex b56781f9aa..a5823059f9 100644--- a/packages/views/layout/panels/work-tree.tsx+++ b/packages/views/layout/panels/work-tree.tsx@@ -1,6 +1,6 @@"use client";-import { useCallback, useEffect, useId, useRef, useSyncExternalStore } from "react";+import { useCallback, useEffect, useId, useMemo, useRef, useSyncExternalStore } from "react";import { useQueryClient } from "@tanstack/react-query";import { DndContext, PointerSensor, closestCenter, useSensor, useSensors, type DragEndEvent } from "@dnd-kit/core";import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";@@ -53,12 +53,20 @@ function usePrefetch(wsId: string, source: string, request: SidebarIssuesRequest};}+export interface IssueInTree {+ /** `null` when no expanded row lists the issue. */+ issueId: string | null;+ /** The sidebar sources of the expanded rows that list or keep it. */+ sources: readonly string[];+}++const NOT_IN_TREE: IssueInTree = { issueId: null, sources: [] };+/**- * The id of the issue an expanded row lists or keeps under `ref` — its UUID,- * or an identifier like `MUL-123` matched case-insensitively as the server- * does — or `null` when no expanded row lists it.+ * Where the expanded rows list or keep the issue under `ref` — its UUID, or+ * an identifier like `MUL-123` matched case-insensitively as the server does.*/-export function useIssueIdInTree(wsId: string, ref: string | null): string | null {+export function useIssueInTree(wsId: string, ref: string | null): IssueInTree {const qc = useQueryClient();const cache = qc.getQueryCache();const subscribe = useCallback(@@ -72,23 +80,36 @@ export function useIssueIdInTree(wsId: string, ref: string | null): string | nul},[cache],);- return useSyncExternalStore(subscribe, () => {- if (!ref) return null;+ // The snapshot is a string so an unchanged answer compares equal.+ const snapshot = useSyncExternalStore(subscribe, () => {+ if (!ref) return "";const identifier = ref.toUpperCase();const matches = (issue: Issue) => issue.id === ref || issue.identifier.toUpperCase() === identifier;+ const sourceAt = issueKeys.sidebarAll(wsId).length;const shown = (queryKey: readonly unknown[]) =>cache.findAll({ queryKey }).filter((query) => query.getObserversCount() > 0);+ let issueId: string | null = null;+ const sources = new Set<string>();for (const query of shown(issueKeys.sidebarAll(wsId))) {const issue = (query.state.data as ListIssuesResponse | undefined)?.issues?.find(matches);- if (issue) return issue.id;+ if (!issue) continue;+ issueId = issue.id;+ sources.add(String(query.queryKey[sourceAt]));}// A shown list keeps the open issue its query dropped (`useKeptActiveItem`).for (const [list, held] of Object.entries(useSidebarKeptStore.getState().held)) {const issue = qc.getQueryData<Issue>(issueKeys.detail(wsId, held.id));- if (issue && matches(issue) && shown([...issueKeys.sidebarAll(wsId), list]).length > 0) return issue.id;+ if (!issue || !matches(issue) || shown([...issueKeys.sidebarAll(wsId), list]).length === 0) continue;+ issueId = issue.id;+ sources.add(list);}- return null;+ return issueId ? [issueId, ...sources].join("\n") : "";});+ return useMemo(() => {+ if (!snapshot) return NOT_IN_TREE;+ const [issueId, ...sources] = snapshot.split("\n");+ return { issueId: issueId!, sources };+ }, [snapshot]);}interface ProjectsSectionProps {@@ -96,10 +117,14 @@ interface ProjectsSectionProps {userId: string | undefined;pathname: string;/** Already filtered and ordered by the section's settings. */- projects: Project[];+ projects: readonly Project[];totalProjects: number;plainRowsLit: boolean;activeIssueId: string | null;+ /** The one list that lights the open issue. */+ litSource: string | null;+ /** The project whose row marks the open issue no list shows. */+ locatedProjectId: string | null;}export function ProjectsSection({@@ -110,6 +135,8 @@ export function ProjectsSection({totalProjects,plainRowsLit,activeIssueId,+ litSource,+ locatedProjectId,}: ProjectsSectionProps) {const { t } = useT("layout");const p = useWorkspacePaths();@@ -167,7 +194,9 @@ export function ProjectsSection({active={plainRowsLit && isPathWithin(pathname, p.projectDetail(project.id))}showCount={projectSettings.showCount}issueSettings={issueSettings}- activeIssueId={activeIssueId}+ activeIssueId={litSource === projectSidebarSource(project.id) ? activeIssueId : null}+ openIssueId={activeIssueId}+ located={locatedProjectId === project.id}/>))}</PanelList>@@ -213,6 +242,8 @@ function ProjectTreeItem({showCount,issueSettings,activeIssueId,+ openIssueId,+ located,}: {wsId: string;userId: string | undefined;@@ -221,6 +252,8 @@ function ProjectTreeItem({showCount: boolean;issueSettings: SidebarIssueSettings;activeIssueId: string | null;+ openIssueId: string | null;+ located: boolean;}) {const { t } = useT("layout");const p = useWorkspacePaths();@@ -258,6 +291,7 @@ function ProjectTreeItem({label={project.title}icon={<Folder className="size-4 shrink-0" />}active={active}+ located={located}expanded={expanded}onExpandedChange={setExpanded}listId={listId}@@ -298,6 +332,8 @@ function ProjectTreeItem({paramsError={catalogDependency.error}onRetry={catalogDependency.retry}activeIssueId={activeIssueId}+ openIssueId={openIssueId}+ ownsOpen={(issue) => issue.project_id === project.id}onCollapse={() => {setExpanded(false);linkRef.current?.focus();diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex e9d7514157..64abb5bba5 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -982,6 +982,7 @@"unassigned": "Unassigned","open_in_new_tab": "Open in new tab","pin_to_sidebar": "Pin to sidebar",+ "locate_in_sidebar": "Show in sidebar","unpin_from_sidebar": "Unpin from sidebar","restore_to_inbox": "Restore to inbox","mark_read": "Mark as read",diff --git a/packages/views/locales/es/issues.json b/packages/views/locales/es/issues.jsonindex ff01ac77ea..45e7478159 100644--- a/packages/views/locales/es/issues.json+++ b/packages/views/locales/es/issues.json@@ -895,6 +895,7 @@"unassigned": "Sin asignar","open_in_new_tab": "Abrir en una pestaña nueva","pin_to_sidebar": "Fijar en la barra lateral",+ "locate_in_sidebar": "Mostrar en la barra lateral","unpin_from_sidebar": "Dejar de fijar de la barra lateral","copy_link": "Copiar enlace","copy_workdir_path": "Copiar ruta del directorio de trabajo local",diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex 64a49f1147..82e1ab2299 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -982,6 +982,7 @@"unassigned": "Non assigné","open_in_new_tab": "Ouvrir dans un nouvel onglet","pin_to_sidebar": "Épingler à la barre latérale",+ "locate_in_sidebar": "Afficher dans la barre latérale","unpin_from_sidebar": "Détacher de la barre latérale","restore_to_inbox": "Restaurer dans la boîte de réception","mark_read": "Marquer comme lu",diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex 1262b573fa..a39b4a5ae4 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -937,6 +937,7 @@"unassigned": "未割り当て","open_in_new_tab": "新しいタブで開く","pin_to_sidebar": "サイドバーにピン留め",+ "locate_in_sidebar": "サイドバーで表示","unpin_from_sidebar": "サイドバーのピン留めを解除","restore_to_inbox": "インボックスに戻す","mark_read": "既読にする",diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex 1f51103411..a2752a0a71 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -937,6 +937,7 @@"unassigned": "담당자 없음","open_in_new_tab": "새 탭에서 열기","pin_to_sidebar": "사이드바에 고정",+ "locate_in_sidebar": "사이드바에서 보기","unpin_from_sidebar": "사이드바 고정 해제","restore_to_inbox": "인박스로 복원","mark_read": "읽음으로 표시",diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex 4a67d4e681..d48b35dd5b 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -937,6 +937,7 @@"unassigned": "未分配","open_in_new_tab": "在新标签页打开","pin_to_sidebar": "固定到侧边栏",+ "locate_in_sidebar": "在侧边栏中定位","unpin_from_sidebar": "从侧边栏取消固定","restore_to_inbox": "恢复到收件箱","mark_read": "标为已读",diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.jsonindex a53f9cff69..0185d72bb6 100644--- a/packages/views/locales/zh-Hant/issues.json+++ b/packages/views/locales/zh-Hant/issues.json@@ -937,6 +937,7 @@"unassigned": "未分配","open_in_new_tab": "在新標籤頁開啟","pin_to_sidebar": "固定到側邊欄",+ "locate_in_sidebar": "在側邊欄中定位","unpin_from_sidebar": "從側邊欄取消固定","restore_to_inbox": "恢復到收件箱","mark_read": "標為已讀",