diff --git a/web/src/features/build/build-failure-notice.test.tsx b/web/src/features/build/build-failure-notice.test.tsx index 09b1299..7a76761 100644 --- a/web/src/features/build/build-failure-notice.test.tsx +++ b/web/src/features/build/build-failure-notice.test.tsx @@ -2,11 +2,14 @@ import { expect, spyOn, test } from 'bun:test' import type { ApplicationDraft, BuildFailure } from '@appthrust/api-schema/platform-api' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { createMemoryHistory, createRootRoute, createRoute, createRouter, RouterProvider } from '@tanstack/react-router' -import { act } from 'react' +import { act, type ReactElement } from 'react' import { draftOf, turnOf } from '../../api/testing/build-domain' import { createRoot } from 'react-dom/client' import { renderToStaticMarkup } from 'react-dom/server' import * as api from '../../api/build' +import { buildKeys } from '../../api/queries/build' +import { ImproveButton } from '../improve/entry' +import { buildCopy } from '../../model/build/copy' import { BuildFailureNotice } from './build-failure-notice' const at = '2026-11-01T00:00:00Z' @@ -22,27 +25,29 @@ test('cause is plain escaped text; viewers and successful builds have no repair expect(renderToStaticMarkup()).toBe('') }) -test('one click creates an improvement draft and sends exactly the cause lines as its first turn', async () => { +async function exerciseStart(entry: ReactElement, interact: (container: HTMLDivElement, expectNoWrites: () => void) => Promise) { const create = spyOn(api, 'createDraft').mockResolvedValue(draftOf(draft)) const list = spyOn(api, 'listDrafts').mockResolvedValue({ data: [], unreadable: [] }) const turn = spyOn(api, 'createTurn').mockImplementation(async (_projectId, _draftId, payload) => turnOf({ id: 'turn-1', kind: 'conversation', userMessage: payload.message, status: 'pending', startedAt: at, devWorkspaceId: 'workspace' })) const client = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } }) + client.setQueryData(buildKeys.drafts('pj-demo'), { data: [], unreadable: [] }) const container = document.createElement('div') document.body.append(container) const root = createRoot(container) const rootRoute = createRootRoute() - const route = createRoute({ getParentRoute: () => rootRoute, path: '/', component: () => }) + const route = createRoute({ getParentRoute: () => rootRoute, path: '/', component: () => entry }) const destination = createRoute({ getParentRoute: () => rootRoute, path: '/-/improve/$draftId', component: () =>

改善

}) const router = createRouter({ routeTree: rootRoute.addChildren([route, destination]), history: createMemoryHistory({ initialEntries: ['/'] }) }) try { await router.load() await act(async () => { root.render() }) - const button = container.querySelector('[data-testid="repair-build-with-ai"]') - expect(button?.textContent).toContain('AI に直させる') - await act(async () => { button!.click() }) + const message = await interact(container, () => { + expect(create).not.toHaveBeenCalled() + expect(turn).not.toHaveBeenCalled() + }) expect(create).toHaveBeenCalledTimes(1) - expect(create).toHaveBeenCalledWith('pj-demo', { kind: 'improvement', applicationStackId: 'stack-web', title: '台帳', intent: failure.lines.join('\n') }) - expect(turn).toHaveBeenCalledWith('pj-demo', 'repair-draft', { message: failure.lines.join('\n') }) + expect(create).toHaveBeenCalledWith('pj-demo', { kind: 'improvement', applicationStackId: 'stack-web', title: '台帳', intent: message }) + expect(turn).toHaveBeenCalledWith('pj-demo', 'repair-draft', { message }) expect(router.state.location.pathname).toBe('/-/improve/repair-draft') } finally { await act(async () => { root.unmount() }) @@ -52,4 +57,47 @@ test('one click creates an improvement draft and sends exactly the cause lines a list.mockRestore() turn.mockRestore() } +} + +test('one click creates an improvement draft and sends exactly the cause lines as its first turn', async () => { + await exerciseStart(, async (container) => { + const button = container.querySelector('[data-testid="repair-build-with-ai"]')! + expect(button.textContent).toContain('AI に直させる') + await act(async () => { button.click() }) + return failure.lines.join('\n') + }) +}) + +test.each(['improve', 'repair'])('an oversized %s request is kept for editing; only the corrected 4000 bytes are sent', async (mode) => { + const lines = ['在庫'.repeat(666), '欠品'] + const entry = mode === 'repair' + ? + : + await exerciseStart(entry, async (container, expectNoWrites) => { + await act(async () => { container.querySelector('[data-testid$="-with-ai"]')!.click() }) + const dialog = document.querySelector('[role="dialog"]')! + const input = dialog.querySelector('textarea')! + const form = dialog.querySelector('form')! + const submit = dialog.querySelector('button[type="submit"]')! + const type = async (value: string) => { + await act(async () => { + Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value')!.set!.call(input, value) + input.dispatchEvent(new window.Event('input', { bubbles: true }) as unknown as Event) + }) + } + const original = lines.join('\n') + if (mode === 'improve') await type(original) + expect(input.value).toBe(original) + expect(dialog.textContent).toContain(buildCopy.inputBytes.over(3)) + expect(submit.disabled).toBe(true) + await act(async () => { form.dispatchEvent(new window.Event('submit', { bubbles: true, cancelable: true }) as unknown as Event) }) + expectNoWrites() + + const edited = '在庫'.repeat(666) + '😀' + await type(edited) + expect(dialog.textContent).toContain(buildCopy.inputBytes.remaining(0)) + expect(submit.disabled).toBe(false) + await act(async () => { form.dispatchEvent(new window.Event('submit', { bubbles: true, cancelable: true }) as unknown as Event) }) + return edited + }) }) diff --git a/web/src/features/build/build-failure-notice.tsx b/web/src/features/build/build-failure-notice.tsx index 51d5155..169f866 100644 --- a/web/src/features/build/build-failure-notice.tsx +++ b/web/src/features/build/build-failure-notice.tsx @@ -17,8 +17,10 @@ export function BuildFailureNotice({ failure, projectId, stackId, title, canEdit canEdit: boolean behind?: { runUrl?: string } }) { - const repair = canEdit && stackId && failure - ? + const cause = failure?.lines.join('\n') + // Pass the full cause: the improvement entry opens it for editing if it cannot be sent in one click. + const repair = canEdit && stackId && cause + ? : null if (behind) { const runUrl = behind.runUrl && /^https?:\/\//i.test(behind.runUrl) ? behind.runUrl : undefined @@ -28,12 +30,12 @@ export function BuildFailureNotice({ failure, projectId, stackId, title, canEdit {repair} : undefined}>

{copy.detail}

- {failure ?

{copy.cause(failure.lines.join('\n'))}

: null} + {cause ?

{copy.cause(cause)}

: null} } if (!failure) return null return -

