Show recorded OpenCode models in the chat list
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user