mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #466] [MERGED] feat(extensions): server-side storage for cross-device sync #4631
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4631
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/466
Author: @Romuromylus
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @Romuromylus
Base:
main← Head:feat/extensions-server-storage📝 Commits (5)
ee142e3feat(extensions): server-side storage for cross-device sync8a9884cMerge branch 'main' into feat/extensions-server-storagebd0e1c3fix(extensions): address review feedback + restore swipe-nav toggles44b1a5adocs(changelog): note cross-device extension sync under 1.5.8bb00a57Revert "docs(changelog): note cross-device extension sync under 1.5.8"📊 Changes
17 files changed (+499 additions, -59 deletions)
View changed files
📝
packages/client/src/App.tsx(+2 -0)📝
packages/client/src/components/layout/CustomThemeInjector.tsx(+33 -4)📝
packages/client/src/components/panels/SettingsPanel.tsx(+41 -36)➕
packages/client/src/hooks/use-extensions.ts(+148 -0)📝
packages/client/src/stores/ui.store.ts(+27 -19)📝
packages/server/drizzle.config.cts(+1 -0)📝
packages/server/src/db/file-backed-store.ts(+1 -0)📝
packages/server/src/db/migrate.ts(+11 -0)➕
packages/server/src/db/schema/extensions.ts(+16 -0)📝
packages/server/src/db/schema/index.ts(+1 -0)📝
packages/server/src/middleware/rate-limit.ts(+4 -0)➕
packages/server/src/routes/extensions.routes.ts(+46 -0)📝
packages/server/src/routes/index.ts(+2 -0)➕
packages/server/src/services/storage/extensions.storage.ts(+77 -0)📝
packages/shared/src/index.ts(+2 -0)➕
packages/shared/src/schemas/extension.schema.ts(+60 -0)➕
packages/shared/src/types/extension.ts(+27 -0)📄 Description
Linked issue
Closes #465
Why this change
Extensions in Marinara are stored in browser
localStorage, so they're per-device + per-browser. A user on desktop + phone has to import each extension twice and toggle each one's enabled state separately on every device. Custom themes already solve this with server-side storage +useLegacyThemeMigration— extensions should follow the same pattern.This is the storage slice of @kolacheee's earlier proposal in #431. This PR keeps the loader exactly as-is and only changes where the extension list lives.
What changed
New (server):
installed_extensionstable — both file-backed (FILE_BACKED_TABLES) and legacy SQLite (migrate.tsCREATE TABLE)./api/extensionsCRUD route (GET /,POST /,PATCH /:id,DELETE /:id). No script-serving endpoint.New (shared):
InstalledExtensiontype +createExtensionSchema/updateExtensionSchemazod schemas, with.max()size caps oncss(256 KiB) andjs(1 MiB).New (client):
useExtensions()/useCreateExtension()/useUpdateExtension()/useDeleteExtension()React Query hooks.useExtensions()mirrorsuseThemes()exactly:staleTime: 0,refetchOnWindowFocus: true,refetchOnReconnect: true,refetchInterval: 15s.useLegacyExtensionMigration()— one-shot replay of pre-migrationlocalStorageentries against/api/extensions, dedupe byname + css + js, then flip ahasMigratedExtensionsToServerflag.Modified (client, surgical):
CustomThemeInjector.tsx— data source switches fromuseUIStore((s) => s.installedExtensions)touseExtensions(). Loader code (theimport(blob:URL)pipeline, IIFE wrapper, API map management) is unchanged. Plus an extension-sideapiFetchdenylist for/extensions/*and/admin/*(a malicious extension shouldn't be able to re-install itself after deletion or pivot to admin endpoints).SettingsPanel.tsx— extension actions switch from Zustand mutators to React Query mutations.App.tsx— wiresuseLegacyExtensionMigration()next touseLegacyThemeMigration().ui.store.ts— renamesInstalledExtensiontoLegacyInstalledExtension(kept solely for migration replay), removesaddExtension/removeExtension/toggleExtensionactions, adds migration helpers + flag, bumps persist version17 → 18with a one-line migration step.rate-limit.ts— new entry:/api/extensionscapped at 60 req/min/IP.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What was verified by the contributor on a private staging instance:
pnpm check— passes on this branch (TS + ESLint + production build).localStoragefrom a pre-PR build → on first load after upgrade, all extensions migrate to/api/extensions,localStorageis cleared, migration flag flips, no duplicates.apiFetchdenylist — an extension that callsmarinara.apiFetch("/extensions", ...)(any method) is rejected with a denial error before any network request is made./admin/*likewise denied. Allowed control:marinara.apiFetch("/themes")succeeds.js.max()rejects server-side). 256 KiB CSS / 1 MiB JS caps confirmed enforced./api/extensionscovers React Query polling + legacy migration of any reasonable extension count without affecting normal use.Docs and release impact
Reviewer to decide whether
CHANGELOG.mdshould mention this for the next minor release. Happy to add a one-liner if you want it noted.UI evidence (if applicable)
The Settings → Extensions panel UI is unchanged in look and feel — same import button, same enable/disable/delete row controls. The only behavior difference is that mutations now hit the server instead of
localStorage. Cross-device sync is invisible to the user except as "extensions appear on my other device."Credit: storage layer + migration shape adapted from @kolacheee's earlier work in #431. Thanks to them for surfacing the cross-device gap.
Summary by CodeRabbit
New Features
Chores
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.