Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

feat(onboarding): show the tour once to every user, then the update summary

Jasona3cad14cd7a8
diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs
index abfc1f6a5..ee7a4ad27 100644
--- a/src-tauri/src/settings.rs
+++ b/src-tauri/src/settings.rs
@@ -636,6 +636,11 @@ pub struct AppSettings {
/// User has confirmed the first-run welcome notice
#[serde(default, skip_serializing_if = "Option::is_none")]
pub first_run_notice_confirmed: Option<bool>,
+ /// User has finished or skipped the onboarding tour. Separate from
+ /// `first_run_notice_confirmed` so users who dismissed the old welcome
+ /// dialog still get the tour once.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub onboarding_tour_seen: Option<bool>,
/// User has confirmed the one-time "new layout" dialog shown to upgrading users
#[serde(default, skip_serializing_if = "Option::is_none")]
pub new_layout_notice_confirmed: Option<bool>,
@@ -832,6 +837,7 @@ impl Default for AppSettings {
codex_stack_auto_review_model: None,
failover_confirmed: None,
first_run_notice_confirmed: None,
+ onboarding_tour_seen: None,
new_layout_notice_confirmed: None,
whats_new_seen_version: None,
common_config_confirmed: None,
diff --git a/src/components/FirstRunNoticeDialog.tsx b/src/components/FirstRunNoticeDialog.tsx
index aedde01a8..ca6a9406c 100644
--- a/src/components/FirstRunNoticeDialog.tsx
+++ b/src/components/FirstRunNoticeDialog.tsx
@@ -5,7 +5,10 @@ import { OnboardingTour, type TourPage } from "@/components/OnboardingTour";
import { useSettingsQuery } from "@/lib/query";
import { settingsApi } from "@/lib/api";
import { markSeen } from "@/lib/whatsNew";
-import { useOnboardingTourRequest } from "@/lib/onboardingTour";
+import {
+ tourReplacesWhatsNew,
+ useOnboardingTourRequest,
+} from "@/lib/onboardingTour";
interface FirstRunNoticeDialogProps {
/** 手动重看前把界面切到供应商页:要圈的侧栏、按钮、卡片都在这一页上 */
@@ -15,8 +18,9 @@ interface FirstRunNoticeDialogProps {
}
/**
- * 使用教程的宿主:settings.json 里 firstRunNoticeConfirmed 为空时自动打开,
+ * 使用教程的宿主:settings.json 里 onboardingTourSeen 不是 true 时自动打开,
* 跳过或看完都写成 true,以后不再自动打开;关于页可以用 startOnboardingTour() 手动重看。
+ * 不沿用 firstRunNoticeConfirmed:关过旧欢迎弹窗的老用户也要看一次教程。
*/
export function FirstRunNoticeDialog({
onBeforeOpen,
@@ -29,7 +33,7 @@ export function FirstRunNoticeDialog({
const [replaying, setReplaying] = useState(false);
const firstRunPending =
- !closed && settings != null && settings.firstRunNoticeConfirmed !== true;
+ !closed && settings != null && settings.onboardingTourSeen !== true;
const isOpen = firstRunPending || replaying;
// 手动重看(从设置 → 关于)时先回到供应商页;首次启动本来就停在供应商页,
@@ -44,17 +48,27 @@ export function FirstRunNoticeDialog({
if (!settings) return;
try {
const { webdavSync: _, ...rest } = settings;
- // 新装用户看的就是新界面、新版本,「界面改版了」弹窗和更新摘要一并记成已看过
- const version = await getVersion().catch(() => undefined);
+ // 教程讲的就是当前界面,「界面改版了」弹窗一并记成已看过;更新摘要只替新装和
+ // 3.x 升上来的用户记掉,4.x 老用户看完教程接着看摘要。
+ // firstRunNoticeConfirmed 一起写,降级回旧版也不再弹欢迎框。
+ const whatsNew = tourReplacesWhatsNew(settings)
+ ? {
+ whatsNewSeenVersion: markSeen(
+ settings.whatsNewSeenVersion,
+ await getVersion().catch(() => undefined),
+ ),
+ }
+ : {};
await settingsApi.save({
...rest,
+ onboardingTourSeen: true,
firstRunNoticeConfirmed: true,
newLayoutNoticeConfirmed: true,
- whatsNewSeenVersion: markSeen(settings.whatsNewSeenVersion, version),
+ ...whatsNew,
});
await queryClient.invalidateQueries({ queryKey: ["settings"] });
} catch (error) {
- console.error("Failed to save firstRunNoticeConfirmed:", error);
+ console.error("Failed to save onboardingTourSeen:", error);
}
};
diff --git a/src/components/WhatsNewDialog.tsx b/src/components/WhatsNewDialog.tsx
index 81494979d..cfd04accc 100644
--- a/src/components/WhatsNewDialog.tsx
+++ b/src/components/WhatsNewDialog.tsx
@@ -15,6 +15,7 @@ import { Button } from "@/components/ui/button";
import { useNewLayoutNoticePending } from "@/components/shell/NewLayoutDialog";
import { settingsApi } from "@/lib/api";
import { useSettingsQuery } from "@/lib/query";
+import { tourReplacesWhatsNew } from "@/lib/onboardingTour";
import {
WHATS_NEW_ENTRIES,
changelogUrl,
@@ -169,13 +170,15 @@ export function WhatsNewNotice() {
});
const [closed, setClosed] = useState(false);
const stampedRef = useRef(false);
- // 这次启动弹过首次运行教程:整个会话都不弹更新摘要,教程确认后只静默记下当前版本。
- // 教程确认时本来就会记下版本,这里兜住它读不到版本、没记上的情况。
+ // 这次启动弹的教程代替了更新摘要(新装、从 3.x 升上来):整个会话都不弹摘要,
+ // 教程确认后只静默记下当前版本。教程确认时本来就会记下版本,这里兜住它读不到版本、
+ // 没记上的情况。4.x 老用户不在此列,教程结束后照常弹摘要。
const [firstRunSession, setFirstRunSession] = useState(false);
if (
!firstRunSession &&
settings != null &&
- settings.firstRunNoticeConfirmed !== true
+ settings.onboardingTourSeen !== true &&
+ tourReplacesWhatsNew(settings)
) {
setFirstRunSession(true);
}
@@ -183,7 +186,7 @@ export function WhatsNewNotice() {
const seen = settings?.whatsNewSeenVersion;
const due =
settings != null &&
- settings.firstRunNoticeConfirmed === true &&
+ settings.onboardingTourSeen === true &&
newLayoutPending === false &&
!!currentVersion &&
isNewerThanSeen(currentVersion, seen);
diff --git a/src/components/shell/NewLayoutDialog.tsx b/src/components/shell/NewLayoutDialog.tsx
index e3ca7d2a6..20977909b 100644
--- a/src/components/shell/NewLayoutDialog.tsx
+++ b/src/components/shell/NewLayoutDialog.tsx
@@ -35,9 +35,9 @@ async function hasAnyProvider(): Promise<boolean> {
/**
* 「界面改版了」弹窗这次会不会出现:true 会,false 不会,undefined 还在查供应商。
- * - 必须已经确认过首次启动的欢迎弹窗。全新安装时后端会先导入当前配置、再预置官方
- * 供应商,单看「有没有供应商」分不出新老用户;新用户点欢迎弹窗的「我知道了」时
- * 会把这个字段一起写成 true,以后也不会再看到这里。
+ * - 必须已经看完或跳过使用教程。全新安装时后端会先导入当前配置、再预置官方
+ * 供应商,单看「有没有供应商」分不出新老用户;教程结束时会把这个字段一起写成
+ * true,所以看过教程的用户(新老都是)不会再看到这里。
* - 数据库里已经有供应商(任一应用)。
* 更新摘要弹窗也读它,排在这个弹窗后面。
*/
@@ -46,7 +46,7 @@ export function useNewLayoutNoticePending(
): boolean | undefined {
const eligible =
settings != null &&
- settings.firstRunNoticeConfirmed === true &&
+ settings.onboardingTourSeen === true &&
settings.newLayoutNoticeConfirmed !== true;
const { data: hasProviders } = useQuery({
diff --git a/src/lib/onboardingTour.ts b/src/lib/onboardingTour.ts
index b58a5b2ef..5a0982797 100644
--- a/src/lib/onboardingTour.ts
+++ b/src/lib/onboardingTour.ts
@@ -1,4 +1,5 @@
import { useEffect, useRef } from "react";
+import type { Settings } from "@/types";
const START_EVENT = "cc-switch:onboarding-tour-start";
@@ -7,6 +8,17 @@ export function startOnboardingTour() {
window.dispatchEvent(new Event(START_EVENT));
}
+/**
+ * 自动弹出的教程结束时,要不要把这一版的更新摘要一并记成已看:
+ * - 新装用户、从 3.x 升上来的用户(newLayoutNoticeConfirmed 不是 true):要。
+ * 整个 4.x 界面对他们都是新的,教程就是完整介绍,摘要里相对上一个 4.x 版本的改动没意义。
+ * - 已经在用 4.x 的老用户:不要。看完教程后接着弹这一版的更新摘要。
+ * 必须在教程写入设置之前判断:教程结束时会把 newLayoutNoticeConfirmed 写成 true。
+ */
+export function tourReplacesWhatsNew(settings: Settings): boolean {
+ return settings.newLayoutNoticeConfirmed !== true;
+}
+
export function useOnboardingTourRequest(onRequest: () => void) {
const ref = useRef(onRequest);
ref.current = onRequest;
diff --git a/src/types.ts b/src/types.ts
index 224ec93fa..543c21075 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -490,6 +490,9 @@ export interface Settings {
failoverConfirmed?: boolean;
// User has confirmed the first-run welcome notice
firstRunNoticeConfirmed?: boolean;
+ // User has finished or skipped the onboarding tour (shown once to every user,
+ // including those who dismissed the old welcome dialog)
+ onboardingTourSeen?: boolean;
// User has confirmed the one-time "new layout" dialog shown to upgrading users
newLayoutNoticeConfirmed?: boolean;
// Highest app version whose "what's new" summary the user has seen on this device
diff --git a/tests/components/FirstRunNoticeDialog.test.tsx b/tests/components/FirstRunNoticeDialog.test.tsx
index ab2b980b7..9f25d3862 100644
--- a/tests/components/FirstRunNoticeDialog.test.tsx
+++ b/tests/components/FirstRunNoticeDialog.test.tsx
@@ -11,7 +11,14 @@ import { createTestQueryClient } from "../utils/testQueryClient";
const mocks = vi.hoisted(() => ({
save: vi.fn(),
- settings: undefined as { firstRunNoticeConfirmed?: boolean } | undefined,
+ settings: undefined as
+ | {
+ firstRunNoticeConfirmed?: boolean;
+ newLayoutNoticeConfirmed?: boolean;
+ onboardingTourSeen?: boolean;
+ whatsNewSeenVersion?: string;
+ }
+ | undefined,
}));
vi.mock("@/lib/api", () => ({
@@ -39,7 +46,7 @@ const next = () =>
describe("FirstRunNoticeDialog", () => {
beforeEach(() => {
- mocks.settings = { firstRunNoticeConfirmed: undefined };
+ mocks.settings = { onboardingTourSeen: undefined };
mocks.save.mockReset().mockResolvedValue(true);
});
@@ -92,10 +99,11 @@ describe("FirstRunNoticeDialog", () => {
await waitFor(() =>
expect(screen.queryByText("tutorial.more.title")).not.toBeInTheDocument(),
);
- // 新装用户看的就是当前版本,「界面改版了」和更新摘要一并记成已看
+ // 教程讲的就是当前版本,「界面改版了」和更新摘要一并记成已看
expect(mocks.save).toHaveBeenCalledTimes(1);
expect(mocks.save).toHaveBeenCalledWith(
expect.objectContaining({
+ onboardingTourSeen: true,
firstRunNoticeConfirmed: true,
newLayoutNoticeConfirmed: true,
whatsNewSeenVersion: "4.0.25",
@@ -108,12 +116,43 @@ describe("FirstRunNoticeDialog", () => {
fireEvent.click(screen.getByRole("button", { name: "tutorial.skip" }));
await waitFor(() =>
expect(mocks.save).toHaveBeenCalledWith(
- expect.objectContaining({ firstRunNoticeConfirmed: true }),
+ expect.objectContaining({ onboardingTourSeen: true }),
),
);
expect(screen.queryByText("firstRunNotice.title")).not.toBeInTheDocument();
});
+ it("leaves the update summary for 4.x users to see after the tour", async () => {
+ mocks.settings = {
+ firstRunNoticeConfirmed: true,
+ newLayoutNoticeConfirmed: true,
+ whatsNewSeenVersion: "4.0.20",
+ };
+ render(withClient(<FirstRunNoticeDialog />));
+ fireEvent.click(screen.getByRole("button", { name: "tutorial.skip" }));
+ await waitFor(() => expect(mocks.save).toHaveBeenCalledTimes(1));
+ expect(mocks.save).toHaveBeenCalledWith(
+ expect.objectContaining({
+ onboardingTourSeen: true,
+ whatsNewSeenVersion: "4.0.20",
+ }),
+ );
+ });
+
+ it("records the update summary as seen for 3.x upgraders", async () => {
+ mocks.settings = { firstRunNoticeConfirmed: true };
+ render(withClient(<FirstRunNoticeDialog />));
+ fireEvent.click(screen.getByRole("button", { name: "tutorial.skip" }));
+ await waitFor(() =>
+ expect(mocks.save).toHaveBeenCalledWith(
+ expect.objectContaining({
+ newLayoutNoticeConfirmed: true,
+ whatsNewSeenVersion: "4.0.25",
+ }),
+ ),
+ );
+ });
+
it("records the tour as seen when dismissed with Escape", async () => {
render(withClient(<FirstRunNoticeDialog />));
fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
@@ -137,9 +176,18 @@ describe("FirstRunNoticeDialog", () => {
expect(screen.getByText("firstRunNotice.title")).toBeInTheDocument();
});
- it("stays hidden once confirmed", () => {
+ it("shows once to users who dismissed the old welcome dialog", () => {
mocks.settings = { firstRunNoticeConfirmed: true };
render(withClient(<FirstRunNoticeDialog />));
+ expect(screen.getByText("firstRunNotice.title")).toBeInTheDocument();
+ });
+
+ it("stays hidden once the tour was seen", () => {
+ mocks.settings = {
+ firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
+ };
+ render(withClient(<FirstRunNoticeDialog />));
expect(screen.queryByText("firstRunNotice.title")).not.toBeInTheDocument();
});
@@ -150,7 +198,7 @@ describe("FirstRunNoticeDialog", () => {
});
it("replays on request without touching settings", async () => {
- mocks.settings = { firstRunNoticeConfirmed: true };
+ mocks.settings = { onboardingTourSeen: true };
const onBeforeOpen = vi.fn();
render(withClient(<FirstRunNoticeDialog onBeforeOpen={onBeforeOpen} />));
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
diff --git a/tests/components/NewLayoutDialog.test.tsx b/tests/components/NewLayoutDialog.test.tsx
index 1fba3df4f..ea67b4c15 100644
--- a/tests/components/NewLayoutDialog.test.tsx
+++ b/tests/components/NewLayoutDialog.test.tsx
@@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({
save: vi.fn(),
openExternal: vi.fn(),
settings: undefined as
- | { firstRunNoticeConfirmed?: boolean; newLayoutNoticeConfirmed?: boolean }
+ | { onboardingTourSeen?: boolean; newLayoutNoticeConfirmed?: boolean }
| undefined,
}));
@@ -37,7 +37,7 @@ function renderDialog() {
describe("NewLayoutDialog", () => {
beforeEach(() => {
- mocks.settings = { firstRunNoticeConfirmed: true };
+ mocks.settings = { onboardingTourSeen: true };
mocks.save.mockReset().mockResolvedValue(true);
mocks.openExternal.mockReset().mockResolvedValue(undefined);
mocks.getAll
@@ -92,7 +92,7 @@ describe("NewLayoutDialog", () => {
it("stays closed once confirmed", async () => {
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
newLayoutNoticeConfirmed: true,
};
renderDialog();
@@ -110,7 +110,7 @@ describe("NewLayoutDialog", () => {
});
it("never shows to a fresh install that is seeing the welcome dialog", async () => {
- mocks.settings = { firstRunNoticeConfirmed: undefined };
+ mocks.settings = { onboardingTourSeen: undefined };
renderDialog();
expect(mocks.getAll).not.toHaveBeenCalled();
expect(screen.queryByText("newLayoutNotice.title")).not.toBeInTheDocument();
diff --git a/tests/components/WhatsNewNotice.test.tsx b/tests/components/WhatsNewNotice.test.tsx
index ef74a4638..3c070dd95 100644
--- a/tests/components/WhatsNewNotice.test.tsx
+++ b/tests/components/WhatsNewNotice.test.tsx
@@ -17,7 +17,7 @@ const mocks = vi.hoisted(() => ({
version: "4.0.4",
settings: undefined as
| {
- firstRunNoticeConfirmed?: boolean;
+ onboardingTourSeen?: boolean;
newLayoutNoticeConfirmed?: boolean;
whatsNewSeenVersion?: string;
}
@@ -76,7 +76,7 @@ describe("WhatsNewNotice", () => {
beforeEach(() => {
mocks.version = "4.0.4";
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
newLayoutNoticeConfirmed: true,
whatsNewSeenVersion: "4.0.1",
};
@@ -112,7 +112,7 @@ describe("WhatsNewNotice", () => {
it("shows only the current version when nothing was recorded before", async () => {
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
newLayoutNoticeConfirmed: true,
};
renderNotice();
@@ -151,7 +151,7 @@ describe("WhatsNewNotice", () => {
});
it("waits for the welcome dialog on a fresh install", async () => {
- mocks.settings = { firstRunNoticeConfirmed: undefined };
+ mocks.settings = { onboardingTourSeen: undefined };
renderNotice();
await settle();
expect(title()).not.toBeInTheDocument();
@@ -159,13 +159,13 @@ describe("WhatsNewNotice", () => {
});
it("stays hidden for the rest of a first-run session, even if the tutorial did not record a version", async () => {
- mocks.settings = { firstRunNoticeConfirmed: undefined };
+ mocks.settings = { onboardingTourSeen: undefined };
const view = renderNotice();
await settle();
// 教程确认了,但当时没读到版本,whatsNewSeenVersion 还是空的
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
newLayoutNoticeConfirmed: true,
};
view.rerender(
@@ -181,9 +181,29 @@ describe("WhatsNewNotice", () => {
expect(title()).not.toBeInTheDocument();
});
+ it("shows after the tour for users already on 4.x", async () => {
+ mocks.settings = {
+ newLayoutNoticeConfirmed: true,
+ whatsNewSeenVersion: "4.0.1",
+ };
+ const view = renderNotice();
+ await settle();
+ expect(title()).not.toBeInTheDocument();
+
+ // 教程结束:只写了 onboardingTourSeen,更新摘要的版本留着
+ mocks.settings = { ...mocks.settings, onboardingTourSeen: true };
+ view.rerender(
+ <QueryClientProvider client={createTestQueryClient()}>
+ <WhatsNewNotice />
+ </QueryClientProvider>,
+ );
+ expect(await screen.findByText("whatsNew.updatedTo")).toBeInTheDocument();
+ expect(screen.getByText("v4.0.4")).toBeInTheDocument();
+ });
+
it("waits while the new layout dialog is showing", async () => {
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
whatsNewSeenVersion: "4.0.1",
};
renderNotice();
@@ -195,7 +215,7 @@ describe("WhatsNewNotice", () => {
it("shows when the new layout dialog does not apply", async () => {
mocks.settings = {
- firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
whatsNewSeenVersion: "4.0.1",
};
mocks.getAll.mockResolvedValue({});
diff --git a/tests/integration/App.test.tsx b/tests/integration/App.test.tsx
index b0c85c382..f567c96c9 100644
--- a/tests/integration/App.test.tsx
+++ b/tests/integration/App.test.tsx
@@ -233,6 +233,7 @@ describe("App integration with MSW", () => {
resetProviderState();
setSettings({
firstRunNoticeConfirmed: true,
+ onboardingTourSeen: true,
newLayoutNoticeConfirmed: true,
});
toastSuccessMock.mockReset();