diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index e888c278e..368553a95 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -2420,6 +2420,27 @@ hidden ones, read by `AutoVideomaker`, `videomakerObjects` and `mediaModels(true)`. A hidden one still makes its video when named: `bareVideomaker`, `videosCreate` and `arkFilms` read `Videomakers`. +Settings › Models › Images › Video generation (`#videoGenRow`, under +Image generation, gone while that is Off) picks the model a video +request that names none is made with, the Magpie Image MCP's +`generate_video` and `/v1/videos` alike (Discord #feedback: a custom +provider's model marked a video model by hand was made with only when +Automatic happened to take it). `settings.VideoGen` holds a +provider/model or a group ref; `videomaker` takes it while +`VideomakerMissingOf` finds it among its provider's `Videomakers` (on, +not decide-only; a group through `mediaGroupFirst`), and +`AutoVideomaker` otherwise. A save of a model that makes no videos is +refused (settingsapi), a save that doesn't send `videoGen` keeps it, and +a pick that stops making videos is `videoGenMissing`: the row says so +and Automatic makes them meanwhile. The list (`videoGenModels`) is every +`Videomakers` model of such providers, a hidden one only when it is the +pick. With none, the row says how to mark one (right-click in the +provider's Model settings, Makes › Video model; kept in sight). The +row is drawn by `videogen.js`, imported when Settings draws Image +generation, so it weighs nothing on the core. +`TestVideoGenPicksAMarkedModel`, `TestVideoGenCheckedAndKept`, +`TestVideoGenModelsListed`, `video-gen-pick.test.cjs`. + An Ark key's list marks its video and image models by `domain` (`VideoGeneration`, `ImageGeneration`) and `modalities.output_modalities`, with no `kind`; `catalog`'s live parse diff --git a/internal/gateway/video.go b/internal/gateway/video.go index 0d8170db8..1e1ab7355 100644 --- a/internal/gateway/video.go +++ b/internal/gateway/video.go @@ -260,16 +260,60 @@ func markedKey(p provider.Provider, by string) (provider.Provider, bool) { } // videomaker is the model a request that names none makes its video with: -// AutoVideomaker's, unless the Settings turned image generation off, which -// turns video off with it. None when it is off or no provider makes videos. +// the Settings' VideoGen while it resolves, else AutoVideomaker's, unless +// the Settings turned image generation off, which turns video off with +// it. None when it is off or no provider makes videos. func videomaker() (string, bool) { - if settings.Load().ImageGen == "off" { + st := settings.Load() + if st.ImageGen == "off" { return "", false } + if v := st.VideoGen; v != "" && VideomakerMissingOf(v) == "" { + return v, true + } m := AutoVideomaker() return m, m != "" } +// Videomaker is the model a request that names none makes its video with +// (videomaker), as provider/model: "" when it is off or none can. +func Videomaker() string { + m, _ := videomaker() + return m +} + +// VideomakerMissing is the model Settings › Images › Video generation +// names when magpie can't make videos with it any more, so that +// AutoVideomaker's makes them in its place, as DrawerMissing is Image +// generation's. "" when none is named or it resolves. +func VideomakerMissing() string { return VideomakerMissingOf(settings.Load().VideoGen) } + +// VideomakerMissingOf is v, a Video generation pick, when magpie can't +// make videos with it: its provider is gone, off or decide-only, or no +// longer has it among its Videomakers (a custom provider's model the user +// no longer marks a video model, #1399). A routing group resolves while +// one of its members makes videos. +func VideomakerMissingOf(v string) string { + if v == "" { + return "" + } + if provider.IsGroupRef(v) { + if _, _, ok := mediaGroupFirst(v, provider.KindVideo); ok { + return "" + } + return v + } + id, model, _ := strings.Cut(v, "/") + p, err := provider.Find(id) + if err != nil || !p.On() || p.DecideOnly() { + return v + } + if slices.ContainsFunc(Videomakers(*p), func(m catalog.Model) bool { return m.ID == model }) { + return "" + } + return v +} + // AutoVideomaker is the model a request that names none makes its video // with: the first model of the first provider that makes any. "" when none // can. A MiniMax API key's H3 comes after every other: it is paid by the diff --git a/internal/gateway/video_custom_test.go b/internal/gateway/video_custom_test.go index 57d7465d0..2ff65d7f4 100644 --- a/internal/gateway/video_custom_test.go +++ b/internal/gateway/video_custom_test.go @@ -434,3 +434,71 @@ func TestCustomProviderVideoKeepsTheCallersFields(t *testing.T) { t.Fatalf("sent %s", b) } } + +// Settings › Images › Video generation (the reporter's "custom providers +// still can't pick a video model"): a custom provider's model the user +// marked a video model, picked there, makes the video a request that names +// none gets, and is generate_video's default, though Automatic would take +// the provider's listed one. One no longer marked is said missing, and +// Automatic's makes the video in its place; Image generation's Off turns +// it off with the rest. +func TestVideoGenPicksAMarkedModel(t *testing.T) { + fresh(t) + up := newOpenAIVideos(t) + saveFetched(t, provider.Provider{ID: "studio", Name: "Studio", Chat: up.URL + "/v1", Key: "sk-studio", Models: []string{"gpt-5.5", "agnes-video-2.5-flash"}}) + const pick = "studio/agnes-video-2.5-flash" + if err := provider.SetModelKind(pick, provider.KindVideo); err != nil { + t.Fatal(err) + } + h := New().Handler() + made := func() string { + t.Helper() + n := len(up.bodies) + code, _, raw := asKey(t, h, "", "POST", "/v1/videos", `{"prompt":"waves on a rock"}`) + if code != 200 || len(up.bodies) != n+1 { + t.Fatalf("%d %s", code, raw) + } + var sent map[string]any + json.Unmarshal([]byte(up.bodies[n]), &sent) + return "studio/" + sent["model"].(string) + } + if a := AutoVideomaker(); a != "studio/vid-1" { + t.Fatalf("automatic %q", a) + } + if m := made(); m != "studio/vid-1" { + t.Fatalf("with none picked, made with %s", m) + } + + st := settings.Load() + st.VideoGen = pick + if err := settings.Save(st); err != nil { + t.Fatal(err) + } + if m := made(); m != pick { + t.Fatalf("picked %s, made with %s", pick, m) + } + if _, def := mediaModels(true); def != pick { + t.Fatalf("generate_video's default %q", def) + } + if v := VideomakerMissing(); v != "" { + t.Fatalf("a marked pick said missing: %q", v) + } + + if err := provider.SetModelKind(pick, ""); err != nil { + t.Fatal(err) + } + if v := VideomakerMissing(); v != pick { + t.Fatalf("unmarked, missing %q", v) + } + if m := made(); m != "studio/vid-1" { + t.Fatalf("a missing pick made with %s, not Automatic's", m) + } + + st.ImageGen = "off" + if err := settings.Save(st); err != nil { + t.Fatal(err) + } + if m, ok := videomaker(); ok || m != "" { + t.Fatalf("image generation off, videomaker %q", m) + } +} diff --git a/internal/gui/api.go b/internal/gui/api.go index d5793d5c2..761d08af2 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -488,6 +488,14 @@ type settingsJSON struct { // editor since (provider.HiddenDrawers): it still draws, and is // listed, as picked, with the row saying it is hidden ImageGenHidden bool `json:"imageGenHidden,omitempty"` + // the model a video request that names none is made with when + // VideoGen names none (gateway.AutoVideomaker), the VideoGen picked + // when magpie can't find it any more, and those that can be picked: + // each provider's video models, a custom provider's the user marked + // (#1399) among them, less those unticked in its editor + VideoGenAuto string `json:"videoGenAuto,omitempty"` + VideoGenMissing string `json:"videoGenMissing,omitempty"` + VideoGenModels []modelRef `json:"videoGenModels"` // the web search APIs a model's search goes to when no provider can // search (#419), their keys masked; the ones that can be added; and // the provider that searches first, if one does @@ -925,6 +933,19 @@ func settingsState() settingsJSON { s.ImageGenShown = v } s.ImageGenHidden = gateway.DrawerHidden(s.ImageGen) + s.VideoGenAuto, s.VideoGenModels, s.VideoGenMissing = gateway.AutoVideomaker(), []modelRef{}, gateway.VideomakerMissing() + for _, p := range provider.All() { + if !p.On() || p.DecideOnly() { + continue + } + // one unticked in its editor is left out, but the one picked here + for _, m := range gateway.Videomakers(p) { + if p.VideomakerHidden(m.ID) && s.VideoGen != p.ID+"/"+m.ID { + continue + } + s.VideoGenModels = append(s.VideoGenModels, modelRef{ID: p.ID + "/" + m.ID, Name: cmp.Or(m.Name, m.ID), Provider: p.ID, PName: p.Name, Icon: p.Icon}) + } + } // the Codex subagents row's warning: magpie's multi-agent V1 doesn't reach // Codex where its own multi_agent_v2 is on in the config magpie routes, and // magpie writes nothing there — the setting is the user's to turn off diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index aa89607d5..13323cb9f 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3897,7 +3897,7 @@ input.words.compact-num { flex: none; width: 76px; font-variant-numeric: tabular sends, who the allow list lets in), a line with a button or link in it. A touch screen, with no hover, keeps them all. */ @media (hover: hover) { - #view-settings:not(.set-searching) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) { + #view-settings:not(.set-searching) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .video-gen-how, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) { --hint: 1; position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } /* a row left with its name alone is as tall as any other: its control diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 8890e6cc6..fe429b19b 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -21571,6 +21571,13 @@ function renderImageGen(s, keep, box) { val.append(b); r.append(who, val); box.append(r); + // Video generation's row (#1399), drawn by videogen.js + if (v !== "off") { + const vr = el("div", "row pref"); + box.append(vr); + if (window.videoGenFill) videoGenFill(vr, s, keep); + else { vr.hidden = true; import("./videogen.js").then(() => videoGenFill(vr, s, keep), () => {}); } + } // how long a vendor is given to draw an image and send it: 5 minutes // unless set, as a slow image endpoint needs more (neighbads on X) box.append(waitRow("imageTimeoutRow", t("Image generation timeout"), t("How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer"), @@ -22671,7 +22678,7 @@ function prefsKeep(s) { codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly, replyModel: s.replyModel || "", noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudePrintMode: !!s.claudePrintMode, refusalRetries: s.refusalRetries ?? null, retryAfterCap: s.retryAfterCap ?? null, noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload, updateChannel: s.updateChannel || "", - trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd", + trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", videoGen: s.videoGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd", chineseUnits: !!s.chineseUnits, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0, resetReminder: s.resetReminder || 0, turnDoneAlert: s.turnDoneAlert || 0, maskAlert: !!s.maskAlert }; } diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 9f597368a..2adce787b 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -1119,6 +1119,12 @@ const I18N = { "{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "这里选的 {model} 已不可用:它的服务商被删除或关闭了,或者不再提供这个模型。也没有其他能生图的模型,所以没指定模型的请求会被拒绝。请在这里另选一个模型。", "images turned away": "带图的请求被拒绝", "Image generation": "生图模型", + "Video generation": "视频生成", + "To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "右键点服务商「模型设置」里的模型,选「类型:视频模型」,就能用它生成视频", + "no model that makes videos": "没有能生成视频的模型", + "The model Magpie Image makes videos with": "Magpie Image 生成视频用的模型", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "这里选的 {model} 已不能生成视频:它的服务商被删除或关闭了,或者这个模型不再标记为视频模型。现在由自动选择的 {auto} 代为生成视频。请在这里另选一个模型。", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "这里选的 {model} 已不能生成视频:它的服务商被删除或关闭了,或者这个模型不再标记为视频模型。也没有其他能生成视频的模型。请在这里另选一个模型。", "Intent classifier timeout": "意图判断超时", "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由组的意图判断模型判断这一轮属于哪种意图可用的时间。这一轮要等它判断完才会发出,超过则不等它的回答直接继续。较慢的判断模型可能需要更长时间", "Image generation timeout": "生图超时", @@ -5870,6 +5876,12 @@ const I18N = { "{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "這裡選的 {model} 已無法使用:它的服務商被刪除或關閉了,或者不再提供這個模型。也沒有其他能生圖的模型,所以沒指定模型的請求會被拒絕。請在這裡另選一個模型。", "images turned away": "帶圖的請求被拒絕", "Image generation": "生圖模型", + "Video generation": "影片生成", + "To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "在服務商「模型設定」裡的模型上按右鍵,選「類型:影片模型」,就能用它生成影片", + "no model that makes videos": "沒有能生成影片的模型", + "The model Magpie Image makes videos with": "Magpie Image 生成影片用的模型", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "這裡選的 {model} 已無法生成影片:它的服務商被刪除或關閉了,或者這個模型不再標記為影片模型。現在由自動選擇的 {auto} 代為生成影片。請在這裡另選一個模型。", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "這裡選的 {model} 已無法生成影片:它的服務商被刪除或關閉了,或者這個模型不再標記為影片模型。也沒有其他能生成影片的模型。請在這裡另選一個模型。", "Intent classifier timeout": "意圖判斷逾時", "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由組的意圖判斷模型判斷這一輪屬於哪種意圖可用的時間。這一輪要等它判斷完才會送出,超過則不等它的回答直接繼續。較慢的判斷模型可能需要更長時間", "Image generation timeout": "生圖逾時", @@ -10592,6 +10604,12 @@ const I18N = { "{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "ここで選んだ {model} は使えなくなっています。プロバイダーが削除またはオフにされたか、このモデルがなくなりました。画像を生成できるモデルが他にないため、モデルを指定しないリクエストは拒否されます。ここで別のモデルを選んでください。", "images turned away": "画像付きリクエストは拒否", "Image generation": "画像生成", + "Video generation": "動画生成", + "To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "プロバイダーの「モデル設定」でモデルを右クリックし、「種類:動画モデル」を選ぶと、そのモデルで動画を生成できます", + "no model that makes videos": "動画を生成できるモデルがありません", + "The model Magpie Image makes videos with": "Magpie Image が動画の生成に使うモデル", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "ここで選んだ {model} は動画を生成できなくなっています。プロバイダーが削除またはオフにされたか、このモデルが動画モデルとしてマークされなくなりました。代わりに自動で選ばれた {auto} が動画を生成しています。ここで別のモデルを選んでください。", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "ここで選んだ {model} は動画を生成できなくなっています。プロバイダーが削除またはオフにされたか、このモデルが動画モデルとしてマークされなくなりました。動画を生成できるモデルが他にありません。ここで別のモデルを選んでください。", "Intent classifier timeout": "インテント判定のタイムアウト", "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "ルーティンググループの分類モデルが、このターンがどのインテントかを答えるまで待つ時間。ターンは答えを待ってから送られ、過ぎると答えなしで進みます。遅い分類モデルではもっと長く必要なことがあります", "Image generation timeout": "画像生成のタイムアウト", @@ -15329,6 +15347,12 @@ const I18N = { "{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "{model}, hier gewählt, ist nicht mehr eingerichtet: Sein Anbieter wurde entfernt oder ausgeschaltet, oder er hat das Modell nicht mehr. Kein anderes Modell erzeugt Bilder, daher wird eine Anfrage ohne Modell abgewiesen. Wähle hier ein anderes Modell.", "images turned away": "Bilder werden abgelehnt", "Image generation": "Bilderzeugung", + "Video generation": "Videoerzeugung", + "To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "Um mit einem Modell eines Anbieters Videos zu erzeugen, klicke es in den Modelleinstellungen des Anbieters mit rechts an und wähle Erzeugt › Videomodell", + "no model that makes videos": "kein Modell zur Videoerzeugung", + "The model Magpie Image makes videos with": "Das Modell, mit dem Magpie Image Videos erzeugt", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "{model}, hier gewählt, erzeugt keine Videos mehr: Sein Anbieter wurde entfernt oder ausgeschaltet, oder das Modell ist nicht mehr als Videomodell markiert. {auto}, die automatische Wahl, erzeugt die Videos an seiner Stelle. Wähle hier ein anderes Modell.", + "{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "{model}, hier gewählt, erzeugt keine Videos mehr: Sein Anbieter wurde entfernt oder ausgeschaltet, oder das Modell ist nicht mehr als Videomodell markiert. Kein anderes Modell erzeugt Videos. Wähle hier ein anderes Modell.", "Intent classifier timeout": "Zeitlimit für den Absicht-Klassifikator", "How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "Wie lange der Klassifikator einer Routing-Gruppe Zeit hat zu sagen, welche Absicht eine Runde hat. Die Runde wartet darauf, bevor sie irgendwohin geht, und danach geht sie ohne seine Antwort weiter. Ein langsamer Klassifikator braucht vielleicht länger", "Image generation timeout": "Zeitlimit für Bilderzeugung", diff --git a/internal/gui/assets/videogen.js b/internal/gui/assets/videogen.js new file mode 100644 index 000000000..b9ab3a0e6 --- /dev/null +++ b/internal/gui/assets/videogen.js @@ -0,0 +1,37 @@ +// Settings › Models › Images' Video generation: the model a video request +// that names none is made with, generate_video's — the one magpie picks or +// one named. A custom provider's model makes videos once marked so in its +// Model settings (#1399), which the row says while no model makes any. +// Image generation's Off turns it off too. app.js imports this when +// Settings draws Image generation, so it weighs nothing on the core. + +// videoGenFill draws the row into r +window.videoGenFill = function (r, s, keep) { + const models = s.videoGenModels || []; + const v = s.videoGen || ""; + const named = namedIn(models); + const icOf = (id) => models.find((x) => x.id === id)?.icon; + const gone = v && v === s.videoGenMissing; + r.id = "videoGenRow"; + r.hidden = false; + const who = el("div", "who"); + who.append(el("div", "name", t("Video generation")), el("div", "sub wraps", t("The model Magpie Image makes videos with"))); + if (!models.length && !v) who.append(el("div", "sub wraps video-gen-how", t("To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes › Video model"))); + if (gone) who.append(el("div", "sub err video-gen-missing", s.videoGenAuto + ? t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.", { model: v, auto: named(s.videoGenAuto) }) + : t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.", { model: v }))); + const b = el("button", "rt-cond on"); + if (gone) b.append(icon("generic"), el("span", "", v + " · " + t("missing"))); + else if (v) b.append(icon(icOf(v) || "generic"), el("span", "", named(v))); + else { + if (s.videoGenAuto) b.append(icon(icOf(s.videoGenAuto) || "generic")); + b.append(el("span", "", s.videoGenAuto ? t("Automatic") + " · " + named(s.videoGenAuto) : t("Automatic") + " · " + t("no model that makes videos"))); + } + b.onclick = (ev) => openPicker({ id: "", name: "", fields: [] }, { key: "videoGen", label: "model", value: v, options: [ + { value: "", label: t("Automatic"), note: s.videoGenAuto ? named(s.videoGenAuto) : t("no model that makes videos"), reset: true }, + ...models.map((x) => ({ value: x.id, label: x.name || x.id, note: x.providerName, icon: x.icon, group: x.providerName, ref: x.id }))], + onPick: (id) => { if (id !== v) savePrefs({ ...keep, videoGen: id }); } }, b, ev); + const val = el("div", "val"); + val.append(b); + r.append(who, val); +}; diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 2922a7cd4..849282e77 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -16,7 +16,7 @@ import ( // raises them and says why in its commit. const ( appScriptBudget = 1_316_874 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30); 1,317,705 with a Claude account added from a setup-token (sfss5362 on X): the sign-in's Use a setup-token instead…, its sheet, and its account row's magpie only, the provider editor's account rows, the core's own editor, its comments cut down, with no room added (10-30); back to 1,315,316 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, loaded when one is asked for (signAsk, 10-30); 1,315,479 with the provider editor lining its Advanced up with its fields (the owner: 高级这个折叠按钮为什么在一个前不着村后不着店的位置?) and a refresh on each of its accounts (在这里也要加上手动刷新用量的按钮), the core's own editor, with no room added (10-31); 1,315,603 with About's Log row, the path of the log the app writes and an Open for its folder (rayem1w on X), in app.js, its comment cut to one line, with no room added (10-31); 1,316,781 with a provider's model listed by an id of the user's (zeewell on X), the provider editor's Names & levels Listed as box beside Same as, the core's own editor, with no room added (10-31); 1,316,874 with a package manager's magpie (the AUR's magpie-bin) naming the command that updates it in Settings' Version row and lighting no Update pill (shuhai on Discord), the core's own update row, which the tray panel reads too, its comments cut to one line, with no room added (10-31); Settings › Sync's Kept on this computer row (hayden4608 on Discord) raised it to 1,317,497, which is no bound; the 1,316,874 it had came back once later trims left app.js at 1,308,363 (10-31) - coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09) + coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09) ) func TestCoreScriptBudget(t *testing.T) { diff --git a/internal/gui/tests/old-webkit.test.cjs b/internal/gui/tests/old-webkit.test.cjs index 0f224b2ba..be5f01427 100644 --- a/internal/gui/tests/old-webkit.test.cjs +++ b/internal/gui/tests/old-webkit.test.cjs @@ -161,9 +161,10 @@ test("compat.js is the first of the page's own scripts", async () => { // with no Balance URL, passerrors.js when it draws a key provider's // Errors, keybalance.js when it draws a key whose vendor tells no // balance, modellimits.js when it draws a model's row, notices.js when - // About's Open-source licenses opens; the checks above + // About's Open-source licenses opens, videogen.js when Settings draws + // Image generation; the checks above // still read them - for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); + for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); }); test("the styles hold up in Safari 15.0", async () => { diff --git a/internal/gui/tests/video-gen-pick.test.cjs b/internal/gui/tests/video-gen-pick.test.cjs new file mode 100644 index 000000000..17e86c6b1 --- /dev/null +++ b/internal/gui/tests/video-gen-pick.test.cjs @@ -0,0 +1,182 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Discord #feedback: "自定义的供应商还是不能选视频模型". A custom +// provider's model marked a video model (right-click in its Model settings, +// Makes › Video model) made videos only when magpie happened to pick it: +// Magpie Image's video generation had no setting, Automatic took the first +// provider's. Settings › Models › Images now has a Video generation row, +// beside Image generation: Automatic names its pick, the picker lists every +// model that makes videos by provider, picking one saves videoGen, a pick +// that no longer makes videos says so, and with none at all the row says +// how to mark one (in sight: it is the way there). Image generation off +// takes the row away. Every language; wide and at a phone's width; no +// backend, the API is faked here. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); + +function settingsPayload(lang, over) { + return { + theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", textSize: 100, + dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [], + codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false, + trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "", + version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425", + proxyNow: "none", proxySource: "none", login: false, + visionModels: [], workbuddyCheckins: [], lanURLs: [], + imageGenAuto: "openai/gpt-image-2", + imageGenModels: [{ id: "openai/gpt-image-2", name: "gpt-image-2", provider: "openai", providerName: "OpenAI", icon: "openai" }], + videoGen: "", + videoGenAuto: "grok/grok-imagine-video", + videoGenModels: [ + { id: "grok/grok-imagine-video", name: "Grok Imagine Video", provider: "grok", providerName: "Grok", icon: "grok" }, + { id: "studio/kling-v3", name: "kling-v3", provider: "studio", providerName: "Studio", icon: "" }, + ], + fx: { rate: 7.2, at: new Date().toISOString(), stale: false }, + ...over, + }; +} + +function server(lang, cur, posted) { + return async (route) => { + const req = route.request(), url = new URL(req.url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true,textSize:100};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 }, fx: cur.fx }); + if (url.pathname === "/api/settings") { + if (req.method() === "POST") { + const body = JSON.parse(req.postData() || "{}"); + posted.push(body); + Object.assign(cur, body); + } + return json(cur); + } + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/usage/quotas") return json([]); + if (url.pathname === "/api/groups") return json({ groups: [], models: [] }); + if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + const body = await fs.readFile(file).catch(() => null); + await (body ? route.fulfill({ body, contentType }) : route.fulfill({ status: 404, body: "" })); + }; +} + +const want = { + en: { name: "Video generation", auto: "Automatic", how: /^To make videos with a provider's model, right-click it/, none: "no model that makes videos", missing: "missing", gone: /^studio\/kling-v3, picked here, no longer makes videos/ }, + zh: { name: "视频生成", auto: "自动", how: /类型:视频模型/, none: "没有能生成视频的模型", missing: "已失效", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ }, + "zh-TW": { name: "影片生成", auto: "自動", how: /類型:影片模型/, none: "沒有能生成影片的模型", missing: "已失效", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ }, + ja: { name: "動画生成", auto: "自動", how: /種類:動画モデル/, none: "動画を生成できるモデルがありません", missing: "見つかりません", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ }, + de: { name: "Videoerzeugung", auto: "Automatisch", how: /Videomodell/, none: "kein Modell zur Videoerzeugung", missing: "fehlt", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ }, +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": Settings picks the model Magpie Image makes videos with", async (t) => { + assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit"); + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const shots = []; + t.after(async () => { + if (process.env.ARTIFACT_DIR) { + await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); + for (const [name, buf] of shots) await fs.writeFile(path.join(process.env.ARTIFACT_DIR, `${engine}-video-gen-pick-${name}.png`), buf); + } + await browser.close(); + }); + const open = async (lang, cur, width, posted) => { + const context = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" }); + const page = await context.newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + page.errors = []; + page.on("pageerror", (e) => page.errors.push(e.message)); + await page.route("**/*", server(lang, cur, posted)); + await page.goto("http://magpie.test/?view=settings&tab=models"); + await page.locator("#imagesList .row").nth(1).waitFor(); + return page; + }; + const click = async (page, loc) => { + const b = await loc.boundingBox(); + await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2); + }; + const fits = (page) => page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); + for (const lang of Object.keys(want)) { + const w = want[lang]; + for (const width of lang === "en" || lang === "zh" ? [1100, 400] : [1100]) { + await t.test(`${lang} at ${width}px: Automatic names its pick, and a custom provider's video model is picked`, async () => { + const posted = []; + const page = await open(lang, settingsPayload(lang, {}), width, posted); + const row = page.locator("#imagesList #videoGenRow"); + await row.waitFor(); + assert.equal((await row.locator(".name").textContent()).trim(), w.name); + const button = row.locator("button.rt-cond"); + assert.equal((await button.textContent()).trim(), `${w.auto} · Grok Imagine Video · Grok`); + assert.equal(await row.locator(".video-gen-how").count(), 0, "no how-to while a model makes videos"); + assert.equal(await row.locator(".video-gen-missing").count(), 0); + assert.equal(await fits(page), 0, "no sideways scroll"); + shots.push([`${lang}-${width}`, await page.screenshot({ fullPage: true })]); + + await click(page, button); + await page.locator("#pop").waitFor({ state: "visible" }); + const items = await page.locator("#list li:not(.group)").allInnerTexts(); + assert.equal(items.length, 3, items.join(" | ")); + assert(items[0].startsWith(w.auto), items[0]); + assert(items.some((x) => x.includes("kling-v3") && x.includes("Studio")), items.join(" | ")); + assert(items.some((x) => x.includes("Grok Imagine Video") && x.includes("Grok")), items.join(" | ")); + await click(page, page.locator("#list li:not(.group)", { hasText: "kling-v3" })); + await page.waitForFunction(() => document.querySelector("#videoGenRow button.rt-cond")?.textContent.includes("kling-v3")); + assert.equal(posted.length, 1, JSON.stringify(posted)); + assert.equal(posted[0].videoGen, "studio/kling-v3"); + assert.equal((await page.locator("#videoGenRow button.rt-cond").textContent()).trim(), "kling-v3 · Studio"); + // picking Automatic again clears it + await click(page, page.locator("#videoGenRow button.rt-cond")); + await page.locator("#pop").waitFor({ state: "visible" }); + assert((await page.locator("#list li.cur").innerText()).includes("kling-v3")); + await click(page, page.locator("#list li:not(.group):not(.cur)", { hasText: w.auto })); + await page.waitForFunction(() => !document.querySelector("#videoGenRow button.rt-cond")?.textContent.includes("kling-v3")); + assert.equal(posted.at(-1).videoGen, ""); + assert.deepEqual(page.errors, []); + await page.context().close(); + }); + await t.test(`${lang} at ${width}px: a pick that no longer makes videos says so; none at all says how to mark one`, async () => { + const posted = []; + let page = await open(lang, settingsPayload(lang, { videoGen: "studio/kling-v3", videoGenMissing: "studio/kling-v3", + videoGenModels: [{ id: "grok/grok-imagine-video", name: "Grok Imagine Video", provider: "grok", providerName: "Grok", icon: "grok" }] }), width, posted); + let row = page.locator("#videoGenRow"); + await row.waitFor(); + assert.equal((await row.locator("button.rt-cond").textContent()).trim(), `studio/kling-v3 · ${w.missing}`); + const gone = row.locator(".video-gen-missing"); + assert.match((await gone.textContent()).trim(), w.gone); + assert.equal(await gone.isVisible(), true, "the error is in sight"); + assert.equal(await fits(page), 0); + await page.context().close(); + + page = await open(lang, settingsPayload(lang, { videoGenAuto: "", videoGenModels: [] }), width, posted); + row = page.locator("#videoGenRow"); + await row.waitFor(); + assert.equal((await row.locator("button.rt-cond").textContent()).trim(), `${w.auto} · ${w.none}`); + const how = row.locator(".video-gen-how"); + assert.match((await how.textContent()).trim(), w.how); + assert.equal(await how.evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "", "the way to a video model shows at rest"); + assert.equal(await how.isVisible(), true); + assert.equal(await fits(page), 0); + shots.push([`${lang}-${width}-none`, await page.screenshot({ fullPage: true })]); + assert.deepEqual(posted, []); + assert.deepEqual(page.errors, []); + await page.context().close(); + }); + } + } + await t.test("Image generation off takes the row away", async () => { + const page = await open("en", settingsPayload("en", { imageGen: "off" }), 1100, []); + await page.locator("#imagesList .row").nth(1).waitFor(); + assert.equal(await page.locator("#videoGenRow").count(), 0); + assert.deepEqual(page.errors, []); + await page.context().close(); + }); + }); +} diff --git a/internal/gui/video_gen_test.go b/internal/gui/video_gen_test.go new file mode 100644 index 000000000..87ab89c4c --- /dev/null +++ b/internal/gui/video_gen_test.go @@ -0,0 +1,73 @@ +package gui + +import ( + "os" + "slices" + "testing" + + "github.com/yetone/magpie/internal/provider" + "github.com/yetone/magpie/internal/settings" +) + +// Settings › Images › Video generation lists a custom provider's model the +// user marked a video model (#1399), and none of its others; one unticked +// in its editor is left out unless it is the one picked; a pick no longer +// marked is said missing, with Automatic's named. +func TestVideoGenModelsListed(t *testing.T) { + t.Setenv("HOME", t.TempDir()) + t.Setenv("USERPROFILE", os.Getenv("HOME")) + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + t.Setenv("XDG_CACHE_HOME", t.TempDir()) + if err := provider.Save(provider.Provider{ID: "studio", Name: "Studio", Chat: "https://studio.example/v1", Key: "sk-s", Models: []string{"chat-1", "seedance-x", "kling-y"}}); err != nil { + t.Fatal(err) + } + for _, ref := range []string{"studio/seedance-x", "studio/kling-y"} { + if err := provider.SetModelKind(ref, provider.KindVideo); err != nil { + t.Fatal(err) + } + } + listed := func() (ids []string) { + for _, m := range settingsState().VideoGenModels { + if m.Provider == "studio" { + ids = append(ids, m.ID) + } + } + slices.Sort(ids) + return + } + if got := listed(); !slices.Equal(got, []string{"studio/kling-y", "studio/seedance-x"}) { + t.Fatalf("listed %v", got) + } + if a := settingsState().VideoGenAuto; a == "" { + t.Fatal("no automatic video model") + } + + p, _ := provider.Find("studio") + q := *p + q.HiddenVideomakers = []string{"kling-y"} + if err := provider.Save(q); err != nil { + t.Fatal(err) + } + if got := listed(); !slices.Equal(got, []string{"studio/seedance-x"}) { + t.Fatalf("an unticked one is listed: %v", got) + } + st := settings.Load() + st.VideoGen = "studio/kling-y" + if err := settings.Save(st); err != nil { + t.Fatal(err) + } + if got := listed(); !slices.Equal(got, []string{"studio/kling-y", "studio/seedance-x"}) { + t.Fatalf("the unticked pick isn't listed: %v", got) + } + if m := settingsState().VideoGenMissing; m != "" { + t.Fatalf("a marked pick said missing: %q", m) + } + + if err := provider.SetModelKind("studio/kling-y", ""); err != nil { + t.Fatal(err) + } + s := settingsState() + if s.VideoGenMissing != "studio/kling-y" || s.VideoGenAuto != "studio/seedance-x" { + t.Fatalf("unmarked pick: missing %q, automatic %q", s.VideoGenMissing, s.VideoGenAuto) + } +} diff --git a/internal/settings/settings.go b/internal/settings/settings.go index 54257591c..d1a4bc341 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -500,6 +500,11 @@ type Settings struct { // "off" turns the video a request that names no model gets off too // (gateway.videomaker). ImageGen string `json:"imageGen,omitempty"` + // VideoGen is the model a video request that names none is made with + // (generate_video, the gateway's /v1/videos): a model's id, or empty + // for one magpie picks (gateway.videomaker). ImageGen's "off" turns it + // off too. + VideoGen string `json:"videoGen,omitempty"` // ImageTimeout is how long, in minutes, a vendor is given to draw an // image and send it (neighbads on X: a slow image endpoint needs more // than 5): from 1 to ImageTimeoutMost, 0 for ImageTimeoutDefault. @@ -2299,6 +2304,10 @@ func saveOwn(s Settings, recording, reads bool) error { if s.ImageGen != "" && s.ImageGen != "off" && !strings.Contains(s.ImageGen, "/") { return fmt.Errorf("the image generation model must be a model's id such as openai/gpt-image-2, or off, not %q", s.ImageGen) } + s.VideoGen = strings.TrimSpace(s.VideoGen) + if s.VideoGen != "" && !strings.Contains(s.VideoGen, "/") { + return fmt.Errorf("the video generation model must be a model's id such as grok/grok-imagine-video, not %q", s.VideoGen) + } rules, err := redact.CheckRules(s.RedactRules) if err != nil { return err diff --git a/internal/settingsapi/settingsapi.go b/internal/settingsapi/settingsapi.go index 2f5d3a517..5fb54a7fe 100644 --- a/internal/settingsapi/settingsapi.go +++ b/internal/settingsapi/settingsapi.go @@ -46,7 +46,7 @@ var Keys = []string{ "workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin", // models: replies, vision, images, search "replyModel", "noLoopGuard", "claudeLeanPrompt", "claudePrintMode", "refusalRetries", "retryAfterCap", - "vision", "visionEffort", "imageGen", "imageTimeout", "classifyTimeout", + "vision", "visionEffort", "imageGen", "videoGen", "imageTimeout", "classifyTimeout", // what every routing group does that says nothing of its own "groupSink", "groupFirstToken", "groupPatience", "searcher", "searcherThen", "searcherEffort", "searchFirst", @@ -206,6 +206,10 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err in.RedactShape = cur.RedactShape } // nor how long an image is given to be drawn + // nor the video model, picked in its own row + if _, sent := fields["videoGen"]; !sent { + in.VideoGen = cur.VideoGen + } if _, sent := fields["imageTimeout"]; !sent { in.ImageTimeout = cur.ImageTimeout } @@ -385,6 +389,9 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err return in, fmt.Errorf("no model %s to generate images", v) } } + if v := strings.TrimSpace(in.VideoGen); v != "" && v != cur.VideoGen && gateway.VideomakerMissingOf(v) != "" { + return in, fmt.Errorf("no model %s to make videos", v) + } // the searchers after the one named, set in their own row: a save // that doesn't send them (prefsKeep has none) keeps them, and an // empty list clears them diff --git a/internal/settingsapi/settingsapi_test.go b/internal/settingsapi/settingsapi_test.go index 35bd202e4..34a802c2b 100644 --- a/internal/settingsapi/settingsapi_test.go +++ b/internal/settingsapi/settingsapi_test.go @@ -10,6 +10,7 @@ import ( "strings" "testing" + "github.com/yetone/magpie/internal/provider" "github.com/yetone/magpie/internal/settings" "github.com/yetone/magpie/internal/testenv" ) @@ -36,6 +37,8 @@ func sample(t reflect.Type, key string, was reflect.Value) reflect.Value { switch key { case "vision", "imageGen", "searcher", "searcherThen": s = "off" // a model is checked against the catalog + case "videoGen": + s = "studio/clip-1" // a video model, videoModel's } for _, c := range Choices[key] { if c != was.String() { @@ -78,6 +81,8 @@ func sample(t reflect.Type, key string, was reflect.Value) reflect.Value { // fails here, and so `magpie settings` can't fall behind the window // (#4745). func TestKeysAreWhatTheSaveWrites(t *testing.T) { + home(t) + videoModel(t) cur := settings.Defaults() curJSON, err := json.Marshal(cur) if err != nil { @@ -127,6 +132,46 @@ func TestKeysAreWhatTheSaveWrites(t *testing.T) { } } +// videoModel sets up a provider whose clip-1 the user marked a video +// model (#1399), so studio/clip-1 is one videoGen can name. +func videoModel(t *testing.T) { + t.Helper() + if err := provider.Save(provider.Provider{ID: "studio", Name: "Studio", Chat: "https://studio.example/v1", Key: "sk-studio", Models: []string{"chat-1", "clip-1"}}); err != nil { + t.Fatal(err) + } + if err := provider.SetModelKind("studio/clip-1", provider.KindVideo); err != nil { + t.Fatal(err) + } +} + +// Settings › Images' video model: a model that makes videos is saved, one +// that doesn't (a chat model, or none such) is refused, and a save from +// another row, which doesn't send it, keeps it. +func TestVideoGenCheckedAndKept(t *testing.T) { + home(t) + videoModel(t) + for _, bad := range []string{"studio/chat-1", "studio/nope", "clip-1"} { + if _, _, err := Apply([]byte(`{"videoGen":"`+bad+`"}`), false); err == nil { + t.Errorf("%s was taken as a video model", bad) + } + } + if _, _, err := Apply([]byte(`{"videoGen":"studio/clip-1"}`), false); err != nil { + t.Fatal(err) + } + if _, _, err := Apply([]byte(`{"theme":"dark"}`), false); err != nil { + t.Fatal(err) + } + if got := settings.Load().VideoGen; got != "studio/clip-1" { + t.Fatalf("videoGen %q after another row's save", got) + } + if _, _, err := Apply([]byte(`{"videoGen":""}`), false); err != nil { + t.Fatal(err) + } + if got := settings.Load().VideoGen; got != "" { + t.Fatalf("Automatic left videoGen %q", got) + } +} + func minus(a, b []string) []string { var out []string for _, k := range a {