feat: add Part primitive task selection

This commit is contained in:
2026-08-02 19:25:37 -04:00
parent 9e15a6b10d
commit 42e59ac068
3 changed files with 12 additions and 8 deletions

View File

@@ -287,8 +287,9 @@ export function createMockFacade(): BitBybitWebCadFacade {
const existing = state.document.tree.filter((item) => item.label.toLowerCase().startsWith(base)).length
return existing === 0 ? base : `${base}${String(existing).padStart(3, '0')}`
}
const appendFeature = (document: DocumentSnapshot, commandId: string): { document: DocumentSnapshot; objectId: string } => {
const definition = featureCommands[commandId]
const appendFeature = (document: DocumentSnapshot, commandId: string, draft: Record<string, unknown> = {}): { document: DocumentSnapshot; objectId: string } => {
const primitiveType = commandId === 'primitive' && ['Box', 'Cylinder', 'Sphere', 'Cone'].includes(String(draft.primitiveType)) ? String(draft.primitiveType) : 'Box'
const definition = commandId === 'primitive' ? { label: primitiveType, detail: primitiveType === 'Box' ? '10 × 10 × 10 mm' : `${primitiveType} primitive` } : featureCommands[commandId]
if (!definition) return { document, objectId: '' }
const objectId = nextFeatureId(definition.label)
const type = commandId === 'create-sketch' ? 'sketch' : commandId === 'create-body' ? 'body' : 'feature'
@@ -472,14 +473,14 @@ export function createMockFacade(): BitBybitWebCadFacade {
const applyTask = () => {
const task = state.task
if (!task || task.status !== 'preview') return
const result = appendFeature(state.document, task.commandId)
const result = appendFeature(state.document, task.commandId, task.draft)
if (!result.objectId) {
state = { ...state, task: { ...task, status: 'completed' } }
emitState()
return
}
commit({ ...state, document: result.document, selectedObjectId: result.objectId, task: { ...task, status: 'completed' } })
notify(`${featureCommands[task.commandId].label} created`)
notify(`${result.document.tree.find((item) => item.id === result.objectId)?.label || featureCommands[task.commandId]?.label || task.commandId} created`)
}
const execute = ({ commandId, payload }: ExecuteCommandInput) => {
const requestId = `req-${++requestSequence}`