diff --git a/web/src/api/build.test.ts b/web/src/api/build.test.ts index 262f769..50ce5d7 100644 --- a/web/src/api/build.test.ts +++ b/web/src/api/build.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, expect, mock, test } from 'bun:test' import { QueryClient, QueryObserver, skipToken } from '@tanstack/react-query' import * as api from './build' import { BUILD_POLL_MS, buildDraftOptions, buildKeys, draftsOptions } from './queries/build' -import { draftOf, runOf } from './testing/build-domain' +import { draftOf, generationOf, runOf, turnOf } from './testing/build-domain' import { POLL_INTERVAL_MS, readRetryDelay, retryReadQuery } from './queries/shared' import { isPublishPreparationPending } from './publish-retry' @@ -44,6 +44,17 @@ afterEach(() => { else Reflect.deleteProperty(globalThis, 'sessionStorage') }) +test('turn and plan generation readers keep the workspace they replaced, and read answers without it (APT-1264)', () => { + expect(turnOf({ ...turn, replacedDevWorkspaceId: 'workspace-0' }).replacedDevWorkspaceId).toBe('workspace-0') + expect(generationOf({ ...generation, replacedDevWorkspaceId: 'workspace-0' }).replacedDevWorkspaceId).toBe('workspace-0') + // An older Platform never sends the field: the same answers read unchanged. + expect(turnOf(turn).replacedDevWorkspaceId).toBeUndefined() + expect(generationOf(generation).replacedDevWorkspaceId).toBeUndefined() + const read = draftOf({ ...draft, conversationTurns: [{ ...turn, replacedDevWorkspaceId: 'workspace-0' }, { ...turn, id: 'turn-2' }], creationPlanGenerations: [{ ...generation, replacedDevWorkspaceId: 'workspace-0' }] }) + expect(read.conversationTurns.map((item) => item.replacedDevWorkspaceId)).toEqual(['workspace-0', undefined]) + expect(read.creationPlanGenerations[0]?.replacedDevWorkspaceId).toBe('workspace-0') +}) + test('all build API adapters use contract routes, payloads and idempotency keys per mutation attempt', async () => { await api.createDraft('project-1', { intent: '見積を作る', title: '見積' }) await api.updateDraft('project-1', 'draft-1', { specMarkdown: '---\nspec: {}\n---\n', intent: '新しい内容', title: '新しい名前' }) diff --git a/web/src/api/contracts/platform/build.ts b/web/src/api/contracts/platform/build.ts index bd2ac5b..02a8b67 100644 --- a/web/src/api/contracts/platform/build.ts +++ b/web/src/api/contracts/platform/build.ts @@ -67,17 +67,23 @@ export function openCanonical(canonical: { options: readonly K const DRAFT_OMITS = 'platform-api internal/api/dto_application_draft.go' +// The retired workspace a turn or plan generation replaced (APT-1264): present only on the record that switched to a new +// workspace. Restated here until the published api-schema carries it; an older Platform never sends it. +const replacedDevWorkspaceId = z.string().optional() + export const turnReader: z.ZodType = ApplicationDraftConversationTurn.extend({ // A turn without `kind` predates the field and is a conversation turn (canonical default). kind: openCanonical(ApplicationDraftConversationTurnKind).default({ kind: 'known', value: 'conversation' }), status: openCanonical(ApplicationDraftConversationTurnStatus), excelProgress: excelProgressReader.optional(), uiDesign: uiDesignReader.optional(), + replacedDevWorkspaceId, }) export const generationReader: z.ZodType = ApplicationDraftCreationPlanGeneration.extend({ status: openCanonical(ApplicationDraftCreationPlanGenerationStatus), stage: openCanonical(ApplicationDraftCreationPlanGeneration.shape.stage.unwrap()).optional(), + replacedDevWorkspaceId, }) const stepReader: z.ZodType = ApplicationDraftCreationExecutionStep.extend({ diff --git a/web/src/features/build/build-page-wire.test.tsx b/web/src/features/build/build-page-wire.test.tsx index 8e4f4f1..3ab9790 100644 --- a/web/src/features/build/build-page-wire.test.tsx +++ b/web/src/features/build/build-page-wire.test.tsx @@ -987,6 +987,31 @@ describe('a plan Platform\'s validation rejects is an answer about the plan (APT expect(proposalButtons()).toEqual([buildCopy.primary.prepare]) }) + test('at the generation limit, a recreated-workspace notice sorted after the limit notice (device clock behind the server) brings back no new plan (APT-1264)', async () => { + const { draftId, key } = await rejected(fieldErrorAnswer) + refusals.push({ method: 'POST', path: generations(draftId), status: 412, body: { error: { code: 'failed_precondition', message: 'application draft has reached 20 plan generation attempts' } } }) + await click(action(buildCopy.failure.plan.incomplete.title, makeAgain)) + await settle(10) + expect(notices(buildCopy.failure.limit.title, '#build-conversation')).toHaveLength(1) + expect(proposalButtons()).toEqual([]) + // Platform marks the plan's generation as the switch from a retired workspace. Its start (server time) reads later + // than the limit notice's (this device's time), so the display-only notice is the conversation's last message. + const ahead = new Date(Date.now() + 60 * 60_000).toISOString() + rewrites.push({ + method: 'GET', path: new RegExp(`${draftPath(draftId)}$`), once: false, + body: (wire) => rewriteDraftWire(wire, draftId, (draft) => ({ ...draft, creationPlanGenerations: (draft.creationPlanGenerations as Json[]).map((generation) => ({ ...generation, startedAt: ahead, replacedDevWorkspaceId: 'ws-retired' })) })), + }) + await tick(key) + await settle(10) + expect(notices(buildCopy.workspaceRecreated, '#build-conversation')).toHaveLength(1) + expect(conversation().lastIndexOf(buildCopy.workspaceRecreated)).toBeGreaterThan(conversation().lastIndexOf(buildCopy.failure.limit.title)) + // The limit is still what the page decides on: 「計画を作り直す」 is not offered again, and nothing is generated. + expect(labels(buildCopy.failure.limit.title)).toEqual([]) + expect(labels(buildCopy.workspaceRecreated)).toEqual([]) + expect(proposalButtons()).toEqual([]) + expect(count('POST', generations(draftId))).toBe(1) + }) + // A failed request is not an answer about the plan: preparing asks no AI, so a 500 and a gateway 503 alike are the // platform failure with its reference, and the same approval may be tried again. test.each([500, 503])('a failed validation request (%i) is the platform failure with its reference, never a plan rejection', async (status) => { diff --git a/web/src/features/build/build-page.tsx b/web/src/features/build/build-page.tsx index 4ff0f9f..7d7dab3 100644 --- a/web/src/features/build/build-page.tsx +++ b/web/src/features/build/build-page.tsx @@ -24,6 +24,7 @@ import { useEffect, useState, type ReactNode } from 'react' import { buildKeys, useBuildDraft } from '../../api/queries/build' import { useGroups } from '../../api/queries/console' import { buildCopy } from '../../model/build/copy' +import { lastActionable } from '../../model/build/messages' import { isBuildPending } from '../../model/build/progress' import { paths } from '../../routes/paths' import { setArtifactCollapsed, shellStore } from '../../shell/store' @@ -79,7 +80,8 @@ function Session({ draft, groupId, stale }: { draft: BuildDraft; groupId: string const primary = { ...build.result.primary, enabled: build.result.primary.enabled && !build.busy && !sharing && !updatingPlan && (build.result.primary.action !== 'publish' || !appReadOnly) } // 決める: the prepare action is attached to the AI's proposal, labelled by what pressing it will do. After the // destination moved, the notice right below the proposal carries the same action (once, beside its explanation). - const lastMessage = build.messages.at(-1) + // A recreated-workspace notice is display only: what follows is decided on the newest message before it. + const lastMessage = lastActionable(build.messages) const reapproveNotice = lastMessage?.role === 'notice' && lastMessage.retry === 'prepare' && lastMessage.title === buildCopy.failure.destination.changed.title // A plan Platform's validation rejected is never approved again. Its actions (「もう一度確かめる」 when the cause may lie // outside the plan, 「計画を作り直す」) are on the notice that explains the rejection, or on the proposal when that notice diff --git a/web/src/features/build/conversation-pane.tsx b/web/src/features/build/conversation-pane.tsx index d5bdad1..a8c2053 100644 --- a/web/src/features/build/conversation-pane.tsx +++ b/web/src/features/build/conversation-pane.tsx @@ -148,6 +148,14 @@ export function UserMessage({ text }: { text: string }) { } +/** + * The workspace was recreated (APT-1264), where a conversation keeps its own records (improve, Excel → app): + * information only, the same as the build conversation's derived notice (messages.ts#workspaceRecreatedNotice). + */ +export function WorkspaceRecreatedNotice({ className }: { className?: string }) { + return +} + /** A failure's support reference, with its copy button. */ export function FailureReference({ reference }: { reference: NonNullable }) { const value = buildFailureReference(reference) diff --git a/web/src/features/build/copy.test.tsx b/web/src/features/build/copy.test.tsx index c51e8d9..353b355 100644 --- a/web/src/features/build/copy.test.tsx +++ b/web/src/features/build/copy.test.tsx @@ -7,6 +7,7 @@ import { isPlatformNotFound } from '../../api/platform-error' import { draftOf, runOf, taskOf } from '../../api/testing/build-domain' import { buildCopy } from '../../model/build/copy' import { buildFailureReference, classifyBuildFailure, destinationFailure } from '../../model/build/failure' +import { messagesFromDraft } from '../../model/build/messages' import { deriveStage, draftPublished } from '../../model/build/stage' import type { BuildProposal, BuildSpec } from '../../model/build/types' import type { BuildDraft } from '../../model/contracts/build' @@ -126,6 +127,34 @@ test.each(['ja', 'en'] as const)('a moved destination is approved again with the expect(render('blocked')).toContain(`>${text.conversation.retry}`) }) +test.each(['ja', 'en'] as const)('a recreated workspace is announced once, on the turn that replaced it, as information only (%s)', (language) => { + setLanguage(language) + const at = (minute: number, second = 0) => `2026-11-18T00:0${minute}:${String(second).padStart(2, '0')}Z` + const turn = (id: string, minute: number, fields: Record = {}) => ({ + id, kind: 'conversation', status: 'succeeded', startedAt: at(minute), finishedAt: at(minute, 10), devWorkspaceId: 'ws-new', userMessage: `request ${id}`, assistantMessage: `answer ${id}`, ...fields, + }) + const draft = draftOf({ + id: 'draft-1', projectId: 'project-1', title: 'Contacts', intent: 'Keep contacts', phase: 'specifying', specMarkdown: '', architectureMarkdown: '', ownerUserId: 'user-1', createdAt: at(0), updatedAt: at(4), + conversationTurns: [turn('turn-1', 1, { devWorkspaceId: 'ws-old' }), turn('turn-2', 2, { replacedDevWorkspaceId: 'ws-old' }), turn('turn-3', 3)], + creationPlanGenerations: [{ id: 'gen-1', status: 'succeeded', startedAt: at(4), finishedAt: at(4, 30), devWorkspaceId: 'ws-new' }], + }) + const markup = renderToStaticMarkup( {}} onRetry={() => {}} onUseName={() => {}} + />) + const notice = buildCopy.workspaceRecreated + expect(notice).toBe(language === 'ja' ? '作業環境を作り直しました。会話と計画は引き継いでいます' : 'Your workspace was recreated. The conversation and plan are kept.') + expect(markup.split(notice)).toHaveLength(2) + // Below the request that switched workspaces and above its answer; the later turn carries none. + expect(markup.indexOf('request turn-2')).toBeLessThan(markup.indexOf(notice)) + expect(markup.indexOf(notice)).toBeLessThan(markup.indexOf('answer turn-2')) + // A calm status, not an alert: no retry, no support reference. + expect(markup).toContain('role="status"') + expect(markup).not.toContain('role="alert"') + expect(markup).not.toContain(`>${text.conversation.retry}`) + expect(markup).not.toContain(buildCopy.failure.copyReference) +}) + // The rendered state needs the router (LinkButton); app-build-ai.mock.spec.ts covers it. Here: the // classifier that routes a 404 away from 「しばらくしてから再読み込み」, and the wording. test('a 404 draft is an answer, not a transient failure, and the copy names the signed-in account', () => { diff --git a/web/src/features/excel2app/excel2app-page-wire.test.tsx b/web/src/features/excel2app/excel2app-page-wire.test.tsx index ca88bc9..4f29380 100644 --- a/web/src/features/excel2app/excel2app-page-wire.test.tsx +++ b/web/src/features/excel2app/excel2app-page-wire.test.tsx @@ -375,3 +375,81 @@ describe('X5: a 2xx Excel write whose answer cannot be read', () => { expect(stepTitle()).toBe(text.preview.title) }) }) + +describe('APT-1264: a turn that replaced a retired workspace', () => { + /** Platform marks the draft's turns of `kind` as the switch from a retired workspace (every read of the draft). */ + function replaced(kind: 'excel-analysis' | 'ui-design') { + rewrites.push({ + method: 'GET', path: /\/application-drafts\/[^/]+$/, once: false, + body: (wire) => Array.isArray(wire.conversationTurns) + ? { ...wire, conversationTurns: (wire.conversationTurns as Json[]).map((turn) => turn.kind === kind ? { ...turn, replacedDevWorkspaceId: 'ws-retired' } : turn) } + : wire, + }) + } + const recreated = () => [...container.querySelectorAll('[role="status"]')].filter((item) => item.querySelector('p')?.textContent === buildCopy.workspaceRecreated) + async function reopen(draftId: string) { + await act(async () => { root?.unmount() }) + container.remove() + await renderExcel(draftId) + } + + test('the analysis step says so once, also after the same draft is opened again', async () => { + const draftId = await storedDraft() + // Started but not advanced: the analysis runs, so the page opens on its step. + await call('POST', `${draftPath(draftId)}/conversation-turns`, { kind: 'excel-analysis', message: '' }) + replaced('excel-analysis') + await renderExcel(draftId) + await until(() => Boolean(byTestId('excel2app-workspace-recreated'))) + expect(recreated()).toHaveLength(1) + expect(buttonsIn(byTestId('excel2app-workspace-recreated')!)).toEqual([]) + await reopen(draftId) + await until(() => Boolean(byTestId('excel2app-workspace-recreated'))) + expect(recreated()).toHaveLength(1) + }) + + test('an earlier analysis that replaced the workspace and failed says nothing on the analysis shown after it; the shown one that replaced does', async () => { + const draftId = await storedDraft() + const startAnalysis = async () => ((await call('POST', `${draftPath(draftId)}/conversation-turns`, { kind: 'excel-analysis', message: '' })).resource as Json).id as string + const first = await startAnalysis() + await call('POST', '/api/v1/__mock/advance') + // Started but not advanced: the second analysis (reusing what the first read) runs, so the page opens on its step. + const second = await startAnalysis() + /** The first analysis failed after replacing a retired workspace; `marked` carries the switch (only it). */ + const reads = (marked: string) => rewrites.push({ + method: 'GET', path: new RegExp(`${draftPath(draftId)}$`), once: false, + body: (wire) => ({ + ...Object.fromEntries(Object.entries(wire).filter(([key]) => key !== 'excelAnalysis')), + conversationTurns: (wire.conversationTurns as Json[]).map((turn) => ({ + ...turn, + ...(turn.id === first ? { status: 'failed', error: 'codex exited' } : {}), + ...(turn.id === marked ? { replacedDevWorkspaceId: 'ws-retired' } : {}), + })), + }), + }) + reads(first) + await renderExcel(draftId) + await until(() => stepTitle() === text.analysis.running) + await settle(10) + expect(byTestId('excel2app-workspace-recreated')).toBeNull() + expect(recreated()).toHaveLength(0) + rewrites = [] + reads(second) + await reopen(draftId) + await until(() => Boolean(byTestId('excel2app-workspace-recreated'))) + expect(recreated()).toHaveLength(1) + }) + + test('the preview chat says so once, at the design turn, also after the same draft is opened again', async () => { + const draftId = await storedDraft({ analysed: true, designed: true }) + replaced('ui-design') + await renderExcel(draftId) + await until(() => Boolean(byTestId('excel2app-chat-input'))) + expect(recreated()).toHaveLength(1) + expect(container.querySelectorAll('[data-testid="excel2app-chat-message"][data-role="notice"]')).toHaveLength(1) + // The analysis turn did not switch: its step has nothing to say. + expect(byTestId('excel2app-workspace-recreated')).toBeNull() + await reopen(draftId) + await until(() => Boolean(byTestId('excel2app-chat-input'))) + expect(recreated()).toHaveLength(1) + }) +}) diff --git a/web/src/features/excel2app/page.tsx b/web/src/features/excel2app/page.tsx index 5cf3f79..ac8cf20 100644 --- a/web/src/features/excel2app/page.tsx +++ b/web/src/features/excel2app/page.tsx @@ -20,6 +20,7 @@ import { Button, Card, CardBody, cn, CopyButton, EmptyState, Field, focusHeading import { ResourceBoundary, type ResourceQuery } from '../../ui/resource-boundary' import { text as buildText } from '../build/copy' import { resolveBuildGroup } from '../build/entry' +import { WorkspaceRecreatedNotice } from '../build/conversation-pane' import { UnconfirmedNotice } from '../build/unconfirmed-notice' import { filesFromDrop, filesFromList, type CollectedWorkbook } from './collect' import { text } from './copy' @@ -274,6 +275,8 @@ function Excel2AppFlow({ draftId, onCreatedDraft }: { draftId?: string; onCreate {flow.unconfirmed ?
void flow.confirm()} />
: null} {step === 0 && !readOnly ? void collected(files)} onSample={(grids) => void collected(grids, true)} onRemove={(file) => void remove(file)} onRetry={(file) => void flow.retryFile(file.key)} onStart={() => { setStep(ANALYSIS_STEP); void flow.startAnalysis() }} /> : null} + {/* The analysis switched from a retired workspace (APT-1264): told once on its step, above what it read. */} + {step === ANALYSIS_STEP && draft && flow.analysis.recreated ?
: null} {step === ANALYSIS_STEP && draft ? ( reading ? ( diff --git a/web/src/features/excel2app/ui-preview-step.test.tsx b/web/src/features/excel2app/ui-preview-step.test.tsx index 5ecd860..35d5993 100644 --- a/web/src/features/excel2app/ui-preview-step.test.tsx +++ b/web/src/features/excel2app/ui-preview-step.test.tsx @@ -109,6 +109,21 @@ test('a failed turn renders as a notice with retry on the last message only', () expect(render({ messages: [failed], onRetry: () => {}, busy: true })).not.toContain('excel2app-chat-retry') }) +test.each(['ja', 'en'] as const)('a recreated workspace is one calm notice between the instruction and its reply, never a bubble or a retry (APT-1264, %s)', (language) => { + setLanguage(language) + const messages: UiPreviewChatMessage[] = [ + { role: 'user', text: '一覧をカード表示に' }, + { role: 'notice', text: buildCopy.workspaceRecreated }, + { role: 'assistant', text: '一覧をカード表示にしました。' }, + ] + const html = render({ messages, onRetry: () => {} }) + expect(html.split(buildCopy.workspaceRecreated)).toHaveLength(2) + expect(html.split('data-role="notice"')).toHaveLength(2) + expect(html.indexOf('data-role="user"')).toBeLessThan(html.indexOf(buildCopy.workspaceRecreated)) + expect(html.indexOf(buildCopy.workspaceRecreated)).toBeLessThan(html.indexOf('data-role="assistant"')) + expect(html).not.toContain('excel2app-chat-retry') +}) + test.each(['ja', 'en'] as const)('quota failure in UI chat explains the account problem and retains manual retry in %s', (language) => { setLanguage(language) for (const error of [ diff --git a/web/src/features/excel2app/ui-preview-step.tsx b/web/src/features/excel2app/ui-preview-step.tsx index 8cacbc0..4f0e3d2 100644 --- a/web/src/features/excel2app/ui-preview-step.tsx +++ b/web/src/features/excel2app/ui-preview-step.tsx @@ -233,6 +233,9 @@ function ChatPanel({ messages, busy, readOnly, activity, ready, onSend, onUndo, {/* biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard. */}
    {messages.map((message, index) => { + // The workspace was recreated (APT-1264): information between an instruction and its reply, not a chat bubble. + // biome-ignore lint/suspicious/noArrayIndexKey: the conversation only grows; an index is its identity. + if (message.role === 'notice') return
  1. const state = message.failed ? 'failed' : message.pending ? 'pending' : undefined const quota = message.failed && isAIQuotaExhausted(message.text) const failure = message.failed ? message.failure ?? classifyBuildFailure(message.text, undefined, 'turn') : undefined diff --git a/web/src/features/excel2app/use-excel2app-draft.test.ts b/web/src/features/excel2app/use-excel2app-draft.test.ts index 99b6fb8..88c87c6 100644 --- a/web/src/features/excel2app/use-excel2app-draft.test.ts +++ b/web/src/features/excel2app/use-excel2app-draft.test.ts @@ -2,13 +2,15 @@ import { describe, expect, test } from 'bun:test' import type { ApplicationDraft, ApplicationDraftConversationTurn } from '@appthrust/api-schema/platform-api' import { completeUiDesign, excelAnalysisOf, uiDesignOf, type CompleteUiDesign } from '../../model/contracts/excel' import { draftOf, readEachFirst, readFirst, turnOf } from '../../api/testing/build-domain' +import { buildCopy } from '../../model/build/copy' +import { recreatingRecords } from '../../model/build/messages' import { serializeSpec } from '../../model/build/spec' import { textJa } from './copy' import { fromDraftWorkbook, planApp, toDraftWorkbook } from './model' import { designFromReadings } from './design' import { SAMPLE_SETS } from './samples' import { defaultUiDesign } from './ui-design' -import { analysisTitle as domainAnalysisTitle, classifyStoreError, currentTurns as domainCurrentTurns, designMessages as domainDesignMessages, designStack as domainDesignStack, fileStem, handOffPatch, isApplicationCreated, latestSaver, resumeStep as domainResumeStep, specParts, undoMessage, UI_DESIGN_INIT } from './use-excel2app-draft' +import { analysisTitle as domainAnalysisTitle, classifyStoreError, currentTurns as domainCurrentTurns, designMessages as domainDesignMessages, designStack as domainDesignStack, fileStem, handOffPatch, isApplicationCreated, latestSaver, resumeStep as domainResumeStep, specParts, undoMessage, UI_DESIGN_INIT, type UiPreviewChatMessage } from './use-excel2app-draft' const currentTurns = readFirst(draftOf, domainCurrentTurns) const resumeStep = readFirst(draftOf, domainResumeStep) @@ -153,6 +155,28 @@ describe('screen design turns', () => { { role: 'user', text: '密度をコンパクトに', pending: true }, ]) }) + test('a turn that replaced a retired workspace says so once, after its instruction and before its reply; reopening gives the same chat (APT-1264)', () => { + const replacingInit = { ...init, replacedDevWorkspaceId: 'ws-old' } + const replacingChange = { ...change, replacedDevWorkspaceId: 'ws-1' } + // A later turn naming the same retired workspace again adds nothing. + const again = { ...turn('t-again', '色を青に', 4, { assistantMessage: '## 要約\n色を青にしました。' }), replacedDevWorkspaceId: 'ws-old' } + const open = () => { + const turns = domainCurrentTurns(draftOf({ ...draft, conversationTurns: [replacingInit, replacingChange, again] })) + return domainDesignMessages(turns, recreatingRecords(turns)) + } + const notice: UiPreviewChatMessage = { role: 'notice', text: buildCopy.workspaceRecreated } + expect(open()).toEqual([ + notice, + { role: 'assistant', text: '6 画面を用意しました。' }, + { role: 'user', text: '一覧をカード表示に' }, + notice, + { role: 'assistant', text: '一覧をカード表示にしました。' }, + { role: 'user', text: '色を青に' }, + { role: 'assistant', text: '色を青にしました。' }, + ]) + expect(open()).toEqual(open()) + expect(designMessages([init, change]).some((message) => message.role === 'notice')).toBe(false) + }) test('the undo request carries the previous design as JSON within one turn message', () => { const message = undoMessage(design) expect(message.startsWith(textJa.preview.undoRequest)).toBe(true) diff --git a/web/src/features/excel2app/use-excel2app-draft.ts b/web/src/features/excel2app/use-excel2app-draft.ts index 0697188..61ca3da 100644 --- a/web/src/features/excel2app/use-excel2app-draft.ts +++ b/web/src/features/excel2app/use-excel2app-draft.ts @@ -10,9 +10,10 @@ import { draftWorkbookGridOptions, draftWorkbooksOptions } from '../../api/queri import { isResponseContractError } from '../../api/boundary' import { platformErrorEnvelope } from '../../api/platform-error' import { useCreationTools } from '../../api/queries/catalog' +import { buildCopy } from '../../model/build/copy' import { classifyBuildFailure } from '../../model/build/failure' import type { BuildFailure } from '../../model/build/types' -import { parseAssistantMessage } from '../../model/build/messages' +import { parseAssistantMessage, recreatingRecords } from '../../model/build/messages' import { isBuildPending } from '../../model/build/progress' import { parseSpec, serializeSpec } from '../../model/build/spec' import { filesFromList, isWorkbookFile, workbookBudget, type CollectedWorkbook, type WorkbookFileState } from './collect' @@ -43,9 +44,12 @@ export interface CollectionResult { analysisRequested: boolean } -/** One bubble of the chat. Failed turns retain their cause for classification by the notice. */ +/** + * One bubble of the chat. Failed turns retain their cause for classification by the notice. `notice`: the workspace was + * recreated (APT-1264), shown between the turn's instruction and its reply; information only. + */ export interface UiPreviewChatMessage { - role: 'user' | 'assistant' + role: 'user' | 'assistant' | 'notice' text: string pending?: boolean failed?: boolean @@ -123,12 +127,16 @@ export function designStack(turns: BuildTurn[]): UiDesign[] { return stack } -/** The chat the ui-design turns make: the instruction, then the reply's summary (or its error). */ -export function designMessages(turns: BuildTurn[]): UiPreviewChatMessage[] { +/** + * The chat the ui-design turns make: the instruction, then the reply's summary (or its error). A turn in `recreating` + * (messages.ts#recreatingRecords) switched from a retired workspace: it says so once, after its instruction. + */ +export function designMessages(turns: BuildTurn[], recreating: ReadonlySet = new Set()): UiPreviewChatMessage[] { const messages: UiPreviewChatMessage[] = [] for (const turn of turns) { const pending = isBuildPending(turn) if (turn.userMessage !== UI_DESIGN_INIT) messages.push({ role: 'user', text: isUndoMessage(turn.userMessage) ? text.preview.undoMessage : turn.userMessage, ...(pending ? { pending: true } : {}) }) + if (recreating.has(turn)) messages.push({ role: 'notice', text: buildCopy.workspaceRecreated }) if (isOneOf(turn.status, 'failed')) messages.push({ role: 'assistant', text: turn.error || text.preview.turnFailed, failed: true }) else if (isOneOf(turn.status, 'succeeded') && turn.assistantMessage) { const parts = parseAssistantMessage(turn.assistantMessage) @@ -255,6 +263,8 @@ export function useExcel2AppDraft(projectId: string, draftId: string | undefined const turns = useMemo(() => (draft ? currentTurns(draft) : []), [draft]) const analysisTurn = turnsOf(turns, 'excel-analysis').at(-1) const designTurns = useMemo(() => turnsOf(turns, 'ui-design'), [turns]) + // Turns that switched from a retired workspace (APT-1264): derived from the draft, so reopening it shows the same ones. + const recreating = useMemo(() => recreatingRecords(turns), [turns]) const latestDesignTurn = designTurns.at(-1) // A turn in a state this console does not know may still run: nothing new is sent over it. const turnRunning = turns.some((turn) => jobState(turn) !== 'settled') @@ -662,14 +672,14 @@ export function useExcel2AppDraft(projectId: string, draftId: string | undefined const messages = useMemo(() => { if (usingOffline) return offlineDesign?.messages ?? [] - const list = designMessages(designTurns) + const list = designMessages(designTurns, recreating) if (sending && sending !== UI_DESIGN_INIT) list.push({ role: 'user', text: isUndoMessage(sending) ? text.preview.undoMessage : sending, pending: true }) if (sendProblem) { if (sendProblem.instruction !== UI_DESIGN_INIT) list.push({ role: 'user', text: isUndoMessage(sendProblem.instruction) ? text.preview.undoMessage : sendProblem.instruction }) list.push({ role: 'assistant', text: sendProblem.message, failed: true, failure: sendProblem.failure }) } return list - }, [usingOffline, offlineDesign, designTurns, sending, sendProblem]) + }, [usingOffline, offlineDesign, designTurns, recreating, sending, sendProblem]) const designBusy = usingOffline ? false : Boolean(sending) || isBuildPending(latestDesignTurn) const suggestions = usingOffline @@ -721,6 +731,11 @@ export function useExcel2AppDraft(projectId: string, draftId: string | undefined offline: usingOffline, analysis: { turn: analysisTurn, + /** + * The analysis turn this step shows switched from a retired workspace: the step says so once (APT-1264). An + * earlier analysis that switched and failed says nothing about the one shown now. + */ + recreated: Boolean(analysisTurn && recreating.has(analysisTurn)), running: starting || isBuildPending(analysisTurn), problem: analysisProblem?.kind ?? (isOneOf(analysisTurn?.status, 'failed') && !draft?.excelAnalysis ? ('failed' as const) : undefined), failure: analysisProblem?.failure, diff --git a/web/src/features/improve/conversation.tsx b/web/src/features/improve/conversation.tsx index d8c512d..c8e7ad0 100644 --- a/web/src/features/improve/conversation.tsx +++ b/web/src/features/improve/conversation.tsx @@ -3,14 +3,14 @@ import { Check, Circle, ExternalLink, Loader2 } from 'lucide-react' import { forwardRef, useLayoutEffect, useRef, type ReactNode } from 'react' import { buildCopy } from '../../model/build/copy' import { buildFailureReference, classifyBuildFailure, classifyRunFailure, failureOffers, failureText } from '../../model/build/failure' -import { assistantMessage } from '../../model/build/messages' +import { assistantMessage, recreatingRecords } from '../../model/build/messages' import { activityLines, formatElapsed } from '../../model/build/progress' import type { BuildFailure } from '../../model/build/types' import { isProductLanguage } from '../../model/build/wording' import { improveTimeline, runVersion, sortedTurns, type ImproveState, type ImproveTask } from '../../model/improve' import { ActivityLog, Button, CopyButton, LinkButton, Notice } from '../../ui' import { Composer } from '../build/composer' -import { AiTurn, AssistantMessage, UserMessage } from '../build/conversation-pane' +import { AiTurn, AssistantMessage, UserMessage, WorkspaceRecreatedNotice } from '../build/conversation-pane' import { text as buildText } from '../build/copy' import { text } from './copy' import { useClock } from './use-clock' @@ -72,6 +72,8 @@ export const ImproveConversation = forwardRef isOneOf(turn.status, 'succeeded')) + // The turn that switched from a retired workspace tells it once, between its request and its answer (APT-1264). + const recreating = recreatingRecords(turns) const latestRun = draft.implementationRuns.at(-1) const answerable = state.phase === 'asking' || state.phase === 'proposed' const chips = answerable && !locked ? (lastAnswer?.suggestedReplies ?? []).map((reply) => ({ label: reply, value: reply })) : [] @@ -80,6 +82,7 @@ export const ImproveConversation = forwardRef + {recreating.has(turn) ? : null} {answer?.role === 'assistant' ? : null} {turn.id === state.proposalTurnId ? : null} {isOneOf(turn.status, 'failed') ? submit(turn.userMessage) : undefined} /> : null} diff --git a/web/src/features/improve/copy.test.tsx b/web/src/features/improve/copy.test.tsx index ec7edc2..cddffe4 100644 --- a/web/src/features/improve/copy.test.tsx +++ b/web/src/features/improve/copy.test.tsx @@ -96,6 +96,22 @@ test('improvement failures honor run and task reasons before diagnostic wording' expect(interrupted).toContain(buildCopy.failure.resumable.reason) }) +test.each(['ja', 'en'] as const)('a turn that replaced a retired workspace tells it once, between its request and its answer, as information (APT-1264, %s)', (language) => { + setLanguage(language) + const first = draft.conversationTurns![0]! + const replacing = { ...first, id: 't2', startedAt: '2026-10-26T00:01:00Z', finishedAt: '2026-10-26T00:01:10Z', userMessage: '並び順も変えたい', assistantMessage: '## 要約\n並び順を変えます。', replacedDevWorkspaceId: 'ws-old' } + const later = { ...first, id: 't3', startedAt: '2026-10-26T00:02:00Z', finishedAt: '2026-10-26T00:02:10Z', userMessage: '色も変えたい', assistantMessage: '## 要約\n色を変えます。' } + const html = render({ ...draft, conversationTurns: [first, replacing, later] }) + const notice = buildCopy.workspaceRecreated + expect(notice).toBe(language === 'ja' ? '作業環境を作り直しました。会話と計画は引き継いでいます' : 'Your workspace was recreated. The conversation and plan are kept.') + expect(html.split(notice)).toHaveLength(2) + expect(html.indexOf('並び順も変えたい')).toBeLessThan(html.indexOf(notice)) + expect(html.indexOf(notice)).toBeLessThan(html.indexOf('並び順を変えます。')) + expect(html.indexOf(notice)).toBeLessThan(html.indexOf('色も変えたい')) + // An older Platform sends no field: nothing is shown. + expect(render(draft)).not.toContain(notice) +}) + test.each(['ja', 'en'] as const)('a stopped run names no way on this page lacks: no skip, and a reply here is a new turn, not a change run, in %s', (language) => { setLanguage(language) const id = implementationTodoId(tasks[0]!.title, 0) diff --git a/web/src/model/build/copy.en.ts b/web/src/model/build/copy.en.ts index 7206b45..4050793 100644 --- a/web/src/model/build/copy.en.ts +++ b/web/src/model/build/copy.en.ts @@ -3,6 +3,7 @@ import type { textJa } from './copy' export const textEn: typeof textJa = { intent: { reply: '### Follow-up', publish: 'Publish: yes', omitted: (count) => `(${count} earlier follow-up${count === 1 ? '' : 's'} omitted)` }, unreadablePlan: { title: 'The saved plan could not be read', detail: 'This console cannot show the contents of the plan saved on the platform.' }, + workspaceRecreated: 'Your workspace was recreated. The conversation and plan are kept.', questions: { firstTurn: 'Ask me one question at a time about the decisions needed to build this app.', kickoffReply: 'Propose an app from this', diff --git a/web/src/model/build/copy.ts b/web/src/model/build/copy.ts index daa12c8..1aba573 100644 --- a/web/src/model/build/copy.ts +++ b/web/src/model/build/copy.ts @@ -4,6 +4,8 @@ import { textEn } from './copy.en' export const textJa = { intent: { reply: '### 追記', publish: '公開: する', omitted: (count: number) => `(以前の追記 ${count} 件を省略)` }, unreadablePlan: { title: '保存された計画を読めませんでした', detail: '基盤に保存された計画の内容を、このコンソールでは確認できません。' }, + /** A turn or plan generation moved to a new workspace because the old one was retired (APT-1264): information only. */ + workspaceRecreated: '作業環境を作り直しました。会話と計画は引き継いでいます', questions: { firstTurn: 'このアプリを作るために決めるべきことを、一つずつ質問してください。', kickoffReply: 'この内容で提案して', diff --git a/web/src/model/build/messages.test.ts b/web/src/model/build/messages.test.ts index 80926d7..fa6980f 100644 --- a/web/src/model/build/messages.test.ts +++ b/web/src/model/build/messages.test.ts @@ -10,7 +10,10 @@ const messagesFromDraft = readFirst(draftOf, model.messagesFromDraft) const planProposal = readFirst(draftOf, model.planProposal) const prepareAnswers = readEachFirst(turnOf, questions.prepareAnswers) const { replyOptions } = questions -import { buildCopy } from './copy' +import { buildCopy, textJa } from './copy' +import { textEn } from './copy.en' +import { preserveLanguage } from '../../../test/language' +import { setLanguage } from '../../shell/language' import { buildFailureReference, classifyBuildFailure } from './failure' import { serializeSpec } from './spec' import type { BuildMessage } from './types' @@ -123,6 +126,94 @@ describe('conversation history', () => { }) }) +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' } + const switched = { ...turn, id: 'turn-2', startedAt: '2026-10-08T00:02:00Z', finishedAt: '2026-10-08T00:02:10Z', userMessage: '入れる', replacedDevWorkspaceId: 'ws-old' } + const later = { ...turn, id: 'turn-3', startedAt: '2026-10-08T00:03:00Z', finishedAt: '2026-10-08T00:03:10Z', userMessage: 'ありがとう' } + const generation = { id: 'gen-1', status: 'succeeded', startedAt: '2026-10-08T00:04:00Z', finishedAt: '2026-10-08T00:04:30Z', devWorkspaceId: 'ws-1' } + const notices = (wire: unknown) => messagesFromDraft(wire, []).filter((message) => message.role === 'notice') + const shape = (messages: BuildMessage[]) => messages.map((message) => message.role === 'notice' ? message.title : message.role) + + test('appears once, on the turn that replaced the workspace: below its request, above its answer', () => { + const messages = messagesFromDraft({ ...draft, conversationTurns: [later, switched, earlier], creationPlanGenerations: [generation] }, []) + expect(shape(messages)).toEqual(['user', 'assistant', 'user', textJa.workspaceRecreated, 'assistant', 'user', 'assistant']) + expect(messages.filter((message) => message.role === 'notice')).toEqual([recreated]) + }) + test('is information only: no retry and no reference', () => { + const [notice] = notices({ ...draft, conversationTurns: [switched] }) + expect(notice).toEqual(recreated) + expect(notice).not.toHaveProperty('retry') + expect(notice).not.toHaveProperty('reference') + }) + test('stays one notice on every read and reload, also while the replacing turn runs', () => { + const read = { ...draft, conversationTurns: [earlier, switched, later] } + const first = messagesFromDraft(read, []) + // A reload hands the earlier transcript back as local messages: the derived notice is not added twice. + expect(messagesFromDraft(read, first).filter((message) => message.role === 'notice')).toEqual([recreated]) + const running = messagesFromDraft({ ...draft, conversationTurns: [earlier, { ...switched, status: 'running', finishedAt: undefined }] }, []) + expect(running.slice(-2)).toEqual([{ role: 'user', text: switched.userMessage, at: switched.startedAt }, recreated]) + }) + test('sits right below the request, before an answer of the same time (no finishedAt, or finished at its start)', () => { + const user = { role: 'user', text: switched.userMessage, at: switched.startedAt } satisfies BuildMessage + const failed = messagesFromDraft({ ...draft, conversationTurns: [{ ...switched, status: 'failed', finishedAt: undefined, error: 'codex exited' }] }, []) + expect(failed.slice(0, 2)).toEqual([user, recreated]) + expect(failed[2]).toMatchObject({ role: 'notice', tone: 'error', at: switched.startedAt, retry: 'turn' }) + const unknown = messagesFromDraft({ ...draft, conversationTurns: [{ ...switched, status: 'future-state', finishedAt: undefined }] }, []) + expect(shape(unknown)).toEqual(['user', textJa.workspaceRecreated, buildCopy.unsupported.title]) + const instant = messagesFromDraft({ ...draft, conversationTurns: [{ ...switched, finishedAt: switched.startedAt }] }, []) + expect(shape(instant)).toEqual(['user', textJa.workspaceRecreated, 'assistant']) + }) + test('appears on a plan generation that replaced the workspace, at its start', () => { + const replacing = { ...generation, replacedDevWorkspaceId: 'ws-old' } + const messages = messagesFromDraft({ ...draft, conversationTurns: [earlier], creationPlanGenerations: [replacing] }, []) + expect(messages.filter((message) => message.role === 'notice')).toEqual([{ ...recreated, at: replacing.startedAt }]) + expect(messages.at(-1)).toEqual({ ...recreated, at: replacing.startedAt }) + }) + test('a switch an Excel → app turn made stays after the collapsed Excel line', () => { + 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', replacedDevWorkspaceId: 'ws-old' } + const messages = messagesFromDraft({ ...draft, conversationTurns: [switched, design, analysis] }, []) + // The design turn named ws-old first: the later conversation turn naming it again adds nothing. + expect(shape(messages)).toEqual(['assistant', textJa.workspaceRecreated, 'user', 'assistant']) + expect(messages[0]).toMatchObject({ turnId: `excel:${draft.id}` }) + expect(messages[1]).toEqual({ ...recreated, at: design.startedAt }) + }) + test('a retired workspace named by more than one record is announced at the first; another retirement is announced again', () => { + const replacing = { ...generation, replacedDevWorkspaceId: 'ws-old' } + expect(notices({ ...draft, conversationTurns: [switched], creationPlanGenerations: [replacing] })).toEqual([recreated]) + const again = { ...later, replacedDevWorkspaceId: 'ws-1' } + expect(notices({ ...draft, conversationTurns: [again, switched] }).map((notice) => notice.at)).toEqual([switched.startedAt, again.startedAt]) + const read = draftOf({ ...draft, conversationTurns: [again, switched], creationPlanGenerations: [replacing] }) + expect([...model.recreatingRecords([...read.conversationTurns, ...read.creationPlanGenerations])].map((record) => record.id)).toEqual(['turn-2', 'turn-3']) + }) + test('nothing is shown without the field (an older Platform) or for an empty one', () => { + expect(notices({ ...draft, conversationTurns: [earlier, later], creationPlanGenerations: [generation] })).toEqual([]) + expect(notices({ ...draft, conversationTurns: [{ ...switched, replacedDevWorkspaceId: '' }] })).toEqual([]) + }) + test('decisions read past it: the newest actionable message is the one before it', () => { + // A device clock behind the server's sorts the server-timed notice after the local generation-limit notice. + const limit = { role: 'notice', tone: 'warning', title: buildCopy.failure.limit.title, detail: buildCopy.failure.limitRejected, at: '2026-10-08T00:01:30Z' } satisfies BuildMessage + const messages = messagesFromDraft({ ...draft, conversationTurns: [earlier], creationPlanGenerations: [{ ...generation, replacedDevWorkspaceId: 'ws-old' }] }, [limit]) + expect(messages.at(-1)).toMatchObject({ kind: 'workspace-recreated' }) + expect(model.lastActionable(messages)).toEqual(limit) + expect(model.lastActionable([{ ...recreated }])).toBeUndefined() + }) + test('the copy is calm and exact in Japanese and English, switched at use time', () => { + expect(textJa.workspaceRecreated).toBe('作業環境を作り直しました。会話と計画は引き継いでいます') + expect(textEn.workspaceRecreated).toBe('Your workspace was recreated. The conversation and plan are kept.') + const restore = preserveLanguage() + try { + setLanguage('en') + expect(messagesFromDraft({ ...draft, conversationTurns: [switched] }, []).find((message) => message.role === 'notice')).toEqual({ ...recreated, title: textEn.workspaceRecreated }) + setLanguage('ja') + expect(buildCopy.workspaceRecreated).toBe(textJa.workspaceRecreated) + } finally { + restore() + } + }) +}) + describe('plan proposal', () => { const specMarkdown = serializeSpec({ name: '在庫管理', oneLine: '在庫を数えて一覧にする', users: ['自分だけ'], screens: ['在庫一覧', '入出庫の記録'], records: [{ name: '在庫', fields: ['品目', '数量', '保管場所'] }], rules: ['数量は 0 以上'] }, '') const tasks = Array.from({ length: 8 }, (_, index) => ({ title: `作業 ${index + 1}`, description: '一覧を作る。並べ替えもできる。', acceptanceCriteria: ['できる'] })) diff --git a/web/src/model/build/messages.ts b/web/src/model/build/messages.ts index b037967..10da955 100644 --- a/web/src/model/build/messages.ts +++ b/web/src/model/build/messages.ts @@ -157,6 +157,43 @@ function proposalMessage(draft: BuildDraft, lastPlannedIntent?: string, destinat return { role: 'assistant', text: proposal.lead ?? proposal.name, proposal, at, turnId: `proposal:${generation?.id ?? draft.id}` } } +/** A record Platform may mark as the switch from a retired workspace (APT-1264): a conversation turn or a plan generation. */ +interface WorkspaceSwitch { startedAt: string; replacedDevWorkspaceId?: string } + +/** + * The records that announce a recreated workspace: of those a surface shows, the first (by start) to name each retired + * workspace in `replacedDevWorkspaceId`. Derived from the records alone, so every read and reload of the same draft + * announces the same ones, once each, and a later record that does not carry the field never repeats it. + */ +export function recreatingRecords(records: readonly T[]): Set { + const announced = new Set() + const recreating = new Set() + for (const record of [...records].sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt))) { + const replaced = record.replacedDevWorkspaceId + if (!replaced || announced.has(replaced)) continue + announced.add(replaced) + recreating.add(record) + } + return recreating +} + +/** The notice that the workspace was recreated, at the switch's start. Information only: no retry, no reference. */ +function workspaceRecreatedNotice(at: string): BuildMessage { + return { role: 'notice', kind: 'workspace-recreated', tone: 'info', title: buildCopy.workspaceRecreated, 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. + */ +export function lastActionable(messages: readonly BuildMessage[]): BuildMessage | undefined { + for (let index = messages.length - 1; index >= 0; index--) { + const message = messages[index]! + if (message.role !== 'notice' || message.kind !== 'workspace-recreated') return message + } + return undefined +} + export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], options: { lastPlannedIntent?: string; preparationDone?: boolean; destination?: ShownDestination } = {}): BuildMessage[] { const messages: BuildMessage[] = [] if (draft.creationPlanUnreadable) messages.push({ @@ -164,6 +201,10 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti ...(!draft.createdApplicationId && !draft.createdApplicationStackId && !draft.creationExecutions.length ? { retry: 'plan' as const } : {}), at: draft.updatedAt, }) const all = [...draft.conversationTurns].sort((a, b) => Date.parse(a.startedAt) - Date.parse(b.startedAt)) + // A switch from a retired workspace is told once, at the record that made it (stable sort: a notice pushed after a + // message of the same time stays below it). + const recreating = recreatingRecords([...all, ...draft.creationPlanGenerations]) + const recreated = (record: WorkspaceSwitch) => recreating.has(record) ? [workspaceRecreatedNotice(record.startedAt)] : [] // Excel → app's analysis and screen-design turns read as one line before the conversation, // linked back to Excel → app; 「この内容で提案して」 is offered right away, since the // specification is already written. @@ -172,12 +213,20 @@ export function messagesFromDraft(draft: BuildDraft, extra: BuildMessage[], opti 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 } }) } + // 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) { 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)) } + // 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)) + // Before the plan's proposal, which sits where the generation finished. + for (const generation of draft.creationPlanGenerations) messages.push(...recreated(generation)) const proposal = proposalMessage(draft, options.lastPlannedIntent, options.destination) if (proposal) messages.push(proposal) for (const message of extra) { diff --git a/web/src/model/build/types.ts b/web/src/model/build/types.ts index c156fd2..ab63e7e 100644 --- a/web/src/model/build/types.ts +++ b/web/src/model/build/types.ts @@ -58,8 +58,10 @@ export type BuildMessage = * `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 * 「もう一度確かめる」 (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). */ - | { role: 'notice'; tone: 'info' | 'warning' | 'error'; title: string; detail?: string; at: string; retry?: 'turn' | 'plan' | 'prepare' | 'implement' | 'publish' | 'confirm' | 'recheck'; reference?: BuildFailure['reference'] } + | { 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' } export interface ProgressCard { kind: 'workspace' | 'turn' | 'plan' | 'prepare' | 'implement' | 'publish' title: string diff --git a/web/src/model/contracts/build.ts b/web/src/model/contracts/build.ts index 327ad1f..2961a18 100644 --- a/web/src/model/contracts/build.ts +++ b/web/src/model/contracts/build.ts @@ -52,8 +52,9 @@ export type WorkspacePhase = DevWorkspacePhase export type ConditionStatus = CanonicalCondition['status'] export type PreviewDatabaseEngine = DevWorkspacePreviewDatabaseEngine -export type BuildTurn = Omit & { kind: OpenValue; status: OpenValue; excelProgress?: ExcelProgress; uiDesign?: UiDesign } -export type BuildGeneration = Omit & { status: OpenValue; stage?: OpenValue } +/** `replacedDevWorkspaceId`: the retired workspace this turn or plan generation replaced (APT-1264), on that record only. */ +export type BuildTurn = Omit & { kind: OpenValue; status: OpenValue; excelProgress?: ExcelProgress; uiDesign?: UiDesign; replacedDevWorkspaceId?: string } +export type BuildGeneration = Omit & { status: OpenValue; stage?: OpenValue; replacedDevWorkspaceId?: string } export type BuildExecutionStep = Omit & { status: OpenValue; phase?: OpenValue } export type BuildExecution = Omit & { status: OpenValue