YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: Open Reminders button uses opener plugin instead of shell plugin
Louis Beaumontef6d5e386391
diff --git a/apps/screenpipe-app-tauri/components/settings/apple-intelligence-card.tsx b/apps/screenpipe-app-tauri/components/settings/apple-intelligence-card.tsxindex ee319a19b..a23c677f7 100644--- a/apps/screenpipe-app-tauri/components/settings/apple-intelligence-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/apple-intelligence-card.tsx@@ -16,6 +16,7 @@ import {} from "lucide-react";import { platform } from "@tauri-apps/plugin-os";import { invoke } from "@tauri-apps/api/core";+import { openUrl } from "@tauri-apps/plugin-opener";import posthog from "posthog-js";const API = "http://localhost:3030";@@ -402,12 +403,7 @@ export function AppleIntelligenceCard() {<Buttonvariant="outline"size="sm"- onClick={async () => {- const { open } = await import(- "@tauri-apps/plugin-shell"- );- await open("x-apple-reminderkit://");- }}+ onClick={() => openUrl("x-apple-reminderkit://")}className="text-xs"><ExternalLink className="h-3 w-3 mr-1.5" />diff --git a/packages/ai-gateway/src/services/usage-tracker.ts b/packages/ai-gateway/src/services/usage-tracker.tsindex d9a4a7039..81aef2a68 100644--- a/packages/ai-gateway/src/services/usage-tracker.ts+++ b/packages/ai-gateway/src/services/usage-tracker.ts@@ -1,5 +1,70 @@import { Env, UserTier, TierLimits, UsageResult, UsageStatus } from '../types';+/**+ * Try to deduct 1 credit from user's balance via Supabase RPC.+ * Returns remaining balance or -1 if insufficient/error.+ */+async function tryDeductCredit(env: Env, userId: string, reason: string): Promise<{ success: boolean; remaining: number }> {+ if (!userId) return { success: false, remaining: 0 };++ try {+ const response = await fetch(`${env.SUPABASE_URL}/rest/v1/rpc/deduct_credits`, {+ method: 'POST',+ headers: {+ apikey: env.SUPABASE_ANON_KEY,+ Authorization: `Bearer ${env.SUPABASE_ANON_KEY}`,+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify({+ p_user_id: userId,+ p_amount: 1,+ p_type: reason,+ p_description: `${reason} via ai gateway`,+ p_reference_id: `gw-${Date.now()}`,+ }),+ });++ if (!response.ok) {+ console.error('deduct_credits error:', await response.text());+ return { success: false, remaining: 0 };+ }++ const result = await response.json() as Array<{ success: boolean; new_balance: number; error_message: string | null }>;+ if (Array.isArray(result) && result.length > 0 && result[0].success) {+ return { success: true, remaining: result[0].new_balance };+ }+ return { success: false, remaining: 0 };+ } catch (error) {+ console.error('credit deduction failed:', error);+ return { success: false, remaining: 0 };+ }+}++/**+ * Get user's current credit balance without deducting.+ */+async function getCreditBalance(env: Env, userId: string): Promise<number> {+ if (!userId) return 0;++ try {+ const response = await fetch(+ `${env.SUPABASE_URL}/rest/v1/user_credits?select=balance&user_id=eq.${encodeURIComponent(userId)}&limit=1`,+ {+ headers: {+ apikey: env.SUPABASE_ANON_KEY,+ Authorization: `Bearer ${env.SUPABASE_ANON_KEY}`,+ },+ }+ );++ if (!response.ok) return 0;+ const rows = await response.json() as Array<{ balance: number }>;+ return rows.length > 0 ? rows[0].balance : 0;+ } catch {+ return 0;+ }+}+// IP-based abuse prevention limits (on top of device limits)const IP_DAILY_LIMIT = 200; // Max queries per IP per day (catches device ID spoofing)@@ -117,12 +182,31 @@ export async function trackUsage(} else {// Check limit BEFORE incrementing — don't inflate counter on rejected requestsif (existing.daily_count >= limits.dailyQueries) {+ // Daily free quota exhausted — try credit fallback+ if (userId) {+ const credit = await tryDeductCredit(env, userId, 'ai_query');+ if (credit.success) {+ console.log(`credit deducted for ${userId}, remaining: ${credit.remaining}`);+ return {+ used: existing.daily_count,+ limit: limits.dailyQueries,+ remaining: 0,+ allowed: true,+ resetsAt: getNextResetTime(),+ paidVia: 'credits',+ creditsRemaining: credit.remaining,+ };+ }+ }+ // No credits available — check balance for error response+ const balance = userId ? await getCreditBalance(env, userId) : 0;return {used: existing.daily_count,limit: limits.dailyQueries,remaining: 0,allowed: false,resetsAt: getNextResetTime(),+ creditsRemaining: balance,};}// Increment countdiff --git a/packages/ai-gateway/src/types.ts b/packages/ai-gateway/src/types.tsindex f42db5574..a3d8883f7 100644--- a/packages/ai-gateway/src/types.ts+++ b/packages/ai-gateway/src/types.ts@@ -174,6 +174,10 @@ export interface UsageResult {remaining: number;allowed: boolean;resetsAt: string;+ /** Set when request was allowed by deducting a credit */+ paidVia?: 'free' | 'credits';+ /** Current credit balance (included in both success and failure) */+ creditsRemaining?: number;}// Usage status response