Repository navigation
MIDI drum input: kit-profile persistence, live scoring, provider integration, settings panel (#5-#9) - #11
Conversation
…ote-state provider, and settings panel (issues #5-#9) - Persistence (#5): per-profile kit_updated_at stamps, per_song_overrides, bounded validation/salvage, settings.server_files opt-in for Host-side export/import; GET/POST /kit-profiles exposes the new keys. - Chart consumption (#6): the plugin holds its own listener on the highway WS — core exposes drum_tab/drum_hits to renderer bundles only, with no bus event or getDrumTab() getter (checked). Multi-part picker via ?drum_part=; legacy no-tab packs degrade to 'no chart, scoring off'. - Live scoring (#7): ±50 ms matching window with EARLY/OK/LATE split at 40%, per-frame miss sweep with a connect-time floor re-armed on seek-back, streak/accuracy/extras readouts, bounded surfacing of unmapped strikes and missing chart pieces. Mirrors drum_highway_3d. - Note-state provider (#8): function provider (note, chartTime) => state registered on window.highway only while a device session is open, cleared with setNoteStateProvider(null) on exit/disposal. - Settings panel (#9): settings.html with profile CRUD, active-profile switching, coverage chips per lib/drums.py display conventions, and remap deep-links into the player's single-piece remap path via nav params. Fixes audit drift: piece vocabulary now matches lib/drums.py (18 ids, title-cased fallback for unknown ids); the broken object-wrapper setNoteStateProvider registration and the dead drum-tab/drum-hits/ drum-part bus listeners (events no host component emits) are gone, along with the dead onDrumTabChanged API and an unreachable view-scope registerWithHighway() call.
| } | ||
|
|
||
| function normalizeProfileName(name) { | ||
| return String(name || '').trim().replace(/\s+/g, ' ').slice(0, 99); |
There was a problem hiding this comment.
WARNING: normalizeProfileName truncates to 99 chars but server allows 100 for kit profile names
A 100-char profile created via the settings panel is silently truncated to 99 on the player screen, so setActiveKit() and getActiveKitProfile() can't find it.
| return String(name || '').trim().replace(/\s+/g, ' ').slice(0, 99); | |
| return String(name || '').trim().replace(/\s+/g, ' ').slice(0, 100); |
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| clean = {} | ||
| for profile_name, profile in value.items(): | ||
| if not isinstance(profile_name, str) or len(profile_name) > 100: | ||
| if not isinstance(profile_name, str) or not profile_name or len(profile_name) > MAX_PROFILE_NAME_LEN: |
There was a problem hiding this comment.
WARNING: _sanitise_kit_profiles doesn't filter JavaScript reserved object keys
Keys like __proto__, constructor, and prototype pass validation and are persisted. Client-side code then reads inherited properties instead of stored mappings, which can corrupt state or display wrong data.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| return {} | ||
| clean = {} | ||
| for song_id, pieces in value.items(): | ||
| if type(song_id) is not str or not song_id or len(song_id) > MAX_SONG_ID_LEN: |
There was a problem hiding this comment.
WARNING: _sanitise_song_overrides has the same reserved-key gap as _sanitise_kit_profiles
Song override keys like __proto__ or constructor are persisted and misread client-side.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| " standard pieces mapped" + (extra.length ? " (+" + extra.length + " extra)" : ""); | ||
| li.appendChild(count); | ||
|
|
||
| var actions = document.createElement("div"); |
There was a problem hiding this comment.
WARNING: "clean in data.kit_profiles" rejects valid reserved names
The in operator matches prototype properties, so the panel always reports "already exists" for names like constructor or __proto__, even when they aren't in the profile set.
| var actions = document.createElement("div"); | |
| if (Object.prototype.hasOwnProperty.call(data.kit_profiles, clean)) { |
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (7 files)
Previous Review Summaries (5 snapshots)Current summary above is authoritative. Previous snapshots are kept for context only. Previous reviewStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous review (commit db097c9)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous review (commit d7f0fc7)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous review (commit 8e59844)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit e488cc3)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (8 files)
Reviewed by free · Input: 290.5K · Output: 10.5K · Cached: 371.5K |
There was a problem hiding this comment.
Summary
Implements #5–#9 end to end: kit-profile persistence behind namespaced, size-capped routes; live scoring with a note-state provider; midi-input capability wiring; and a full profile-management settings panel. Cross-repo contracts were verified against core: the layer's /ws/highway/{filename}?drum_part= socket, highway.setNoteStateProvider / getNoteStateProvider, and navigate(screenId, params) / one-shot getNavParams() all match what this PR calls. setup() validates before registering routes, and POST bodies are streamed under a cap before deserialization — both per the plugin spec.
One important finding (stale state clobbering across surfaces) plus three smaller ones, inline in Files changed.
Checks out
- WS message shapes (
song_info/drum_tab/drum_hits/ready) matchlib/routers/ws_highway.py; the route has no connection guard, so the layer's socket coexists with the drums plugin's. - The idempotence guard matches the one-shot script model (the host's
loadedScriptsguard evaluatesscreen.jsonce per version per session). - No external consumers of the removed
onDrumTabChanged/ provider-wrapper APIs; the piece-vocabulary change is display-only — profiles are keyed by chart kit ids, so stored data needs no migration. - Atomic write (tmp +
os.replace), corrupt-file salvage, andtype(x) is int-style strictness follow the template conventions.
⚠️ #8's acceptance can't be met yet: no renderer feeds drum hits to the provider
The provider contract on this PR's side is correct — the layer registers a decaying-alpha provider keyed by chartHitKey(t, note.p) — but no current renderer consumes it for drums:
- the 2D highway draws no drum lanes and consults
getNoteStateonly for guitar notes/chords; - core's
drum_highway_3duses its ownplaceNotehit map, never callsgetNoteState, and its drum notes are{lane, t}withoutp, sochartHitKeywould miss anyway; got-feedBack/feedBack-plugin-drumsdoesn't touch the provider either.
So the observable half of #8 (hit gems lighting up, miss wash) won't appear from this PR alone. Suggest keeping #8 open — or splitting the renderer-side work into a follow-up — rather than closing it here.
Testing note
This repo has no test or lint command (the CI workflow comes from the org template and is expected red here), so the checks above are inspection against core sources and the plugin spec rather than a green suite.
big-pickle (free) | 𝕏
There was a problem hiding this comment.
Summary
Incremental pass over the 8 commits since e488cc3 (388500c…8e59844): reserved-key skips on the read paths, hasOwnProperty duplicate checks in the panel, the 99-char bound, the settings-category comment fix, score resets on create/delete, and the two-way stale-state fix (panel refetch on visibility plus an unconditional activation refetch). All four threads from the previous review are addressed — one-sentence replies and resolutions are on each of them.
Two new findings inline: a write/read asymmetry the reserved-key commits introduce, and an unconditional score reset in deleteKitProfile. One nitpick below.
Checks out
- Both halves of the stale-state fix were verified against host sources rather than assumed: inactive screens are
display:none(static/style.css:13-14), settings tab panels likewise (static/v3/v3.css:1099-1100), and the panel's<details>generates no boxes while closed — so theIntersectionObserver(settings.html:123) fires on exactly the transitions that matter (screen switch, tab switch, section expand), in both directions.loadSaved()never rejects (fail-soft fetch, screen.js:534-556), so a failed GET still reachesactivate(), and theactive === !!nextguard (screen.js:1294) keeps the refetch off repeated activation signals. - The activation refetch needs no score reset of its own: returning to the screen re-opens the chart socket and the
drum_tabre-arrival resets scoring (screen.js:1207-1221), so a profile edited from Settings cannot be scored against stale judgments on the way back in. - The three sanitisers cover the three persisted collections consistently (
kit_profiles/kit_updated_at/per_song_overrides, routes.py:227/246/263), and the panel's create and rename both usehasOwnProperty(settings.html:261/351). - Per-song overrides are keyed by song alone (screen.js:827), so a rename or a delete of a non-active profile cannot orphan them.
Nitpick
screen.html:73 still carries maxlength="100" — the half of the earlier 99-character thread that 55bdc9c left behind (the panel's input dropped to 99). Harmless in itself, since normalizeProfileName truncates to 99 anyway; the two name inputs simply disagree now, so drop it to 99 for parity.
Testing note
No test or lint command in this repo (the CI workflow comes from the org template and is expected red here); the checks above are inspection against host sources (static/style.css, static/v3/v3.css, session.js, plugin-loader.js) plus the plugin's own routes, rather than a green suite.
big-pickle (free) | 𝕏
|
Addressed both review threads on PR #11 and the review-body nitpick; 4 commits pushed to
Verified with Task list (1/4 completed)
|
| type="text" | ||
| class="midi-drums__input" | ||
| placeholder="New kit name" | ||
| maxlength="99" |
There was a problem hiding this comment.
SUGGESTION: maxlength="99" but server's MAX_PROFILE_NAME_LEN=100 allows 100-char kit profile names
The client enforces 99 chars (matching normalizeProfileName), but the server's kit_profiles validation accepts 100. Consider aligning: either raise client to 100 or lower server's MAX_PROFILE_NAME_LEN to 99.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Core's plugin-loader mounts settings.html and runs its inline script (plugin-loader.js:618-640) before loading screen.js, so the layer singleton may not exist when the panel first renders. Quote the line range instead of asserting it as a general rule.
…ywhere kilo-code-bot findings (latest review, commit d7f0fc7): - routes.py active_kit validator now rejects __proto__/constructor/prototype (was the one slot without a reserved-key check, so a hand-edited __proto__ would shadow the default on the next read). Read path already skipped them. - 100-char cap aligned end to end. Server is the authority (MAX_PROFILE_NAME_LEN=100), so the client (normalizeProfileName) and both HTML maxlength attributes now allow 100 too — previously the settings panel could create a 100-char profile the player screen could not select. - Validator asymmetry fixed: several spots used len < 100 while kit_profiles used len > 100, so the same name passed one check and failed the other. - settings.html already rejected reserved names (pullfrog's earlier fix); verified present (RESERVED_PROFILE_NAMES + hasOwnProperty checks).
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com> Signed-off-by: Carolina <79524656+carochacs@users.noreply.github.com>
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com> Signed-off-by: Carolina <79524656+carochacs@users.noreply.github.com>
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Checks out
Incremental pass over the four commits since d7f0fc7 (14c8a0c, db097c9, fc8adac, 0a44ed9): the active_kit reserved-key guard, the 100-character name cap aligned across routes.py, screen.html, screen.js and settings.html, and the script-ordering note in the panel header.
The cap now agrees at every site — server validation, the three sanitisers, _read()'s truncation, both inputs' maxlength, normalizeProfileName, and both panel handlers. The two .slice(0, 99) sites the open kilo-code-bot threads at midi-drums/settings.html:265 and :356 called out were fixed here in fc8adac and 0a44ed9; the older open threads at midi-drums/routes.py:246, :282, midi-drums/settings.html:245 and midi-drums/screen.html:73 also match the code now, so all seven can be closed by their author.
The loader-ordering claim in the panel header checks out against core: settings markup mounts and its inline script runs at plugin-loader.js:618-640, and screen.js loads after at :642.
Checks out: 4 commits, 4 files.
big-pickle (free) | 𝕏
|
Addressed the single thread from review 5441875089 on PR #11. The comment at
Task list (2/5 completed)
|

Closes #5, closes #6, closes #7, closes #8, closes #9. Parent: #2.
What lands
#5 — Kit-profile persistence (
routes.py,plugin.json)kit_updated_at(per-profile ISO last-modified stamps, a flatcompanion of
kit_profilesso the mapping shape stayspieceId → mapping)and
per_song_overrides(songKey → {pieceId → mapping}, sparse overlaysconsulted before the base profile).
MAX_KIT_PROFILES,MAX_PIECES_PER_PROFILE,MAX_SONG_OVERRIDE_KEYS, …); the profile routes take their own 256 KiB bodycap since a full 64-profile library of 18-piece e-kits outgrows the 16 KiB
settings cap.
settings.server_files: ["midi-drums.json"]opt-in for Host-sideexport/import; read-side salvage covers the new keys key-by-key.
#6 — Drum chart consumption (
screen.js)static/highway.js: the highway handsdrum_tab/drum_hitsto renderer bundles only — neither is re-emitted as abus event and there is no
getDrumTab()getter — so a non-renderer pluginholds its own listener on the same WS endpoint (the server's extraction
caches make the second connection cheap). The previous code listened for
drum-tab/drum-hits/drum-partbus events that no host component emits.?drum_part=reconnects for multi-part packs; the picker mirrors theauthoritative
drum_tab.part_idafter fallbacks, like highway.js does.drum_tab: treatedas "no chart — scoring off" for that song rather than shipping a private
legacy decoder (issue Drum chart consumption: drum_tab/drum_hits + multi-part support #6 offered exactly that choice).
#7 — Live scoring engine (
screen.js)drum_highway_3d: ±50 ms window (HIT_TOLERANCE_S), EARLY/OK/LATEsplit at 40%, per-frame miss sweep whose 2 s look-back window stays
populated by a rAF tick, connect-time
missFloorso notes that elapsedwithout a device open are not scored, and seek-back re-arms the region.
t|pieceinscoredJudgments; streak/best-streak/extracounters; unmapped strikes and missing chart pieces surfaced (count +
bounded sample / piece list) instead of silently dropped.
#8 — setNoteStateProvider integration (
screen.js)(note, chartTime) => stateonwindow.highway(the previous code passed an object wrapper, which thecontract never invokes) and clears with
setNoteStateProvider(null)onscreen exit and disposal. Returns decaying
alphaglows (hit 450 ms, miss1.2 s) and goes falsy when the effect ends — the provider owns all fade
timing per feedBack#254.
last-call-wins, so a provider that cannot score must not squat it.
#9 — Settings screen UI (
settings.html, CSS)rename), delete (active falls back to
defaultand is recreated ondemand), set-active; per-profile coverage chips over the canonical
vocabulary with last-updated stamps.
(Per-piece kit-profile calibration wizard #4's
remapPiece) viawindow.feedBack.navigate('__', { remapPiece });the plugin screen consumes nav params on activation. The panel talks
straight to the plugin's routes and does not depend on the plugin screen
having hydrated.
Audit drift fixed
lib/drums.py(18 ids, 1:1); unknown ids fromnewer packs round-trip with a title-cased fallback.
onDrumTabChangedrunner, the unused note-state wrapper,updateNoteStateForHit, and an unreachable view-scoperegisterWithHighway()call (it was also a ReferenceError — a layer-internalfunction called in view scope).
—rather than a lie of100%on a fresh chart.Verification
node --check screen.js,python3 -m py_compile routes.py, JSON manifestparse — clean.
carries stamp, unknown-profile rejection, active-fallback), pushed-chart
state, missing-piece surfacing, provider registered as a function,
nullverdict for unscored notes, provider cleared on demand.routes.pyhandler harness: full round-trip of the new keys; 400s onunknown keys / invalid stamps /
boolnote (int-subclass guard) / extramapping keys / over-long song ids / duplicate source keys; 413 on oversize;
hand-edited-file salvage retains valid entries and drops bad ones; corrupt
file degrades to defaults.