Skip to content

fix: menu lists raw catalogue + feat: /filtered-models picker with type-to-filter - #3

Open
Ruivalim wants to merge 3 commits into
clankercode:masterfrom
Ruivalim:fix/menu-raw-catalogue
Open

fix: menu lists raw catalogue + feat: /filtered-models picker with type-to-filter#3
Ruivalim wants to merge 3 commits into
clankercode:masterfrom
Ruivalim:fix/menu-raw-catalogue

Conversation

@Ruivalim

@Ruivalim Ruivalim commented Sep 1, 2026

Copy link
Copy Markdown

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 unpatched originals.getAll() captured in the patch state (falling back to getAvailable() when unpatched). Verified against a live pi session: patched getAvailable() 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 /models reads a cached ModelRuntime snapshot and ignores the registry patch, so blocked models still show there. This adds a /filtered-models command (alias /fmodels) that lists the patched getAvailable() (i.e. only models that survive the filter), marks and pre-selects the current model, and switches with pi.setModel().

Also adds type-to-filter to the shared SubmenuController (printable chars extend the query, backspace shrinks, drives SelectList.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).

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
Ruivalim force-pushed the fix/menu-raw-catalogue branch from f31c7cf to 0f9bd22 Compare September 1, 2026 22:56
@Ruivalim Ruivalim changed the title fix: menu lists the raw model catalogue, not the filtered one fix: menu lists raw catalogue + feat: /filtered-models picker with type-to-filter Sep 1, 2026
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