Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(issues): unify sidebar layout and execution summaries (#9532)
YYClawfae0a9060c6e
diff --git a/packages/views/common/date-only-picker.test.tsx b/packages/views/common/date-only-picker.test.tsxnew file mode 100644index 0000000000..e9f0bc3cc9--- /dev/null+++ b/packages/views/common/date-only-picker.test.tsx@@ -0,0 +1,14 @@+import { screen } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../test/i18n";+import { DateOnlyPicker } from "./date-only-picker";++describe("date picker progressive disclosure", () => {+ it("keeps the calendar mounted when its one-shot defaultOpen flag clears", async () => {+ const props = { value: null, onChange: vi.fn(), icon: <span />, placeholder: "Start date", emptyLabel: "No date" };+ const { rerender } = renderWithI18n(<DateOnlyPicker {...props} defaultOpen />);+ expect(await screen.findByRole("grid")).toBeVisible();+ rerender(<DateOnlyPicker {...props} defaultOpen={false} />);+ expect(screen.getByRole("grid")).toBeVisible();+ });+});diff --git a/packages/views/common/date-only-picker.tsx b/packages/views/common/date-only-picker.tsxindex b96bad1181..7d36f1cd6a 100644--- a/packages/views/common/date-only-picker.tsx+++ b/packages/views/common/date-only-picker.tsx@@ -67,10 +67,12 @@ interface DateOnlyPickerProps {* `DeferredPopup` for why.*/export function DateOnlyPicker(props: DateOnlyPickerProps) {+ // A one-shot defaultOpen must not replace the mounted calendar with a cold trigger.+ const [initialDefaultOpen] = useState(props.defaultOpen ?? false);const canDefer =props.open === undefined &&props.onOpenChange === undefined &&- !props.defaultOpen;+ !props.defaultOpen && !initialDefaultOpen;if (!canDefer) {return <DateOnlyPickerImpl {...props} />;}diff --git a/packages/views/issues/components/deliverables/deliverables-section.tsx b/packages/views/issues/components/deliverables/deliverables-section.tsxindex 3ebf01d828..33d093eebe 100644--- a/packages/views/issues/components/deliverables/deliverables-section.tsx+++ b/packages/views/issues/components/deliverables/deliverables-section.tsx@@ -1,8 +1,11 @@"use client";+import { IssueSidebarSectionHeader } from "../issue-sidebar-section";+import { useState } from "react";-import { ChevronRight, LayoutGrid } from "lucide-react";+import { LayoutGrid } from "lucide-react";import type { DeliverableFile } from "@multica/core/attachments/deliverables";+import { IconButton } from "@multica/ui/components/common/icon-button";import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { useT } from "../../../i18n";import { formatBytes } from "../../../common/format-bytes";@@ -48,22 +51,13 @@ export function DeliverablesSection({return (<div>- <button- type="button"- className={`flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors mb-2 hover:bg-accent/70 ${open ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => setOpen(!open)}- aria-expanded={open}- >- {t(($) => $.deliverables.section_title)}{" "}- <span className="rounded-xs bg-muted px-1 text-micro font-medium tabular-nums text-muted-foreground">- {files.length}- </span>- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`} />- </button>+ <IssueSidebarSectionHeader title={t(($) => $.deliverables.section_title)} open={open} onOpenChange={setOpen} count={files.length} actions={+ <IconButton size="icon-xs" label={t(($) => $.deliverables.view_all, { count: files.length })} onClick={onOpenOverview}><LayoutGrid /></IconButton>+ } />{open && (- <div className="pl-2">+ <div className="px-2">{images.length > 0 && (- <div className="mb-1.5 grid grid-cols-3 gap-1.5">+ <div className="mx-2 mb-1.5 grid grid-cols-3 gap-1.5">{images.map((file) => (<TooltipHint key={file.key} label={file.latest.filename}><button@@ -89,14 +83,7 @@ export function DeliverablesSection({onOpen={() => openAttachment(file.latest)}/>))}- <button- type="button"- className="mt-0.5 flex w-[calc(100%+1rem)] -mx-2 items-center gap-2 rounded-md px-2 py-1 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"- onClick={onOpenOverview}- >- <LayoutGrid className="size-3.5 shrink-0" />- {t(($) => $.deliverables.view_all, { count: files.length })}- </button>+</div>)}{modal}@@ -122,7 +109,7 @@ function FileRow({ file, onOpen }: { file: DeliverableFile; onOpen: () => void }return (<buttontype="button"- className="group flex w-[calc(100%+1rem)] -mx-2 items-center gap-2 rounded-md px-2 py-1 text-left text-caption transition-colors hover:bg-accent/50"+ className="group flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-caption transition-colors hover:bg-accent/50"title={latest.filename}aria-label={versionedName(file, t)}onClick={onOpen}diff --git a/packages/views/issues/components/execution-log-section.test.tsx b/packages/views/issues/components/execution-log-section.test.tsxindex d6acebc828..f9f0720eea 100644--- a/packages/views/issues/components/execution-log-section.test.tsx+++ b/packages/views/issues/components/execution-log-section.test.tsx@@ -309,14 +309,7 @@ describe("per-run token usage", () => {});});-// The sidebar this section lives in is a resizable panel — 260px minimum,-// 320px default, 420px maximum — so the header's three items (section label,-// active-run count, issue total) have to hold a width the component does not-// choose. They stopped holding it once the total moved into the header: at the-// 260px minimum the row has 227px and the full header wants ~238px, and the-// label was the only item that could give. It gave by breaking "Execution log"-// across two lines (MUL-5804). These tests pin the contract that replaced that:-// one line always, and a width tier that drops the run count whole.+// Header figures stay readable at every supported sidebar width.describe("execution log header geometry", () => {function renderSection(tasks: AgentTask[]) {// Seed the cache instead of mocking the API: the query is fresh for 30s,@@ -356,59 +349,30 @@ describe("execution log header geometry", () => {usage: [usageSlice()],});- it("tiers on the sidebar's width, not the viewport's", () => {- const { container } = renderSection([completed]);-- // Two sidebars of different widths can be open in one window (desktop- // split panes, the mobile sheet), so a `lg:` variant would tier this- // header on a width that has nothing to do with the panel it sits in.- const root = container.firstElementChild as HTMLElement;- expect(root.className).toContain("@container/execution-log");+ it("keeps the header independent of viewport breakpoints", () => {+ renderSection([completed]);for (const el of headerOf().querySelectorAll("*")) {- // classList, not className: the chevron is an SVG, whose className is an- // SVGAnimatedString.for (const cls of el.classList) {expect(cls).not.toMatch(/^(sm|md|lg|xl|2xl):/);}}+ expect(screen.getByRole("button", { name: "Execution log 1" })).toHaveAttribute("aria-expanded", "true");});- it("drops the run count whole rather than clipping a number", () => {- const { unmount } = renderSection([completed]);- let header = within(headerOf());-- // Below the tier the count and its separator leave together and the cost- // stays — never a clipped "$2.0…", which would read as a different figure- // than the issue actually spent.- const cost = header.getByText("$2.00");- expect(header.getByText("1 run").className).toContain(- "@max-[14rem]/execution-log:hidden",- );- expect(header.getByText("·").className).toContain(- "@max-[14rem]/execution-log:hidden",- );- expect(cost.className).not.toContain("hidden");- // And the pill itself never truncates — that is what would clip a digit.- const pill = cost.closest("button");- expect(pill?.className).toContain("shrink-0");- expect(pill?.className).not.toContain("truncate");-- // An active run puts the count chip in the same row, which is the shape- // that actually runs out of width — so it tiers earlier. At rest the total- // fits the 260px minimum whole and should not be tiered away with it.- unmount();- renderSection([completed, makeTask({ status: "running" })]);- header = within(headerOf());- expect(header.getByText("2 runs").className).toContain(- "@max-[16rem]/execution-log:hidden",- );+ it("keeps complete cost figures in the summary rather than crowding the header", () => {+ renderSection([completed]);+ expect(within(headerOf()).queryByText("$2.00")).not.toBeInTheDocument();+ const spent = screen.getByText("Spent", { selector: "dt" }).parentElement!;+ expect(spent).toHaveTextContent("$2.00");+ fireEvent.click(screen.getByRole("button", { name: "Execution log 1" }));+ expect(screen.getByRole("button", { name: "Execution log 1" })).toHaveAttribute("aria-expanded", "false");+ expect(screen.queryByText("Spent", { selector: "dt" })).not.toBeInTheDocument();});- it("keeps the run count when there is no cost to show instead", () => {+ it("keeps the count without inventing zero cost when no usage was reported", () => {renderSection([makeTask({ status: "completed", completed_at: "2026-06-08T08:04:00Z" })]);- const count = within(headerOf()).getByText("1 run");- expect(count.className).not.toContain("hidden");- expect(within(headerOf()).queryByText("$0.00")).not.toBeInTheDocument();+ expect(within(headerOf()).getByText("1")).toBeVisible();+ expect(screen.queryByText("$0.00")).not.toBeInTheDocument();});});@@ -444,20 +408,22 @@ describe("execution log past runs", () => {"Past run 4","Past run 3",]);- expect(screen.getByText("2 more")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Open timeline · Show 2 more" })).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: /Open timeline/ }));expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();expect(screen.getByText("MUL-1 · Wakeups")).toBeInTheDocument();});- it("shows each past run's cost, and who ran it with what on a second line", () => {+ it("keeps cost and agent duration visible with usage details in the tooltip", () => {renderSection([past(1)]);const row = screen.getByText("Past run 1").closest("[title]") as HTMLElement;expect(within(row).getByText("$2.00")).toBeInTheDocument();- expect(row).toHaveTextContent("Lambda · 10m · 892K tokens · Opus 5");- // The exact model id stays one hover away.+ expect(row).toHaveTextContent("Lambda · 10m");+ // Detailed usage remains available without crowding the summary row.+ expect(row).not.toHaveTextContent("892K tokens");+ expect(row.getAttribute("title")).toContain("892K tokens");expect(row.getAttribute("title")).toContain("claude-opus-5");});@@ -465,7 +431,7 @@ describe("execution log past runs", () => {renderSection([past(1, { status: "failed", failure_reason: "agent_error.provider_quota_limit" })]);const row = screen.getByText("Past run 1").closest("[title]") as HTMLElement;- expect(row).toHaveTextContent("Lambda · Provider quota exhausted · 892K tokens");+ expect(row).toHaveTextContent("Lambda · Provider quota exhausted");expect(row).not.toHaveTextContent("10m");});@@ -478,28 +444,84 @@ describe("execution log past runs", () => {expect(term("Agent time")).toHaveTextContent("30m");});- it("draws one bar per run and opens the Runs dialog from it", () => {+ it("opens the full history from the compact cost chart", () => {renderSection([past(1), past(2), past(3, { status: "failed", usage: [] })]);+ fireEvent.click(screen.getByRole("button", { name: /Cost per run/ }));+ expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();+ });- const bars = screen.getByRole("button", { name: "Cost per run — open the run timeline" });- expect(Array.from(bars.querySelectorAll("[data-run]"), (el) => el.getAttribute("data-run"))).toEqual([- "past-1",- "past-2",- "past-3",+ it("bounds the chart and recent list while keeping all-run totals and a visible history entry", () => {+ const tasks = Array.from({ length: 35 }, (_, i) => past(i + 1, {+ started_at: new Date(Date.UTC(2026, 5, i + 1, 8)).toISOString(),+ completed_at: new Date(Date.UTC(2026, 5, i + 1, 8, 10)).toISOString(),+ usage: [usageSlice({ cost_usd_ticks: 20_000_000_000 })],+ }));+ renderSection(tasks);+ const chart = screen.getByRole("button", { name: /Cost per run/ });+ expect(chart.querySelectorAll("[data-run]")).toHaveLength(30);+ expect(chart.querySelector("[data-run]")).toHaveAttribute("data-run", "past-6");+ expect(chart.querySelectorAll("[data-run]")[29]).toHaveAttribute("data-run", "past-35");+ expect(screen.getByText("Spent", { selector: "dt" }).parentElement).toHaveTextContent("$70.00");+ expect(screen.getAllByText(/^Past run \d+$/)).toHaveLength(3);+ fireEvent.click(screen.getByRole("button", { name: "Show 32 more" }));+ expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();+ });++ it("keeps all active tasks reachable in a separate scrolling region", () => {+ renderSection(Array.from({ length: 8 }, (_, i) => makeTask({ id: `active-${i}`, status: "queued", trigger_summary: `Queued ${i}`, usage: [] })));+ const active = screen.getByRole("region", { name: "8 active" });+ expect(within(active).getAllByText(/^Queued \d$/)).toHaveLength(8);+ expect(active).toHaveAttribute("tabindex", "0");+ });++ it("scales sidebar bars by cost to match the default run history", () => {+ renderSection([+ past(1, { usage: [usageSlice({ input_tokens: 100, output_tokens: 0, cache_read_tokens: 0, cache_write_tokens: 0, cost_usd_ticks: 100_000_000_000 })] }),+ past(2, { usage: [usageSlice({ input_tokens: 1000, output_tokens: 0, cache_read_tokens: 0, cache_write_tokens: 0, cost_usd_ticks: 10_000_000_000 })] }),]);- // The run without usage is a stub, not a bar sized like a cheap run.- expect((bars.querySelector('[data-run="past-3"]') as HTMLElement).className).toContain("bg-destructive");+ const bars = screen.getByRole("button", { name: /Cost per run/ }).querySelectorAll("[data-run]");+ expect((bars[0] as HTMLElement).style.height).toBe("40px");+ expect((bars[1] as HTMLElement).style.height).toBe("4px");+ });- fireEvent.click(bars);- expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();+ it.each([1, 8, 15, 30])("preserves upstream slots for %i runs", (count) => {+ renderSection(Array.from({ length: count }, (_, i) => past(i + 1, {+ started_at: new Date(Date.UTC(2026, 5, i + 1, 8)).toISOString(),+ completed_at: new Date(Date.UTC(2026, 5, i + 1, 8, 10)).toISOString(),+ })));+ const chart = screen.getByRole("button", { name: /Cost per run/ });+ const plot = chart.querySelector("[aria-hidden]") as HTMLElement;+ expect(plot.style.height).toBe("40px");+ expect(plot.children).toHaveLength(Math.max(20, count));+ expect(chart.querySelectorAll("[data-run]")).toHaveLength(count);+ expect(plot.children[plot.children.length - count]).toHaveAttribute("data-run");+ expect(chart).not.toHaveTextContent("Latest");+ expect(chart).not.toHaveTextContent("Cost per run");+ expect(chart).not.toHaveTextContent("#1");+ });++ it("preserves run status colors and marks missing usage", () => {+ renderSection([+ past(1, { status: "failed" }),+ past(2, { status: "cancelled" }),+ past(3, { usage: [] }),+ makeTask({ id: "active", status: "running", usage: [] }),+ ]);+ const chart = screen.getByRole("button", { name: /Cost per run/ });+ expect(chart.querySelector('[data-run="past-1"]')).toHaveClass("bg-destructive");+ expect(chart.querySelector('[data-run="past-2"]')).toHaveClass("bg-faint-foreground");+ expect(chart.querySelector('[data-run="past-3"]')).toHaveClass("border-dashed");+ expect(chart.querySelector('[data-run="active"]')).toHaveClass("bg-info");+ expect(chart).toHaveTextContent("Now");});- it("draws the bars from the first priced run", () => {+ it("makes full details reachable from the first priced run", () => {renderSection([past(1)]);- expect(screen.getByRole("button", { name: /Cost per run/ })).toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: /Open timeline/ }));+ expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();});- it("skips the bars when no run recorded usage — there is no cost to compare", () => {+ it("skips the bars when no run recorded usage — there are no costs to compare", () => {renderSection([past(1, { usage: [] }), past(2, { usage: [] })]);expect(screen.queryByRole("button", { name: /Cost per run/ })).not.toBeInTheDocument();});diff --git a/packages/views/issues/components/execution-log-section.tsx b/packages/views/issues/components/execution-log-section.tsxindex be3626e630..09efae1684 100644--- a/packages/views/issues/components/execution-log-section.tsx+++ b/packages/views/issues/components/execution-log-section.tsx@@ -2,13 +2,14 @@import { Fragment, useEffect, useMemo, useState } from "react";import { useQuery } from "@tanstack/react-query";-import { ChevronRight, Loader2, Maximize2, Square } from "lucide-react";+import { Loader2, Maximize2, Square } from "lucide-react";import { toast } from "sonner";import { api } from "@multica/core/api";import { issueTasksOptions } from "@multica/core/issues/queries";import { useActorName } from "@multica/core/workspace/hooks";import { useCustomPricingStore } from "@multica/core/runtimes/custom-pricing-store";import type { AgentTask } from "@multica/core/types";+import { IconButton } from "@multica/ui/components/common/icon-button";import { cn } from "@multica/ui/lib/utils";import { useLocale, useTimeAgo } from "../../i18n";import {@@ -20,6 +21,7 @@ import { ActorAvatar } from "../../common/actor-avatar";import { formatDuration } from "../../agents/components/agent-activity-hover-content";import { TranscriptButton } from "../../common/task-transcript";import { cancellationActorLabel, cancelReasonLabel, failureReasonLabel } from "../../agents/components/tabs/task-failure";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";import { useT } from "../../i18n";import { compareActiveIssueTasks } from "./active-task-order";import { formatDuration as formatAgentTime } from "../../dashboard/utils";@@ -34,27 +36,16 @@ import { IssueRunsDialog } from "./issue-runs-dialog";import { RunTriggerLabel } from "./run-trigger-label";import {buildRunTimeline,- shortModelName,- type RunTimeline,type TimelineRun,+ type RunTimeline,} from "./issue-run-timeline";import { canRetryRun, RetryRunButton } from "./retry-run-button";import { TaskStatusIcon } from "./task-status-icon";import { useStatusLabel, useTriggerText } from "./task-run-labels";import { WakeupRunLabel } from "./wakeup-source-chip";-// Right-panel section that lists every agent run for this issue. Active-// runs sit at the top (always visible when present); below them the issue's-// totals, one cost bar per recent run, and the latest few past runs. The full-// history lives in the Runs dialog the header total, the bars and the "Open-// timeline" row open — 21 rows do not belong in a 320px column, and the dialog-// can lay them out in time.-//-// Replaces:-// - the click-to-expand timeline that used to live inside the in-body live-// card (the live "agent is working" signal now lives in the header via-// IssueAgentHeaderChip)-// - the standalone <TaskRunHistory> below the main content+// Sidebar summary: totals, a bounded cost chart, active runs and recent history.+// Full charts and history live in the Runs dialog.//// Row layout — simple left/right flex:// 1. Agent avatar (no status dot — agent availability is not the@@ -136,15 +127,12 @@ export function ExecutionLogSection({ issueId, identifier, issueTitle }: Executi});}, [tasks]);- // Sidebar-only figures: the totals and the cost bars. Priced with the same- // helpers as the dialog, and re-derived on a saved custom rate for the same- // reason IssueRunsTotal subscribes.+ // Keep summary totals priced with the same helpers and custom rates as the dialog.const timeline = useMemo(() => buildRunTimeline(tasks, Date.now()),// eslint-disable-next-line react-hooks/exhaustive-deps -- `pricings` re-prices on a saved custom rate[tasks, pricings],);- const pastRuns = useMemo(() => timeline.runs.filter((run) => !run.active), [timeline]);if (activeTasks.length === 0 && pastTasks.length === 0) return null;@@ -153,84 +141,41 @@ export function ExecutionLogSection({ issueId, identifier, issueTitle }: Executiconst openRuns = () => setRunsOpen(true);return (- // `@container/execution-log`: the header's three items only fit side by- // side above a certain width, and the width that decides it is the- // sidebar's — a resizable 260–420px panel — not the viewport's. See- // IssueRunsTotal for the tier this container drives.<div className="@container/execution-log">- {/* Header is two independent targets, not one: the label + chevron- collapse the section, the total on the right opens the Runs dialog.- Nesting a button inside a button is invalid HTML, so they are- siblings in a flex row rather than a button wrapping a button. */}- <div className="mb-2 flex w-full items-center gap-1">- <button- type="button"- className={`flex min-w-0 items-center gap-1 whitespace-nowrap rounded-md px-2 py-1 text-caption font-medium transition-colors hover:bg-accent/70 ${- open ? "" : "text-muted-foreground hover:text-foreground"- }`}- onClick={() => setOpen(!open)}- >- {/* The section label is the one item here that may shrink, so it- carries the nowrap + ellipsis pair. Without it the squeezed- button broke "Execution log" across two lines (MUL-5804) — a- section heading that reflows is a layout bug, not a narrow- column. The tier below keeps the ellipsis from ever showing at- the panel's 260px minimum; it is the backstop for a longer- translation, not the everyday state. */}- <span className="truncate">{t(($) => $.execution_log.section)}</span>- <ChevronRight- className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${- open ? "rotate-90" : ""- }`}- />- </button>- {activeTasks.length > 0 && (- <span className="ml-auto inline-flex shrink-0 items-center gap-1 text-info">- <span className="h-1.5 w-1.5 rounded-full bg-info animate-pulse" />- <span className="font-mono text-caption tabular-nums">{activeTasks.length}</span>+ <IssueSidebarSectionHeader+ title={t(($) => $.execution_log.section)} open={open} onOpenChange={setOpen}+ count={activeTasks.length + pastTasks.length}+ actions={<IconButton size="icon-xs" onClick={openRuns}+ label={[t(($) => $.execution_log.open_timeline), hiddenCount > 0 ? t(($) => $.execution_log.more_runs, { count: hiddenCount }) : null].filter(Boolean).join(" · ")}>+ <Maximize2 />+ </IconButton>}+ status={activeTasks.length > 0 ? (+ <span className="inline-flex shrink-0 items-center gap-1 text-caption text-info tabular-nums">+ <span aria-hidden="true" className="size-1.5 rounded-full bg-info motion-safe:animate-pulse" />+ {t(($) => $.runs_timeline.count_active, { count: activeTasks.length })}</span>- )}- <IssueRunsTotal- tasks={tasks}- alone={activeTasks.length === 0}- onOpen={openRuns}- />- </div>+ ) : undefined}+ />{open && (- <div className="space-y-0.5 pl-2">- {activeTasks.map((task) => (- <ActiveTaskRow key={task.id} task={task} issueId={issueId} />- ))}- {activeTasks.length > 0 && pastRuns.length > 0 && (- <div className="my-1.5 border-t border-border/60" />+ <div className="space-y-2 px-2">+ {(timeline.pricedCount > 0 || timeline.agentMs > 0) && (+ <div className="space-y-0.5 pt-2">+ <RunTotals timeline={timeline} />+ {timeline.pricedCount > 0 && <RunCostBars timeline={timeline} onOpen={openRuns} />}+ </div>)}-- {(timeline.pricedCount > 0 || timeline.agentMs > 0) && <RunTotals timeline={timeline} />}- {timeline.pricedCount > 0 && <RunCostBars timeline={timeline} onOpen={openRuns} />}-- {latest.length > 0 && (- <>- <div className="px-1 pt-2 pb-0.5 text-micro text-muted-foreground">- {t(($) => $.execution_log.latest)}- </div>- {latest.map((task) => (- <PastRow key={task.id} task={task} issueId={issueId} />- ))}- </>+ {activeTasks.length > 0 && (+ <div className="max-h-48 space-y-0.5 overflow-y-auto overscroll-contain rounded-md focus-visible:outline-2 focus-visible:outline-ring" role="region" aria-label={t(($) => $.runs_timeline.count_active, { count: activeTasks.length })} tabIndex={0}>+ {activeTasks.map((task) => <ActiveTaskRow key={task.id} task={task} issueId={issueId} />)}+ </div>)}- <button- type="button"- onClick={openRuns}- className="flex w-full items-center gap-1.5 rounded-xs px-1 py-1.5 text-caption transition-colors hover:bg-accent/40"- >- <Maximize2 aria-hidden className="size-3 shrink-0 text-muted-foreground" />- <span className="truncate">{t(($) => $.execution_log.open_timeline)}</span>- {hiddenCount > 0 && (- <span className="ml-auto shrink-0 text-muted-foreground tabular-nums">- {t(($) => $.execution_log.more_runs, { count: hiddenCount })}- </span>- )}- </button>+ {latest.length > 0 && <div className="space-y-0.5">+ {activeTasks.length > 0 && <p className="px-2 text-micro text-muted-foreground">{t(($) => $.execution_log.latest)}</p>}+ {latest.map((task) => <PastRow key={task.id} task={task} issueId={issueId} />)}+ {hiddenCount > 0 && <button type="button" onClick={openRuns} className="flex min-h-8 w-full items-center rounded-md px-2 text-caption text-muted-foreground hover:bg-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">+ {t(($) => $.execution_log.more_runs, { count: hiddenCount })}+ </button>}+ </div>}</div>)}<IssueRunsDialog@@ -332,7 +277,7 @@ function RunCostBars({ timeline, onOpen }: { timeline: RunTimeline; onOpen: () =}, [first, last, timeline.activeCount, locale, t]);return (- <div className="px-1 pb-1">+ <div className="px-1"><Tooltip trackCursorAxis="x"><TooltipTriggerrender={@@ -685,19 +630,17 @@ function PastRow({ task, issueId }: { task: AgentTask; issueId: string }) {? [cancellationLabel, failureLabel].filter(Boolean).join(" · "): failureLabel ?? label;- // What this run cost sits on the first line, beside the trigger people scan- // the list for; the second line says who ran it and how — the reason it- // stopped, or how long it took, then its tokens and model. The list is- // sorted newest-first, so the exact "when" is the detail: it lives in the- // row tooltip, with the full model ids.- //- // `null` (no usage recorded) renders an em dash, never $0: a run from before- // usage reporting was not free, we simply have no figure for it.+ // Keep per-run usage and model details in the tooltip and Runs dialog.+ // Failure and cancellation reasons remain visible beside the agent name.const usage = summarizeTaskUsage(task.usage);const reason = cancellationLabel? [cancellationLabel, failureLabel].filter(Boolean).join(" · "): failureLabel;- const rowTitle = [time, usage?.models.join(", ") ?? ""].filter(Boolean).join(" · ");+ const rowTitle = [+ time,+ usage ? t(($) => $.runs_timeline.tokens_count, { tokens: formatTokens(usage.tokens) }) : null,+ usage?.models.join(", "),+ ].filter(Boolean).join(" · ");const meta: { key: string; node: React.ReactNode }[] = [];if (task.agent_id) meta.push({ key: "agent", node: getActorName("agent", task.agent_id) });if (reason) {@@ -709,10 +652,7 @@ function PastRow({ task, issueId }: { task: AgentTask; issueId: string }) {const seconds = (new Date(task.completed_at).getTime() - new Date(task.started_at).getTime()) / 1000;meta.push({ key: "duration", node: formatAgentTime(seconds, "0s") });}- if (usage) {- meta.push({ key: "tokens", node: t(($) => $.runs_timeline.tokens_count, { tokens: formatTokens(usage.tokens) }) });- if (usage.models[0]) meta.push({ key: "model", node: shortModelName(usage.models[0]) });- }+return (<RowShell task={task} title={rowTitle} multiline>@@ -739,7 +679,7 @@ function PastRow({ task, issueId }: { task: AgentTask; issueId: string }) {</RowActions></div>{meta.length > 0 && (- <p className="-mt-1 truncate text-micro text-muted-foreground">+ <p className="-mt-1 break-words text-micro text-muted-foreground">{meta.map((part, i) => (<Fragment key={part.key}>{i > 0 && <span className="text-faint-foreground"> · </span>}@@ -775,7 +715,7 @@ function RowShell({<divtitle={title || undefined}className={cn(- "group/execution-log-row flex gap-2 overflow-hidden rounded-xs px-1 py-1.5 transition-colors hover:bg-accent/40",+ "group/execution-log-row flex gap-2 overflow-hidden rounded-md px-2 py-1.5 transition-colors hover:bg-accent/50",multiline ? "items-start" : "items-center",)}>diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 3bc662f9b5..8b356a7168 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -1,6 +1,7 @@import { forwardRef, useEffect, useRef, useState, useImperativeHandle } from "react";import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";+import userEvent from "@testing-library/user-event";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import type { AgentTask, Attachment, Issue, IssueStatusEntry, Label, TimelineEntry } from "@multica/core/types";import { issueKeys } from "@multica/core/issues/queries";@@ -123,6 +124,8 @@ vi.mock("@multica/core/paths", async () => {};});+const settingsPush = vi.hoisted(() => vi.fn());+// Mock navigationvi.mock("../../navigation", () => ({AppLink: ({ children, href, ...props }: any) => (@@ -131,7 +134,7 @@ vi.mock("../../navigation", () => ({</a>),useNavigation: () => ({- push: vi.fn(),+ push: settingsPush,pathname: "/issues/issue-1",getShareableUrl: (p: string) => `https://app.multica.com${p}`,}),@@ -1138,7 +1141,7 @@ describe("IssueDetail (shared)", () => {expect(screen.queryByText("Parent issue")).not.toBeInTheDocument();// The "+ Add property" affordance is always offered while any// optional field is still hidden.- expect(screen.getByText("Add property")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Add property" })).toBeInTheDocument();});it("hides every optional property row when none are set", async () => {@@ -1163,7 +1166,39 @@ describe("IssueDetail (shared)", () => {expect(screen.getByTestId("project-picker")).toBeInTheDocument();// No parent → no standalone Parent issue section either.expect(screen.queryByText("Parent issue")).not.toBeInTheDocument();- expect(screen.getByText("Add property")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Add property" })).toBeInTheDocument();+ });++ it("opens property management independently while Properties is folded", async () => {+ renderIssueDetail();+ const disclosure = await screen.findByRole("button", { name: "Properties" });+ fireEvent.click(disclosure);+ fireEvent.click(screen.getByRole("button", { name: "Properties options" }));+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ fireEvent.click(await screen.findByRole("menuitem", { name: "Custom property settings" }));+ expect(settingsPush).toHaveBeenCalledWith("/test/settings?tab=properties");+ });++ it("returns focus to Add property when the menu is dismissed without selecting a field", async () => {+ const user = userEvent.setup();+ renderIssueDetail();+ const trigger = await screen.findByRole("button", { name: "Add property" });+ await user.click(trigger);+ expect(await screen.findByRole("menuitem", { name: "Start date" })).toBeVisible();+ await user.keyboard("{Escape}");+ await waitFor(() => expect(trigger).toHaveFocus());+ expect(screen.queryByRole("menuitem", { name: "Start date" })).not.toBeInTheDocument();+ });++ it("keeps add-property available when folded and expands after choosing a field", async () => {+ renderIssueDetail();+ const disclosure = await screen.findByRole("button", { name: "Properties" });+ fireEvent.click(disclosure);+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ fireEvent.click(screen.getByRole("button", { name: "Add property" }));+ fireEvent.click(await screen.findByRole("menuitem", { name: "Start date" }));+ await waitFor(() => expect(disclosure).toHaveAttribute("aria-expanded", "true"));+ expect(within(disclosure.parentElement!.parentElement!).getAllByText("Start date")[0]).toBeVisible();});it("uses a non-resizable layout with the sidebar sheet closed by default on mobile", async () => {@@ -1303,9 +1338,7 @@ describe("IssueDetail (shared)", () => {expect(scrollIntoViewSpy).not.toHaveBeenCalled();});- it("hides metadata content from the sidebar and shows a button when the bag has keys", async () => {- // Metadata is agent-facing; the sidebar only exposes a button that opens- // the raw JSON on demand. Keys are NOT rendered inline anywhere.+ it("keeps metadata collapsed by default when the bag has keys", async () => {mockApiObj.getIssue.mockResolvedValue({...mockIssue,metadata: {@@ -1317,42 +1350,24 @@ describe("IssueDetail (shared)", () => {renderIssueDetail();await waitFor(() => {- // Trigger label includes a "· N" count so users can see payload size- // before clicking — accept any count via regex.expect(screen.getByRole("button", { name: /^Metadata\b/ })).toBeInTheDocument();});- // Key names are not rendered in the sidebar prior to opening the dialog.+ // Keys stay hidden until the section is expanded.expect(screen.queryByText("pr_url")).not.toBeInTheDocument();expect(screen.queryByText("pipeline_status")).not.toBeInTheDocument();});- it("opens a dialog with formatted JSON when the Metadata button is clicked", async () => {+ it("expands metadata inline from the shared sidebar header", async () => {mockApiObj.getIssue.mockResolvedValue({...mockIssue,- metadata: {- pr_url: "https://example.com/pr/1",- pipeline_status: "running",- },+ metadata: { pipeline_status: "running" },});-renderIssueDetail();-- const button = await screen.findByRole("button", { name: /^Metadata\b/ });- fireEvent.click(button);-- // The dialog renders a <pre> containing the formatted JSON; checking the- // exact serialized payload also verifies the indent / structure.- const expected = JSON.stringify(- { pr_url: "https://example.com/pr/1", pipeline_status: "running" },- null,- 2,- );- await waitFor(() => {- const pre = document.querySelector("pre");- expect(pre).not.toBeNull();- expect(pre!.textContent).toBe(expected);- });+ fireEvent.click(await screen.findByRole("button", { name: /^Metadata\b/ }));+ expect(screen.getByText("pipeline_status")).toBeVisible();+ expect(screen.getByText("running")).toBeVisible();+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();});it("hides the Metadata button entirely when the bag is empty", async () => {diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 82925bbc19..ad86c504f9 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -38,7 +38,6 @@ import { BreadcrumbHeader, type BreadcrumbSegment } from "../../layout/breadcrumimport { Skeleton } from "@multica/ui/components/ui/skeleton";import { Button } from "@multica/ui/components/ui/button";import { IconButton } from "@multica/ui/components/common/icon-button";-import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@multica/ui/components/ui/resizable";import { Sheet, SheetContent } from "@multica/ui/components/ui/sheet";import { useIsMobile } from "@multica/ui/hooks/use-mobile";@@ -64,7 +63,6 @@ import {DropdownMenuItem,} from "@multica/ui/components/ui/dropdown-menu";import { Popover, PopoverTrigger, PopoverContent } from "@multica/ui/components/ui/popover";-import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@multica/ui/components/ui/dialog";import { Checkbox } from "@multica/ui/components/ui/checkbox";import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@multica/ui/components/ui/command";import { AvatarGroup, AvatarGroupCount } from "@multica/ui/components/ui/avatar";@@ -177,6 +175,9 @@ import { PAGE_GUTTER } from "../../layout/page-header";import { ProgressRing } from "./progress-ring";import { matchesPinyin } from "../../editor/extensions/pinyin-match";+import { MetadataSection } from "./metadata-section";+import { IssueSidebarSettingsMenu } from "./issue-sidebar-settings-menu";+import { IssueSidebarSectionHeader, IssueSidebarStack, IssueSidebarPropertyGrid } from "./issue-sidebar-section";import { useT } from "../../i18n";import { useIssueDetailScrollRestore } from "../hooks/use-issue-detail-scroll-restore";import { useInPageFind } from "../hooks/use-in-page-find";@@ -1352,10 +1353,9 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr}, [isMobile]);const sidebarOpen = isMobile ? mobileSidebarOpen : desktopSidebarOpen;const [propertiesOpen, setPropertiesOpen] = useState(true);- const [detailsOpen, setDetailsOpen] = useState(true);+ const [detailsOpen, setDetailsOpen] = useState(false);const [parentIssueOpen, setParentIssueOpen] = useState(true);const [pullRequestsOpen, setPullRequestsOpen] = useState(true);- const [metadataOpen, setMetadataOpen] = useState(false);const githubSettings = useGitHubSettings();// Per-issue, per-session set of optional properties currently visible in@@ -1374,11 +1374,9 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr// picked it from "+ Add property" and we want them dropped straight into// edit state). Consumed by the row that matches this key, cleared after.const [autoOpenProp, setAutoOpenProp] = useState<OptionalPropKey | null>(null);- // Controlled state for the "+ Add property" popover. Base UI's Popover- // doesn't auto-dismiss on item click (it's not a Menu primitive), so the- // popover would stay open behind the newly auto-opened picker — two- // popovers stacked. We close it explicitly in `addOptionalProp`.- const [addPropPopoverOpen, setAddPropPopoverOpen] = useState(false);+ // Keep the add menu controlled while its action opens the field picker.+ const [addPropMenuOpen, setAddPropMenuOpen] = useState(false);+ const propertyPickerOpeningRef = useRef(false);// Virtuoso's `customScrollParent` wants the HTMLElement, not a ref. A plain// `useRef.current` does not trigger a re-render when it populates, so the// Virtuoso prop would never receive the element. Callback ref + state fixes@@ -2583,9 +2581,10 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trreturn next;});setAutoOpenProp(key);- // Dismiss the "+ Add property" popover so it doesn't sit stacked- // behind the picker we're about to auto-open.- setAddPropPopoverOpen(false);+ // Let the field picker take focus instead of restoring it to the menu trigger.+ propertyPickerOpeningRef.current = true;+ setPropertiesOpen(true);+ setAddPropMenuOpen(false);},[],);@@ -2597,8 +2596,10 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trnext.add(propertyId);return next;});+ propertyPickerOpeningRef.current = true;setAutoOpenCustomProp(propertyId);- setAddPropPopoverOpen(false);+ setPropertiesOpen(true);+ setAddPropMenuOpen(false);}, []);// Clear the auto-open flag after the next render so pickers (which read@@ -2728,19 +2729,94 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trpersistDescriptionSave(draft);};+ const canAddProperty = OPTIONAL_PROP_KEYS.some(+ (key) => !visibleOptionalProps.has(key) && (key !== "stage" || issue.parent_issue_id != null),+ ) || workspaceProperties.some(+ (property) => !property.archived && !visibleCustomProps.has(property.id) && issue.properties?.[property.id] === undefined,+ );+ const addPropertyAction = canAddProperty && (+ <DropdownMenu open={addPropMenuOpen} onOpenChange={(open) => {+ if (open) propertyPickerOpeningRef.current = false;+ setAddPropMenuOpen(open);+ }}>+ <DropdownMenuTrigger render={<IconButton size="icon-xs" label={t(($) => $.detail.add_property_action)} />}>+ <Plus />+ </DropdownMenuTrigger>+ {/* 388px is the sidebar's 420px resize limit minus its 16px padding on each side. */}+ <DropdownMenuContent+ align="end"+ className="w-max max-w-[min(388px,var(--available-width))]"+ finalFocus={() => !propertyPickerOpeningRef.current}+ >+ {OPTIONAL_PROP_KEYS.filter((k) => !visibleOptionalProps.has(k) && (k !== "stage" || issue.parent_issue_id != null)).map((k) => (+ <DropdownMenuItem+ key={k}+ onClick={() => addOptionalProp(k)}+ >+ {k === "priority" && (+ <PriorityIcon priority="medium" inheritColor className="text-muted-foreground" />+ )}+ {k === "stage" && (+ <Milestone className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ {k === "start_date" && (+ <CalendarClock className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ {k === "due_date" && (+ <CalendarDays className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ {k === "labels" && (+ <Tag className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ <span className="truncate">+ {k === "priority" && t(($) => $.detail.prop_priority)}+ {k === "stage" && t(($) => $.detail.prop_stage)}+ {k === "start_date" && t(($) => $.detail.prop_start_date)}+ {k === "due_date" && t(($) => $.detail.prop_due_date)}+ {k === "labels" && t(($) => $.detail.prop_labels)}+ </span>+ </DropdownMenuItem>+ ))}+ {(() => {+ const addable = workspaceProperties.filter(+ (p) =>+ !p.archived &&+ !visibleCustomProps.has(p.id) &&+ issue.properties?.[p.id] === undefined,+ );+ if (addable.length === 0) return null;+ return (+ <>+ <div className="my-1 h-px bg-border" />+ {addable.map((p) => (+ <DropdownMenuItem+ key={p.id}+ onClick={() => addCustomProp(p.id)}+ >+ {p.icon ? (+ <PropertyIcon property={p} className="size-3.5 text-caption" />+ ) : (+ <SlidersHorizontal className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ <span className="line-clamp-2 min-w-0 break-words [overflow-wrap:anywhere]" title={p.name}>{p.name}</span>+ </DropdownMenuItem>+ ))}+ </>+ );+ })()}+ </DropdownMenuContent>+ </DropdownMenu>+ );+const sidebarContent = (- <div className="space-y-5">+ <IssueSidebarStack>{/* Properties */}<div>- <button- type="button"- className={`flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors mb-2 hover:bg-accent/70 ${propertiesOpen ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => setPropertiesOpen(!propertiesOpen)}- >- {t(($) => $.detail.section_properties)}- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${propertiesOpen ? "rotate-90" : ""}`} />- </button>- {propertiesOpen && <div className="grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5 pl-2">+ <IssueSidebarSectionHeader title={t(($) => $.detail.section_properties)} open={propertiesOpen} onOpenChange={setPropertiesOpen} actions={<>+ {addPropertyAction}+ <IssueSidebarSettingsMenu title={t(($) => $.detail.section_properties)} label={t(($) => $.sidebar_settings.properties)} tab="properties" />+ </>} />+ {propertiesOpen && <IssueSidebarPropertyGrid>{/* Core props — always rendered. */}<PropRow label={t(($) => $.detail.prop_status)}><StatusPicker@@ -2833,7 +2909,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trlabel={<><PropertyIcon property={p} className="size-3.5 text-caption" />- <span className="truncate">{p.name}</span>+ <span className="line-clamp-2 min-w-0 break-words [overflow-wrap:anywhere]" title={p.name}>{p.name}</span></>}>@@ -2845,104 +2921,18 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr</PropRow>))}- {/* "+ Add property" — opens a Popover listing optional fields- not yet displayed. Hidden once every optional field is on- screen. Sits inside the same grid as a full-row, with its- own padding so the visual rhythm follows the rows above. */}- {(OPTIONAL_PROP_KEYS.some((k) => !visibleOptionalProps.has(k) && (k !== "stage" || issue.parent_issue_id != null)) ||- workspaceProperties.some((p) => !p.archived && !visibleCustomProps.has(p.id) && issue.properties?.[p.id] === undefined)) && (- <div className="col-span-2 mt-1">- <Popover open={addPropPopoverOpen} onOpenChange={setAddPropPopoverOpen}>- <PopoverTrigger- className="flex items-center gap-1.5 rounded-md px-2 py-1 -mx-2 text-caption text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors"- >- <Plus className="h-3 w-3 shrink-0" />- <span>{t(($) => $.detail.add_property_action)}</span>- </PopoverTrigger>- {/* Item visuals mirror the inspector rows' typography- (text-caption, muted icons) and each option leads with the- icon the resulting picker uses, so the dropdown reads- as a preview of what will show up below. */}- <PopoverContent align="start" className="w-44 p-1">- {OPTIONAL_PROP_KEYS.filter((k) => !visibleOptionalProps.has(k) && (k !== "stage" || issue.parent_issue_id != null)).map((k) => (- <button- key={k}- type="button"- onClick={() => addOptionalProp(k)}- className="flex w-full items-center gap-2 rounded-md px-2 py-1 text-caption text-foreground transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none"- >- {k === "priority" && (- <PriorityIcon priority="medium" inheritColor className="text-muted-foreground" />- )}- {k === "stage" && (- <Milestone className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- )}- {k === "start_date" && (- <CalendarClock className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- )}- {k === "due_date" && (- <CalendarDays className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- )}- {k === "labels" && (- <Tag className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- )}- <span className="truncate">- {k === "priority" && t(($) => $.detail.prop_priority)}- {k === "stage" && t(($) => $.detail.prop_stage)}- {k === "start_date" && t(($) => $.detail.prop_start_date)}- {k === "due_date" && t(($) => $.detail.prop_due_date)}- {k === "labels" && t(($) => $.detail.prop_labels)}- </span>- </button>- ))}- {(() => {- const addable = workspaceProperties.filter(- (p) =>- !p.archived &&- !visibleCustomProps.has(p.id) &&- issue.properties?.[p.id] === undefined,- );- if (addable.length === 0) return null;- return (- <>- <div className="my-1 h-px bg-border" />- {addable.map((p) => (- <button- key={p.id}- type="button"- onClick={() => addCustomProp(p.id)}- className="flex w-full items-center gap-2 rounded-md px-2 py-1 text-caption text-foreground transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none"- >- {p.icon ? (- <PropertyIcon property={p} className="size-3.5 text-caption" />- ) : (- <SlidersHorizontal className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- )}- <span className="truncate">{p.name}</span>- </button>- ))}- </>- );- })()}- </PopoverContent>- </Popover>- </div>- )}- </div>}+ </IssueSidebarPropertyGrid>}</div>- {/* Quick actions — the sidebar's only "do something" block, so it sits- directly under Properties and above every read-only section. Renders- nothing when the workspace has no active action visible to this- member. It is NOT filtered by invoke permission: a member can see and- click an action they cannot run, and the refusal is explained at run- time rather than by a silently shorter list. */}+ {/* Keep creation available even when the workspace has no active quick actions. */}<QuickActionsSection issueId={issue.id} />+<WakeupsSectionissueId={issue.id}closed={["done", "closed"].includes(resolveStatusCategory(issue.status))}defaultAgentId={issue.assignee_type === "agent" ? (issue.assignee_id ?? undefined) : undefined}/>+<PluginPanelSection issueId={issue.id} />{/* Parent issue — standalone section, only when the issue has a@@ -2951,19 +2941,13 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trspace for issues that don't have one. */}{parentIssue && (<div>- <button- type="button"- className={`flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors mb-2 hover:bg-accent/70 ${parentIssueOpen ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => setParentIssueOpen(!parentIssueOpen)}- >- {t(($) => $.detail.section_parent_issue)}- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${parentIssueOpen ? "rotate-90" : ""}`} />- </button>- {parentIssueOpen && <div className="pl-2">- <div className="flex items-center gap-0.5 rounded-md px-2 -mx-2 hover:bg-accent/50 transition-colors group">+ <IssueSidebarSectionHeader title={t(($) => $.detail.section_parent_issue)} open={parentIssueOpen} onOpenChange={setParentIssueOpen}+ actions={<IconButton size="icon-xs" label={t(($) => $.actions.remove_parent_issue)} onClick={() => actions.removeParent()}><Unlink /></IconButton>} />+ {parentIssueOpen && <div className="px-2">+ <div className="flex items-center gap-0.5 rounded-md px-2 hover:bg-accent/50 transition-colors group"><AppLinkhref={paths.issueDetail(parentIssue.id)}- className="flex flex-1 min-w-0 items-center gap-1.5 py-1.5 text-caption"+ className="flex flex-1 min-w-0 items-center gap-1.5 py-2 text-caption"><StatusIconstatus={parentIssue.status}@@ -2975,16 +2959,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr<span className="text-muted-foreground shrink-0">{parentIssue.identifier}</span><span className="truncate group-hover:text-foreground">{parentIssue.title}</span></AppLink>- <TooltipHint label={t(($) => $.actions.remove_parent_issue)}>- <button- type="button"- aria-label={t(($) => $.actions.remove_parent_issue)}- onClick={() => actions.removeParent()}- className="shrink-0 rounded-xs p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"- >- <Unlink className="h-3.5 w-3.5" />- </button>- </TooltipHint>+</div></div>}</div>@@ -3008,10 +2983,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trwhile there are none. */}<DeliverablesSection files={deliverableFiles} onOpenOverview={openOverview} />- {/* Execution log — active runs + collapsed past runs, each carrying its- own token spend, with the issue total on the section header.- Self-contained; owns its own collapse state and WS subscriptions.- Hides itself when there are no runs to show. */}+ {/* Execution summary owns its query, realtime updates and disclosure. */}<ExecutionLogSection issueId={id} identifier={issue.identifier} issueTitle={issue.title} />{/* Details — creator and timestamps. Sits below the execution log@@ -3019,66 +2991,23 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trnever change once the issue exists, while the log above it iswhat people actually come here to check. */}<div>- <button- type="button"- className={`flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors mb-2 hover:bg-accent/70 ${detailsOpen ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => setDetailsOpen(!detailsOpen)}- >- {t(($) => $.detail.section_details)}- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${detailsOpen ? "rotate-90" : ""}`} />- </button>- {detailsOpen && <div className="grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5 pl-2">- <PropRow label={t(($) => $.detail.prop_created_by)}>+ <IssueSidebarSectionHeader title={t(($) => $.detail.section_details)} open={detailsOpen} onOpenChange={setDetailsOpen} />+ {detailsOpen && <IssueSidebarPropertyGrid>+ <PropRow interactive={false} label={t(($) => $.detail.prop_created_by)}><ActorAvatar actorType={issue.creator_type} actorId={issue.creator_id} size="sm" enableHoverCard /><span className="cursor-pointer truncate">{getActorName(issue.creator_type, issue.creator_id)}</span></PropRow>- <PropRow label={t(($) => $.detail.prop_created)}>+ <PropRow interactive={false} label={t(($) => $.detail.prop_created)}><span className="text-muted-foreground">{shortDate(issue.created_at, locale)}</span></PropRow>- <PropRow label={t(($) => $.detail.prop_updated)}>+ <PropRow interactive={false} label={t(($) => $.detail.prop_updated)}><span className="text-muted-foreground">{shortDate(issue.updated_at, locale)}</span></PropRow>- </div>}+ </IssueSidebarPropertyGrid>}</div>- {/* The standalone "Token usage" section that used to sit here is gone:- it showed the same issue totals the execution-log header now carries,- minus the cost and minus any way to tell which run spent them. Its- every field (input / output / cache / run count) lives in the usage- dialog that header opens. The `/api/issues/:id/usage` endpoint it- read stays — the CLI's `issue usage` command still uses it. */}-- {/* Metadata — agent-facing free-form KV bag. The values almost- never mean anything to humans, so the trigger row matches the- sibling section headers (Pull requests / Details / Parent issue)- but clicking opens a dialog with the raw JSON instead of expanding- inline — the payload can be large and pushing the rest of the- sidebar down was noisy. */}- {Object.keys(issue.metadata ?? {}).length > 0 && (- <>- <button- type="button"- className="flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium text-muted-foreground transition-colors hover:bg-accent/70 hover:text-foreground"- onClick={() => setMetadataOpen(true)}- >- {t(($) => $.detail.section_metadata)}- <span className="tabular-nums">- · {Object.keys(issue.metadata ?? {}).length}- </span>- </button>- <Dialog open={metadataOpen} onOpenChange={setMetadataOpen}>- <DialogContent className="max-w-2xl">- <DialogHeader>- <DialogTitle>{t(($) => $.detail.section_metadata)}</DialogTitle>- </DialogHeader>- <pre className="max-h-[60vh] overflow-auto rounded-md bg-muted p-3 font-mono text-caption">- {JSON.stringify(issue.metadata ?? {}, null, 2)}- </pre>- </DialogContent>- </Dialog>- </>- )}- </div>+ <MetadataSection metadata={issue.metadata ?? {}} />+ </IssueSidebarStack>);// Shared row renderer for both timeline render modes (flat / virtualized).@@ -4020,7 +3949,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr<div className="flex flex-1 min-h-0">{detailContent}<Sheet open={mobileSidebarOpen} onOpenChange={setMobileSidebarOpen}>- <SheetContent side="right" showCloseButton={false} className="w-[320px] overflow-y-auto p-4">+ <SheetContent side="right" showCloseButton={false} className="w-[320px] overflow-y-auto [scrollbar-gutter:stable] p-4">{sidebarContent}</SheetContent></Sheet>diff --git a/packages/views/issues/components/issue-duplicates.tsx b/packages/views/issues/components/issue-duplicates.tsxindex c861b0b3cf..bc175f8a71 100644--- a/packages/views/issues/components/issue-duplicates.tsx+++ b/packages/views/issues/components/issue-duplicates.tsx@@ -1,8 +1,10 @@"use client";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";+import { useState } from "react";import { useQuery } from "@tanstack/react-query";-import { ArrowRight, ChevronRight } from "lucide-react";+import { ArrowRight } from "lucide-react";import type { Issue, IssueDuplicateOf } from "@multica/core/types";import { issueStatusCategory } from "@multica/core/issues";import { issueDuplicatesOptions } from "@multica/core/issues/queries";@@ -99,24 +101,14 @@ export function IssueDuplicatesSection({ issueId }: { issueId: string }) {return (<div>- <button- type="button"- className={`flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors mb-2 hover:bg-accent/70 ${open ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => setOpen(!open)}- >- {t(($) => $.duplicates.section_title)}{" "}- <span className="rounded-xs bg-muted px-1 text-micro font-medium tabular-nums text-muted-foreground">- {duplicates.length}- </span>- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`} />- </button>+ <IssueSidebarSectionHeader title={t(($) => $.duplicates.section_title)} open={open} onOpenChange={setOpen} count={duplicates.length} />{open && (- <div className="pl-2">+ <div className="px-2">{duplicates.map((duplicate) => (<AppLinkkey={duplicate.id}href={paths.issueDetail(duplicate.id)}- className="group flex items-center gap-1.5 rounded-md px-2 -mx-2 py-1.5 text-caption hover:bg-accent/50 transition-colors"+ className="group flex items-center gap-1.5 rounded-md px-2 py-2 text-caption hover:bg-accent/50 transition-colors"><ActorAvataractorType={duplicate.creator_type}diff --git a/packages/views/issues/components/issue-runs-dialog.test.tsx b/packages/views/issues/components/issue-runs-dialog.test.tsxindex a06038ad91..4927fd53e7 100644--- a/packages/views/issues/components/issue-runs-dialog.test.tsx+++ b/packages/views/issues/components/issue-runs-dialog.test.tsx@@ -257,6 +257,8 @@ describe("IssueRunsDialog", () => {const plot = plotOf();layOut(plot);+ expect(screen.getByRole("button", { name: "Cost" })).toHaveAttribute("aria-pressed", "true");+ expect(screen.getByRole("button", { name: "Tokens" })).toHaveAttribute("aria-pressed", "false");fireEvent.click(screen.getByRole("button", { name: "Tokens" }));expect(screen.getByText("per run · by token type")).toBeInTheDocument();// In the token view the hover splits the run's tokens by type.diff --git a/packages/views/issues/components/issue-sidebar-section.test.tsx b/packages/views/issues/components/issue-sidebar-section.test.tsxnew file mode 100644index 0000000000..28481bb5b7--- /dev/null+++ b/packages/views/issues/components/issue-sidebar-section.test.tsx@@ -0,0 +1,44 @@+import { useState } from "react";+import { fireEvent, render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";++describe("issue sidebar disclosure", () => {+ it("keeps an empty title static while its add action remains available", () => {+ const toggle = vi.fn();+ const add = vi.fn();+ render(<IssueSidebarSectionHeader title="References" count={0} open onOpenChange={toggle} collapsible={false}+ actions={<button onClick={add}>Add reference</button>} />);+ fireEvent.click(screen.getByText("References"));+ expect(toggle).not.toHaveBeenCalled();+ expect(screen.queryByRole("button", { name: "References" })).not.toBeInTheDocument();+ expect(screen.queryByText("0")).not.toBeInTheDocument();+ expect(screen.getByText("References").previousElementSibling).toHaveAttribute("aria-hidden", "true");+ fireEvent.click(screen.getByRole("button", { name: "Add reference" }));+ expect(add).toHaveBeenCalledOnce();+ });++ it("keeps section actions independent and supports keyboard disclosure", async () => {+ const add = vi.fn();+ function Example() {+ const [open, setOpen] = useState(true);+ return <>+ <IssueSidebarSectionHeader title="References" count={2} open={open} onOpenChange={setOpen}+ actions={<button onClick={add}>Add reference</button>} />+ {open && <p>Linked item</p>}+ </>;+ }+ render(<Example />);+ const disclosure = screen.getByRole("button", { name: "References 2" });+ fireEvent.click(screen.getByRole("button", { name: "Add reference" }));+ expect(add).toHaveBeenCalledOnce();+ expect(disclosure).toHaveAttribute("aria-expanded", "true");+ disclosure.focus();+ await userEvent.keyboard(" ");+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ expect(screen.queryByText("Linked item")).not.toBeInTheDocument();+ await userEvent.keyboard("{Enter}");+ expect(screen.getByText("Linked item")).toBeVisible();+ });+});diff --git a/packages/views/issues/components/issue-sidebar-section.tsx b/packages/views/issues/components/issue-sidebar-section.tsxnew file mode 100644index 0000000000..87e81f05b6--- /dev/null+++ b/packages/views/issues/components/issue-sidebar-section.tsx@@ -0,0 +1,61 @@+"use client";++import type { ReactNode } from "react";+import { ChevronRight } from "lucide-react";+import { Badge } from "@multica/ui/components/ui/badge";+import { Button, buttonVariants } from "@multica/ui/components/ui/button";+import { cn } from "@multica/ui/lib/utils";++/** Shared disclosure header; actions stay outside the disclosure button. */+export function IssueSidebarSectionHeader({+ title, open, onOpenChange, count, actions, status, id, collapsible = true,+}: {+ title: ReactNode;+ open: boolean;+ onOpenChange: (open: boolean) => void;+ collapsible?: boolean;+ count?: number;+ actions?: ReactNode;+ status?: ReactNode;+ id?: string;+}) {+ return (+ <div className="mb-1 flex min-w-0 items-center gap-1">+ {collapsible ? <Button+ id={id}+ type="button"+ variant="ghost"+ size="sm"+ aria-expanded={open}+ onClick={() => onOpenChange(!open)}+ className={cn("min-w-0 flex-1 shrink justify-start text-body font-medium aria-expanded:bg-transparent active:not-aria-[haspopup]:translate-y-0", !open && "text-muted-foreground")}+ >+ <ChevronRight aria-hidden="true" className={cn("!size-3 shrink-0 text-faint-foreground transition-transform motion-reduce:transition-none", open && "rotate-90")} />+ <span className="truncate">{title}</span>+ {count !== undefined && count > 0 && (+ <>+ {" "}+ <Badge variant="secondary" className="min-w-5 rounded-md px-1.5 text-micro tabular-nums text-muted-foreground">{count}</Badge>+ </>+ )}+ </Button> : (+ <div id={id} className={cn(buttonVariants({ variant: "ghost", size: "sm" }), "min-w-0 flex-1 shrink justify-start text-body font-medium hover:bg-transparent dark:hover:bg-transparent")}>+ <span aria-hidden="true" className="size-3 shrink-0" />+ <span className="truncate">{title}</span>+ </div>+ )}+ {status}+ {actions && <div className="flex shrink-0 items-center gap-1">{actions}</div>}+ </div>+ );+}++/** Shared spacing separates rendered sections without adding divider lines. */+export function IssueSidebarStack({ children }: { children: ReactNode }) {+ return <div className="flex flex-col gap-6 [overflow-anchor:none] [&>*]:flow-root">{children}</div>;+}++/** Fits labels to their content while reserving space for values and the hover gutter. */+export function IssueSidebarPropertyGrid({ children }: { children: ReactNode }) {+ return <div className="grid grid-cols-[fit-content(min(44%,11rem))_minmax(0,1fr)] gap-x-2 gap-y-1 px-4">{children}</div>;+}diff --git a/packages/views/issues/components/issue-sidebar-settings-menu.test.tsx b/packages/views/issues/components/issue-sidebar-settings-menu.test.tsxnew file mode 100644index 0000000000..2927a8aaf4--- /dev/null+++ b/packages/views/issues/components/issue-sidebar-settings-menu.test.tsx@@ -0,0 +1,53 @@+import { fireEvent, screen, waitFor } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../../test/i18n";+import { DropdownMenuItem } from "@multica/ui/components/ui/dropdown-menu";+import { IssueSidebarSettingsMenu } from "./issue-sidebar-settings-menu";++const push = vi.hoisted(() => vi.fn());+vi.mock("@multica/core/paths", () => ({ useWorkspacePaths: () => ({ settings: () => "/acme/settings" }) }));+vi.mock("../../navigation", () => ({ useNavigation: () => ({ push }) }));++beforeEach(() => push.mockReset());++describe("IssueSidebarSettingsMenu", () => {+ it.each(["quick-actions", "wakeups", "properties", "plugins", "code"] as const)("opens the workspace %s settings", async (tab) => {+ renderWithI18n(<IssueSidebarSettingsMenu title="Section" label="Section settings" tab={tab} />);+ fireEvent.click(screen.getByRole("button", { name: "Section options" }));+ fireEvent.click(await screen.findByRole("menuitem", { name: "Section settings" }));+ expect(push).toHaveBeenCalledExactlyOnceWith(`/acme/settings?tab=${tab}`);+ });++ it("composes section actions before settings without navigating on action clicks", async () => {+ const action = vi.fn();+ renderWithI18n(+ <IssueSidebarSettingsMenu title="Pull requests" triggerLabel="Pull request automation" label="PR merge settings" tab="code">+ <DropdownMenuItem onClick={action}>Keep status when PRs merge</DropdownMenuItem>+ </IssueSidebarSettingsMenu>,+ );+ fireEvent.click(screen.getByRole("button", { name: "Pull request automation" }));+ const item = await screen.findByRole("menuitem", { name: "Keep status when PRs merge" });+ expect(screen.getAllByRole("menuitem").map((node) => node.textContent)).toEqual(["Keep status when PRs merge", "PR merge settings"]);+ fireEvent.click(item);+ expect(action).toHaveBeenCalledOnce();+ expect(push).not.toHaveBeenCalled();+ });++ it("supports keyboard opening and Escape restores focus without navigating", async () => {+ const user = userEvent.setup();+ renderWithI18n(<IssueSidebarSettingsMenu title="Properties" label="Custom property settings" tab="properties" />);+ const trigger = screen.getByRole("button", { name: "Properties options" });+ trigger.focus();+ await user.keyboard("{Enter}");+ expect(await screen.findByRole("menuitem", { name: "Custom property settings" })).toBeVisible();+ await user.keyboard("{Escape}");+ await waitFor(() => expect(trigger).toHaveFocus());+ expect(push).not.toHaveBeenCalled();+ });++ it("localizes the menu trigger", () => {+ renderWithI18n(<IssueSidebarSettingsMenu title="属性" label="自定义属性设置" tab="properties" />, { locale: "zh-Hans" });+ expect(screen.getByRole("button", { name: "属性选项" })).toBeVisible();+ });+});diff --git a/packages/views/issues/components/issue-sidebar-settings-menu.tsx b/packages/views/issues/components/issue-sidebar-settings-menu.tsxnew file mode 100644index 0000000000..1649e07b31--- /dev/null+++ b/packages/views/issues/components/issue-sidebar-settings-menu.tsx@@ -0,0 +1,36 @@+"use client";++import type { ReactNode } from "react";+import { MoreHorizontal, Settings } from "lucide-react";+import { useWorkspacePaths } from "@multica/core/paths";+import { IconButton } from "@multica/ui/components/common/icon-button";+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@multica/ui/components/ui/dropdown-menu";+import { useNavigation } from "../../navigation";+import { useT } from "../../i18n";++export function IssueSidebarSettingsMenu({ title, label, tab, triggerLabel, children }: {+ title: string;+ label: string;+ tab: "quick-actions" | "wakeups" | "properties" | "plugins" | "code";+ triggerLabel?: string;+ children?: ReactNode;+}) {+ const { t } = useT("issues");+ const paths = useWorkspacePaths();+ const navigation = useNavigation();++ return (+ <DropdownMenu>+ <DropdownMenuTrigger render={+ <IconButton size="icon-xs" label={triggerLabel ?? t(($) => $.sidebar_settings.menu, { section: title })}><MoreHorizontal /></IconButton>+ } />+ <DropdownMenuContent align="end" className="w-max max-w-(--available-width)">+ {children}+ <DropdownMenuItem onClick={() => navigation.push(`${paths.settings()}?tab=${tab}`)}>+ <Settings />+ {label}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/packages/views/issues/components/metadata-section.test.tsx b/packages/views/issues/components/metadata-section.test.tsxnew file mode 100644index 0000000000..202de707c2--- /dev/null+++ b/packages/views/issues/components/metadata-section.test.tsx@@ -0,0 +1,64 @@+import { fireEvent, screen, waitFor, within } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { copyText } from "@multica/ui/lib/clipboard";+import { toast } from "sonner";+import { renderWithI18n } from "../../test/i18n";+import { MetadataSection } from "./metadata-section";++vi.mock("@multica/ui/lib/clipboard", () => ({ copyText: vi.fn() }));+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));+const metadata = { pipeline_status: "waiting_review", pr_number: 61, passed: false, note: "长文本\n第二行" };++beforeEach(() => {+ vi.clearAllMocks();+ vi.mocked(copyText).mockResolvedValue(true);+});++describe("MetadataSection", () => {+ it("hides empty metadata", () => {+ const { container } = renderWithI18n(<MetadataSection metadata={{}} />);+ expect(container).toBeEmptyDOMElement();+ });+ it("uses the shared count and expands values inline without a dialog", () => {+ renderWithI18n(<MetadataSection metadata={metadata} />);+ const header = screen.getByRole("button", { name: "Metadata 4" });+ expect(header).toHaveAttribute("aria-expanded", "false");+ expect(within(header).getByText("4")).toHaveAttribute("data-slot", "badge");+ expect(screen.queryByText("pipeline_status")).not.toBeInTheDocument();+ fireEvent.click(header);+ expect(screen.getByText("waiting_review")).toBeVisible();+ expect(screen.getByText("61")).toBeVisible();+ expect(screen.getByText("false")).toBeVisible();+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ fireEvent.click(header);+ expect(screen.queryByText("waiting_review")).not.toBeInTheDocument();+ });+ it("copies complete formatted JSON even while collapsed and reports failure", async () => {+ renderWithI18n(<MetadataSection metadata={metadata} />);+ fireEvent.click(screen.getByRole("button", { name: "Copy metadata" }));+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith("Copied"));+ expect(copyText).toHaveBeenCalledWith(JSON.stringify(metadata, null, 2));+ vi.mocked(copyText).mockResolvedValue(false);+ fireEvent.click(screen.getByRole("button", { name: "Copy metadata" }));+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith("Failed to copy metadata"));+ expect(toast.success).toHaveBeenCalledTimes(1);+ });+ it("opens the enlarged view, copies, resizes and returns focus after Escape", async () => {+ const user = userEvent.setup();+ renderWithI18n(<MetadataSection metadata={metadata} />);+ const trigger = screen.getByRole("button", { name: "View metadata" });+ await user.click(trigger);+ const dialog = await screen.findByRole("dialog", { name: "Metadata" });+ expect(within(dialog).getByText("waiting_review")).toBeVisible();+ await user.click(within(dialog).getByRole("button", { name: "Copy metadata" }));+ expect(copyText).toHaveBeenCalledWith(JSON.stringify(metadata, null, 2));+ await user.click(within(dialog).getByRole("button", { name: "Expand dialog" }));+ expect(within(dialog).getByRole("button", { name: "Restore dialog size" })).toBeVisible();+ await user.keyboard("{Escape}");+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());+ expect(trigger).toHaveFocus();+ await user.click(trigger);+ expect(await screen.findByRole("button", { name: "Expand dialog" })).toBeVisible();+ });+});diff --git a/packages/views/issues/components/metadata-section.tsx b/packages/views/issues/components/metadata-section.tsxnew file mode 100644index 0000000000..849951f743--- /dev/null+++ b/packages/views/issues/components/metadata-section.tsx@@ -0,0 +1,77 @@+"use client";++import { useState } from "react";+import { Copy, Maximize2, Minimize2, X } from "lucide-react";+import { toast } from "sonner";+import type { IssueMetadata } from "@multica/core/types";+import { IconButton } from "@multica/ui/components/common/icon-button";+import { Dialog, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@multica/ui/components/ui/dialog";+import { copyText } from "@multica/ui/lib/clipboard";+import { cn } from "@multica/ui/lib/utils";+import { useT } from "../../i18n";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";++export function MetadataSection({ metadata }: { metadata: IssueMetadata }) {+ const { t } = useT("issues");+ const [open, setOpen] = useState(false);+ const [expanded, setExpanded] = useState(false);+ const count = Object.keys(metadata).length;+ if (count === 0) return null;++ const copy = async () => {+ const ok = await copyText(JSON.stringify(metadata, null, 2));+ if (ok) toast.success(t(($) => $.comment.copied_toast));+ else toast.error(t(($) => $.detail.metadata_copy_failed));+ };+ const copyButton = () => (+ <IconButton size="icon-xs" label={t(($) => $.detail.metadata_copy)} onClick={() => void copy()}><Copy /></IconButton>+ );++ return (+ <section>+ <Dialog onOpenChange={(next) => { if (!next) setExpanded(false); }}>+ <IssueSidebarSectionHeader title={t(($) => $.detail.section_metadata)} count={count} open={open} onOpenChange={setOpen}+ actions={<>+ {copyButton()}+ <DialogTrigger render={<IconButton size="icon-xs" label={t(($) => $.detail.metadata_view)}><Maximize2 /></IconButton>} />+ </>} />+ {open && <div className="px-2">+ <div className="max-h-64 overflow-auto overscroll-contain px-2" role="region" aria-label={t(($) => $.detail.section_metadata)} tabIndex={0}>+ <MetadataEntries metadata={metadata} />+ </div>+ </div>}+ <DialogContent showCloseButton={false} className={cn("flex flex-col overflow-hidden sm:max-w-3xl", expanded && "h-[calc(100dvh-2rem)] sm:max-w-[calc(100%-2rem)]")}>+ <DialogHeader className="shrink-0">+ <div className="flex min-w-0 items-center justify-between gap-2">+ <DialogTitle>{t(($) => $.detail.section_metadata)}</DialogTitle>+ <div className="flex shrink-0 items-center gap-1">+ {copyButton()}+ <IconButton size="icon-xs" label={expanded ? t(($) => $.detail.metadata_restore) : t(($) => $.detail.metadata_expand)} onClick={() => setExpanded(!expanded)}>+ {expanded ? <Minimize2 /> : <Maximize2 />}+ </IconButton>+ <DialogClose render={<IconButton size="icon-xs" label={t(($) => $.detail.metadata_close)}><X /></IconButton>} />+ </div>+ </div>+ <DialogDescription>{t(($) => $.detail.metadata_description)}</DialogDescription>+ </DialogHeader>+ <div className="min-h-0 overflow-auto overscroll-contain rounded-lg border border-border px-3" role="region" aria-label={t(($) => $.detail.section_metadata)} tabIndex={0}>+ <MetadataEntries metadata={metadata} wide />+ </div>+ </DialogContent>+ </Dialog>+ </section>+ );+}++function MetadataEntries({ metadata, wide = false }: { metadata: IssueMetadata; wide?: boolean }) {+ return <dl>+ {Object.entries(metadata).map(([key, value]) => (+ <div key={key} className={cn("grid min-w-0 gap-1 py-2", wide && "sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)] sm:gap-4")}>+ <dt className="min-w-0 break-words font-mono text-micro text-muted-foreground [overflow-wrap:anywhere]">{key}</dt>+ <dd className="min-w-0 whitespace-pre-wrap break-words text-caption [overflow-wrap:anywhere]">+ {typeof value === "string" ? value : <span className="font-mono tabular-nums">{JSON.stringify(value)}</span>}+ </dd>+ </div>+ ))}+ </dl>;+}diff --git a/packages/views/issues/components/pickers/label-picker.test.tsx b/packages/views/issues/components/pickers/label-picker.test.tsxnew file mode 100644index 0000000000..b0770f342f--- /dev/null+++ b/packages/views/issues/components/pickers/label-picker.test.tsx@@ -0,0 +1,52 @@+import { screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { afterEach, describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../../../test/i18n";+import { LabelPicker } from "./label-picker";++vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));+vi.mock("@multica/core/paths", () => ({ useWorkspacePaths: () => ({ settings: () => "/settings" }) }));+vi.mock("../../../navigation", () => ({ useNavigation: () => ({ push: vi.fn() }) }));+vi.mock("@tanstack/react-query", () => ({ useQuery: () => ({ data: [{ id: "bug", name: "Bug", color: "#ff0000" }] }) }));+vi.mock("@multica/core/labels", () => ({+ labelListOptions: () => ({}),+ issueLabelsOptions: () => ({}),+ useAttachLabel: () => ({ mutate: vi.fn() }),+ useDetachLabel: () => ({ mutate: vi.fn() }),+ useCreateLabel: () => ({ mutate: vi.fn() }),+}));+afterEach(() => vi.restoreAllMocks());++describe("LabelPicker trigger semantics", () => {+ it("uses non-native semantics for the compound trigger and opens from the keyboard without warnings", async () => {+ const error = vi.spyOn(console, "error");+ const user = userEvent.setup();+ renderWithI18n(<LabelPicker selectedIds={["bug"]} onSelectedIdsChange={() => {}} />);+ const trigger = screen.getByRole("button", { name: /^Bug/ }).closest('[data-slot="popover-trigger"]')!;+ expect(trigger.tagName).toBe("DIV");+ expect(trigger).not.toHaveAttribute("type");+ (trigger as HTMLElement).focus();+ await user.keyboard("{Enter}");+ expect(screen.getByRole("dialog")).toBeVisible();+ expect(error).not.toHaveBeenCalled();+ });+ it("keeps chip removal independent from opening the picker", async () => {+ const change = vi.fn();+ renderWithI18n(<LabelPicker selectedIds={["bug"]} onSelectedIdsChange={change} />);+ screen.getByRole("button", { name: "Remove label Bug" }).focus();+ await userEvent.keyboard("{Enter}");+ expect(change).toHaveBeenCalledWith([]);+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ });+ it("retains native buttons for empty and custom triggers across selection changes", () => {+ const error = vi.spyOn(console, "error");+ const { rerender } = renderWithI18n(<LabelPicker selectedIds={[]} />);+ expect(document.querySelector('[data-slot="popover-trigger"]')?.tagName).toBe("BUTTON");+ rerender(<LabelPicker selectedIds={["bug"]} />);+ expect(document.querySelector('[data-slot="popover-trigger"]')?.tagName).toBe("DIV");+ rerender(<LabelPicker selectedIds={["bug"]} triggerRender={<button type="button" />} />);+ expect(document.querySelector('[data-slot="popover-trigger"]')?.tagName).toBe("BUTTON");+ expect(screen.queryByRole("button", { name: "Remove label Bug" })).not.toBeInTheDocument();+ expect(error).not.toHaveBeenCalled();+ });+});diff --git a/packages/views/issues/components/pickers/label-picker.tsx b/packages/views/issues/components/pickers/label-picker.tsxindex f7c3d519c6..18201e1216 100644--- a/packages/views/issues/components/pickers/label-picker.tsx+++ b/packages/views/issues/components/pickers/label-picker.tsx@@ -229,6 +229,7 @@ export function LabelPicker({searchPlaceholder={t(($) => $.pickers.label.search_placeholder)}onSearchChange={setFilter}triggerRender={resolvedTriggerRender}+ nativeButton={!!triggerRender || !hasLabels}tooltip={tooltip}trigger={hasLabels ? (diff --git a/packages/views/issues/components/pickers/property-picker.tsx b/packages/views/issues/components/pickers/property-picker.tsxindex fe4521c3ac..3bad8cf131 100644--- a/packages/views/issues/components/pickers/property-picker.tsx+++ b/packages/views/issues/components/pickers/property-picker.tsx@@ -42,6 +42,7 @@ export function PropertyPicker({onOpenChange,trigger,triggerRender,+ nativeButton = true,width = "w-48",align = "end",side = "bottom",@@ -57,6 +58,8 @@ export function PropertyPicker({onOpenChange: (v: boolean) => void;trigger: React.ReactNode;triggerRender?: React.ReactElement;+ /** False when a compound trigger renders a non-button element. */+ nativeButton?: boolean;width?: string;align?: "start" | "center" | "end";side?: React.ComponentProps<typeof PopoverContent>["side"];@@ -180,6 +183,7 @@ export function PropertyPicker({const popoverTrigger = (<PopoverTrigger+ nativeButton={nativeButton}className={triggerRender ? undefined : PICKER_TRIGGER_CLASS}render={triggerRender}>diff --git a/packages/views/issues/components/pull-request-list.tsx b/packages/views/issues/components/pull-request-list.tsxindex 8fe1699c47..4d5c910f23 100644--- a/packages/views/issues/components/pull-request-list.tsx+++ b/packages/views/issues/components/pull-request-list.tsx@@ -80,7 +80,7 @@ export function PullRequestList({}) {const { t } = useT("issues");const [expanded, setExpanded] = useState(false);- const { data, isLoading } = useQuery(issuePullRequestsOptions(issueId));+ const { data, isLoading, isError, refetch } = useQuery(issuePullRequestsOptions(issueId));const prs = data?.pull_requests ?? [];// Older backends send no auto-complete block and have no link/unlink// endpoints, so the row actions stay hidden with it.@@ -90,12 +90,13 @@ export function PullRequestList({if (isLoading) {return <p className="text-caption text-muted-foreground px-2">{t(($) => $.detail.pull_requests_loading)}</p>;}+ if (isError) {+ return <button type="button" className="flex min-h-8 w-full items-center rounded-md px-2 py-1.5 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring" onClick={() => void refetch()}>+ {t(($) => $.detail.section_load_failed_retry)}+ </button>;+ }if (prs.length === 0) {- return (- <p className="px-2 text-caption text-muted-foreground">- {t(($) => $.detail.pull_requests_empty_title)}- </p>- );+ return null;}// Render rule:@@ -124,7 +125,7 @@ export function PullRequestList({<buttontype="button"onClick={() => setExpanded((v) => !v)}- className="block w-[calc(100%+1rem)] -mx-2 rounded-md px-2 py-1.5 text-left text-micro text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors"+ className="block w-full rounded-md px-2 py-2 text-left text-caption text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors">{expanded? t(($) => $.detail.pull_request_card_show_less)@@ -215,13 +216,13 @@ function PullRequestRowMenu({ pr, actions }: { pr: GitHubPullRequest; actions: Rvariant="ghost"size="icon-xs"label={t(($) => $.pr_automation.row_menu)}- className="absolute top-0.5 right-0 opacity-0 group-hover/pr:opacity-100 group-focus-within/pr:opacity-100 data-popup-open:opacity-100 [@media(pointer:coarse)]:opacity-100"+ className="absolute top-0.5 right-0 opacity-0 group-hover/pr:opacity-100 group-has-[:focus-visible]/pr:opacity-100 data-popup-open:opacity-100 [@media(pointer:coarse)]:opacity-100"><MoreHorizontal /></IconButton>}/>- <DropdownMenuContent align="end" className="w-56">+ <DropdownMenuContent align="end" className="w-max max-w-(--available-width)"><DropdownMenuGroup><DropdownMenuLabel className="font-normal">{linkSourceLabel(pr, actions.identifier, t)}@@ -279,9 +280,9 @@ function AutoCompleteLine({const withTarget = (sentence: string) => {const [before, after = ""] = sentence.split(STATUS_SLOT);return (- <>+ <span>{before}- <span className="inline-flex items-center gap-1 align-[-2px] font-medium text-foreground">+ <span className="inline-flex items-center gap-1 whitespace-nowrap align-middle font-medium text-foreground"><StatusIconstatus={target}category={catalog.categoryOf(target)}@@ -292,7 +293,7 @@ function AutoCompleteLine({{statusLabel(target)}</span>{after}- </>+ </span>);};@@ -339,7 +340,7 @@ function AutoCompleteLine({return (<pdata-testid="pr-auto-complete-line"- className="mt-1 flex items-start gap-1.5 border-t border-border pt-2 text-caption text-muted-foreground [&>svg]:mt-0.5 [&>svg]:size-3.5 [&>svg]:shrink-0"+ className="mx-2 mt-1 flex items-start gap-1.5 border-t border-border py-2 text-caption text-muted-foreground [&>svg]:mt-px [&>svg]:size-3.5 [&>svg]:shrink-0">{icon}<span className="min-w-0">{body}</span>@@ -431,7 +432,7 @@ function PullRequestRow({// The row link and its menu are siblings: a button inside an anchor is// invalid HTML, and the menu must not open the PR.return (- <div className="group/pr relative -mx-2 rounded-md transition-colors hover:bg-accent/50">+ <div className="group/pr relative rounded-md transition-colors hover:bg-accent/50"><Tooltip><TooltipTriggerrender={@@ -440,7 +441,7 @@ function PullRequestRow({href={pr.html_url}target="_blank"rel="noreferrer noopener"- className="flex items-start gap-2 rounded-md px-2 py-1.5"+ className="flex items-start gap-2 rounded-md px-2 py-2"/>}>diff --git a/packages/views/issues/components/pull-requests-section.test.tsx b/packages/views/issues/components/pull-requests-section.test.tsxindex fbdca12a22..f0bd85c386 100644--- a/packages/views/issues/components/pull-requests-section.test.tsx+++ b/packages/views/issues/components/pull-requests-section.test.tsx@@ -9,6 +9,7 @@ import enIssues from "../../locales/en/issues.json";const TEST_RESOURCES = { en: { common: enCommon, issues: enIssues } };+let queryFails = false;let mockAutoComplete: PRAutoComplete | null = null;vi.mock("@multica/core/github/queries", async () => {const actual = await vi.importActual<typeof import("@multica/core/github/queries")>(@@ -18,7 +19,10 @@ vi.mock("@multica/core/github/queries", async () => {...actual,issuePullRequestsOptions: (issueId: string) => ({queryKey: ["github", "pull-requests", issueId],- queryFn: async () => ({ pull_requests: [], auto_complete: mockAutoComplete }),+ queryFn: async () => {+ if (queryFails) throw new Error("Offline");+ return { pull_requests: [], auto_complete: mockAutoComplete };+ },enabled: !!issueId,}),};@@ -46,8 +50,11 @@ vi.mock("@multica/core/paths", async (importOriginal) => ({import { PullRequestsSection } from "./pull-requests-section";-function renderSection() {+function renderSection(cachedDecision?: PRAutoComplete) {const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ if (cachedDecision) {+ qc.setQueryData(["github", "pull-requests", "issue-1"], { pull_requests: [], auto_complete: cachedDecision });+ }return render(<QueryClientProvider client={qc}><I18nProvider resources={TEST_RESOURCES} locale="en">@@ -66,6 +73,7 @@ const decision: PRAutoComplete = {describe("PullRequestsSection (MUL-7429)", () => {beforeEach(() => {+ queryFails = false;mockAutoComplete = decision;mockWorkspaceSettings = {};apiMock.linkIssuePullRequest.mockReset();@@ -73,6 +81,27 @@ describe("PullRequestsSection (MUL-7429)", () => {navigatePush.mockReset();});+ it("keeps the empty title static and retains linking without redundant copy", async () => {+ renderSection();+ expect(await screen.findByRole("button", { name: "Link pull request" })).toBeVisible();+ expect(screen.queryByRole("button", { name: "Pull requests" })).not.toBeInTheDocument();+ expect(screen.queryByText(enIssues.detail.pull_requests_empty_title)).not.toBeInTheDocument();+ });++ it("keeps a retry entry when loading fails with no cached PRs", async () => {+ queryFails = true;+ renderSection();+ expect(await screen.findByRole("button", { name: "Could not load. Retry" })).toBeVisible();+ expect(screen.queryByRole("button", { name: "Link pull request" })).not.toBeInTheDocument();+ });++ it("retains linking after a failed refresh when cached data confirms backend support", async () => {+ queryFails = true;+ renderSection(decision);+ expect(await screen.findByRole("button", { name: "Could not load. Retry" })).toBeVisible();+ expect(screen.getByRole("button", { name: "Link pull request" })).toBeVisible();+ });+it("links a pasted PR URL", async () => {apiMock.linkIssuePullRequest.mockResolvedValue({ pull_requests: [], auto_complete: decision });renderSection();@@ -149,7 +178,7 @@ describe("PullRequestsSection (MUL-7429)", () => {it("hides the actions on a backend without auto-complete", async () => {mockAutoComplete = null;renderSection();- await screen.findByText("No linked pull requests.");+ await waitFor(() => expect(screen.queryByText("Pull requests")).not.toBeInTheDocument());expect(screen.queryByRole("button", { name: "Link pull request" })).toBeNull();expect(screen.queryByRole("button", { name: "Pull request automation" })).toBeNull();});diff --git a/packages/views/issues/components/pull-requests-section.tsx b/packages/views/issues/components/pull-requests-section.tsxindex f41b7fb6fc..66dcc3b887 100644--- a/packages/views/issues/components/pull-requests-section.tsx+++ b/packages/views/issues/components/pull-requests-section.tsx@@ -1,9 +1,12 @@"use client";+import { IssueSidebarSettingsMenu } from "./issue-sidebar-settings-menu";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";+import { useState } from "react";import { useQuery } from "@tanstack/react-query";import { toast } from "sonner";-import { ChevronRight, CircleSlash, MoreHorizontal, Plus, RotateCcw, Settings } from "lucide-react";+import { CircleSlash, Plus, RotateCcw } from "lucide-react";import { ApiError } from "@multica/core/api";import {issuePullRequestsOptions,@@ -11,19 +14,14 @@ import {useLinkIssuePullRequest,useSetIssuePRAutoComplete,} from "@multica/core/github";-import { useWorkspacePaths } from "@multica/core/paths";import { Button } from "@multica/ui/components/ui/button";import { IconButton } from "@multica/ui/components/common/icon-button";import {- DropdownMenu,- DropdownMenuContent,DropdownMenuItem,DropdownMenuSeparator,- DropdownMenuTrigger,} from "@multica/ui/components/ui/dropdown-menu";import { Input } from "@multica/ui/components/ui/input";import { Popover, PopoverContent, PopoverTrigger } from "@multica/ui/components/ui/popover";-import { useNavigation } from "../../navigation";import { useT } from "../../i18n";import { PullRequestList } from "./pull-request-list";@@ -45,43 +43,25 @@ export function PullRequestsSection({onOpenChange: (open: boolean) => void;}) {const { t } = useT("issues");- const { data } = useQuery(issuePullRequestsOptions(issueId));+ const { data, isLoading, isError } = useQuery(issuePullRequestsOptions(issueId));// Older backends have no link / auto-complete endpoints; keep the header// actions hidden until the server says it supports them.const supported = !!data?.auto_complete;const count = data?.pull_requests.length ?? 0;+ if (!isLoading && !isError && count === 0 && !supported) return null;+return (<div>- {/* Label and actions are siblings, not a button wrapping buttons. */}- <div className="mb-2 flex w-full items-center gap-0.5">- <button- type="button"- aria-expanded={open}- className={`flex min-w-0 flex-1 items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors hover:bg-accent/70 ${open ? "" : "text-muted-foreground hover:text-foreground"}`}- onClick={() => onOpenChange(!open)}- >- <span className="truncate">{t(($) => $.detail.section_pull_requests)}</span>- {count > 0 ? (- <span className="shrink-0 rounded-xs bg-muted px-1 text-micro font-medium tabular-nums text-muted-foreground">- {count}- </span>- ) : null}- <ChevronRight className={`!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform ${open ? "rotate-90" : ""}`} />- </button>- {supported ? (- <>- <LinkPullRequestPopover issueId={issueId} identifier={identifier} onLinked={() => onOpenChange(true)} />- <AutoCompleteMenu- issueId={issueId}- disabled={data?.auto_complete?.issue_disabled ?? false}- workspaceEnabled={data?.auto_complete?.workspace_enabled ?? true}- />- </>- ) : null}- </div>- {open && (- <div className="pl-2">+ <IssueSidebarSectionHeader+ title={t(($) => $.detail.section_pull_requests)} open={open} onOpenChange={onOpenChange} count={count} collapsible={count > 0 || isLoading || isError}+ actions={supported ? <>+ <LinkPullRequestPopover issueId={issueId} identifier={identifier} onLinked={() => onOpenChange(true)} />+ <AutoCompleteMenu issueId={issueId} disabled={data?.auto_complete?.issue_disabled ?? false} workspaceEnabled={data?.auto_complete?.workspace_enabled ?? true} />+ </> : undefined}+ />+ {open && (count > 0 || isLoading || isError) && (+ <div className="px-2"><PullRequestList issueId={issueId} identifier={identifier} /></div>)}@@ -203,42 +183,32 @@ function AutoCompleteMenu({workspaceEnabled: boolean;}) {const { t } = useT("issues");- const paths = useWorkspacePaths();- const navigation = useNavigation();const setAutoComplete = useSetIssuePRAutoComplete(issueId);return (- <DropdownMenu>- <DropdownMenuTrigger- render={- <IconButton variant="ghost" size="icon-xs" label={t(($) => $.pr_automation.section_menu)}>- <MoreHorizontal />- </IconButton>- }- />- <DropdownMenuContent align="end" className="w-60">- {/* When the workspace leaves status alone, the issue switch changes nothing. */}- {workspaceEnabled ? (- <>- <DropdownMenuItem- disabled={setAutoComplete.isPending}- onClick={() =>- setAutoComplete.mutate(!disabled, {- onError: () => toast.error(t(($) => $.pr_automation.update_failed)),- })- }- >- {disabled ? <RotateCcw /> : <CircleSlash />}- {disabled ? t(($) => $.pr_automation.enable) : t(($) => $.pr_automation.disable)}- </DropdownMenuItem>- <DropdownMenuSeparator />- </>- ) : null}- <DropdownMenuItem onClick={() => navigation.push(`${paths.settings()}?tab=code`)}>- <Settings />- {t(($) => $.pr_automation.settings)}- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ <IssueSidebarSettingsMenu+ title={t(($) => $.detail.section_pull_requests)}+ triggerLabel={t(($) => $.pr_automation.section_menu)}+ label={t(($) => $.pr_automation.settings)}+ tab="code"+ >+ {/* When the workspace leaves status alone, the issue switch changes nothing. */}+ {workspaceEnabled ? (+ <>+ <DropdownMenuItem+ disabled={setAutoComplete.isPending}+ onClick={() =>+ setAutoComplete.mutate(!disabled, {+ onError: () => toast.error(t(($) => $.pr_automation.update_failed)),+ })+ }+ >+ {disabled ? <RotateCcw /> : <CircleSlash />}+ {disabled ? t(($) => $.pr_automation.enable) : t(($) => $.pr_automation.disable)}+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ </>+ ) : null}+ </IssueSidebarSettingsMenu>);}diff --git a/packages/views/issues/components/quick-actions-section.test.tsx b/packages/views/issues/components/quick-actions-section.test.tsxindex e277c957ed..3ae6d7da76 100644--- a/packages/views/issues/components/quick-actions-section.test.tsx+++ b/packages/views/issues/components/quick-actions-section.test.tsx@@ -1,5 +1,5 @@import { describe, expect, it, vi, beforeEach } from "vitest";-import { fireEvent, screen, waitFor } from "@testing-library/react";+import { fireEvent, screen, waitFor, within } from "@testing-library/react";import type { QuickAction } from "@multica/core/types";import { renderWithI18n } from "../../test/i18n";import { QuickActionsSection } from "./quick-actions-section";@@ -18,13 +18,20 @@ import { QuickActionsSection } from "./quick-actions-section";const runMock = vi.fn();let listData: QuickAction[] = [];+let loading = false;+let queryError = false;+let workspaceId = "ws-1";+const refetch = vi.fn();vi.mock("@tanstack/react-query", () => ({- useQuery: () => ({ data: listData, isLoading: false }),+ useQuery: () => ({ data: listData, isLoading: loading, isError: queryError, refetch }),}));+const settingsPush = vi.hoisted(() => vi.fn());+vi.mock("../../navigation", () => ({ useNavigation: () => ({ push: settingsPush }) }));vi.mock("@multica/core/paths", () => ({- useCurrentWorkspace: () => ({ id: "ws-1" }),+ useWorkspacePaths: () => ({ settings: () => "/acme/settings" }),+ useCurrentWorkspace: () => workspaceId ? ({ id: workspaceId }) : null,}));vi.mock("@multica/core/quick-actions", () => ({@@ -85,21 +92,62 @@ function outcome(status: string) {describe("QuickActionsSection", () => {beforeEach(() => {runMock.mockReset();+ loading = false;+ queryError = false;+ workspaceId = "ws-1";+ refetch.mockReset();toastCalls.length = 0;reasonCode = undefined;listData = [action()];});- it("renders nothing when the workspace has no actions", () => {+ it("hides during loading and outside a workspace", () => {+ loading = true;+ const view = renderWithI18n(<QuickActionsSection issueId="i-1" />);+ expect(screen.queryByRole("button", { name: "New quick action" })).not.toBeInTheDocument();+ loading = false;+ workspaceId = "";+ view.rerender(<QuickActionsSection issueId="i-1" />);+ expect(screen.queryByRole("button", { name: "New quick action" })).not.toBeInTheDocument();+ });++ it("retries a failed catalog query and removes recovery after success", () => {listData = [];- const { container } = renderWithI18n(<QuickActionsSection issueId="i-1" />);- expect(container).toBeEmptyDOMElement();+ queryError = true;+ const view = renderWithI18n(<QuickActionsSection issueId="i-1" />);+ fireEvent.click(screen.getByRole("button", { name: "Could not load. Retry" }));+ expect(refetch).toHaveBeenCalledOnce();+ expect(screen.getByRole("button", { name: "New quick action" })).toBeVisible();+ queryError = false;+ listData = [action()];+ view.rerender(<QuickActionsSection issueId="i-1" />);+ expect(screen.queryByRole("button", { name: "Could not load. Retry" })).not.toBeInTheDocument();+ expect(screen.getByText("Code Review")).toBeVisible();+ });++ it("keeps management available while folded and opens the action catalog", async () => {+ renderWithI18n(<QuickActionsSection issueId="i-1" />);+ const disclosure = screen.getByRole("button", { name: "Quick Actions 1" });+ fireEvent.click(disclosure);+ fireEvent.click(screen.getByRole("button", { name: "Quick Actions options" }));+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ fireEvent.click(await screen.findByRole("menuitem", { name: "Quick action settings" }));+ expect(settingsPush).toHaveBeenCalledWith("/acme/settings?tab=quick-actions");+ });++ it("offers creation before the workspace has any actions", () => {+ listData = [];+ renderWithI18n(<QuickActionsSection issueId="i-1" />);+ expect(screen.getByRole("button", { name: "New quick action" })).toBeVisible();+ expect(screen.queryByRole("button", { name: "Quick Actions" })).not.toBeInTheDocument();+ expect(screen.getByText("Quick Actions")).toBeVisible();});it("hides archived actions even if the server returned them", () => {listData = [action({ status: "archived" })];- const { container } = renderWithI18n(<QuickActionsSection issueId="i-1" />);- expect(container).toBeEmptyDOMElement();+ renderWithI18n(<QuickActionsSection issueId="i-1" />);+ expect(screen.getByRole("button", { name: "New quick action" })).toBeVisible();+ expect(screen.queryByText("Code Review")).not.toBeInTheDocument();});it("runs immediately on click when the action takes no input", async () => {@@ -187,7 +235,7 @@ describe("QuickActionsSection", () => {expect(screen.queryByRole("textbox")).not.toBeInTheDocument();});- it("collapses everything past the sidebar limit behind More", () => {+ it("shows more actions from a text row below the list instead of a header icon", () => {listData = [action({ id: "a", name: "One" }),action({ id: "b", name: "Two" }),@@ -195,13 +243,25 @@ describe("QuickActionsSection", () => {action({ id: "d", name: "Four" }),action({ id: "e", name: "Five" }),action({ id: "f", name: "Six" }),+ action({ id: "archived", name: "Archived", status: "archived" }),];renderWithI18n(<QuickActionsSection issueId="i-1" />);+ expect(screen.getByRole("button", { name: /Quick actions 6/i })).toBeVisible();+ expect(screen.queryByText("Archived")).not.toBeInTheDocument();expect(screen.getByText("Five")).toBeInTheDocument();expect(screen.queryByText("Six")).not.toBeInTheDocument();- fireEvent.click(screen.getByText(/Show 1 more/i));+ const disclosure = screen.getByRole("button", { name: /Quick actions 6/i });+ const more = screen.getByRole("button", { name: "Show 1 more" });+ expect(more).toHaveTextContent("Show 1 more");+ expect(within(disclosure.parentElement!).queryByRole("button", { name: "Show 1 more" })).not.toBeInTheDocument();+ expect(more.compareDocumentPosition(screen.getByText("Five")) & Node.DOCUMENT_POSITION_PRECEDING).toBeTruthy();+ fireEvent.click(more);expect(screen.getByText("Six")).toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Show 1 more" })).not.toBeInTheDocument();+ fireEvent.click(disclosure);+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ expect(screen.getByRole("button", { name: /Quick actions 6/i })).toBeVisible();});});diff --git a/packages/views/issues/components/quick-actions-section.tsx b/packages/views/issues/components/quick-actions-section.tsxindex f3d64a60ea..a10b60a1d9 100644--- a/packages/views/issues/components/quick-actions-section.tsx+++ b/packages/views/issues/components/quick-actions-section.tsx@@ -2,7 +2,8 @@import { useMemo, useState } from "react";import { useQuery } from "@tanstack/react-query";-import { ChevronRight, Loader2, Zap } from "lucide-react";+import { Loader2, Plus, Zap } from "lucide-react";+import { IconButton } from "@multica/ui/components/common/icon-button";import { toast } from "sonner";import { dispatchReasonCode } from "@multica/core/api";import { useCurrentWorkspace } from "@multica/core/paths";@@ -21,6 +22,9 @@ import {import { Tooltip, TooltipContent, TooltipTrigger } from "@multica/ui/components/ui/tooltip";import { cn } from "@multica/ui/lib/utils";import { ActorAvatar } from "../../common/actor-avatar";+import { IssueSidebarSettingsMenu } from "./issue-sidebar-settings-menu";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";+import { CreateQuickActionDialog } from "../../quick-actions/components/quick-action-dialog";import { useT } from "../../i18n";// Quick Actions sidebar section (MUL-5465).@@ -44,6 +48,8 @@ import { useT } from "../../i18n";export function QuickActionsSection({ issueId }: { issueId: string }) {const { t } = useT("issues");+ const { t: tSettings } = useT("settings");+ const [creating, setCreating] = useState(false);// Nullable read, not useWorkspaceId(): this section is an enhancement on the// sidebar and must degrade to "not rendered" outside a workspace route// rather than throwing and taking the whole issue detail down with it.@@ -52,39 +58,30 @@ export function QuickActionsSection({ issueId }: { issueId: string }) {const [showAll, setShowAll] = useState(false);const [blocked, setBlocked] = useState<QuickAction | null>(null);- const { data = [], isLoading } = useQuery({+ const { data = [], isLoading, isError, refetch } = useQuery({...quickActionListOptions(wsId),enabled: wsId !== "",});const actions = useMemo(() => data.filter((a) => a.status === "active"), [data]);- // Nothing configured renders nothing at all: an empty section header in the- // sidebar is pure noise.- if (isLoading || actions.length === 0) return null;+ // Keep the creation entry available even before the first action exists.+ if (!wsId || isLoading) return null;const visible = showAll ? actions : actions.slice(0, QUICK_ACTION_SIDEBAR_LIMIT);const hiddenCount = actions.length - visible.length;return (<div>- <button- type="button"- className={cn(- "mb-2 flex w-full items-center gap-1 rounded-md px-2 py-1 text-caption font-medium transition-colors hover:bg-accent/70",- !open && "text-muted-foreground hover:text-foreground",- )}- onClick={() => setOpen(!open)}- >- {t(($) => $.detail.section_quick_actions)}- <ChevronRight- className={cn(- "!size-3 shrink-0 stroke-[2.5] text-muted-foreground transition-transform",- open && "rotate-90",- )}- />- </button>- {open ? (- <div className="space-y-0.5 pl-2">+ <IssueSidebarSectionHeader title={t(($) => $.detail.section_quick_actions)} count={actions.length} collapsible={actions.length > 0 || isError === true} open={open} onOpenChange={setOpen}+ actions={<>+ <IconButton size="icon-xs" label={tSettings(($) => $.quick_actions.create_title)} onClick={() => setCreating(true)}><Plus /></IconButton>+ <IssueSidebarSettingsMenu title={t(($) => $.detail.section_quick_actions)} label={t(($) => $.sidebar_settings.quick_actions)} tab="quick-actions" />+ </>} />+ {open && (actions.length > 0 || isError) ? (+ <div className="space-y-0.5 px-2">+ {isError && <button type="button" className="flex min-h-8 w-full items-center rounded-md px-2 py-1.5 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring" onClick={() => void refetch()}>+ {t(($) => $.detail.section_load_failed_retry)}+ </button>}{visible.map((action) => (<QuickActionRowkey={action.id}@@ -93,18 +90,20 @@ export function QuickActionsSection({ issueId }: { issueId: string }) {onBlocked={() => setBlocked(action)}/>))}- {hiddenCount > 0 ? (+ {hiddenCount > 0 && (<buttontype="button"- className="w-full rounded-md px-2 py-1 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/70 hover:text-foreground"onClick={() => setShowAll(true)}+ className="flex min-h-8 w-full items-center rounded-md px-2 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">{t(($) => $.detail.quick_actions_more, { count: hiddenCount })}</button>- ) : null}+ )}</div>) : null}+ {creating && <CreateQuickActionDialog onClose={() => setCreating(false)} />}+{/* One message for every refusal. The person reading this dialog and theperson who can fix the binding are different people — the clicker'snext step is the same either way, and the diagnostic detail lives in@@ -200,8 +199,8 @@ function QuickActionRow({disabled={running}onClick={() => void handleRun()}className={cn(- "group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-body transition-colors",- "hover:bg-accent/70 disabled:cursor-default disabled:opacity-60",+ "group flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-caption transition-colors",+ "hover:bg-accent/50 disabled:cursor-default disabled:opacity-60",)}>{running ? (diff --git a/packages/views/issues/components/system-wakeup-row.tsx b/packages/views/issues/components/system-wakeup-row.tsxindex f21e1ad984..9166f3877d 100644--- a/packages/views/issues/components/system-wakeup-row.tsx+++ b/packages/views/issues/components/system-wakeup-row.tsx@@ -72,16 +72,16 @@ export function SystemWakeupRow({render={<buttontype="button"- className="col-span-2 col-start-1 row-start-1 grid min-w-0 grid-cols-subgrid rounded-md py-1.5 text-left text-caption hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring"+ className="col-span-2 col-start-1 row-start-1 grid min-w-0 grid-cols-subgrid rounded-md py-2 text-left text-caption hover:bg-accent/50 focus-visible:outline-2 focus-visible:outline-ring"/>}>- <span className="flex min-h-8 min-w-0 items-start gap-2 py-1 pl-2 pr-1">+ <span className="flex min-h-7 min-w-0 items-center gap-2 pl-2 pr-1"><ListChecks className="mt-px size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />- <span className="line-clamp-2 min-w-0 break-words font-medium">{title}</span>+ <span className="line-clamp-2 min-w-0 break-words">{title}</span><SystemBadge /></span>- <span className={`col-span-2 min-w-0 break-words pl-7.5 pr-2 ${paused ? "text-warning" : "text-muted-foreground"}`}>+ <span className={`col-span-2 min-w-0 break-words pl-7.5 pr-2 text-micro ${paused ? "text-warning" : "text-muted-foreground"}`}>{summary}</span></PopoverTrigger>@@ -123,8 +123,9 @@ export function SystemWakeupRow({</p></PopoverContent></Popover>- <div className="z-10 col-start-2 row-start-1 flex min-h-11 items-center self-start px-2">+ <div className="z-10 col-start-2 row-start-1 flex min-h-10 items-center self-start px-2"><Switch+ size="sm"checked={rule.enabled}disabled={update.isPending}aria-label={t(($) => $.wakeups.system.toggle)}diff --git a/packages/views/issues/components/wakeup-control.tsx b/packages/views/issues/components/wakeup-control.tsxindex 26f2d0b599..25ff46aaed 100644--- a/packages/views/issues/components/wakeup-control.tsx+++ b/packages/views/issues/components/wakeup-control.tsx@@ -22,11 +22,13 @@ export function WakeupControl({closed,onDisable,onEnable,+ size = "default",}: {wakeup: Omit<IssueWakeup, "instruction">;task?: AgentTask;pending: boolean;closed: boolean;+ size?: "sm" | "default";onDisable: () => void;onEnable: (input?: { at?: string; rearm?: boolean }) => Promise<void>;}) {@@ -49,9 +51,10 @@ export function WakeupControl({const needsRearm = !wakeup.enabled && (consumed || expired);const canEnable = !closed && (!activeRun || wakeup.mode === "continuous");return (- <div className="flex min-h-11 shrink-0 items-center px-2">+ <div className={`flex shrink-0 items-center px-2 ${size === "sm" ? "min-h-10 [&>button]:text-caption [&>button]:font-normal" : "min-h-11"}`}>{wakeup.enabled || (!needsRearm && !canDisable) ? (<Switch+ size={size}checked={wakeup.enabled}disabled={pending || (!wakeup.enabled && !canEnable)}aria-label={t(($) => $.wakeups.toggle, {diff --git a/packages/views/issues/components/wakeup-create.tsx b/packages/views/issues/components/wakeup-create.tsxindex 194acc7c06..a16821036b 100644--- a/packages/views/issues/components/wakeup-create.tsx+++ b/packages/views/issues/components/wakeup-create.tsx@@ -106,7 +106,6 @@ export function WakeupCreate({<IconButtonvariant="ghost"size="icon-xs"- className="text-muted-foreground"label={t(($) => $.wakeups.create.open)}/>}diff --git a/packages/views/issues/components/wakeups-section.test.tsx b/packages/views/issues/components/wakeups-section.test.tsxindex 394d01b4fe..2bf0e54b03 100644--- a/packages/views/issues/components/wakeups-section.test.tsx+++ b/packages/views/issues/components/wakeups-section.test.tsx@@ -9,6 +9,9 @@ const updateSystem = vi.fn();const trigger = vi.fn();const remove = vi.fn();let runs: unknown[] = [];+let empty = false;+let systemError = false;+const refetch = vi.fn();let systemRules: SystemWakeup[] = [];let pending = false;let wakeup: IssueWakeup;@@ -17,7 +20,10 @@ let viewTZ = "UTC";vi.mock("./wakeup-condition-names", () => ({useConditionNames: () => ({ status: (key: string) => key, label: () => undefined, property: () => undefined, actor: (_type: string, id: string) => id }),}));+const settingsPush = vi.hoisted(() => vi.fn());+vi.mock("../../navigation", () => ({ useNavigation: () => ({ push: settingsPush }) }));vi.mock("@multica/core/paths", () => ({+ useWorkspacePaths: () => ({ settings: () => "/acme/settings" }),useCurrentWorkspace: () => ({ id: "ws" }),}));vi.mock("@multica/core/issues", () => ({@@ -34,9 +40,11 @@ vi.mock("@multica/core/issues", () => ({}));vi.mock("@tanstack/react-query", () => ({useQuery: ({ queryKey }: { queryKey: string[] }) => ({+ isError: queryKey[0] === "system" && systemError,+ refetch,data:queryKey[0] === "wakeups"- ? [wakeup]+ ? empty ? [] : [wakeup]: queryKey[0] === "system"? systemRules: queryKey[0] === "tasks"@@ -60,6 +68,9 @@ beforeEach(() => {trigger.mockReset();remove.mockReset();runs = [];+ empty = false;+ systemError = false;+ refetch.mockReset();updateSystem.mockReset().mockResolvedValue(undefined);systemRules = [];enable.mockReset().mockResolvedValue(undefined);@@ -89,6 +100,34 @@ beforeEach(() => {};});describe("Wakeups sidebar", () => {+ it("opens workspace defaults from the folded section", async () => {+ renderWithI18n(<WakeupsSection issueId="issue" />);+ const disclosure = screen.getByRole("button", { name: "Wakeups 1" });+ fireEvent.click(disclosure);+ fireEvent.click(screen.getByRole("button", { name: "Wakeups options" }));+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ fireEvent.click(await screen.findByRole("menuitem", { name: "Wakeup settings" }));+ expect(settingsPush).toHaveBeenCalledWith("/acme/settings?tab=wakeups");+ });+ it("shows an empty static title with creation available", () => {+ empty = true;+ renderWithI18n(<WakeupsSection issueId="issue" />);+ expect(screen.getByText("Wakeups")).toBeVisible();+ expect(screen.queryByRole("button", { name: "Wakeups" })).not.toBeInTheDocument();+ });+ it("keeps history accessible even without current rules", () => {+ wakeup.enabled = false;+ status = "completed";+ renderWithI18n(<WakeupsSection issueId="issue" />);+ expect(screen.getByRole("button", { name: "Wakeups" })).toHaveAttribute("aria-expanded", "true");+ });+ it("shows retry when system rules fail instead of treating the section as empty", () => {+ empty = true;+ systemError = true;+ renderWithI18n(<WakeupsSection issueId="issue" />);+ fireEvent.click(screen.getByRole("button", { name: "Could not load wakeups. Retry" }));+ expect(refetch).toHaveBeenCalledTimes(2);+ });it("describes hourly schedules without exposing interval seconds", () => {renderWithI18n(<WakeupsSection issueId="issue" />, { locale: "zh-Hans" });expect(screen.getByRole("button", { name: /唤醒 Emacs/ })).toHaveTextContent("每小时唤醒");@@ -170,7 +209,7 @@ describe("Wakeups sidebar", () => {renderWithI18n(<WakeupsSection issueId="issue" />);expect(screen.queryByRole("button", { name: /Wake Emacs/ })).toBeNull();expect(screen.queryByRole("switch")).toBeNull();- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));expect(screen.getByRole("button", { name: /Wake Emacs/ })).toBeVisible();});it("uses server run status while the run detail query is still incomplete", () => {@@ -190,7 +229,7 @@ it("re-enables a manually disabled recurring configuration with its revision", awakeup.disabled_at = "2026-09-16T00:00:00Z";status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));const toggle = screen.getByRole("switch", { name: "Wakeup for Emacs" });expect(toggle).not.toBeChecked();fireEvent.click(toggle);@@ -203,7 +242,7 @@ it("blocks re-enabling on terminal issues", () => {wakeup.enabled = false;status = "completed";renderWithI18n(<WakeupsSection issueId="issue" closed />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));expect(screen.getByRole("switch")).toHaveAttribute("aria-disabled", "true");fireEvent.click(screen.getByRole("switch"));expect(enable).not.toHaveBeenCalled();@@ -218,7 +257,7 @@ it("requires a new future time for an expired one-shot", async () => {wakeup.next_fire_at = "2020-01-01T00:00:00Z";status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));expect(screen.queryByRole("switch")).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Set a new time" }));const input = await screen.findByLabelText(/Time \(/);@@ -245,7 +284,7 @@ it("uses explicit resubscribe for a completed one-shot event", async () => {wakeup.mode = "once";status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));expect(screen.queryByRole("switch")).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Enable again" }));await waitFor(() =>@@ -286,7 +325,7 @@ it("shows a disabled rule independently from its last successful execution", ()wakeup.disabled_at = "2026-09-16T00:00:00Z";status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));const row = screen.getByRole("button", { name: /Wake Emacs/ });expect(row).toHaveTextContent("Turned off");expect(row).toHaveTextContent("Last execution: Run succeeded");@@ -299,7 +338,7 @@ it("keeps a failed one-shot triggered without calling the rule completed", () =>wakeup.event_types = ["comment.created"];status = "failed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));const row = screen.getByRole("button", { name: /Wake Emacs/ });expect(row).toHaveTextContent("Triggered");expect(row).toHaveTextContent("This execution: Run failed");@@ -367,7 +406,7 @@ describe("v2 sidebar", () => {});status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));expect(screen.getByRole("button", { name: /Wake Emacs/ })).toHaveTextContent("Timed out");});@@ -434,7 +473,7 @@ describe("conditions, limits and history", () => {});status = "completed";renderWithI18n(<WakeupsSection issueId="issue" />);- fireEvent.click(screen.getByRole("button", { name: "Wakeup history 1" }));+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));const row = screen.getByRole("button", { name: /Wake Emacs/ });expect(row).toHaveTextContent("Paused automatically");expect(row).toHaveTextContent("Stopped after reaching 5 runs");diff --git a/packages/views/issues/components/wakeups-section.tsx b/packages/views/issues/components/wakeups-section.tsxindex 373d32397e..e37ae4f820 100644--- a/packages/views/issues/components/wakeups-section.tsx+++ b/packages/views/issues/components/wakeups-section.tsx@@ -1,5 +1,8 @@"use client";+import { IssueSidebarSettingsMenu } from "./issue-sidebar-settings-menu";+import { IssueSidebarSectionHeader } from "./issue-sidebar-section";+import { useState } from "react";import { useQuery } from "@tanstack/react-query";import { Bell, Clock3, ChevronRight, GitPullRequest, Link2, ListChecks, CircleDot, Play } from "lucide-react";@@ -182,20 +185,20 @@ function WakeupRow({render={<buttontype="button"- className="col-span-2 col-start-1 row-start-1 grid min-w-0 grid-cols-subgrid rounded-md py-1.5 text-left text-caption hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring"+ className="col-span-2 col-start-1 row-start-1 grid min-w-0 grid-cols-subgrid rounded-md py-2 text-left text-caption hover:bg-accent/50 focus-visible:outline-2 focus-visible:outline-ring"/>}>- <span className="flex min-h-8 min-w-0 items-start gap-2 py-1 pl-2 pr-1">+ <span className="flex min-h-7 min-w-0 items-center gap-2 pl-2 pr-1"><IconclassName="mt-px size-3.5 shrink-0 text-muted-foreground"aria-hidden="true"/>- <span className="line-clamp-2 min-w-0 break-words font-medium">+ <span className="line-clamp-2 min-w-0 break-words">{text.trigger(wakeup)}</span></span>- <span className="col-span-2 min-w-0 break-words pl-7.5 pr-2">+ <span className="col-span-2 min-w-0 break-words pl-7.5 pr-2 text-micro"><span className="block text-muted-foreground">{text.summary(wakeup, closed)}</span>@@ -347,6 +350,7 @@ function WakeupRow({</Popover><div className="z-10 col-start-2 row-start-1 self-start"><WakeupControl+ size="sm"wakeup={wakeup}task={task}pending={pending}@@ -375,16 +379,18 @@ export function WakeupsSection({const [historyOpen, setHistoryOpen] = useState(false);const {data = [],- isError,+ isError: wakeupsError,refetch,} = useQuery(issueWakeupsOptions(workspaceId, issueId));const { data: tasks = [] } = useQuery(issueTasksOptions(issueId));- const { data: systemRules = [] } = useQuery(issueSystemWakeupsOptions(workspaceId, issueId));+ const { data: systemRules = [], isError: systemRulesError, refetch: refetchSystemRules } = useQuery(issueSystemWakeupsOptions(workspaceId, issueId));+ const isError = wakeupsError === true || systemRulesError === true;+ const hasContent = data.length > 0 || (!closed && systemRules.length > 0) || isError;const text = useWakeupText();const disable = useDisableIssueWakeup(workspaceId, issueId);const enable = useEnableIssueWakeup(workspaceId, issueId);// Open issues always show the section so people can add a wakeup.- if (closed && !data.length && !isError) return null;+ if (closed && !hasContent) return null;const current = data.filter((w) => isCurrentWakeup(w, wakeupRun(w, tasks)));const history = data.filter((w) => !isCurrentWakeup(w, wakeupRun(w, tasks)));const row = (wakeup: IssueWakeup) => (@@ -418,34 +424,23 @@ export function WakeupsSection({);return (<section>- <div className="mb-1 flex items-center gap-1">- <button- type="button"- id={`issue-wakeups-${issueId}`}- aria-expanded={open}- onClick={() => setOpen(!open)}- className="flex min-h-9 flex-1 items-center gap-1 rounded-md px-2 py-1 text-caption font-medium hover:bg-accent/70 focus-visible:outline-2 focus-visible:outline-ring"- >- {t(($) => $.wakeups.title)}{" "}- <span className="text-muted-foreground tabular-nums">- {current.length + systemRules.length}- </span>- <ChevronRight- className={`size-3 text-muted-foreground ${open ? "rotate-90" : ""}`}- aria-hidden="true"- />- </button>- {!closed && (- <WakeupCreate workspaceId={workspaceId} issueId={issueId} defaultAgentId={defaultAgentId} />- )}- </div>- {open && (- <div>+ <IssueSidebarSectionHeader+ id={`issue-wakeups-${issueId}`}+ title={t(($) => $.wakeups.title)} open={open} onOpenChange={setOpen}+ count={current.length + (!closed ? systemRules.length : 0)}+ collapsible={hasContent}+ actions={<>+ {!closed && <WakeupCreate workspaceId={workspaceId} issueId={issueId} defaultAgentId={defaultAgentId} />}+ <IssueSidebarSettingsMenu title={t(($) => $.wakeups.title)} label={t(($) => $.sidebar_settings.wakeups)} tab="wakeups" />+ </>}+ />+ {open && hasContent && (+ <div className="px-2">{isError && (<buttontype="button"- className="px-2 text-caption text-muted-foreground hover:text-foreground"- onClick={() => void refetch()}+ className="flex min-h-8 w-full items-center rounded-md px-2 py-1.5 text-left text-caption text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"+ onClick={() => { void refetch(); void refetchSystemRules(); }}>{t(($) => $.wakeups.retry)}</button>@@ -466,7 +461,7 @@ export function WakeupsSection({type="button"aria-expanded={historyOpen}onClick={() => setHistoryOpen(!historyOpen)}- className="flex min-h-9 w-full items-center gap-1 rounded-md px-2 py-1 text-caption text-muted-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring"+ className="flex min-h-9 w-full items-center gap-1 rounded-md px-2 py-1 text-caption text-muted-foreground hover:bg-accent/50 focus-visible:outline-2 focus-visible:outline-ring"><ChevronRightclassName={`size-3 ${historyOpen ? "rotate-90" : ""}`}diff --git a/packages/views/layout/animated-right-sidebar.tsx b/packages/views/layout/animated-right-sidebar.tsxindex fc143e17e2..6eb7046546 100644--- a/packages/views/layout/animated-right-sidebar.tsx+++ b/packages/views/layout/animated-right-sidebar.tsx@@ -140,7 +140,7 @@ export function AnimatedRightSidebar({// so wheeling past the end of the comments scrolled the whole issue// detail up and left a blank band at the bottom (MUL-8100).className={cn(- "relative h-full overflow-x-hidden overflow-y-auto border-l",+ "relative h-full overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] border-l",!open && "pointer-events-none",className,)}diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex 8e27abdd4b..328c483cf4 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "{{section}} options",+ "quick_actions": "Quick action settings",+ "wakeups": "Wakeup settings",+ "properties": "Custom property settings",+ "plugins": "Plugin settings"+ },"inline_run": {"label": "{{name}} run","stop": "Stop",@@ -381,6 +388,15 @@"close": "Close preview"},"detail": {+ "metadata_close": "Close metadata",+ "metadata_copy": "Copy metadata",+ "metadata_view": "View metadata",+ "metadata_expand": "Expand dialog",+ "metadata_restore": "Restore dialog size",+ "metadata_copy_failed": "Failed to copy metadata",+ "metadata_description": "Key-value data recorded by agents and integrations for workflow coordination.",++ "section_load_failed_retry": "Could not load. Retry","not_found": "This issue does not exist or has been deleted in this workspace.","breadcrumb_project_unknown": "Unknown project","back": "Back",@@ -763,8 +779,8 @@"summary_runs_other": "{{count}} runs","latest": "Latest","open_timeline": "Open timeline",- "more_runs_one": "{{count}} more",- "more_runs_other": "{{count}} more",+ "more_runs_one": "Show {{count}} more",+ "more_runs_other": "Show {{count}} more","strip_aria": "Cost per run — open the run timeline","strip_no_usage": "No usage recorded","sparkline_now": "Now"@@ -1111,7 +1127,7 @@"wake_agent": "Wake {{agent}}","needs_attention": "Needs attention","turn_off": "Turn off",- "ended": "Wakeup history {{count}}",+ "ended": "Wakeup history · {{count}}","waiting_event": "Waiting for trigger","triggered_by_wakeup": "Triggered by wakeup","upcoming": "{{count}} enabled wakeup rules",diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex f95670ea49..37377cc8e5 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "Options : {{section}}",+ "quick_actions": "Paramètres des actions rapides",+ "wakeups": "Paramètres de réveil",+ "properties": "Paramètres des propriétés personnalisées",+ "plugins": "Paramètres des plugins"+ },"inline_run": {"label": "Exécution de {{name}}","stop": "Arrêter",@@ -381,6 +388,14 @@"close": "Fermer l'aperçu"},"detail": {+ "metadata_close": "Fermer les métadonnées",+ "metadata_copy": "Copier les métadonnées",+ "metadata_view": "Agrandir les métadonnées",+ "metadata_expand": "Agrandir la boîte de dialogue",+ "metadata_restore": "Rétablir la taille de la boîte de dialogue",+ "metadata_copy_failed": "Impossible de copier les métadonnées",+ "metadata_description": "Données clé-valeur enregistrées par les agents et les intégrations pour poursuivre le workflow.",+ "section_load_failed_retry": "Échec du chargement. Réessayer","not_found": "Cette tâche n'existe pas ou a été supprimée dans cet espace de travail.","breadcrumb_project_unknown": "Projet inconnu","back": "Retour",@@ -763,8 +778,8 @@"summary_runs_other": "{{count}} exécutions","latest": "Récentes","open_timeline": "Ouvrir la chronologie",- "more_runs_one": "{{count}} de plus",- "more_runs_other": "{{count}} de plus",+ "more_runs_one": "Afficher {{count}} de plus",+ "more_runs_other": "Afficher {{count}} de plus","strip_aria": "Coût par exécution — ouvrir la chronologie","strip_no_usage": "Aucune consommation enregistrée","sparkline_now": "Maintenant"@@ -1111,7 +1126,7 @@"wake_agent": "Réveiller {{agent}}","needs_attention": "Action requise","turn_off": "Désactiver",- "ended": "Historique des réveils {{count}}",+ "ended": "Historique des réveils · {{count}}","waiting_event": "En attente du déclencheur","triggered_by_wakeup": "Déclenché par un réveil","upcoming": "{{count}} règles de réveil activées",diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex 1ea4242abc..1dadbb6bf8 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "{{section}}のオプション",+ "quick_actions": "クイックアクション設定",+ "wakeups": "自動起動設定",+ "properties": "カスタムプロパティ設定",+ "plugins": "プラグイン設定"+ },"inline_run": {"label": "{{name}} の実行","stop": "停止",@@ -377,6 +384,15 @@"close": "プレビューを閉じる"},"detail": {+ "metadata_close": "メタデータを閉じる",+ "metadata_copy": "メタデータをコピー",+ "metadata_view": "メタデータを拡大表示",+ "metadata_expand": "ダイアログを拡大",+ "metadata_restore": "ダイアログのサイズを戻す",+ "metadata_copy_failed": "メタデータをコピーできませんでした",+ "metadata_description": "エージェントや連携機能がワークフローを引き継ぐために記録するキーと値のデータ。",++ "section_load_failed_retry": "読み込めませんでした。再試行","not_found": "このタスクはこのワークスペースに存在しないか、削除されています。","breadcrumb_project_unknown": "不明なプロジェクト","back": "戻る",@@ -426,7 +442,7 @@"pull_request_snapshot_stale": "{{time}}に更新","pull_request_snapshot_stale_unknown": "スナップショットが古い可能性があります","pull_request_card_files_count_other": "{{count}} ファイル",- "pull_request_card_show_more": "他 {{count}} 件を表示",+ "pull_request_card_show_more": "残り {{count}} 件を表示","pull_request_card_show_less": "折りたたむ","prop_status": "ステータス","prop_priority": "優先度",@@ -733,7 +749,7 @@"summary_runs_other": "{{count}} 回の実行","latest": "最新","open_timeline": "タイムラインを開く",- "more_runs_other": "他 {{count}} 件",+ "more_runs_other": "残り {{count}} 件を表示","strip_aria": "実行ごとの費用 — 実行タイムラインを開く","strip_no_usage": "使用量の記録なし","sparkline_now": "現在"@@ -1069,7 +1085,7 @@"wake_agent": "{{agent}} を起動","needs_attention": "対応が必要","turn_off": "オフにする",- "ended": "ウェイクアップ履歴 {{count}}",+ "ended": "ウェイクアップ履歴 · {{count}}","waiting_event": "トリガー待ち","triggered_by_wakeup": "自動起動による実行","upcoming": "有効なルール {{count}} 件",diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex 2a74306922..17abd5ccfa 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "{{section}} 옵션",+ "quick_actions": "빠른 작업 설정",+ "wakeups": "깨우기 설정",+ "properties": "사용자 지정 속성 설정",+ "plugins": "플러그인 설정"+ },"inline_run": {"label": "{{name}} 실행","stop": "중지",@@ -377,6 +384,15 @@"close": "미리보기 닫기"},"detail": {+ "metadata_close": "메타데이터 닫기",+ "metadata_copy": "메타데이터 복사",+ "metadata_view": "메타데이터 확대 보기",+ "metadata_expand": "대화상자 확대",+ "metadata_restore": "대화상자 크기 복원",+ "metadata_copy_failed": "메타데이터를 복사하지 못했습니다",+ "metadata_description": "에이전트와 연동 기능이 작업 흐름을 이어가기 위해 기록하는 키와 값 데이터입니다.",++ "section_load_failed_retry": "불러오지 못했습니다. 다시 시도","not_found": "이 워크스페이스에 해당 태스크가 없거나 삭제되었습니다.","breadcrumb_project_unknown": "알 수 없는 프로젝트","back": "뒤로",@@ -733,7 +749,7 @@"summary_runs_other": "실행 {{count}}회","latest": "최근","open_timeline": "타임라인 열기",- "more_runs_other": "{{count}}개 더",+ "more_runs_other": "{{count}}개 더 보기","strip_aria": "실행별 비용 — 실행 타임라인 열기","strip_no_usage": "사용량 기록 없음","sparkline_now": "지금"@@ -1069,7 +1085,7 @@"wake_agent": "{{agent}} 깨우기","needs_attention": "확인 필요","turn_off": "끄기",- "ended": "깨우기 기록 {{count}}",+ "ended": "깨우기 기록 · {{count}}","waiting_event": "트리거 대기 중","triggered_by_wakeup": "자동 깨우기로 시작됨","upcoming": "활성 깨우기 규칙 {{count}}개",diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex 5903812c17..b57904b946 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "{{section}}选项",+ "quick_actions": "快捷操作设置",+ "wakeups": "唤醒设置",+ "properties": "自定义属性设置",+ "plugins": "插件设置"+ },"inline_run": {"label": "{{name}} 的运行","stop": "停止",@@ -377,6 +384,15 @@"close": "关闭预览"},"detail": {+ "metadata_close": "关闭元数据",+ "metadata_copy": "复制元数据",+ "metadata_view": "放大查看元数据",+ "metadata_expand": "放大弹窗",+ "metadata_restore": "恢复弹窗大小",+ "metadata_copy_failed": "复制元数据失败",+ "metadata_description": "智能体和集成记录的键值数据,用于衔接工作流程。",++ "section_load_failed_retry": "加载失败,点击重试","not_found": "这个任务不存在或已在该工作区被删除。","breadcrumb_project_unknown": "未知项目","back": "返回",@@ -733,7 +749,7 @@"summary_runs_other": "{{count}} 次运行","latest": "最近","open_timeline": "打开时间线",- "more_runs_other": "还有 {{count}} 次",+ "more_runs_other": "显示其余 {{count}} 次运行","strip_aria": "每次运行的费用——打开运行时间线","strip_no_usage": "没有用量记录","sparkline_now": "现在"@@ -1069,7 +1085,7 @@"wake_agent": "唤醒 {{agent}}","needs_attention": "需要处理","turn_off": "关闭",- "ended": "历史唤醒 {{count}}",+ "ended": "历史唤醒 · {{count}}","waiting_event": "等待触发","triggered_by_wakeup": "由唤醒触发","upcoming": "已开启 {{count}} 条唤醒规则",diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.jsonindex 982f345ecc..9e2775f6ab 100644--- a/packages/views/locales/zh-Hant/issues.json+++ b/packages/views/locales/zh-Hant/issues.json@@ -1,4 +1,11 @@{+ "sidebar_settings": {+ "menu": "{{section}}選項",+ "quick_actions": "快捷操作設定",+ "wakeups": "喚醒設定",+ "properties": "自訂屬性設定",+ "plugins": "外掛設定"+ },"inline_run": {"label": "{{name}} 的執行","stop": "停止",@@ -377,6 +384,14 @@"close": "關閉預覽"},"detail": {+ "metadata_close": "關閉後設資料",+ "metadata_copy": "複製後設資料",+ "metadata_view": "放大檢視後設資料",+ "metadata_expand": "放大彈出視窗",+ "metadata_restore": "還原彈出視窗大小",+ "metadata_copy_failed": "複製後設資料失敗",+ "metadata_description": "智慧體和整合記錄的鍵值資料,用於銜接工作流程。",+ "section_load_failed_retry": "載入失敗,點選重試","not_found": "這個任務不存在或已在該工作區被刪除。","breadcrumb_project_unknown": "未知專案","back": "返回",@@ -733,7 +748,7 @@"summary_runs_other": "{{count}} 次執行","latest": "最近","open_timeline": "開啟時間線",- "more_runs_other": "還有 {{count}} 次",+ "more_runs_other": "顯示其餘 {{count}} 次執行","strip_aria": "每次執行的費用——開啟執行時間線","strip_no_usage": "沒有用量記錄","sparkline_now": "現在"@@ -1069,7 +1084,7 @@"wake_agent": "喚醒 {{agent}}","needs_attention": "需要處理","turn_off": "關閉",- "ended": "歷史喚醒 {{count}}",+ "ended": "歷史喚醒 · {{count}}","waiting_event": "等待觸發","triggered_by_wakeup": "由喚醒觸發","upcoming": "已開啟 {{count}} 條喚醒規則",diff --git a/packages/views/plugins/plugin-panel-section.test.tsx b/packages/views/plugins/plugin-panel-section.test.tsxindex fd58dacbe1..6f8a0cb7ab 100644--- a/packages/views/plugins/plugin-panel-section.test.tsx+++ b/packages/views/plugins/plugin-panel-section.test.tsx@@ -1,6 +1,6 @@import type { ReactNode } from "react";import { beforeEach, describe, expect, it, vi } from "vitest";-import { act, render, screen } from "@testing-library/react";+import { act, fireEvent, render, screen } from "@testing-library/react";import { I18nProvider } from "@multica/core/i18n/react";import enCommon from "../locales/en/common.json";import enIssues from "../locales/en/issues.json";@@ -29,7 +29,12 @@ vi.mock("@multica/core/plugins", () => ({pluginInstallationsOptions: () => ({ queryKey: ["plugins"] }),pluginSurfaceLaunchOptions: () => ({ queryKey: ["surface"] }),}));-vi.mock("@multica/core/paths", () => ({ useCurrentWorkspace: () => ({ id: "workspace-1", name: "Acme", slug: "acme" }) }));+const settingsPush = vi.hoisted(() => vi.fn());+vi.mock("../navigation", () => ({ useNavigation: () => ({ push: settingsPush }) }));+vi.mock("@multica/core/paths", () => ({+ useWorkspacePaths: () => ({ settings: () => "/acme/settings" }),+ useCurrentWorkspace: () => ({ id: "workspace-1", name: "Acme", slug: "acme" }),+}));vi.mock("@multica/core/config", () => ({ useFeatureEnabled: () => data.flagEnabled }));vi.mock("../platform/local-directory", () => ({ isDesktopShell: () => false }));@@ -89,6 +94,33 @@ describe("PluginPanelSection", () => {expect(srcdoc).not.toContain('child.setAttribute("sandbox", "allow-scripts allow-same-origin")');});+ it("opens plugin management without unfolding or replacing the panel", async () => {+ data.installed.plugins = [installation()];+ render(<PluginPanelSection issueId="issue-1" />, { wrapper: Wrapper });+ const frame = screen.getByTitle("Hello Panel — Hello");+ const disclosure = screen.getByRole("button", { name: "Plugins 1" });+ fireEvent.click(disclosure);+ fireEvent.click(screen.getByRole("button", { name: "Plugins options" }));+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ fireEvent.click(await screen.findByRole("menuitem", { name: "Plugin settings" }));+ expect(settingsPush).toHaveBeenCalledWith("/acme/settings?tab=plugins");+ expect(screen.getByTitle("Hello Panel — Hello")).toBe(frame);+ });++ it("preserves the mounted plugin frame across disclosure changes", () => {+ data.installed.plugins = [installation()];+ render(<PluginPanelSection issueId="issue-1" />, { wrapper: Wrapper });+ const frame = screen.getByTitle("Hello Panel — Hello");+ const disclosure = screen.getByRole("button", { expanded: true });+ fireEvent.click(disclosure);+ expect(disclosure).toHaveAttribute("aria-expanded", "false");+ expect(screen.getByTitle("Hello Panel — Hello")).toBe(frame);+ expect(frame).not.toBeVisible();+ fireEvent.click(disclosure);+ expect(screen.getByTitle("Hello Panel — Hello")).toBe(frame);+ expect(frame).toBeVisible();+ });+it("does not mount a disabled installation", () => {data.installed.plugins = [installation({ enabled: false })];render(<PluginPanelSection issueId="issue-1" />, { wrapper: Wrapper });diff --git a/packages/views/plugins/plugin-panel-section.tsx b/packages/views/plugins/plugin-panel-section.tsxindex bf21492f0d..700202bf96 100644--- a/packages/views/plugins/plugin-panel-section.tsx+++ b/packages/views/plugins/plugin-panel-section.tsx@@ -1,6 +1,6 @@"use client";-import { useMemo } from "react";+import { useMemo, useState } from "react";import { useQuery } from "@tanstack/react-query";import { pluginInstallationsOptions } from "@multica/core/plugins";import { useCurrentWorkspace } from "@multica/core/paths";@@ -8,6 +8,8 @@ import { useFeatureEnabled } from "@multica/core/config";import { PLUGINS_V1_FLAG } from "@multica/core/feature-flags";import { useT } from "../i18n";import { isDesktopShell } from "../platform/local-directory";+import { IssueSidebarSettingsMenu } from "../issues/components/issue-sidebar-settings-menu";+import { IssueSidebarSectionHeader } from "../issues/components/issue-sidebar-section";import { PluginSurfaceFrame } from "./plugin-surface-frame";/**@@ -20,6 +22,7 @@ import { PluginSurfaceFrame } from "./plugin-surface-frame";*/export function PluginPanelSection({ issueId }: { issueId: string }) {const { t } = useT("issues");+ const [open, setOpen] = useState(true);const platform = isDesktopShell() ? "desktop" : "web";const workspace = useCurrentWorkspace();const wsId = workspace?.id ?? "";@@ -44,17 +47,20 @@ export function PluginPanelSection({ issueId }: { issueId: string }) {if (!pluginsEnabled || panels.length === 0) return null;return (- <section className="space-y-3">- <h3 className="px-0.5 text-caption font-medium text-muted-foreground">{t(($) => $.plugins.panels)}</h3>- {panels.map(({ installation, surface }) => (- <PluginSurfaceFrame- key={`${installation.id}:${surface.key}`}- wsId={wsId}- installation={installation}- surface={surface}- issueId={issueId}- />- ))}+ <section>+ <IssueSidebarSectionHeader title={t(($) => $.plugins.panels)} open={open} onOpenChange={setOpen} count={panels.length}+ actions={<IssueSidebarSettingsMenu title={t(($) => $.plugins.panels)} label={t(($) => $.sidebar_settings.plugins)} tab="plugins" />} />+ <div hidden={!open} className="space-y-2 px-2">+ {panels.map(({ installation, surface }) => (+ <PluginSurfaceFrame+ key={`${installation.id}:${surface.key}`}+ wsId={wsId}+ installation={installation}+ surface={surface}+ issueId={issueId}+ />+ ))}+ </div></section>);}diff --git a/packages/views/quick-actions/components/quick-action-dialog.test.tsx b/packages/views/quick-actions/components/quick-action-dialog.test.tsxnew file mode 100644index 0000000000..4a9fd2eeb3--- /dev/null+++ b/packages/views/quick-actions/components/quick-action-dialog.test.tsx@@ -0,0 +1,83 @@+import { fireEvent, screen, waitFor } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { renderWithI18n } from "../../test/i18n";++const state = vi.hoisted(() => ({ role: "member" as string, create: vi.fn() }));+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));+vi.mock("@multica/core/permissions", () => ({ useCurrentMember: () => ({ role: state.role }) }));+vi.mock("@multica/core/quick-actions", () => ({ useCreateQuickAction: () => ({ mutateAsync: state.create }) }));+vi.mock("../../autopilots/components/pickers/agent-picker", () => ({ AgentPicker: () => null }));+import type { QuickAction } from "@multica/core/types";+import { CreateQuickActionDialog, QuickActionDialog } from "./quick-action-dialog";++describe("shared quick action creation", () => {+ beforeEach(() => { state.role = "member"; state.create.mockReset(); state.create.mockResolvedValue({}); });+ function fill() {+ fireEvent.change(screen.getByLabelText("Name"), { target: { value: "Review" } });+ fireEvent.change(screen.getByLabelText("Prompt"), { target: { value: "Review this issue" } });+ }+ it("lets a member create a private action and closes after success", async () => {+ const close = vi.fn();+ renderWithI18n(<CreateQuickActionDialog onClose={close} />);+ expect(screen.queryByRole("button", { name: /Team/ })).not.toBeInTheDocument();+ fill();+ fireEvent.click(screen.getByRole("button", { name: "Save" }));+ await waitFor(() => expect(close).toHaveBeenCalledOnce());+ expect(state.create).toHaveBeenCalledWith(expect.objectContaining({ visibility: "private", name: "Review", prompt: "Review this issue" }));+ });+ it("allows an admin to choose a team action", async () => {+ state.role = "admin";+ renderWithI18n(<CreateQuickActionDialog onClose={vi.fn()} />);+ fill();+ fireEvent.click(screen.getByRole("button", { name: /Team/ }));+ fireEvent.click(screen.getByRole("button", { name: "Save" }));+ await waitFor(() => expect(state.create).toHaveBeenCalledWith(expect.objectContaining({ visibility: "public" })));+ });+ it("preserves the draft after a failed creation", async () => {+ state.create.mockRejectedValue(new Error("Save failed"));+ const close = vi.fn();+ renderWithI18n(<CreateQuickActionDialog onClose={close} />);+ fill();+ fireEvent.click(screen.getByRole("button", { name: "Save" }));+ await waitFor(() => expect(screen.getByRole("button", { name: "Save" })).toBeEnabled());+ expect(close).not.toHaveBeenCalled();+ expect(screen.getByLabelText("Prompt")).toHaveValue("Review this issue");+ });+ it("blocks empty and template prompts before submission", () => {+ renderWithI18n(<CreateQuickActionDialog onClose={vi.fn()} />);+ const save = screen.getByRole("button", { name: "Save" });+ expect(save).toBeDisabled();+ fill();+ expect(save).toBeEnabled();+ fireEvent.change(screen.getByLabelText("Prompt"), { target: { value: "Review {{issue.title}}" } });+ expect(save).toBeDisabled();+ fireEvent.click(save);+ expect(state.create).not.toHaveBeenCalled();+ fireEvent.change(screen.getByLabelText("Prompt"), { target: { value: " " } });+ expect(save).toBeDisabled();+ });++ it("preserves saved visibility when editing and resets a reopened new draft", async () => {+ const existing: QuickAction = {+ id: "qa-1", workspace_id: "ws-1", name: "Existing action", description: "",+ assignee_type: "", assignee_id: "", prompt: "Existing prompt", visibility: "public",+ status: "active", created_by_id: "user-1", created_at: "", updated_at: "",+ last_used_at: null, use_count: 0, target_name: "", target_public: false, target_missing: false,+ };+ const submit = vi.fn().mockResolvedValue(undefined);+ const change = vi.fn();+ const view = renderWithI18n(<QuickActionDialog open action={existing} onOpenChange={change} onSubmit={submit} />);+ expect(screen.getByRole("button", { name: /Team/ })).toHaveAttribute("aria-pressed", "true");+ expect(screen.getByLabelText("Name")).toHaveValue("Existing action");+ fireEvent.click(screen.getByRole("button", { name: "Save" }));+ await waitFor(() => expect(submit).toHaveBeenCalledWith(expect.objectContaining({ visibility: "public" })));+ await waitFor(() => expect(change).toHaveBeenCalledWith(false));+ view.rerender(<QuickActionDialog open={false} action={null} onOpenChange={change} onSubmit={submit} />);+ view.rerender(<QuickActionDialog open action={null} onOpenChange={change} onSubmit={submit} />);+ expect(screen.getByLabelText("Name")).toHaveValue("");+ expect(screen.getByRole("button", { name: /Just me/ })).toHaveAttribute("aria-pressed", "true");+ fireEvent.click(screen.getByRole("button", { name: "Cancel" }));+ expect(submit).toHaveBeenCalledTimes(1);+ });++});diff --git a/packages/views/quick-actions/components/quick-action-dialog.tsx b/packages/views/quick-actions/components/quick-action-dialog.tsxnew file mode 100644index 0000000000..38b6bba07d--- /dev/null+++ b/packages/views/quick-actions/components/quick-action-dialog.tsx@@ -0,0 +1,236 @@+"use client";++import { useEffect, useMemo, useState } from "react";+import { Globe, Info, Lock } from "lucide-react";+import { toast } from "sonner";+import { useWorkspaceId } from "@multica/core/hooks";+import { useCurrentMember } from "@multica/core/permissions";+import { useCreateQuickAction } from "@multica/core/quick-actions";+import type { QuickAction, QuickActionAssigneeType, QuickActionVisibility } from "@multica/core/types";+import { findQuickActionTemplateToken } from "@multica/core/types";+import { Button } from "@multica/ui/components/ui/button";+import { Input } from "@multica/ui/components/ui/input";+import { Textarea } from "@multica/ui/components/ui/textarea";+import { Label as FieldLabel } from "@multica/ui/components/ui/label";+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@multica/ui/components/ui/dialog";+import { cn } from "@multica/ui/lib/utils";+import { AgentPicker } from "../../autopilots/components/pickers/agent-picker";+import { useT } from "../../i18n";++interface FormState {+ name: string;+ description: string;+ assigneeType: Exclude<QuickActionAssigneeType, "">;+ assigneeId: string;+ prompt: string;+ visibility: QuickActionVisibility;+}++const EMPTY_FORM: FormState = {+ name: "",+ description: "",+ assigneeType: "agent",+ assigneeId: "",+ prompt: "",+ visibility: "private",+};++function toFormState(action: QuickAction): FormState {+ return {+ name: action.name,+ description: action.description,+ assigneeType: action.assignee_type === "squad" ? "squad" : "agent",+ assigneeId: action.assignee_id,+ prompt: action.prompt,+ visibility: action.visibility === "private" ? "private" : "public",+ };+}++export function QuickActionDialog({+ open,+ action,+ onOpenChange,+ onSubmit,+}: {+ open: boolean;+ action: QuickAction | null;+ onOpenChange: (open: boolean) => void;+ onSubmit: (form: FormState) => Promise<void>;+}) {+ const { t } = useT("settings");+ const { role } = useCurrentMember(useWorkspaceId());+ const canPublish = role === "owner" || role === "admin";+ const [form, setForm] = useState<FormState>(EMPTY_FORM);+ const [saving, setSaving] = useState(false);++ useEffect(() => {+ if (!open) return;+ setForm(action ? toFormState(action) : EMPTY_FORM);+ }, [open, action]);++ // Mirror the server's rejection inline so the author sees it while typing+ // instead of on submit. The server stays the authority; this is an+ // affordance.+ const templateToken = useMemo(() => findQuickActionTemplateToken(form.prompt), [form.prompt]);++ const canSave =+ form.name.trim().length > 0 &&+ form.prompt.trim().length > 0 &&+ templateToken === null;++ const handleSubmit = async () => {+ if (!canSave) return;+ setSaving(true);+ try {+ await onSubmit(form);+ onOpenChange(false);+ } catch (error) {+ toast.error(error instanceof Error ? error.message : String(error));+ } finally {+ setSaving(false);+ }+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="sm:max-w-lg">+ <DialogHeader>+ <DialogTitle>+ {action ? t(($) => $.quick_actions.edit_title) : t(($) => $.quick_actions.create_title)}+ </DialogTitle>+ <DialogDescription>{t(($) => $.quick_actions.dialog_description)}</DialogDescription>+ </DialogHeader>++ {/* space-y-5 against space-y-1.5 inside each group: the gap BETWEEN+ fields has to clearly beat the gap between a label and its own+ control, or the four groups read as one continuous block of text. */}+ <div className="space-y-5">+ <div className="space-y-1.5">+ <FieldLabel htmlFor="qa-name">{t(($) => $.quick_actions.field_name)}</FieldLabel>+ <Input+ id="qa-name"+ value={form.name}+ maxLength={32}+ placeholder={t(($) => $.quick_actions.field_name_placeholder)}+ onChange={(e) => setForm((f) => ({ ...f, name: e.target.value }))}+ />+ </div>++ {/* Visibility first: it is the one choice that constrains the rest+ (a public action may only bind a publicly-invocable target), so+ asking it up front avoids a rejected Save. */}+ <div className="space-y-1.5">+ <FieldLabel>{t(($) => $.quick_actions.field_visibility)}</FieldLabel>+ <div className={cn("grid gap-2", action || canPublish ? "grid-cols-2" : "grid-cols-1")}>+ {(action || canPublish ? ["public", "private"] as const : ["private"] as const).map((option) => (+ <button+ key={option}+ type="button"+ aria-pressed={form.visibility === option}+ onClick={() => setForm((f) => ({ ...f, visibility: option }))}+ className={cn(+ "flex items-start gap-2 rounded-lg border px-3 py-2 text-left transition-colors",+ form.visibility === option+ ? "border-primary bg-accent/50"+ : "border-surface-border hover:bg-accent/30",+ )}+ >+ {option === "public" ? (+ <Globe className="mt-0.5 size-4 shrink-0 text-muted-foreground" />+ ) : (+ <Lock className="mt-0.5 size-4 shrink-0 text-muted-foreground" />+ )}+ <span className="min-w-0">+ <span className="block text-body font-medium">+ {option === "public"+ ? t(($) => $.quick_actions.visibility_public)+ : t(($) => $.quick_actions.visibility_private)}+ </span>+ <span className="mt-0.5 block text-caption text-muted-foreground">+ {option === "public"+ ? t(($) => $.quick_actions.visibility_public_hint)+ : t(($) => $.quick_actions.visibility_private_hint)}+ </span>+ </span>+ </button>+ ))}+ </div>+ </div>++ <div className="space-y-1.5">+ <FieldLabel id="qa-target-label" htmlFor="qa-target">+ {t(($) => $.quick_actions.field_target)}+ </FieldLabel>+ <AgentPicker+ assignee={form.assigneeId ? { type: form.assigneeType, id: form.assigneeId } : null}+ onChange={(next) =>+ setForm((f) => ({ ...f, assigneeType: next.type, assigneeId: next.id }))+ }+ emptyOption={{+ label: t(($) => $.quick_actions.no_target),+ onSelect: () => setForm((f) => ({ ...f, assigneeId: "" })),+ }}+ triggerRender={+ <Button+ id="qa-target"+ type="button"+ variant="outline"+ aria-labelledby="qa-target-label qa-target"+ />+ }+ />+ {/* Public promises "everyone can run this", so the server refuses a+ target the team cannot invoke. Saying so here turns a 400 into+ an expectation set before the user hits Save. */}+ {!form.assigneeId ? (+ <p className="text-caption text-muted-foreground">+ {t(($) => $.quick_actions.no_target_hint)}+ </p>+ ) : form.visibility === "public" ? (+ <p className="text-caption text-muted-foreground">+ {t(($) => $.quick_actions.public_target_hint)}+ </p>+ ) : null}+ </div>++ <div className="space-y-1.5">+ <FieldLabel htmlFor="qa-prompt">{t(($) => $.quick_actions.field_prompt)}</FieldLabel>+ <Textarea+ id="qa-prompt"+ value={form.prompt}+ rows={5}+ placeholder={t(($) => $.quick_actions.field_prompt_placeholder)}+ onChange={(e) => setForm((f) => ({ ...f, prompt: e.target.value }))}+ />+ {templateToken !== null ? (+ <p className="text-caption text-destructive">+ {t(($) => $.quick_actions.template_not_supported, { token: templateToken })}+ </p>+ ) : (+ <p className="inline-flex items-center gap-1 text-caption text-muted-foreground">+ <Info className="size-3" />+ {t(($) => $.quick_actions.prompt_hint)}+ </p>+ )}+ </div>+ </div>++ <DialogFooter>+ <Button variant="outline" onClick={() => onOpenChange(false)}>+ {t(($) => $.quick_actions.cancel)}+ </Button>+ <Button onClick={handleSubmit} disabled={!canSave || saving}>+ {t(($) => $.quick_actions.save)}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}++export function CreateQuickActionDialog({ onClose }: { onClose: () => void }) {+ const create = useCreateQuickAction();+ return <QuickActionDialog open action={null} onOpenChange={(open) => { if (!open) onClose(); }} onSubmit={async (form) => {+ await create.mutateAsync({ name: form.name, description: form.description, assignee_type: form.assigneeId ? form.assigneeType : "", assignee_id: form.assigneeId, prompt: form.prompt, visibility: form.visibility });+ }} />;+}diff --git a/packages/views/settings/components/quick-actions-tab.tsx b/packages/views/settings/components/quick-actions-tab.tsxindex d32084f334..5a540e7103 100644--- a/packages/views/settings/components/quick-actions-tab.tsx+++ b/packages/views/settings/components/quick-actions-tab.tsx@@ -1,12 +1,11 @@"use client";-import { useEffect, useMemo, useState } from "react";+import { useMemo, useState } from "react";import { useQuery } from "@tanstack/react-query";import {Archive,ArchiveRestore,Globe,- Info,Lock,MoreHorizontal,Pencil,@@ -26,24 +25,12 @@ import {} from "@multica/core/quick-actions";import type {QuickAction,- QuickActionAssigneeType,- QuickActionVisibility,} from "@multica/core/types";-import { findQuickActionTemplateToken } from "@multica/core/types";import { Button } from "@multica/ui/components/ui/button";import { IconButton } from "@multica/ui/components/common/icon-button";import { Badge } from "@multica/ui/components/ui/badge";import { Input } from "@multica/ui/components/ui/input";-import { Textarea } from "@multica/ui/components/ui/textarea";-import { Label as FieldLabel } from "@multica/ui/components/ui/label";-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from "@multica/ui/components/ui/dialog";+import { QuickActionDialog } from "../../quick-actions/components/quick-action-dialog";import {AlertDialog,AlertDialogAction,@@ -61,7 +48,6 @@ import {DropdownMenuTrigger,} from "@multica/ui/components/ui/dropdown-menu";import { cn } from "@multica/ui/lib/utils";-import { AgentPicker } from "../../autopilots/components/pickers/agent-picker";import { useLocale, useT } from "../../i18n";import { SettingsTab } from "./settings-layout";@@ -160,35 +146,6 @@ function TargetLine({ action, t }: { action: QuickAction; t: QuickActionsT }) {);}-interface FormState {- name: string;- description: string;- assigneeType: Exclude<QuickActionAssigneeType, "">;- assigneeId: string;- prompt: string;- visibility: QuickActionVisibility;-}--const EMPTY_FORM: FormState = {- name: "",- description: "",- assigneeType: "agent",- assigneeId: "",- prompt: "",- visibility: "public",-};--function toFormState(action: QuickAction): FormState {- return {- name: action.name,- description: action.description,- assigneeType: action.assignee_type === "squad" ? "squad" : "agent",- assigneeId: action.assignee_id,- prompt: action.prompt,- visibility: action.visibility === "private" ? "private" : "public",- };-}-export function QuickActionsTab() {const { t } = useT("settings");const locale = useLocale();@@ -438,183 +395,3 @@ export function QuickActionsTab() {</SettingsTab>);}--function QuickActionDialog({- open,- action,- onOpenChange,- onSubmit,-}: {- open: boolean;- action: QuickAction | null;- onOpenChange: (open: boolean) => void;- onSubmit: (form: FormState) => Promise<void>;-}) {- const { t } = useT("settings");- const [form, setForm] = useState<FormState>(EMPTY_FORM);- const [saving, setSaving] = useState(false);-- useEffect(() => {- if (!open) return;- setForm(action ? toFormState(action) : EMPTY_FORM);- }, [open, action]);-- // Mirror the server's rejection inline so the author sees it while typing- // instead of on submit. The server stays the authority; this is an- // affordance.- const templateToken = useMemo(() => findQuickActionTemplateToken(form.prompt), [form.prompt]);-- const canSave =- form.name.trim().length > 0 &&- form.prompt.trim().length > 0 &&- templateToken === null;-- const handleSubmit = async () => {- if (!canSave) return;- setSaving(true);- try {- await onSubmit(form);- onOpenChange(false);- } catch (error) {- toast.error(error instanceof Error ? error.message : String(error));- } finally {- setSaving(false);- }- };-- return (- <Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-lg">- <DialogHeader>- <DialogTitle>- {action ? t(($) => $.quick_actions.edit_title) : t(($) => $.quick_actions.create_title)}- </DialogTitle>- <DialogDescription>{t(($) => $.quick_actions.dialog_description)}</DialogDescription>- </DialogHeader>-- {/* space-y-5 against space-y-1.5 inside each group: the gap BETWEEN- fields has to clearly beat the gap between a label and its own- control, or the four groups read as one continuous block of text. */}- <div className="space-y-5">- <div className="space-y-1.5">- <FieldLabel htmlFor="qa-name">{t(($) => $.quick_actions.field_name)}</FieldLabel>- <Input- id="qa-name"- value={form.name}- maxLength={32}- placeholder={t(($) => $.quick_actions.field_name_placeholder)}- onChange={(e) => setForm((f) => ({ ...f, name: e.target.value }))}- />- </div>-- {/* Visibility first: it is the one choice that constrains the rest- (a public action may only bind a publicly-invocable target), so- asking it up front avoids a rejected Save. */}- <div className="space-y-1.5">- <FieldLabel>{t(($) => $.quick_actions.field_visibility)}</FieldLabel>- <div className="grid grid-cols-2 gap-2">- {(["public", "private"] as const).map((option) => (- <button- key={option}- type="button"- aria-pressed={form.visibility === option}- onClick={() => setForm((f) => ({ ...f, visibility: option }))}- className={cn(- "flex items-start gap-2 rounded-lg border px-3 py-2 text-left transition-colors",- form.visibility === option- ? "border-primary bg-accent/50"- : "border-surface-border hover:bg-accent/30",- )}- >- {option === "public" ? (- <Globe className="mt-0.5 size-4 shrink-0 text-muted-foreground" />- ) : (- <Lock className="mt-0.5 size-4 shrink-0 text-muted-foreground" />- )}- <span className="min-w-0">- <span className="block text-body font-medium">- {option === "public"- ? t(($) => $.quick_actions.visibility_public)- : t(($) => $.quick_actions.visibility_private)}- </span>- <span className="mt-0.5 block text-caption text-muted-foreground">- {option === "public"- ? t(($) => $.quick_actions.visibility_public_hint)- : t(($) => $.quick_actions.visibility_private_hint)}- </span>- </span>- </button>- ))}- </div>- </div>-- <div className="space-y-1.5">- <FieldLabel id="qa-target-label" htmlFor="qa-target">- {t(($) => $.quick_actions.field_target)}- </FieldLabel>- <AgentPicker- assignee={form.assigneeId ? { type: form.assigneeType, id: form.assigneeId } : null}- onChange={(next) =>- setForm((f) => ({ ...f, assigneeType: next.type, assigneeId: next.id }))- }- emptyOption={{- label: t(($) => $.quick_actions.no_target),- onSelect: () => setForm((f) => ({ ...f, assigneeId: "" })),- }}- triggerRender={- <Button- id="qa-target"- type="button"- variant="outline"- aria-labelledby="qa-target-label qa-target"- />- }- />- {/* Public promises "everyone can run this", so the server refuses a- target the team cannot invoke. Saying so here turns a 400 into- an expectation set before the user hits Save. */}- {!form.assigneeId ? (- <p className="text-caption text-muted-foreground">- {t(($) => $.quick_actions.no_target_hint)}- </p>- ) : form.visibility === "public" ? (- <p className="text-caption text-muted-foreground">- {t(($) => $.quick_actions.public_target_hint)}- </p>- ) : null}- </div>-- <div className="space-y-1.5">- <FieldLabel htmlFor="qa-prompt">{t(($) => $.quick_actions.field_prompt)}</FieldLabel>- <Textarea- id="qa-prompt"- value={form.prompt}- rows={5}- placeholder={t(($) => $.quick_actions.field_prompt_placeholder)}- onChange={(e) => setForm((f) => ({ ...f, prompt: e.target.value }))}- />- {templateToken !== null ? (- <p className="text-caption text-destructive">- {t(($) => $.quick_actions.template_not_supported, { token: templateToken })}- </p>- ) : (- <p className="inline-flex items-center gap-1 text-caption text-muted-foreground">- <Info className="size-3" />- {t(($) => $.quick_actions.prompt_hint)}- </p>- )}- </div>- </div>-- <DialogFooter>- <Button variant="outline" onClick={() => onOpenChange(false)}>- {t(($) => $.quick_actions.cancel)}- </Button>- <Button onClick={handleSubmit} disabled={!canSave || saving}>- {t(($) => $.quick_actions.save)}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>- );-}