From 6e5139527207a6ee2cd0bdc3fc4d0e23c22fda9d Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:19:23 +0000 Subject: [PATCH 1/6] fix links home list recovery --- apps/backend/src/lib/data/links.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/backend/src/lib/data/links.ts b/apps/backend/src/lib/data/links.ts index 9a6ccf337..261114f5e 100644 --- a/apps/backend/src/lib/data/links.ts +++ b/apps/backend/src/lib/data/links.ts @@ -415,10 +415,7 @@ async function getHomeListId(userId: string) { const cachedHomeListId = homeListIdByUser.get(userId); if (cachedHomeListId) return cachedHomeListId; - const list = await pb.collection("linksLists").getFirstListItem( - `user = "${userId}" && type = "home"`, - { fields: "id", skipTotal: true }, - ); + const list = await getOrCreateHomeCollection(pb, userId); homeListIdByUser.set(userId, list.id); return list.id; } @@ -501,12 +498,19 @@ async function getOrCreateHomeCollection(pb: any, userId: string) { .catch(() => null); if (!homeCollection) { - homeCollection = await pb.collection("linksLists").create({ - user: userId, - type: "home", - name: "Home", - description: "", - }); + const namedHomeCollection = await pb + .collection("linksLists") + .getFirstListItem(`user = "${userId}" && name = "Home"`) + .catch(() => null); + + homeCollection = namedHomeCollection + ? await pb.collection("linksLists").update(namedHomeCollection.id, { type: "home" }) + : await pb.collection("linksLists").create({ + user: userId, + type: "home", + name: "Home", + description: "", + }); } return homeCollection; From 798ef87d88570d10966a75be995ab799c1e9142a Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:30:40 +0000 Subject: [PATCH 2/6] fix links data access for authenticated routes --- apps/backend/src/lib/data/links.ts | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/backend/src/lib/data/links.ts b/apps/backend/src/lib/data/links.ts index 261114f5e..7c4e7d068 100644 --- a/apps/backend/src/lib/data/links.ts +++ b/apps/backend/src/lib/data/links.ts @@ -1,6 +1,6 @@ import { ApiActionError } from "./auth"; import { config } from "../config"; -import { getServerPB, getSuperuserPB } from "../pb/pocketbase"; +import { getSuperuserPB } from "../pb/pocketbase"; export interface LinkList { collectionId: string; @@ -76,7 +76,7 @@ interface HomeLinkInput { } export async function getLinksCollections(userId: string) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const records = await pb.collection("linksLists").getFullList({ filter: `user = "${userId}"`, sort: "-created", @@ -93,7 +93,7 @@ export async function getLinksCollections(userId: string) { })); } -async function requireUserList(pb: ReturnType, userId: string, listId: string) { +async function requireUserList(pb: any, userId: string, listId: string) { const list = await pb.collection("linksLists").getOne(listId); if (list.user !== userId) { throw new ApiActionError("Unauthorized", 401, { error: "Unauthorized" }); @@ -103,7 +103,7 @@ async function requireUserList(pb: ReturnType, userId: strin } export async function getLinksFolders(userId: string, listId: string) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); await requireUserList(pb, userId, listId); const records = await pb.collection("linksFolders").getFullList({ @@ -128,7 +128,7 @@ export async function createLinksFolder( userId: string, data: { list: string; name: string; parentFolder?: string; icon?: string }, ) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); await requireUserList(pb, userId, data.list); const normalizedName = String(data.name || "").trim(); @@ -174,7 +174,7 @@ export async function createLinksFolder( } export async function getLinksItems(userId: string, listId: string, folderId?: string) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); await requireUserList(pb, userId, listId); let filter = `collection = "${listId}"`; @@ -208,7 +208,7 @@ export async function getLinksItems(userId: string, listId: string, folderId?: s } export async function getLinksTags() { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const records = await pb.collection("linksTags").getFullList({ sort: "name", }); @@ -224,7 +224,7 @@ export async function createLinkTag( userId: string, data: { name: string; color?: string }, ): Promise<{ id: string; name: string; color: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const normalizedName = String(data.name || "").trim(); if (!normalizedName) { @@ -250,7 +250,7 @@ export async function updateCollection( listId: string, data: { name?: string; description?: string }, ): Promise<{ id: string; name: string; description: string; type: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const list = await pb.collection("linksLists").getOne(listId); if (list.user !== userId) throw new ApiActionError("Unauthorized", 401, { error: "Unauthorized" }); @@ -273,7 +273,7 @@ export async function updateLinkTag( tagId: string, data: { name?: string; color?: string }, ): Promise<{ id: string; name: string; color: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); void userId; const record = await pb.collection("linksTags").update(tagId, { @@ -410,7 +410,7 @@ async function syncHomeLinkMonitor( const homeListIdByUser = new Map(); async function getHomeListId(userId: string) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const cachedHomeListId = homeListIdByUser.get(userId); if (cachedHomeListId) return cachedHomeListId; @@ -422,7 +422,7 @@ async function getHomeListId(userId: string) { export async function getHomeLinks(userId: string) { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const userHomeListId = await getHomeListId(userId); const monitorByLinkId = new Map(); @@ -447,7 +447,7 @@ export async function getHomeLinks(userId: string) { filter: `list = "${userHomeListId}"`, sort: "name", }), - ]).catch(() => [[], []]); + ]); if (!records.length) return []; @@ -551,7 +551,7 @@ async function getOrCreateFolderInList( } export async function getHomeLinkGroups(userId: string): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const homeCollection = await pb .collection("linksLists") .getFirstListItem(`user = "${userId}" && type = "home"`) @@ -576,7 +576,7 @@ export async function createHomeLinkGroup( userId: string, name: string, ): Promise<{ id: string; name: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const normalizedName = String(name || "").trim(); if (!normalizedName) { @@ -601,7 +601,7 @@ export async function updateHomeLinkFolderIcon( folderId: string, data: { icon?: string }, ): Promise<{ id: string; name: string; icon: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const folder = await pb.collection("linksFolders").getOne(folderId); const list = await pb.collection("linksLists").getOne(folder.list); @@ -644,7 +644,7 @@ export async function createHomeLinkItem( folder?: string; } > { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const homeCollection = await getOrCreateHomeCollection(pb, userId); const existingLinks = await pb.collection("linkItems").getFullList({ @@ -710,7 +710,7 @@ export async function setHomeLinks( userId: string, json: string, ): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const inputs: HomeLinkInput[] = JSON.parse(json); let homeCollection = await pb @@ -797,7 +797,7 @@ export async function updateHomeLinkItem( secondaryUrls?: SecondaryUrl[]; }, ): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const item = await pb.collection("linkItems").getOne(linkId); const list = await pb.collection("linksLists").getOne(item.collection); @@ -856,7 +856,7 @@ export async function reorderLinks( userId: string, items: { id: string; type: "link" | "folder"; position: number }[], ): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); await Promise.all( items.map(async (item) => { @@ -873,7 +873,7 @@ export async function createCollection( userId: string, data: { name: string; description?: string; icon?: string }, ): Promise<{ id: string; name: string; description: string; icon: string; type: string }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const record = await pb.collection("linksLists").create({ user: userId, @@ -896,7 +896,7 @@ export async function deleteCollection( userId: string, listId: string, ): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const list = await pb.collection("linksLists").getOne(listId); if (list.user !== userId) throw new ApiActionError("Unauthorized", 401, { error: "Unauthorized" }); @@ -936,7 +936,7 @@ export async function deleteCollection( export async function wipeUserLinks( userId: string, ): Promise<{ deletedCollections: number; deletedFolders: number; deletedItems: number }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const lists = await pb.collection("linksLists").getFullList({ filter: `user = "${userId}"`, }); @@ -1007,7 +1007,7 @@ export async function createLinkItem(data: { created: string; updated: string; }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const record = await pb.collection("linkItems").create({ url: data.url, @@ -1057,7 +1057,7 @@ export async function createCollectionLinkItem( created: string; updated: string; }> { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const list = await pb.collection("linksLists").getOne(data.collection); if (list.user !== userId) { @@ -1087,7 +1087,7 @@ export async function updateLinkItem( folder?: string; } > { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const record = await pb.collection("linkItems").update(itemId, { ...(data.url !== undefined && { url: data.url }), @@ -1113,7 +1113,7 @@ export async function deleteLinkItem( userId: string, linkId: string, ): Promise { - const pb = getServerPB(); + const pb = await getSuperuserPB(); const item = await pb.collection("linkItems").getOne(linkId); const list = await pb.collection("linksLists").getOne(item.collection); From 36d862a3e9d73f791b539cbab9956500514c35a3 Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:30:51 +0000 Subject: [PATCH 3/6] authorize link reorder targets --- apps/backend/src/lib/data/links.ts | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/lib/data/links.ts b/apps/backend/src/lib/data/links.ts index 7c4e7d068..d65306635 100644 --- a/apps/backend/src/lib/data/links.ts +++ b/apps/backend/src/lib/data/links.ts @@ -858,8 +858,39 @@ export async function reorderLinks( ): Promise { const pb = await getSuperuserPB(); + const records = await Promise.all(items.map(async (item) => { + if ( + !item || + (item.type !== "link" && item.type !== "folder") || + typeof item.id !== "string" || + !item.id.trim() || + !Number.isInteger(item.position) + ) { + throw new ApiActionError("Invalid reorder item", 400, { error: "Invalid reorder item" }); + } + + const record = item.type === "link" + ? await pb.collection("linkItems").getOne(item.id) + : await pb.collection("linksFolders").getOne(item.id); + + return { + item, + listId: item.type === "link" ? String(record.collection || "") : String(record.list || ""), + }; + })); + + const listIds = Array.from(new Set(records.map((record) => record.listId).filter(Boolean))); + const lists = await Promise.all(listIds.map((listId) => pb.collection("linksLists").getOne(listId))); + const ownedListIds = new Set( + lists.filter((list: any) => list.user === userId).map((list: any) => String(list.id)), + ); + + if (records.some((record) => !ownedListIds.has(record.listId))) { + throw new ApiActionError("Not found", 404, { error: "Not found" }); + } + await Promise.all( - items.map(async (item) => { + records.map(async ({ item }) => { if (item.type === "link") { await pb.collection("linkItems").update(item.id, { position: item.position }); } else { From ad6f6f06013252666ed2f5b176687a21254c715a Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:31:18 +0000 Subject: [PATCH 4/6] initialize signup home links and config --- apps/backend/src/lib/data/auth.ts | 9 +++++---- apps/backend/src/routes/auth.route.ts | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/lib/data/auth.ts b/apps/backend/src/lib/data/auth.ts index f4a5808ed..c05986004 100644 --- a/apps/backend/src/lib/data/auth.ts +++ b/apps/backend/src/lib/data/auth.ts @@ -1,4 +1,4 @@ -import { ClientResponseError, getServerPB } from "../pb/pocketbase"; +import { ClientResponseError, getServerPB, getSuperuserPB } from "../pb/pocketbase"; import { defaultHomeConfig } from "@dashwise/assets"; import type { UsersResponse } from "@dashwise/types"; @@ -276,7 +276,7 @@ export async function signupUser(payload: { search?: Record; }; homeConfig?: Record; - linksConfig?: Record; + linksConfig?: Array>; }; }) { if (config.DISABLE_USER_SIGNUP) { @@ -320,9 +320,10 @@ export async function signupUser(payload: { searchPreferences: userConfig?.preferences?.search || {}, }); - await pb.collection("pageConfig").create({ + const admin = await getSuperuserPB(); + await admin.collection("pageConfig").create({ associatedUserId: user.id, - config: defaultHomeConfig, + config: userConfig?.homeConfig ?? defaultHomeConfig, pageName: "home", }); diff --git a/apps/backend/src/routes/auth.route.ts b/apps/backend/src/routes/auth.route.ts index 7dd61134d..dfeb1e19a 100644 --- a/apps/backend/src/routes/auth.route.ts +++ b/apps/backend/src/routes/auth.route.ts @@ -10,6 +10,7 @@ import { } from "../lib/data/auth"; import type { UserPropertyValue } from "../lib/data/auth"; import { ensureBuiltinIntegrations } from "../lib/data/integrations"; +import { setHomeLinks } from "../lib/data/links"; import { getSuperuserPB } from "../lib/pb/pocketbase"; import { @@ -79,6 +80,7 @@ authRoute.get( }, }); + await setHomeLinks(result.user.id, JSON.stringify(links)); await ensureBuiltinIntegrations(result.user.id, await getSuperuserPB()); return result; From 7c3f0b5ffff825deeae58daafed399b4bf2b4383 Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:32:25 +0000 Subject: [PATCH 5/6] respect new tab link preference --- apps/web/src/components/links/LinksDetailView.tsx | 8 +++++--- apps/web/src/components/widgets/LinkView.tsx | 14 ++++++++------ .../web/src/components/widgets/ShortcutsWidget.tsx | 8 ++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/links/LinksDetailView.tsx b/apps/web/src/components/links/LinksDetailView.tsx index 135fd9d2a..b50b77e9d 100644 --- a/apps/web/src/components/links/LinksDetailView.tsx +++ b/apps/web/src/components/links/LinksDetailView.tsx @@ -12,6 +12,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/u import CreateLinksFolderDialog from "@/components/links/CreateLinksFolderDialog"; import QRCode from "qrcode"; import { useEffect, useMemo, useState, type Dispatch, type SetStateAction } from "react"; +import { useAuth } from "@/context/useAuth"; import { Badge } from "../ui/badge"; export type LinkTagRecord = { @@ -286,12 +287,13 @@ function LinkRow({ onEdit?: (item: LinkItemRecord) => void; onEditTags?: (item: LinkItemRecord) => void; }) { + const { user } = useAuth(); const linkUrl = String(item.url ?? "").trim(); const titleElement = linkUrl ? ( {item.title || linkUrl} @@ -777,4 +779,4 @@ export default function LinksDetailView({ ); -} \ No newline at end of file +} diff --git a/apps/web/src/components/widgets/LinkView.tsx b/apps/web/src/components/widgets/LinkView.tsx index 14ad1096a..68ec0a4a2 100644 --- a/apps/web/src/components/widgets/LinkView.tsx +++ b/apps/web/src/components/widgets/LinkView.tsx @@ -860,6 +860,7 @@ function LinkTile({ isDragging, }: LinkTileProps) { const { user } = useAuth(); + const linkOpenInNewTab = user?.searchPreferences?.linkOpenBehaviour === "newtab"; if (style === "compact") { return ( diff --git a/apps/web/src/components/widgets/ShortcutsWidget.tsx b/apps/web/src/components/widgets/ShortcutsWidget.tsx index 4dbbdf839..20a080b58 100644 --- a/apps/web/src/components/widgets/ShortcutsWidget.tsx +++ b/apps/web/src/components/widgets/ShortcutsWidget.tsx @@ -10,7 +10,7 @@ import { getRoutedLinkUrl } from "@/lib/linkRouting"; type Shortcut = { id: string; name: string; icon?: string; sourceId?: string; action: string | { type: string; url?: string } }; export default function ShortcutsWidget({ shortcutIds = [], className = "" }: { shortcutIds?: string[]; className?: string }) { - const { withAuth, toggleTheme, toggleLinkTileLayout } = useAuth(); + const { user, withAuth, toggleTheme, toggleLinkTileLayout } = useAuth(); const [shortcuts, setShortcuts] = useState([]); const [homeLinks, setHomeLinks] = useState }>>([]); @@ -54,7 +54,11 @@ export default function ShortcutsWidget({ shortcutIds = [], className = "" }: { window.location.href = value.startsWith("command://") ? value : value.replace("command:", "client://"); return; } - window.open(value.startsWith("url:") ? value.slice(4) : value, "_self"); + window.open( + value.startsWith("url:") ? value.slice(4) : value, + user?.searchPreferences?.linkOpenBehaviour === "newtab" ? "_blank" : "_self", + user?.searchPreferences?.linkOpenBehaviour === "newtab" ? "noopener,noreferrer" : undefined, + ); void withAuth((auth) => logShortcutUsageAction(auth, shortcut.id, new Date().toISOString())); }; From f2bcef1a05c62ba14c54dfec74829a8f2947dd57 Mon Sep 17 00:00:00 2001 From: Andreas Molnar <75847494+andreasmolnardev@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:36:04 +0000 Subject: [PATCH 6/6] build and publish test docker image --- .github/workflows/aio-test.yml | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/aio-test.yml diff --git a/.github/workflows/aio-test.yml b/.github/workflows/aio-test.yml new file mode 100644 index 000000000..fb5e99a5c --- /dev/null +++ b/.github/workflows/aio-test.yml @@ -0,0 +1,44 @@ +name: Build and Publish aio-test + +on: + push: + branches: + - test + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + + - name: Install dependencies and build web app + run: | + cd apps/web + bun install + bun run build + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push multi-architecture Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ secrets.DOCKER_USERNAME }}/dashwise:test