A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
feat(mobile): make the bookmark edit UIs look more native
Mohamed Bassemec7ef00fc1c2
diff --git a/apps/mobile/app/dashboard/_layout.tsx b/apps/mobile/app/dashboard/_layout.tsxindex 78fd7c60..00872b92 100644--- a/apps/mobile/app/dashboard/_layout.tsx+++ b/apps/mobile/app/dashboard/_layout.tsx@@ -80,26 +80,27 @@ export default function Dashboard() {name="bookmarks/[slug]/manage_tags"options={{headerTitle: "Manage Tags",- headerBackTitle: "Back",- headerTransparent: true,- presentation: "modal",+ headerTransparent: false,+ presentation: "formSheet",+ sheetGrabberVisible: true,}}/><Stack.Screenname="bookmarks/[slug]/manage_lists"options={{headerTitle: "Manage Lists",- headerBackTitle: "Back",- headerTransparent: true,- presentation: "modal",+ headerTransparent: false,+ presentation: "formSheet",+ sheetGrabberVisible: true,}}/><Stack.Screenname="bookmarks/[slug]/info"options={{- headerBackTitle: "Back",- headerTransparent: true,- presentation: "modal",+ headerTitle: "Info",+ headerTransparent: false,+ presentation: "formSheet",+ sheetGrabberVisible: true,}}/><Stack.Screendiff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsxindex 744b7f7d..821e58d1 100644--- a/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/info.tsx@@ -1,23 +1,30 @@import React from "react";-import { ActivityIndicator, Alert, Pressable, View } from "react-native";+import {+ ActivityIndicator,+ Alert,+ Pressable,+ TextInput,+ View,+} from "react-native";import {KeyboardAwareScrollView,KeyboardGestureArea,} from "react-native-keyboard-controller";-import { useSafeAreaInsets } from "react-native-safe-area-context";+import * as Haptics from "expo-haptics";import { router, Stack, useLocalSearchParams } from "expo-router";import BookmarkTextMarkdown from "@/components/bookmarks/BookmarkTextMarkdown";import TagPill from "@/components/bookmarks/TagPill";import FullPageError from "@/components/FullPageError";-import { Button } from "@/components/ui/Button";-import ChevronRight from "@/components/ui/ChevronRight";-import { Divider } from "@/components/ui/Divider";import FullPageSpinner from "@/components/ui/FullPageSpinner";-import { Input } from "@/components/ui/Input";+import {+ GroupedSection,+ NavigationRow,+ RowSeparator,+} from "@/components/ui/GroupedList";import { Skeleton } from "@/components/ui/Skeleton";import { Text } from "@/components/ui/Text";import { useToast } from "@/components/ui/Toast";-import { cn } from "@/lib/utils";+import { useColorScheme } from "@/lib/useColorScheme";import { ChevronUp, RefreshCw, Sparkles, Trash2 } from "lucide-react-native";import {@@ -30,78 +37,7 @@ import { useWhoAmI } from "@karakeep/shared-react/hooks/users";import { BookmarkTypes, ZBookmark } from "@karakeep/shared/types/bookmarks";import { isBookmarkStillTagging } from "@karakeep/shared/utils/bookmarkUtils";-function InfoSection({- className,- ...props-}: React.ComponentProps<typeof View>) {- return (- <View- className={cn("flex gap-2 rounded-lg bg-card p-3", className)}- {...props}- />- );-}--function TagList({- bookmark,- readOnly,-}: {- bookmark: ZBookmark;- readOnly: boolean;-}) {- return (- <InfoSection>- {isBookmarkStillTagging(bookmark) ? (- <View className="flex gap-4 pb-3">- <Skeleton className="h-4 w-full" />- <Skeleton className="h-4 w-full" />- </View>- ) : (- bookmark.tags.length > 0 && (- <>- <View className="flex flex-row flex-wrap gap-2 rounded-lg p-2">- {bookmark.tags.map((t) => (- <TagPill key={t.id} tag={t} clickable={!readOnly} />- ))}- </View>- <Divider orientation="horizontal" />- </>- )- )}- {!readOnly && (- <View>- <Pressable- onPress={() =>- router.push(`/dashboard/bookmarks/${bookmark.id}/manage_tags`)- }- className="flex w-full flex-row justify-between gap-3"- >- <Text>Manage Tags</Text>- <ChevronRight />- </Pressable>- </View>- )}- </InfoSection>- );-}--function ManageLists({ bookmark }: { bookmark: ZBookmark }) {- return (- <InfoSection>- <View>- <Pressable- onPress={() =>- router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`)- }- className="flex w-full flex-row justify-between gap-3 rounded-lg"- >- <Text>Manage Lists</Text>- <ChevronRight />- </Pressable>- </View>- </InfoSection>- );-}+// --- Section Components ---function TitleEditor({title,@@ -114,17 +50,18 @@ function TitleEditor({isPending: boolean;disabled?: boolean;}) {+ const { colors } = useColorScheme();return (- <InfoSection>- <Input+ <GroupedSection header="Title">+ <TextInputeditable={!isPending && !disabled}- multiline={false}- numberOfLines={1}- placeholder="Title"+ placeholder="Untitled"+ placeholderTextColor={colors.grey}onChangeText={(text) => setTitle(text)}defaultValue={title ?? ""}+ className="px-4 py-3 text-[17px] leading-6 text-foreground"/>- </InfoSection>+ </GroupedSection>);}@@ -135,22 +72,82 @@ function NotesEditor({disabled,}: {notes: string | null | undefined;- setNotes: (title: string | null) => void;+ setNotes: (note: string | null) => void;isPending: boolean;disabled?: boolean;}) {+ const { colors } = useColorScheme();return (- <InfoSection>- <Input+ <GroupedSection header="Notes">+ <TextInputeditable={!isPending && !disabled}- multiline={true}- placeholder="Notes"- inputClasses="h-24"+ multiline+ placeholder="Add notes..."+ placeholderTextColor={colors.grey}onChangeText={(text) => setNotes(text)}textAlignVertical="top"defaultValue={notes ?? ""}+ className="min-h-[100px] px-4 py-3 text-[17px] leading-6 text-foreground"/>- </InfoSection>+ </GroupedSection>+ );+}++function TagList({+ bookmark,+ readOnly,+}: {+ bookmark: ZBookmark;+ readOnly: boolean;+}) {+ const hasTags = bookmark.tags.length > 0;+ const isTagging = isBookmarkStillTagging(bookmark);++ if (!isTagging && !hasTags && readOnly) {+ return null;+ }++ return (+ <GroupedSection header="Tags">+ {isTagging ? (+ <View className="gap-3 p-4">+ <Skeleton className="h-4 w-full" />+ <Skeleton className="h-4 w-3/4" />+ </View>+ ) : (+ hasTags && (+ <>+ <View className="flex-row flex-wrap gap-2 px-4 py-3">+ {bookmark.tags.map((t) => (+ <TagPill key={t.id} tag={t} clickable={!readOnly} />+ ))}+ </View>+ {!readOnly && <RowSeparator />}+ </>+ )+ )}+ {!readOnly && (+ <NavigationRow+ label="Manage Tags"+ onPress={() =>+ router.push(`/dashboard/bookmarks/${bookmark.id}/manage_tags`)+ }+ />+ )}+ </GroupedSection>+ );+}++function ManageLists({ bookmark }: { bookmark: ZBookmark }) {+ return (+ <GroupedSection header="Lists">+ <NavigationRow+ label="Manage Lists"+ onPress={() =>+ router.push(`/dashboard/bookmarks/${bookmark.id}/manage_lists`)+ }+ />+ </GroupedSection>);}@@ -162,14 +159,12 @@ function AISummarySection({readOnly: boolean;}) {const { toast } = useToast();+ const { colors } = useColorScheme();const [isExpanded, setIsExpanded] = React.useState(false);const { mutate: summarize, isPending: isSummarizing } = useSummarizeBookmark({onSuccess: () => {- toast({- message: "Summary generated successfully!",- showProgress: false,- });+ toast({ message: "Summary generated!", showProgress: false });},onError: () => {toast({@@ -182,10 +177,7 @@ function AISummarySection({const { mutate: resummarize, isPending: isResummarizing } =useSummarizeBookmark({onSuccess: () => {- toast({- message: "Summary regenerated successfully!",- showProgress: false,- });+ toast({ message: "Summary regenerated!", showProgress: false });},onError: () => {toast({@@ -198,10 +190,7 @@ function AISummarySection({const { mutate: updateBookmark, isPending: isDeletingSummary } =useUpdateBookmark({onSuccess: () => {- toast({- message: "Summary deleted!",- showProgress: false,- });+ toast({ message: "Summary deleted!", showProgress: false });},onError: () => {toast({@@ -211,108 +200,97 @@ function AISummarySection({},});- // Only show for LINK bookmarksif (bookmark.content.type !== BookmarkTypes.LINK) {return null;}- // If there's a summary, show itif (bookmark.summary) {return (- <InfoSection>- <View className={isExpanded ? "" : "max-h-20 overflow-hidden"}>- <BookmarkTextMarkdown text={bookmark.summary} />- </View>- {!isExpanded && (- <Pressable- onPress={() => setIsExpanded(true)}- className="rounded-md bg-gray-100 py-2 dark:bg-gray-800"- >- <Text className="text-center text-sm font-medium text-gray-600 dark:text-gray-400">+ <GroupedSection header="AI Summary">+ <Pressable+ onPress={() => setIsExpanded(!isExpanded)}+ className="px-4 py-3"+ >+ <View className={isExpanded ? "" : "max-h-16 overflow-hidden"}>+ <BookmarkTextMarkdown text={bookmark.summary} />+ </View>+ {!isExpanded && (+ <Text variant="footnote" className="mt-1.5 text-primary">Show more</Text>- </Pressable>- )}+ )}+ </Pressable>{isExpanded && !readOnly && (- <View className="mt-2 flex flex-row justify-end gap-2">- <Pressable- onPress={() => resummarize({ bookmarkId: bookmark.id })}- disabled={isResummarizing}- className="rounded-full bg-gray-200 p-2 dark:bg-gray-700"- >- {isResummarizing ? (- <ActivityIndicator size="small" />- ) : (- <RefreshCw- size={16}- className="text-gray-600 dark:text-gray-400"- />- )}- </Pressable>- <Pressable- onPress={() =>- updateBookmark({ bookmarkId: bookmark.id, summary: null })- }- disabled={isDeletingSummary}- className="rounded-full bg-gray-200 p-2 dark:bg-gray-700"- >- {isDeletingSummary ? (- <ActivityIndicator size="small" />- ) : (- <Trash2- size={16}- className="text-gray-600 dark:text-gray-400"- />- )}- </Pressable>- <Pressable- onPress={() => setIsExpanded(false)}- className="rounded-full bg-gray-200 p-2 dark:bg-gray-700"- >- <ChevronUp- size={16}- className="text-gray-600 dark:text-gray-400"- />- </Pressable>- </View>+ <>+ <RowSeparator />+ <View className="flex-row justify-end gap-1 px-2 py-2">+ <Pressable+ onPress={() => resummarize({ bookmarkId: bookmark.id })}+ disabled={isResummarizing}+ className="rounded-full p-2.5 active:opacity-70"+ >+ {isResummarizing ? (+ <ActivityIndicator size="small" />+ ) : (+ <RefreshCw size={18} color={colors.grey} />+ )}+ </Pressable>+ <Pressable+ onPress={() =>+ updateBookmark({ bookmarkId: bookmark.id, summary: null })+ }+ disabled={isDeletingSummary}+ className="rounded-full p-2.5 active:opacity-70"+ >+ {isDeletingSummary ? (+ <ActivityIndicator size="small" />+ ) : (+ <Trash2 size={18} color={colors.grey} />+ )}+ </Pressable>+ <Pressable+ onPress={() => setIsExpanded(false)}+ className="rounded-full p-2.5 active:opacity-70"+ >+ <ChevronUp size={18} color={colors.grey} />+ </Pressable>+ </View>+ </>)}- </InfoSection>+ </GroupedSection>);}- // If no summary, show button to generate oneif (readOnly) {return null;}+return (- <InfoSection>+ <GroupedSection><PressableonPress={() => summarize({ bookmarkId: bookmark.id })}disabled={isSummarizing}- className="rounded-lg bg-purple-500 p-3 dark:bg-purple-600"+ className="flex-row items-center justify-center gap-2 px-4 py-3 active:opacity-70">- <View className="flex flex-row items-center justify-center gap-2">- {isSummarizing ? (- <>- <ActivityIndicator size="small" color="#fff" />- <Text className="font-medium text-white">- Generating summary...- </Text>- </>- ) : (- <>- <Text className="font-medium text-white">Summarize with AI</Text>- <Sparkles size={16} color="#fff" />- </>- )}- </View>+ {isSummarizing ? (+ <>+ <ActivityIndicator size="small" color={colors.primary} />+ <Text className="text-primary">Generating...</Text>+ </>+ ) : (+ <>+ <Sparkles size={16} color={colors.primary} />+ <Text className="text-primary">Summarize with AI</Text>+ </>+ )}</Pressable>- </InfoSection>+ </GroupedSection>);}+// --- Main Page ---+const ViewBookmarkPage = () => {- const insets = useSafeAreaInsets();const { slug } = useLocalSearchParams();const { toast } = useToast();const { data: currentUser } = useWhoAmI();@@ -320,13 +298,24 @@ const ViewBookmarkPage = () => {throw new Error("Unexpected param type");}+ const [editedBookmark, setEditedBookmark] = React.useState<{+ title?: string | null;+ note?: string;+ }>({});++ const hasChanges = Object.keys(editedBookmark).length > 0;+const { mutate: editBookmark, isPending: isEditPending } = useUpdateBookmark({onSuccess: () => {- toast({- message: "The bookmark has been updated!",- showProgress: false,- });- setEditedBookmark({});+ toast({ message: "Bookmark updated!", showProgress: false });+ if (router.canGoBack()) {+ router.back();+ } else {+ router.replace("dashboard");+ }+ },+ onError: () => {+ toast({ message: "Failed to save changes", showProgress: false });},});@@ -334,10 +323,7 @@ const ViewBookmarkPage = () => {useDeleteBookmark({onSuccess: () => {router.replace("dashboard");- toast({- message: "The bookmark has been deleted!",- showProgress: false,- });+ toast({ message: "Bookmark deleted!", showProgress: false });},});@@ -349,13 +335,23 @@ const ViewBookmarkPage = () => {bookmarkId: slug,});- // Check if the current user owns this bookmarkconst isOwner = currentUser?.id === bookmark?.userId;- const [editedBookmark, setEditedBookmark] = React.useState<{- title?: string | null;- note?: string;- }>({});+ const onDone = () => {+ const dismiss = () => {+ if (router.canGoBack()) {+ router.back();+ } else {+ router.replace("dashboard");+ }+ };++ if (hasChanges && bookmark) {+ editBookmark({ bookmarkId: bookmark.id, ...editedBookmark });+ } else {+ dismiss();+ }+ };if (isPending) {return <FullPageSpinner />;@@ -368,8 +364,9 @@ const ViewBookmarkPage = () => {}const handleDeleteBookmark = () => {+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Warning);Alert.alert(- "Delete bookmark?",+ "Delete Bookmark","Are you sure you want to delete this bookmark?",[{ text: "Cancel", style: "cancel" },@@ -382,113 +379,89 @@ const ViewBookmarkPage = () => {);};- const onDone = () => {- const doDone = () => {- if (router.canGoBack()) {- router.back();- } else {- router.replace("dashboard");- }- };- if (Object.keys(editedBookmark).length === 0) {- doDone();- return;- }- Alert.alert("You have unsaved changes", "Do you still want to leave?", [- { text: "Cancel", style: "cancel" },- {- text: "Leave",- onPress: doDone,- },- ]);- };-- let title = null;+ let title: string | null = null;switch (bookmark.content.type) {case BookmarkTypes.LINK:- title = bookmark.title ?? bookmark.content.title;+ title = bookmark.title ?? bookmark.content.title ?? null;break;case BookmarkTypes.TEXT:- title = bookmark.title;+ title = bookmark.title ?? null;break;case BookmarkTypes.ASSET:- title = bookmark.title ?? bookmark.content.fileName;+ title = bookmark.title ?? bookmark.content.fileName ?? null;break;}+return (<KeyboardGestureArea interpolator="ios">+ <Stack.Screen+ options={{+ headerShown: true,+ headerTransparent: false,+ headerTitle: "Info",+ headerRight: () => (+ <Pressable onPress={onDone} disabled={isEditPending}>+ {isEditPending ? (+ <ActivityIndicator size="small" />+ ) : (+ <Text+ className={+ hasChanges ? "font-semibold text-primary" : "text-primary"+ }+ >+ {hasChanges ? "Save" : "Done"}+ </Text>+ )}+ </Pressable>+ ),+ }}+ /><KeyboardAwareScrollView- className="p-4"bottomOffset={8}keyboardDismissMode="interactive"- contentContainerStyle={{ paddingBottom: insets.bottom }}+ contentContainerStyle={{ padding: 16, gap: 20, paddingBottom: 40 }}+ className="bg-background">- <Stack.Screen- options={{- headerShown: true,- headerTransparent: false,- headerTitle: title ?? "Untitled",- headerRight: () => (- <Pressable onPress={onDone}>- <Text>Done</Text>- </Pressable>- ),- }}+ <TitleEditor+ title={title}+ setTitle={(t) => setEditedBookmark((prev) => ({ ...prev, title: t }))}+ isPending={isEditPending}+ disabled={!isOwner}/>- <View className="gap-4">- <TitleEditor- title={title}- setTitle={(title) =>- setEditedBookmark((prev) => ({ ...prev, title }))- }- isPending={isEditPending}- disabled={!isOwner}- />- <AISummarySection bookmark={bookmark} readOnly={!isOwner} />- <TagList bookmark={bookmark} readOnly={!isOwner} />- {isOwner && <ManageLists bookmark={bookmark} />}- <NotesEditor- notes={bookmark.note}- setNotes={(note) =>- setEditedBookmark((prev) => ({ ...prev, note: note ?? "" }))- }- isPending={isEditPending}- disabled={!isOwner}- />- {isOwner && (- <View className="flex justify-between gap-3">- <Button- onPress={() =>- editBookmark({- bookmarkId: bookmark.id,- ...editedBookmark,- })- }- disabled={isEditPending}- >- <Text>Save</Text>- </Button>- <Button- variant="destructive"- onPress={handleDeleteBookmark}- disabled={isDeletionPending}- >- <Text>Delete</Text>- </Button>- </View>- )}- <View className="gap-1">- <Text className="text-center text-xs text-muted-foreground">- Created {bookmark.createdAt.toLocaleString()}- </Text>- {bookmark.modifiedAt &&- bookmark.modifiedAt.getTime() !==- bookmark.createdAt.getTime() && (- <Text className="text-center text-xs text-muted-foreground">- Modified {bookmark.modifiedAt.toLocaleString()}- </Text>- )}- </View>+ <AISummarySection bookmark={bookmark} readOnly={!isOwner} />+ <TagList bookmark={bookmark} readOnly={!isOwner} />+ {isOwner && <ManageLists bookmark={bookmark} />}+ <NotesEditor+ notes={bookmark.note}+ setNotes={(note) =>+ setEditedBookmark((prev) => ({ ...prev, note: note ?? "" }))+ }+ isPending={isEditPending}+ disabled={!isOwner}+ />+ {isOwner && (+ <GroupedSection>+ <Pressable+ onPress={handleDeleteBookmark}+ disabled={isDeletionPending}+ className="items-center px-4 py-3 active:opacity-70"+ >+ <Text className="text-destructive">+ {isDeletionPending ? "Deleting..." : "Delete Bookmark"}+ </Text>+ </Pressable>+ </GroupedSection>+ )}+ <View className="items-center gap-1 pt-2">+ <Text variant="caption1" color="tertiary" selectable>+ Created {bookmark.createdAt.toLocaleString()}+ </Text>+ {bookmark.modifiedAt &&+ bookmark.modifiedAt.getTime() !== bookmark.createdAt.getTime() && (+ <Text variant="caption1" color="tertiary" selectable>+ Modified {bookmark.modifiedAt.toLocaleString()}+ </Text>+ )}</View></KeyboardAwareScrollView></KeyboardGestureArea>diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsxindex 1070207b..943b9d86 100644--- a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_lists.tsx@@ -1,11 +1,12 @@import React from "react";-import { ActivityIndicator, FlatList, Pressable, View } from "react-native";-import Checkbox from "expo-checkbox";-import { useLocalSearchParams } from "expo-router";-import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";+import { ActivityIndicator, Pressable, ScrollView, View } from "react-native";+import { Stack, useLocalSearchParams } from "expo-router";+import { RowSeparator } from "@/components/ui/GroupedList";import { Text } from "@/components/ui/Text";import { useToast } from "@/components/ui/Toast";+import { useColorScheme } from "@/lib/useColorScheme";import { useQuery } from "@tanstack/react-query";+import { Check } from "lucide-react-native";import type { ZBookmarkList } from "@karakeep/shared/types/lists";import {@@ -18,9 +19,12 @@ import { useTRPC } from "@karakeep/shared-react/trpc";const ListPickerPage = () => {const api = useTRPC();const { slug: bookmarkId } = useLocalSearchParams();+ const { colors } = useColorScheme();+if (typeof bookmarkId !== "string") {throw new Error("Unexpected param type");}+const { toast } = useToast();const onError = () => {toast({@@ -29,17 +33,17 @@ const ListPickerPage = () => {showProgress: false,});};+const { data: existingLists } = useQuery(api.lists.getListsOfBookmark.queryOptions(- {- bookmarkId,- },+ { bookmarkId },{select: (data: { lists: ZBookmarkList[] }) =>new Set(data.lists.map((l) => l.id)),},),);+const { data } = useBookmarkLists();const {@@ -49,7 +53,7 @@ const ListPickerPage = () => {} = useAddBookmarkToList({onSuccess: () => {toast({- message: `The bookmark has been added to the list!`,+ message: "Added to list!",showProgress: false,});},@@ -63,7 +67,7 @@ const ListPickerPage = () => {} = useRemoveBookmarkFromList({onSuccess: () => {toast({- message: `The bookmark has been removed from the list!`,+ message: "Removed from list!",showProgress: false,});},@@ -71,9 +75,7 @@ const ListPickerPage = () => {});const toggleList = (listId: string) => {- if (!existingLists) {- return;- }+ if (!existingLists) return;if (existingLists.has(listId)) {removeToList({ bookmarkId, listId });} else {@@ -89,53 +91,68 @@ const ListPickerPage = () => {};const { allPaths } = data ?? {};- // Filter out lists where user is a viewer (can't add/remove bookmarks)const filteredPaths = allPaths?.filter((path) => path[path.length - 1].userRole !== "viewer",);+return (- <CustomSafeAreaView>- <FlatList- className="h-full"- contentContainerStyle={{- gap: 6,+ <>+ <Stack.Screen+ options={{+ headerShown: true,+ headerTransparent: false,+ headerTitle: "Manage Lists",}}- renderItem={(l) => {- const listId = l.item[l.item.length - 1].id;- const isLoading = isListLoading(listId);- const isChecked = existingLists && existingLists.has(listId);+ />+ <ScrollView+ contentInsetAdjustmentBehavior="automatic"+ contentContainerStyle={{ padding: 16, paddingBottom: 40 }}+ className="bg-background"+ >+ {filteredPaths && filteredPaths.length > 0 ? (+ <View+ className="overflow-hidden rounded-xl bg-card"+ style={{ borderCurve: "continuous" }}+ >+ {filteredPaths.map((path, index) => {+ const listId = path[path.length - 1].id;+ const isLoading = isListLoading(listId);+ const isChecked = existingLists?.has(listId);- return (- <View className="mx-2 flex flex-row items-center rounded-xl bg-card px-4 py-2">- <Pressable- key={listId}- onPress={() => !isLoading && toggleList(listId)}- disabled={isLoading}- className="flex w-full flex-row items-center justify-between"- >- <Text className="shrink">- {l.item- .map((item) => `${item.icon} ${item.name}`)- .join(" / ")}- </Text>- {isLoading ? (- <ActivityIndicator size="small" />- ) : (- <Checkbox- value={isChecked}- onValueChange={() => {- toggleList(listId);- }}+ return (+ <React.Fragment key={listId}>+ {index > 0 && <RowSeparator />}+ <Pressable+ onPress={() => !isLoading && toggleList(listId)}disabled={isLoading}- />- )}- </Pressable>- </View>- );- }}- data={filteredPaths}- />- </CustomSafeAreaView>+ className="flex-row items-center justify-between px-4 py-3 active:opacity-70"+ >+ <Text className="flex-1 pr-3" numberOfLines={1}>+ {path+ .map((item) => `${item.icon} ${item.name}`)+ .join(" / ")}+ </Text>+ {isLoading ? (+ <ActivityIndicator size="small" />+ ) : isChecked ? (+ <Check+ size={20}+ color={colors.primary}+ strokeWidth={2.5}+ />+ ) : null}+ </Pressable>+ </React.Fragment>+ );+ })}+ </View>+ ) : (+ <View className="items-center py-12">+ <Text color="tertiary">No lists available</Text>+ </View>+ )}+ </ScrollView>+ </>);};diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsxindex 64d057f2..2198ae9c 100644--- a/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/manage_tags.tsx@@ -1,8 +1,8 @@import React, { useMemo } from "react";-import { Pressable, SectionList, TouchableOpacity, View } from "react-native";+import { Pressable, ScrollView, View } from "react-native";import { Stack, useLocalSearchParams } from "expo-router";-import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";import FullPageSpinner from "@/components/ui/FullPageSpinner";+import { GroupedSection, RowSeparator } from "@/components/ui/GroupedList";import { Text } from "@/components/ui/Text";import { useToast } from "@/components/ui/Toast";import { useColorScheme } from "@/lib/useColorScheme";@@ -17,16 +17,16 @@ import { useTRPC } from "@karakeep/shared-react/trpc";const NEW_TAG_ID = "new-tag";-const ListPickerPage = () => {+const TagPickerPage = () => {const api = useTRPC();const { colors } = useColorScheme();const { slug: bookmarkId } = useLocalSearchParams();-const [search, setSearch] = React.useState("");if (typeof bookmarkId !== "string") {throw new Error("Unexpected param type");}+const { toast } = useToast();const onError = () => {toast({@@ -55,6 +55,7 @@ const ListPickerPage = () => {},),);+const { data: existingTags } = useAutoRefreshingBookmarkQuery({bookmarkId,});@@ -62,6 +63,7 @@ const ListPickerPage = () => {const [optimisticTags, setOptimisticTags] = React.useState<{ id: string; name: string; lowered: string }[]>([]);+React.useEffect(() => {setOptimisticTags(existingTags?.tags.map((t) => ({@@ -77,7 +79,11 @@ const ListPickerPage = () => {req.attach.forEach((t) =>setOptimisticTags((prev) => [...prev,- { id: t.tagId!, name: t.tagName!, lowered: t.tagName!.toLowerCase() },+ {+ id: t.tagId!,+ name: t.tagName!,+ lowered: t.tagName!.toLowerCase(),+ },]),);req.detach.forEach((t) =>@@ -89,7 +95,6 @@ const ListPickerPage = () => {const clearAllTags = () => {if (optimisticTags.length === 0) return;-updateTags({bookmarkId,detach: optimisticTags.map((tag) => ({@@ -104,54 +109,70 @@ const ListPickerPage = () => {return new Set(optimisticTags?.map((t) => t.id) ?? []);}, [optimisticTags]);- const filteredTags = useMemo(() => {+ const { filteredAllTags, filteredOptimisticTags } = useMemo(() => {const loweredSearch = search.toLowerCase();- let filteredAllTags = allTags?.filter(- (t) =>- t.lowered.startsWith(loweredSearch) &&- !optimisticExistingTagIds.has(t.id),- );- let addCreateTag = false;+ let filteredAll =+ allTags?.filter(+ (t) =>+ t.lowered.startsWith(loweredSearch) &&+ !optimisticExistingTagIds.has(t.id),+ ) ?? [];+if (allTags && search) {const exactMatchExists =allTags.some((t) => t.lowered == loweredSearch) ||optimisticTags.some((t) => t.lowered == loweredSearch);- addCreateTag = !exactMatchExists;- }- if (filteredAllTags && addCreateTag) {- filteredAllTags = [- {- id: NEW_TAG_ID,- name: search,- lowered: loweredSearch,- },- ...filteredAllTags,- ];+ if (!exactMatchExists) {+ filteredAll = [+ { id: NEW_TAG_ID, name: search, lowered: loweredSearch },+ ...filteredAll,+ ];+ }}- const filteredOptimisticTags = optimisticTags.filter((t) =>+ const filteredExisting = optimisticTags.filter((t) =>t.lowered.startsWith(loweredSearch),);- return { filteredAllTags, filteredOptimisticTags };+ return {+ filteredAllTags: filteredAll,+ filteredOptimisticTags: filteredExisting,+ };}, [search, allTags, optimisticTags, optimisticExistingTagIds]);- const ClearButton = () => (- <TouchableOpacity- onPress={clearAllTags}- disabled={optimisticTags.length === 0}- className={`mr-4 ${optimisticTags.length === 0 ? "opacity-50" : ""}`}- >- <Text className="text-base font-medium text-blue-500">Clear</Text>- </TouchableOpacity>- );+ const handleTagPress = (+ tag: { id: string; name: string },+ action: "attach" | "detach",+ ) => {+ updateTags({+ bookmarkId,+ attach:+ action === "attach"+ ? [+ {+ tagId: tag.id === NEW_TAG_ID ? undefined : tag.id,+ tagName: tag.name,+ },+ ]+ : [],+ detach:+ action === "detach"+ ? [+ {+ tagId: tag.id === NEW_TAG_ID ? undefined : tag.id,+ tagName: tag.name,+ },+ ]+ : [],+ });+ };if (isAllTagsPending) {return <FullPageSpinner />;}return (- <CustomSafeAreaView>+ <><Stack.Screenoptions={{headerSearchBarOptions: {@@ -160,75 +181,72 @@ const ListPickerPage = () => {autoCapitalize: "none",hideWhenScrolling: false,},- headerRight: () => <ClearButton />,+ headerRight: () => (+ <Pressable+ onPress={clearAllTags}+ disabled={optimisticTags.length === 0}+ className={optimisticTags.length === 0 ? "opacity-50" : ""}+ >+ <Text className="text-primary">Clear</Text>+ </Pressable>+ ),}}/>- <SectionList- className="h-full px-3"- keyboardShouldPersistTaps="handled"+ <ScrollViewcontentInsetAdjustmentBehavior="automatic"- keyExtractor={(t) => t.id}- contentContainerStyle={{- gap: 6,- }}- SectionSeparatorComponent={() => <View className="h-1" />}- sections={[- {- title: "Existing Tags",- data: filteredTags.filteredOptimisticTags ?? [],- },- {- title: "All Tags",- data: filteredTags.filteredAllTags ?? [],- },- ]}- renderItem={(t) => (- <Pressable- key={t.item.id}- onPress={() =>- updateTags({- bookmarkId,- detach:- t.section.title == "Existing Tags"- ? [- {- tagId:- t.item.id == NEW_TAG_ID ? undefined : t.item.id,- tagName: t.item.name,- },- ]- : [],- attach:- t.section.title == "All Tags"- ? [- {- tagId:- t.item.id == NEW_TAG_ID ? undefined : t.item.id,- tagName: t.item.name,- },- ]- : [],- })- }- >- <View className="mx-2 flex flex-row items-center gap-2 rounded-xl bg-card px-4 py-2">- {t.section.title == "Existing Tags" && (- <Check color={colors.foreground} />- )}- {t.section.title == "All Tags" && t.item.id == NEW_TAG_ID && (- <Plus color={colors.foreground} />- )}- <Text>- {t.item.id == NEW_TAG_ID- ? `Create new tag '${t.item.name}'`- : t.item.name}- </Text>- </View>- </Pressable>+ keyboardShouldPersistTaps="handled"+ contentContainerStyle={{ padding: 16, gap: 20, paddingBottom: 40 }}+ className="bg-background"+ >+ {filteredOptimisticTags.length > 0 && (+ <GroupedSection header="Attached">+ {filteredOptimisticTags.map((tag, index) => (+ <React.Fragment key={tag.id}>+ {index > 0 && <RowSeparator />}+ <Pressable+ onPress={() => handleTagPress(tag, "detach")}+ className="flex-row items-center justify-between px-4 py-3 active:opacity-70"+ >+ <Text className="flex-1 pr-3">{tag.name}</Text>+ <Check size={20} color={colors.primary} strokeWidth={2.5} />+ </Pressable>+ </React.Fragment>+ ))}+ </GroupedSection>)}- />- </CustomSafeAreaView>+ {filteredAllTags.length > 0 && (+ <GroupedSection header="All Tags">+ {filteredAllTags.map((tag, index) => (+ <React.Fragment key={tag.id}>+ {index > 0 && <RowSeparator />}+ <Pressable+ onPress={() => handleTagPress(tag, "attach")}+ className="flex-row items-center justify-between px-4 py-3 active:opacity-70"+ >+ {tag.id === NEW_TAG_ID ? (+ <>+ <Text className="flex-1 pr-3 text-primary">+ Create “{tag.name}”+ </Text>+ <Plus size={20} color={colors.primary} strokeWidth={2} />+ </>+ ) : (+ <Text className="flex-1 pr-3">{tag.name}</Text>+ )}+ </Pressable>+ </React.Fragment>+ ))}+ </GroupedSection>+ )}+ {filteredOptimisticTags.length === 0 &&+ filteredAllTags.length === 0 && (+ <View className="items-center py-12">+ <Text color="tertiary">No tags found</Text>+ </View>+ )}+ </ScrollView>+ </>);};-export default ListPickerPage;+export default TagPickerPage;diff --git a/apps/mobile/components/ui/GroupedList.tsx b/apps/mobile/components/ui/GroupedList.tsxnew file mode 100644index 00000000..c36b7cba--- /dev/null+++ b/apps/mobile/components/ui/GroupedList.tsx@@ -0,0 +1,68 @@+import { Pressable, StyleSheet, View } from "react-native";+import ChevronRight from "@/components/ui/ChevronRight";+import { Text } from "@/components/ui/Text";++/**+ * iOS-style grouped table section with an optional uppercase header label+ * and a rounded card container for its children.+ */+function GroupedSection({+ children,+ header,+}: {+ children: React.ReactNode;+ header?: string;+}) {+ return (+ <View style={{ gap: 6 }}>+ {header && (+ <Text variant="footnote" color="tertiary" className="px-5 uppercase">+ {header}+ </Text>+ )}+ <View+ className="overflow-hidden rounded-xl bg-card"+ style={{ borderCurve: "continuous" }}+ >+ {children}+ </View>+ </View>+ );+}++/**+ * Hairline separator indented from the left, used between rows+ * within a GroupedSection.+ */+function RowSeparator() {+ return (+ <View+ className="ml-4 bg-border/30"+ style={{ height: StyleSheet.hairlineWidth }}+ />+ );+}++/**+ * A pressable row with a label and a trailing chevron,+ * used for drill-down navigation within a GroupedSection.+ */+function NavigationRow({+ label,+ onPress,+}: {+ label: string;+ onPress: () => void;+}) {+ return (+ <Pressable+ onPress={onPress}+ className="flex-row items-center justify-between px-4 py-3 active:opacity-70"+ >+ <Text>{label}</Text>+ <ChevronRight size={16} />+ </Pressable>+ );+}++export { GroupedSection, NavigationRow, RowSeparator };