diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index a82fb53ff..9f9aa99a1 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -641,13 +641,23 @@ that one keeps serving the agents and the Quit goes on). line. With nothing connected any more it quits without drawing. - A second Quit within a minute of the question (`quitNow`, `quitAgain`) quits, so a window that can't show the question doesn't trap the user. +- Don't ask again (zhujiu on Discord), a tick above the buttons, unticked + each time, goes with the Quit or Disconnect and quit chosen as + `noAsk=1`: the handler saves `settings.QuitNoAsk` (`SetQuitNoAsk`, that + field alone) before quitting, and a save that fails keeps magpie open. + Cancel saves nothing. With `QuitNoAsk` set, `quitAtOnce` quits without + asking; a settings file that can't be read asks. Settings › General › + Ask before quitting (`#quitAskRow`, the app's only) shows it as On/Off + and saves `quitNoAsk` through `POST /api/settings`, which keeps it when a + page doesn't send it. - Not asked: a restart to update, Uninstall, a browser's page (`magpie web`), logging out or shutting down, and the Dock's Quit (AppKit's `terminate:`). See `TestWindowQuitAsksFirst`, `TestQuitListsWiredAgents`, -`TestQuitAPIListsAgents`, `TestQuitNow`, `TestCommandQAsksFirst` and -`quit-ask.test.cjs`. +`TestQuitAPIListsAgents`, `TestQuitNow`, `TestCommandQAsksFirst`, +`TestQuitDontAskAgain`, `TestSetQuitNoAsk`, `TestQuitNoAskKeptUnlessSent`, +`quit-ask.test.cjs` and `quit-ask-setting.test.cjs`. ### A restart to update hands the gateway over diff --git a/internal/gui/api.go b/internal/gui/api.go index cad76dc65..1a6a09a40 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -2528,6 +2528,15 @@ func Handler(w Windows, gw *gateway.Server) http.Handler { case "main": w.ShowMain(mainView(r.URL.Query())) case "quit": + // the question's "Don't ask again" (noAsk=1, zhujiu on + // Discord) is saved before the quit; a save that fails keeps + // magpie open, saying why + if r.URL.Query().Get("noAsk") == "1" { + if err := settings.SetQuitNoAsk(true); err != nil { + fail(rw, err) + return + } + } // the user's Quit asks first while agents are connected // (quitask.go); the question's own Quit is now=1 if a, ok := w.(quitAsker); ok && r.URL.Query().Get("now") == "" { diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 03b7eb10a..545a49001 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -4674,6 +4674,7 @@ body.window .row + .row.agent.conn > .who { min-height: 41px; } /* the line abov .quit-ask .quit-agents li { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; } .quit-ask .quit-agents li > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .quit-ask .ag-note { grid-column: 1 / -1; margin: 0 0 10px; font-size: 12px; color: var(--muted); } +.quit-ask .quit-never { grid-column: 1 / -1; margin: 0 0 10px; font-size: 12px; } @media (max-width: 600px) { body.window .row.agent.conn { display: flex; } /* the name beside its logo; the link and the switch wrap under it when short of room */ diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 0dce76e95..86f6928d0 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -19711,7 +19711,7 @@ function renderSettings() { renderGatewayMode(s); // a browser tab has its own zoom, and magpie leaves it to it $("#textSizeRow").hidden = web; - // the keys that do it too, kept in the choices' tooltip, the row saying no more than its name + // the keys that do it too, in the choices' tooltip $("#textSizeSegs").title = t("Everything in magpie's windows, larger; {keys} too", { keys: textSizeKeys() }); $("#textSizeSegs").replaceChildren(segs(TEXT_SIZES.map((n) => [n, n + "%"]), s.textSize || 100, (n) => setTextSize(n))); $("#traySegs").replaceChildren(segs(TRAYS.map(([id, name]) => [id, t(name)]), s.tray || "panel", (tray) => savePrefs({ ...keep, tray }))); @@ -19725,16 +19725,18 @@ function renderSettings() { $("#lightweightRow").hidden = web; $("#lightweightSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.lightweight === true ? "on" : "off", (v) => savePrefs({ ...keep, lightweight: v === "on" }))); - // the display kept on too (#975): an agent recording the screen found it locked + // the display kept on too (#975) $("#keepAwakeSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")], ["display", t("Screen on too")]], !s.keepAwake ? "off" : s.keepAwakeDisplay ? "display" : "on", (v) => savePrefs({ ...keep, keepAwake: v !== "off", keepAwakeDisplay: v === "display" }))); - // its line says what the choice does; data-en keeps a language change on it + // its line says what it does; data-en keeps it on a language change const awakeSub = $("#keepAwakeRow .sub"); awakeSub.dataset.en = s.keepAwake && s.keepAwakeDisplay ? "Keeps this computer and its screen awake while magpie runs tasks" : "Keeps this computer awake while magpie runs tasks"; awakeSub.textContent = t(awakeSub.dataset.en); + // quitask.js's question + $("#quitAskSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.quitNoAsk ? "off" : "on", (v) => savePrefs({ ...keep, quitNoAsk: v === "off" }))); // WSL's distros, looked in on Windows unless turned off (#1264) $("#wslAgentsRow").hidden = !s.wsl; $("#wslAgentsSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.noWSLAgents ? "off" : "on", @@ -19749,8 +19751,7 @@ function renderSettings() { $("#loginSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.login ? "on" : "off", (v) => prefWrite(api("settings/login", { on: v === "on" })))); renderLoginAllow(s); - // Codex's and Claude Code's warm-ups and WorkBuddy's check-in, one tab - // each over one card, the rows' names not saying the service again. + // the warm-ups and check-in, one tab each over one card // A ChatGPT account's next window started as soon as the last resets $("#warmSegs").replaceChildren(segs([["off", t("Off")], ["week", t("Weekly")], ["all", t("Weekly and 5-hour")]], s.codexWarmup || "off", (v) => savePrefs({ ...keep, codexWarmup: v === "off" ? "" : v }))); @@ -22650,7 +22651,7 @@ function dockChoice(s) { // prefsKeep is what the settings page sends of s, all of it each time. function prefsKeep(s) { - return { theme: s.theme, colorblind: !!s.colorblind, reduceMotion: !!s.reduceMotion, noBird: !!s.noBird, lang: s.lang, tray: s.tray, dock: !!s.dock, dockWindow: !!s.dockWindow, dockNever: !!s.dockNever, lightweight: s.lightweight, keepAwake: !!s.keepAwake, keepAwakeDisplay: !!s.keepAwakeDisplay, noWSLAgents: !!s.noWSLAgents, proxy: s.proxy || "", + return { theme: s.theme, colorblind: !!s.colorblind, reduceMotion: !!s.reduceMotion, noBird: !!s.noBird, lang: s.lang, tray: s.tray, dock: !!s.dock, dockWindow: !!s.dockWindow, dockNever: !!s.dockNever, lightweight: s.lightweight, keepAwake: !!s.keepAwake, keepAwakeDisplay: !!s.keepAwakeDisplay, noWSLAgents: !!s.noWSLAgents, quitNoAsk: !!s.quitNoAsk, proxy: s.proxy || "", sessionTerminal: s.sessionTerminal || "", uiFont: s.uiFont || null, codeFont: s.codeFont || null, otel: s.otel || {}, diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 055058b97..199386d1e 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -617,6 +617,10 @@ const I18N = { "Closing the window keeps magpie running in the menu bar.": "关闭窗口时 magpie 会继续在菜单栏中运行。", "Closing the window keeps magpie running in the system tray.": "关闭窗口时 magpie 会继续在系统托盘中运行。", "Disconnect and quit": "断开并退出", + "Ask before quitting": "退出前询问", + "While agents go through magpie, Quit names them and asks first": "有 Agent 通过 magpie 连接时,退出前先列出它们并询问", + "Don't ask again": "不再提示", + "Settings › General › Ask before quitting turns it back on": "可在 设置 › 常规 › 退出前询问 里重新打开", "Puts back each agent's own settings first, so they work without magpie": "先恢复每个 Agent 自己的设置,让它们不经过 magpie 也能使用", "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "移除 magpie 写入 {agent} 配置的所有内容(接口地址、密钥、模型和推理强度),还原 {agent} 之前的设置。magpie 的供应商和账号不受影响。", "Disconnect": "断开", @@ -5033,6 +5037,10 @@ const I18N = { "Closing the window keeps magpie running in the menu bar.": "關閉視窗時 magpie 會繼續在選單列中執行。", "Closing the window keeps magpie running in the system tray.": "關閉視窗時 magpie 會繼續在系統匣中執行。", "Disconnect and quit": "斷開並退出", + "Ask before quitting": "退出前詢問", + "While agents go through magpie, Quit names them and asks first": "有 Agent 透過 magpie 連線時,退出前先列出它們並詢問", + "Don't ask again": "不再提示", + "Settings › General › Ask before quitting turns it back on": "可在 設定 › 常規 › 退出前詢問 裡重新開啟", "Puts back each agent's own settings first, so they work without magpie": "先還原每個 Agent 自己的設定,讓它們不經過 magpie 也能使用", "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "移除 magpie 寫入 {agent} 設定的所有內容(介面位址、金鑰、模型和推理強度),還原 {agent} 之前的設定。magpie 的供應商和帳號不受影響。", "Disconnect": "斷開", @@ -9414,6 +9422,10 @@ const I18N = { "Closing the window keeps magpie running in the menu bar.": "ウインドウを閉じても magpie はメニューバーで動作し続けます。", "Closing the window keeps magpie running in the system tray.": "ウインドウを閉じても magpie はシステムトレイで動作し続けます。", "Disconnect and quit": "切断して終了", + "Ask before quitting": "終了前に確認", + "While agents go through magpie, Quit names them and asks first": "エージェントが magpie を経由しているとき、終了前にそれらを示して確認します", + "Don't ask again": "今後は確認しない", + "Settings › General › Ask before quitting turns it back on": "設定 › 一般 › 終了前に確認 でもう一度オンにできます", "Puts back each agent's own settings first, so they work without magpie": "まず各エージェント自身の設定に戻し、magpie なしでも動作するようにします", "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "magpie は {agent} の設定に書き込んだ内容(エンドポイント、キー、モデル、推論レベル)をすべて削除し、{agent} を以前の設定に戻します。magpie のプロバイダとアカウントはそのままです。", "Disconnect": "切断", @@ -13813,6 +13825,10 @@ const I18N = { "Closing the window keeps magpie running in the menu bar.": "Wenn du das Fenster schließt, läuft magpie in der Menüleiste weiter.", "Closing the window keeps magpie running in the system tray.": "Wenn du das Fenster schließt, läuft magpie im Infobereich weiter.", "Disconnect and quit": "Trennen und beenden", + "Ask before quitting": "Vor dem Beenden fragen", + "While agents go through magpie, Quit names them and asks first": "Solange Agenten über magpie laufen, nennt Beenden sie und fragt zuerst nach", + "Don't ask again": "Nicht mehr fragen", + "Settings › General › Ask before quitting turns it back on": "Einstellungen › Allgemein › Vor dem Beenden fragen schaltet es wieder ein", "Puts back each agent's own settings first, so they work without magpie": "Stellt zuerst die eigenen Einstellungen jedes Agenten wieder her, damit er ohne magpie funktioniert", "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "magpie entfernt alles, was es in die Konfiguration von {agent} geschrieben hat — Endpunkt, Schlüssel, Modelle und Reasoning-Effort — und stellt die vorherigen Einstellungen von {agent} wieder her. Anbieter und Konten in magpie bleiben unverändert.", "Disconnect": "Trennen", diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index b969843d6..b8be41653 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -232,6 +232,10 @@
Open at login
+
+
Ask before quitting
While agents go through magpie, Quit names them and asks first
+
+