feat: poll only the current session's llama-server

This commit is contained in:
Troed Sångberg
2026-08-21 13:54:39 +02:00
parent 1748c93cc4
commit 194711e206
+6 -2
View File
@@ -2,7 +2,7 @@
import type { TextRenderable } from "@opentui/core"
import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
import { onCleanup } from "solid-js"
import { backoffDelayMs, processPoll, resolveServerUrls } from "./src/stats.ts"
import { backoffDelayMs, processPoll, resolveServerUrls, selectSessionUrls } from "./src/stats.ts"
type StreamSample = {
at: number
@@ -184,6 +184,7 @@ const tui: TuiPlugin = async (api, options) => {
if (!llamaServerUrls.length) return
let model = llamaServerModel
let sessionProviderId: string | undefined
if (!model) {
const routeSessionID = api.route.current.params?.sessionID
if (routeSessionID) {
@@ -191,10 +192,13 @@ const tui: TuiPlugin = async (api, options) => {
if (session?.model?.id) {
model = session.model.id
}
sessionProviderId = session?.model?.providerID
}
}
for (const baseUrl of llamaServerUrls) {
const activeUrls = selectSessionUrls(llamaServerUrls, api.state.provider, sessionProviderId)
if (!activeUrls.length) return
for (const baseUrl of activeUrls) {
const now = Date.now()
const backoff = backoffByUrl.get(baseUrl)
if (backoff && now < backoff.nextRetryAt) {