fix: AI tracks auto-align to end of last existing item
- Replace currentTime with auto-calculated maxEnd from existing items - Each AI generation starts right after the previous one - Ensures tracks from different generations align in bar columns
This commit is contained in:
+11
-1
@@ -13854,7 +13854,17 @@ const App = () => {
|
||||
};
|
||||
updatedTracks.push(targetTrack);
|
||||
}
|
||||
const itemStartTimeSec = currentTime;
|
||||
const itemStartTimeSec = (() => {
|
||||
// Auto-align: place new AI tracks right after the last existing item
|
||||
let maxEnd = 0;
|
||||
updatedTracks.forEach(t => {
|
||||
(t.midiItems || []).forEach(mi => {
|
||||
const miEnd = (mi.startTime || 0) + (mi.duration || 0);
|
||||
if (miEnd > maxEnd) maxEnd = miEnd;
|
||||
});
|
||||
});
|
||||
return maxEnd > 0 ? maxEnd : 0;
|
||||
})();
|
||||
const newMidiItem = {
|
||||
id: 'item_ai_' + Date.now() + '_' + Math.random().toString(36).substr(2, 5),
|
||||
name: `${composition_title || 'AI Theme'} - ${aiTrack.track_name}`,
|
||||
|
||||
Reference in New Issue
Block a user