summaryrefslogtreecommitdiff
path: root/tui.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-11-24 12:00:46 +0300
committerGrail Finder <wohilas@gmail.com>2025-11-24 12:00:46 +0300
commit8a62e987894dc6b0b083d23acfcfad9547fa1106 (patch)
tree91f2b3b866874815c162a5333e77e0b6f73f82a4 /tui.go
parent504af1a2132ca51f50ab24cd95f2690a4d45323e (diff)
Fix: apilinks rotation
Diffstat (limited to 'tui.go')
-rw-r--r--tui.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/tui.go b/tui.go
index 89c636e..714b710 100644
--- a/tui.go
+++ b/tui.go
@@ -764,13 +764,27 @@ func init() {
return nil
}
if event.Key() == tcell.KeyCtrlV {
- // switch between /chat and /completion api
- newAPI := cfg.APIMap[cfg.CurrentAPI]
- if newAPI == "" {
- // do not switch
+ // switch between API links using index-based rotation
+ if len(cfg.ApiLinks) == 0 {
+ // No API links to rotate through
return nil
}
- cfg.CurrentAPI = newAPI
+ // Find current API in the list to get the current index
+ currentIndex := -1
+ for i, api := range cfg.ApiLinks {
+ if api == cfg.CurrentAPI {
+ currentIndex = i
+ break
+ }
+ }
+ // If current API is not in the list, start from beginning
+ // Otherwise, advance to next API in the list (with wrap-around)
+ if currentIndex == -1 {
+ currentAPIIndex = 0
+ } else {
+ currentAPIIndex = (currentIndex + 1) % len(cfg.ApiLinks)
+ }
+ cfg.CurrentAPI = cfg.ApiLinks[currentAPIIndex]
choseChunkParser()
updateStatusLine()
return nil