Skip to content

Commit c5917a5

Browse files
feat: implement memory entry synchronization functions and schemas (#71)
* feat: implement memory entry synchronization functions and schemas * feat: implement authentication service and integrate with UI components * refactor: remove debug log for authentication status in App component * feat: implement PKCE for secure OAuth flow and enhance auth logging * fix: remove unnecessary response_type parameter and add extension metadata to token request * feat(sync): integrate Convex for synchronization and add auto-sync functionality - Added Convex as a dependency for synchronization. - Implemented ConvexClientManager to manage Convex client initialization and authentication. - Created SyncService to handle sync operations (push, pull, full sync) with remote storage. - Introduced AutoSyncManager to manage automatic synchronization triggers. - Updated auth store to authenticate sync service upon successful login. - Enhanced memory store to trigger debounced push sync after memory operations. - Added sync state management to handle sync operations and errors. - Refactored provider-key-input component to clean up imports. - Improved background script to check auth status and trigger startup sync. - Updated options and popup components to include necessary imports and hooks. * wip: supabase auth check in sync service * feat(auth): implement OAuth login flow with Supabase and add LoginDialog component * refactor: reorganize imports and improve type definitions across multiple files * feat: refactor storage structure by replacing securityStorage with apiKeys and syncStateAndSettings * feat: update @types/node to version 24.10.1 and format tsconfig.json for consistency * refactor: update authentication check to use getUser instead of getSession * refactor: remove unused crypto-utils functions and update Supabase client configuration * refactor: enhance trigger-settings and theme-provider imports; update permissions in wxt.config * refactor: remove unused flowType configuration from Supabase client * fix: improve memory sync handling by ensuring null values for optional fields * feat: implement sync functionality with manual trigger and status handling * fix: enhance loading state handling and improve code formatting in App components * feat: enhance authentication flow and sync functionality across components * feat: add cloud models support and settings management across components * fix: update WXT_WEBSITE_URL in .env.example for consistency * feat: enhance database types with payments, subscriptions, and webhook logs support * fix: reduce authentication wait timeout from 300s to 120s and update cloud models toggle behavior for unauthenticated users * chore: update dependencies to latest versions - upgraded @opentelemetry/sdk-trace-web from ^2.2.0 to ^2.3.0 - upgraded @supabase/supabase-js from ^2.81.1 to ^2.90.1 - upgraded ai from ^5.0.117 to ^5.0.118 - upgraded use-debounce from ^10.0.6 to ^10.1.0 - upgraded zod from ^4.3.4 to ^4.3.5 - upgraded @typescript/native-preview from ^7.0.0-dev.20260102.1 to ^7.0.0-dev.20260109.1 * fix: update service registration order and sync service import * feat: adjust logging verbosity from info to debug This is for routine operations and refine user authentication context in the sync service. * fix: reorder key validation service registration and ensure message listener returns a promise * feat: integrate capture memory service and add message handler for saving captured memories * feat: integrate cloud AI features for categorization and deduplication - Added cloud AI support for bulk categorization and deduplication in the BulkCategorizer and DeduplicationCategorizer classes. - Implemented cloud-based categorization and rephrasing in the CategorizationService. - Introduced cloud-client module for handling API requests to the cloud service. - Enhanced the AIMatcher to utilize cloud models for field matching. - Added toast notifications for cloud AI usage and quota limits. - Updated UI components to display cloud usage status and settings. - Refactored existing code to support cloud functionality and improve maintainability. * feat: enhance CloudUsageDisplay with compact mode and tooltip for better usage insights * refactor: remove compact mode from CloudUsageDisplay component * feat: Implement pending deletion queue and sync process for memory entries. * feat: Integrate cloud usage tracking and enhance alert system for cloud model limits * feat: refactor cloud usage handling and improve cache invalidation logic * fix: simplify Separator component usage in AiProviderSettings * fix: update existingMemoryId type to use z.uuid() in DeduplicationOperationSchema * feat: update biome schema version, refactor useAuth hook with React Query, and implement sync cooldown logic * fix: streamline includes formatting in biome.json * feat: implement content hash computation for memory entries and update related schemas * Merge branch 'main' of https://github.com/mikr13/superfill.ai into phase-2 * feat: update changeset to reflect addition of subscription service * feat: enhance user feedback for pending account approval in auth components * feat: add environment variable validation for release workflow * feat: improve toast manager UI handling and theme application * fix: update version type for subscription service to minor * fix: conditionally include localhost permission in manifest * fix: reorder installation of dependencies in CI workflow * fix: improve usage percentage calculation and update database types for cloud usage * fix: reorder imports for better organization in use-auth hook * fix: refactor useAuth hook to streamline user status fetching and improve state management * fix: replace autoSyncManager with direct call to performFullSync during startup sync * fix: update deduplication schemas to use TagSchema and improve type definitions * fix: ensure cloud usage status is checked before displaying alert for active cloud models * fix: centralize ToastType definition and update imports across components * fix: enhance error handling in cloud categorization and rephrasing, and update timestamp fields to ISO string format in sync types --------- Co-authored-by: Mihir Kumar <mihir.kumar-ext@ab-Inbev.com>
1 parent a790d17 commit c5917a5

57 files changed

Lines changed: 4550 additions & 722 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/curvy-banks-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"superfill.ai": minor
3+
---
4+
5+
feat: subscription service added

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Environment Variables for SuperFill Extension
22

3+
# Website URL for authentication
4+
# In production, this should be https://superfill.ai
5+
# In development, use http://localhost:3002
6+
WXT_WEBSITE_URL=https://superfill.ai
7+
8+
# Supabase Configuration
9+
# Get these from your Supabase project settings
10+
WXT_SUPABASE_URL=https://your-project.supabase.co
11+
WXT_SUPABASE_PUBLISHABLE_KEY=your-supabase-publishable-key
12+
313
# Skip onboarding flow for local development (optional)
414
# Set this to 'true' to skip the onboarding dialog during development
515
# VITE_SKIP_ONBOARDING=true

.github/workflows/ci-release.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ permissions:
99
jobs:
1010
submit:
1111
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
12+
env:
13+
WXT_WEBSITE_URL: ${{ secrets.WXT_WEBSITE_URL }}
14+
WXT_SUPABASE_URL: ${{ secrets.WXT_SUPABASE_URL }}
15+
WXT_SUPABASE_PUBLISHABLE_KEY: ${{ secrets.WXT_SUPABASE_PUBLISHABLE_KEY }}
1216
steps:
1317
- uses: actions/checkout@v6
1418

1519
- uses: oven-sh/setup-bun@v2
1620
with:
1721
bun-version: latest
1822

23+
- name: Validate required env
24+
run: |
25+
[[ -n "$WXT_WEBSITE_URL" ]] || { echo "Missing WXT_WEBSITE_URL"; exit 1; }
26+
[[ -n "$WXT_SUPABASE_URL" ]] || { echo "Missing WXT_SUPABASE_URL"; exit 1; }
27+
[[ -n "$WXT_SUPABASE_PUBLISHABLE_KEY" ]] || { echo "Missing WXT_SUPABASE_PUBLISHABLE_KEY"; exit 1; }
28+
1929
- name: Install dependencies
2030
run: bun install
2131

bun.lock

Lines changed: 290 additions & 489 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"copy-pdfjs-worker": "node scripts/copy-pdfjs-worker.js",
2424
"format": "biome check --write",
2525
"lint": "bun run format",
26+
"db:types": "bunx supabase gen types typescript --project-id nybgpislnqwqbcbyhzpp > src/lib/supabase/database.types.ts",
2627
"changeset": "changeset",
2728
"changeset:add": "changeset add",
2829
"changeset:status": "changeset status",
@@ -64,6 +65,7 @@
6465
"@radix-ui/react-toggle": "^1.1.10",
6566
"@radix-ui/react-toggle-group": "^1.1.11",
6667
"@radix-ui/react-tooltip": "^1.2.8",
68+
"@supabase/supabase-js": "^2.90.1",
6769
"@tailwindcss/vite": "^4.1.18",
6870
"@tanstack/react-form": "^1.27.7",
6971
"@tanstack/react-query": "^5.90.19",
@@ -85,6 +87,7 @@
8587
"react-day-picker": "^9.13.0",
8688
"react-dom": "^19.2.3",
8789
"react-hotkeys-hook": "^5.2.3",
90+
"react-icons": "^5.5.0",
8891
"react-resizable-panels": "^3.0.6",
8992
"shadcn": "^3.8.2",
9093
"sonner": "^2.0.7",
@@ -100,6 +103,7 @@
100103
"@biomejs/biome": "2.3.14",
101104
"@changesets/changelog-github": "^0.5.2",
102105
"@changesets/cli": "^2.29.8",
106+
"@types/node": "24.10.1",
103107
"@types/react": "^19.2.8",
104108
"@types/react-dom": "^19.2.3",
105109
"@types/uuid": "^11.0.0",

src/assets/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* biome-ignore-all lint: all G here */
12
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap");
23
@import "tailwindcss";
34
@import "tw-animate-css";
@@ -267,6 +268,5 @@
267268
}
268269

