Commit Graph

707 Commits

Author SHA1 Message Date
3dtours 35fb29201d fix: AI Suggestion shows only Rearrange presets when MIDI item selected
When hasSelItem is true, suggestions filtered to only
Rearrange / Variation category + favorites.
2026-07-28 21:04:19 +07:00
3dtours 393dd7190f fix: rearrangeMidiMelody newId not defined
newId was defined inside updateActiveTracks callback but
referenced outside (line 15002 return). Moved declaration
before the callback as rearrangeNewId, accessible in both
the callback body and the outer return statement.
2026-07-28 20:58:44 +07:00
3dtours fc81f19b1c fix: MIDI rearrange tool spec double-wrapped, AI returns _unknown
REARRANGE_TOOL_SPEC already has {type:'function', function:{...}}
wrapper. callLLM's tools.map(t => ({type:'function', function:t}))
added ANOTHER wrapper, creating nested:
  {type:'function', function:{type:'function', function:{name}}}
which AI models couldn't parse -> function name became _unknown.
Fix: pass .function (inner spec) instead of the outer wrapper.
2026-07-28 20:51:27 +07:00
3dtours 61f4b90af0 feat: Action Log hidden by default, click header to toggle
- showAIActionLog state defaults to false
- Action Log header clickable (cursor-pointer), shows '-' when
  visible, '+' when hidden
- Body always rendered with CSS class 'hidden' toggled, avoids
  deep ternary nesting that exceeded Babel 8 maxTargets limit
2026-07-28 20:43:08 +07:00
3dtours a56c616817 fix: AI Panel list show 2026-07-28 20:38:53 +07:00
3dtours 9cbf5940f4 chore: Copilot prompt textarea 8 rows 2026-07-28 20:27:58 +07:00
3dtours 4c3d649506 fix: remove preset auto-optimization from AI send paths
matchPreset was replacing systemInstruction with the preset's
template on keyword match. Typing 'epic orchestra' would
auto-apply 'Epic Orchestra Intro (8 Bars)' restrictive template.

