Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Task Preview Dialog Description Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Resolve Issue #915 by giving the task preview dialog an accessible description without changing its visible layout or interaction.

**Architecture:** Reuse the existing Radix-backed `DialogDescription` component and the existing `taskDetail.preview` translation namespace. Extend the existing source-structure regression test so removal of the accessible description or either locale string fails immediately.

**Tech Stack:** React 19, TypeScript, Radix UI, i18next resources, Node.js test runner, ESLint, Vite.

## Global Constraints

- Keep the description visually hidden with `sr-only`.
- Add Chinese and English copy under `taskDetail.preview.description`.
- Preserve the existing task preview layout and behavior.
- Run the targeted test, ESLint, and online build.
- Keep commit, push, and PR creation behind separate explicit authorization.

---

### Task 1: Add the accessible task preview description

**Files:**
- Modify: `frontend/test/task-detail-preview-publish.test.ts`
- Modify: `frontend/src/pages/console/user/task/task-detail.tsx:1614-1635`
- Modify: `frontend/src/i18n/resources/cn.ts:4305-4311`
- Modify: `frontend/src/i18n/resources/en.ts:4305-4311`

**Interfaces:**
- Consumes: existing `DialogDescription` and `t("taskDetail.preview.description")` translation lookup.
- Produces: a Radix dialog description associated with the task preview `DialogContent`.

- [x] **Step 1: Write the failing regression test**

Add assertions that the preview dialog contains a screen-reader-only description and both locales define the exact copy:

```ts
assert.match(
previewDialogMatch[0],
/<DialogDescription className="sr-only">[\s\S]*?taskDetail\.preview\.description[\s\S]*?<\/DialogDescription>/,
);
assert.equal(cn.taskDetail.preview.description, "查看开发环境中可访问的端口预览");
assert.equal(en.taskDetail.preview.description, "View accessible port previews from the development environment");
```

- [x] **Step 2: Run the targeted test and verify failure**

Run: `tsx --test test/task-detail-preview-publish.test.ts`

Expected: FAIL because the preview dialog and locale resources do not yet contain `taskDetail.preview.description`.

- [x] **Step 3: Add the minimal implementation**

Place the description directly after the existing title while preserving the compact horizontal header:

```tsx
<DialogDescription className="sr-only">
{t("taskDetail.preview.description")}
</DialogDescription>
```

Add these locale entries:

```ts
description: "查看开发环境中可访问的端口预览",
```

```ts
description: "View accessible port previews from the development environment",
```

- [x] **Step 4: Verify the targeted behavior**

Run: `tsx --test test/task-detail-preview-publish.test.ts`

Expected: PASS.

- [x] **Step 5: Run frontend quality checks**

Run: `pnpm exec eslint src/pages/console/user/task/task-detail.tsx src/i18n/resources/cn.ts src/i18n/resources/en.ts test/task-detail-preview-publish.test.ts`

Expected: exit code 0.

Run: `pnpm run build:online`

Expected: exit code 0.

- [x] **Step 6: Build a test environment**

Start Vite in online mode with the API proxy target configured, request a preview URL, open the task preview dialog, and verify the console no longer emits the missing description warning.

- [x] **Step 7: Commit after explicit authorization**

```bash
git add docs/superpowers/plans/2026-07-24-task-preview-dialog-description.md frontend/test/task-detail-preview-publish.test.ts frontend/src/pages/console/user/task/task-detail.tsx frontend/src/i18n/resources/cn.ts frontend/src/i18n/resources/en.ts
git commit -m "修复:补充任务预览弹窗无障碍描述"
```
1 change: 1 addition & 0 deletions frontend/src/i18n/resources/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,7 @@ const cn = {
},
preview: {
title: "在线预览",
description: "查看开发环境中可访问的端口预览",
envNotReady: "开发环境未就绪,无法预览",
unavailable: "暂不可访问",
open: "访问",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/resources/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,7 @@ const en = {
},
preview: {
title: "Preview",
description: "View accessible port previews from the development environment",
envNotReady: "Development environment is not ready; preview is unavailable",
unavailable: "Unavailable",
open: "Open",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/pages/console/user/task/task-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,9 @@ export default function TaskDetailPage() {
<DialogContent>
<DialogHeader className="flex-row items-center justify-start gap-2 pr-8">
<DialogTitle>{t("taskDetail.panels.preview")}</DialogTitle>
<DialogDescription className="sr-only">
{t("taskDetail.preview.description")}
</DialogDescription>
<Button
variant="ghost"
size="icon-sm"
Expand Down
12 changes: 12 additions & 0 deletions frontend/test/task-detail-preview-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ test("任务详情预览弹窗支持确认后自动发送发布指令", () => {
/<Dialog open=\{previewDialogOpen\}[\s\S]*?<\/Dialog>/,
);
assert.ok(previewDialogMatch, "preview dialog should be present");
assert.match(
previewDialogMatch[0],
/<DialogDescription className="sr-only">[\s\S]*?taskDetail\.preview\.description[\s\S]*?<\/DialogDescription>/,
);
assert.doesNotMatch(
previewDialogMatch[0],
/taskDetail\.page\.dialogs\.publishWebsite\.button/,
Expand All @@ -56,6 +60,14 @@ test("任务详情预览弹窗支持确认后自动发送发布指令", () => {
});

test("任务详情预览发布确认提供中英文资源", () => {
assert.equal(
cn.taskDetail.preview.description,
"查看开发环境中可访问的端口预览",
);
assert.equal(
en.taskDetail.preview.description,
"View accessible port previews from the development environment",
);
assert.equal(cn.taskDetail.page.dialogs.publishWebsite.button, "发布");
assert.equal(en.taskDetail.page.dialogs.publishWebsite.button, "Publish");
assert.equal(
Expand Down