fix: menu lists raw catalogue + feat: /filtered-models picker with type-to-filter - #3
Open
Ruivalim wants to merge 3 commits into
Open
fix: menu lists raw catalogue + feat: /filtered-models picker with type-to-filter#3Ruivalim wants to merge 3 commits into
Ruivalim wants to merge 3 commits into
Conversation
handleInput() dereferenced this.selectList after SelectList.handleInput(), but Enter (single-select) and Escape callbacks close the submenu and set selectList to null, throwing 'TypeError: null is not an object'. Guard the post-input index tracking and return early: the input was already consumed by the closed submenu. Adds submenu tests covering Enter-select, Esc-cancel and Esc-apply.
getProviders/getModelsForProvider read ctx.modelRegistry.getAvailable(), which the extension itself patches to hide blocked models. Models already covered by a block rule disappeared from the Provider and Match IDs pickers, making them impossible to select when editing or adding rules. The menu now reads the unpatched originals.getAll() captured by the patch (falling back to getAvailable() when unpatched).
pi's built-in /models reads a cached ModelRuntime snapshot and ignores the registry patch, so blocked models still show there. Adds a /filtered-models command (alias /fmodels) listing the patched getAvailable() (so already filtered), marking and pre-selecting the current model, switching via pi.setModel(). SelectList only handles arrows/Enter/Esc, so typing did nothing. The SubmenuController now maintains a filter query (printable chars extend, backspace shrinks) and drives SelectList.setFilter(). Applies to the picker and all menu submenus. Includes the submenu null-guard from #1 as this branch's base does not have it; will drop cleanly when rebased onto #1.
Ruivalim
force-pushed
the
fix/menu-raw-catalogue
branch
from
September 1, 2026 22:56
f31c7cf to
0f9bd22
Compare
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.
What this PR does
Two related fixes/features around the menu seeing the real model catalogue:
1. fix: menu lists the raw model catalogue, not the filtered one
Models already covered by a block rule did not appear in the Provider or Match IDs pickers, so they could not be selected when adding or editing rules. Cause: the menu read
ctx.modelRegistry.getAvailable(), which this extension itself patches to hide blocked models. The menu now reads the unpatchedoriginals.getAll()captured in the patch state (falling back togetAvailable()when unpatched). Verified against a live pi session: patchedgetAvailable()hides a blocked model; the unpatched originals return the full 1334-model catalogue including it.2. feat: /filtered-models (/fmodels) + type-to-filter
pi's built-in
/modelsreads a cachedModelRuntimesnapshot and ignores the registry patch, so blocked models still show there. This adds a/filtered-modelscommand (alias/fmodels) that lists the patchedgetAvailable()(i.e. only models that survive the filter), marks and pre-selects the current model, and switches withpi.setModel().Also adds type-to-filter to the shared
SubmenuController(printable chars extend the query, backspace shrinks, drivesSelectList.setFilter()), since SelectList itself only handles arrows/Enter/Esc. Applies to the picker and all menu submenus.Tests
92 passed: picker tests (listing, current marker/pre-select, Enter pick, Esc cancel, empty state) and submenu type-to-filter test included.
Depends on #1 (stacked on the submenu crash fix).