From d4cb47eadc515646f9f42679100a075ff9c9d458 Mon Sep 17 00:00:00 2001
From: Dax Raad <d@ironbay.co>
Date: Fri, 31 Oct 2025 19:42:27 -0400
Subject: 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.
---
 packages/desktop/src/context/local.tsx | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'packages/desktop/src/context/local.tsx')

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())
-- 
cgit v1.2.3