269270
.toaster.group [data-description] {
270-
/* biome-ignore lint/complexity/noImportantStyles: it's fine here */
271271
color: var(--color-popover-foreground) !important;
272272
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { ExternalLink } from "lucide-react";
2+
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
3+
import { Button } from "@/components/ui/button";
4+
import {
5+
Dialog,
6+
DialogContent,
7+
DialogDescription,
8+
DialogHeader,
9+
DialogTitle,
10+
} from "@/components/ui/dialog";
11+
import { Spinner } from "@/components/ui/spinner";
12+
import { useAuth } from "@/hooks/use-auth";
13+
import { createLogger } from "@/lib/logger";
14+
15+
interface LoginDialogProps {
16+
open: boolean;
17+
onOpenChange: (open: boolean) => void;
18+
}
19+
20+
const logger = createLogger("login-dialog");
21+
22+
export function LoginDialog({ open, onOpenChange }: LoginDialogProps) {
23+
const { signIn, signingIn, pendingApproval, inactiveMessage } = useAuth();
24+
25+
const handleLogin = async () => {
26+
try {
27+
await signIn();
28+
onOpenChange(false);
29+
} catch (error) {
30+
logger.error("Login failed:", error);
31+
}
32+
};
33+
34+
const preventClose = (event: Event) => {
35+
event.preventDefault();
36+
};
37+
38+
return (
39+
<Dialog open={open} onOpenChange={onOpenChange}>
40+
<DialogContent
41+
className="sm:max-w-md"
42+
showCloseButton={false}
43+
onEscapeKeyDown={preventClose}
44+
onPointerDownOutside={preventClose}
45+
onInteractOutside={preventClose}
46+
>
47+
<DialogHeader>
48+
<DialogTitle className="text-2xl">Sign In</DialogTitle>
49+
<DialogDescription>
50+
Sign in to sync your memories across devices and access cloud
51+
features
52+
</DialogDescription>
53+
</DialogHeader>
54+
<div className="grid gap-4 py-4">
55+
{pendingApproval && (
56+
<Alert>
57+
<AlertTitle>Account pending approval</AlertTitle>
58+
<AlertDescription>
59+
{inactiveMessage ??
60+
"Cloud and sync features are disabled until your account is approved."}
61+
</AlertDescription>
62+
</Alert>
63+
)}
64+
65+
<Button
66+
variant="default"
67+
className="w-full"
68+
onClick={handleLogin}
69+
disabled={signingIn}
70+
>
71+
{signingIn ? (
72+
<>
73+
<Spinner className="size-4" />
74+
Checking for authentication...
75+
</>
76+
) : (
77+
<>
78+
<ExternalLink className="size-4" />
79+
Open Login Page
80+
</>
81+
)}
82+
</Button>
83+
</div>
84+
{signingIn && (
85+
<div className="space-y-2 text-sm text-muted-foreground">
86+
<p className="text-center">
87+
A new tab will open for authentication.
88+
</p>
89+
<p className="text-center">
90+
After logging in, return here and this dialog will automatically
91+
close.
92+
</p>
93+
</div>
94+
)}
95+
</DialogContent>
96+
</Dialog>
97+
);
98+
}

0 commit comments

Comments
 (0)