Skip to content

Restore LBOS-1046 'updatefilters' editor controller action#20

Merged
jeperkins4 merged 1 commit into
custom/masterfrom
restore/updatefilters
May 28, 2026
Merged

Restore LBOS-1046 'updatefilters' editor controller action#20
jeperkins4 merged 1 commit into
custom/masterfrom
restore/updatefilters

Conversation

@jeperkins4

Copy link
Copy Markdown

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 updateFilters IMPLEMENTATION in webapp/src/app.tsx (line 591) but DROPPED the controller wiring — the case "updatefilters" was lost in pxteditor/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; add updateFilters(filters?: pxt.editor.ProjectFilters) to IProjectView.
  • pxteditor/editorcontroller.ts: re-add case "updatefilters" calling projectView.updateFilters((data as any).filters).

Verification

End-to-end against the FUSE editor with ENABLE_PXT_FILTERS = true re-enabled in p2-studio:

  • Toolbox categories before flag flip: 19 (all categories visible)
  • Toolbox categories after flag flip + this PR: 11 — exactly the ones DEFAULT_CODEBIT_FILTERS marks SHOW_BLOCK (Display, Text, Input, Output, Timing, Sound, Loops, Logic, Math, Variables, Functions). Hidden: Accelerometer, RgbLed, Debug, Bits, Color, Console, Lists, Arrays — exactly the HIDE_BLOCK set.
  • Restored the pre-Vite-migration FUSE behavior end-to-end.

🤖 Generated with Claude Code

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>
@jeperkins4 jeperkins4 merged commit d91f2b2 into custom/master May 28, 2026
16 checks passed
@jeperkins4 jeperkins4 deleted the restore/updatefilters branch May 28, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant