Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(web): signing out asks first (#724)

Yaowei Zheng0602e9dbbf96
diff --git a/changelog/unreleased/2026-09-14-logout-confirm.md b/changelog/unreleased/2026-09-14-logout-confirm.md
new file mode 100644
index 00000000..465904f1
--- /dev/null
+++ b/changelog/unreleased/2026-09-14-logout-confirm.md
@@ -0,0 +1,12 @@
+# Signing out asks first
+
+- **Date:** 2026-09-14
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#724](https://github.com/Prism-Shadow/penguin-harness/pull/724)
+
+[中文版](2026-09-14-logout-confirm.zh.md)
+
+## What changed
+
+- **Sign out** in the user menu now opens a confirmation before ending the session. The row sits in a menu of harmless entries, and one slip used to land the user on the login page; the dialog names what happens (the session here ends, running conversations keep going on the server) and Cancel keeps everything as it was.
diff --git a/changelog/unreleased/2026-09-14-logout-confirm.zh.md b/changelog/unreleased/2026-09-14-logout-confirm.zh.md
new file mode 100644
index 00000000..38a030ce
--- /dev/null
+++ b/changelog/unreleased/2026-09-14-logout-confirm.zh.md
@@ -0,0 +1,12 @@
+# 登出前先确认
+
+- **Date:** 2026-09-14
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#724](https://github.com/Prism-Shadow/penguin-harness/pull/724)
+
+[English](2026-09-14-logout-confirm.md)
+
+## 变更内容
+
+- 用户菜单里的**登出**现在会先弹出确认框再结束会话。这一行夹在一串无害的菜单项中间,此前手一滑就直接回到登录页;确认框写明会发生什么(本地会话结束,进行中的对话在服务端继续运行),取消则一切如旧。
diff --git a/packages/web/e2e/draft-user-scope.spec.mjs b/packages/web/e2e/draft-user-scope.spec.mjs
index b3f44de1..d9696bbd 100644
--- a/packages/web/e2e/draft-user-scope.spec.mjs
+++ b/packages/web/e2e/draft-user-scope.spec.mjs
@@ -59,9 +59,11 @@ test("switching accounts: B does not restore A's draft; both drafts coexist", as
// A logs out: the bottom-left user menu (the username button shares its name with the top
// Project switcher — the initial Project's display name defaults to the username — so take
- // the last match, which is the bottom user menu).
+ // the last match, which is the bottom user menu). The menu row only opens the confirmation;
+ // the dialog's own button, scoped to the dialog because both carry the same label, ends the session.
await page.getByRole("button", { name: UA }).last().click();
await page.getByRole("button", { name: "登出" }).click();
+ await page.getByRole("dialog").getByRole("button", { name: "登出" }).click();
await page.waitForURL(/\/login/);
// B logs in on the same browser, landing on the draft page for the shared Project.
diff --git a/packages/web/src/components/layout/user-menu.tsx b/packages/web/src/components/layout/user-menu.tsx
index dd7b1043..2a5c444b 100644
--- a/packages/web/src/components/layout/user-menu.tsx
+++ b/packages/web/src/components/layout/user-menu.tsx
@@ -20,6 +20,7 @@ import { useNavigate } from "react-router";
import { S } from "../../lib/strings";
import { ICON_GAP } from "../../lib/icon-scale";
import { useAuth } from "../../state/auth";
+import { ConfirmModal } from "../ui/confirm-modal";
import { Dropdown, menuItemClass } from "../ui/dropdown";
import { UserAvatar } from "../ui/user-avatar";
import type { DropdownPortal } from "../ui/dropdown";
@@ -52,6 +53,7 @@ export function UserMenu({
const { user, logout, desktopMode } = useAuth();
const [open, setOpen] = useState(false);
const [settingsOpen, setSettingsOpen] = useState(false);
+ const [confirmingLogout, setConfirmingLogout] = useState(false);
return (
<>
@@ -123,7 +125,7 @@ export function UserMenu({
className="block w-full px-3.5 py-2 text-left text-sm text-red-600 transition-colors duration-150 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40"
onClick={() => {
setOpen(false);
- void logout().then(() => navigate("/login"));
+ setConfirmingLogout(true);
}}
>
{S.auth.logout}
@@ -132,6 +134,21 @@ export function UserMenu({
</div>
</Dropdown>
<SettingsDialog open={settingsOpen} onClose={() => setSettingsOpen(false)} />
+ {/* Signing out is confirmed first: the row sits in a menu of harmless entries, and a
+ slip would end the session and land on the login page. Mounted beside the settings
+ dialog, outside the dropdown, so it outlives the menu that opened it. */}
+ <ConfirmModal
+ open={confirmingLogout}
+ title={S.auth.logoutConfirmTitle}
+ confirmLabel={S.auth.logout}
+ onClose={() => setConfirmingLogout(false)}
+ onConfirm={() => {
+ setConfirmingLogout(false);
+ void logout().then(() => navigate("/login"));
+ }}
+ >
+ <p className="text-sm text-gray-600 dark:text-gray-300">{S.auth.logoutConfirmBody}</p>
+ </ConfirmModal>
</>
);
}
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index d297d542..0534bdd5 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -428,6 +428,10 @@ export const en: Strings = {
hidePassword: "Hide password",
login: "Sign in",
logout: "Sign out",
+ /** The sign-out confirmation: dialog name and body. */
+ logoutConfirmTitle: "Sign out?",
+ logoutConfirmBody:
+ "This ends your session here and returns to the login page. Running conversations keep going on the server.",
admin: "Admin",
defaultAdminNote:
"First run: the server prints a first-login link in its startup output — open it to claim the built-in admin “admin” and set a password. No initial password exists to type here",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index bef48c03..bac32e3b 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -433,6 +433,9 @@ export const zh = {
hidePassword: "隐藏密码",
login: "登录",
logout: "登出",
+ /** The sign-out confirmation: dialog name and body. */
+ logoutConfirmTitle: "登出?",
+ logoutConfirmBody: "将退出当前账号并回到登录页;进行中的对话会在服务端继续运行。",
admin: "管理员",
defaultAdminNote:
"首次使用请打开服务端启动输出中的首次登录链接,认领内置管理员 admin 并设置密码。这里没有可输入的初始密码",
diff --git a/packages/web/test/account-menu.test.ts b/packages/web/test/account-menu.test.ts
index 5703f7b0..807cf50e 100644
--- a/packages/web/test/account-menu.test.ts
+++ b/packages/web/test/account-menu.test.ts
@@ -114,6 +114,22 @@ describe("the account menu", () => {
expect(source.slice(gate, signOut).match(/<\w/g)).toEqual(["<b"]);
});
+ it("confirms before signing out, from a dialog the closing menu cannot take with it", () => {
+ // The row opens the confirmation; only the dialog's Confirm ends the session. A direct
+ // logout() back on the row is the regression worth naming: sign-out sits in a menu of
+ // otherwise harmless entries, where one slip used to land on the login page.
+ const signOut = source.indexOf("S.auth.logout");
+ const row = source.slice(source.lastIndexOf("{!desktopMode && (", signOut), signOut);
+ expect(row).toContain("setConfirmingLogout(true)");
+ expect(row).not.toContain("logout()");
+ // And the dialog is mounted OUTSIDE the dropdown, the property the comment beside it
+ // claims: the panel's children unmount the moment the menu closes, and the row closes
+ // the menu as it opens the dialog — moved inside, the confirmation would never appear.
+ const menuEnd = source.indexOf("</Dropdown>");
+ expect(menuEnd).toBeGreaterThan(-1);
+ expect(source.indexOf("<ConfirmModal")).toBeGreaterThan(menuEnd);
+ });
+
it("reaches the settings it no longer holds through one ungated System settings entry", () => {
// The preference rows, change password and user management all moved into the settings
// dialog, whose own section registry decides which pages this viewer sees — so the row