From bcabf4fac0469936cc72442d6f046c677dcda966 Mon Sep 17 00:00:00 2001 From: reoring Date: Fri, 20 Nov 2026 01:48:29 +0900 Subject: [PATCH 1/3] Collapse a conversation failure a later turn superseded; only the last failed turn offers retry (APT-1365) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - assistantMessage gave every failed turn's notice retry: 'turn', but retry('turn') resends only the last failed turn. A failure followed by a later turn kept a red card whose 「もう一度試す」 did nothing and that never went away (Craftsman, 0.6.1, draft 「test」: turn 1 timed out, the resent turn 2 succeeded). - messagesFromDraft renders a failed turn that a later conversation turn followed as one information line 「この依頼は一度止まりました」 / "This request stopped once", without retry, detail or reference. The last failed turn keeps its card and retry, which resends the same request. A tab's saved copy of the superseded failure notice is not shown again. - Mock: POST /api/v1/__mock/turn-failure {error} fails the next settling conversation turn once. - Tests: messages.test.ts superseded-failure cases; story build-turn-retry.mock.spec.ts (old failure collapsed without retry; last failure's retry POSTs the same message and the conversation continues). --- web/e2e/stories/build-turn-retry.mock.spec.ts | 69 +++++++++++++++++++ web/src/dev/mock-platform.ts | 20 +++++- web/src/model/build/copy.en.ts | 1 + web/src/model/build/copy.ts | 2 + web/src/model/build/messages.test.ts | 65 +++++++++++++++++ web/src/model/build/messages.ts | 27 ++++++-- 6 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 web/e2e/stories/build-turn-retry.mock.spec.ts diff --git a/web/e2e/stories/build-turn-retry.mock.spec.ts b/web/e2e/stories/build-turn-retry.mock.spec.ts new file mode 100644 index 0000000..9382f5b --- /dev/null +++ b/web/e2e/stories/build-turn-retry.mock.spec.ts @@ -0,0 +1,69 @@ +import type { APIRequestContext } from '@playwright/test' +import { test, expect, seed, captureWrite, type MockControl } from '../support/fixtures' +import { textJa as buildText } from '../../src/model/build/copy' +import { textJa as text } from '../../src/features/build/copy' + +// APT-1365: only the last failed conversation turn offers 「もう一度試す」. A failed turn a later turn followed reads +// as one past, information-only line; it never keeps a red card whose retry does nothing. +const root = `/api/v1/projects/${seed.projectId}` +const TIMED_OUT = 'application draft conversation turn timed out' +const MESSAGE = 'test' + +/** A draft whose turns settle, in order, as failed (`true`, with TIMED_OUT) or succeeded (`false`). */ +async function draftWithTurns(request: APIRequestContext, mock: MockControl, failures: boolean[]): Promise { + const created = await request.post(`${root}/application-drafts`, { data: { title: '見積作成', intent: '見積を管理する' } }) + expect(created.ok()).toBe(true) + const draftId: string = (await created.json()).resource.id + for (const failed of failures) { + await mock.platform('turn-failure', failed ? { error: TIMED_OUT } : {}) + expect((await request.post(`${root}/application-drafts/${draftId}/conversation-turns`, { data: { message: MESSAGE } })).ok()).toBe(true) + await mock.advance() + } + const turns: { status: string; error?: string }[] = (await (await request.get(`${root}/application-drafts/${draftId}`)).json()).conversationTurns + expect(turns.map((turn) => turn.status)).toEqual(failures.map((failed) => failed ? 'failed' : 'succeeded')) + return draftId +} + +test.describe('build conversation turn retry @build-turn-retry', () => { + test('a timed-out turn the user already sent again reads as one past line, without 「もう一度試す」 @mock @story', async ({ page, mock, request }, testInfo) => { + await mock.platform('codex', { available: true }) + const draftId = await draftWithTurns(request, mock, [true, false]) + await page.goto(`/-/build/${draftId}`) + const conversation = page.getByRole('log', { name: 'AI との会話' }) + await expect(conversation).toContainText('ご希望を仕様に反映しました。') + // Both requests stay as the user's own words; the first one's failure is collapsed between them. + // A user bubble is an article labelled 「あなた:」 followed by the request text. + await expect(conversation.getByRole('article').filter({ hasText: new RegExp(`^あなた:\\s*${MESSAGE}$`) })).toHaveCount(2) + const collapsed = conversation.getByRole('status').filter({ hasText: buildText.failure.superseded }) + await expect(collapsed).toHaveCount(1) + await expect(collapsed).toHaveText(buildText.failure.superseded) + await expect(conversation.getByRole('alert')).toHaveCount(0) + await expect(conversation).not.toContainText(buildText.failure.timeout.title) + await expect(conversation).not.toContainText(buildText.failure.timeout.reason) + await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) + await page.screenshot({ path: testInfo.outputPath('superseded-failure.png'), fullPage: true }) + }) + + test('the last timed-out turn keeps 「もう一度試す」, which sends the same request again and continues @mock @story', async ({ page, mock, request }, testInfo) => { + await mock.platform('codex', { available: true }) + await mock.platform('plan-generation', { autoAdvance: true }) + const draftId = await draftWithTurns(request, mock, [true]) + await page.goto(`/-/build/${draftId}`) + const conversation = page.getByRole('log', { name: 'AI との会話' }) + const card = conversation.getByRole('alert').filter({ hasText: buildText.failure.timeout.title }) + await expect(card).toHaveCount(1) + await expect(card).toContainText(buildText.failure.timeout.reason) + const retry = card.getByRole('button', { name: text.conversation.retry, exact: true }) + await expect(retry).toBeVisible() + await page.screenshot({ path: testInfo.outputPath('last-failure.png'), fullPage: true }) + const resent = await captureWrite(page, 'POST', `${root}/application-drafts/${draftId}/conversation-turns`, () => retry.click()) + expect(resent.body).toEqual({ message: MESSAGE }) + // The mock answers the new turn; the stopped one is now behind it and reads as the past line. + await expect(conversation).toContainText('ご希望を仕様に反映しました。', { timeout: 20_000 }) + await expect(conversation.getByRole('status').filter({ hasText: buildText.failure.superseded })).toHaveCount(1) + await expect(conversation.getByRole('alert')).toHaveCount(0) + await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) + const turns: { status: string }[] = (await (await request.get(`${root}/application-drafts/${draftId}`)).json()).conversationTurns + expect(turns.map((turn) => turn.status)).toEqual(['failed', 'succeeded']) + }) +}) diff --git a/web/src/dev/mock-platform.ts b/web/src/dev/mock-platform.ts index dd57e20..ea0f63f 100644 --- a/web/src/dev/mock-platform.ts +++ b/web/src/dev/mock-platform.ts @@ -46,6 +46,8 @@ // - `POST /api/v1/__mock/ai-quota {exhausted: boolean}` makes AI turns, plan generation // and implementation tasks fail with the provider's credits message while exhausted. // Clear it to resume manually; completed work is retained and reset clears the toggle. +// - `POST /api/v1/__mock/turn-failure {error}` makes the next new-app conversation turn that settles fail with `error` +// (once); `{}` clears it. Reset clears it too. // - `POST /api/v1/__mock/stack-conflict {appName?, reason?, message?}` makes the next stack create (of // `appName`, or any) answer one 409 with `details.reason` (`delivery_pending` = retryable). // - `POST /api/v1/__mock/github-repository {name}` marks `acme/` as existing on GitHub (`uriage` is seeded). @@ -705,6 +707,15 @@ function failQuotaTurn(draft: ApplicationDraft, turn: ApplicationDraftConversati return true } +/** `__mock/turn-failure`: the next conversation turn that settles fails with the configured error, once. */ +function failNextTurn(draft: ApplicationDraft, turn: ApplicationDraftConversationTurn, now: string): boolean { + if (state.turnFailure === undefined || turn.kind !== 'conversation') return false + Object.assign(turn, { status: 'failed', error: state.turnFailure, finishedAt: now }) + state.turnFailure = undefined + draft.updatedAt = now + return true +} + /** Plan generations run three steps; a running creation execution finishes in one. */ function advanceDraft(draft: ApplicationDraft): boolean { let moved = false @@ -723,7 +734,7 @@ function advanceDraft(draft: ApplicationDraft): boolean { } for (const turn of draft.conversationTurns ?? []) { if (turn.status !== 'pending' && turn.status !== 'running') continue - if (failQuotaTurn(draft, turn, now)) { moved = true; continue } + if (failQuotaTurn(draft, turn, now) || failNextTurn(draft, turn, now)) { moved = true; continue } if (turn.kind === 'excel-analysis' || turn.kind === 'ui-design') { answerExcelTurn(draft, turn, now) moved = true @@ -1200,6 +1211,8 @@ function seedPlatform() { codexUnavailableReason: undefined as ApplicationDraftCreationToolRegistryResponse['codexUnavailableReason'], codexPolicy: undefined as string | undefined, aiQuotaExhausted: false, + /** `__mock/turn-failure`: the error the next settling conversation turn fails with (once). */ + turnFailure: undefined as string | undefined, rejectNextValidation: false, creationPublishConflict: false, accessForbidden: false, @@ -1866,6 +1879,11 @@ const routes: Array<[method: string, pattern: RegExp, handler: Handler]> = [ if (typeof body.exhausted === 'boolean') state.aiQuotaExhausted = body.exhausted return json({ exhausted: state.aiQuotaExhausted }) }], + ['POST', /^\/api\/v1\/__mock\/turn-failure$/, async (_, request) => { + const body = await request.json() as { error?: unknown } + state.turnFailure = typeof body.error === 'string' ? body.error : undefined + return json({ error: state.turnFailure ?? null }) + }], [ 'POST', /^\/api\/v1\/__mock\/plan-generation$/, diff --git a/web/src/model/build/copy.en.ts b/web/src/model/build/copy.en.ts index 4050793..0296ce0 100644 --- a/web/src/model/build/copy.en.ts +++ b/web/src/model/build/copy.en.ts @@ -97,6 +97,7 @@ export const textEn: typeof textJa = { unknownWorkspace: 'We cannot yet confirm whether AI is ready.', timeout: { title: 'Taking longer than expected', reason: 'Your conversation is saved; please try again shortly.' }, busy: { title: 'AI is still working', reason: 'Your changes are saved; work will continue when the previous request finishes.' }, + superseded: 'This request stopped once', failed: { turn: 'AI could not process your request', plan: 'Could not create plan', implement: 'Building your app stopped', publish: 'Could not save the published state' }, retry: 'Your requirements and plan are saved; try again, or contact your administrator if work keeps stopping.', platform: { title: 'A platform problem stopped app creation', reason: 'This is not a problem with your input or actions. Your requirements and plan are still saved. Wait a little and try again, or share the support reference below with your administrator.' }, diff --git a/web/src/model/build/copy.ts b/web/src/model/build/copy.ts index 1aba573..ed862a8 100644 --- a/web/src/model/build/copy.ts +++ b/web/src/model/build/copy.ts @@ -108,6 +108,8 @@ export const textJa = { unknownWorkspace: 'AI の作業場所が使える状態か、まだ確認できません。', timeout: { title: '処理に時間がかかっています', reason: '相談した内容は残っています。少し待ってから、もう一度試してください。' }, busy: { title: 'AI が前の作業を進めています', reason: '内容は残っています。前の作業が終わったら続けます。' }, + /** A failed conversation turn a later turn followed (APT-1365): over, information only, never a retry. */ + superseded: 'この依頼は一度止まりました', failed: { turn: 'AI が内容を整理できませんでした', plan: '計画を作れませんでした', implement: 'アプリを作る作業が止まりました', publish: '公開済みの状態を保存できませんでした' }, retry: '仕様と計画は残っています。もう一度試してください。何度も止まるときは基盤の担当者に確認してください。', platform: { title: '基盤の問題で作成が止まりました', reason: 'あなたの入力や操作の問題ではありません。仕様と計画はそのまま残っています。少し待ってもう一度試すか、下の問い合わせ番号を基盤の担当者に伝えてください。' }, diff --git a/web/src/model/build/messages.test.ts b/web/src/model/build/messages.test.ts index fa6980f..c90dffe 100644 --- a/web/src/model/build/messages.test.ts +++ b/web/src/model/build/messages.test.ts @@ -126,6 +126,71 @@ describe('conversation history', () => { }) }) +describe('superseded turn failure (APT-1365)', () => { + const timedOut = { ...turn, id: 'turn-1', status: 'failed' as const, error: 'application draft conversation turn timed out', userMessage: 'test', assistantMessage: undefined, changed: undefined, suggestedReplies: undefined } + const resent = { ...turn, id: 'turn-2', userMessage: 'test', startedAt: '2026-10-08T01:00:00Z', finishedAt: '2026-10-08T01:00:30Z' } + const collapsed = { role: 'notice', tone: 'info', title: textJa.failure.superseded, at: timedOut.finishedAt ?? timedOut.startedAt } satisfies BuildMessage + const roles = (messages: BuildMessage[]) => messages.map((message) => message.role === 'notice' ? `notice:${message.tone}` : message.role) + + test('a failed turn a later turn followed reads as one past line: no retry, not an error, the later turn as it is', () => { + const messages = messagesFromDraft({ ...draft, conversationTurns: [resent, timedOut] }, []) + expect(roles(messages)).toEqual(['user', 'notice:info', 'user', 'assistant']) + expect(messages[0]).toEqual({ role: 'user', text: 'test', at: timedOut.startedAt }) + expect(messages[1]).toEqual(collapsed) + expect(messages[1]).not.toHaveProperty('retry') + expect(messages[1]).not.toHaveProperty('detail') + expect(messages[1]).not.toHaveProperty('reference') + expect(messages.slice(2)).toEqual([{ role: 'user', text: 'test', at: resent.startedAt }, assistantMessage(resent, draft.id)]) + expect(messages.some((message) => message.role === 'notice' && message.retry)).toBe(false) + }) + test('the last failed turn keeps its error notice with 「もう一度試す」', () => { + const messages = messagesFromDraft({ ...draft, conversationTurns: [timedOut] }, []) + expect(messages[1]).toMatchObject({ role: 'notice', tone: 'error', title: textJa.failure.timeout.title, detail: textJa.failure.timeout.reason, retry: 'turn' }) + }) + test('of failures in a row only the last offers retry', () => { + const again = { ...timedOut, id: 'turn-2', startedAt: resent.startedAt, finishedAt: resent.finishedAt } + const messages = messagesFromDraft({ ...draft, conversationTurns: [again, timedOut] }, []) + const notices = messages.filter((message) => message.role === 'notice') + expect(notices).toEqual([collapsed, expect.objectContaining({ tone: 'error', at: again.finishedAt, retry: 'turn' })]) + expect(notices.filter((message) => message.retry)).toHaveLength(1) + }) + test('a later turn still running or in an unknown state supersedes it too', () => { + for (const status of ['running', 'future-state']) { + const notices = messagesFromDraft({ ...draft, conversationTurns: [timedOut, { ...resent, status, finishedAt: undefined }] }, []).filter((message) => message.role === 'notice') + expect(notices[0]).toEqual(collapsed) + } + }) + test('a policy failure followed by a later turn is collapsed alike; as the last turn it stays without retry', () => { + const denied = { ...timedOut, error: 'workspace: ai_policy_denied' } + expect(classifyBuildFailure(denied.error, undefined, 'turn').kind).toBe('policy') + expect(messagesFromDraft({ ...draft, conversationTurns: [denied, resent] }, [])[1]).toEqual(collapsed) + const last = messagesFromDraft({ ...draft, conversationTurns: [denied] }, [])[1] + expect(last).toMatchObject({ role: 'notice', tone: 'error' }) + expect(last).not.toHaveProperty('retry') + }) + test('the failure notice this tab kept when it saw the failure is not shown again once superseded', () => { + // use-build-session `fail` stores the observed failure at the turn's finish, with the derived notice's title. + const kept = assistantMessage(timedOut, draft.id) + expect(kept).toMatchObject({ role: 'notice', retry: 'turn' }) + const read = { ...draft, conversationTurns: [timedOut, resent] } + const messages = messagesFromDraft(read, [kept]) + expect(roles(messages)).toEqual(['user', 'notice:info', 'user', 'assistant']) + // A reload hands the transcript back as local messages: nothing is added twice. + expect(messagesFromDraft(read, messages)).toEqual(messages) + }) + test('the copy is short and past tense in Japanese and English', () => { + expect(textJa.failure.superseded).toBe('この依頼は一度止まりました') + expect(textEn.failure.superseded).toBe('This request stopped once') + const restore = preserveLanguage() + try { + setLanguage('en') + expect(messagesFromDraft({ ...draft, conversationTurns: [timedOut, resent] }, [])[1]).toEqual({ ...collapsed, title: textEn.failure.superseded }) + } finally { + restore() + } + }) +}) + describe('recreated workspace notice (APT-1264)', () => { const recreated = { role: 'notice', kind: 'workspace-recreated', tone: 'info', title: textJa.workspaceRecreated, at: '2026-10-08T00:02:00Z' } satisfies BuildMessage const earlier = { ...turn, devWorkspaceId: 'ws-old' } diff --git a/web/src/model/build/messages.ts b/web/src/model/build/messages.ts index 10da955..7e63c7e 100644 --- a/web/src/model/build/messages.ts +++ b/web/src/model/build/messages.ts @@ -182,6 +182,14 @@ function workspaceRecreatedNotice(at: string): BuildMessage { return { role: 'notice', kind: 'workspace-recreated', tone: 'info', title: buildCopy.workspaceRecreated, at } } +/** + * A failed turn a later conversation turn followed (APT-1365): that turn is over, so it reads as one past line. Information + * only: no retry (it would resend nothing) and nothing asks the user to try again. + */ +function supersededFailureNotice(at: string): BuildMessage { + return { role: 'notice', tone: 'info', title: buildCopy.failure.superseded, at } +} + /** * The newest message the page decides on (re-approval, a rejected plan, the generation limit). A recreated-workspace * notice is display only: it is skipped, also when a device clock behind the server's sorts it after a local notice. @@ -216,12 +224,21 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti // The collapsed line does not hide a switch Excel → app's turns made. for (const turn of excel) messages.push(...recreated(turn)) const turns = conversationTurns(all) - for (const turn of turns) { + // The failure notices superseded turns would have had: the same notice kept by this tab (a failure it saw) is not shown again. + const superseded: BuildMessage[] = [] + for (const [index, turn] of turns.entries()) { messages.push({ role: 'user', text: turn.userMessage, at: turn.startedAt }) // Right below the request, before its answer, also when the answer carries the same time (no finishedAt). messages.push(...recreated(turn)) // A reply in a state this console does not know reads as that, never as an answer or a failure. - if (turn.status.kind === 'unknown' || isOneOf(turn.status, 'succeeded', 'failed')) messages.push(assistantMessage(turn, draft.id)) + if (turn.status.kind === 'unknown' || isOneOf(turn.status, 'succeeded', 'failed')) { + const reply = assistantMessage(turn, draft.id) + // Only the last turn's failure can be tried again (use-build-session `retry('turn')` resends the last turn). + if (isOneOf(turn.status, 'failed') && index < turns.length - 1) { + superseded.push(reply) + messages.push(supersededFailureNotice(reply.at)) + } else messages.push(reply) + } } // A turn of a kind this console does not know is not shown, but its switch is still told. for (const turn of all) if (!excel.includes(turn) && !turns.includes(turn)) messages.push(...recreated(turn)) @@ -230,14 +247,14 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti const proposal = proposalMessage(draft, options.lastPlannedIntent, options.destination) if (proposal) messages.push(proposal) for (const message of extra) { - const duplicate = messages.some((item) => { + const same = (item: BuildMessage) => { if (item.role !== message.role) return false if (item.role === 'assistant' && message.role === 'assistant' && message.turnId) return item.turnId === message.turnId if (item.at !== message.at) return false if (item.role === 'notice' && message.role === 'notice') return item.title === message.title return 'text' in item && 'text' in message && item.text === message.text - }) - if (!duplicate) messages.push(message) + } + if (!messages.some(same) && !superseded.some(same)) messages.push(message) } // Only observed template startup earns the completion line; execution success // alone merely proves that the application's resources were created. From 4bb05545bc0cb5d2b4ae8184e49e09f6cb639dd6 Mon Sep 17 00:00:00 2001 From: reoring Date: Fri, 20 Nov 2026 02:08:35 +0900 Subject: [PATCH 2/3] Supersede turn failures by turn id; retry and observe the conversation's own last turn (APT-1365 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Review of #48: a tab's saved notice of an observed turn failure kept blocking a pending reply after the UI collapsed it, and retry('turn') resent the last turn of any kind (an Excel → app turn after the failed conversation turn). Matching saved notices by role/at/title also hid or kept the wrong ones. - Observed turn-failure notices carry the turn id; a notice naming a superseded failed turn is neither shown nor kept in the tab (withoutStaleTurnFailures), and the failure it set clears, so pending replies send. A failed send (no turn) keeps blocking until its retry, as before. - Observation, the plan-start guard and retry('turn') use the conversation's last turn (shownConversationTurns), the list the conversation renders. - A superseded policy refusal keeps its reason; only failures that offered a retry collapse. - Copy: 「この依頼は途中で止まりました」 / "This request was interrupted." - Tests: turn-id matching, language switch, policy, Excel turn after a failure, a pruning table; stories C (another tab's resend clears this tab's saved failure and a new reply is sent) and D (a failed screen-design turn does not change what 「もう一度試す」 sends). --- web/e2e/stories/build-turn-retry.mock.spec.ts | 67 +++++++++++++++ web/src/dev/mock-platform.ts | 21 ++--- web/src/features/build/session.ts | 2 +- web/src/features/build/use-build-session.ts | 38 +++++++-- web/src/model/build/copy.en.ts | 2 +- web/src/model/build/copy.ts | 2 +- web/src/model/build/messages.test.ts | 85 +++++++++++++++---- web/src/model/build/messages.ts | 55 +++++++++--- web/src/model/build/types.ts | 4 +- 9 files changed, 226 insertions(+), 50 deletions(-) diff --git a/web/e2e/stories/build-turn-retry.mock.spec.ts b/web/e2e/stories/build-turn-retry.mock.spec.ts index 9382f5b..c402ae3 100644 --- a/web/e2e/stories/build-turn-retry.mock.spec.ts +++ b/web/e2e/stories/build-turn-retry.mock.spec.ts @@ -66,4 +66,71 @@ test.describe('build conversation turn retry @build-turn-retry', () => { const turns: { status: string }[] = (await (await request.get(`${root}/application-drafts/${draftId}`)).json()).conversationTurns expect(turns.map((turn) => turn.status)).toEqual(['failed', 'succeeded']) }) + + test('a failure this tab saw stops offering a retry once another tab sent the request again; a new reply is sent @mock @story', async ({ page, mock, request }, testInfo) => { + await mock.platform('codex', { available: true }) + const draftId = await draftWithTurns(request, mock, []) + const turnsPath = `${root}/application-drafts/${draftId}/conversation-turns` + // The request is running when the page opens, and times out while this tab watches it. + await mock.platform('turn-failure', { error: TIMED_OUT }) + expect((await request.post(turnsPath, { data: { message: MESSAGE } })).ok()).toBe(true) + await page.goto(`/-/build/${draftId}`) + const conversation = page.getByRole('log', { name: 'AI との会話' }) + await mock.advance() + const card = conversation.getByRole('alert').filter({ hasText: buildText.failure.timeout.title }) + await expect(card.getByRole('button', { name: text.conversation.retry, exact: true })).toBeVisible({ timeout: 20_000 }) + // The tab keeps the failure it saw (use-build-session `fail`), across a reload too. + const saved = () => page.evaluate((key) => sessionStorage.getItem(key) ?? '', `builder-console:build:${draftId}`) + expect(await saved()).toContain(buildText.failure.timeout.title) + + // Another tab sends the same request again, and it succeeds; this tab reads the draft again. + expect((await request.post(turnsPath, { data: { message: MESSAGE } })).ok()).toBe(true) + await mock.advance() + await page.reload() + await expect(conversation).toContainText('ご希望を仕様に反映しました。', { timeout: 20_000 }) + await expect(conversation.getByRole('status').filter({ hasText: buildText.failure.superseded })).toHaveCount(1) + await expect(conversation.getByRole('alert')).toHaveCount(0) + await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) + // The saved notice leaves the tab too, so it can no longer hold back a reply. + await expect.poll(saved).not.toContain(buildText.failure.timeout.title) + await page.screenshot({ path: testInfo.outputPath('superseded-saved-failure.png'), fullPage: true }) + + const reply = '担当者も記録したい' + await page.getByLabel('AI に伝えること', { exact: true }).fill(reply) + const sent = await captureWrite(page, 'POST', turnsPath, () => page.getByRole('button', { name: '送信', exact: true }).click()) + expect(sent.body).toEqual({ message: reply }) + }) + + test('a failed screen-design turn after the failed request neither adds a card nor changes what 「もう一度試す」 sends @mock @story', async ({ page, mock, request }) => { + await mock.platform('codex', { available: true }) + await mock.platform('plan-generation', { autoAdvance: true }) + const draftId = await draftWithTurns(request, mock, [true]) + const turnsPath = `${root}/application-drafts/${draftId}/conversation-turns` + // An Excel → app screen-design turn is recorded after the conversation's request, and fails too. + await mock.platform('turn-failure', { error: 'codex exited', kind: 'ui-design' }) + expect((await request.post(turnsPath, { data: { kind: 'ui-design', message: '__init__' } })).ok()).toBe(true) + await mock.advance() + const turns: { id: string; kind: string; status: string }[] = (await (await request.get(`${root}/application-drafts/${draftId}`)).json()).conversationTurns + expect(turns.map((turn) => [turn.kind, turn.status])).toEqual([['conversation', 'failed'], ['ui-design', 'failed']]) + const [asked, designed] = turns + + await page.goto(`/-/build/${draftId}`) + const conversation = page.getByRole('log', { name: 'AI との会話' }) + // The tab observes the conversation's failure, by its turn, and not the design turn's. + const saved = () => page.evaluate((key) => sessionStorage.getItem(key) ?? '', `builder-console:build:${draftId}`) + await expect.poll(saved).toContain(`"turnId":"${asked!.id}"`) + expect(await saved()).not.toContain(`"turnId":"${designed!.id}"`) + // One card: the conversation's request, retried by its own turn. + const card = conversation.getByRole('alert') + await expect(card).toHaveCount(1) + await expect(card).toContainText(buildText.failure.timeout.title) + const retry = card.getByRole('button', { name: text.conversation.retry, exact: true }) + await expect(retry).toBeVisible() + const resent = await captureWrite(page, 'POST', turnsPath, () => retry.click()) + expect(resent.body).toEqual({ message: MESSAGE }) + await expect(conversation).toContainText('ご希望を仕様に反映しました。', { timeout: 20_000 }) + await expect(conversation.getByRole('status').filter({ hasText: buildText.failure.superseded })).toHaveCount(1) + await expect(conversation.getByRole('alert')).toHaveCount(0) + await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) + }) }) diff --git a/web/src/dev/mock-platform.ts b/web/src/dev/mock-platform.ts index ea0f63f..9e7c295 100644 --- a/web/src/dev/mock-platform.ts +++ b/web/src/dev/mock-platform.ts @@ -46,8 +46,8 @@ // - `POST /api/v1/__mock/ai-quota {exhausted: boolean}` makes AI turns, plan generation // and implementation tasks fail with the provider's credits message while exhausted. // Clear it to resume manually; completed work is retained and reset clears the toggle. -// - `POST /api/v1/__mock/turn-failure {error}` makes the next new-app conversation turn that settles fail with `error` -// (once); `{}` clears it. Reset clears it too. +// - `POST /api/v1/__mock/turn-failure {error, kind?}` makes the next new-app turn of `kind` (default `conversation`; +// `excel-analysis` or `ui-design`) that settles fail with `error` (once); `{}` clears it. Reset clears it too. // - `POST /api/v1/__mock/stack-conflict {appName?, reason?, message?}` makes the next stack create (of // `appName`, or any) answer one 409 with `details.reason` (`delivery_pending` = retryable). // - `POST /api/v1/__mock/github-repository {name}` marks `acme/` as existing on GitHub (`uriage` is seeded). @@ -707,10 +707,10 @@ function failQuotaTurn(draft: ApplicationDraft, turn: ApplicationDraftConversati return true } -/** `__mock/turn-failure`: the next conversation turn that settles fails with the configured error, once. */ +/** `__mock/turn-failure`: the next turn of the configured kind that settles fails with the configured error, once. */ function failNextTurn(draft: ApplicationDraft, turn: ApplicationDraftConversationTurn, now: string): boolean { - if (state.turnFailure === undefined || turn.kind !== 'conversation') return false - Object.assign(turn, { status: 'failed', error: state.turnFailure, finishedAt: now }) + if (state.turnFailure === undefined || (turn.kind ?? 'conversation') !== state.turnFailure.kind) return false + Object.assign(turn, { status: 'failed', error: state.turnFailure.error, finishedAt: now }) state.turnFailure = undefined draft.updatedAt = now return true @@ -1211,8 +1211,8 @@ function seedPlatform() { codexUnavailableReason: undefined as ApplicationDraftCreationToolRegistryResponse['codexUnavailableReason'], codexPolicy: undefined as string | undefined, aiQuotaExhausted: false, - /** `__mock/turn-failure`: the error the next settling conversation turn fails with (once). */ - turnFailure: undefined as string | undefined, + /** `__mock/turn-failure`: the error the next settling turn of `kind` fails with (once). */ + turnFailure: undefined as { error: string; kind: NonNullable } | undefined, rejectNextValidation: false, creationPublishConflict: false, accessForbidden: false, @@ -1880,9 +1880,10 @@ const routes: Array<[method: string, pattern: RegExp, handler: Handler]> = [ return json({ exhausted: state.aiQuotaExhausted }) }], ['POST', /^\/api\/v1\/__mock\/turn-failure$/, async (_, request) => { - const body = await request.json() as { error?: unknown } - state.turnFailure = typeof body.error === 'string' ? body.error : undefined - return json({ error: state.turnFailure ?? null }) + const body = await request.json() as { error?: unknown; kind?: unknown } + const kind = body.kind === 'excel-analysis' || body.kind === 'ui-design' ? body.kind : 'conversation' + state.turnFailure = typeof body.error === 'string' ? { error: body.error, kind } : undefined + return json(state.turnFailure ?? {}) }], [ 'POST', diff --git a/web/src/features/build/session.ts b/web/src/features/build/session.ts index 073674c..15d754f 100644 --- a/web/src/features/build/session.ts +++ b/web/src/features/build/session.ts @@ -11,7 +11,7 @@ import { textEn } from './copy.en' const messageSchema = z.discriminatedUnion('role', [ z.object({ role: z.literal('user'), text: z.string(), at: z.string() }), z.object({ role: z.literal('assistant'), text: z.string(), at: z.string(), summary: z.string().optional(), changed: z.array(z.string()).optional(), question: z.string().optional(), options: z.array(z.string()).optional(), turnId: z.string().optional() }), - z.object({ role: z.literal('notice'), tone: z.enum(['info', 'warning', 'error']), title: z.string(), detail: z.string().optional(), at: z.string(), retry: z.enum(['turn', 'plan', 'prepare', 'implement', 'publish', 'confirm', 'recheck']).optional(), reference: z.object({ draftId: z.string(), executionId: z.string().optional(), at: z.iso.datetime() }).optional() }), + z.object({ role: z.literal('notice'), tone: z.enum(['info', 'warning', 'error']), title: z.string(), detail: z.string().optional(), at: z.string(), retry: z.enum(['turn', 'plan', 'prepare', 'implement', 'publish', 'confirm', 'recheck']).optional(), reference: z.object({ draftId: z.string(), executionId: z.string().optional(), at: z.iso.datetime() }).optional(), turnId: z.string().optional() }), ]) const sessionSchema = z.object({ baseIntent: z.string(), diff --git a/web/src/features/build/use-build-session.ts b/web/src/features/build/use-build-session.ts index d6cf4b4..95aded3 100644 --- a/web/src/features/build/use-build-session.ts +++ b/web/src/features/build/use-build-session.ts @@ -10,7 +10,7 @@ import { platformErrorEnvelope } from '../../api/platform-error' import { isSessionExpiredError, sessionExpiryStore } from '../../api/session-expiry' import { classifyBuildFailure, failureOffers } from '../../model/build/failure' import { buildCopy } from '../../model/build/copy' -import { messagesFromDraft, planProposal } from '../../model/build/messages' +import { messagesFromDraft, planProposal, shownConversationTurns, supersededFailures, withoutStaleTurnFailures } from '../../model/build/messages' import { composeBuildIntent, conversationTurns, decomposeBuildIntent, isPrepareTurn, prepareAnswers } from '../../model/build/questions' import { parseSpec, serializeSpec } from '../../model/build/spec' import { deriveStage, hasUnplannedKickoff, needsPlanRefresh } from '../../model/build/stage' @@ -48,6 +48,8 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o const lock = useRef(false) const retryContext = useRef<'turn' | 'plan' | 'prepare' | 'implement' | 'publish'>('turn') const observedFailures = useRef(new Set()) + // The draft turn whose observed failure `failure` holds (none for a failed send or another context). + const failedTurnId = useRef(undefined) const blockedUntil = useRef(0) // A 412 from the AI gate is usually the platform rolling out (the API pod restarts, the // runtime target is briefly unadmitted). Retry with backoff before declaring it unavailable. @@ -61,6 +63,9 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o const { app, appView, appProgress, generation, execution, domain, proposalDraft, published, implementation, implementing, destination } = creation const planBlocksStart = Boolean(draft.creationPlanUnreadable) && !isBuildPending(execution) && !draft.createdApplicationId const turn = draft.conversationTurns.at(-1) + // The conversation's last turn as the conversation shows it (APT-1365): its failure is the one observed, guarded and + // retried, never an Excel → app turn recorded after it. `turn` (any kind) still tells whether a job runs. + const conversationTurn = useMemo(() => shownConversationTurns(draft.conversationTurns).at(-1), [draft.conversationTurns]) const running = [generation, turn, execution].some(isBuildPending) const result = deriveStage({ draft, generation, turn, execution, appProgress, implementation: stageImplementation(implementation.state), published, lastPlannedIntent: session.lastPlannedIntent, now }) const { spec } = useMemo(() => parseSpec(draft.specMarkdown), [draft.specMarkdown]) @@ -95,7 +100,8 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o async function receive(next: BuildDraft) { await writeDraft(queryClient, projectId, draftRef, next) } - function fail(error: unknown, context: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish', at = new Date().toISOString(), failedStep?: BuildExecutionStep) { + /** `turnId`: the draft's conversation turn whose failure was observed; a failed send made no turn and has none. */ + function fail(error: unknown, context: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish', at = new Date().toISOString(), failedStep?: BuildExecutionStep, turnId?: string) { const preparationExecution = context === 'prepare' ? draftRef.current.creationExecutions.at(-1) : undefined // Console binding can fail after creation succeeded; keep that execution in the support reference. const reference = { draftId: draft.id, at, ...(preparationExecution ? { executionId: preparationExecution.id } : {}) } @@ -109,6 +115,7 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o ? { ...classified, reason: planRecheck ? buildCopy.failure.limitRecheck : buildCopy.failure.limitRejected } : classified retryContext.current = context + failedTurnId.current = turnId setFailure(next) patch((current) => { // The same failure repeated (retry, reload) stays one notice. @@ -122,7 +129,7 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o const limited = context === 'plan' && next.kind === 'limit' const calm = unconfirmed || next.destination === 'changed' || next.destination === 'blocked' || next.kind === 'plan' || limited const retry = unconfirmed ? 'confirm' as const : context === 'prepare' && draftRef.current.creationPlanUnreadable ? undefined : next.recheck ? 'recheck' as const : next.kind === 'plan' ? 'plan' as const : next.kind !== 'policy' && !limited ? context : undefined - return { ...current, ...(next.kind === 'quota' || next.kind === 'policy' || limited ? { planRequested: false } : {}), messages: [...messages, { role: 'notice', tone: calm ? 'warning' : 'error', title: next.title, detail: next.reason, ...(retry ? { retry } : {}), at, ...(next.reference ? { reference: next.reference } : {}) }] } + return { ...current, ...(next.kind === 'quota' || next.kind === 'policy' || limited ? { planRequested: false } : {}), messages: [...messages, { role: 'notice', tone: calm ? 'warning' : 'error', title: next.title, detail: next.reason, ...(retry ? { retry } : {}), at, ...(next.reference ? { reference: next.reference } : {}), ...(turnId ? { turnId } : {}) }] } }) } async function perform(context: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish', action: () => Promise) { @@ -261,7 +268,7 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o ? unreadableReplanRequested.current && session.planRequested : (isOneOf(turn?.status, 'succeeded') && (session.planRequested || hasUnplannedKickoff(draft))) || (session.prepareRequested && !session.reusePlan && needsPlanRefresh(draft, session.lastPlannedIntent)) || (session.planRequested && creation.planRejected) - const unobservedFailure = [generation, turn].some((operation) => isOneOf(operation?.status, 'failed') && !observedFailures.current.has(operation!.id)) + const unobservedFailure = [generation, conversationTurn].some((operation) => isOneOf(operation?.status, 'failed') && !observedFailures.current.has(operation!.id)) const creationEffects = useDraftCreationEffects(creation, { projectId, groupId, draft, draftRef, tab: session, currentTab: () => store.state, patch, receive, perform, fail, clearFailure: () => setFailure(undefined), busy, lock, failure, running, unsupported: Boolean(result.unsupported), @@ -274,12 +281,12 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o useEffect(() => { // A phase or job state this console does not know starts nothing on its own (stage.ts `unsupported`). if (running || busy || lock.current || session.pending.length || failure || draft.createdApplicationStackId || result.unsupported) return - if ([generation, turn, execution].some((operation) => isOneOf(operation?.status, 'failed') && !observedFailures.current.has(operation!.id))) return + if ([generation, conversationTurn, execution].some((operation) => isOneOf(operation?.status, 'failed') && !observedFailures.current.has(operation!.id))) return if (planFirst) void perform('plan', generate) }, [draft, session.prepareRequested, session.planRequested, session.pending.length, running, busy, failure, creation.defaultPending]) useEffect(() => { - for (const [context, operation] of [['turn', turn], ['plan', generation]] as const) { + for (const [context, operation] of [['turn', conversationTurn], ['plan', generation]] as const) { if (draft.creationPlanUnreadable) continue if (!operation || !isOneOf(operation.status, 'failed') || observedFailures.current.has(operation.id)) continue observedFailures.current.add(operation.id) @@ -287,9 +294,21 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o // An unset repository destination stops every plan alike: trying again waits for the user (after an administrator set it). if (context === 'plan' && session.planRetries === 0 && kind !== 'quota' && kind !== 'policy' && kind !== 'destination') { patch((current) => ({ ...current, planRetries: 1, planRequested: true, messages: [...current.messages, { role: 'notice', tone: 'info', title: text.session.retryPlan, at: new Date().toISOString() }] })) - } else fail(new Error(operation.error ?? text.session.operationFailed), context, operation.finishedAt) + } else fail(new Error(operation.error ?? text.session.operationFailed), context, operation.finishedAt, undefined, context === 'turn' ? operation.id : undefined) } - }, [turn, generation]) + }, [conversationTurn, generation]) + + // A later conversation turn (another tab's resend, say) supersedes an observed turn failure (APT-1365): its notice + // leaves the tab's messages and its failure clears, so neither holds back a pending reply the screen no longer explains. + useEffect(() => { + const current = store.state + const messages = withoutStaleTurnFailures(current.messages, draft.conversationTurns, current.pending.length > 0) + if (messages !== current.messages) patch({ messages }) + if (failedTurnId.current && supersededFailures(draft.conversationTurns).has(failedTurnId.current)) { + failedTurnId.current = undefined + setFailure(undefined) + } + }, [draft.conversationTurns, session.messages, session.pending.length]) // Draft preferences are authoritative across tabs. During implementation only the // preferences/title are writable; specification alignment waits for its lock. @@ -346,7 +365,8 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o else if (context === 'publish' || context === 'implement' || context === 'prepare') creationEffects.retry(context) else if (context === 'recheck') creationEffects.recheck() else if (context === 'plan') patch({ planRequested: true }) - else if (context === 'turn' && !store.state.pending.length && isOneOf(turn?.status, 'failed')) send(turn!.userMessage) + // The turn the conversation shows last (`conversationTurn`), never an Excel → app turn after it. + else if (context === 'turn' && !store.state.pending.length && isOneOf(conversationTurn?.status, 'failed')) send(conversationTurn!.userMessage) } return { session, spec, app, implementation, failure, busy, result, proposal, domain, planBlocksStart, diff --git a/web/src/model/build/copy.en.ts b/web/src/model/build/copy.en.ts index 0296ce0..83d792f 100644 --- a/web/src/model/build/copy.en.ts +++ b/web/src/model/build/copy.en.ts @@ -97,7 +97,7 @@ export const textEn: typeof textJa = { unknownWorkspace: 'We cannot yet confirm whether AI is ready.', timeout: { title: 'Taking longer than expected', reason: 'Your conversation is saved; please try again shortly.' }, busy: { title: 'AI is still working', reason: 'Your changes are saved; work will continue when the previous request finishes.' }, - superseded: 'This request stopped once', + superseded: 'This request was interrupted.', failed: { turn: 'AI could not process your request', plan: 'Could not create plan', implement: 'Building your app stopped', publish: 'Could not save the published state' }, retry: 'Your requirements and plan are saved; try again, or contact your administrator if work keeps stopping.', platform: { title: 'A platform problem stopped app creation', reason: 'This is not a problem with your input or actions. Your requirements and plan are still saved. Wait a little and try again, or share the support reference below with your administrator.' }, diff --git a/web/src/model/build/copy.ts b/web/src/model/build/copy.ts index ed862a8..952ea7f 100644 --- a/web/src/model/build/copy.ts +++ b/web/src/model/build/copy.ts @@ -109,7 +109,7 @@ export const textJa = { timeout: { title: '処理に時間がかかっています', reason: '相談した内容は残っています。少し待ってから、もう一度試してください。' }, busy: { title: 'AI が前の作業を進めています', reason: '内容は残っています。前の作業が終わったら続けます。' }, /** A failed conversation turn a later turn followed (APT-1365): over, information only, never a retry. */ - superseded: 'この依頼は一度止まりました', + superseded: 'この依頼は途中で止まりました', failed: { turn: 'AI が内容を整理できませんでした', plan: '計画を作れませんでした', implement: 'アプリを作る作業が止まりました', publish: '公開済みの状態を保存できませんでした' }, retry: '仕様と計画は残っています。もう一度試してください。何度も止まるときは基盤の担当者に確認してください。', platform: { title: '基盤の問題で作成が止まりました', reason: 'あなたの入力や操作の問題ではありません。仕様と計画はそのまま残っています。少し待ってもう一度試すか、下の問い合わせ番号を基盤の担当者に伝えてください。' }, diff --git a/web/src/model/build/messages.test.ts b/web/src/model/build/messages.test.ts index c90dffe..4f37dac 100644 --- a/web/src/model/build/messages.test.ts +++ b/web/src/model/build/messages.test.ts @@ -160,35 +160,88 @@ describe('superseded turn failure (APT-1365)', () => { expect(notices[0]).toEqual(collapsed) } }) - test('a policy failure followed by a later turn is collapsed alike; as the last turn it stays without retry', () => { + test('a superseded policy refusal keeps its reason (it never offered a retry); as the last turn it stays without retry', () => { const denied = { ...timedOut, error: 'workspace: ai_policy_denied' } expect(classifyBuildFailure(denied.error, undefined, 'turn').kind).toBe('policy') - expect(messagesFromDraft({ ...draft, conversationTurns: [denied, resent] }, [])[1]).toEqual(collapsed) - const last = messagesFromDraft({ ...draft, conversationTurns: [denied] }, [])[1] - expect(last).toMatchObject({ role: 'notice', tone: 'error' }) - expect(last).not.toHaveProperty('retry') - }) - test('the failure notice this tab kept when it saw the failure is not shown again once superseded', () => { - // use-build-session `fail` stores the observed failure at the turn's finish, with the derived notice's title. - const kept = assistantMessage(timedOut, draft.id) - expect(kept).toMatchObject({ role: 'notice', retry: 'turn' }) - const read = { ...draft, conversationTurns: [timedOut, resent] } - const messages = messagesFromDraft(read, [kept]) + const refusal = assistantMessage(denied, draft.id) + expect(refusal).toMatchObject({ role: 'notice', tone: 'error' }) + expect(refusal).not.toHaveProperty('retry') + const messages = messagesFromDraft({ ...draft, conversationTurns: [denied, resent] }, []) + expect(messages[1]).toEqual(refusal) + expect(roles(messages)).toEqual(['user', 'notice:error', 'user', 'assistant']) + // The tab's own notice of that refusal does not add a second one. + const kept = { ...refusal, turnId: denied.id } as BuildMessage + expect(messagesFromDraft({ ...draft, conversationTurns: [denied, resent] }, [kept]).filter((message) => message.role === 'notice')).toEqual([refusal]) + expect(messagesFromDraft({ ...draft, conversationTurns: [denied] }, [])[1]).toEqual(refusal) + }) + + /** The notice use-build-session `fail` saves for an observed turn failure (`turnId`), or for a failed send (none). */ + const saved = (turnId?: string): BuildMessage => ({ + role: 'notice', tone: 'error', title: textJa.failure.timeout.title, detail: textJa.failure.timeout.reason, retry: 'turn', at: collapsed.at, ...(turnId ? { turnId } : {}), + }) + const read = { ...draft, conversationTurns: [timedOut, resent] } + + test('the notice this tab saved when it saw that turn fail is not shown once a later turn followed', () => { + const messages = messagesFromDraft(read, [saved(timedOut.id)]) expect(roles(messages)).toEqual(['user', 'notice:info', 'user', 'assistant']) + expect(messages[1]).toEqual(collapsed) // A reload hands the transcript back as local messages: nothing is added twice. expect(messagesFromDraft(read, messages)).toEqual(messages) }) - test('the copy is short and past tense in Japanese and English', () => { - expect(textJa.failure.superseded).toBe('この依頼は一度止まりました') - expect(textEn.failure.superseded).toBe('This request stopped once') + test('a notice of the same title and time that names another turn, or none (a failed send), is still shown', () => { + for (const notice of [saved('turn-other'), saved()]) { + const messages = messagesFromDraft(read, [notice]) + expect(messages.filter((message) => message.role === 'notice')).toEqual([collapsed, notice]) + } + }) + test('switching the language does not bring back the saved notice of a superseded turn', () => { const restore = preserveLanguage() try { setLanguage('en') - expect(messagesFromDraft({ ...draft, conversationTurns: [timedOut, resent] }, [])[1]).toEqual({ ...collapsed, title: textEn.failure.superseded }) + const messages = messagesFromDraft(read, [saved(timedOut.id)]) + expect(messages.filter((message) => message.role === 'notice')).toEqual([{ ...collapsed, title: textEn.failure.superseded }]) + expect(JSON.stringify(messages)).not.toContain(textJa.failure.timeout.title) } finally { restore() } }) + test('the copy says only that the request was interrupted, in Japanese and English', () => { + expect(textJa.failure.superseded).toBe('この依頼は途中で止まりました') + expect(textEn.failure.superseded).toBe('This request was interrupted.') + }) + + const design = { ...turn, kind: 'ui-design' as const, id: 'turn-ui', userMessage: '__init__', status: 'failed' as const, error: 'codex exited', startedAt: '2026-10-08T02:00:00Z', finishedAt: '2026-10-08T02:00:10Z' } + test('display and retry read the same turns: the last conversation turn, never an Excel → app turn after it', () => { + expect(model.shownConversationTurns([design, resent, timedOut].map(turnOf)).map((item) => item.id)).toEqual([timedOut.id, resent.id]) + expect(model.shownConversationTurns([design, timedOut].map(turnOf)).at(-1)?.id).toBe(timedOut.id) + expect([...model.supersededFailures([design, resent, timedOut].map(turnOf))]).toEqual([timedOut.id]) + expect([...model.supersededFailures([design, timedOut].map(turnOf))]).toEqual([]) + // The design turn is not a later conversation turn: the conversation failure stays the one to retry. + expect(messagesFromDraft({ ...draft, conversationTurns: [timedOut, design] }, []).filter((message) => message.role === 'notice')).toEqual([expect.objectContaining({ tone: 'error', retry: 'turn' })]) + }) + + const stale = (messages: BuildMessage[], wires: readonly unknown[], pending: boolean) => model.withoutStaleTurnFailures(messages, wires.map(turnOf), pending) + const typed: BuildMessage = { role: 'user', text: '担当者も記録したい', at: '2026-10-08T00:01:05Z' } + const planNotice: BuildMessage = { role: 'notice', tone: 'error', title: textJa.failure.timeout.title, at: collapsed.at, retry: 'plan' } + const pruning: [string, BuildMessage[], unknown[], boolean, BuildMessage[]][] = [ + ['a notice naming a superseded turn, with a reply pending', [saved(timedOut.id), typed], [timedOut, resent], true, [typed]], + ['a notice naming a superseded turn, nothing pending', [saved(timedOut.id)], [timedOut, resent], false, []], + ['a notice naming the last failed turn', [typed, saved(timedOut.id)], [timedOut], true, [typed, saved(timedOut.id)]], + ['a notice naming the last turn while an Excel → app turn follows', [saved(timedOut.id)], [timedOut, design], false, [saved(timedOut.id)]], + ['an old saved notice (no turnId), nothing pending, the last turn not failed', [saved()], [timedOut, resent], false, []], + ['an old saved notice, the last turn still running', [saved()], [timedOut, { ...resent, status: 'running', finishedAt: undefined }], false, []], + ['an old saved notice, the last turn failed', [saved()], [timedOut], false, [saved()]], + ['a failed send (no turnId) keeps its pending reply and notice', [typed, saved()], [timedOut, resent], true, [typed, saved()]], + ['a failed send before any turn', [typed, saved()], [], true, [typed, saved()]], + ['a notice of another context', [planNotice], [timedOut, resent], false, [planNotice]], + ] + test.each(pruning)('withoutStaleTurnFailures: %s', (_, messages, wires, pending, expected) => { + expect(stale(messages, wires, pending)).toEqual(expected) + }) + test('withoutStaleTurnFailures answers the same list when nothing is stale', () => { + const messages = [typed, saved(timedOut.id)] + expect(stale(messages, [timedOut], true)).toBe(messages) + }) }) describe('recreated workspace notice (APT-1264)', () => { diff --git a/web/src/model/build/messages.ts b/web/src/model/build/messages.ts index 7e63c7e..dd5d9d2 100644 --- a/web/src/model/build/messages.ts +++ b/web/src/model/build/messages.ts @@ -190,6 +190,40 @@ function supersededFailureNotice(at: string): BuildMessage { return { role: 'notice', tone: 'info', title: buildCopy.failure.superseded, at } } +/** The conversation turns as the conversation shows them, oldest first; `retry('turn')` resends the last one. */ +export function shownConversationTurns(turns: readonly BuildTurn[]): BuildTurn[] { + return conversationTurns([...turns].sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt))) +} + +/** Of the shown conversation turns (oldest first), the failed ones a later conversation turn followed. */ +function supersededIds(shown: readonly BuildTurn[]): Set { + return new Set(shown.slice(0, -1).filter((turn) => isOneOf(turn.status, 'failed')).map((turn) => turn.id)) +} + +/** Failed conversation turns a later conversation turn followed (APT-1365): over, never tried again from their notice. */ +export function supersededFailures(turns: readonly BuildTurn[]): Set { + return supersededIds(shownConversationTurns(turns)) +} + +/** + * The tab's own messages without the turn-failure notices the draft has made stale, so that they neither show nor hold + * back a pending reply (use-build-session stops sending while its last message is a notice with `retry: 'turn'`): + * - a notice naming a superseded failed turn (`turnId`, set when the tab observed that turn fail) is dropped; + * - a notice saved before notices named their turn (no `turnId`) with `retry: 'turn'` is dropped when no reply is pending + * and the last shown conversation turn is not failed. A failed send (HTTP) keeps its reply pending until its retry, so + * without a pending reply such a notice can only be an observed turn failure that is no longer the last turn. + * Every other message stays, a failed send's notice included. Answers `messages` itself when nothing is dropped. + */ +export function withoutStaleTurnFailures(messages: BuildMessage[], turns: readonly BuildTurn[], pending: boolean): BuildMessage[] { + const shown = shownConversationTurns(turns) + const superseded = supersededIds(shown) + const lastFailed = isOneOf(shown.at(-1)?.status, 'failed') + const stale = (message: BuildMessage) => message.role === 'notice' && (message.turnId !== undefined + ? superseded.has(message.turnId) + : message.retry === 'turn' && !pending && !lastFailed) + return messages.some(stale) ? messages.filter((message) => !stale(message)) : messages +} + /** * The newest message the page decides on (re-approval, a rejected plan, the generation limit). A recreated-workspace * notice is display only: it is skipped, also when a device clock behind the server's sorts it after a local notice. @@ -224,20 +258,17 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti // The collapsed line does not hide a switch Excel → app's turns made. for (const turn of excel) messages.push(...recreated(turn)) const turns = conversationTurns(all) - // The failure notices superseded turns would have had: the same notice kept by this tab (a failure it saw) is not shown again. - const superseded: BuildMessage[] = [] - for (const [index, turn] of turns.entries()) { + const superseded = supersededIds(turns) + for (const turn of turns) { messages.push({ role: 'user', text: turn.userMessage, at: turn.startedAt }) // Right below the request, before its answer, also when the answer carries the same time (no finishedAt). messages.push(...recreated(turn)) // A reply in a state this console does not know reads as that, never as an answer or a failure. if (turn.status.kind === 'unknown' || isOneOf(turn.status, 'succeeded', 'failed')) { const reply = assistantMessage(turn, draft.id) - // Only the last turn's failure can be tried again (use-build-session `retry('turn')` resends the last turn). - if (isOneOf(turn.status, 'failed') && index < turns.length - 1) { - superseded.push(reply) - messages.push(supersededFailureNotice(reply.at)) - } else messages.push(reply) + // Only the last conversation turn's failure can be tried again (use-build-session `retry('turn')` resends it): a + // superseded one that offered a retry reads as one past line; one that never did (a policy refusal) keeps its reason. + messages.push(superseded.has(turn.id) && reply.role === 'notice' && reply.retry ? supersededFailureNotice(reply.at) : reply) } } // A turn of a kind this console does not know is not shown, but its switch is still told. @@ -247,14 +278,16 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti const proposal = proposalMessage(draft, options.lastPlannedIntent, options.destination) if (proposal) messages.push(proposal) for (const message of extra) { - const same = (item: BuildMessage) => { + // The tab's notice of a failure it observed is over once a later conversation turn followed that turn. + if (message.role === 'notice' && message.turnId !== undefined && superseded.has(message.turnId)) continue + const duplicate = messages.some((item) => { if (item.role !== message.role) return false if (item.role === 'assistant' && message.role === 'assistant' && message.turnId) return item.turnId === message.turnId if (item.at !== message.at) return false if (item.role === 'notice' && message.role === 'notice') return item.title === message.title return 'text' in item && 'text' in message && item.text === message.text - } - if (!messages.some(same) && !superseded.some(same)) messages.push(message) + }) + if (!duplicate) messages.push(message) } // Only observed template startup earns the completion line; execution success // alone merely proves that the application's resources were created. diff --git a/web/src/model/build/types.ts b/web/src/model/build/types.ts index ab63e7e..a5d9b21 100644 --- a/web/src/model/build/types.ts +++ b/web/src/model/build/types.ts @@ -60,8 +60,10 @@ export type BuildMessage = * 「もう一度確かめる」 (the same plan validated once more) and 「計画を作り直す」. * `kind: 'workspace-recreated'`: display only (messages.ts#workspaceRecreatedNotice); it never stands for the * conversation's state, so decisions read past it (messages.ts#lastActionable). + * `turnId`: the draft's conversation turn whose failure the tab observed (APT-1365); a failed send, which made no turn, + * has none. Notices saved before it existed have none either (messages.ts#withoutStaleTurnFailures). */ - | { role: 'notice'; tone: 'info' | 'warning' | 'error'; title: string; detail?: string; at: string; retry?: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish' | 'confirm' | 'recheck'; reference?: BuildFailure['reference']; kind?: 'workspace-recreated' } + | { role: 'notice'; tone: 'info' | 'warning' | 'error'; title: string; detail?: string; at: string; retry?: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish' | 'confirm' | 'recheck'; reference?: BuildFailure['reference']; kind?: 'workspace-recreated'; turnId?: string } export interface ProgressCard { kind: 'workspace' | 'turn' | 'plan' | 'prepare' | 'implement' | 'publish' title: string From 470c80cacbfbb771a15009945f9ecefcf9adad52 Mon Sep 17 00:00:00 2001 From: reoring Date: Fri, 20 Nov 2026 02:23:35 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Tell=20a=20stopped=20Excel=20=E2=86=92=20ap?= =?UTF-8?q?p=20step=20on=20the=20build=20page=20and=20link=20back=20to=20c?= =?UTF-8?q?ontinue=20it=20(APT-1365=20review=202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Review 2 of #48: once observation and retry follow the conversation's own last turn, a draft whose Excel → app turn failed showed nothing on the build page (opened from 作りかけ), and an analysis that succeeded before a failed screen design still read as 「解析と画面の決定は済んでいます」. - When the latest Excel → app turn (analysis or screen design) failed, the conversation shows one line 「Excel から作る作業が途中で止まりました。「Excel から作る」で続けてください」 with a link 「「Excel から作る」で続ける」 to that page, which retries each step by its kind; no retry here. - Tests: stopped-step cases in messages.test.ts; story case E (a failed screen-design turn shows the line and the link to /-/excel2app?draft=, no alert, no 「もう一度試す」). --- web/e2e/stories/build-turn-retry.mock.spec.ts | 16 ++++++ web/src/features/build/conversation-pane.tsx | 2 +- web/src/features/build/copy.en.ts | 1 + web/src/features/build/copy.ts | 2 + web/src/model/build/copy.en.ts | 1 + web/src/model/build/copy.ts | 2 + web/src/model/build/messages.test.ts | 51 ++++++++++++++++++- web/src/model/build/messages.ts | 8 ++- web/src/model/build/questions.ts | 7 +-- web/src/model/build/types.ts | 5 +- 10 files changed, 86 insertions(+), 9 deletions(-) diff --git a/web/e2e/stories/build-turn-retry.mock.spec.ts b/web/e2e/stories/build-turn-retry.mock.spec.ts index c402ae3..b2ac1d3 100644 --- a/web/e2e/stories/build-turn-retry.mock.spec.ts +++ b/web/e2e/stories/build-turn-retry.mock.spec.ts @@ -133,4 +133,20 @@ test.describe('build conversation turn retry @build-turn-retry', () => { await expect(conversation.getByRole('alert')).toHaveCount(0) await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) }) + + test('a draft whose Excel → app step stopped says so and links back to Excel から作る, with nothing to retry here @mock @story', async ({ page, mock, request }) => { + await mock.platform('codex', { available: true }) + const draftId = await draftWithTurns(request, mock, []) + await mock.platform('turn-failure', { error: 'codex exited', kind: 'ui-design' }) + expect((await request.post(`${root}/application-drafts/${draftId}/conversation-turns`, { data: { kind: 'ui-design', message: '__init__' } })).ok()).toBe(true) + await mock.advance() + + await page.goto(`/-/build/${draftId}`) + const conversation = page.getByRole('log', { name: 'AI との会話' }) + await expect(conversation).toContainText(buildText.questions.excelStopped) + await expect(conversation).not.toContainText(buildText.questions.excelReady) + await expect(conversation.getByRole('link', { name: text.conversation.excelResume, exact: true })).toHaveAttribute('href', new RegExp(`/-/excel2app\\?draft=${draftId}$`)) + await expect(conversation.getByRole('alert')).toHaveCount(0) + await expect(page.getByRole('button', { name: text.conversation.retry, exact: true })).toHaveCount(0) + }) }) diff --git a/web/src/features/build/conversation-pane.tsx b/web/src/features/build/conversation-pane.tsx index a8c2053..184ff08 100644 --- a/web/src/features/build/conversation-pane.tsx +++ b/web/src/features/build/conversation-pane.tsx @@ -195,6 +195,6 @@ export function AssistantMessage({ message, active, action }: { message: Assista
    {changed.map((item, index) =>
  • {item}
  • )}
: null} {question ?
0) && 'mt-2.5')}>{question}
: null} - {message.link ? {uiText.conversation.excelReview} : null} + {message.link ? {message.link.resume ? uiText.conversation.excelResume : uiText.conversation.excelReview} : null} } diff --git a/web/src/features/build/copy.en.ts b/web/src/features/build/copy.en.ts index b539efe..f3e07dd 100644 --- a/web/src/features/build/copy.en.ts +++ b/web/src/features/build/copy.en.ts @@ -46,6 +46,7 @@ export const textEn: typeof textJa = { labelSeparator: ' · ', changed: 'What changed', excelReview: 'See the analysis and screens', + excelResume: 'Continue in Start from Excel', }, page: { title: (name: string) => `${name} — Build with AI`, diff --git a/web/src/features/build/copy.ts b/web/src/features/build/copy.ts index 3667abf..9c7a45b 100644 --- a/web/src/features/build/copy.ts +++ b/web/src/features/build/copy.ts @@ -52,6 +52,8 @@ export const textJa = { changed: '変えたところ', /** The collapsed Excel → app line links back to the analysis and the UI preview. */ excelReview: '解析と画面を見る', + /** A stopped Excel → app step is continued there. */ + excelResume: '「Excel から作る」で続ける', }, page: { title: (name: string) => `${name} — AI と作る`, diff --git a/web/src/model/build/copy.en.ts b/web/src/model/build/copy.en.ts index 83d792f..d626b0c 100644 --- a/web/src/model/build/copy.en.ts +++ b/web/src/model/build/copy.en.ts @@ -9,6 +9,7 @@ export const textEn: typeof textJa = { kickoffReply: 'Propose an app from this', prepareTurn: 'While preparing the app, ask me one question at a time about its published name and who can see it.', excelReady: 'The Excel analysis and the screen decisions are done', + excelStopped: 'Building from Excel stopped partway. Continue in Start from Excel.', }, primary: { prepare: 'Build this app', afterPlan: 'Build when planned', refresh: 'Update plan and build', publish: 'Publish', continue: 'Keep improving' }, proposal: { diff --git a/web/src/model/build/copy.ts b/web/src/model/build/copy.ts index 952ea7f..e4d566c 100644 --- a/web/src/model/build/copy.ts +++ b/web/src/model/build/copy.ts @@ -12,6 +12,8 @@ export const textJa = { prepareTurn: 'アプリを用意している間に、公開するときの名前と、誰に見せるかを一つずつ確認してください。', /** The excel2app analysis and screen-design turns, collapsed into one line of the conversation. */ excelReady: 'Excel の解析と画面の決定は済んでいます', + /** The latest of those turns failed: it is continued in Excel から作る, which retries each step by its kind. */ + excelStopped: 'Excel から作る作業が途中で止まりました。「Excel から作る」で続けてください', }, primary: { prepare: 'この内容で作る', afterPlan: '計画ができたら作る', refresh: '計画を更新して作る', publish: '公開する', continue: '続けて直す' }, proposal: { diff --git a/web/src/model/build/messages.test.ts b/web/src/model/build/messages.test.ts index 4f37dac..840a420 100644 --- a/web/src/model/build/messages.test.ts +++ b/web/src/model/build/messages.test.ts @@ -121,8 +121,55 @@ describe('conversation history', () => { expect(JSON.stringify(messages)).not.toContain('__init__') expect(JSON.stringify(messages)).not.toContain('```json') expect(replyOptions(messagesFromDraft({ ...draft, conversationTurns: [analysis, init] }, []))).toEqual([buildCopy.questions.kickoffReply]) - // Nothing is done until an Excel turn succeeded. - expect(messagesFromDraft({ ...draft, conversationTurns: [{ ...analysis, status: 'failed' }] }, [])).toEqual([]) + // Nothing is called done until an Excel turn succeeded; a failed one says where to continue (below). + expect(messagesFromDraft({ ...draft, conversationTurns: [{ ...analysis, status: 'running', finishedAt: undefined }] }, [])).toEqual([]) + }) + describe('a stopped Excel → app step', () => { + const analysis = { ...turn, kind: 'excel-analysis' as const, id: 'turn-excel', userMessage: 'この Excel を読み取ってください', startedAt: '2026-10-08T00:00:10Z', finishedAt: '2026-10-08T00:00:40Z' } + const design = { ...turn, kind: 'ui-design' as const, id: 'turn-ui-1', userMessage: '__init__', startedAt: '2026-10-08T00:00:50Z', finishedAt: '2026-10-08T00:00:55Z' } + const stopped = (at: string) => { + const text = buildCopy.questions.excelStopped + return { role: 'assistant', text, summary: text, at, turnId: `excel:${draft.id}`, link: { kind: 'excel2app', draftId: draft.id, resume: true } } satisfies BuildMessage + } + test('the latest analysis failed: one line that sends the user back to Excel → app, no ready line and no retry', () => { + const messages = messagesFromDraft({ ...draft, conversationTurns: [{ ...analysis, status: 'failed', error: 'codex exited' }] }, []) + expect(messages).toEqual([stopped(analysis.finishedAt)]) + expect(replyOptions(messages)).toEqual([]) + expect(JSON.stringify(messages)).not.toContain(buildCopy.questions.excelReady) + }) + test('the analysis succeeded and the screen design failed after it: the stop line, not the ready line', () => { + const messages = messagesFromDraft({ ...draft, conversationTurns: [{ ...design, status: 'failed', error: 'codex exited' }, analysis] }, []) + expect(messages).toEqual([stopped(design.finishedAt)]) + expect(JSON.stringify(messages)).not.toContain('__init__') + }) + test('a failure followed by a succeeded Excel → app step, or both succeeded: the ready line as before', () => { + const ready = buildCopy.questions.excelReady + const line = { role: 'assistant', text: ready, summary: ready, at: analysis.startedAt, turnId: `excel:${draft.id}`, options: [buildCopy.questions.kickoffReply], link: { kind: 'excel2app', draftId: draft.id } } satisfies BuildMessage + expect(messagesFromDraft({ ...draft, conversationTurns: [analysis, design] }, [])).toEqual([line]) + expect(messagesFromDraft({ ...draft, conversationTurns: [{ ...analysis, status: 'failed', error: 'codex exited' }, { ...analysis, id: 'turn-excel-2', startedAt: '2026-10-08T00:00:45Z', finishedAt: '2026-10-08T00:00:48Z' }, design] }, [])).toEqual([line]) + }) + test('the line is in the language in use', () => { + const restore = preserveLanguage() + try { + setLanguage('en') + expect(messagesFromDraft({ ...draft, conversationTurns: [{ ...analysis, status: 'failed', error: 'codex exited' }] }, [])).toEqual([{ ...stopped(analysis.finishedAt), text: textEn.questions.excelStopped, summary: textEn.questions.excelStopped }]) + } finally { + restore() + } + }) + test('offers no reply chips, and is not counted as a reply toward 「この内容で提案して」', () => { + const second = { ...turn, id: 'turn-2', userMessage: '入れる', startedAt: '2026-10-08T00:02:00Z', finishedAt: '2026-10-08T00:02:10Z' } + const stoppedLater = { ...design, status: 'failed' as const, error: 'codex exited', startedAt: '2026-10-08T00:03:00Z', finishedAt: '2026-10-08T00:03:10Z' } + // Two replies, then the stopped step as the latest line: nothing to answer here, no proposal chip. + const afterTwo = messagesFromDraft({ ...draft, conversationTurns: [turn, second, stoppedLater] }, []) + expect(afterTwo.at(-1)).toEqual(stopped(stoppedLater.finishedAt)) + expect(replyOptions(afterTwo)).toEqual([]) + // One reply before it and one after: two replies, so the proposal chip is not offered yet. + const third = { ...second, id: 'turn-3', userMessage: '入れない', startedAt: '2026-10-08T00:04:00Z', finishedAt: '2026-10-08T00:04:10Z' } + const around = messagesFromDraft({ ...draft, conversationTurns: [turn, stoppedLater, third] }, []) + expect(around.at(-1)).toMatchObject({ role: 'assistant', turnId: third.id }) + expect(replyOptions(around)).toEqual(turn.suggestedReplies!) + }) }) }) diff --git a/web/src/model/build/messages.ts b/web/src/model/build/messages.ts index dd5d9d2..eade532 100644 --- a/web/src/model/build/messages.ts +++ b/web/src/model/build/messages.ts @@ -251,7 +251,13 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti // linked back to Excel → app; 「この内容で提案して」 is offered right away, since the // specification is already written. const excel = all.filter((turn) => isOneOf(turn.kind, 'excel-analysis', 'ui-design')) - if (excel.some((turn) => isOneOf(turn.status, 'succeeded'))) { + const latestExcel = excel.at(-1) + if (isOneOf(latestExcel?.status, 'failed')) { + // The latest Excel → app step stopped: it is continued in Excel → app, which retries each step by its kind; the + // build page offers no retry for it and does not call the analysis and screens done. + const text = buildCopy.questions.excelStopped + messages.push({ role: 'assistant', text, summary: text, at: latestExcel!.finishedAt ?? latestExcel!.startedAt, turnId: `excel:${draft.id}`, link: { kind: 'excel2app', draftId: draft.id, resume: true } }) + } else if (excel.some((turn) => isOneOf(turn.status, 'succeeded'))) { const text = buildCopy.questions.excelReady messages.push({ role: 'assistant', text, summary: text, at: excel[0]!.startedAt, turnId: `excel:${draft.id}`, options: [buildCopy.questions.kickoffReply], link: { kind: 'excel2app', draftId: draft.id } }) } diff --git a/web/src/model/build/questions.ts b/web/src/model/build/questions.ts index ee10d4d..9e614c6 100644 --- a/web/src/model/build/questions.ts +++ b/web/src/model/build/questions.ts @@ -30,17 +30,18 @@ export function isPrepareTurn(text: string): boolean { return text === textJa.questions.prepareTurn || text === textEn.questions.prepareTurn } -/** Only successful AI turns count; notices and the derived proposal are not replies. */ +/** Only successful AI turns count; notices, the derived proposal and a stopped Excel → app step are not replies. */ export function replyOptions(messages: BuildMessage[]): string[] { const conversation = messages.filter((message) => message.role !== 'notice' && !(message.role === 'assistant' && message.proposal)) const latest = conversation.at(-1) - if (latest?.role !== 'assistant') return [] + // A stopped Excel → app step (messages.ts, `link.resume`) is continued in Excel から作る: nothing is answered here. + if (latest?.role !== 'assistant' || latest.link?.resume) return [] const previous = conversation.at(-2) const options = latest.options ?? [] if (previous?.role === 'user' && isKickoffReply(previous.text)) return options // 用意する asks two fixed things; 「この内容で提案して」 would restart planning. if (conversation.some((message) => message.role === 'user' && isPrepareTurn(message.text))) return options - const successful = conversation.filter((message) => message.role === 'assistant' && message.turnId).length + const successful = conversation.filter((message) => message.role === 'assistant' && message.turnId && !message.link?.resume).length return successful >= 3 && !options.some(isKickoffReply) ? [...options, buildCopy.questions.kickoffReply] : options } diff --git a/web/src/model/build/types.ts b/web/src/model/build/types.ts index a5d9b21..3a6ccee 100644 --- a/web/src/model/build/types.ts +++ b/web/src/model/build/types.ts @@ -51,9 +51,10 @@ export type BuildMessage = /** * `text` is the reply as written (markdown); `summary` / `changed` / `question` are its * parsed parts (messages.ts#parseAssistantMessage). `link` points back to where the - * message's content was made (the collapsed Excel → app line opens its analysis and screens). + * message's content was made (the collapsed Excel → app line opens its analysis and screens; with `resume`, the line + * saying an Excel → app step stopped sends the user back there to continue it). */ - | { role: 'assistant'; text: string; summary?: string; changed?: string[]; question?: string; options?: string[]; proposal?: BuildProposal; link?: { kind: 'excel2app'; draftId: string }; at: string; turnId?: string } + | { role: 'assistant'; text: string; summary?: string; changed?: string[]; question?: string; options?: string[]; proposal?: BuildProposal; link?: { kind: 'excel2app'; draftId: string; resume?: true }; at: string; turnId?: string } /** * `retry: 'confirm'` re-reads the draft after a write whose answer could not be read; it never resends that write. * `retry: 'recheck'`: Platform's validation rejected the plan for a cause that may lie outside it; the notice offers