ビルドが失敗しました。原因: {failure.lines.join('\n')}

+

ビルドが失敗しました。原因: {cause}

{repair ?
{repair}
: null}
} diff --git a/web/src/features/build/composer.tsx b/web/src/features/build/composer.tsx index eac6e9e..ccb6490 100644 --- a/web/src/features/build/composer.tsx +++ b/web/src/features/build/composer.tsx @@ -29,7 +29,7 @@ export interface ComposerProps { onChip(value: string, label: string): void } -export const MAX_LENGTH = 4000 +const MAX_LENGTH = 4000 const MIN_ROWS = 3 const MAX_ROWS = 8 diff --git a/web/src/features/build/console-entry.test.ts b/web/src/features/build/console-entry.test.ts index 4a6131a..8ac7b88 100644 --- a/web/src/features/build/console-entry.test.ts +++ b/web/src/features/build/console-entry.test.ts @@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test' import { createBuildSessionsApi, type BuildSessionsApi } from '../../api/build-sessions' import { getDraft } from '../../api/build' +import { buildCopy } from '../../model/build/copy' import { createConsoleMockFetch, resetMocks, type ConsoleMockFetch } from '../../api/testing/console-mock-fetch' import { createTestGateway } from '../../api/testing/gateway' import { readConsoleStart } from './console-session-state' @@ -55,17 +56,20 @@ test('a console-v1 start creates one server session, follows advance to its draf expect(readConsoleStart(storage)).toBeUndefined() }) -test('a console-v1 start sends a byte-bounded opening but keeps the original words for replay', async () => { - const opening = '来客受付'.repeat(400) +test('a console-v1 start replays the complete 4000-byte opening and never sends an oversized one', async () => { + const opening = '受'.repeat(1332) + '😀' const create = spyOn(api, 'create') restore.push(() => create.mockRestore()) + await expect(startConsoleBuild(opening + '字', 'g-team-a', deps())).rejects.toThrow(buildCopy.inputBytes.over(3)) + expect(readConsoleStart(storage)).toBeUndefined() + expect(create).not.toHaveBeenCalled() mock.rewrites.push({ method: 'POST', path: CREATE, once: true, body: (wire) => ({ ...wire, id: 'SENTINEL' }) }) await expect(startConsoleBuild(opening, 'g-team-a', deps())).rejects.toBeInstanceOf(BuildStartError) expect(readConsoleStart(storage)?.intent).toBe(opening) await startConsoleBuild(opening, 'g-team-a', deps()) expect(create.mock.calls).toHaveLength(2) const [payload, key] = create.mock.calls[0]! - expect(new TextEncoder().encode(payload.intent).length).toBeLessThanOrEqual(4000) + expect(payload.intent).toBe(opening) expect(create.mock.calls[1]).toEqual([payload, key]) expect(await sessions()).toHaveLength(1) }) @@ -167,12 +171,14 @@ describe('the new-session engine (server flag) at beginBuild', () => { expect(mock.requests.filter((item) => item.path.startsWith('/api/console/v1/'))).toEqual([]) expect((await api.resolve(draft.id)).engine).toBe('platform-v1') }) - test('an oversized original creates one bounded Platform draft and resumes it by its complete words', async () => { - const opening = '在庫管理'.repeat(400) + test('Platform rejects an oversized opening locally and resumes an exact 4000-byte opening without truncation', async () => { + const opening = '庫'.repeat(1332) + '😀' const options = { groupId: 'g-team-a', ownerSubject: 'sub-yamada' } + await expect(beginBuild('commerce', opening + '字', options)).rejects.toThrow(buildCopy.inputBytes.over(3)) + expect(mock.count('POST', /\/application-drafts$/)).toBe(0) const { id } = await beginBuild('commerce', opening, options) const stored = (await getDraft('commerce', id)).intent - expect(new TextEncoder().encode(stored).length).toBeLessThanOrEqual(4000) + expect(stored).toBe(opening) expect((await beginBuild('commerce', opening, options)).id).toBe(id) expect(mock.count('POST', /\/application-drafts$/)).toBe(1) }) diff --git a/web/src/features/build/entry.ts b/web/src/features/build/entry.ts index 3f9e69d..7bca53d 100644 --- a/web/src/features/build/entry.ts +++ b/web/src/features/build/entry.ts @@ -4,7 +4,8 @@ import { buildSessionsApi, intentKeys, isVersionConflict, mintIdempotencyKey, ty import { ConsoleApiError } from '../../api/console' import { boundedRetryAfter, buildPollDelay, ERROR_BACKOFF_MS } from '../../api/queries/build-sessions' import { membershipRoots, type BuildError, type BuildSession, type Group, type Me } from '../../model/contracts/console' -import { boundBuildOpening } from '../../model/build/questions' +import { buildCopy } from '../../model/build/copy' +import { remainingIntentBytes } from '../../model/build/questions' import { findResumableDraft } from '../../model/build/resume' import { currentLanguage } from '../../shell/language' import { readConsoleStart, saveConsoleStart, type ConsoleStart } from './console-session-state' @@ -27,6 +28,11 @@ export function resolveBuildGroup(me: Pick, groups: rea return membershipRoots(me, groups)[0]?.id } +function checkOpeningSize(words: string): void { + const remaining = remainingIntentBytes(words) + if (remaining < 0) throw new Error(buildCopy.inputBytes.over(-remaining)) +} + /** * Starts building from `intent` and answers the draft to open (`paths.build(id)`). * platform-v1 (the default): resumes the caller's unfinished draft with these exact words, otherwise creates one. @@ -35,14 +41,21 @@ export function resolveBuildGroup(me: Pick, groups: rea export async function beginBuild(projectId: string, intent: string, options: { groupId: string; ownerSubject: string; newSessionEngine?: NewSessionEngine }): Promise<{ id: string }> { if (!options.groupId) throw new Error(text.page.noGroup.body) if (options.newSessionEngine === 'console-v1') return startConsoleBuild(intent, options.groupId) + const words = intent.trim() const drafts = await listDrafts(projectId) - const existing = await findResumableDraft(drafts.data, intent) + const existing = await findResumableDraft(drafts.data, words) if (existing) { - if (!readBuildSession(existing.id)) saveBuildSession(existing.id, initialSession({ projectId, ownerSubject: options.ownerSubject, groupId: options.groupId, baseIntent: existing.intent })) + const saved = readBuildSession(existing.id) + if (!saved || saved.projectId !== projectId || saved.ownerSubject !== options.ownerSubject) { + saveBuildSession(existing.id, initialSession({ projectId, ownerSubject: options.ownerSubject, groupId: options.groupId, baseIntent: words })) + } else if (saved.baseIntent !== words) { + saveBuildSession(existing.id, { ...saved, baseIntent: words }) + } return existing } - const draft = await createDraft(projectId, { title: titleFromIntent(intent), intent: await boundBuildOpening(intent.trim()) }) - saveBuildSession(draft.id, initialSession({ projectId, ownerSubject: options.ownerSubject, groupId: options.groupId, baseIntent: intent.trim() })) + checkOpeningSize(words) + const draft = await createDraft(projectId, { title: titleFromIntent(words), intent: words }) + saveBuildSession(draft.id, initialSession({ projectId, ownerSubject: options.ownerSubject, groupId: options.groupId, baseIntent: words })) return draft } @@ -98,10 +111,11 @@ export async function startConsoleBuild(intent: string, groupId: string, deps: P let start: ConsoleStart = saved && saved.intent === words && saved.groupId === groupId ? saved : { intent: words, groupId, locale: currentLanguage(), key: mintIdempotencyKey() } + if (!start.sessionId) checkOpeningSize(words) saveConsoleStart(start, storage) let session: BuildSession try { - session = start.sessionId ? await api.get(start.sessionId) : await api.create({ kind: 'new-app', groupId, intent: await boundBuildOpening(words), locale: start.locale }, start.key) + session = start.sessionId ? await api.get(start.sessionId) : await api.create({ kind: 'new-app', groupId, intent: words, locale: start.locale }, start.key) } catch (error) { // The create may have happened; the kept key replays it on the next start. Nothing else is sent. if (isResponseContractError(error)) throw new BuildStartError('unconfirmed', start.sessionId ? { sessionId: start.sessionId } : {}) diff --git a/web/src/features/build/use-build-session.test.tsx b/web/src/features/build/use-build-session.test.tsx index 62d5ab3..a765d01 100644 --- a/web/src/features/build/use-build-session.test.tsx +++ b/web/src/features/build/use-build-session.test.tsx @@ -16,7 +16,7 @@ import { keys } from '../../api/queries/shared' import { sessionExpiryStore } from '../../api/session-expiry' import { buildCopy } from '../../model/build/copy' import { shareScopeLabel } from '../../model/access' -import { composeBuildIntent } from '../../model/build/questions' +import { boundBuildOpening, composeBuildIntent, decomposeBuildIntent } from '../../model/build/questions' import { parseSpec, serializeSpec } from '../../model/build/spec' import type { BuildFailure, BuildMessage, BuildPrimary, BuildStage } from '../../model/build/types' import * as appViews from '../app/use-app-views' @@ -180,11 +180,34 @@ describe('kickoff to plan handoff', () => { })) await mount({ ...draft, conversationTurns: [turn('opening', buildCopy.questions.firstTurn, 0)] }) await act(async () => { build.send('一覧を作る') }) - expect(build.failure).toMatchObject({ kind: 'platform', title: buildCopy.failure.platform.title, reference: { draftId: draft.id } }) + expect(build.failure).toMatchObject({ kind: 'platform', ...buildCopy.failure.requestRejected, reference: { draftId: draft.id } }) expect(build.session.pending.map((item) => item.text)).toEqual(['一覧を作る']) expect(createTurn).not.toHaveBeenCalled() }) + test('a long turn receives the full reply while the following kickoff plans with the complete opening', async () => { + const opening = '在庫'.repeat(600) + const message = '倉庫'.repeat(1500) + const generation = mockGeneration() + const firstTurn = buildCopy.questions.firstTurn + const stored = `${await boundBuildOpening(opening, 1941)}\n\n### 追記\n\n${firstTurn}` + createTurn.mockImplementation(async (_project, _draftId, { message }) => turnOf(turn(message === buildCopy.questions.kickoffReply ? 'kickoff' : 'large', message, 2))) + await mount({ ...draft, intent: stored, conversationTurns: [turn('opening', firstTurn, 0)] }, { ...initial, baseIntent: opening }) + await act(async () => { build.send(message) }) + expect(createTurn).toHaveBeenCalledWith(me.projectId, draft.id, { message }) + await act(async () => { build.send(buildCopy.questions.kickoffReply) }) + const intents = update.mock.calls.map(([, , patch]) => patch.intent!) + expect(intents).toHaveLength(3) + for (const intent of intents) { + expect(decomposeBuildIntent(intent)).toBe(opening) + expect(new TextEncoder().encode(intent).length).toBeLessThanOrEqual(4000) + } + expect(intents[0]).not.toContain(message) + expect(intents[2]).toContain(buildCopy.questions.kickoffReply) + expect(build.session.lastPlannedIntent).toBe(intents[2]) + expect(generation).toHaveBeenCalledTimes(1) + }) + test.each([3954, 4000, 4050])('a fresh tab can send a kickoff and plan from a %i-byte draft with 14 replies', async (storedBytes) => { const generation = mockGeneration() const utf8 = new TextEncoder() diff --git a/web/src/features/build/use-build-session.ts b/web/src/features/build/use-build-session.ts index d6cf4b4..9912e9f 100644 --- a/web/src/features/build/use-build-session.ts +++ b/web/src/features/build/use-build-session.ts @@ -193,11 +193,11 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o return } void perform('turn', async () => { - // The persisted opening is shared by fresh and resumed tabs. Preparation answers do not change the plan. + // Preparation answers do not change the plan. if (!asking) { const current = draftRef.current const replies = conversationTurns(current.conversationTurns).map((item) => item.userMessage) - const intent = await composeBuildIntent(current.intent, [...replies, pending.text]) + const intent = await composeBuildIntent(current.intent, [...replies, pending.text], false, store.state.baseIntent) await receive(await api.updateDraft(projectId, draft.id, { intent })) } try { @@ -245,7 +245,7 @@ export function useBuildSession(observed: BuildDraft, me: Me, groupId: string, o return } if ([latestGeneration, current.conversationTurns.at(-1)].some(isBuildPending)) return - const intent = await composeBuildIntent(current.intent, conversationTurns(current.conversationTurns).map((item) => item.userMessage), true) + const intent = await composeBuildIntent(current.intent, conversationTurns(current.conversationTurns).map((item) => item.userMessage), true, store.state.baseIntent) const updated = current.intent === intent ? current : await api.updateDraft(projectId, draft.id, { intent }) await receive(updated) const attemptKey = `build-plan-${draft.id}-${current.conversationTurns.at(-1)?.id ?? 'initial'}-${previousGenerationId ?? 'initial'}` diff --git a/web/src/features/create/form.ts b/web/src/features/create/form.ts index b5ec582..eebcbf7 100644 --- a/web/src/features/create/form.ts +++ b/web/src/features/create/form.ts @@ -15,8 +15,6 @@ import { } from '../../model/create' import { businessTemplateById } from './templates' -export const INTENT_MAX = 8000 - export interface CreateValues { /** Step 0 choice; the image entry is chosen from 詳しい人向け. */ entry: Exclude | undefined diff --git a/web/src/features/create/new-app-page-kept-group.test.tsx b/web/src/features/create/new-app-page-kept-group.test.tsx index 727ed8e..7d103fe 100644 --- a/web/src/features/create/new-app-page-kept-group.test.tsx +++ b/web/src/features/create/new-app-page-kept-group.test.tsx @@ -12,6 +12,7 @@ import { groupsContract } from '../../api/contracts/console/groups' import { meContract } from '../../api/contracts/console/me' import { consoleKeys } from '../../api/queries/console' import { createTestGateway } from '../../api/testing/gateway' +import { copy } from '../../copy' import { consoleRoutes } from '../../dev/mock-console' import { platformRoutes } from '../../dev/mock-platform' import type { BusinessApp } from '../../model/contracts/console' @@ -120,6 +121,29 @@ const buttons = (label: string) => [...container.querySelectorAll('button')].fil const appWrites = () => requests.filter((item) => item.method !== 'GET' && item.path.startsWith('/api/console/apps')) const savedGroupId = () => readCreateSession()?.values.groupId +test.each(['ja', 'en'] as const)('an oversized URL opening stays editable with a byte count and cannot start a build (%s)', async (language) => { + setLanguage(language) + const exact = '庫'.repeat(1332) + '😀' + const oversized = exact + '字' + await open(`/new?intent=${encodeURIComponent(oversized)}`, ['g-team-a']) + const input = container.querySelector('#create-start-intent')! + const [build] = buttons(copy.create.start.build) + expect(input.value).toBe(oversized) + expect(input.getAttribute('aria-invalid')).toBe('true') + expect(container.querySelector('#create-start-intent-error')?.textContent).toContain(language === 'ja' ? '3 バイト超えています' : '3 bytes over the limit') + expect(build!.disabled).toBe(true) + await act(async () => { build!.click() }) + expect(requests.filter((item) => item.method === 'POST' && /\/(?:application-drafts|build-sessions)$/.test(item.path))).toEqual([]) + expect(container.querySelector('#build-start-failure')).toBeNull() + + await act(async () => { + Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value')!.set!.call(input, exact) + input.dispatchEvent(new window.Event('input', { bubbles: true }) as unknown as Event) + }) + expect(container.querySelector('#create-start-intent-hint')?.textContent).toBe(language === 'ja' ? '残り 0 バイト' : '0 bytes remaining') + expect(build!.disabled).toBe(false) +}) + test('a saved session whose app is kept in a group the caller left is held, never moved to the group they belong to now', async () => { const draft = await keptApp('g-team-a') saveCreateSession({ version: 1, step: 'confirm', progress: { draft }, values: savedValues(draft, draft.group.id) }) diff --git a/web/src/features/create/new-app-page.tsx b/web/src/features/create/new-app-page.tsx index d97cc55..a8c2806 100644 --- a/web/src/features/create/new-app-page.tsx +++ b/web/src/features/create/new-app-page.tsx @@ -23,6 +23,7 @@ import { templateUsableFor, type CreateEntry, } from '../../model/create' +import { remainingIntentBytes } from '../../model/build/questions' import { shareSentence } from '../../model/share' import { paths } from '../../routes/paths' import { useShell } from '../../shell/use-shell' @@ -513,7 +514,14 @@ function CreateWizard({ defaultGroupPath, search, draft }: { defaultGroupPath?: const buildRequest = useRef<{ intent: string } | undefined>(undefined) const startBuild = async (intent: string) => { - if (startingBuild || !aiGroupId || !entryReady('ai') || !intent.trim()) return + const opening = intent.trim() + if (startingBuild || !aiGroupId || !entryReady('ai') || !opening) return + if (remainingIntentBytes(opening) < 0) { + // URL seeds already populate the field on first load; a reload must not replace the user's edits. + if (intent !== search.intent) form.setFieldValue('intent', intent) + setBuildError(undefined) + return + } buildRequest.current = { intent } setStartingBuild(true) setBuildError(undefined) diff --git a/web/src/features/create/steps/start-step.tsx b/web/src/features/create/steps/start-step.tsx index e50e213..61d0eb4 100644 --- a/web/src/features/create/steps/start-step.tsx +++ b/web/src/features/create/steps/start-step.tsx @@ -1,6 +1,8 @@ // Step 0: describe the job, choose a business template, or publish existing work. import type { CreationTools, TemplateSummary } from '../../../model/contracts/catalog' import { isOneOf } from '../../../model/contracts/build' +import { buildCopy } from '../../../model/build/copy' +import { remainingIntentBytes } from '../../../model/build/questions' import { useStore } from '@tanstack/react-form' import { ArrowRight, Check, FileSpreadsheet, FolderGit2, Settings, Sparkles } from 'lucide-react' import { useState, type ReactNode } from 'react' @@ -10,7 +12,7 @@ import { DEFAULT_TEMPLATE_ID, templateUsableFor, type CreateEntry } from '../../ import { Button, Disclosure, Field, HrefLink, LinkButton, LoadFailed, Notice, Select, Skeleton, TextArea, TextInput } from '../../../ui' import { text } from '../copy' import { paths } from '../../../routes/paths' -import { firstError, INTENT_MAX, startSchema, type CreateFormApi } from '../form' +import { firstError, startSchema, type CreateFormApi } from '../form' import { joinBusinessTemplates, type BusinessTemplate } from '../templates' export type EntryBlocks = Record @@ -47,6 +49,8 @@ export function StartStep({ form, disabled, loading, catalogFailed, onRetryCatal onUseImage: () => void }) { const values = useStore(form.store, (state) => state.values) + const opening = values.intent.trim() + const remaining = remainingIntentBytes(opening) const [framework, setFramework] = useState(DEFAULT_TEMPLATE_ID) const ready = (entry: CreateEntry) => !disabled && !loading && !catalogFailed && !stale && !blocked[entry] const templates = joinBusinessTemplates(catalog) @@ -73,12 +77,12 @@ export function StartStep({ form, disabled, loading, catalogFailed, onRetryCatal
{(field) => ( - -