feat: switch model or agent and start new sessions

- chat: a searchable sheet picks the model or agent for the session; the
  choice is applied through the server and mirrored in the session list
- sessions: a new-session sheet with a title and a working directory
  (the server's default plus the directories already listed); creating
  one opens its chat
- ocapi: list models with their display names and read the server's
  default location
- bump version to 0.1.1 (build 2)
This commit is contained in:
blumia committed 2026-11-16 10:31:20 +08:00
1 parent 254d08b1bd
commit 23f72fc46d
9 files changed
+461 -42

No files matched your search

+32 -12
View File
@@ -149,28 +149,48 @@ func (c *Client) ListMessages(ctx context.Context, id string, o ListMessagesOpti
return page, err
}
// ModelSelection lists the models the server offers for a directory.
func (c *Client) Models(ctx context.Context, directory string) ([]ModelRef, error) {
// ModelInfo is one model the server offers.
type ModelInfo struct {
ID string `json:"id"`
ProviderID string `json:"providerID"`
Name string `json:"name"`
Variant string `json:"variant"`
}
// Models lists the models the server offers for a directory.
func (c *Client) Models(ctx context.Context, directory string) ([]ModelInfo, error) {
q := url.Values{}
if directory != "" {
q.Set("location[directory]", directory)
}
var payload struct {
Data []struct {
ID string `json:"id"`
ProviderID string `json:"providerID"`
Name string `json:"name"`
Variant string `json:"variant"`
} `json:"data"`
Data []ModelInfo `json:"data"`
}
if err := c.do(ctx, http.MethodGet, "/api/model", requestOptions{query: q}, nil, &payload); err != nil {
return nil, err
}
out := make([]ModelRef, 0, len(payload.Data))
for _, m := range payload.Data {
out = append(out, ModelRef{ID: m.ID, ProviderID: m.ProviderID, Variant: m.Variant})
return payload.Data, nil
}
// ServerLocation is the server's default working directory.
type ServerLocation struct {
Directory string `json:"directory"`
ProjectID string `json:"projectID"`
}
// Location reads the server's default location, which a new session uses
// when the user does not pick one.
func (c *Client) Location(ctx context.Context) (ServerLocation, error) {
var payload struct {
Directory string `json:"directory"`
Project struct {
ID string `json:"id"`
} `json:"project"`
}
return out, nil
if err := c.do(ctx, http.MethodGet, "/api/location", requestOptions{}, nil, &payload); err != nil {
return ServerLocation{}, err
}
return ServerLocation{Directory: payload.Directory, ProjectID: payload.Project.ID}, nil
}
// AgentInfo is one entry of GET /api/agent.