From 0bb4ccf11fe2e7f76feb6d78a533b4f9704d99cf Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 17 Apr 2026 16:58:49 +0200 Subject: [PATCH] fix(coding-agent): keep scoped-model reorder inert in implicit all-enabled state closes #3331 --- packages/coding-agent/CHANGELOG.md | 1 + .../components/scoped-models-selector.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 51935979..71aadd1e 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed +- Fixed `/scoped-models` Alt+Up/Down to stay a no-op in the implicit `all enabled` state instead of materializing a full explicit enabled-model list and marking the selector dirty ([#3331](https://github.com/badlogic/pi-mono/issues/3331)) - Fixed flaky git package update notifications by waiting for captured git command stdio to fully drain before comparing local and remote commit SHAs ([#3027](https://github.com/badlogic/pi-mono/issues/3027)) - Fixed auto-retry transient error detection to treat `Network connection lost.` as retryable, so dropped provider connections retry instead of terminating the agent ([#3317](https://github.com/badlogic/pi-mono/issues/3317)) - Fixed compact interactive extension startup summaries to disambiguate package extensions and repeated local `index.ts` entries by using package-aware labels and the minimal parent path needed to make local entries unique ([#3308](https://github.com/badlogic/pi-mono/issues/3308)) diff --git a/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts b/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts index 18d39db8..ab7c741f 100644 --- a/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts +++ b/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts @@ -45,8 +45,9 @@ function clearAll(enabledIds: EnabledIds, allIds: string[], targetIds?: string[] return enabledIds.filter((id) => !targets.has(id)); } -function move(enabledIds: EnabledIds, allIds: string[], id: string, delta: number): EnabledIds { - const list = enabledIds ?? [...allIds]; +function move(enabledIds: EnabledIds, id: string, delta: number): EnabledIds { + if (enabledIds === null) return null; + const list = [...enabledIds]; const index = list.indexOf(id); if (index < 0) return list; const newIndex = index + delta; @@ -238,15 +239,15 @@ export class ScopedModelsSelectorComponent extends Container implements Focusabl // Alt+Up/Down - Reorder enabled models if (matchesKey(data, Key.alt("up")) || matchesKey(data, Key.alt("down"))) { + if (this.enabledIds === null) return; const item = this.filteredItems[this.selectedIndex]; if (item && isEnabled(this.enabledIds, item.fullId)) { const delta = matchesKey(data, Key.alt("up")) ? -1 : 1; - const enabledList = this.enabledIds ?? this.allIds; - const currentIndex = enabledList.indexOf(item.fullId); + const currentIndex = this.enabledIds.indexOf(item.fullId); const newIndex = currentIndex + delta; // Only move if within bounds - if (newIndex >= 0 && newIndex < enabledList.length) { - this.enabledIds = move(this.enabledIds, this.allIds, item.fullId, delta); + if (newIndex >= 0 && newIndex < this.enabledIds.length) { + this.enabledIds = move(this.enabledIds, item.fullId, delta); this.isDirty = true; this.selectedIndex += delta; this.refresh();