-
+
+
+ {md && (
+
)}
-
+
+
+
{profile.demo && }
+
-
+
);
};
diff --git a/web/src/lib/memo-views.ts b/web/src/lib/memo-views.ts
new file mode 100644
index 00000000..fc385106
--- /dev/null
+++ b/web/src/lib/memo-views.ts
@@ -0,0 +1,54 @@
+import { ROUTES } from "@/router/routes";
+
+export type MemoScope = "home" | "explore" | "archived";
+
+export const BUILTIN_TASKS_VIEW_ID = "__built_in_tasks__";
+export const BUILTIN_TASKS_VIEW_FILTER = "has_task_list && has_incomplete_tasks";
+
+export const getShortcutId = (name: string): string => {
+ const parts = name.split("/");
+ return parts.length === 4 ? parts[3] : name;
+};
+
+export const isMemoScopeRoute = (pathname: string): boolean =>
+ pathname === ROUTES.HOME || pathname === ROUTES.EXPLORE || pathname === ROUTES.ARCHIVED;
+
+export const getMemoScopePath = (scope: MemoScope): string => {
+ if (scope === "explore") return ROUTES.EXPLORE;
+ if (scope === "archived") return ROUTES.ARCHIVED;
+ return ROUTES.HOME;
+};
+
+const cleanPathname = (value: string): string => value.split(/[?#]/, 1)[0] || ROUTES.HOME;
+
+interface ResolveMemoScopeOptions {
+ currentUsername?: string;
+ detailFrom?: string;
+ memoArchived?: boolean;
+ fallback?: MemoScope;
+}
+
+export const resolveMemoScope = (pathname: string, options: ResolveMemoScopeOptions = {}): MemoScope => {
+ const cleanPath = cleanPathname(pathname);
+ if (cleanPath === ROUTES.EXPLORE) return "explore";
+ if (cleanPath === ROUTES.ARCHIVED) return "archived";
+ if (cleanPath === ROUTES.HOME) return "home";
+
+ const profileMatch = cleanPath.match(/^\/u\/([^/]+)$/);
+ if (profileMatch) {
+ return options.currentUsername && decodeURIComponent(profileMatch[1]) === options.currentUsername ? "home" : "explore";
+ }
+
+ if (cleanPath.startsWith("/memos/") && options.detailFrom) {
+ return resolveMemoScope(options.detailFrom, {
+ currentUsername: options.currentUsername,
+ fallback: options.fallback,
+ });
+ }
+
+ if (cleanPath.startsWith("/memos/") && options.memoArchived) {
+ return "archived";
+ }
+
+ return options.fallback ?? "home";
+};
diff --git a/web/src/locales/en.json b/web/src/locales/en.json
index a71566e8..bef1e0aa 100644
--- a/web/src/locales/en.json
+++ b/web/src/locales/en.json
@@ -1,17 +1,25 @@
{
"about": {
+ "api-docs": "API Docs",
+ "api-docs-note": "REST and gRPC reference",
"blogs": "Blogs",
"build": "Build",
"commit": "Commit",
+ "demo": "Demo",
"description": "A privacy-first, lightweight note-taking service. Easily capture and share your great thoughts.",
"distribution": "Distribution",
"documents": "Documents",
+ "documents-note": "Deploy, configure, and use Memos",
+ "github-repository": "GitHub Repo",
+ "github-repository-note": "Source, issues, and releases",
"license": "License",
"media": "Media",
- "github-repository": "GitHub Repo",
"official-website": "Official Website",
+ "official-website-note": "The project homepage",
"powered-by": "Powered by Memos",
"project": "Project",
+ "project-links": "Project links",
+ "web-clipper": "Web Clipper",
"web-clipper-platforms": "Chrome + Firefox"
},
"auth": {
@@ -51,6 +59,7 @@
"retry": "Retry"
},
"empty": {
+ "all": "No attachments yet.",
"audio": "No audio attachments yet.",
"documents": "No document attachments yet.",
"media": "No media attachments yet."
@@ -79,6 +88,7 @@
},
"common": {
"about": "About",
+ "actions": "Actions",
"add": "Add",
"admin": "Admin",
"all": "All",
@@ -134,15 +144,18 @@
"mark": "Mark",
"memo": "Memo",
"memos": "Memos",
+ "month-navigation": "Month navigation",
"more": "More",
"name": "Name",
"new": "New",
+ "next-month": "Next month",
"nickname": "Nickname",
"null": "Null",
"or": "or",
"password": "Password",
"pin": "Pin",
"pinned": "Pinned",
+ "previous-month": "Previous month",
"preview": "Preview",
"profile": "Profile",
"properties": "Properties",
@@ -163,10 +176,12 @@
"shortcut-filter": "Shortcut filter",
"shortcuts": "Shortcuts",
"sign-in": "Sign in",
+ "sign-in-to-memos": "Sign in to Memos",
"sign-out": "Sign out",
"sign-up": "Sign up",
"statistics": "Statistics",
"tags": "Tags",
+ "tasks": "Tasks",
"title": "Title",
"today": "Today",
"tree-mode": "Tree mode",
@@ -179,6 +194,7 @@
"username": "Username",
"version": "Version",
"visibility": "Visibility",
+ "views": "Views",
"yourself": "Yourself"
},
"locale-picker": {
diff --git a/web/src/locales/zh-Hans.json b/web/src/locales/zh-Hans.json
index a8c97d9e..85ca0b66 100644
--- a/web/src/locales/zh-Hans.json
+++ b/web/src/locales/zh-Hans.json
@@ -1,11 +1,26 @@
{
"about": {
+ "api-docs": "API 文档",
+ "api-docs-note": "REST 与 gRPC 参考",
"blogs": "博客",
+ "build": "构建信息",
+ "commit": "提交",
+ "demo": "演示",
"description": "Memos 是一个隐私优先、轻量级的笔记解决方案,可以轻松捕捉和分享您的想法。",
+ "distribution": "发行版本",
"documents": "文档",
+ "documents-note": "部署、配置和使用 Memos",
"github-repository": "GitHub 仓库",
+ "github-repository-note": "源代码、问题与版本发布",
+ "license": "许可证",
"official-website": "官网",
- "media": "媒体"
+ "official-website-note": "项目主页",
+ "media": "媒体",
+ "powered-by": "由 Memos 提供支持",
+ "project": "项目",
+ "project-links": "项目链接",
+ "web-clipper": "网页剪藏器",
+ "web-clipper-platforms": "Chrome + Firefox"
},
"auth": {
"admin-sign-in": "管理员登录",
@@ -40,6 +55,7 @@
},
"common": {
"about": "关于",
+ "actions": "操作",
"add": "增加",
"admin": "管理",
"all": "全部",
@@ -93,15 +109,18 @@
"mark": "引用",
"memo": "备忘录",
"memos": "备忘录",
+ "month-navigation": "月份导航",
"more": "更多",
"name": "名称",
"new": "新建",
+ "next-month": "下个月",
"nickname": "昵称",
"null": "空",
"or": "或者",
"password": "密码",
"pin": "置顶",
"pinned": "已置顶",
+ "previous-month": "上个月",
"preview": "预览",
"profile": "个人资料",
"properties": "属性",
@@ -122,10 +141,12 @@
"shortcut-filter": "捷径过滤器",
"shortcuts": "捷径",
"sign-in": "登录",
+ "sign-in-to-memos": "登录 Memos",
"sign-out": "退出登录",
"sign-up": "注册",
"statistics": "统计",
"tags": "标签",
+ "tasks": "任务",
"title": "标题",
"today": "今天",
"tree-mode": "树模式",
@@ -138,6 +159,7 @@
"username": "用户名",
"version": "版本",
"visibility": "可见性",
+ "views": "视图",
"yourself": "您自己"
},
"locale-picker": {
@@ -849,6 +871,7 @@
"retry": "重试"
},
"empty": {
+ "all": "暂无附件",
"audio": "暂无音频附件",
"documents": "暂无文档附件",
"media": "暂无媒体附件"
diff --git a/web/src/locales/zh-Hant.json b/web/src/locales/zh-Hant.json
index 2c5297d0..4a7f2369 100644
--- a/web/src/locales/zh-Hant.json
+++ b/web/src/locales/zh-Hant.json
@@ -1,11 +1,26 @@
{
"about": {
+ "api-docs": "API 文件",
+ "api-docs-note": "REST 與 gRPC 參考",
"blogs": "部落格",
+ "build": "建置資訊",
+ "commit": "提交",
+ "demo": "示範",
"description": "以隱私為核心的輕量化筆記服務,輕鬆記錄並分享您的好點子。",
+ "distribution": "發行版本",
"documents": "文件",
- "media": "媒體",
+ "documents-note": "部署、設定及使用 Memos",
"github-repository": "GitHub 儲存庫",
- "official-website": "官方網站"
+ "github-repository-note": "原始碼、問題與版本發佈",
+ "license": "授權條款",
+ "media": "媒體",
+ "official-website": "官方網站",
+ "official-website-note": "專案首頁",
+ "powered-by": "由 Memos 提供支援",
+ "project": "專案",
+ "project-links": "專案連結",
+ "web-clipper": "網頁剪藏器",
+ "web-clipper-platforms": "Chrome + Firefox"
},
"auth": {
"create-your-account": "建立您的帳號",
@@ -27,6 +42,7 @@
"retry": "重試"
},
"empty": {
+ "all": "尚無附件。",
"audio": "尚無音訊附件。",
"documents": "尚無文件附件。",
"media": "尚無媒體附件。"
@@ -55,6 +71,7 @@
},
"common": {
"about": "關於",
+ "actions": "操作",
"add": "新增",
"admin": "管理",
"all": "所有",
@@ -108,15 +125,18 @@
"mark": "標記",
"memo": "備忘錄",
"memos": "備忘錄",
+ "month-navigation": "月份導覽",
"more": "更多",
"name": "名稱",
"new": "新增",
+ "next-month": "下個月",
"nickname": "暱稱",
"null": "空",
"or": "或",
"password": "密碼",
"pin": "置頂",
"pinned": "已置頂",
+ "previous-month": "上個月",
"preview": "預覽",
"profile": "個人檔案",
"properties": "屬性",
@@ -137,11 +157,13 @@
"shortcut-filter": "篩選條件表達式",
"shortcuts": "快捷篩選",
"sign-in": "登入",
+ "sign-in-to-memos": "登入 Memos",
"sign-in-with": "使用 {{provider}} 登入",
"sign-out": "登出",
"sign-up": "註冊",
"statistics": "統計",
"tags": "標籤",
+ "tasks": "任務",
"title": "標題",
"today": "今天",
"tree-mode": "樹狀顯示",
@@ -154,6 +176,7 @@
"username": "帳號",
"version": "版本",
"visibility": "瀏覽權限",
+ "views": "檢視",
"yourself": "您自己"
},
"locale-picker": {
diff --git a/web/src/pages/About.tsx b/web/src/pages/About.tsx
index e06b0e0f..c586df60 100644
--- a/web/src/pages/About.tsx
+++ b/web/src/pages/About.tsx
@@ -1,132 +1,22 @@
-import { ExternalLinkIcon, ScissorsIcon } from "lucide-react";
-import { Badge } from "@/components/ui/badge";
-import { useInstance } from "@/contexts/InstanceContext";
-import { WEB_CLIPPER_URL } from "@/lib/constants";
-import { useTranslate } from "@/utils/i18n";
-
-const GITHUB_COMMIT_URL_PREFIX = "https://github.com/usememos/memos/commit/";
-const GITHUB_RELEASE_URL_PREFIX = "https://github.com/usememos/memos/releases/tag/v";
-
-const DEFAULT_TITLE = "Memos";
-const DEFAULT_TAGLINE = "Capture first. Keep it yours.";
-const DEFAULT_LOGO = "/logo.webp";
-
-const isCommitSha = (commit: string) => /^[0-9a-f]{7,40}$/i.test(commit);
-const isSemver = (version: string) => /^\d+\.\d+\.\d+/.test(version);
-
-const Chip = ({ href, children }: { href?: string; children: React.ReactNode }) => {
- const className = "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 font-mono text-xs text-muted-foreground";
- if (href) {
- return (
-
- {children}
-
- );
- }
- return
{children};
-};
-
-const SectionLabel = ({ children }: { children: React.ReactNode }) => (
-
{children}
-);
+import { useEffect } from "react";
+import { Navigate } from "react-router-dom";
+import { useAppSidebar } from "@/contexts/AppSidebarContext";
+import { useAuth } from "@/contexts/AuthContext";
+import useCurrentUser from "@/hooks/useCurrentUser";
+import { ROUTES } from "@/router/routes";
const About = () => {
- const t = useTranslate();
- const { profile, generalSetting } = useInstance();
+ const currentUser = useCurrentUser();
+ const { setAboutOpen } = useAppSidebar();
+ const { isInitialized } = useAuth();
- // Instance identity: custom branding when the admin has set it, Memos defaults otherwise.
- const customProfile = generalSetting.customProfile;
- const instanceTitle = customProfile?.title || DEFAULT_TITLE;
- const instanceTagline = customProfile?.description || DEFAULT_TAGLINE;
- const instanceLogo = customProfile?.logoUrl || DEFAULT_LOGO;
- const isCustomBranded = instanceTitle !== DEFAULT_TITLE;
+ useEffect(() => {
+ if (isInitialized) setAboutOpen(true);
+ }, [isInitialized, setAboutOpen]);
- // Dev builds report version "dev" and commit "unknown"; show the raw version and skip the commit row.
- const hasSemver = isSemver(profile.version);
- const releaseUrl = hasSemver ? `${GITHUB_RELEASE_URL_PREFIX}${profile.version}` : "";
- const versionLabel = hasSemver ? `v${profile.version}` : profile.version;
- const hasCommitSha = isCommitSha(profile.commit);
- const commitUrl = hasCommitSha ? `${GITHUB_COMMIT_URL_PREFIX}${profile.commit}` : "";
- const shortCommit = hasCommitSha ? profile.commit.slice(0, 7) : "";
+ if (!isInitialized) return null;
- const buildRows: { label: string; value: React.ReactNode }[] = [];
- if (profile.version) {
- buildRows.push({ label: t("common.version"), value:
{versionLabel} });
- }
- if (shortCommit) {
- buildRows.push({ label: t("about.commit"), value:
{shortCommit} });
- }
- buildRows.push({ label: t("about.license"), value:
MIT });
- if (isCustomBranded) {
- buildRows.push({
- label: t("about.distribution"),
- value:
{t("about.powered-by")},
- });
- }
-
- const projectLinks = [
- { label: t("about.official-website"), note: "the project homepage", href: "https://usememos.com/" },
- { label: t("about.documents"), note: "deploy, configure, use", href: "https://usememos.com/docs" },
- { label: "API Docs", note: "REST + gRPC reference", href: "https://usememos.com/docs/api" },
- { label: t("about.github-repository"), note: "source, issues, releases", href: "https://github.com/usememos/memos" },
- { label: "Web Clipper", note: t("about.web-clipper-platforms"), href: WEB_CLIPPER_URL, icon: ScissorsIcon },
- ];
-
- return (
-
-
-
-
-
- {t("about.build")}
-
- {buildRows.map((row) => (
-
-
- {row.label}
- - {row.value}
-
- ))}
-
-
-
-
-
-
Free and open source under the MIT license.
-
-
- );
+ return
;
};
export default About;
diff --git a/web/src/pages/Archived.tsx b/web/src/pages/Archived.tsx
index 28046135..52941c8e 100644
--- a/web/src/pages/Archived.tsx
+++ b/web/src/pages/Archived.tsx
@@ -8,10 +8,9 @@ import { Memo } from "@/types/proto/api/v1/memo_service_pb";
const Archived = () => {
const user = useCurrentUser();
- // Build filter using unified hook (no shortcuts or pinned filter)
const memoFilter = useMemoFilters({
creatorName: user?.name,
- includeShortcuts: false,
+ includeShortcuts: true,
includePinned: false,
});
diff --git a/web/src/pages/Attachments.tsx b/web/src/pages/Attachments.tsx
index 1063efdf..dbb412a7 100644
--- a/web/src/pages/Attachments.tsx
+++ b/web/src/pages/Attachments.tsx
@@ -1,6 +1,6 @@
import { create } from "@bufbuild/protobuf";
-import { LoaderCircleIcon } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { LoaderCircleIcon, Trash2Icon } from "lucide-react";
+import { useState } from "react";
import { toast } from "react-hot-toast";
import {
AttachmentAudioRows,
@@ -8,20 +8,17 @@ import {
AttachmentLibraryEmptyState,
AttachmentLibraryErrorState,
AttachmentLibrarySkeletonGrid,
- AttachmentLibraryToolbar,
- AttachmentLibraryUnusedPanel,
AttachmentMediaGrid,
AttachmentUnusedRows,
} from "@/components/AttachmentLibrary";
import ConfirmDialog from "@/components/ConfirmDialog";
-import MobileHeader from "@/components/MobileHeader";
import PreviewImageDialog from "@/components/PreviewImageDialog";
import { Button } from "@/components/ui/button";
import { attachmentServiceClient } from "@/connect";
-import { type AttachmentLibraryStats, type AttachmentLibraryTab, useAttachmentLibrary } from "@/hooks/useAttachmentLibrary";
+import { useAppSidebar } from "@/contexts/AppSidebarContext";
+import { useAttachmentLibrary, useUnusedAttachmentLibrary } from "@/hooks/useAttachmentLibrary";
import { useBatchDeleteAttachments } from "@/hooks/useAttachmentQueries";
import useDialog from "@/hooks/useDialog";
-import useMediaQuery from "@/hooks/useMediaQuery";
import i18n from "@/i18n";
import { handleError } from "@/lib/error";
import { ListAttachmentsRequestSchema } from "@/types/proto/api/v1/attachment_service_pb";
@@ -30,12 +27,6 @@ import { useTranslate } from "@/utils/i18n";
const UNUSED_PAGE_SIZE = 1000;
const BATCH_DELETE_SIZE = 100;
-const TAB_COUNT_SELECTOR = {
- audio: (stats: AttachmentLibraryStats) => stats.audio,
- documents: (stats: AttachmentLibraryStats) => stats.documents,
- media: (stats: AttachmentLibraryStats) => stats.media,
-} as const;
-
const chunkNames = (names: string[], size: number) => {
const chunks: string[][] = [];
@@ -68,11 +59,9 @@ const listUnusedAttachmentNames = async () => {
const Attachments = () => {
const t = useTranslate();
- const md = useMediaQuery("md");
const deleteUnusedAttachmentsDialog = useDialog();
- const [activeTab, setActiveTab] = useState
("media");
+ const { attachmentSection } = useAppSidebar();
const [previewState, setPreviewState] = useState({ open: false, initialIndex: 0 });
- const [showUnusedSection, setShowUnusedSection] = useState(false);
const { mutateAsync: batchDeleteAttachments, isPending: isDeletingUnused } = useBatchDeleteAttachments();
const {
audioItems,
@@ -88,16 +77,15 @@ const Attachments = () => {
mediaPreviewItems,
refetch,
stats,
- unusedItems,
} = useAttachmentLibrary(i18n.language);
-
- const currentItemsCount = useMemo(() => TAB_COUNT_SELECTOR[activeTab](stats), [activeTab, stats]);
-
- useEffect(() => {
- if (stats.unused === 0) {
- setShowUnusedSection(false);
- }
- }, [stats.unused]);
+ const {
+ error: unusedError,
+ isComplete: unusedIsComplete,
+ isError: unusedIsError,
+ isLoading: unusedIsLoading,
+ refetch: refetchUnused,
+ unusedItems: completeUnusedItems,
+ } = useUnusedAttachmentLibrary(i18n.language, attachmentSection === "unused");
const handlePreview = (itemId: string) => {
const initialIndex = mediaPreviewItems.findIndex((item) => item.id === itemId);
@@ -109,7 +97,7 @@ const Attachments = () => {
const names = await listUnusedAttachmentNames();
if (names.length === 0) {
- await refetch();
+ await Promise.all([refetch(), refetchUnused()]);
return;
}
@@ -118,7 +106,7 @@ const Attachments = () => {
}
toast.success(t("resource.delete-all-unused-success"));
- await refetch();
+ await Promise.all([refetch(), refetchUnused()]);
} catch (deleteError) {
handleError(deleteError, toast.error, {
context: "Failed to delete unused attachments",
@@ -128,6 +116,41 @@ const Attachments = () => {
};
const renderContent = () => {
+ if (attachmentSection === "unused") {
+ if (unusedIsError) {
+ return (
+ refetchUnused()} />
+ );
+ }
+
+ if (unusedIsLoading || !unusedIsComplete) {
+ return ;
+ }
+
+ return completeUnusedItems.length === 0 ? (
+ {t("message.no-data")}
+ ) : (
+
+
+
+
{t("attachment-library.unused.title")}
+
{t("attachment-library.unused.description")}
+
+
+
+
+
+ );
+ }
+
if (isLoading) {
return ;
}
@@ -136,19 +159,45 @@ const Attachments = () => {
return refetch()} />;
}
- if (currentItemsCount === 0) {
- return ;
+ if (attachmentSection === "all") {
+ const total = stats.media + stats.documents + stats.audio;
+ if (total === 0) return {t("attachment-library.empty.all")}
;
+ return (
+
+ {stats.media > 0 && (
+
+ {t("attachment-library.tabs.media")}
+
+
+ )}
+ {stats.documents > 0 && (
+
+ {t("attachment-library.tabs.documents")}
+
+
+ )}
+ {stats.audio > 0 && (
+
+ {t("attachment-library.tabs.audio")}
+
+
+ )}
+
+ );
}
- if (activeTab === "media") {
+ if (attachmentSection === "media") {
+ if (stats.media === 0) return ;
return ;
}
- if (activeTab === "documents") {
+ if (attachmentSection === "documents") {
+ if (stats.documents === 0) return ;
return ;
}
- if (activeTab === "audio") {
+ if (attachmentSection === "audio") {
+ if (stats.audio === 0) return ;
return ;
}
@@ -156,26 +205,12 @@ const Attachments = () => {
};
return (
-
- {!md && }
-
+
-
-
- {stats.unused > 0 && (
-
deleteUnusedAttachmentsDialog.open()}
- onToggle={() => setShowUnusedSection((state) => !state)}
- />
- )}
-
{renderContent()}
- {hasNextPage && (
+ {attachmentSection !== "unused" && hasNextPage && (
-
- {showUnusedSection && stats.unused > 0 && (
-
-
{t("attachment-library.unused.title")}
-
-
- )}
{
// Note: The backend is responsible for filtering stats based on visibility permissions.
const visibilities = currentUser ? [Visibility.PUBLIC, Visibility.PROTECTED] : [Visibility.PUBLIC];
- // Build filter using unified hook (no creator scoping for Explore)
const memoFilter = useMemoFilters({
- includeShortcuts: false,
+ includeShortcuts: true,
includePinned: false,
visibilities,
});
diff --git a/web/src/pages/Inboxes.tsx b/web/src/pages/Inboxes.tsx
index 6be94f8f..3baff805 100644
--- a/web/src/pages/Inboxes.tsx
+++ b/web/src/pages/Inboxes.tsx
@@ -1,21 +1,17 @@
import { timestampDate } from "@bufbuild/protobuf/wkt";
import { sortBy } from "lodash-es";
-import { ArchiveIcon, BellIcon, InboxIcon } from "lucide-react";
-import { useState } from "react";
+import { BellIcon } from "lucide-react";
import MemoCommentMessage from "@/components/Inbox/MemoCommentMessage";
import MemoMentionMessage from "@/components/Inbox/MemoMentionMessage";
-import MobileHeader from "@/components/MobileHeader";
import Placeholder from "@/components/Placeholder";
-import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import useMediaQuery from "@/hooks/useMediaQuery";
+import { useAppSidebar } from "@/contexts/AppSidebarContext";
import { useNotifications } from "@/hooks/useUserQueries";
import { UserNotification, UserNotification_Status, UserNotification_Type } from "@/types/proto/api/v1/user_service_pb";
import { useTranslate } from "@/utils/i18n";
const Inboxes = () => {
const t = useTranslate();
- const md = useMediaQuery("md");
- const [filter, setFilter] = useState<"all" | "unread" | "archived">("all");
+ const { inboxFilter: filter } = useAppSidebar();
// Fetch notifications with React Query
const { data: fetchedNotifications = [] } = useNotifications();
@@ -31,11 +27,8 @@ const Inboxes = () => {
});
const unreadCount = allNotifications.filter((n) => n.status === UserNotification_Status.UNREAD).length;
- const archivedCount = allNotifications.filter((n) => n.status === UserNotification_Status.ARCHIVED).length;
-
return (
- {!md && }
{/* Header */}
@@ -53,25 +46,6 @@ const Inboxes = () => {
- {/* Filter Tabs */}
-
-
setFilter(value as typeof filter)} variant="segmented">
-
-
- {t("common.all")} ({allNotifications.length})
-
-
-
- {t("inbox.unread")} ({unreadCount})
-
-
-
- {t("common.archived")} ({archivedCount})
-
-
-
-
-
{/* Notifications List */}
{notifications.length === 0 ? (
diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsx
index b79fb224..ea153243 100644
--- a/web/src/pages/MemoDetail.tsx
+++ b/web/src/pages/MemoDetail.tsx
@@ -1,30 +1,51 @@
import { Code, ConnectError } from "@connectrpc/connect";
import { ArrowUpLeftFromCircleIcon } from "lucide-react";
-import { useEffect, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo as useReactMemo, useRef, useState } from "react";
import { Link, Navigate, useLocation, useParams } from "react-router-dom";
import MemoCommentSection from "@/components/MemoCommentSection";
import { MentionResolutionProvider } from "@/components/MemoContent/MentionResolutionContext";
-import { MemoDetailSidebar, MemoDetailSidebarDrawer } from "@/components/MemoDetailSidebar";
import MemoView from "@/components/MemoView";
-import MobileHeader from "@/components/MobileHeader";
+import { useAppSidebar } from "@/contexts/AppSidebarContext";
import { useAuth } from "@/contexts/AuthContext";
import { useInstance } from "@/contexts/InstanceContext";
-import useMediaQuery from "@/hooks/useMediaQuery";
import useMemoDetailError from "@/hooks/useMemoDetailError";
import { useInfiniteMemoComments, useMemo } from "@/hooks/useMemoQueries";
import { useSharedMemo, withShareAttachmentLinks } from "@/hooks/useMemoShareQueries";
import { memoNamePrefix } from "@/lib/resource-names";
-import { cn } from "@/lib/utils";
import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
+import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
+
+const MemoSidebarRegistration = ({
+ memo,
+ from,
+ readonly,
+ onShareImageOpen,
+}: {
+ memo: Memo;
+ from?: string;
+ readonly: boolean;
+ onShareImageOpen: () => void;
+}) => {
+ const { setMemoDetail } = useAppSidebar();
+
+ useEffect(() => {
+ setMemoDetail({ memo, from, readonly, onShareImageOpen });
+ }, [from, memo, onShareImageOpen, readonly, setMemoDetail]);
+
+ useEffect(() => () => setMemoDetail(undefined), [setMemoDetail]);
+
+ return null;
+};
const MemoDetail = () => {
- const md = useMediaQuery("md");
const { isInitialized: authInitialized } = useAuth();
const { isInitialized: instanceInitialized } = useInstance();
const [shareImageDialogOpen, setShareImageDialogOpen] = useState(false);
const params = useParams();
const location = useLocation();
const { state: locationState, hash } = location;
+ const parentPage = typeof locationState?.from === "string" ? locationState.from : undefined;
+ const handleShareImageOpen = useCallback(() => setShareImageDialogOpen(true), []);
// Detect share mode from the route parameter.
const shareToken = params.token;
@@ -43,6 +64,11 @@ const MemoDetail = () => {
const error = isShareMode ? shareError : directError;
const isLoading = isShareMode ? shareLoading : directLoading;
const memoName = memo?.name ?? memoNameFromParams;
+ const displayMemo = useReactMemo(() => {
+ if (!memo) return undefined;
+ if (!isShareMode) return memo;
+ return { ...memo, attachments: withShareAttachmentLinks(memo.attachments as Attachment[], shareToken!) };
+ }, [isShareMode, memo, shareToken]);
useMemoDetailError({
error: error as Error | null,
@@ -82,29 +108,19 @@ const MemoDetail = () => {
// Start the permitted requests as soon as routing is unlocked, but do not
// expose content before tag-blur and instance display settings settle.
- if (isLoading || !memo || !authInitialized || !instanceInitialized) {
+ if (isLoading || !memo || !displayMemo || !authInitialized || !instanceInitialized) {
return null;
}
-
- // In share mode, rewrite attachment URLs to include the share token for unauthenticated access.
- const displayMemo = isShareMode
- ? { ...memo, attachments: withShareAttachmentLinks(memo.attachments as Attachment[], shareToken!) }
- : memo;
const mentionResolutionContents = [displayMemo.content, ...comments.map((comment) => comment.content)];
const userResolutionNames = Array.from(
new Set([displayMemo, ...comments].flatMap((item) => [item.creator, ...(item.reactions ?? []).map((reaction) => reaction.creator)])),
);
-
return (
-
- {!md && (
-
- setShareImageDialogOpen(true)} />
-
- )}
+
-
-
+
+
+
{!isShareMode && parentMemo && (
{
key={`${displayMemo.name}-${displayMemo.updateTime}`}
memo={displayMemo}
compact={false}
- parentPage={locationState?.from}
+ parentPage={parentPage}
shareImageDialogOpen={shareImageDialogOpen}
showCreator
showVisibility
@@ -133,18 +149,13 @@ const MemoDetail = () => {
)}
- {md && (
-
- setShareImageDialogOpen(true)} />
-
- )}
diff --git a/web/src/pages/NotFound.tsx b/web/src/pages/NotFound.tsx
index e09dfc2e..889103f4 100644
--- a/web/src/pages/NotFound.tsx
+++ b/web/src/pages/NotFound.tsx
@@ -1,9 +1,6 @@
-import MobileHeader from "@/components/MobileHeader";
-
const NotFound = () => {
return (
-
{"The page you are looking for can't be found."}
404
diff --git a/web/src/pages/PermissionDenied.tsx b/web/src/pages/PermissionDenied.tsx
index 8742d0bd..da03fef3 100644
--- a/web/src/pages/PermissionDenied.tsx
+++ b/web/src/pages/PermissionDenied.tsx
@@ -1,9 +1,6 @@
-import MobileHeader from "@/components/MobileHeader";
-
const PermissionDenied = () => {
return (
-
Permission denied
403
diff --git a/web/src/pages/Setting.tsx b/web/src/pages/Setting.tsx
index f5d2e879..ffc6170e 100644
--- a/web/src/pages/Setting.tsx
+++ b/web/src/pages/Setting.tsx
@@ -1,27 +1,16 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
-import MobileHeader from "@/components/MobileHeader";
-import SectionChip from "@/components/Settings/SectionChip";
-import SectionMenuItem from "@/components/Settings/SectionMenuItem";
import {
DEFAULT_SETTING_SECTION,
isSettingSectionKey,
SETTINGS_SECTIONS,
- type SettingSectionDefinition,
type SettingSectionKey,
} from "@/components/Settings/settingSections";
import { useInstance } from "@/contexts/InstanceContext";
import useCurrentUser from "@/hooks/useCurrentUser";
-import useMediaQuery from "@/hooks/useMediaQuery";
import { User_Role } from "@/types/proto/api/v1/user_service_pb";
-import { useTranslate } from "@/utils/i18n";
-
-const NAV_GROUP_LABEL_CLASSES = "mb-1 px-2 text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground/55 select-none";
const Setting = () => {
- const t = useTranslate();
- const sm = useMediaQuery("sm");
- const md = useMediaQuery("md");
const location = useLocation();
const user = useCurrentUser();
const { fetchSettings } = useInstance();
@@ -31,7 +20,6 @@ const Setting = () => {
const sectionGroups = useMemo(() => {
const visibleSections = SETTINGS_SECTIONS.filter((section) => section.scope === "basic" || isHost);
return {
- basic: visibleSections.filter((section) => section.scope === "basic"),
admin: visibleSections.filter((section) => section.scope === "admin"),
all: visibleSections,
};
@@ -69,59 +57,12 @@ const Setting = () => {
SETTINGS_SECTIONS[0];
const ActiveSection = selectedSectionDefinition.component;
- const renderSectionMenuItems = (sections: SettingSectionDefinition[]) =>
- sections.map((section) => (
-
- ));
-
- const renderSectionChips = (sections: SettingSectionDefinition[]) =>
- sections.map((section) => (
-
- ));
-
return (
- {!sm && }
-
- {md && (
-
- )}
-
- {!md && (
-
- {t("common.settings")}
-
-
- )}
+
);
diff --git a/web/src/pages/Shortcuts.tsx b/web/src/pages/Shortcuts.tsx
index 79432913..f30eb89c 100644
--- a/web/src/pages/Shortcuts.tsx
+++ b/web/src/pages/Shortcuts.tsx
@@ -32,6 +32,7 @@ import { useAuth } from "@/contexts/AuthContext";
import useCurrentUser from "@/hooks/useCurrentUser";
import useLoading from "@/hooks/useLoading";
import { handleError } from "@/lib/error";
+import { getShortcutId } from "@/lib/memo-views";
import { cn } from "@/lib/utils";
import { Shortcut, ShortcutSchema } from "@/types/proto/api/v1/shortcut_service_pb";
import { useTranslate } from "@/utils/i18n";
@@ -176,11 +177,6 @@ const filterFields = [
'timestamp("2025-01-01T00:00:00Z")',
];
-const getShortcutId = (name: string): string => {
- const parts = name.split("/");
- return parts.length === 4 ? parts[3] : name;
-};
-
const createEmptyShortcut = () =>
create(ShortcutSchema, {
name: "",
diff --git a/web/src/pages/UserProfile.tsx b/web/src/pages/UserProfile.tsx
index 579fdf17..a8ed206c 100644
--- a/web/src/pages/UserProfile.tsx
+++ b/web/src/pages/UserProfile.tsx
@@ -1,5 +1,5 @@
import copy from "copy-to-clipboard";
-import { ExternalLinkIcon, LayoutListIcon, MapIcon } from "lucide-react";
+import { ExternalLinkIcon } from "lucide-react";
import { Suspense } from "react";
import { toast } from "react-hot-toast";
import { useParams, useSearchParams } from "react-router-dom";
@@ -7,7 +7,6 @@ import MemoView from "@/components/MemoView";
import PagedMemoList, { getMemoKey } from "@/components/PagedMemoList";
import UserAvatar from "@/components/UserAvatar";
import { Button } from "@/components/ui/button";
-import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { useMemoFilters, useMemoSorting } from "@/hooks";
import { useUser } from "@/hooks/useUserQueries";
import { State } from "@/types/proto/api/v1/common_pb";
@@ -49,7 +48,7 @@ const ProfileHeader = ({ user, onCopyProfileLink, shareLabel }: { user: User; on
const UserProfile = () => {
const t = useTranslate();
const username = useParams().username;
- const [searchParams, setSearchParams] = useSearchParams();
+ const [searchParams] = useSearchParams();
const activeTab = (searchParams.get("view") === "map" ? "map" : "memos") as TabView;
const { data: user, isLoading, error } = useUser(`users/${username}`, { enabled: !!username });
@@ -75,13 +74,6 @@ const UserProfile = () => {
toast.success(t("message.copied"));
};
- const toggleTab = (view: TabView) => {
- setSearchParams((prev) => {
- view === "map" ? prev.set("view", "map") : prev.delete("view");
- return prev;
- });
- };
-
if (isLoading) return null;
return (
@@ -90,24 +82,7 @@ const UserProfile = () => {
<>
-
-
- toggleTab(value as TabView)} variant="underline">
-
-
-
- {t("common.memos")}
-
-
-
- {t("common.map")}
-
-
-
-
-
-
-
+
{activeTab === "memos" ? (
void;
- activityStats: Record;
- timeBasis: MemoTimeBasis;
}
export interface StatisticsData {
diff --git a/web/tests/about-page.test.tsx b/web/tests/about-page.test.tsx
index a0af2ce3..29f5fa52 100644
--- a/web/tests/about-page.test.tsx
+++ b/web/tests/about-page.test.tsx
@@ -1,5 +1,7 @@
-import { render, screen } from "@testing-library/react";
+import { render, screen, waitFor } from "@testing-library/react";
+import { MemoryRouter, Route, Routes } from "react-router-dom";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import AboutDialog from "@/components/AboutDialog";
import About from "@/pages/About";
const mockInstance = {
@@ -12,11 +14,28 @@ const mockInstance = {
},
generalSetting: {} as { customProfile?: { title: string; description: string; logoUrl: string } },
};
+const pageState = vi.hoisted(() => ({
+ authInitialized: false,
+ currentUser: { name: "users/test" } as { name: string } | undefined,
+ setAboutOpen: vi.fn(),
+}));
vi.mock("@/contexts/InstanceContext", () => ({
useInstance: () => mockInstance,
}));
+vi.mock("@/contexts/AppSidebarContext", () => ({
+ useAppSidebar: () => ({ setAboutOpen: pageState.setAboutOpen }),
+}));
+
+vi.mock("@/contexts/AuthContext", () => ({
+ useAuth: () => ({ isInitialized: pageState.authInitialized }),
+}));
+
+vi.mock("@/hooks/useCurrentUser", () => ({
+ default: () => pageState.currentUser,
+}));
+
vi.mock("@/utils/i18n", () => ({
useTranslate: () => (key: string) =>
(
@@ -27,8 +46,13 @@ vi.mock("@/utils/i18n", () => ({
)[key] ?? key,
}));
-describe("", () => {
+const renderAbout = () => render();
+
+describe("", () => {
beforeEach(() => {
+ pageState.authInitialized = false;
+ pageState.currentUser = { name: "users/test" };
+ pageState.setAboutOpen.mockReset();
mockInstance.profile = {
version: "0.25.0",
commit: "0123456789abcdef0123456789abcdef01234567",
@@ -44,7 +68,7 @@ describe("", () => {
});
it("renders the identity hero with linked version and commit chips", () => {
- render();
+ renderAbout();
expect(screen.getByRole("heading", { name: "Memos" })).toBeInTheDocument();
expect(screen.getByText(/Capture first/i)).toBeInTheDocument();
@@ -53,21 +77,21 @@ describe("", () => {
"href",
"https://github.com/usememos/memos/commit/0123456789abcdef0123456789abcdef01234567",
);
- expect(screen.getByText(/MIT license/i)).toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "MIT" })).toHaveAttribute("href", "https://github.com/usememos/memos/blob/main/LICENSE");
});
it("links to the usememos.com homepage, docs, API docs, and GitHub repo", () => {
- render();
+ renderAbout();
expect(screen.getByRole("link", { name: /about\.official-website/ })).toHaveAttribute("href", "https://usememos.com/");
expect(screen.getByRole("link", { name: /about\.documents/ })).toHaveAttribute("href", "https://usememos.com/docs");
- expect(screen.getByRole("link", { name: /API Docs/ })).toHaveAttribute("href", "https://usememos.com/docs/api");
- expect(screen.getByRole("link", { name: /Web Clipper/ })).toHaveAttribute("href", "https://github.com/usememos/web-clipper");
+ expect(screen.getByRole("link", { name: /about\.api-docs/ })).toHaveAttribute("href", "https://usememos.com/docs/api");
+ expect(screen.getByRole("link", { name: /about\.web-clipper/ })).toHaveAttribute("href", "https://github.com/usememos/web-clipper");
expect(screen.getByRole("link", { name: /about\.github-repository/ })).toHaveAttribute("href", "https://github.com/usememos/memos");
});
it("does not surface the instance URL, administrator, or birds", () => {
- render();
+ renderAbout();
expect(screen.queryByText("https://notes.example.com")).not.toBeInTheDocument();
expect(screen.queryByText("Administrator")).not.toBeInTheDocument();
@@ -80,7 +104,7 @@ describe("", () => {
mockInstance.profile.version = "dev";
mockInstance.profile.commit = "unknown";
- render();
+ renderAbout();
expect(screen.getByText("dev")).toBeInTheDocument();
expect(screen.queryByText("vdev")).not.toBeInTheDocument();
@@ -90,9 +114,9 @@ describe("", () => {
it("shows the demo badge on demo instances", () => {
mockInstance.profile.demo = true;
- render();
+ renderAbout();
- expect(screen.getByText("Demo")).toBeInTheDocument();
+ expect(screen.getByText("about.demo")).toBeInTheDocument();
});
it("uses custom branding for the identity hero and credits Memos", () => {
@@ -100,19 +124,47 @@ describe("", () => {
customProfile: { title: "Team Notes", description: "Our shared scratchpad.", logoUrl: "/custom-logo.png" },
};
- render();
+ renderAbout();
expect(screen.getByRole("heading", { name: "Team Notes" })).toBeInTheDocument();
expect(screen.getByText("Our shared scratchpad.")).toBeInTheDocument();
expect(screen.getByText("Powered by Memos")).toBeInTheDocument();
});
- it("does not add nested horizontal page padding on mobile", () => {
- const { container } = render();
+ it("renders in a compact dialog instead of a page surface", () => {
+ renderAbout();
- const contentWrapper = container.querySelector("section > div");
+ expect(screen.getByRole("dialog")).toHaveClass("p-0!");
+ expect(screen.getByRole("button", { name: "Close" })).toBeInTheDocument();
+ });
- expect(contentWrapper).toHaveClass("w-full");
- expect(contentWrapper).not.toHaveClass("px-4");
+ it("waits for auth initialization before redirecting the compatibility route", async () => {
+ const view = render(
+
+
+ } />
+ Home route} />
+
Explore route } />
+
+ ,
+ );
+
+ expect(screen.queryByText("Home route")).not.toBeInTheDocument();
+ expect(screen.queryByText("Explore route")).not.toBeInTheDocument();
+ expect(pageState.setAboutOpen).not.toHaveBeenCalled();
+
+ pageState.authInitialized = true;
+ view.rerender(
+
+
+ } />
+ Home route } />
+ Explore route } />
+
+ ,
+ );
+
+ await waitFor(() => expect(screen.getByText("Home route")).toBeInTheDocument());
+ expect(pageState.setAboutOpen).toHaveBeenCalledWith(true);
});
});
diff --git a/web/tests/app-sidebar-context.test.tsx b/web/tests/app-sidebar-context.test.tsx
new file mode 100644
index 00000000..6904816c
--- /dev/null
+++ b/web/tests/app-sidebar-context.test.tsx
@@ -0,0 +1,45 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { MemoryRouter, useNavigate } from "react-router-dom";
+import { describe, expect, it } from "vitest";
+import { AppSidebarProvider, useAppSidebar } from "@/contexts/AppSidebarContext";
+
+const Harness = () => {
+ const navigate = useNavigate();
+ const { attachmentSection, setAttachmentSection, inboxFilter, setInboxFilter } = useAppSidebar();
+ return (
+
+
+
+
+
+
+
+ );
+};
+
+describe("AppSidebarProvider", () => {
+ it("keeps page controls local and resets them after a route change", () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Select media" }));
+ fireEvent.click(screen.getByRole("button", { name: "Select unread" }));
+ expect(screen.getByTestId("attachment-section")).toHaveTextContent("media");
+ expect(screen.getByTestId("inbox-filter")).toHaveTextContent("unread");
+
+ fireEvent.click(screen.getByRole("button", { name: "Change route" }));
+ expect(screen.getByTestId("attachment-section")).toHaveTextContent("all");
+ expect(screen.getByTestId("inbox-filter")).toHaveTextContent("all");
+ });
+});
diff --git a/web/tests/app-sidebar-logo.test.tsx b/web/tests/app-sidebar-logo.test.tsx
new file mode 100644
index 00000000..9d23a018
--- /dev/null
+++ b/web/tests/app-sidebar-logo.test.tsx
@@ -0,0 +1,180 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { MemoryRouter } from "react-router-dom";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import AppSidebar, { MobileAppHeader } from "@/components/AppSidebar";
+
+const authState = vi.hoisted(() => ({ currentUser: { name: "users/test" } as { name: string } | undefined }));
+const sidebarState = vi.hoisted(() => ({ setAboutOpen: vi.fn() }));
+
+vi.mock("@/components/MemosLogo", () => ({
+ default: () => Memos logo,
+}));
+
+vi.mock("@/components/UserMenu", () => ({
+ default: () => User menu
,
+}));
+
+vi.mock("@/components/StatisticsView", () => ({
+ default: () => Calendar
,
+}));
+
+vi.mock("@/components/AppSidebar/TagsSection", () => ({
+ default: () => Tags
,
+}));
+
+vi.mock("@/contexts/AppSidebarContext", () => ({
+ useAppSidebar: () => ({
+ aboutOpen: false,
+ setAboutOpen: sidebarState.setAboutOpen,
+ attachmentSection: "all",
+ setAttachmentSection: vi.fn(),
+ inboxFilter: "all",
+ setInboxFilter: vi.fn(),
+ memoDetail: undefined,
+ setMemoDetail: vi.fn(),
+ mobileOpen: false,
+ setMobileOpen: vi.fn(),
+ quickFindOpen: false,
+ setQuickFindOpen: vi.fn(),
+ memoScope: "home",
+ setMemoScope: vi.fn(),
+ }),
+}));
+
+vi.mock("@/contexts/AuthContext", () => ({
+ useAuth: () => ({ shortcuts: [], refetchSettings: vi.fn(), isInitialized: true }),
+}));
+
+vi.mock("@/contexts/InstanceContext", () => ({
+ useInstance: () => ({ isInitialized: true }),
+}));
+
+vi.mock("@/contexts/MemoFilterContext", () => ({
+ stringifyFilters: () => "",
+ useMemoFilterContext: () => ({
+ filters: [],
+ shortcut: undefined,
+ setShortcut: vi.fn(),
+ }),
+}));
+
+vi.mock("@/hooks/useCurrentUser", () => ({
+ default: () => authState.currentUser,
+}));
+
+vi.mock("@/hooks/useFilteredMemoStats", () => ({
+ useFilteredMemoStats: () => ({ statistics: { activityStats: {}, timeBasis: "create_time" }, tags: {} }),
+}));
+
+vi.mock("@/hooks/useAttachmentLibrary", () => ({
+ useAttachmentLibraryStats: () => ({ stats: { media: 0, documents: 0, audio: 0, unused: 0 } }),
+}));
+
+vi.mock("@/hooks/useMediaQuery", () => ({
+ default: () => true,
+}));
+
+vi.mock("@/hooks/useUserQueries", () => ({
+ useNotifications: () => ({ data: [] }),
+ useUser: () => ({ data: undefined }),
+}));
+
+vi.mock("@/i18n", () => ({
+ default: { language: "en" },
+}));
+
+vi.mock("@/utils/i18n", () => ({
+ useTranslate: () => (key: string) => key,
+}));
+
+describe("App sidebar logo", () => {
+ beforeEach(() => {
+ authState.currentUser = { name: "users/test" };
+ sidebarState.setAboutOpen.mockReset();
+ });
+
+ it("navigates home instead of opening a global editor", () => {
+ render(
+
+
+ ,
+ );
+
+ const logo = screen.getByRole("link", { name: "Memos logo" });
+ expect(logo).toHaveAttribute("href", "/");
+ expect(screen.queryByRole("button", { name: /create.*memos/i })).not.toBeInTheDocument();
+ expect(screen.queryByText("common.calendar")).not.toBeInTheDocument();
+ });
+
+ it("shows the compact public navigation for a guest", () => {
+ authState.currentUser = undefined;
+ render(
+
+
+ ,
+ );
+
+ expect(screen.getByRole("link", { name: "common.explore" })).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: "common.about" }));
+ expect(sidebarState.setAboutOpen).toHaveBeenCalledWith(true);
+ expect(screen.getByRole("link", { name: "common.sign-in-to-memos" }).closest("footer")).not.toBeNull();
+ expect(screen.queryByRole("link", { name: "common.home" })).not.toBeInTheDocument();
+ });
+
+ it("uses a compact scope menu and places views below the calendar", async () => {
+ render(
+
+
+ ,
+ );
+
+ const calendar = screen.getByText("Calendar");
+ const views = screen.getByText("common.views");
+ expect(calendar.compareDocumentPosition(views) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(screen.getByRole("button", { name: "common.tasks" })).toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: "common.all" })).not.toBeInTheDocument();
+
+ const scopeTrigger = screen.getByRole("button", { name: "common.home" });
+ fireEvent.click(scopeTrigger);
+ expect(await screen.findByRole("menuitem", { name: "common.home" })).toBeInTheDocument();
+ expect(screen.getByRole("menuitem", { name: "common.explore" })).toBeInTheDocument();
+ expect(screen.getByRole("menuitem", { name: "common.archived" })).toBeInTheDocument();
+ });
+
+ it("collapses inactive global destinations and sends the scope icon to Home", async () => {
+ render(
+
+
+ ,
+ );
+
+ const scopeTrigger = screen.getByRole("button", { name: "common.home" });
+ expect(scopeTrigger).toHaveClass("size-[30px]");
+ expect(scopeTrigger).not.toHaveTextContent("common.home");
+
+ const inbox = screen.getByRole("link", { name: "common.inbox" });
+ expect(inbox).toHaveClass("size-[30px]");
+ expect(inbox).not.toHaveTextContent("common.inbox");
+
+ const attachments = screen.getByRole("link", { name: "common.attachments" });
+ expect(attachments).toHaveAttribute("aria-current", "page");
+ expect(attachments).toHaveTextContent("common.attachments");
+
+ fireEvent.click(scopeTrigger);
+ expect(await screen.findByText("Calendar")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "common.home" })).toHaveTextContent("common.home");
+ expect(screen.queryByRole("menuitem", { name: "common.explore" })).not.toBeInTheDocument();
+ });
+
+ it("keeps the mobile brand beside navigation without a duplicate search action", () => {
+ render(
+
+
+ ,
+ );
+
+ expect(screen.getByRole("button", { name: "Open navigation" })).toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "Memos logo" })).toHaveAttribute("href", "/");
+ expect(screen.queryByRole("button", { name: "common.search" })).not.toBeInTheDocument();
+ });
+});
diff --git a/web/tests/app-sidebar-routes.test.ts b/web/tests/app-sidebar-routes.test.ts
new file mode 100644
index 00000000..36746f34
--- /dev/null
+++ b/web/tests/app-sidebar-routes.test.ts
@@ -0,0 +1,21 @@
+import { describe, expect, it } from "vitest";
+import { getSidebarRouteKind } from "@/components/AppSidebar/routes";
+
+describe("sidebar route content", () => {
+ it.each([
+ ["/", "home"],
+ ["/archived", "archived"],
+ ["/explore", "explore"],
+ ["/u/steven", "profile"],
+ ["/shortcuts", "shortcuts"],
+ ["/attachments", "attachments"],
+ ["/inbox", "inbox"],
+ ["/setting", "settings"],
+ ["/memos/abc", "memo"],
+ ["/memos/shares/token", "memo"],
+ ["/about", "empty"],
+ ["/404", "empty"],
+ ])("maps %s to %s content", (path, kind) => {
+ expect(getSidebarRouteKind(path)).toBe(kind);
+ });
+});
diff --git a/web/tests/attachment-library-stats.test.ts b/web/tests/attachment-library-stats.test.ts
new file mode 100644
index 00000000..4632600a
--- /dev/null
+++ b/web/tests/attachment-library-stats.test.ts
@@ -0,0 +1,76 @@
+import { create } from "@bufbuild/protobuf";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { renderHook, waitFor } from "@testing-library/react";
+import { createElement, type PropsWithChildren } from "react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { buildAttachmentLibraryStats, useAttachmentLibraryStats } from "@/hooks/useAttachmentLibrary";
+import {
+ AttachmentSchema,
+ MotionMediaFamily,
+ MotionMediaRole,
+ MotionMediaSchema,
+ type Attachment,
+} from "@/types/proto/api/v1/attachment_service_pb";
+
+const clients = vi.hoisted(() => ({ listAttachments: vi.fn() }));
+
+vi.mock("@/connect", () => ({
+ attachmentServiceClient: { listAttachments: clients.listAttachments },
+}));
+
+const attachment = (name: string, type: string, memo?: string): Attachment =>
+ create(AttachmentSchema, { name: `attachments/${name}`, filename: name, type, memo });
+
+describe("buildAttachmentLibraryStats", () => {
+ beforeEach(() => clients.listAttachments.mockReset());
+
+ it("counts linked attachment types without expanding live-photo pairs", () => {
+ const still = attachment("live.jpg", "image/jpeg", "memos/one");
+ still.motionMedia = create(MotionMediaSchema, {
+ family: MotionMediaFamily.APPLE_LIVE_PHOTO,
+ role: MotionMediaRole.STILL,
+ groupId: "live-photo",
+ });
+ const video = attachment("live.mov", "video/quicktime", "memos/one");
+ video.motionMedia = create(MotionMediaSchema, {
+ family: MotionMediaFamily.APPLE_LIVE_PHOTO,
+ role: MotionMediaRole.VIDEO,
+ groupId: "live-photo",
+ });
+
+ expect(
+ buildAttachmentLibraryStats([
+ still,
+ video,
+ attachment("photo.png", "image/png", "memos/one"),
+ attachment("recording.mp3", "audio/mpeg", "memos/one"),
+ attachment("notes.pdf", "application/pdf", "memos/one"),
+ attachment("unused.png", "image/png"),
+ ]),
+ ).toEqual({
+ unused: 1,
+ media: 2,
+ documents: 1,
+ audio: 1,
+ });
+ });
+
+ it("loads every page before exposing complete sidebar counts", async () => {
+ clients.listAttachments
+ .mockResolvedValueOnce({
+ attachments: [attachment("photo.png", "image/png", "memos/one")],
+ nextPageToken: "1000",
+ })
+ .mockResolvedValueOnce({
+ attachments: [attachment("unused.pdf", "application/pdf")],
+ nextPageToken: "",
+ });
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ const wrapper = ({ children }: PropsWithChildren) => createElement(QueryClientProvider, { client: queryClient }, children);
+ const { result } = renderHook(() => useAttachmentLibraryStats(), { wrapper });
+
+ await waitFor(() => expect(result.current.isComplete).toBe(true));
+ expect(result.current.stats).toEqual({ media: 1, documents: 0, audio: 0, unused: 1 });
+ expect(clients.listAttachments).toHaveBeenCalledTimes(2);
+ });
+});
diff --git a/web/tests/calendar-cell-empty-clickable.test.tsx b/web/tests/calendar-cell-empty-clickable.test.tsx
index 6308e1d5..9b916db5 100644
--- a/web/tests/calendar-cell-empty-clickable.test.tsx
+++ b/web/tests/calendar-cell-empty-clickable.test.tsx
@@ -30,6 +30,7 @@ describe("CalendarCell empty-day clickability", () => {
const button = screen.getByRole("button", { name: /May 1, 2025/ });
expect(button).toHaveAttribute("tabindex", "0");
expect(button).toHaveAttribute("aria-disabled", "false");
+ expect(button).toHaveClass("bg-transparent");
});
it("still renders a populated in-month day as interactive", () => {
@@ -40,6 +41,22 @@ describe("CalendarCell empty-day clickability", () => {
expect(onClick).toHaveBeenCalledWith("2025-05-01");
});
+ it("marks today with a dot without changing the numeral weight", () => {
+ render( {}} />);
+
+ const button = screen.getByRole("button", { name: /May 1, 2025/ });
+ expect(button).not.toHaveClass("font-semibold", "font-bold");
+ expect(button.querySelector('[aria-hidden="true"]')).toHaveClass("rounded-full");
+ });
+
+ it("uses an inset ring for selection without changing the numeral weight", () => {
+ render( {}} />);
+
+ const button = screen.getByRole("button", { name: /selected/ });
+ expect(button).toHaveClass("ring-2", "ring-inset");
+ expect(button).not.toHaveClass("font-semibold", "font-bold");
+ });
+
it("does not render out-of-month days as interactive (no role=button)", () => {
render(
{}} />,
diff --git a/web/tests/date-filter-navigation.test.tsx b/web/tests/date-filter-navigation.test.tsx
new file mode 100644
index 00000000..a9b4e852
--- /dev/null
+++ b/web/tests/date-filter-navigation.test.tsx
@@ -0,0 +1,39 @@
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { MemoryRouter, useLocation } from "react-router-dom";
+import { describe, expect, it } from "vitest";
+import { MemoFilterProvider } from "@/contexts/MemoFilterContext";
+import { useDateFilterNavigation } from "@/hooks/useDateFilterNavigation";
+
+const Harness = () => {
+ const location = useLocation();
+ const navigateToDate = useDateFilterNavigation();
+ return (
+ <>
+
+
+ >
+ );
+};
+
+describe("useDateFilterNavigation", () => {
+ it("preserves unrelated query parameters while replacing the date filter", async () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Select date" }));
+
+ await waitFor(() => {
+ const params = new URLSearchParams(screen.getByTestId("search").textContent ?? "");
+ expect(params.get("view")).toBe("map");
+ expect(params.get("filter")).toContain("tagSearch:work");
+ expect(params.get("filter")).toContain("displayTime:2026-08-02");
+ });
+ });
+});
diff --git a/web/tests/global-memo-editor.test.tsx b/web/tests/global-memo-editor.test.tsx
deleted file mode 100644
index 31425d37..00000000
--- a/web/tests/global-memo-editor.test.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { fireEvent, render, screen } from "@testing-library/react";
-import { describe, expect, it, vi } from "vitest";
-import { loadMemoEditor } from "@/components/MemoEditor/loader";
-import { GlobalMemoEditorProvider, useGlobalMemoEditor } from "@/contexts/GlobalMemoEditorContext";
-
-const authState = vi.hoisted(() => ({
- currentUser: undefined as { name: string } | undefined,
-}));
-
-vi.mock("@/components/MemoEditor/loader", () => ({
- loadMemoEditor: vi.fn(async () => ({
- default: ({ initialFocusMode, onFocusModeExit }: { initialFocusMode?: boolean; onFocusModeExit?: () => void }) => (
-
-
-
- ),
- })),
-}));
-
-vi.mock("@/hooks/useCurrentUser", () => ({
- default: () => authState.currentUser,
-}));
-
-vi.mock("@/utils/i18n", () => ({ useTranslate: () => (key: string) => key }));
-
-function Trigger() {
- const { openEditor } = useGlobalMemoEditor();
- return (
-
- );
-}
-
-describe("GlobalMemoEditorProvider", () => {
- it("opens the shared editor in focus mode and closes when focus mode exits", async () => {
- authState.currentUser = { name: "users/test" };
-
- render(
-
-
- ,
- );
-
- fireEvent.click(screen.getByRole("button", { name: "Open editor" }));
-
- const editor = await screen.findByTestId("global-editor");
- expect(editor).toHaveAttribute("data-focus-mode", "true");
-
- fireEvent.click(screen.getByRole("button", { name: "Exit focus mode" }));
- expect(screen.queryByTestId("global-editor")).not.toBeInTheDocument();
- });
-
- it("does not load or open the editor for an unauthenticated user", () => {
- authState.currentUser = undefined;
-
- render(
-
-
- ,
- );
-
- fireEvent.click(screen.getByRole("button", { name: "Open editor" }));
-
- expect(loadMemoEditor).not.toHaveBeenCalled();
- expect(screen.queryByTestId("global-editor")).not.toBeInTheDocument();
- });
-});
diff --git a/web/tests/memo-detail-sidebar.test.tsx b/web/tests/memo-detail-sidebar.test.tsx
index e35626f9..4623b2c6 100644
--- a/web/tests/memo-detail-sidebar.test.tsx
+++ b/web/tests/memo-detail-sidebar.test.tsx
@@ -5,30 +5,20 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import MemoDetailSidebar from "@/components/MemoDetailSidebar/MemoDetailSidebar";
import { AttachmentSchema } from "@/types/proto/api/v1/attachment_service_pb";
import { State } from "@/types/proto/api/v1/common_pb";
-import { LocationSchema, MemoSchema, Visibility } from "@/types/proto/api/v1/memo_service_pb";
+import {
+ LocationSchema,
+ MemoRelation_MemoSchema,
+ MemoRelation_Type,
+ MemoRelationSchema,
+ MemoSchema,
+ Visibility,
+} from "@/types/proto/api/v1/memo_service_pb";
+const copyToClipboard = vi.hoisted(() => vi.fn());
const updateMemo = vi.hoisted(() => vi.fn());
-vi.mock("copy-to-clipboard", () => ({ default: vi.fn() }));
+vi.mock("copy-to-clipboard", () => ({ default: copyToClipboard }));
vi.mock("react-hot-toast", () => ({ default: { success: vi.fn() } }));
-vi.mock("@/components/ui/tooltip", () => ({
- Tooltip: ({ children }: { children: React.ReactNode }) => <>{children}>,
- TooltipContent: ({ children }: { children: React.ReactNode }) => <>{children}>,
- TooltipTrigger: ({ children, render }: { children: React.ReactNode; render: React.ReactElement }) => (
- <>
- {render}
- {children}
- >
- ),
-}));
-vi.mock("@/components/MemoEditor/Toolbar/VisibilitySelector", () => ({
- default: ({ onChange }: { onChange: (visibility: Visibility) => void }) => (
-
- ),
-}));
-vi.mock("@/components/UserAvatar", () => ({ default: () => }));
vi.mock("@/components/MemoDetailSidebar/MemoOutline", () => ({
default: ({ headings }: { headings: unknown[] }) => {headings.length}
,
}));
@@ -37,19 +27,16 @@ vi.mock("@/components/MemoMetadata/Relation/useResolvedRelationMemos", () => ({
vi.mock("@/contexts/InstanceContext", () => ({ useInstance: () => ({ profile: { instanceUrl: "https://memos.example" } }) }));
vi.mock("@/hooks/useCurrentUser", () => ({ default: () => ({ name: "users/alice" }) }));
vi.mock("@/hooks/useMemoQueries", () => ({ useUpdateMemo: () => ({ mutateAsync: updateMemo }) }));
-vi.mock("@/hooks/useUserQueries", () => ({
- useUser: () => ({ data: { username: "alice", displayName: "Alice", avatarUrl: "" } }),
-}));
vi.mock("@/utils/i18n", () => ({ useTranslate: () => (key: string) => key }));
-vi.mock("@/i18n", () => ({ default: { language: "en-US" } }));
describe("MemoDetailSidebar", () => {
beforeEach(() => {
+ copyToClipboard.mockReset();
updateMemo.mockReset();
updateMemo.mockResolvedValue(undefined);
});
- it("renders the property rail and wires editable quick actions", async () => {
+ it("renders concise actions, outline, and backlinks without repeating body metadata", async () => {
const memo = create(MemoSchema, {
name: "memos/detail",
creator: "users/alice",
@@ -66,6 +53,18 @@ describe("MemoDetailSidebar", () => {
size: 2048n,
}),
],
+ relations: [
+ create(MemoRelationSchema, {
+ type: MemoRelation_Type.REFERENCE,
+ memo: create(MemoRelation_MemoSchema, { name: "memos/detail" }),
+ relatedMemo: create(MemoRelation_MemoSchema, { name: "memos/outgoing", snippet: "Outgoing reference" }),
+ }),
+ create(MemoRelationSchema, {
+ type: MemoRelation_Type.REFERENCE,
+ memo: create(MemoRelation_MemoSchema, { name: "memos/incoming", snippet: "Incoming backlink" }),
+ relatedMemo: create(MemoRelation_MemoSchema, { name: "memos/detail" }),
+ }),
+ ],
});
const onShareImageOpen = vi.fn();
@@ -75,15 +74,17 @@ describe("MemoDetailSidebar", () => {
,
);
- expect(screen.getByText("common.visibility")).toBeInTheDocument();
- expect(screen.getByText("common.created-at")).toBeInTheDocument();
- expect(screen.getByText("common.author")).toBeInTheDocument();
- expect(screen.getByText("common.location")).toBeInTheDocument();
- expect(screen.getByText("common.tags")).toBeInTheDocument();
- expect(screen.getByText("common.attachments")).toBeInTheDocument();
+ expect(screen.getByText("common.actions")).toBeInTheDocument();
expect(screen.getByText("memo.outline")).toBeInTheDocument();
- expect(screen.getByText("release/0.30")).toBeInTheDocument();
- expect(screen.getByRole("link", { name: /release-notes\.pdf/ })).toBeInTheDocument();
+ expect(screen.getByText("common.referenced-by")).toBeInTheDocument();
+ expect(screen.getByRole("link", { name: "Incoming backlink" })).toBeInTheDocument();
+ expect(screen.queryByText("Outgoing reference")).not.toBeInTheDocument();
+ expect(screen.queryByText("common.visibility")).not.toBeInTheDocument();
+ expect(screen.queryByText("common.created-at")).not.toBeInTheDocument();
+ expect(screen.queryByText("common.location")).not.toBeInTheDocument();
+ expect(screen.queryByText("common.attachments")).not.toBeInTheDocument();
+ expect(screen.queryByText("release-notes.pdf")).not.toBeInTheDocument();
+ expect(screen.queryByText("release/0.30")).not.toBeInTheDocument();
expect(screen.getByTestId("outline")).toHaveTextContent("2");
fireEvent.click(screen.getByRole("button", { name: "common.pin" }));
@@ -91,17 +92,64 @@ describe("MemoDetailSidebar", () => {
expect(updateMemo).toHaveBeenCalledWith({ update: { name: "memos/detail", pinned: true }, updateMask: ["pinned"] }),
);
- fireEvent.click(screen.getByRole("button", { name: "visibility-selector" }));
- await waitFor(() =>
- expect(updateMemo).toHaveBeenCalledWith({
- update: { name: "memos/detail", visibility: Visibility.PRIVATE },
- updateMask: ["visibility"],
- }),
- );
+ fireEvent.click(screen.getByRole("button", { name: "common.share" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "memo.copy-link" }));
+ expect(copyToClipboard).toHaveBeenCalledWith("https://memos.example/memos/detail");
- fireEvent.click(screen.getByRole("button", { name: "memo.share.open-image" }));
+ fireEvent.click(screen.getByRole("button", { name: "common.share" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "memo.share.open-image" }));
expect(onShareImageOpen).toHaveBeenCalledTimes(1);
- fireEvent.click(screen.getByRole("button", { name: "memo.share.open-panel" }));
+
+ fireEvent.click(screen.getByRole("button", { name: "common.share" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "memo.share.open-panel" }));
expect(screen.getByTestId("share-panel")).toBeInTheDocument();
});
+
+ it("keeps a readonly simple memo useful with only the share action", () => {
+ const memo = create(MemoSchema, {
+ name: "memos/readonly",
+ creator: "users/alice",
+ state: State.NORMAL,
+ visibility: Visibility.PUBLIC,
+ content: "# Overview\n\nBody",
+ relations: [
+ create(MemoRelationSchema, {
+ type: MemoRelation_Type.REFERENCE,
+ memo: create(MemoRelation_MemoSchema, { name: "memos/incoming", snippet: "Private backlink" }),
+ relatedMemo: create(MemoRelation_MemoSchema, { name: "memos/readonly" }),
+ }),
+ ],
+ });
+
+ render(
+
+
+ ,
+ );
+
+ expect(screen.getByRole("button", { name: "common.share" })).toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: "common.pin" })).not.toBeInTheDocument();
+ expect(screen.queryByText("memo.outline")).not.toBeInTheDocument();
+ expect(screen.queryByText("common.referenced-by")).not.toBeInTheDocument();
+ expect(screen.queryByText("Private backlink")).not.toBeInTheDocument();
+ });
+
+ it("keeps the outline available for readonly memos with multiple headings", () => {
+ const memo = create(MemoSchema, {
+ name: "memos/readonly-outline",
+ creator: "users/alice",
+ state: State.NORMAL,
+ visibility: Visibility.PUBLIC,
+ content: "# Overview\n\nBody\n\n## Details\n\nMore",
+ });
+
+ render(
+
+
+ ,
+ );
+
+ expect(screen.getByText("memo.outline")).toBeInTheDocument();
+ expect(screen.getByTestId("outline")).toHaveTextContent("2");
+ });
});
diff --git a/web/tests/memo-filter-context.test.tsx b/web/tests/memo-filter-context.test.tsx
new file mode 100644
index 00000000..b004d0e9
--- /dev/null
+++ b/web/tests/memo-filter-context.test.tsx
@@ -0,0 +1,45 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { MemoryRouter } from "react-router-dom";
+import { describe, expect, it } from "vitest";
+import { MemoFilterProvider, parseFilterQuery, useMemoFilterContext } from "@/contexts/MemoFilterContext";
+import { BUILTIN_TASKS_VIEW_ID } from "@/lib/memo-views";
+
+const Harness = () => {
+ const { filters, setFilters, setShortcut, shortcut } = useMemoFilterContext();
+ return (
+
+
+
+
+
+
+ );
+};
+
+describe("MemoFilterProvider", () => {
+ it("keeps encoded values containing colons intact", () => {
+ expect(parseFilterQuery("contentSearch:https://example.com:8080/path")).toEqual([
+ { factor: "contentSearch", value: "https://example.com:8080/path" },
+ ]);
+ });
+
+ it("keeps search filters when selecting a view", () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Search plan" }));
+ fireEvent.click(screen.getByRole("button", { name: "Select Tasks" }));
+
+ expect(screen.getByTestId("filters")).toHaveTextContent('[{"factor":"contentSearch","value":"plan"}]');
+ expect(screen.getByTestId("shortcut")).toHaveTextContent(BUILTIN_TASKS_VIEW_ID);
+ });
+});
diff --git a/web/tests/memo-views.test.ts b/web/tests/memo-views.test.ts
new file mode 100644
index 00000000..6ad3d653
--- /dev/null
+++ b/web/tests/memo-views.test.ts
@@ -0,0 +1,93 @@
+import { describe, expect, it } from "vitest";
+import { buildMemoFilter } from "@/hooks/useMemoFilters";
+import {
+ BUILTIN_TASKS_VIEW_FILTER,
+ BUILTIN_TASKS_VIEW_ID,
+ getMemoScopePath,
+ getShortcutId,
+ isMemoScopeRoute,
+ resolveMemoScope,
+} from "@/lib/memo-views";
+import { Visibility } from "@/types/proto/api/v1/memo_service_pb";
+
+describe("memo scopes", () => {
+ it("resolves collection, profile, and detail routes", () => {
+ expect(resolveMemoScope("/archived")).toBe("archived");
+ expect(resolveMemoScope("/explore")).toBe("explore");
+ expect(resolveMemoScope("/u/steven", { currentUsername: "steven" })).toBe("home");
+ expect(resolveMemoScope("/u/maya", { currentUsername: "steven" })).toBe("explore");
+ expect(resolveMemoScope("/memos/123", { detailFrom: "/archived?filter=tagSearch%3Awork" })).toBe("archived");
+ expect(resolveMemoScope("/memos/123", { memoArchived: true })).toBe("archived");
+ expect(resolveMemoScope("/settings", { fallback: "explore" })).toBe("explore");
+ });
+
+ it("maps only the three collection routes to memo scopes", () => {
+ expect(isMemoScopeRoute("/")).toBe(true);
+ expect(isMemoScopeRoute("/explore")).toBe(true);
+ expect(isMemoScopeRoute("/archived")).toBe(true);
+ expect(isMemoScopeRoute("/attachments")).toBe(false);
+ expect(getMemoScopePath("home")).toBe("/");
+ expect(getMemoScopePath("explore")).toBe("/explore");
+ expect(getMemoScopePath("archived")).toBe("/archived");
+ });
+});
+
+describe("memo views", () => {
+ it("uses a collision-safe built-in Tasks view", () => {
+ expect(BUILTIN_TASKS_VIEW_ID).not.toBe("tasks");
+ expect(BUILTIN_TASKS_VIEW_FILTER).toBe("has_task_list && has_incomplete_tasks");
+ expect(getShortcutId("users/steven/shortcuts/work")).toBe("work");
+ });
+
+ it("composes Tasks with search, tags, creator, and visibility", () => {
+ expect(
+ buildMemoFilter({
+ creatorName: "users/steven",
+ currentShortcut: BUILTIN_TASKS_VIEW_ID,
+ filters: [
+ { factor: "contentSearch", value: "plan" },
+ { factor: "tagSearch", value: "work" },
+ ],
+ includePinned: false,
+ visibilities: [Visibility.PUBLIC],
+ }),
+ ).toBe(
+ 'creator == "users/steven" && has_task_list && has_incomplete_tasks && content.contains("plan") && tag in ["work"] && visibility in ["PUBLIC"]',
+ );
+ });
+
+ it("uses a custom shortcut filter when Tasks is not selected", () => {
+ expect(
+ buildMemoFilter({
+ currentShortcut: "work",
+ filters: [],
+ includePinned: false,
+ selectedShortcutFilter: 'tag in ["work"]',
+ }),
+ ).toBe('tag in ["work"]');
+ });
+
+ it("builds display-time filters from valid local calendar-day boundaries", () => {
+ const start = new Date(2026, 7, 2);
+ const end = new Date(start);
+ end.setDate(end.getDate() + 1);
+
+ expect(
+ buildMemoFilter({
+ filters: [{ factor: "displayTime", value: "2026-08-02" }],
+ includePinned: false,
+ }),
+ ).toBe(
+ `created_ts >= timestamp(${Math.floor(start.getTime() / 1000)}) && created_ts < timestamp(${Math.floor(end.getTime() / 1000)})`,
+ );
+ });
+
+ it("ignores invalid display-time filter values", () => {
+ expect(
+ buildMemoFilter({
+ filters: [{ factor: "displayTime", value: "2026-02-30" }],
+ includePinned: false,
+ }),
+ ).toBeUndefined();
+ });
+});
diff --git a/web/tests/month-navigator.test.tsx b/web/tests/month-navigator.test.tsx
new file mode 100644
index 00000000..75921283
--- /dev/null
+++ b/web/tests/month-navigator.test.tsx
@@ -0,0 +1,23 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import { MonthNavigator } from "@/components/StatisticsView/MonthNavigator";
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ i18n: { language: "en" }, t: (key: string) => key }),
+}));
+
+describe("MonthNavigator", () => {
+ it("keeps only previous and next month actions", () => {
+ const onMonthChange = vi.fn();
+ render();
+
+ expect(screen.getByRole("heading", { name: "August 2026" })).toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: "Select month" })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole("button", { name: "common.previous-month" }));
+ expect(onMonthChange).toHaveBeenCalledWith("2026-07");
+
+ fireEvent.click(screen.getByRole("button", { name: "common.next-month" }));
+ expect(onMonthChange).toHaveBeenCalledWith("2026-09");
+ });
+});
diff --git a/web/tests/navigation-logo-create.test.tsx b/web/tests/navigation-logo-create.test.tsx
deleted file mode 100644
index 2ffa4fac..00000000
--- a/web/tests/navigation-logo-create.test.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { fireEvent, render, screen } from "@testing-library/react";
-import { MemoryRouter } from "react-router-dom";
-import { describe, expect, it, vi } from "vitest";
-import Navigation from "@/components/Navigation";
-
-const mocks = vi.hoisted(() => ({
- openEditor: vi.fn(),
-}));
-
-vi.mock("@/components/MemosLogo", () => ({
- default: () => Memos logo,
-}));
-
-vi.mock("@/components/UserMenu", () => ({
- default: () => User menu
,
-}));
-
-vi.mock("@/contexts/GlobalMemoEditorContext", () => ({
- useGlobalMemoEditor: () => ({ isOpen: false, openEditor: mocks.openEditor }),
-}));
-
-vi.mock("@/hooks/useCurrentUser", () => ({
- default: () => ({ name: "users/test" }),
-}));
-
-vi.mock("@/hooks/useUserQueries", () => ({
- useNotifications: () => ({ data: [] }),
-}));
-
-vi.mock("@/utils/i18n", () => ({
- useTranslate: () => (key: string) => key,
-}));
-
-describe("Navigation logo", () => {
- it("opens the global memo editor for an authenticated user", () => {
- render(
-
-
- ,
- );
-
- fireEvent.click(screen.getByRole("button", { name: "common.create common.memos" }));
-
- expect(mocks.openEditor).toHaveBeenCalledTimes(1);
- });
-});
diff --git a/web/tests/quick-find.test.ts b/web/tests/quick-find.test.ts
new file mode 100644
index 00000000..ab23c02b
--- /dev/null
+++ b/web/tests/quick-find.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from "vitest";
+import { buildQuickFindFilters, isQuickFindCollectionRoute } from "@/components/AppSidebar/QuickFindDialog";
+import { type MemoFilter, replaceFiltersByFactor } from "@/contexts/MemoFilterContext";
+
+describe("Quick Find", () => {
+ const scopedFilters: MemoFilter[] = [
+ { factor: "tagSearch", value: "work" },
+ { factor: "displayTime", value: "2026-08-03" },
+ { factor: "contentSearch", value: "old" },
+ ];
+
+ it("replaces search terms while preserving date and tag facets in a collection", () => {
+ expect(buildQuickFindFilters("project plan project", scopedFilters, true)).toEqual([
+ { factor: "tagSearch", value: "work" },
+ { factor: "displayTime", value: "2026-08-03" },
+ { factor: "contentSearch", value: "project" },
+ { factor: "contentSearch", value: "plan" },
+ ]);
+ });
+
+ it("starts a clean All search outside collection routes", () => {
+ expect(buildQuickFindFilters("project", scopedFilters, false)).toEqual([{ factor: "contentSearch", value: "project" }]);
+ expect(isQuickFindCollectionRoute("/attachments")).toBe(false);
+ expect(isQuickFindCollectionRoute("/archived")).toBe(true);
+ expect(isQuickFindCollectionRoute("/u/steven")).toBe(true);
+ });
+
+ it("replaces only the selected date facet", () => {
+ expect(replaceFiltersByFactor(scopedFilters, "displayTime", [{ factor: "displayTime", value: "2026-08-02" }])).toEqual([
+ { factor: "tagSearch", value: "work" },
+ { factor: "contentSearch", value: "old" },
+ { factor: "displayTime", value: "2026-08-02" },
+ ]);
+ });
+});