Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): fold turned-off system wakeups into wakeup history (#10258)
Jiayuan Zhang10f0ab332e57
diff --git a/packages/views/issues/components/system-wakeup-row.tsx b/packages/views/issues/components/system-wakeup-row.tsxindex c165f5d3fe..227355833d 100644--- a/packages/views/issues/components/system-wakeup-row.tsx+++ b/packages/views/issues/components/system-wakeup-row.tsx@@ -26,10 +26,12 @@ export function SystemWakeupRow({rule,workspaceId,issueId,+ onTurnedOff,}: {rule: SystemWakeup;workspaceId: string;issueId: string;+ onTurnedOff?: () => void;}) {const { t } = useT("issues");const text = useWakeupText();@@ -62,10 +64,12 @@ export function SystemWakeupRow({: [target, t(($) => $.wakeups.system.remaining, { count: rule.remaining })].join(" · "));const save = (input: { enabled: boolean; instruction: string }) =>update.mutateAsync({ rule: rule.rule, ...input });- const toggle = (enabled: boolean) =>+ const toggle = (enabled: boolean) => {+ if (!enabled) onTurnedOff?.();void save({ enabled, instruction: rule.instruction }).catch(() =>toast.error(t(($) => $.wakeups.system.save_error)),);+ };return (<div className="grid grid-cols-[minmax(0,1fr)_auto]" aria-busy={update.isPending}><Popover>diff --git a/packages/views/issues/components/wakeups-section.test.tsx b/packages/views/issues/components/wakeups-section.test.tsxindex 733738dde9..381f137f1f 100644--- a/packages/views/issues/components/wakeups-section.test.tsx+++ b/packages/views/issues/components/wakeups-section.test.tsx@@ -421,6 +421,23 @@ describe("v2 sidebar", () => {await waitFor(() => expect(updateSystem).toHaveBeenCalledWith({ rule: "child_done", enabled: false, instruction: "" }));});+ it("folds a turned-off system rule into history and turns it back on from there", async () => {+ empty = true;+ systemRules = [{+ id: "rule", revision: 1, default_instruction: "Advance the next stage.", customized: true, paused_reason: null,+ rule: "child_done", workspace_default: true, enabled: false, instruction: "", staged: false, stage: null, total: 2, remaining: 1,+ waiting: ["MUL-2"], target: { type: "agent", id: "a", name: "Emacs" }, blocked: "",+ }];+ renderWithI18n(<WakeupsSection issueId="issue" />);+ expect(screen.getByRole("button", { name: "Wakeups" })).toBeVisible();+ expect(screen.queryByRole("button", { name: /When all sub-issues finish/ })).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Wakeup history · 1" }));+ const row = screen.getByRole("button", { name: /When all sub-issues finish/ });+ expect(row).toHaveTextContent("Turned off for this issue");+ fireEvent.click(screen.getAllByRole("switch", { name: "Wake the assignee when sub-issues finish" })[0]!);+ await waitFor(() => expect(updateSystem).toHaveBeenCalledWith({ rule: "child_done", enabled: true, instruction: "" }));+ });+it("says a member assignee is notified instead of woken", () => {systemRules = [{id: "rule", revision: 1, default_instruction: "Advance the next stage.", customized: false, paused_reason: null,diff --git a/packages/views/issues/components/wakeups-section.tsx b/packages/views/issues/components/wakeups-section.tsxindex 27d288e4bb..a858f9ec1d 100644--- a/packages/views/issues/components/wakeups-section.tsx+++ b/packages/views/issues/components/wakeups-section.tsx@@ -16,7 +16,7 @@ import {useTriggerIssueWakeup,issueTasksOptions,} from "@multica/core/issues";-import type { AgentTask, IssueWakeup, WakeupCondition } from "@multica/core/types";+import type { AgentTask, IssueWakeup, SystemWakeup, WakeupCondition } from "@multica/core/types";import { useCurrentWorkspace } from "@multica/core/paths";import {Popover,@@ -392,6 +392,19 @@ export function WakeupsSection({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 visibleSystemRules = closed ? [] : systemRules;+ const currentSystemRules = visibleSystemRules.filter((rule) => rule.enabled);+ const offSystemRules = visibleSystemRules.filter((rule) => !rule.enabled);+ const historyCount = history.length + offSystemRules.length;+ const systemRow = (rule: SystemWakeup) => (+ <SystemWakeupRow+ key={rule.rule}+ rule={rule}+ workspaceId={workspaceId}+ issueId={issueId}+ onTurnedOff={() => setHistoryOpen(true)}+ />+ );const row = (wakeup: IssueWakeup) => (<WakeupRowkey={wakeup.id}@@ -426,7 +439,7 @@ export function WakeupsSection({<IssueSidebarSectionHeaderid={`issue-wakeups-${issueId}`}title={t(($) => $.wakeups.title)} open={open} onOpenChange={setOpen}- count={current.length + (!closed ? systemRules.length : 0)}+ count={current.length + currentSystemRules.length}collapsible={hasContent}actions={!closed ? <WakeupCreate workspaceId={workspaceId} issueId={issueId} defaultAgentId={defaultAgentId} /> : undefined}/>@@ -446,12 +459,9 @@ export function WakeupsSection({{t(($) => $.wakeups.closed_hint)}</p>)}- {!closed &&- systemRules.map((rule) => (- <SystemWakeupRow key={rule.rule} rule={rule} workspaceId={workspaceId} issueId={issueId} />- ))}+ {currentSystemRules.map(systemRow)}{current.map(row)}- {history.length > 0 && (+ {historyCount > 0 && (<><buttontype="button"@@ -463,9 +473,14 @@ export function WakeupsSection({className={`size-3 ${historyOpen ? "rotate-90" : ""}`}aria-hidden="true"/>- {t(($) => $.wakeups.ended, { count: history.length })}+ {t(($) => $.wakeups.ended, { count: historyCount })}</button>- {historyOpen && history.map(row)}+ {historyOpen && (+ <>+ {offSystemRules.map(systemRow)}+ {history.map(row)}+ </>+ )}</>)}</div>