A local-first multi-agent app development platform, built on PenguinHarness
fix(web): 标记阻塞被拒时,表单留着、填过的原因也留着(7.45)
lmliheng9eeef95da96e
diff --git a/changelog/unreleased/2026-10-25-ticket-block-refusal.md b/changelog/unreleased/2026-10-25-ticket-block-refusal.mdnew file mode 100644index 00000000..dd9d0240--- /dev/null+++ b/changelog/unreleased/2026-10-25-ticket-block-refusal.md@@ -0,0 +1,37 @@+# Tickets: a refused block keeps the form and what was typed in it++- **Date:** 2026-10-25+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[中文](2026-10-25-ticket-block-refusal.zh.md)++"Mark blocked" is the form itself in the ticket dialog's footer: one line saying where the work is+stuck and whom it waits on, then the write. It used to close before that write landed, so a+refusal put the server's words in a toast that dismissed itself after a few seconds — the form was+gone, the reason just typed was gone, and a retry meant writing it out again.++The form now closes only on the path where its write landed; a refusal draws the server's words+above the fields (the app's existing "Refused:" lead-in) and leaves the reason and the "waiting on"+exactly as typed, so the retry is one press. Opening the form again drops the previous reason,+which belonged to the attempt it named; a write in flight takes one press only, and cancelling+decides nothing.++## Details++- `features/company/ticket-dialog.tsx`: the footer's inline block write became `commitBlock()`,+ sharing the `refusal` state the dialog's three confirmations already use (they cannot be up+ together, and each is cleared before it is raised); closing the form moved inside the write, so+ success is the only path that dismisses it and clears the fields. The `Modal`'s `onClose` no+ longer answers while a write is in flight, matching the other three cards.+- The existing browser spec `e2e/ticket-refusal.spec.mjs` gains one test (mark blocked): with the+ write refused at `page.route` 500, the form, the reason in its field and the ticket file on the+ server all stay (nothing in the notification region carries the words); cancelling and reopening+ shows no stale reason; the retry on the same form really writes — the form closes, the ticket is+ marked blocked, and the footer offers to lift it.++## Compatibility++- No interface, wire-format, stored-data or dependency change: only *when* this form closes and+ *where* the reason is drawn. No new copy beyond the existing `S.common.refused` lead-in.diff --git a/changelog/unreleased/2026-10-25-ticket-block-refusal.zh.md b/changelog/unreleased/2026-10-25-ticket-block-refusal.zh.mdnew file mode 100644index 00000000..2a35855a--- /dev/null+++ b/changelog/unreleased/2026-10-25-ticket-block-refusal.zh.md@@ -0,0 +1,30 @@+# 工单:标记阻塞被拒时,那张表单留着,填过的原因也留着++- **Date:** 2026-10-25+- **Type:** fix+- **Scope:** `web`+- **Breaking:** no++[English](2026-10-25-ticket-block-refusal.md)++「标记阻塞」是工单详情框底栏那张表单本身:填一句卡在哪里、等谁,按下就写。过去它一按就在写入之前+关掉,被拒时服务端原话只落进一条几秒后自己消失的通知 —— 表单没了,刚填的原因也没了,要重试还得从+头再写一遍。++现在表单在写入真正落地那条路径上才关;被拒时服务端原话画在字段上方(应用既有的「操作被拒绝:」前缀),+填过的原因与「等谁」原样留在框里,重试就是再按一次。重开这张表单会先清掉上一次的原因 —— 那句话属于上+次那次尝试;一个写入在途时只认一次点击,取消不决定任何事。++## 细节++- `features/company/ticket-dialog.tsx`:底栏「标记阻塞」那段内联写入收成 `commitBlock()`,与同框里+ 另外三张确认框共用那份 `refusal` 状态(它们不会同时开着,且每次开框前都先清空);关表单挪进写入内部,+ 只有成功那条路径才让表单消失并清空字段。`Modal` 的 `onClose` 在写入在途时不再响应,与另外三张框一致。+- 已有的浏览器用例 `e2e/ticket-refusal.spec.mjs` 增加一条(标记阻塞):用 `page.route` 把那次写入拒成+ 500 之后,表单、字段里的原因与服务端上的工单文件都不变(通知区里没有那句原话);取消后重开不带旧原因;+ 在同一张表单上重试才真正写进去 —— 表单关掉,工单被标记阻塞,底栏换成「解除阻塞」。++## 兼容性++- 没有接口、传输格式、已存数据或依赖变化:只改了这张表单「什么时候关」与「原因画在哪」。除既有的+ `S.common.refused` 前缀外没有新文案。diff --git a/packages/web/e2e/ticket-refusal.spec.mjs b/packages/web/e2e/ticket-refusal.spec.mjsindex cfc1e613..df21a739 100644--- a/packages/web/e2e/ticket-refusal.spec.mjs+++ b/packages/web/e2e/ticket-refusal.spec.mjs@@ -5,11 +5,13 @@* Three cards live in the ticket dialog (`features/company/ticket-dialog.tsx`): saving an edited* section, lifting a block, and moving the ticket from the footer. A fourth entry point raises* the same move card from the board (`features/company/tickets-page.tsx`, a card dropped on- * another column) — one card, two doors. All four used to close before their write landed, so a- * refusal put the reason in a toast that dismissed itself after a few seconds, over a panel that- * had not changed and with the button live again and nothing saying why. Each card now goes only- * once its write landed; a refusal leaves it standing with the reason drawn under its sentence- * (`ConfirmModal`'s `refusal` slot), and reopening it does not carry the old reason.+ * another column) — one card, two doors — and a fifth write has its form for a card: marking the+ * ticket blocked, whose reason fields are the question itself. All of them used to close before+ * their write landed, so a refusal put the reason in a toast that dismissed itself after a few+ * seconds, over a panel that had not changed and with the button live again and nothing saying+ * why. Each card now goes only once its write landed; a refusal leaves it standing with the+ * reason drawn under its sentence (`ConfirmModal`'s `refusal` slot, or above the block form's+ * fields), and reopening it does not carry the old reason.** The organization and its ticket are made through the API rather than through the dialogs:* this spec is about the confirmations, not about creation. Company mode is off on a fresh@@ -271,6 +273,54 @@ test("a refused unblock keeps the card, its sentence and the block", async ({ paawait expect.poll(async () => (await stored()).blocked).toBeFalsy();});+test("a refused block keeps the form, what was typed and the ticket unblocked", async ({+ page,+}) => {+ test.setTimeout(120_000);+ const { projectId, ticketUrl, stored } = await setUp(page, "r131block");+ const REASON = "等市场站点的备案下来";++ await openBoard(page, projectId);+ const dialog = await openTicket(page);+ await dialog.getByRole("button", { name: "标记阻塞", exact: true }).click();+ const form = page.getByRole("dialog", { name: "标记阻塞" });+ await expect(form).toBeVisible();+ await form.getByRole("textbox", { name: /阻塞原因/ }).fill(REASON);+ const sentence = await cardText(form);++ const writes = [];+ const pattern = await refuseWrite(page, ticketUrl, "POST", writes, "/block");+ await form.getByRole("button", { name: "标记阻塞", exact: true }).click();++ // The reason is in the form that asked, and it is not a toast: the notification region never+ // carries the server's words, and the form reads exactly as before plus the one line.+ await expect(form.getByText(REFUSAL.message)).toBeVisible();+ await expect(page.getByRole("region", { name: "通知" })).not.toContainText(REFUSAL.message);+ expect(writes).toHaveLength(1);+ await expect(form).toBeVisible();+ expect(await cardText(form)).toBe(sentence);++ // Nothing was written: the ticket carries no block, and the fields keep what was typed.+ expect((await stored()).blocked).toBeFalsy();+ await expect(form.getByRole("textbox", { name: /阻塞原因/ })).toHaveValue(REASON);++ // Closing the form decides nothing, and reopening it does not carry the old reason.+ await form.getByRole("button", { name: "取消" }).click();+ await expect(form).toHaveCount(0);+ await dialog.getByRole("button", { name: "标记阻塞", exact: true }).click();+ const again = page.getByRole("dialog", { name: "标记阻塞" });+ await expect(again).toBeVisible();+ await expect(again.getByText(REFUSAL.message)).toHaveCount(0);+ expect(await again.innerText()).toBe(sentence);++ // The retry lands: the form goes, the file records the block, and the footer offers to lift it.+ await page.unroute(pattern);+ await again.getByRole("button", { name: "标记阻塞", exact: true }).click();+ await expect(again).toHaveCount(0);+ await expect.poll(async () => (await stored()).blocked).toBeTruthy();+ await expect(dialog.getByRole("button", { name: "解除阻塞", exact: true })).toBeVisible();+});+test("a refused move from the board keeps the card, its sentence and the column", async ({page,}) => {diff --git a/packages/web/src/features/company/ticket-dialog.tsx b/packages/web/src/features/company/ticket-dialog.tsxindex dd8fcc86..0ceafb38 100644--- a/packages/web/src/features/company/ticket-dialog.tsx+++ b/packages/web/src/features/company/ticket-dialog.tsx@@ -50,6 +50,7 @@ import {KeyValueRow,Modal,Notice,+ NoticeStrip,RuledSection,Segmented,Select,@@ -184,8 +185,9 @@ function TicketDialog({/*** The server's own words for a write one of this dialog's confirmations asked for and had* refused, drawn inside that card next to the button that retries it. One slot serves the three- * cards: only one of them can be up at a time (each is raised from an idle footer, and a write in- * flight leaves the others inert), and each is cleared of it before it is raised again.+ * confirmations and the block form: only one of them can be up at a time (each is raised from an+ * idle footer, and a write in flight leaves the others inert), and each is cleared of it before+ * it is raised again.*/const [refusal, setRefusal] = useState<string | null>(null);const names = new Map(employees.map((e) => [e.agentId, e.name]));@@ -381,6 +383,28 @@ function TicketDialog({);};+ /**+ * Marking the ticket blocked, once its reason form is answered. The form is the card that asked,+ * so it goes with its own write landing: a refusal leaves it standing, fields and all, with the+ * server's words above them rather than a toast that would outlive the question.+ */+ const commitBlock = () => {+ if (detail === null || busy || !blockReason.trim()) return;+ void run(+ async () => {+ await api.blockOrgTicket(projectId, orgId, detail.ticketId, {+ reason: blockReason.trim(),+ ...(blockBy.trim() ? { by: blockBy.trim() } : {}),+ });+ setBlockReason("");+ setBlockBy("");+ setBlockOpen(false);+ },+ undefined,+ setRefusal,+ );+ };+const children = (detail?.children ?? []).map((id) => tickets.find((t) => t.ticketId === id) ?? { ticketId: id, title: id },);@@ -952,7 +976,15 @@ function TicketDialog({{S.company.tickets.unblock}</Button>) : (- <Button size="sm" disabled={busy} onClick={() => setBlockOpen(true)}>+ <Button+ size="sm"+ disabled={busy}+ onClick={() => {+ // A new question, not the last one: the previous refusal is not its answer.+ setRefusal(null);+ setBlockOpen(true);+ }}+ >{S.company.tickets.block}</Button>)}@@ -1034,7 +1066,7 @@ function TicketDialog({<Modalopen={blockOpen}title={S.company.tickets.blockTitle}- onClose={() => setBlockOpen(false)}+ onClose={() => (busy ? undefined : setBlockOpen(false))}footer={<><Button size="sm" onClick={() => setBlockOpen(false)} disabled={busy}>@@ -1044,18 +1076,7 @@ function TicketDialog({size="sm"variant="primary"disabled={busy || !blockReason.trim()}- onClick={() => {- if (detail === null) return;- setBlockOpen(false);- void run(async () => {- await api.blockOrgTicket(projectId, orgId, detail.ticketId, {- reason: blockReason.trim(),- ...(blockBy.trim() ? { by: blockBy.trim() } : {}),- });- setBlockReason("");- setBlockBy("");- });- }}+ onClick={commitBlock}>{S.company.tickets.block}</Button>@@ -1063,6 +1084,17 @@ function TicketDialog({}><div className="space-y-3">+ {refusal !== null && (+ // The form's own words: a refusal is about what the reader just typed, so it reads+ // above the fields that still hold it, not as page-level news.+ <NoticeStrip+ tone="danger"+ role="alert"+ className="rounded-md border px-2.5 py-2 text-xs"+ >+ <span data-slot="body">{S.common.refused(refusal)}</span>+ </NoticeStrip>+ )}<Inputsize="sm"label={S.company.tickets.blockedReason}