Skip to content

Commit 24aebe4

Browse files
refactor(ui): flatten tasks page layout
Co-authored-by: Tak Hoffman <[email protected]>
1 parent b4c620b commit 24aebe4

6 files changed

Lines changed: 303 additions & 307 deletions

File tree

‎ui/src/lib/tasks/data.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,10 @@ const STATUS_LABEL_KEYS = {
3030
timed_out: "tasksPage.status.timedOut",
3131
} as const satisfies Record<TaskStatus, string>;
3232

33-
const STATUS_CHIP_CLASSES = {
34-
queued: "chip-warn",
35-
running: "chip-warn",
36-
completed: "chip-ok",
37-
failed: "chip-danger",
38-
cancelled: "",
39-
timed_out: "chip-danger",
40-
} as const satisfies Record<TaskStatus, string>;
41-
4233
export function taskStatusLabel(status: TaskStatus): string {
4334
return t(STATUS_LABEL_KEYS[status]);
4435
}
4536

46-
export function taskStatusChipClass(status: TaskStatus): string {
47-
return STATUS_CHIP_CLASSES[status];
48-
}
49-
5037
export function taskRuntimeLabel(task: TaskSummary): string {
5138
switch (task.runtime) {
5239
case "subagent":

‎ui/src/pages/tasks/tasks-page.ts‎

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { titleForRoute } from "../../app-navigation.ts";
77
import { applicationContext, type ApplicationContext } from "../../app/context.ts";
88
import { hasOperatorReadAccess, hasOperatorWriteAccess } from "../../app/operator-access.ts";
99
import { renderAgentScopeControl } from "../../components/agent-scope-control.ts";
10+
import { renderSettingsWorkspace } from "../../components/settings-workspace.ts";
1011
import { t } from "../../i18n/index.ts";
1112
import { watchAgentScope } from "../../lib/agents/index.ts";
1213
import { copyToClipboard } from "../../lib/clipboard.ts";
@@ -416,40 +417,42 @@ class TasksPage extends OpenClawLightDomElement {
416417
</button>
417418
</div>
418419
</section>
419-
${renderTasks({
420-
basePath: this.context.basePath,
421-
agentId: fallbackAgentId,
422-
mainKey: resolveUiConfiguredMainKey({
423-
agentsList: this.context.agents.state.agentsList,
424-
hello: this.context.gateway.snapshot.hello,
425-
}),
426-
connected: this.gateway.connected,
427-
canCopy: hasOperatorReadAccess(this.context.gateway.snapshot.hello?.auth ?? null),
428-
// Task mutations need operator.write; read-only operators get no mutation buttons.
429-
canCancel: hasOperatorWriteAccess(this.context.gateway.snapshot.hello?.auth ?? null),
430-
loading: this.listTask.status === TaskStatus.PENDING,
431-
error: this.error,
432-
copyResultError: this.copyResultError,
433-
tasks: this.tasks,
434-
cancellingTaskIds: this.cancellingTaskIds,
435-
sessionRow: (sessionKey) => findUiSessionRow(this.context, sessionKey),
436-
onCancel: (taskId) => void this.cancelTask(taskId),
437-
onRetry: (taskId) => void this.recoverTask(taskId, "retry"),
438-
onDismiss: (taskId) => void this.recoverTask(taskId, "dismiss"),
439-
onCopyResult: (taskId) => void this.copyTaskResult(taskId),
440-
onNavigateToChat: (sessionKey) => {
441-
const face = resolveSessionPreferredFaceForKey(this.context, sessionKey);
442-
this.context.navigate(
443-
face,
444-
sessionNavigationTarget({
445-
context: this.context,
420+
${renderSettingsWorkspace(
421+
renderTasks({
422+
basePath: this.context.basePath,
423+
agentId: fallbackAgentId,
424+
mainKey: resolveUiConfiguredMainKey({
425+
agentsList: this.context.agents.state.agentsList,
426+
hello: this.context.gateway.snapshot.hello,
427+
}),
428+
connected: this.gateway.connected,
429+
canCopy: hasOperatorReadAccess(this.context.gateway.snapshot.hello?.auth ?? null),
430+
// Task mutations need operator.write; read-only operators get no mutation buttons.
431+
canCancel: hasOperatorWriteAccess(this.context.gateway.snapshot.hello?.auth ?? null),
432+
loading: this.listTask.status === TaskStatus.PENDING,
433+
error: this.error,
434+
copyResultError: this.copyResultError,
435+
tasks: this.tasks,
436+
cancellingTaskIds: this.cancellingTaskIds,
437+
sessionRow: (sessionKey) => findUiSessionRow(this.context, sessionKey),
438+
onCancel: (taskId) => void this.cancelTask(taskId),
439+
onRetry: (taskId) => void this.recoverTask(taskId, "retry"),
440+
onDismiss: (taskId) => void this.recoverTask(taskId, "dismiss"),
441+
onCopyResult: (taskId) => void this.copyTaskResult(taskId),
442+
onNavigateToChat: (sessionKey) => {
443+
const face = resolveSessionPreferredFaceForKey(this.context, sessionKey);
444+
this.context.navigate(
446445
face,
447-
sessionKey,
448-
preferenceDerivedFace: true,
449-
}).options,
450-
);
451-
},
452-
})}
446+
sessionNavigationTarget({
447+
context: this.context,
448+
face,
449+
sessionKey,
450+
preferenceDerivedFace: true,
451+
}).options,
452+
);
453+
},
454+
}),
455+
)}
453456
`;
454457
}
455458
}

‎ui/src/pages/tasks/tasks.e2e.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ suite.define(() => {
254254
await dismissRow.waitFor({ state: "visible" });
255255
await page.screenshot({ path: path.join(actionArtifactDir, "01-blocked.png") });
256256

257+
await page.setViewportSize({ width: 320, height: 844 });
258+
const recoveryActions = ["Copy result", "Retry delivery", "Dismiss delivery"];
259+
for (const name of recoveryActions) {
260+
const action = retryRow.getByRole("button", { name });
261+
await action.waitFor({ state: "visible" });
262+
const bounds = await action.boundingBox();
263+
expect(bounds).not.toBeNull();
264+
expect(bounds?.x ?? -1).toBeGreaterThanOrEqual(0);
265+
expect((bounds?.x ?? 321) + (bounds?.width ?? 0)).toBeLessThanOrEqual(320);
266+
}
267+
await page.screenshot({ path: path.join(actionArtifactDir, "01-blocked-mobile.png") });
268+
await page.setViewportSize({ width: 1440, height: 900 });
269+
257270
await gateway.deferNext("tasks.retry", { taskIds: [retryBlockedTask.taskId] });
258271
const retryButton = retryRow.getByRole("button", { name: "Retry delivery" });
259272
await retryButton.evaluate((element) => {

0 commit comments

Comments
 (0)