Removed both override blocks (Piano Roll MIDI gen + DAW
rearrange). System instruction stays as generic default.
User can still fill prompt via suggestion click without
forced template override.
2026-07-28 20:26:03 +07:00
3dtours 0dc3f10406 fix: AI Copilot shows all presets in suggestion list
Change suggestions from getContextualSuggestions (filtered)
to promptMgr.presets (all). MIDI item name still shown in
header when hasSelItem is true.
2026-07-28 20:20:22 +07:00
3dtours 6a46b1ffe4 fix: AIPresetModal merge backend presets instead of overwrite
Backend sync effect (useEffect mount) was unconditionally
replacing mgr.presets with data.presets, destroying:
- Frontend-only default presets (12 vs backend's 7)
- User-defined presets in localStorage not yet synced to backend

Fix: merge backend presets by id — keep all local presets,
append any backend presets whose id doesn't exist locally.
User presets + frontend defaults are never lost.
2026-07-28 20:17:52 +07:00
3dtours 71edf7ffb3 feat: AIPresetModal - 'Người dùng' filter for user-defined presets
Add 'Người dùng' category to filter dropdown. Filter logic
checks p.is_user_defined when this category is selected.
Shows only presets the user has created/added.
2026-07-28 20:15:11 +07:00
3dtours c09ad7f48d feat: AI Copilot suggestion toggle button
Add showAISuggestions state + 'Sug' toggle button in Copilot
Prompt header. When hidden, suggestion list is unmounted
(showAISuggestions ? ... : null). Button styling: visible
state = bg-zinc-800/zinc-400, hidden = indigo-950/indigo-400.
2026-07-28 20:11:23 +07:00
3dtours ad29df46d2 fix: AI suggestion list shows only rearrange presets for MIDI item
Use suggestions (filtered by getContextualSuggestions) instead
of promptMgr.presets (all). When MIDI item selected, only
Rearrange/Variation + favorites shown. When no MIDI item,
non-rearrange presets shown instead.
2026-07-28 20:09:45 +07:00
3dtours 2a9748e12e feat: AI Copilot panel - full scrollable preset list + MIDI item name
Replace horizontal suggestion chips (max 6/4) with vertical
scrollable list (max-h-36, no-scrollbar) showing ALL presets
from PromptTemplateManager (capped at 50). Header shows
'AI Suggestion' label. When MIDI item selected, MIDI item
name displayed in header. Each preset shows star/fav icon,
name, and category tag. Click fills the prompt textarea.
2026-07-28 20:07:29 +07:00
3dtours bb49035bee fix: sửa lỗi xóa track khi nhấn phím Del, đúng là phải xóa items được chọn 2026-07-28 19:34:47 +07:00
3dtours 6c8eb79aac fix: use ref-wrapped handler for delete selected items
Move delete logic into handleDeleteSelectedItemsRef to ensure
setSelectedItemIds, updateActiveTracks, showToast are always
up-to-date despite empty useEffect deps in keyboard handler.

Keyboard handler reads selectedItemIdsRef.current (live ref),
calls handleDeleteSelectedItemsRef.current(idsToDelete).
2026-07-28 18:47:40 +07:00
3dtours 54c1ee9e94 fix: use selectedItemIdsRef in keyboard handler to fix stale closure
Keyboard handler useEffect has empty deps [], so selectedItemIds was
always captured as empty Set. Added selectedItemIdsRef to keep live
reference, matching pattern used by selectedClipIdRef.
2026-07-28 18:35:49 +07:00
3dtours a41284ccf7 feat: add Ctrl+A select all items and Del key delete selected items/groups
- Ctrl+A already existed for selecting all timeline items across tracks
- Added Del/Backspace key handler for selectedItemIds: deletes all selected sections, MIDI items, and audio clips from the selected track(s)
- Clears selection after deletion and shows toast with count
2026-07-28 18:22:31 +07:00
3dtours 6604f85e0d fix: sửa lỗi mouse với ctrl+click+drag 2026-07-28 17:29:50 +07:00
3dtours cff3950670 feat: AI Copilot suggestion chips + typeahead dropdown
- Suggestion chips bar: context-aware (amber for rearrange, indigo for creation)
- Typeahead dropdown: keyword matching on ≥2 chars, Tab to select
- getSelectedMidiItemInfo helper for context detection
- Backend: 4 rearrange presets in ai_presets.py
- PromptTemplateManager: getContextualSuggestions(hasSelectedItem)
2026-07-28 11:20:26 +07:00
3dtours 3f7abe0c95 feat: AI Rearrange Scenario Detection from spec 45_SCENARIAO_AI
- 9 rearrange scenarios with keyword matching (arpeggio, harmonies,
  syncopation, walking bass, jazz, synthwave, cinematic, simplify, chromatic)
- detectRearrangeScenario() maps user prompt to specific technique rules
- buildRearrangeMessage auto-injects scenario-specific technique guidance
- 9 rearrange presets added to PromptTemplateManager (Rearrange / Variation)
2026-07-28 11:03:26 +07:00
3dtours 2eb327056d fix: MIDI Rearrange — selected item triggers dedicated tool flow
- midiExtractor.js: extractSelectedMIDIContext with note name conversion
- aiGateway.js: REARRANGE_TOOL_SPEC + buildRearrangeMessage
- dawCommandDispatcher.js: register REARRANGE_MIDI_MELODY command
- app.jsx: handleAISend detects selected MIDI item → rearrange flow
- rearrangeMidiMelody handler places A/B track below source track
2026-07-28 10:54:35 +07:00
3dtours 421535ca0e feat: AI MIDI Prompt Template & Preset Engine
- promptTemplateManager.js: standalone service with keyword scoring, CRUD, fav toggle
- ai_presets.py: backend CRUD router (JSON file, auth isolation)
- AIPresetModal: PromptTemplateManager, star/fav column, backend API sync
- Piano Roll AI: preset matching support
- 7 tests: matching, CRUD, anonymous auth, user isolation
2026-07-28 10:42:30 +07:00
3dtours 77c7486d4e fix: sửa lỗi Ctrl+S trong SECTION-TAB để lưu vào MAIN SESSION sửa AI 2026-07-28 10:32:39 +07:00
3dtours 10c0a743c6 feat: CC lane dropdown with Velocity, Sustain, Modulation, Pitch Bend, Pan
Replaced flex div with velocity/pan buttons with a
<select> dropdown containing 5 CC type options.
Default: Velocity. Button toggle shows short label.
2026-07-28 10:20:52 +07:00
3dtours ae71acef0f fix: sửa lỗi Ctrl+S trong SECTION-TAB để lưu vào MAIN SESSION 2026-07-28 10:13:58 +07:00
3dtours f0b62d5a1c fix: Ctrl+S in SECTION-TAB stale closure, saveSectionTab uses initial sessionTabs
Keyboard handler (useEffect [] deps) captures handleSaveSectionTab
from first render, which has sessionTabs = []. When section tab
is opened later, saved handleSaveSectionTab finds no tab and
returns silently. Added handleSaveSectionTabRef, updated on
every render, used in keyboard handler via ref.current.
2026-07-28 10:13:28 +07:00
3dtours f84431c9a6 fix: sửa lỗi Ctrl+S trong SECTION-TAB 2026-07-28 10:11:25 +07:00
3dtours b5f3f987b7 fix: Ctrl+click empty space starts sweep select with yellow cursor
Line 1163 called onSweepSelectStart which set up sweep
state (yellow selection rectangle). Mousemove then
selected all items in the sweep range. Changed to
onClearSelection = () => setSelectedItemIds(new Set())
which only clears selection without starting sweep.
2026-07-28 10:10:05 +07:00
3dtours 5ec329933a fix: Ctrl+S in SECTION-TAB exports SF instead of saving section
First Ctrl+S handler (line 8066, handleExportSFS) catches
ALL Ctrl+S before second handler (line 8157, save section)
ever runs. Moved section-tab check into first handler:
activeTab.startsWith('session_') -> handleSaveSectionTab.
Main session Ctrl+S still exports SF (same as before).
2026-07-28 10:07:02 +07:00
3dtours aafc750274 fix: sub-tab keyboard block captures Ctrl+A/S in SECTION-TAB
Line 7942 checked activeTabRef.current !== 'main', which
is true for SECTION-TAB (session_xxx). Sub-tab block
only handles audio/image keys then unconditionally
returns at line 8005 -> Ctrl+A/S never reached.
Changed to exclude section tabs via
!activeTabRef.current.startsWith('session_').
2026-07-28 10:03:46 +07:00
3dtours 62a41d4502 fix: Ctrl+S saves section in SECTION-TAB, Ctrl+A selects all items
Ctrl+S in SECTION-TAB (activeTab starts with session_):
calls handleSaveSectionTab(curTab).
Ctrl+A in MAIN/SECTION-TAB: collects sections, midiItems,
clips from activeTracksRef.current into selectedItemIds.
Ignores sub-tab contexts (PIANO_ROLL).
2026-07-28 09:59:13 +07:00
3dtours fa7ffe88bf fix: sửa lỗi insert section trong SECTION-TAB 2026-07-28 09:57:56 +07:00
3dtours 385d62cfaf fix: Insert Section visible in SECTION-TAB context menu
JSX rendering menu at line 17500 lacked the
!sessionTabs.some(s => s.id === activeTab) guard.
Added it - section tab context menu no longer offers
Insert Section (sections cannot contain section items).
2026-07-28 09:55:37 +07:00
3dtours f4a364df51 fix: sửa lỗi play section item và midi item riêng biệt 2026-07-28 09:52:41 +07:00
3dtours 32b61553f9 fix: program_change at call time overrides subsequent notes
_playNoteFluid called program_change synchronously at
call time, not at scheduled note time. startTrackPlayback
processes all MIDI items first, then all sections -> each
note's program_change overwritten by the last type processed.
All notes played with section instrument regardless of
actual time position. Moved program_change into doNote
(setTimeout callback) so it fires at correct time.
2026-07-28 09:48:54 +07:00
3dtours 67551075be fix: sửa lỗi loaded instrument ở SECTION-TAB nhưng không play được ở MAIN SESSION 2026-07-28 09:39:18 +07:00
3dtours fd31e8051d fix: sửa lỗi loaded instrument ở MAIN SESSION thì bị áp dụng cho SECTION-TAB 2026-07-28 09:33:35 +07:00
3dtours 43691a127e fix: section track plays GM Piano via program default 0
section cloned tracks have instrumentProgram:undefined.
Line 10283 defaulted to 0 -> FluidSynth program_change(ch,0)
-> plays whatever SoundFont is loaded (MAIN SF).
Added _isSectionClone flag; line 10283 skips program default
for section clones -> undefined -> _playNoteFluid silent return.
2026-07-28 09:30:27 +07:00
3dtours 6fa6578dd1 feat: silent fallback when no instrument — no oscillator default
_playNoteFluid no-instrument branch previously called
_playNoteFallback (sine wave oscillator). Changed to
silent return. User explicitly requested no default sound.
2026-07-28 09:28:21 +07:00
3dtours 2dec94aa7e fix: restore program default 0 for MAIN track MIDI playback
Line 10283 defaulted to undefined when instrumentProgram
undefined, breaking Play for MAIN tracks with MIDI items
but no instrument. Restored: undefined ? instrumentProgram : 0.
Section sub-track (line 10393) keeps undefined -> oscillator
fallback to avoid loading MAIN SoundFont.
2026-07-28 09:25:50 +07:00
3dtours ea40f0c540 revert: playhead fixes cause cannot play on MAIN/SECTION-TAB
Revert two changes from 5d31563:
1. Explicit requestAnimationFrame in handlePlayPause (redundant,
   useEffect already handles RAF start after setIsPlaying)
2. setCurrentTime(0) in handleEditSectionInTab (resets global
   currentTime, interferes with MAIN session position)
2026-07-28 09:22:44 +07:00
3dtours 5d31563df6 fix: playhead not moving in SECTION-TAB with empty tracks
Two fixes:
1. handlePlayPause: add explicit requestAnimationFrame(updatePlayhead)
   after setIsPlaying(true) to ensure RAF starts immediately.
2. handleEditSectionInTab: add setCurrentTime(0) to reset playhead
   to section start. Without this, currentTime may be outside
   the section's timeline range (e.g. from main session playback).
2026-07-28 09:20:31 +07:00
3dtours 2f2f84066c fix: main playback default program 0 loads MAIN SoundFont
Line 10283 same issue as 10393: when instrumentProgram is
undefined (section cloned tracks), program defaults to 0.
_playNoteFluid calls program_change(ch,0) on FluidSynth,
which loads program 0 from whatever SoundFont is loaded
(MAIN session's SF). Fix: pass undefined -> oscillator
fallback for all tracks without assigned instrument.
2026-07-28 09:15:51 +07:00
3dtours 52ec9379d6 fix: section sub-track MIDI default program 0 loads MAIN SoundFont
Line 10393 defaulted program to 0 when subTrack.instrumentProgram
was undefined (section clone with no instrument). _playNoteFluid
receives program=0, calls program_change(ch,0) on FluidSynth,
which picks program 0 from whatever SoundFont is loaded (MAIN
session's SF). Fix: pass undefined -> _playNoteFluid takes
oscillator fallback, no SoundFont loading.
2026-07-28 09:10:33 +07:00
3dtours 9c2fa52e1b revert: Synth button conditional on section items - track can have both
815a6fa hid Synth when track has sections. But a track
can contain both section items AND midi items. Synth
applies to MIDI items regardless of sections. Section
instrument isolation is handled by section clone
nullifying all soundfont fields (9befc20).
2026-07-28 08:50:13 +07:00
3dtours 815a6faaca fix: Synth button shown on section/audio tracks
Synth button was unconditional in TCP. Now gated:
track.midiItems?.length > 0 && !track.sections?.length
Section tracks: Synth hidden (sections are containers).
MIDI tracks: Synth shown.
Audio tracks: Synth hidden.
FX button stays unconditional for all track types.
2026-07-28 08:37:31 +07:00
3dtours 9befc20851 fix: section track inherits soundfont_id/bank/program via ...t spread
...t in fallback branch copied soundfont_id, soundfont_bank,
soundfont_program, instrument_source from parent MAIN track
even though instrumentProgram and synth_engine were nulled.
FluidSynth picks up these fields and auto-loads the SoundFont.
Fix: override all soundfont/synth fields to null/undefined.
2026-07-28 08:32:21 +07:00
3dtours 18e177fa2d revert: section tracks inherit parent instrument, auto-loads SF prog0
Previous fix f2ac70e inherited instrumentId/program/name
from parent MAIN track. This causes SECTION-TAB to auto-load
program 0 of whatever SoundFont is loaded on MAIN, even
though user didn't select any instrument for the section.
Section tracks now keep null instrument + synth_engine
undefined. User can still load instrument manually via
Synth button (routed by updateActiveTracks fix).
2026-07-28 08:27:27 +07:00
3dtours f2ac70eee0 fix: section sub-tracks nullify instrument instead of inheriting
handleEditSectionInTab fallback branch explicitly set
instrumentId: null, instrumentProgram: undefined,
instrumentName: null, overriding parent track's values
spread by ...t. Changed to inherit from parent track:
instrumentId: t.instrumentId || null,
instrumentProgram: t.instrumentProgram,
instrumentName: t.instrumentName || null
2026-07-28 08:18:43 +07:00
3dtours ed51cab765 fix: instrument load from PIANO_ROLL in SECTION-TAB writes to main
updateActiveTracksRef checks sessionTabs by currentActiveTab.
When activeTab is a PIANO_ROLL sub-tab (midi_xxx), none matches
-> falls to setTracks (main). Instrument changes are lost.
Fix: also check subTabs for PIANO_ROLL type, resolve parent
session tab via parent_tab_id, route to setSessionTabs.
2026-07-28 08:11:36 +07:00