fix(automations): allow scrolling overflowing schedule and run lists (#7901)

The list frame's overflow: hidden let it shrink to the editor height, so rows past the fold were clipped instead of scrolled. The header and tabs now stay pinned above a dedicated scroll body, the footer stays pinned below it, the scroll position resets on tab switch, and a deep-linked schedule row scrolls into view.

Co-authored-by: dengliu <[email protected]>
Цей коміт міститься в:
Deng Liuтаdengliu authored and GitHub committed 2026-12-04 09:46:43 +08:00
1 джерело 5ec05b3aca
коміт 9ad7f91c04
5 files changed
+555 -276

No files matched your search

+138
Переглянути файл
@@ -1760,3 +1760,141 @@ test("configures effort level and context window in Edit Automation dialog and p
await row.getByRole("button", { name: "Edit Automation" }).click();
await expect(dialog.getByRole("button", { name: /^Model settings:/ })).toContainText("Extra High · 1M");
});
test("scrolls overflowing Schedules and Run History lists without clipping while keeping header, tabs, and footer pinned", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 1120, height: 680 });
await installAutomationDesktopHarness(page);
const ids = await page.evaluate(async () => {
const autoMod = "/src/features/agents/automationsModel.ts";
const { openAutomations, refreshAutomations } = await import(/* @vite-ignore */ autoMod);
const createdIds: string[] = [];
const now = Date.now();
for (let i = 1; i <= 10; i++) {
const saved = (await window.__ipc.handlers.agent_automation_save!({
input: {
name: `Daily Workflow ${i} (Self-Scheduling)`,
enabled: true,
prompt: {
text: `Run recurring workflow #${i} and inspect CI, repository status, and pending follow-ups.`,
files: [],
images: [],
},
workspace: { kind: "project", root: "/dev/acme-api", isolation: "local", autoCleanWorktree: false },
continuity: "sameTask",
provider: "claude",
config: [],
permissions: "allowAll",
trigger: { kind: "daily", hour: (8 + i) % 24, minute: 0, timeZone: "UTC" },
allowAgentSchedule: i % 2 === 1,
},
})) as AgentAutomation_Serialize;
createdIds.push(saved.id);
if (i <= 3) {
window.__ipc.handlers.__test_set_override!({
id: saved.id,
nextRunOverrideMs: now + i * 1_800_000,
nextPromptOverride: `Follow up on workflow #${i} after cooldown completes.`,
});
}
}
// Trigger runs across automations so Run History also overflows the viewport.
for (let i = 0; i < 10; i++) {
await window.__ipc.handlers.agent_automation_run_now!({ id: createdIds[i % createdIds.length]! });
await window.__ipc.handlers.agent_automation_run_now!({ id: createdIds[i % createdIds.length]! });
}
await refreshAutomations();
await openAutomations({ tab: "schedules" });
return createdIds;
});
const editor = page.getByTestId("automations-editor");
const scrollBody = page.getByTestId("automations-scroll-body");
await expect(editor).toBeVisible();
await expect(editor.locator('[data-testid^="automation-row-"]')).toHaveCount(10);
// 1. Scroll container must overflow vertically, and the framed list must NOT clip its rows.
const schedulesMetrics = await scrollBody.evaluate((el) => {
const firstRow = el.querySelector<HTMLElement>('[data-testid^="automation-row-"]');
const listFrame = firstRow?.parentElement;
return {
clientHeight: el.clientHeight,
scrollHeight: el.scrollHeight,
listClientHeight: listFrame?.clientHeight ?? 0,
listScrollHeight: listFrame?.scrollHeight ?? 0,
};
});
expect(schedulesMetrics.scrollHeight).toBeGreaterThan(schedulesMetrics.clientHeight + 100);
expect(schedulesMetrics.listScrollHeight).toBeLessThanOrEqual(schedulesMetrics.listClientHeight + 1);
// 2. Scroll to the bottom -> last row is fully reachable & clickable while header, tabs, and footer stay pinned.
const rows = editor.locator('[data-testid^="automation-row-"]');
const lastRow = rows.last();
const lastRowId = (await lastRow.getAttribute("data-testid"))!.replace("automation-row-", "");
await scrollBody.evaluate((el) => {
el.scrollTop = el.scrollHeight;
});
const afterScroll = await scrollBody.evaluate((el) => ({
scrollTop: el.scrollTop,
rect: el.getBoundingClientRect(),
}));
expect(afterScroll.scrollTop).toBeGreaterThan(100);
const lastRowBox = await lastRow.boundingBox();
expect(lastRowBox).not.toBeNull();
expect(lastRowBox!.y).toBeGreaterThanOrEqual(afterScroll.rect.y - 1);
expect(lastRowBox!.y + lastRowBox!.height).toBeLessThanOrEqual(afterScroll.rect.y + afterScroll.rect.height + 1);
// Pinned chrome remains visible inside the editor while scrolled to the bottom.
const editorBox = (await editor.boundingBox())!;
const newBtnBox = (await editor.getByRole("button", { name: "New Automation" }).boundingBox())!;
const footerBox = (await editor.getByRole("checkbox", { name: /Keep automations running/ }).boundingBox())!;
expect(newBtnBox.y).toBeGreaterThanOrEqual(editorBox.y);
expect(newBtnBox.y + newBtnBox.height).toBeLessThanOrEqual(afterScroll.rect.y + 1);
expect(footerBox.y).toBeGreaterThanOrEqual(afterScroll.rect.y + afterScroll.rect.height - 1);
expect(footerBox.y + footerBox.height).toBeLessThanOrEqual(editorBox.y + editorBox.height + 1);
// Bottom row action button is genuinely interactive.
await lastRow.getByRole("button", { name: "Edit Automation" }).click();
await expect(page.getByRole("dialog", { name: "Edit Automation" })).toBeVisible();
await page.keyboard.press("Escape");
await expect(page.getByRole("dialog", { name: "Edit Automation" })).toHaveCount(0);
// 3. Switch to Run History -> scroll resets to top and Run History also scrolls cleanly to its last run.
await editor.getByRole("tab", { name: /Run History/ }).click();
await expect(editor.locator('[data-testid^="automation-run-"]')).toHaveCount(20);
await expect.poll(() => scrollBody.evaluate((el) => el.scrollTop)).toBe(0);
const runsMetrics = await scrollBody.evaluate((el) => ({
clientHeight: el.clientHeight,
scrollHeight: el.scrollHeight,
}));
expect(runsMetrics.scrollHeight).toBeGreaterThan(runsMetrics.clientHeight + 100);
await scrollBody.evaluate((el) => {
el.scrollTop = el.scrollHeight;
});
const lastRunBox = (await editor.locator('[data-testid^="automation-run-"]').last().boundingBox())!;
const runsRect = await scrollBody.evaluate((el) => el.getBoundingClientRect());
expect(lastRunBox.y + lastRunBox.height).toBeLessThanOrEqual(runsRect.y + runsRect.height + 1);
// 4. Deep-linking back to the bottom-most schedule scrolls that focused row into view automatically.
expect(ids).toContain(lastRowId);
await page.evaluate(async (targetId) => {
const autoMod = "/src/features/agents/automationsModel.ts";
const { openAutomations } = await import(/* @vite-ignore */ autoMod);
openAutomations({ tab: "schedules", automationId: targetId });
}, lastRowId);
await expect.poll(() => scrollBody.evaluate((el) => el.scrollTop)).toBeGreaterThan(100);
const focusedBox = (await editor.getByTestId(`automation-row-${lastRowId}`).boundingBox())!;
const schedulesRect = await scrollBody.evaluate((el) => el.getBoundingClientRect());
expect(focusedBox.y).toBeGreaterThanOrEqual(schedulesRect.y - 1);
expect(focusedBox.y + focusedBox.height).toBeLessThanOrEqual(schedulesRect.y + schedulesRect.height + 1);
});
+84 -23
Переглянути файл
@@ -5,22 +5,30 @@
flex-direction: column;
height: 100%;
min-height: 0;
overflow-y: auto;
overflow: hidden;
container-type: inline-size;
background: var(--bg-editor);
color: var(--fg);
font-size: var(--fs-ui);
}
.column {
display: flex;
flex-direction: column;
flex: 1;
width: 100%;
max-width: 820px;
margin: 0 auto;
padding: 20px 28px 24px;
padding: 0 28px;
box-sizing: border-box;
min-height: 0;
}
.topChrome {
flex: none;
border-bottom: 1px solid var(--border);
}
.topChrome .column {
display: flex;
flex-direction: column;
padding-top: 20px;
}
.header {
@@ -92,7 +100,6 @@
flex-wrap: wrap;
gap: var(--space-2);
padding-bottom: 8px;
border-bottom: 1px solid var(--border);
}
.navControls {
@@ -127,7 +134,6 @@
align-items: center;
justify-content: space-between;
gap: var(--space-2);
margin-bottom: 12px;
padding: 8px 12px;
border-radius: var(--radius-control);
background: var(--bg-elev);
@@ -143,35 +149,41 @@
min-width: 0;
}
.body {
.scrollBody {
flex: 1;
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
}
.body {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: 16px 0 20px;
min-height: 0;
padding-top: 16px;
padding-bottom: 24px;
}
/* Framed list with hairline dividers, matching Settings > Agents > Skills. */
.listFrame {
display: flex;
flex-direction: column;
flex-shrink: 0;
border: 1px solid var(--border);
border-radius: var(--radius-control);
background: var(--bg-editor);
box-shadow: inset 0 0 0 1px var(--border);
overflow: hidden;
}
.row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: var(--space-3);
gap: var(--space-2);
padding: 10px 12px;
}
.row + .row {
box-shadow: inset 0 1px 0 var(--border);
border-top: 1px solid var(--border);
}
.row:hover {
@@ -183,12 +195,16 @@
box-shadow: inset 2px 0 0 var(--accent);
}
.rowLeft {
display: flex;
align-items: flex-start;
.rowCenter {
justify-content: center;
}
.rowLeading {
display: inline-flex;
align-items: center;
gap: var(--space-2);
flex: 1;
min-width: 0;
flex-shrink: 0;
height: 24px;
}
.rowContent {
@@ -199,12 +215,22 @@
flex: 1;
}
.rowTop {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: var(--space-2);
min-width: 0;
}
.rowTitleLine {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--space-1-5);
flex: 1;
min-width: 0;
min-height: 24px;
}
.rowTitle {
@@ -325,7 +351,7 @@
}
.templateRow + .templateRow {
box-shadow: inset 0 1px 0 var(--border);
border-top: 1px solid var(--border);
}
.templateRow:hover {
@@ -355,17 +381,52 @@
color: var(--fg-muted);
}
.footer {
flex: none;
border-top: 1px solid var(--border);
}
.footerBar {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-2);
padding-top: 12px;
border-top: 1px solid var(--border);
padding-top: 10px;
padding-bottom: 10px;
color: var(--fg-secondary);
font-size: var(--fs-small);
}
@container (max-width: 560px) {
.column {
padding-inline: var(--space-4);
}
.topChrome .column {
padding-top: var(--space-3);
}
}
@container (max-width: 440px) {
.header {
flex-wrap: wrap;
}
.navControls {
width: 100%;
margin-left: 0;
}
.searchWrap {
flex: 1 1 160px;
width: auto;
}
.rowTop {
flex-wrap: wrap;
}
}
/* Dialog form (aligned to Dialog's 16px titlebar / footer insets). */
.dialogForm {
display: flex;
+281 -252
Переглянути файл
@@ -4,7 +4,7 @@
* open any background run directly in `SessionEditor`.
*/
import clsx from "clsx";
import { useMemo, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import type { AgentAutomation_Serialize, AutomationRun_Serialize } from "@/bindings";
import { executeAction } from "@/platform/actions";
import { useTx } from "@/platform/i18n";
@@ -81,6 +81,10 @@ export function AutomationsEditor({
const loadError = useAutomations((s) => s.error);
const activeTab = useAutomations((s) => s.activeTab);
const focusAutomationId = useAutomations((s) => s.focusAutomationId);
const focusSeq = useAutomations((s) => s.focusSeq);
const scrollBodyRef = useRef<HTMLDivElement>(null);
const rowRefs = useRef<Map<string, HTMLDivElement>>(new Map());
const lastScrolledFocusRef = useRef<string | null>(null);
const untrustedProject = Boolean(project && !project.trusted);
const [autoStartOverride, setAutoStartOverride] = useState<boolean | null>(null);
const autoStartEnabled = Boolean(autoStartOverride ?? agentSettings.automations.autoStartService);
@@ -122,6 +126,20 @@ export function AutomationsEditor({
});
}, [snapshot.runs, query, runFilter]);
useEffect(() => {
if (scrollBodyRef.current) scrollBodyRef.current.scrollTop = 0;
}, [activeTab]);
useEffect(() => {
if (activeTab !== "schedules" || !focusAutomationId) return;
const token = `${focusSeq}:${focusAutomationId}`;
if (lastScrolledFocusRef.current === token) return;
const el = rowRefs.current.get(focusAutomationId);
if (!el) return;
lastScrolledFocusRef.current = token;
el.scrollIntoView?.({ block: "nearest" });
}, [activeTab, focusAutomationId, focusSeq, filteredAutomations]);
const handleToggleEnabled = async (auto: AgentAutomation_Serialize) => {
setBusyId(auto.id);
try {
@@ -376,140 +394,144 @@ export function AutomationsEditor({
return (
<div className={styles.editor} data-testid="automations-editor">
<div className={styles.column}>
<header className={styles.header}>
<div className={styles.headerMain}>
<h2 className={styles.headerTitle}>
<T>Agent Automations</T>
</h2>
<span className={styles.hostMeta} data-testid="scheduler-host-pill">
<span
className={clsx(styles.statusDot, host.activeSchedules > 0 && styles.statusDotOn)}
aria-hidden="true"
/>
{host.remote && <Icon name="remote" size={12} />}
<span>{host.remote ? tx("Remote Daemon") : tx("Local Host")}</span>
<span>·</span>
<span>
{host.activeSchedules === 1 ? tx("1 active schedule") : tx`${host.activeSchedules} active schedules`}
<div className={styles.topChrome}>
<div className={styles.column}>
<header className={styles.header}>
<div className={styles.headerMain}>
<h2 className={styles.headerTitle}>
<T>Agent Automations</T>
</h2>
<span className={styles.hostMeta} data-testid="scheduler-host-pill">
<span
className={clsx(styles.statusDot, host.activeSchedules > 0 && styles.statusDotOn)}
aria-hidden="true"
/>
{host.remote && <Icon name="remote" size={12} />}
<span>{host.remote ? tx("Remote Daemon") : tx("Local Host")}</span>
<span>·</span>
<span>
{host.activeSchedules === 1 ? tx("1 active schedule") : tx`${host.activeSchedules} active schedules`}
</span>
{host.bootServiceRegistered && (
<>
<span>·</span>
<span>
<T>Auto-starts on login</T>
</span>
</>
)}
</span>
{host.bootServiceRegistered && (
</div>
<div className={styles.headerActions}>
<Button
variant="primary"
size="small"
icon="plus"
disabled={untrustedProject}
onClick={() => openAutomationDialog()}
>
<T>New Automation</T>
</Button>
<IconButton
icon="settings"
title="Automation Settings"
onClick={() => void executeAction("file.settings", AUTOMATIONS_PAGE)}
/>
<IconButton icon="more" title="Options" onClick={(e) => showContextMenu(e, headerMoreMenu())} />
</div>
</header>
<div className={styles.navRow}>
<Tabs
variant="compact"
activeId={activeTab}
onSelect={(id) => setAutomationsTab(id as "schedules" | "runs")}
items={[
{
id: "schedules",
label: <T>Schedules</T>,
text: "Schedules",
trailing: snapshot.automations.length ? (
<span className={styles.tabBadge}>{snapshot.automations.length}</span>
) : undefined,
},
{
id: "runs",
label: <T>Run History</T>,
text: "Run History",
trailing:
host.unreadRuns > 0 ? (
<span className={clsx(styles.tag, styles.tagUnread)}>{host.unreadRuns}</span>
) : snapshot.runs.length ? (
<span className={styles.tabBadge}>{snapshot.runs.length}</span>
) : undefined,
},
]}
/>
<div className={styles.navControls}>
<div className={styles.searchWrap}>
<SearchField
value={query}
onChange={setQuery}
clearable
placeholder={tx("Filter automations and runs")}
aria-label={tx("Filter automations and runs")}
/>
</div>
{activeTab === "runs" && (
<>
<span>·</span>
<span>
<T>Auto-starts on login</T>
</span>
<Select
variant="ghost"
aria-label={tx("Run filter")}
value={runFilter}
options={[
{ value: "all", label: tx("All runs") },
{ value: "unread", label: tx("Unread only") },
{ value: "needsInput", label: tx("Waiting for input") },
]}
onChange={(v) => setRunFilter(v as "all" | "unread" | "needsInput")}
/>
{host.unreadRuns > 0 && (
<Button size="small" icon="check" onClick={() => void handleMarkAllRead()}>
<T>Mark All as Read</T>
</Button>
)}
</>
)}
</span>
</div>
<div className={styles.headerActions}>
<Button
variant="primary"
size="small"
icon="plus"
disabled={untrustedProject}
onClick={() => openAutomationDialog()}
>
<T>New Automation</T>
</Button>
<IconButton
icon="settings"
title="Automation Settings"
onClick={() => void executeAction("file.settings", AUTOMATIONS_PAGE)}
/>
<IconButton icon="more" title="Options" onClick={(e) => showContextMenu(e, headerMoreMenu())} />
</div>
</header>
{loadError && (
<div className={styles.errorBox} style={{ marginBottom: 12 }} role="alert">
<Icon name="error" size={14} />
<span>{loadError}</span>
</div>
)}
{host.bootServiceError && (
<div className={styles.errorBox} style={{ marginBottom: 12 }} role="alert">
<Icon name="warning" size={14} />
<span>{host.bootServiceError}</span>
</div>
)}
{untrustedProject && (
<div className={styles.bannerWarn} role="status">
<div className={styles.bannerLeft}>
<Icon name="warning" size={14} />
<span>
<T>This project is untrusted. Workspace automations stay paused until you trust the project.</T>
</span>
</div>
</div>
)}
<div className={styles.navRow}>
<Tabs
variant="compact"
activeId={activeTab}
onSelect={(id) => setAutomationsTab(id as "schedules" | "runs")}
items={[
{
id: "schedules",
label: <T>Schedules</T>,
text: "Schedules",
trailing: snapshot.automations.length ? (
<span className={styles.tabBadge}>{snapshot.automations.length}</span>
) : undefined,
},
{
id: "runs",
label: <T>Run History</T>,
text: "Run History",
trailing:
host.unreadRuns > 0 ? (
<span className={clsx(styles.tag, styles.tagUnread)}>{host.unreadRuns}</span>
) : snapshot.runs.length ? (
<span className={styles.tabBadge}>{snapshot.runs.length}</span>
) : undefined,
},
]}
/>
<div className={styles.navControls}>
<div className={styles.searchWrap}>
<SearchField
value={query}
onChange={setQuery}
clearable
placeholder={tx("Filter automations and runs")}
aria-label={tx("Filter automations and runs")}
/>
</div>
{activeTab === "runs" && (
<>
<Select
variant="ghost"
aria-label={tx("Run filter")}
value={runFilter}
options={[
{ value: "all", label: tx("All runs") },
{ value: "unread", label: tx("Unread only") },
{ value: "needsInput", label: tx("Waiting for input") },
]}
onChange={(v) => setRunFilter(v as "all" | "unread" | "needsInput")}
/>
{host.unreadRuns > 0 && (
<Button size="small" icon="check" onClick={() => void handleMarkAllRead()}>
<T>Mark All as Read</T>
</Button>
)}
</>
)}
</div>
</div>
</div>
<div ref={scrollBodyRef} className={styles.scrollBody} data-testid="automations-scroll-body">
<div className={clsx(styles.column, styles.body)}>
{loadError && (
<div className={styles.errorBox} role="alert">
<Icon name="error" size={14} />
<span>{loadError}</span>
</div>
)}
{host.bootServiceError && (
<div className={styles.errorBox} role="alert">
<Icon name="warning" size={14} />
<span>{host.bootServiceError}</span>
</div>
)}
{untrustedProject && (
<div className={styles.bannerWarn} role="status">
<div className={styles.bannerLeft}>
<Icon name="warning" size={14} />
<span>
<T>This project is untrusted. Workspace automations stay paused until you trust the project.</T>
</span>
</div>
</div>
)}
<div className={styles.body}>
{activeTab === "schedules" ? (
filteredAutomations.length === 0 ? (
<div className={styles.emptySection}>
@@ -550,20 +572,25 @@ export function AutomationsEditor({
{filteredAutomations.map((auto) => (
<div
key={auto.id}
ref={(el) => {
if (el) rowRefs.current.set(auto.id, el);
else rowRefs.current.delete(auto.id);
}}
data-testid={`automation-row-${auto.id}`}
className={clsx(styles.row, focusAutomationId === auto.id && styles.rowFocused)}
onContextMenu={(e) => showContextMenu(e, automationMenu(auto))}
>
<div className={styles.rowLeft}>
<div className={styles.rowLeading}>
<span
className={clsx(styles.statusDot, isAutomationActivelyScheduled(auto) && styles.statusDotOn)}
style={{ marginTop: 6 }}
title={
isAutomationActivelyScheduled(auto) ? tx("Active") : auto.enabled ? tx("Idle") : tx("Paused")
}
/>
<Icon name={providerIcon(auto.provider)} size={16} label={providerName(auto.provider)} />
<div className={styles.rowContent}>
</div>
<div className={styles.rowContent}>
<div className={styles.rowTop}>
<div className={styles.rowTitleLine}>
<span className={styles.rowTitle}>{auto.name}</span>
<span className={styles.rowSchedule}>{describeTrigger(auto.trigger, tx)}</span>
@@ -583,81 +610,80 @@ export function AutomationsEditor({
</span>
)}
</div>
<div className={styles.rowPrompt}>{auto.prompt.text}</div>
{auto.nextRunOverrideMs != null && (
<div className={styles.overrideInline} data-testid={`automation-override-${auto.id}`}>
<strong>
<T>Next run override:</T>
</strong>{" "}
{formatShortTimestamp(auto.nextRunOverrideMs)}
{auto.nextPromptOverride ? ` — “${auto.nextPromptOverride}”` : ""}
</div>
)}
{auto.pausedReason && (
<div className={styles.fieldHint} style={{ color: "var(--warning)" }}>
{auto.pausedReason}
</div>
)}
<div className={styles.rowMeta}>
<span>{providerName(auto.provider)}</span>
<span>·</span>
<span>
{auto.workspace.kind === "chatOnly"
? tx("Chat only")
: auto.workspace.isolation === "worktree"
? `${basename(auto.workspace.root)} · ${tx("Worktree")}`
: `${basename(auto.workspace.root)} · ${tx("Local checkout")}`}
</span>
<span>·</span>
<span>{auto.continuity === "sameTask" ? tx("Rolling session") : tx("Fresh session")}</span>
{auto.enabled && auto.nextRunMs ? (
<>
<span>·</span>
<span>
{auto.nextRunOverrideMs != null ? <T>Next (by agent):</T> : <T>Next:</T>}{" "}
{formatShortTimestamp(auto.nextRunMs)}
</span>
</>
) : null}
{auto.maxRuns ? (
<>
<span>·</span>
<span>
{auto.runCount}/{auto.maxRuns} <T>runs</T>
</span>
</>
) : null}
<div className={styles.rowActions}>
<Button
size="small"
icon="run"
disabled={busyId === auto.id || untrustedProject}
onClick={() => void handleRunNow(auto)}
>
<T>Run Now</T>
</Button>
<IconButton
icon={auto.enabled ? "pause" : "resume"}
title={auto.enabled ? "Pause Schedule" : "Resume Schedule"}
disabled={busyId === auto.id || untrustedProject}
onClick={() => void handleToggleEnabled(auto)}
/>
<IconButton
icon="edit"
title="Edit Automation"
disabled={untrustedProject}
onClick={() => openAutomationDialog({ editing: auto })}
/>
<IconButton
icon="more"
title="More Actions"
disabled={untrustedProject}
onClick={(e) => showContextMenu(e, automationMenu(auto))}
/>
</div>
</div>
</div>
<div className={styles.rowActions}>
<Button
size="small"
icon="run"
disabled={busyId === auto.id || untrustedProject}
onClick={() => void handleRunNow(auto)}
>
<T>Run Now</T>
</Button>
<IconButton
icon={auto.enabled ? "pause" : "resume"}
title={auto.enabled ? "Pause Schedule" : "Resume Schedule"}
disabled={busyId === auto.id || untrustedProject}
onClick={() => void handleToggleEnabled(auto)}
/>
<IconButton
icon="edit"
title="Edit Automation"
disabled={untrustedProject}
onClick={() => openAutomationDialog({ editing: auto })}
/>
<IconButton
icon="more"
title="More Actions"
disabled={untrustedProject}
onClick={(e) => showContextMenu(e, automationMenu(auto))}
/>
<div className={styles.rowPrompt}>{auto.prompt.text}</div>
{auto.nextRunOverrideMs != null && (
<div className={styles.overrideInline} data-testid={`automation-override-${auto.id}`}>
<strong>
<T>Next run override:</T>
</strong>{" "}
{formatShortTimestamp(auto.nextRunOverrideMs)}
{auto.nextPromptOverride ? ` — “${auto.nextPromptOverride}”` : ""}
</div>
)}
{auto.pausedReason && (
<div className={styles.fieldHint} style={{ color: "var(--warning)" }}>
{auto.pausedReason}
</div>
)}
<div className={styles.rowMeta}>
<span>{providerName(auto.provider)}</span>
<span>·</span>
<span>
{auto.workspace.kind === "chatOnly"
? tx("Chat only")
: auto.workspace.isolation === "worktree"
? `${basename(auto.workspace.root)} · ${tx("Worktree")}`
: `${basename(auto.workspace.root)} · ${tx("Local checkout")}`}
</span>
<span>·</span>
<span>{auto.continuity === "sameTask" ? tx("Rolling session") : tx("Fresh session")}</span>
{auto.enabled && auto.nextRunMs ? (
<>
<span>·</span>
<span>
{auto.nextRunOverrideMs != null ? <T>Next (by agent):</T> : <T>Next:</T>}{" "}
{formatShortTimestamp(auto.nextRunMs)}
</span>
</>
) : null}
{auto.maxRuns ? (
<>
<span>·</span>
<span>
{auto.runCount}/{auto.maxRuns} <T>runs</T>
</span>
</>
) : null}
</div>
</div>
</div>
))}
@@ -686,9 +712,11 @@ export function AutomationsEditor({
className={styles.row}
onClick={() => void handleOpenRun(run)}
>
<div className={styles.rowLeft}>
<div className={styles.rowLeading}>
<RunStatusGlyph status={run.status} />
<div className={styles.rowContent}>
</div>
<div className={styles.rowContent}>
<div className={styles.rowTop}>
<div className={styles.rowTitleLine}>
<span className={styles.rowTitle}>
{run.automationName} <span className={styles.mono}>#{run.runNumber}</span>
@@ -710,58 +738,57 @@ export function AutomationsEditor({
</span>
)}
</div>
{run.error && (
<div className={styles.rowPrompt} style={{ color: "var(--danger)" }}>
{run.error}
</div>
)}
<div className={styles.rowMeta}>
<span>{formatShortTimestamp(run.startedMs)}</span>
<span>·</span>
<span>{run.origin.kind === "manual" ? tx("Manual run") : tx("Scheduled run")}</span>
{run.branch && (
<>
<span>·</span>
<span className={styles.mono}>{run.branch}</span>
</>
<div className={styles.rowActions} onClick={(e) => e.stopPropagation()}>
{run.unread && (
<IconButton
icon="check"
title="Mark as Read"
onClick={() => void backend.markRead(run.id, null).then(() => refreshAutomations(backend))}
/>
)}
{(run.added > 0 || run.removed > 0) && (
<>
<span>·</span>
<span className={styles.diffAdded}>+{run.added}</span>
<span className={styles.diffRemoved}>-{run.removed}</span>
</>
)}
{run.worktreeCleaned && (
<>
<span>·</span>
<span>
<T>Zero-diff worktree cleaned</T>
</span>
</>
{run.taskId && (
<Button size="small" onClick={() => void handleOpenRun(run)}>
<T>Open Session</T>
</Button>
)}
</div>
</div>
</div>
<div className={styles.rowActions} onClick={(e) => e.stopPropagation()}>
{run.unread && (
<IconButton
icon="check"
title="Mark as Read"
onClick={() => void backend.markRead(run.id, null).then(() => refreshAutomations(backend))}
/>
)}
{run.taskId && (
<Button size="small" onClick={() => void handleOpenRun(run)}>
<T>Open Session</T>
</Button>
{run.error && (
<div className={styles.rowPrompt} style={{ color: "var(--danger)" }}>
{run.error}
</div>
)}
<div className={styles.rowMeta}>
<span>{formatShortTimestamp(run.startedMs)}</span>
<span>·</span>
<span>{run.origin.kind === "manual" ? tx("Manual run") : tx("Scheduled run")}</span>
{run.branch && (
<>
<span>·</span>
<span className={styles.mono}>{run.branch}</span>
</>
)}
{(run.added > 0 || run.removed > 0) && (
<>
<span>·</span>
<span className={styles.diffAdded}>+{run.added}</span>
<span className={styles.diffRemoved}>-{run.removed}</span>
</>
)}
{run.worktreeCleaned && (
<>
<span>·</span>
<span>
<T>Zero-diff worktree cleaned</T>
</span>
</>
)}
</div>
</div>
</div>
))}
{snapshot.runsNextCursor != null && (
<div className={styles.row} style={{ justifyContent: "center" }}>
<div className={clsx(styles.row, styles.rowCenter)}>
<Button size="small" onClick={() => void loadMoreRuns(backend)}>
<T>Show more</T>
</Button>
@@ -770,17 +797,19 @@ export function AutomationsEditor({
</div>
)}
</div>
</div>
{activeTab === "schedules" && (
<div className={styles.footerBar}>
{activeTab === "schedules" && (
<footer className={styles.footer}>
<div className={clsx(styles.column, styles.footerBar)}>
<Checkbox
checked={autoStartEnabled}
onChange={(v) => void handleToggleAutoStart(v)}
label="Keep automations running when OpenIDEA is closed"
/>
</div>
)}
</div>
</footer>
)}
<Dialog
open={importOpen}
+49 -1
Переглянути файл
@@ -217,7 +217,12 @@ function makeMockBackend(initial?: Partial<AutomationSnapshot_Serialize>): {
afterEach(() => {
closeAutomationDialog();
setAutomationsTab("schedules");
useAutomations.setState({ loaded: false, snapshot: structuredClone(EMPTY_AUTOMATION_SNAPSHOT) });
useAutomations.setState({
loaded: false,
focusAutomationId: null,
focusSeq: 0,
snapshot: structuredClone(EMPTY_AUTOMATION_SNAPSHOT),
});
useAgents.setState({
providers: [],
modelCatalogs: new Map(),
@@ -974,4 +979,47 @@ describe("Agent Automations model & UI", () => {
),
);
});
it("resets scroll position on tab switch and scrolls focused schedule rows into view", async () => {
const now = Date.now();
const automations: AgentAutomation_Serialize[] = Array.from({ length: 6 }, (_, i) => ({
id: `auto-${i + 1}`,
name: `Schedule ${i + 1}`,
enabled: true,
prompt: { text: `Run task ${i + 1}`, files: [], images: [] },
workspace: { kind: "chatOnly" },
continuity: "newTask",
provider: "claude",
config: [],
permissions: "assisted",
trigger: { kind: "daily", hour: 9 + i, minute: 0, timeZone: "UTC" },
allowAgentSchedule: false,
nextRunMs: now + (i + 1) * 3_600_000,
runCount: 0,
unreadRuns: 0,
createdMs: now - 10_000,
updatedMs: now - 10_000,
}));
const { backend } = makeMockBackend({ automations });
render(<AutomationsEditor backend={backend} />);
await waitFor(() => expect(screen.getByTestId("automation-row-auto-6")).toBeTruthy());
const targetRow = screen.getByTestId("automation-row-auto-6");
const scrollIntoView = vi.fn();
targetRow.scrollIntoView = scrollIntoView;
useAutomations.setState((s) => ({ focusAutomationId: "auto-6", focusSeq: s.focusSeq + 1 }));
await waitFor(() => expect(scrollIntoView).toHaveBeenCalledTimes(1));
expect(scrollIntoView).toHaveBeenCalledWith({ block: "nearest" });
// Re-focusing the same schedule increments focusSeq and scrolls again.
useAutomations.setState((s) => ({ focusAutomationId: "auto-6", focusSeq: s.focusSeq + 1 }));
await waitFor(() => expect(scrollIntoView).toHaveBeenCalledTimes(2));
// Switching tabs resets scrollTop on the dedicated scroll body.
const scrollBody = screen.getByTestId("automations-scroll-body");
scrollBody.scrollTop = 240;
setAutomationsTab("runs");
await waitFor(() => expect(scrollBody.scrollTop).toBe(0));
});
});
+3
Переглянути файл
@@ -674,6 +674,7 @@ interface AutomationsState {
snapshot: AutomationSnapshot_Serialize;
activeTab: "schedules" | "runs";
focusAutomationId: string | null;
focusSeq: number;
automatedRunFilter: AutomatedRunFilter;
dialog: AutomationDialogRequest;
}
@@ -684,6 +685,7 @@ export const useAutomations = create<AutomationsState>(() => ({
snapshot: EMPTY_AUTOMATION_SNAPSHOT,
activeTab: "schedules",
focusAutomationId: null,
focusSeq: 0,
automatedRunFilter: typeof window === "undefined" ? "attention" : readStoredFilter(),
dialog: {
open: false,
@@ -712,6 +714,7 @@ export function openAutomations(opts?: { tab?: "schedules" | "runs"; automationI
useAutomations.setState((s) => ({
activeTab: opts.tab ?? s.activeTab,
focusAutomationId: opts.automationId ?? null,
focusSeq: opts.automationId ? s.focusSeq + 1 : s.focusSeq,
}));
}
void editorService().openInput({