diff options
| author | Dax Raad <[email protected]> | 2025-10-31 19:42:27 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-10-31 19:42:41 -0400 |
| commit | d4cb47eadc515646f9f42679100a075ff9c9d458 (patch) | |
| tree | c137ade7e0c734698f7ed65b66b9d1fa216e2257 /packages/desktop/src/context | |
| parent | 261ff416a9fb8938adbb36d4de9b6be782fa5682 (diff) | |
| download | opencode-d4cb47eadc515646f9f42679100a075ff9c9d458.tar.gz opencode-d4cb47eadc515646f9f42679100a075ff9c9d458.zip | |
tui: add keyboard shortcuts to cycle through recently used models
Users can now press F2 to cycle forward and Shift+F2 to cycle backward through their recently used models, making it faster to switch between commonly used AI models without opening the model selection dialog.
Diffstat (limited to 'packages/desktop/src/context')
| -rw-r--r-- | packages/desktop/src/context/local.tsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/desktop/src/context/local.tsx b/packages/desktop/src/context/local.tsx index 4607a184c..2b844536d 100644 --- a/packages/desktop/src/context/local.tsx +++ b/packages/desktop/src/context/local.tsx @@ -162,10 +162,32 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ const recent = createMemo(() => store.recent.map(find).filter(Boolean)) + const cycle = (direction: 1 | -1) => { + const recentList = recent() + const current = currentModel() + if (!current) return + + const index = recentList.findIndex((x) => x?.provider.id === current.provider.id && x?.id === current.id) + if (index === -1) return + + let next = index + direction + if (next < 0) next = recentList.length - 1 + if (next >= recentList.length) next = 0 + + const val = recentList[next] + if (!val) return + + model.set({ + providerID: val.provider.id, + modelID: val.id, + }) + } + return { current: currentModel, recent, list, + cycle, set(model: ModelKey | undefined, options?: { recent?: boolean }) { batch(() => { setStore("model", agent.current().name, model ?? fallbackModel()) |
