Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/api/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
```bash
# REPO="SOMEWHERE" ($HOME/repos/hyprnote inside Devin)
infisical export \
--env=dev \
--secret-overriding=false \
--format=dotenv \
--output-file="$REPO/apps/api/.env" \
--output-file="apps/api/.env" \
--projectId=87dad7b5-72a6-4791-9228-b3b86b169db1 \
--path="/ai"
```
4 changes: 2 additions & 2 deletions apps/api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ async fn app() -> Router {
)
.build();

let auth_state_pro =
AuthState::new(&env.supabase.supabase_url).with_required_entitlement("hyprnote_pro");
let auth_state_pro = AuthState::new(&env.supabase.supabase_url)
.with_required_entitlements(vec!["hyprnote_pro".into(), "hyprnote_lite".into()]);
let auth_state_basic = AuthState::new(&env.supabase.supabase_url);
let auth_state_support = AuthState::new(&env.supabase.supabase_url);

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub async fn rate_limit(
}

if let Some(auth) = request.extensions().get::<AuthContext>() {
let limiter = if auth.claims.is_pro() {
let limiter = if auth.claims.is_paid() {
&state.limiter_pro
} else {
&state.limiter_free
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</style>
<script src="/relay-shim.js"></script>
<script type="module">
if (import.meta.env.DEV) {
if (import.meta.env.DEV && !window.location.pathname.startsWith("/app/control")) {
import("react-scan").then(({ scan }) => {
scan();
});
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@ai-sdk/openai": "^3.0.39",
"@ai-sdk/openai-compatible": "^2.0.35",
"@ai-sdk/react": "^3.0.118",
"@hypr/pricing": "workspace:^",
"@codemirror/autocomplete": "^6.20.0",
"@codemirror/lang-jinja": "^6.0.0",
"@codemirror/language": "^6.12.1",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/public/assets/github-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/desktop/public/assets/linear-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions apps/desktop/src/ai/hooks/useLLMConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export const useLLMConnection = (): LLMConnectionResult => {
modelId: current_llm_model,
providerConfig,
session: auth?.session,
isPro: billing.isPro,
isPaid: billing.isPaid,
}),
[
auth,
billing.isPro,
billing.isPaid,
current_llm_model,
current_llm_provider,
providerConfig,
Expand All @@ -119,14 +119,14 @@ const resolveLLMConnection = (params: {
modelId: string | undefined;
providerConfig: AIProviderStorage | undefined;
session: { access_token: string } | null | undefined;
isPro: boolean;
isPaid: boolean;
}): LLMConnectionResult => {
const {
providerId: rawProviderId,
modelId,
providerConfig,
session,
isPro,
isPaid,
} = params;

if (!rawProviderId) {
Expand Down Expand Up @@ -166,7 +166,7 @@ const resolveLLMConnection = (params: {

const context: ProviderEligibilityContext = {
isAuthenticated: !!session,
isPro,
isPaid,
config: { base_url: baseUrl, api_key: apiKey },
};

Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/auth/billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function BillingProvider({ children }: { children: ReactNode }) {
const isReady = !claimsQuery.isPending;

const canTrialQuery = useQuery({
enabled: !!auth?.session && !billing.isPro,
enabled: !!auth?.session && !billing.isPaid,
queryKey: [auth?.session?.user.id ?? "", "canStartTrial"],
queryFn: async () => {
const headers = auth?.getHeaders();
Expand All @@ -78,10 +78,10 @@ export function BillingProvider({ children }: { children: ReactNode }) {

const canStartTrial = useMemo(
() => ({
data: billing.isPro ? false : (canTrialQuery.data ?? false),
data: billing.isPaid ? false : (canTrialQuery.data ?? false),
isPending: canTrialQuery.isPending,
}),
[billing.isPro, canTrialQuery.data, canTrialQuery.isPending],
[billing.isPaid, canTrialQuery.data, canTrialQuery.isPending],
);

const upgradeToPro = useCallback(async () => {
Expand Down
41 changes: 16 additions & 25 deletions apps/desktop/src/calendar/components/oauth/provider-content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback, useMemo } from "react";

import type { ConnectionItem } from "@hypr/api-client";
import { commands as openerCommands } from "@hypr/plugin-opener2";
import {
Tooltip,
TooltipContent,
Expand All @@ -18,12 +17,12 @@ import { useAuth } from "~/auth";
import { useBillingAccess } from "~/auth/billing";
import { useConnections } from "~/auth/useConnections";
import type { CalendarProvider } from "~/calendar/components/shared";
import { buildWebAppUrl } from "~/shared/utils";
import { openIntegrationUrl } from "~/shared/integration";

export function OAuthProviderContent({ config }: { config: CalendarProvider }) {
const auth = useAuth();
const { isPro, upgradeToPro } = useBillingAccess();
const { data: connections, isError } = useConnections(isPro);
const { isPaid, upgradeToPro } = useBillingAccess();
const { data: connections, isError } = useConnections(isPaid);
const providerConnections = useMemo(
() =>
connections?.filter(
Expand All @@ -33,7 +32,13 @@ export function OAuthProviderContent({ config }: { config: CalendarProvider }) {
);

const handleAddAccount = useCallback(
() => openIntegrationUrl(config.nangoIntegrationId, undefined, "connect"),
() =>
openIntegrationUrl(
config.nangoIntegrationId,
undefined,
"connect",
"calendar",
),
[config.nangoIntegrationId],
);

Expand All @@ -57,14 +62,14 @@ export function OAuthProviderContent({ config }: { config: CalendarProvider }) {
);
}

if (!isPro) {
if (!isPaid) {
return (
<div className="pt-1 pb-2">
<button
onClick={upgradeToPro}
className="cursor-pointer text-xs text-neutral-600 underline transition-colors hover:text-neutral-900"
>
Upgrade to Pro to connect
Upgrade to connect
</button>
</div>
);
Expand All @@ -86,13 +91,15 @@ export function OAuthProviderContent({ config }: { config: CalendarProvider }) {
config.nangoIntegrationId,
connection.connection_id,
"reconnect",
"calendar",
)
}
onDisconnect={() =>
openIntegrationUrl(
config.nangoIntegrationId,
connection.connection_id,
"disconnect",
"calendar",
)
}
errorDescription={connection.last_error_description ?? null}
Expand Down Expand Up @@ -199,6 +206,7 @@ function ConnectedContent({
config.nangoIntegrationId,
connection.connection_id,
"reconnect",
"calendar",
),
},
{
Expand All @@ -209,6 +217,7 @@ function ConnectedContent({
config.nangoIntegrationId,
connection.connection_id,
"disconnect",
"calendar",
),
},
],
Expand All @@ -225,21 +234,3 @@ function ConnectedContent({
/>
);
}

export async function openIntegrationUrl(
nangoIntegrationId: string | undefined,
connectionId: string | undefined,
action: "connect" | "reconnect" | "disconnect",
) {
if (!nangoIntegrationId) return;
const params: Record<string, string> = {
action,
integration_id: nangoIntegrationId,
return_to: "calendar",
};
if (connectionId) {
params.connection_id = connectionId;
}
const url = await buildWebAppUrl("/app/integration", params);
await openerCommands.openUrl(url, null);
}
Loading
Loading