Repository navigation
Add AI stock rankings page with subscription gating #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
423d912
Add AI stock rankings page with subscription gating
cursoragent 3e17601
Fix Prettier formatting for AI rankings files
cursoragent 5055077
Rename AI rankings to Ranking at /ranking
cursoragent 401569d
Replace Ranking cards with screener-style table
cursoragent 3f56dcd
Slim main nav and add Ditectrev-style footer
cursoragent a97f663
Restore GitHub star and refine Ditectrev-style footer
cursoragent 0a17786
Improve ranking contrast and add buy/sell sides
cursoragent 6114cc1
Update ranking page SEO copy for buy/sell lists
cursoragent 73b3c67
Defer footer load to restore Lighthouse performance
cursoragent cc20412
Add heatmap-aligned categories to Ranking
cursoragent 1862f8f
Fix ETF and crypto ranking candidate enrichment
cursoragent 516db53
Fix ETF/crypto ranking quotes via market data pipeline
cursoragent 2a1d50b
Remove unsupported environmentMatchGlobs from vitest config
cursoragent 5f82ac1
Fix sell ranking score inversion and stale fetch race condition
cursoragent 1e03cb3
Fix loading spinner stuck after access loss
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Metadata } from "next"; | ||
| import { LegalPlaceholderPage } from "@/components/LegalPlaceholderPage"; | ||
| import { buildPageMetadata } from "@/lib/site-seo"; | ||
|
|
||
| export const metadata: Metadata = buildPageMetadata({ | ||
| title: "Copyrights", | ||
| description: "Copyrights for The Open Stock.", | ||
| path: "/copyrights", | ||
| }); | ||
|
|
||
| export default function CopyrightsPage() { | ||
| return <LegalPlaceholderPage title="Copyrights" />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Metadata } from "next"; | ||
| import { LegalPlaceholderPage } from "@/components/LegalPlaceholderPage"; | ||
| import { buildPageMetadata } from "@/lib/site-seo"; | ||
|
|
||
| export const metadata: Metadata = buildPageMetadata({ | ||
| title: "Privacy & Security", | ||
| description: "Privacy and security for The Open Stock.", | ||
| path: "/privacy-and-security", | ||
| }); | ||
|
|
||
| export default function PrivacyAndSecurityPage() { | ||
| return <LegalPlaceholderPage title="Privacy & Security" />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { Metadata } from "next"; | ||
| import { buildPageMetadata } from "@/lib/site-seo"; | ||
|
|
||
| export const metadata: Metadata = buildPageMetadata({ | ||
| title: "Ranking", | ||
| description: | ||
| "Ranked buy and sell lists for ETFs, crypto, and stocks across short, medium, and long horizons — each pick validated with live quotes, technicals, and analyst data.", | ||
| path: "/ranking", | ||
| }); | ||
|
|
||
| export default function RankingLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| return children; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import Link from "next/link"; | ||
| import { usePricingTier } from "@/lib/use-pricing-tier"; | ||
| import { EXPLANATIONS_PROVIDER_CHANGED_EVENT } from "@/lib/explanation-provider"; | ||
| import { fetchAIStockRankingsForCurrentProvider } from "@/lib/local-ollama-ai-rankings"; | ||
| import { MARKET_UI_COPY } from "@/lib/market-ui-copy"; | ||
| import { | ||
| DNA_BODY_SECONDARY, | ||
| DNA_DISPLAY, | ||
| DNA_PAGE_STACK, | ||
| } from "@/lib/design-dna"; | ||
| import { HOME_SUBTLE_TEXT } from "@/lib/home-ui"; | ||
| import type { | ||
| AIRankingCategory, | ||
| AIRankingTimeframe, | ||
| AIStockRankingsResult, | ||
| } from "@/types"; | ||
| import { AIStockRankingsPanel } from "@/components/AIStockRankingsPanel"; | ||
|
|
||
| export default function AIStockRankingsPage() { | ||
| const pricingTier = usePricingTier(); | ||
| const [serverBYOKAccess, setServerBYOKAccess] = useState<boolean | null>( | ||
| null | ||
| ); | ||
| const hasTierAccess = | ||
| pricingTier === "LOCAL" || | ||
| pricingTier === "BYOK" || | ||
| pricingTier === "HOSTED_AI"; | ||
| const hasAIAccess = hasTierAccess || serverBYOKAccess === true; | ||
|
|
||
| const [category, setCategory] = useState<AIRankingCategory>("stock"); | ||
| const [timeframe, setTimeframe] = useState<AIRankingTimeframe>("short"); | ||
| const [data, setData] = useState<AIStockRankingsResult | null>(null); | ||
| const [loading, setLoading] = useState(false); | ||
| const [loadError, setLoadError] = useState<string | null>(null); | ||
| const [aiProviderVersion, setAiProviderVersion] = useState(0); | ||
|
|
||
| useEffect(() => { | ||
| const onProviderChanged = () => setAiProviderVersion((v) => v + 1); | ||
| window.addEventListener( | ||
| EXPLANATIONS_PROVIDER_CHANGED_EVENT, | ||
| onProviderChanged | ||
| ); | ||
| return () => | ||
| window.removeEventListener( | ||
| EXPLANATIONS_PROVIDER_CHANGED_EVENT, | ||
| onProviderChanged | ||
| ); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| let cancelled = false; | ||
|
|
||
| const load = async () => { | ||
| if (!hasAIAccess) { | ||
| setData(null); | ||
| setLoadError(null); | ||
| setLoading(false); | ||
| return; | ||
| } | ||
|
|
||
| setLoading(true); | ||
| setData(null); | ||
| try { | ||
| const result = await fetchAIStockRankingsForCurrentProvider( | ||
| timeframe, | ||
| category, | ||
| pricingTier | ||
| ); | ||
| if (cancelled) return; | ||
| setData(result); | ||
| setLoadError(null); | ||
| } catch (err) { | ||
| if (cancelled) return; | ||
| setData(null); | ||
| setLoadError( | ||
| err instanceof Error | ||
| ? err.message | ||
| : MARKET_UI_COPY.load.aiStockRankings | ||
| ); | ||
| } finally { | ||
| if (!cancelled) { | ||
| setLoading(false); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| load(); | ||
|
|
||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, [hasAIAccess, aiProviderVersion, pricingTier, timeframe, category]); | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| useEffect(() => { | ||
| const loadBYOKAccess = async () => { | ||
| try { | ||
| const response = await fetch("/api/ai/keys", { | ||
| method: "GET", | ||
| credentials: "include", | ||
| cache: "no-store", | ||
| }); | ||
| setServerBYOKAccess(response.ok); | ||
| } catch { | ||
| setServerBYOKAccess(false); | ||
| } | ||
| }; | ||
| void loadBYOKAccess(); | ||
| const onAuthChanged = () => void loadBYOKAccess(); | ||
| if (typeof window !== "undefined") { | ||
| window.addEventListener("auth-state-changed", onAuthChanged); | ||
| } | ||
| return () => { | ||
| if (typeof window !== "undefined") { | ||
| window.removeEventListener("auth-state-changed", onAuthChanged); | ||
| } | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div className={DNA_PAGE_STACK} data-testid="ranking-page"> | ||
| <header className="space-y-2"> | ||
| <h1 className={DNA_DISPLAY}>Ranking</h1> | ||
| <p className={DNA_BODY_SECONDARY}> | ||
| Ranked buy and sell lists for ETFs, crypto, and stocks across short, | ||
| medium, and long horizons — each row includes a clear rationale. | ||
| </p> | ||
| <p className={`text-xs ${HOME_SUBTLE_TEXT}`}> | ||
| Related:{" "} | ||
| <Link | ||
| href="/stock-of-the-day" | ||
| className="underline underline-offset-2" | ||
| > | ||
| Stock of the day | ||
| </Link> | ||
| </p> | ||
| </header> | ||
|
|
||
| <AIStockRankingsPanel | ||
| data={data} | ||
| loading={loading} | ||
| locked={!hasAIAccess} | ||
| error={loadError} | ||
| pricingTier={pricingTier} | ||
| category={category} | ||
| onCategoryChange={setCategory} | ||
| timeframe={timeframe} | ||
| onTimeframeChange={setTimeframe} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Metadata } from "next"; | ||
| import { LegalPlaceholderPage } from "@/components/LegalPlaceholderPage"; | ||
| import { buildPageMetadata } from "@/lib/site-seo"; | ||
|
|
||
| export const metadata: Metadata = buildPageMetadata({ | ||
| title: "Sitemap", | ||
| description: "Sitemap for The Open Stock.", | ||
| path: "/sitemap", | ||
| }); | ||
|
|
||
| export default function SitemapPage() { | ||
| return <LegalPlaceholderPage title="Sitemap" />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Metadata } from "next"; | ||
| import { LegalPlaceholderPage } from "@/components/LegalPlaceholderPage"; | ||
| import { buildPageMetadata } from "@/lib/site-seo"; | ||
|
|
||
| export const metadata: Metadata = buildPageMetadata({ | ||
| title: "Terms of Use", | ||
| description: "Terms of use for The Open Stock.", | ||
| path: "/terms-of-use", | ||
| }); | ||
|
|
||
| export default function TermsOfUsePage() { | ||
| return <LegalPlaceholderPage title="Terms of Use" />; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.