Replace Prompt Builder beats with complete set framings.
Sets are places with labeled full-text framings; selecting a framing copies only that text, and legacy beat-only sets migrate to a wide framing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,11 +23,10 @@ const {
|
||||
emptyCharacter,
|
||||
emptyOutfit,
|
||||
emptySet,
|
||||
emptyBeat,
|
||||
emptyFraming,
|
||||
cloneSceneForNext,
|
||||
normalizePromptSequence,
|
||||
ensureSceneStatesForCharacters,
|
||||
beatMatchesShotSize
|
||||
ensureSceneStatesForCharacters
|
||||
} = await import(pathToFileURL(tmp).href)
|
||||
unlinkSync(tmp)
|
||||
|
||||
@@ -39,84 +38,112 @@ test('formatCharacterLine covers name/description and outfit', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('shot size filters beats; untagged always included; tags never copied', () => {
|
||||
test('selecting a framing copies only that framing text; labels never appear', () => {
|
||||
const wide = { ...emptyFraming('wide'), id: 'f-wide', text: 'open courtyard at dawn' }
|
||||
const medium = { ...emptyFraming('medium'), id: 'f-med', text: 'courtyard from the arch' }
|
||||
const narrow = { ...emptyFraming('narrow'), id: 'f-nar', text: 'door latch detail' }
|
||||
const set = {
|
||||
...emptySet(),
|
||||
id: 's1',
|
||||
name: 'BadgeSet',
|
||||
description: 'studio backdrop',
|
||||
beats: [
|
||||
{ ...emptyBeat(), id: 'b1', name: 'WideBeat', text: 'wide only line', framings: ['wide'] },
|
||||
{ ...emptyBeat(), id: 'b2', name: 'WideMed', text: 'wide and medium', framings: ['wide', 'medium'] },
|
||||
{ ...emptyBeat(), id: 'b3', name: 'Always', text: 'untagged beat', framings: [] },
|
||||
{ ...emptyBeat(), id: 'b4', name: 'CU', text: 'close only', framings: ['close-up'] }
|
||||
]
|
||||
name: 'Courtyard',
|
||||
framings: [wide, medium, narrow]
|
||||
}
|
||||
const sceneMedium = {
|
||||
const base = {
|
||||
style: 'style',
|
||||
settings: 'settings',
|
||||
shotSize: 'medium',
|
||||
setStates: [{ setId: 's1', on: true }],
|
||||
characterStates: [],
|
||||
prompt: 'prompt'
|
||||
}
|
||||
const mediumText = assembleSceneText(sceneMedium, [], [set])
|
||||
assert.equal(
|
||||
mediumText,
|
||||
'style\n\nsettings\n\nstudio backdrop\nwide and medium\nuntagged beat\n\nprompt'
|
||||
)
|
||||
assert.ok(!mediumText.includes('wide only'))
|
||||
assert.ok(!mediumText.includes('close only'))
|
||||
assert.ok(!mediumText.includes('BadgeSet'))
|
||||
assert.ok(!mediumText.includes('WideBeat'))
|
||||
assert.ok(!mediumText.includes('close-up'))
|
||||
assert.ok(!/\bwide\b/.test(mediumText.replace('wide and medium', '')))
|
||||
const mediumText = assembleSceneText({
|
||||
...base,
|
||||
setStates: [{ setId: 's1', on: true, framingId: 'f-med' }]
|
||||
}, [], [set])
|
||||
assert.equal(mediumText, 'style\n\nsettings\n\ncourtyard from the arch\n\nprompt')
|
||||
assert.ok(!mediumText.includes('open courtyard'))
|
||||
assert.ok(!mediumText.includes('door latch'))
|
||||
assert.ok(!mediumText.includes('Courtyard'))
|
||||
assert.ok(!mediumText.includes('wide'))
|
||||
assert.ok(!mediumText.includes('medium'))
|
||||
assert.ok(!mediumText.includes('narrow'))
|
||||
|
||||
const sceneClose = { ...sceneMedium, shotSize: 'close-up' }
|
||||
const closeText = assembleSceneText(sceneClose, [], [set])
|
||||
assert.equal(
|
||||
closeText,
|
||||
'style\n\nsettings\n\nstudio backdrop\nuntagged beat\nclose only\n\nprompt'
|
||||
)
|
||||
const narrowText = assembleSceneText({
|
||||
...base,
|
||||
setStates: [{ setId: 's1', on: true, framingId: 'f-nar' }]
|
||||
}, [], [set])
|
||||
assert.equal(narrowText, 'style\n\nsettings\n\ndoor latch detail\n\nprompt')
|
||||
assert.ok(!narrowText.includes('open courtyard'))
|
||||
assert.ok(!narrowText.includes('from the arch'))
|
||||
|
||||
const sceneAny = { ...sceneMedium, shotSize: '' }
|
||||
const anyText = assembleSceneText(sceneAny, [], [set])
|
||||
assert.ok(anyText.includes('wide only line'))
|
||||
assert.ok(anyText.includes('wide and medium'))
|
||||
assert.ok(anyText.includes('untagged beat'))
|
||||
assert.ok(anyText.includes('close only'))
|
||||
|
||||
assert.equal(beatMatchesShotSize({ framings: ['wide'] }, 'medium'), false)
|
||||
assert.equal(beatMatchesShotSize({ framings: [] }, 'medium'), true)
|
||||
const noneText = assembleSceneText({
|
||||
...base,
|
||||
setStates: [{ setId: 's1', on: true, framingId: null }]
|
||||
}, [], [set])
|
||||
assert.equal(noneText, 'style\n\nsettings\n\nprompt')
|
||||
})
|
||||
|
||||
test('off set omitted; copy scene is one scene; sequence join is double blank', () => {
|
||||
const set = {
|
||||
...emptySet(),
|
||||
id: 's1',
|
||||
description: 'set desc',
|
||||
beats: [{ ...emptyBeat(), text: 'beat', framings: [] }]
|
||||
}
|
||||
test('off set is omitted; sequence join is double blank', () => {
|
||||
const framing = { ...emptyFraming('wide'), id: 'f1', text: 'set text' }
|
||||
const set = { ...emptySet(), id: 's1', name: 'Place', framings: [framing] }
|
||||
const scene1 = {
|
||||
style: 'a',
|
||||
settings: '',
|
||||
shotSize: '',
|
||||
setStates: [{ setId: 's1', on: true }],
|
||||
setStates: [{ setId: 's1', on: true, framingId: 'f1' }],
|
||||
characterStates: [],
|
||||
prompt: 'p1'
|
||||
}
|
||||
const scene2 = {
|
||||
style: 'b',
|
||||
settings: '',
|
||||
shotSize: '',
|
||||
setStates: [{ setId: 's1', on: false }],
|
||||
setStates: [{ setId: 's1', on: false, framingId: 'f1' }],
|
||||
characterStates: [],
|
||||
prompt: 'p2'
|
||||
}
|
||||
assert.equal(assembleSceneText(scene2, [], [set]), 'b\n\np2')
|
||||
const full = assembleSequenceText({ sets: [set], scenes: [scene1, scene2] })
|
||||
assert.equal(full, 'a\n\nset desc\nbeat\n\np1\n\n\nb\n\np2')
|
||||
assert.equal(assembleSceneText(scene1, [], [set]), 'a\n\nset desc\nbeat\n\np1')
|
||||
assert.equal(full, 'a\n\nset text\n\np1\n\n\nb\n\np2')
|
||||
assert.ok(!full.includes('Place'))
|
||||
assert.ok(!full.includes('wide'))
|
||||
})
|
||||
|
||||
test('legacy beat-only set still opens as one wide framing', () => {
|
||||
const legacy = normalizePromptSequence({
|
||||
id: 'seq1',
|
||||
name: 'Old beats',
|
||||
sets: [{
|
||||
id: 's1',
|
||||
name: 'Hall',
|
||||
description: 'stone walls',
|
||||
beats: [
|
||||
{ id: 'b1', name: 'Beat1', text: 'first beat', framings: ['wide'] },
|
||||
{ id: 'b2', name: 'Beat2', text: 'second beat', framings: ['medium'] }
|
||||
]
|
||||
}],
|
||||
scenes: [{
|
||||
id: 'sc1',
|
||||
title: 'Scene 1',
|
||||
style: 'oil',
|
||||
settings: '',
|
||||
shotSize: 'wide',
|
||||
setStates: [{ setId: 's1', on: true }],
|
||||
prompt: 'walk',
|
||||
characters: []
|
||||
}],
|
||||
characters: [{ id: 'x', name: 'Ada', description: 'tall', outfits: [] }],
|
||||
createdAt: 1,
|
||||
updatedAt: 1
|
||||
})
|
||||
assert.equal(legacy.sets.length, 1)
|
||||
assert.equal(legacy.sets[0].framings.length, 1)
|
||||
assert.equal(legacy.sets[0].framings[0].label, 'wide')
|
||||
assert.ok(legacy.sets[0].framings[0].text.includes('stone walls'))
|
||||
assert.ok(legacy.sets[0].framings[0].text.includes('first beat'))
|
||||
assert.ok(legacy.sets[0].framings[0].text.includes('second beat'))
|
||||
assert.equal(legacy.scenes[0].setStates[0].framingId, legacy.sets[0].framings[0].id)
|
||||
const text = assembleSequenceText(legacy)
|
||||
assert.ok(text.includes('stone walls'))
|
||||
assert.ok(text.includes('first beat'))
|
||||
assert.ok(!text.includes('Hall'))
|
||||
assert.ok(!text.includes('Beat1'))
|
||||
})
|
||||
|
||||
test('legacy sequence without sets still assembles', () => {
|
||||
@@ -137,19 +164,17 @@ test('legacy sequence without sets still assembles', () => {
|
||||
updatedAt: 1
|
||||
})
|
||||
assert.deepEqual(legacy.sets, [])
|
||||
assert.equal(legacy.scenes[0].shotSize, '')
|
||||
const text = assembleSequenceText(legacy)
|
||||
assert.equal(text, 'oil\n\nAda: tall\n\nwalk')
|
||||
assert.equal(assembleSequenceText(legacy), 'oil\n\nAda: tall\n\nwalk')
|
||||
})
|
||||
|
||||
test('cloneSceneForNext copies shotSize and setStates', () => {
|
||||
test('cloneSceneForNext copies setStates including framingId', () => {
|
||||
const sets = [emptySet()]
|
||||
const first = emptyScene(1, [], sets)
|
||||
first.shotSize = 'close-up'
|
||||
first.setStates[0].on = false
|
||||
first.setStates[0].framingId = sets[0].framings[0].id
|
||||
const next = cloneSceneForNext(first, 2)
|
||||
assert.equal(next.shotSize, 'close-up')
|
||||
assert.equal(next.setStates[0].on, false)
|
||||
assert.equal(next.setStates[0].framingId, sets[0].framings[0].id)
|
||||
assert.equal(next.setStates[0].setId, sets[0].id)
|
||||
})
|
||||
|
||||
@@ -164,7 +189,6 @@ test('character outfit and off still work with sets', () => {
|
||||
const text = assembleSceneText({
|
||||
style: '',
|
||||
settings: '',
|
||||
shotSize: '',
|
||||
setStates: [],
|
||||
characterStates: [{ characterId: 'c1', on: true, outfitId: 'o1' }],
|
||||
prompt: 'hi'
|
||||
|
||||
Reference in New Issue
Block a user