fix: guard flattenProviders against non-array p.models
Some OpenCode Serve /config/providers responses include providers without a 'models' field (or with a non-array value). The un-guarded for-of on p.models then throws 'p.models is not iterable' and crashes the inline prompt construction. Skip such providers instead. Also re-assert the button label as 'AI' (matches thedf2f3dflabel simplification, which the02cedacrevert had bundled away). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
02cedac138
commit
f7099be060
@@ -127,7 +127,7 @@ describe('OpenCodeCellActions', () => {
|
||||
const actions = new OpenCodeCellActions(cell);
|
||||
const btns = actions.node.querySelectorAll('button');
|
||||
expect(btns.length).toBe(1);
|
||||
expect(btns[0].textContent).toContain('🪄');
|
||||
expect(btns[0].textContent).toContain('AI');
|
||||
});
|
||||
|
||||
it('disables the button when notebook panel cannot be resolved', () => {
|
||||
|
||||
@@ -114,6 +114,12 @@ function flattenProviders(
|
||||
}
|
||||
const out: { providerId: string; modelId: string }[] = [];
|
||||
for (const p of providers.providers) {
|
||||
// Some OpenCode Serve responses include providers without a `models`
|
||||
// field (or with a non-array value). Guard to avoid the "p.models is
|
||||
// not iterable" crash and simply skip such providers in the picker.
|
||||
if (!Array.isArray(p.models)) {
|
||||
continue;
|
||||
}
|
||||
for (const m of p.models) {
|
||||
out.push({ providerId: p.id, modelId: m.id });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user