Files
Niklas Haiden 51b52abb15 feat: move cards between dashboards, order dashboards, reuse uploaded icons
The card dialog has a dashboard field. Settings orders the dashboards
with arrows. The link dialog offers the images that were uploaded before.
2026-11-21 19:23:16 +01:00

131 lines
7.6 KiB
Markdown

# Dahoam — Plan
Replica of the reference start page (wallpaper, big serif clock, search bar,
app-icon row, "Everything else"), as a TanStack Start app with accounts.
Reference: https://pbs.twimg.com/media/HXSYNQ6XcAER0k9?format=jpg&name=4096x4096
## Stack
- TanStack Start (React 19, Vite 8), Tailwind 4
- UI: [collabry-components](https://git.nhaiden.io/niklas/collabry-components) copied into
`src/vendor/collabry` (replaced the scaffolded shadcn radix-nova set)
- Better Auth 1.7 — email/password + SSO (generic OIDC), Drizzle adapter
- Postgres 17 + Drizzle ORM (`postgres` driver), migrations via drizzle-kit
- Nitro (`nitro/vite`) for the production Node server
## Data model (`src/db/schema.ts`)
| Table | Columns |
|-------|---------|
| `user`, `session`, `account`, `verification` | Better Auth core tables |
| `link` | id, userId → user, name, url, icon (URL or dashboard-icons slug, optional), pinned, createdAt |
| `settings` | userId (PK) → user, title, searchEngine (`duckduckgo` \| `searxng` \| `google`), wallpaperUrl |
| `wallpaper` | userId (PK) → user, mime, data (bytea) |
Every row is scoped to its owner; all server functions check the session.
## Features
1. **Auth** — `/login` with sign in / sign up tabs and a "Continue with SSO" button
(only shown when OIDC env is set). `/` redirects to `/login` without a session.
`DISABLE_SIGNUP=true` closes registration.
2. **Dashboard** (`/`) — date, live clock, glass search bar, pinned links row,
"Everything else" section (unpinned links) below the fold, top bar with
title, add (+) and settings buttons, wallpaper credit + edit pencil.
3. **Home links** — add / edit / delete in a dialog (right-click or hover
pencil on a tile to edit). Icon fallback chain: custom icon →
dashboard-icons by name → site `/favicon.ico` → letter.
4. **Search**
- Engine per user: DuckDuckGo, SearXNG (when `SEARXNG_URL` is set), Google.
- Live suggestions proxied through the server (DuckDuckGo `/ac`, SearXNG `/autocompleter`).
- DuckDuckGo `!bangs` always route through DuckDuckGo.
- `/` focuses the bar; `/text` filters links and commands (add link, settings, sign out).
5. **Wallpaper** — paste an image URL or upload a file (stored in Postgres,
served from `/api/wallpaper`, ≤ 10 MB, jpeg/png/webp/avif). Reset to default.
Dither + vignette overlay like the reference.
## Files
```
docker-compose.yml Postgres for local dev
drizzle.config.ts
.env.example
src/db/{index,schema}.ts
src/lib/auth.ts Better Auth server config
src/lib/auth-client.ts
src/lib/auth.functions.ts getSession / ensureSession / authInfo
src/lib/dashboard.functions.ts links, settings, suggestions
src/lib/search.ts search URL builder (+ test)
src/routes/api/auth/$.ts
src/routes/api/wallpaper.ts
src/routes/login.tsx
src/routes/index.tsx
src/routes/settings.tsx
src/components/{clock,search-bar,link-tile,link-dialog,glass,wallpaper}.tsx
src/vendor/collabry/ copied Collabry components (do not edit)
scripts/sync-collabry.sh copies them from upstream at a pinned commit
```
## Steps
- [x] 1. Deps, docker-compose, env, Drizzle schema + first migration
- [x] 2. Better Auth (server, client, handler route, session helpers)
- [x] 3. Server functions: links, settings, suggestions; wallpaper route
- [x] 4. UI: login, dashboard, dialogs, search bar
- [x] 5. Verify: typecheck, lint, build, end-to-end against real Postgres, screenshot vs reference
- [x] 6. Independent review (subagent), fix findings, README
- [x] 7. Blurred card behind the top-row icons
- [x] 8. Collabry components: Button, Card, Field, Input, Checkbox, SegmentedControl, Dialog, Kbd,
ThemeProvider. Kept: wallpaper, serif clock, glass panels, Inter. Accent is near white.
- [x] 9. Settings page (`/settings`) replaces the settings dialog: General, Search, Wallpaper,
Account. Each setting saves on its own (`saveSettings` takes a patch).
- [x] 10. Cards: table `card`, `link.cardId` + `link.position` (replaces `pinned` and the
"Everything else" section; migration `0001_cards` moves existing links into cards).
Links are dragged inside and between cards with dnd-kit (`src/components/card-grid.tsx`,
layout logic and its test in `src/lib/layout.ts`).
- [x] 11. Image and CI: `Dockerfile` (multi-arch without emulation), `.gitea/workflows/images.yml`
(check, build, push to the Harbor registry on main, as in typst-workspace). The server applies
the migrations on start (`src/db/index.ts`).
- [x] 12. Renamed from "Home Dashboard" to Dahoam (slug `dahoam`): package, compose project, tab title,
default dashboard name, docs, CI examples.
- [x] 13. Dashboards: table `dashboard`, `card.dashboardId`, `settings.defaultDashboardId`
(migration `0006_dashboards_icons` puts the existing cards on a dashboard "Home"). `/?d=<id>`
opens one, `/` the default. Switcher in the header, managed in Settings → Dashboards.
- [x] 14. Icons: the link dialog searches dashboard-icons (`src/lib/icons.ts` and its test) and
uploads custom icons (table `icon`, `/api/icon`, ≤ 1 MB, SVG allowed because it is served
sandboxed). `src/lib/upload.ts` holds the upload checks that wallpaper and icons share.
- [x] 15. A wallpaper per dashboard: `wallpaperUrl` and `wallpaperDim` move from `settings` to
`dashboard`, the `wallpaper` table is keyed by dashboard (migration `0007_dashboard_wallpaper`
copies what each user had to all their dashboards). `/settings?d=<id>` is the dashboard whose
wallpaper is shown, and where "Back to dashboard" goes.
- [x] 16. Cards are dragged by their title bar: `card.position` (migration `0008_card_position`),
`saveLayout` (was `moveLinks`) stores the order of the cards and of their links.
- [x] 17. Password change in Settings → Account (Better Auth `changePassword`, other sessions are
revoked). Hidden for accounts without a password (SSO only).
- [x] 18. The search bar opens links by name: `matchLinks` in `src/lib/search.ts`. A link whose name
or a word of it starts with the text is preselected, Enter opens it.
- [x] 19. Light icons: a link without an icon of its own uses the library's `-light` version when
there is one. The server keeps the library's names for a day (`src/lib/icon-library.ts`) and
sends `lightIcon` with each link.
- [x] 20. Status dots: `STATUS_CHECKS=true` turns them on (`src/lib/status.ts`, `getStatuses`).
Off by default, because the server then requests addresses that users chose.
- [x] 21. Export and import: `exportData` / `importData`, the file format and the bookmarks parser
in `src/lib/transfer.ts`. An import only adds dashboards.
- [x] 22. Cards move to another dashboard in the card dialog, dashboards are ordered with arrows
in Settings (`dashboard.position`, migration `0009_dashboard_position`), uploaded icons are
offered again in the link dialog (`getIcons`).
## Not doing (not asked)
- Unraid version/uptime chip and the Sonarr/Plex notification pills from the screenshot
- Inline SearXNG result rendering (search opens the engine's result page)
- Free placement of cards with gaps in the grid, per-user SearXNG URL (SSRF risk — it is a server env)
- Per dashboard clock or search engine (they stay per user), remembering the last opened
dashboard (it would work against the default dashboard, which opens)
- Links of other dashboards in the search bar, a keyword per link, a status history or alerts
- Info pills (Sonarr, SABnzbd, server status) and a Home Assistant card: each needs its own
integration and an API key on the server
- Email verification / password reset mail (needs an SMTP setup)
- In CI: version tags and releases, a Helm chart, an image vulnerability scan (typst-workspace has all three)