Show recorded OpenCode models in the chat list

This commit is contained in:
2026-11-05 13:42:01 +00:00
parent f5bf8ada8a
commit af178b83a1
7 changed files with 433 additions and 5 deletions
+15
View File
@@ -3,9 +3,11 @@ package server
import (
"context"
"errors"
"log"
"os"
"path/filepath"
"strings"
"time"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
@@ -61,6 +63,10 @@ func handleChatSessions(ctx context.Context, request protocol.Message, broker ch
present[session.ID] = session
}
}
// All optional model lookups share one budget, so a slow metadata endpoint
// cannot add one full timeout per row to the ordinary list request.
modelCtx, cancelModels := context.WithTimeout(ctx, 2*time.Second)
defer cancelModels()
for _, operator := range operatorSessions {
session, ok := present[operator.ID]
if !ok {
@@ -72,6 +78,15 @@ func handleChatSessions(ctx context.Context, request protocol.Message, broker ch
session.Directory = operator.Directory
session.Tag = operator.Tag
session.Backend = operator.Backend
if resolver, ok := broker.(chatSessionModelResolver); ok && session.Model == "" && modelCtx.Err() == nil {
resolved, err := resolver.ResolveSessionModel(modelCtx, session)
if err != nil {
// Metadata failure must not hide an otherwise usable chat.
log.Printf("chat model metadata %s: %v", session.ID, err)
} else {
session = resolved
}
}
session.CreatedAt = operator.CreatedAt
session.UpdatedAt = operator.UpdatedAt
// The closed state comes from the registry, so every client sees the same