Restore LBOS-1046 'updatefilters' editor controller action#20
Merged
Conversation
The original LBOS-1046 commits (2019, PR #4) added an `updatefilters` editor-controller action so p2-studio's CodingCanvas could dynamically restrict the toolbox to blocks/namespaces appropriate for the active codeBit / BLE bit. The v12.2.34 upstream merge preserved the `updateFilters` IMPLEMENTATION in webapp/src/app.tsx but DROPPED the wiring in pxteditor/editorcontroller.ts, so the postMessage was silently ignored. Restore: - localtypings/pxteditor.d.ts: add `"updatefilters"` to the editor action union and `updateFilters(filters?: pxt.editor.ProjectFilters)` to the IProjectView interface. - pxteditor/editorcontroller.ts: add the `case "updatefilters"` handler that calls `projectView.updateFilters((data as any).filters)`. Verified end-to-end against the FUSE editor with `ENABLE_PXT_FILTERS = true` in p2-studio: toolbox correctly drops the ~8 codeBit-inappropriate categories (Accelerometer, RgbLed, Debug, Bits, Color, Console, Lists, Arrays) and keeps the 11 bit-appropriate ones. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
p2-studio's CodingCanvas sends
{ type: 'pxteditor', action: 'updatefilters', filters: {...} }when active bits change, so the toolbox can be restricted to blocks/namespaces appropriate for the connected codeBit or BLE bit. After the v12.2.34 upstream merge (#19), the editor silently ignored these messages — bit-specific toolbox filtering was broken in FUSE.Why
The original LBOS-1046 work (2019, PR #4) added the action handler. The v12.2.34 merge preserved the
updateFiltersIMPLEMENTATION inwebapp/src/app.tsx(line 591) but DROPPED the controller wiring — thecase "updatefilters"was lost inpxteditor/editorcontroller.ts, and the corresponding union member and IProjectView declaration weren't carried over either.Fix
localtypings/pxteditor.d.ts: add"updatefilters"to the editor action union; addupdateFilters(filters?: pxt.editor.ProjectFilters)toIProjectView.pxteditor/editorcontroller.ts: re-addcase "updatefilters"callingprojectView.updateFilters((data as any).filters).Verification
End-to-end against the FUSE editor with
ENABLE_PXT_FILTERS = truere-enabled in p2-studio:SHOW_BLOCK(Display, Text, Input, Output, Timing, Sound, Loops, Logic, Math, Variables, Functions). Hidden: Accelerometer, RgbLed, Debug, Bits, Color, Console, Lists, Arrays — exactly theHIDE_BLOCKset.🤖 Generated with Claude Code